Skip to content

Commit 589fea2

Browse files
committed
Trying to get SkeletonHelper to always be visible.
1 parent 2bc41ab commit 589fea2

4 files changed

Lines changed: 16 additions & 19 deletions

File tree

examples/js/BlendCharacter.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ THREE.BlendCharacter = function () {
3636
scope.skeletonHelper = new THREE.SkeletonHelper( scope.skeleton, 0.5, 1 );
3737
scope.add( scope.skeletonHelper );
3838

39-
scope.toggleShowBones( false );
39+
scope.showSkeleton( true );
4040

4141
// Loading is complete, fire the callback
4242
if ( onLoad !== undefined ) onLoad();
@@ -234,10 +234,9 @@ THREE.BlendCharacter = function () {
234234

235235
}
236236

237-
this.toggleShowBones = function( shouldShow ) {
237+
this.showSkeleton = function( boolean ) {
238238

239-
this.visible = !shouldShow;
240-
this.skeletonHelper.setVisible( shouldShow );
239+
this.skeletonHelper.setVisible( boolean );
241240

242241
}
243242

examples/js/BlendCharacterGui.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function BlendCharacterGui(animations) {
88

99
gui: null,
1010
"Lock Camera": false,
11-
"Show Bones": false,
11+
"Show Skeleton": true,
1212
"Time Scale": 1.0,
1313
"Step Size": 0.016,
1414
"Crossfade Time": 3.5,
@@ -20,9 +20,9 @@ function BlendCharacterGui(animations) {
2020

2121
var animations = animations;
2222

23-
this.shouldShowBones = function() {
23+
this.showSkeleton = function() {
2424

25-
return controls['Show Bones'];
25+
return controls['Show Skeleton'];
2626

2727
};
2828

@@ -49,7 +49,7 @@ function BlendCharacterGui(animations) {
4949
var blending = controls.gui.addFolder( 'Blend Tuning' );
5050

5151
settings.add( controls, "Lock Camera" ).onChange( controls.lockCameraChanged );
52-
settings.add( controls, "Show Bones" ).onChange( controls.showBonesChanged );
52+
settings.add( controls, "Show Skeleton" ).onChange( controls.showSkeletonChanged );
5353
settings.add( controls, "Time Scale", 0, 1, 0.01 );
5454
settings.add( controls, "Step Size", 0.01, 0.1, 0.01 );
5555
settings.add( controls, "Crossfade Time", 0.1, 6.0, 0.05 );
@@ -177,15 +177,15 @@ function BlendCharacterGui(animations) {
177177
window.dispatchEvent( new CustomEvent( 'toggle-lock-camera', data ) );
178178
}
179179

180-
controls.showBonesChanged = function() {
180+
controls.showSkeletonChanged = function() {
181181

182182
var data = {
183183
detail: {
184-
shouldShow: controls['Show Bones']
184+
shouldShow: controls['Show Skeleton']
185185
}
186186
}
187187

188-
window.dispatchEvent( new CustomEvent( 'toggle-show-bones', data ) );
188+
window.dispatchEvent( new CustomEvent( 'toggle-show-skeleton', data ) );
189189
}
190190

191191

examples/webgl_animation_skinning_blending.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
window.addEventListener( 'crossfade', onCrossfade );
9595
window.addEventListener( 'warp', onWarp );
9696
window.addEventListener( 'toggle-lock-camera', onLockCameraToggle );
97-
window.addEventListener( 'toggle-show-bones', onShowBonesToggle );
97+
window.addEventListener( 'toggle-show-skeleton', onShowSkeleton );
9898

9999
blendMesh = new THREE.BlendCharacter();
100100
blendMesh.load( "models/skinned/marine/marine_anims.js", start );
@@ -190,10 +190,10 @@
190190

191191
}
192192

193-
function onShowBonesToggle( event ) {
193+
function onShowSkeleton( event ) {
194194

195195
var shouldShow = event.detail.shouldShow;
196-
blendMesh.toggleShowBones( shouldShow );
196+
blendMesh.showSkeleton( shouldShow );
197197

198198
}
199199

src/extras/helpers/SkeletonHelper.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ THREE.SkeletonHelper = function ( skeleton, jointBoxSize, scaleRatio ) {
1818

1919
var bone = skeleton.bones[ i ];
2020
var boxGeometry = new THREE.BoxGeometry( boxSize, boxSize, boxSize );
21-
var boxMaterial = new THREE.MeshBasicMaterial();
21+
var boxMaterial = new THREE.MeshBasicMaterial( { depthTest: false, depthWrite: false } );
2222

2323
bone.helper = {};
2424
bone.helper.box = new THREE.Mesh( boxGeometry, boxMaterial );
@@ -29,18 +29,16 @@ THREE.SkeletonHelper = function ( skeleton, jointBoxSize, scaleRatio ) {
2929

3030
if ( bone.parent instanceof THREE.Bone ) {
3131

32-
var lineMaterial = new THREE.LineBasicMaterial();
32+
var lineMaterial = new THREE.LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false } );
3333
var lineGeometry = new THREE.Geometry();
3434

35-
lineMaterial.vertexColors = true;
36-
3735
lineGeometry.vertices.push( new THREE.Vector3() );
3836
lineGeometry.vertices.push( new THREE.Vector3() );
3937
lineGeometry.colors.push( new THREE.Color( 1, 1, 0 ) );
4038
lineGeometry.colors.push( new THREE.Color( 0, 0, 0 ) );
4139

4240
bone.helper.line = new THREE.Line( lineGeometry, lineMaterial );
43-
this.add( bone.helper.line);
41+
this.add( bone.helper.line );
4442

4543
}
4644

0 commit comments

Comments
 (0)