浏览代码

Merge pull request #7602 from BabylonJS/drigax/fixLightsGizmo

Fix for light gizmo changing light transforms on activation.
David Catuhe 5 年之前
父节点
当前提交
9b93b1c1d6
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 8 1
      src/Gizmos/lightGizmo.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -328,6 +328,7 @@
 - Fix wrong import of _TimeToken ([Sebavan](https://github.com/sebavan/)
 - Fix shadows not rendered correctly when using point lights ([Popov72](https://github.com/Popov72))
 - Prevent depth buffer clear in shadow maps ([Sebavan](https://github.com/sebavan/)
+- Fix for bug where the light gizmo causes lights to flip orientation ([#7603](https://github.com/BabylonJS/Babylon.js/issues/7603)) ([drigax](https://github.com/drigax))
 
 ## Breaking changes
 

+ 8 - 1
src/Gizmos/lightGizmo.ts

@@ -85,9 +85,13 @@ export class LightGizmo extends Gizmo {
             // Get update position and direction if the light has it
             if ((light as any).position) {
                 this.attachedMesh!.position.copyFrom((light as any).position);
+                this.attachedMesh!.computeWorldMatrix(true);
+                this._cachedPosition.copyFrom(this.attachedMesh!.position);
             }
             if ((light as any).direction) {
                 this.attachedMesh!.setDirection((light as any).direction);
+                this.attachedMesh!.computeWorldMatrix(true);
+                this._cachedForward.copyFrom(this.attachedMesh!.forward);
             }
 
             this._update();
@@ -127,6 +131,8 @@ export class LightGizmo extends Gizmo {
             } else {
                 // update gizmo to match light
                 this.attachedMesh!.position.copyFrom((this._light as any).position);
+                this.attachedMesh!.computeWorldMatrix(true);
+                this._cachedPosition.copyFrom(this.attachedMesh!.position);
             }
 
         }
@@ -139,7 +145,8 @@ export class LightGizmo extends Gizmo {
             } else if (Vector3.DistanceSquared(this.attachedMesh!.forward, (this._light as any).direction) > 0.0001) {
                 // update gizmo to match light
                 this.attachedMesh!.setDirection((this._light as any).direction);
-                this._cachedForward.copyFrom(this._lightMesh.forward);
+                this.attachedMesh!.computeWorldMatrix(true);
+                this._cachedForward.copyFrom(this.attachedMesh!.forward);
             }
         }
         if (!this._light.isEnabled()) {