瀏覽代碼

Bug fixes to KHR_lights_punctual implementation

Gary Hsu 7 年之前
父節點
當前提交
7a1e5ea1a9
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 4 4
      loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts
  2. 1 1
      src/Lights/babylon.spotLight.ts

+ 4 - 4
loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts

@@ -68,8 +68,8 @@ module BABYLON.GLTF2.Extensions {
                 return this._loader.loadNodeAsync(context, node, babylonMesh => {
                 return this._loader.loadNodeAsync(context, node, babylonMesh => {
                     let babylonLight: Light;
                     let babylonLight: Light;
 
 
-                    const name = babylonMesh.name;
                     const light = ArrayItem.Get(extensionContext, this._lights, extension.light);
                     const light = ArrayItem.Get(extensionContext, this._lights, extension.light);
+                    const name = light.name || babylonMesh.name;
 
 
                     switch (light.type) {
                     switch (light.type) {
                         case LightType.DIRECTIONAL: {
                         case LightType.DIRECTIONAL: {
@@ -81,9 +81,9 @@ module BABYLON.GLTF2.Extensions {
                             break;
                             break;
                         }
                         }
                         case LightType.SPOT: {
                         case LightType.SPOT: {
-                            const babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 2, this._loader.babylonScene);
-                            babylonSpotLight.angle = light.spot && light.spot.outerConeAngle || Math.PI / 4;
-                            babylonSpotLight.innerAngle = light.spot && light.spot.innerConeAngle || 0;
+                            const babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, this._loader.babylonScene);
+                            babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
+                            babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
                             babylonLight = babylonSpotLight;
                             babylonLight = babylonSpotLight;
                             break;
                             break;
                         }
                         }

+ 1 - 1
src/Lights/babylon.spotLight.ts

@@ -56,7 +56,7 @@
          */
          */
         @serialize()
         @serialize()
         public get innerAngle(): number {
         public get innerAngle(): number {
-            return this._angle
+            return this._innerAngle;
         }
         }
         /**
         /**
          * Only used in gltf falloff mode, this defines the angle where 
          * Only used in gltf falloff mode, this defines the angle where