diff --git a/src/game-lib-scene.js b/src/game-lib-scene.js index d56935c..972e75d 100644 --- a/src/game-lib-scene.js +++ b/src/game-lib-scene.js @@ -135,55 +135,57 @@ GameLib.D3.Scene.LoadSceneFromApi = function( var lights3d = []; - for (var l = 0; l < scene.lights.length; l++) { + if (scene.lights && scene.lights.length > 0) { + for (var l = 0; l < scene.lights.length; l++) { - var light = scene.lights[l]; + var light = scene.lights[l]; - var light3d = new GameLib.D3.Light( - light.id, - light.lightType, - light.name, - new GameLib.D3.Color( - light.color.r, - light.color.g, - light.color.b, - light.color.a - ), - light.intensity, - new GameLib.D3.Vector3( - light.position.x, - light.position.y, - light.position.z - ), - new GameLib.D3.Vector3( - light.targetPosition.x, - light.targetPosition.y, - light.targetPosition.z - ), - new GameLib.D3.Vector4( - light.quaternion.x, - light.quaternion.y, - light.quaternion.z, - light.quaternion.w - ), - new GameLib.D3.Vector3( - light.rotation.x, - light.rotation.y, - light.rotation.z - ), - new GameLib.D3.Vector3( - light.scale.x, - light.scale.y, - light.scale.z - ), - light.distance, - light.decay, - light.power, - light.angle, - light.penumbra - ); + var light3d = new GameLib.D3.Light( + light.id, + light.lightType, + light.name, + new GameLib.D3.Color( + light.color.r, + light.color.g, + light.color.b, + light.color.a + ), + light.intensity, + new GameLib.D3.Vector3( + light.position.x, + light.position.y, + light.position.z + ), + new GameLib.D3.Vector3( + light.targetPosition.x, + light.targetPosition.y, + light.targetPosition.z + ), + new GameLib.D3.Vector4( + light.quaternion.x, + light.quaternion.y, + light.quaternion.z, + light.quaternion.w + ), + new GameLib.D3.Vector3( + light.rotation.x, + light.rotation.y, + light.rotation.z + ), + new GameLib.D3.Vector3( + light.scale.x, + light.scale.y, + light.scale.z + ), + light.distance, + light.decay, + light.power, + light.angle, + light.penumbra + ); - lights3d.push(light3d); + lights3d.push(light3d); + } } var scene3d = new GameLib.D3.Scene(