Skip to content

Commit

Permalink
Added modelOpacity to hand (#5431)
Browse files Browse the repository at this point in the history
* Added modelOpacity to hand

-Added modelOpacity to hand_tracking_controls schema
-changed updateModelColor to updateModelMaterial because it now updates opacity.

* Refined updateModelMaterial

-simplified the modelOpacity functionality
-added documentation
  • Loading branch information
ehammons11 authored Jan 14, 2024
1 parent 62514e8 commit 0bd3f5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/components/hand-tracking-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Use `hand-tracking-controls` to integrate [hand tracked input][webxrhandinput] i
|----------------|----------------------------------------------------------------------------------------|---------------|
| hand | The hand that will be tracked (i.e., right, left). | left |
| modelColor | Color of hand material. | white |
| modelOpacity | Opacity of the hand material. | 1.0 |
| modelStyle | Mesh representing the hand or dots matching the joints | mesh

## Events
Expand Down
12 changes: 9 additions & 3 deletions src/components/hand-tracking-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ module.exports.Component = registerComponent('hand-tracking-controls', {
schema: {
hand: {default: 'right', oneOf: ['left', 'right']},
modelStyle: {default: 'mesh', oneOf: ['dots', 'mesh']},
modelColor: {default: 'white'}
modelColor: {default: 'white'},
modelOpacity: {default: 1.0}
},

bindMethods: function () {
Expand Down Expand Up @@ -119,18 +120,23 @@ module.exports.Component = registerComponent('hand-tracking-controls', {
},

update: function () {
this.updateModelColor();
this.updateModelMaterial();
},

updateModelColor: function () {
updateModelMaterial: function () {
var jointEls = this.jointEls;
var skinnedMesh = this.skinnedMesh;
var transparent = !(this.data.modelOpacity === 1.0);
if (skinnedMesh) {
this.skinnedMesh.material.color.set(this.data.modelColor);
this.skinnedMesh.material.transparent.set(transparent);
this.skinnedMesh.material.opacity.set(this.data.modelOpacity);
}

for (var i = 0; i < jointEls.length; i++) {
jointEls[i].setAttribute('material', 'color', this.data.modelColor);
jointEls[i].setAttribute('material', 'transparent', transparent);

Check failure on line 138 in src/components/hand-tracking-controls.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Trailing spaces not allowed
jointEls[i].setAttribute('material', 'opacity', this.data.modelOpacity);

Check failure on line 139 in src/components/hand-tracking-controls.js

View workflow job for this annotation

GitHub Actions / Test Cases (16.x, latest)

Trailing spaces not allowed
}
},

Expand Down

0 comments on commit 0bd3f5c

Please sign in to comment.