Browse Source

Fix for issue with skeleton viewer lighting. Changed skeleton viewer initialization to use utility layer for mesh creation. Added utility layer lighting creation, adjusted light intensity to show surface detail

Nicholas Barlow 4 years ago
parent
commit
2037348b0b
1 changed files with 11 additions and 5 deletions
  1. 11 5
      src/Debug/skeletonViewer.ts

+ 11 - 5
src/Debug/skeletonViewer.ts

@@ -558,6 +558,7 @@ export class SkeletonViewer {
     private _revert(animationState: boolean): void {
         if (this.options.pauseAnimations) {
             this.scene.animationsEnabled = animationState;
+            this.utilityLayer?.utilityLayerScene!.animationsEnabled = animationState;
         }
     }
 
@@ -583,16 +584,17 @@ export class SkeletonViewer {
         }
 
         this._ready = false;
-        let scene = this.scene;
+        let utilityLayerScene = this.utilityLayer?.utilityLayerScene!;
         let bones: Bone[] = this.skeleton.bones;
         let spheres: Array<[Mesh, Bone]> = [];
         let spurs: Mesh[] = [];
 
-        const animationState = scene.animationsEnabled;
+        const animationState = this.scene.animationsEnabled;
 
         try {
             if (this.options.pauseAnimations) {
-                scene.animationsEnabled = false;
+                this.scene.animationsEnabled = false;
+                utilityLayerScene.animationsEnabled = false;
             }
 
             if (this.options.returnToRest) {
@@ -665,7 +667,7 @@ export class SkeletonViewer {
                                 },
                         sideOrientation: Mesh.DEFAULTSIDE,
                         updatable: false
-                    },  scene);
+                    },  utilityLayerScene);
 
                     let numVertices = spur.getTotalVertices();
                     let mwk: number[] = [], mik: number[] = [];
@@ -698,7 +700,7 @@ export class SkeletonViewer {
                     segments: 6,
                     diameter: sphereBaseSize,
                     updatable: true
-                }, scene);
+                }, utilityLayerScene);
 
                 const numVertices = sphere.getTotalVertices();
 
@@ -744,6 +746,10 @@ export class SkeletonViewer {
                 this.debugMesh.alwaysSelectAsActiveMesh = true;
             }
 
+            const light = this.utilityLayer!._getSharedGizmoLight();
+            light.includedOnlyMeshes = light.includedOnlyMeshes.concat(this.debugMesh!);
+            light.intensity = 0.7;
+
             this._revert(animationState);
             this.ready = true;
         } catch (err) {