Przeglądaj źródła

Merge pull request #6715 from CedricGuillemet/RHLights

RH coords for hemispheric and spotlights
David Catuhe 6 lat temu
rodzic
commit
a72f0286f8

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

@@ -116,7 +116,7 @@
 - Do not call onError when creating a texture when falling back to another loader ([TrevorDev](https://github.com/TrevorDev))
 - Context loss should not cause PBR materials to render black or instances to stop rendering ([TrevorDev](https://github.com/TrevorDev))
 - Only cast pointer ray input when pointer is locked in webVR ([TrevorDev](https://github.com/TrevorDev))
-- Fix Right Hand coordinates with directional lights and shadows ([CedricGuillemet](https://github.com/CedricGuillemet))
+- Fix Right Hand coordinates with directional lights and shadows, hemispheric lights and spot lights ([CedricGuillemet](https://github.com/CedricGuillemet))
 - Avoid using default utility layer in gizmo manager to support multiple scenes ([TrevorDev](https://github.com/TrevorDev))
 - Fix bug when adding and removing observers in quick succession ([sable](https://github.com/thscott))
 - Cannon and Ammo forceUpdate will no longer cause an unexpected exception ([TrevorDev](https://github.com/TrevorDev))

+ 15 - 6
src/Lights/hemisphericLight.ts

@@ -91,12 +91,21 @@ export class HemisphericLight extends Light {
      */
     public transferToEffect(effect: Effect, lightIndex: string): HemisphericLight {
         var normalizeDirection = Vector3.Normalize(this.direction);
-        this._uniformBuffer.updateFloat4("vLightData",
-            normalizeDirection.x,
-            normalizeDirection.y,
-            normalizeDirection.z,
-            0.0,
-            lightIndex);
+        if (this.getScene().useRightHandedSystem) {
+            this._uniformBuffer.updateFloat4("vLightData",
+                -normalizeDirection.x,
+                -normalizeDirection.y,
+                -normalizeDirection.z,
+                0.0,
+                lightIndex);
+        } else {
+            this._uniformBuffer.updateFloat4("vLightData",
+                normalizeDirection.x,
+                normalizeDirection.y,
+                normalizeDirection.z,
+                0.0,
+                lightIndex);
+        }
         this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
         return this;
     }

+ 15 - 6
src/Lights/spotLight.ts

@@ -352,12 +352,21 @@ export class SpotLight extends ShadowLight {
             normalizeDirection = Vector3.Normalize(this.direction);
         }
 
-        this._uniformBuffer.updateFloat4("vLightDirection",
-            normalizeDirection.x,
-            normalizeDirection.y,
-            normalizeDirection.z,
-            this._cosHalfAngle,
-            lightIndex);
+        if (this.getScene().useRightHandedSystem) {
+            this._uniformBuffer.updateFloat4("vLightDirection",
+                -normalizeDirection.x,
+                -normalizeDirection.y,
+                -normalizeDirection.z,
+                this._cosHalfAngle,
+                lightIndex);
+        } else {
+            this._uniformBuffer.updateFloat4("vLightDirection",
+                normalizeDirection.x,
+                normalizeDirection.y,
+                normalizeDirection.z,
+                this._cosHalfAngle,
+                lightIndex);
+        }
 
         this._uniformBuffer.updateFloat4("vLightFalloff",
             this.range,