Jelajahi Sumber

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