From ac820f70badccd0a57a386aea532de372d715e97 Mon Sep 17 00:00:00 2001 From: polygonboutique Date: Wed, 9 Nov 2016 12:37:46 +0100 Subject: [PATCH] if-guards for 3d-editor --- src/game-lib-component-follow.js | 10 ++++++---- src/game-lib-component-look-at.js | 21 +++++++++++---------- src/game-lib-component-mesh-permutation.js | 17 +++++++++-------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/game-lib-component-follow.js b/src/game-lib-component-follow.js index d1f8a87..8acfd0d 100644 --- a/src/game-lib-component-follow.js +++ b/src/game-lib-component-follow.js @@ -24,10 +24,12 @@ GameLib.D3.ComponentFollow = function( this.minDistance = minDistance || 0; }; -ComponentFollow_Target_Vec3 = new THREE.Vector3(); -ComponentFollow_TargetToParent_Vec3 = new THREE.Vector3(); -ComponentFollow_rotatedTargetOffset_Vec3 = new THREE.Vector3(); -ComponentFollow_tempQuaternion = new THREE.Quaternion(); +if(typeof THREE != "undefined") { + ComponentFollow_Target_Vec3 = new THREE.Vector3(); + ComponentFollow_TargetToParent_Vec3 = new THREE.Vector3(); + ComponentFollow_rotatedTargetOffset_Vec3 = new THREE.Vector3(); + ComponentFollow_tempQuaternion = new THREE.Quaternion(); +} ///////////////////////// Methods to override ////////////////////////// GameLib.D3.ComponentFollow.prototype.onUpdate = function( diff --git a/src/game-lib-component-look-at.js b/src/game-lib-component-look-at.js index a26793c..f64dc7e 100644 --- a/src/game-lib-component-look-at.js +++ b/src/game-lib-component-look-at.js @@ -22,16 +22,17 @@ GameLib.D3.ComponentLookAt = function( this.rotationSpeed = rotationSpeed || 22.0; }; - -ComponentLookAt_rotatedTargetOffset = new THREE.Vector3(); -ComponentLookAt_currentPos = new THREE.Vector3(); -ComponentLookAt_targetPos = new THREE.Vector3(); -ComponentLookAt_upVector = new THREE.Vector3(0, 1, 0); -ComponentLookAt_targetQuaternion = new THREE.Quaternion(0, 0, 0, 1); -ComponentLookAt_tmpQuaternion = new THREE.Quaternion(0, 0, 0, 1); -ComponentLookAt_newRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1); -ComponentLookAt_lastRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1); -ComponentLookAt_lookAtMatrix = new THREE.Matrix4(); +if(typeof THREE != "undefined") { + ComponentLookAt_rotatedTargetOffset = new THREE.Vector3(); + ComponentLookAt_currentPos = new THREE.Vector3(); + ComponentLookAt_targetPos = new THREE.Vector3(); + ComponentLookAt_upVector = new THREE.Vector3(0, 1, 0); + ComponentLookAt_targetQuaternion = new THREE.Quaternion(0, 0, 0, 1); + ComponentLookAt_tmpQuaternion = new THREE.Quaternion(0, 0, 0, 1); + ComponentLookAt_newRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1); + ComponentLookAt_lastRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1); + ComponentLookAt_lookAtMatrix = new THREE.Matrix4(); +} ///////////////////////// Methods to override ////////////////////////// GameLib.D3.ComponentLookAt.prototype.onUpdate = function( diff --git a/src/game-lib-component-mesh-permutation.js b/src/game-lib-component-mesh-permutation.js index e0ded90..c614578 100644 --- a/src/game-lib-component-mesh-permutation.js +++ b/src/game-lib-component-mesh-permutation.js @@ -15,14 +15,15 @@ GameLib.D3.ComponentMeshPermutation = function( GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface); }; -ComponentMeshPermutation_quaternion = new THREE.Quaternion(); -ComponentMeshPermutation_quaternionCopy = new THREE.Quaternion(); -ComponentMeshPermutation_position = new THREE.Vector3(); -ComponentMeshPermutation_scale = new THREE.Vector3(); - -ComponentMeshPermutation_offsetQuaternion = new THREE.Quaternion(); -ComponentMeshPermutation_offsetPosition = new THREE.Vector3(); -ComponentMeshPermutation_offsetScale = new THREE.Vector3(); +if(typeof THREE != "undefined") { + ComponentMeshPermutation_quaternion = new THREE.Quaternion(); + ComponentMeshPermutation_quaternionCopy = new THREE.Quaternion(); + ComponentMeshPermutation_position = new THREE.Vector3(); + ComponentMeshPermutation_scale = new THREE.Vector3(); + ComponentMeshPermutation_offsetQuaternion = new THREE.Quaternion(); + ComponentMeshPermutation_offsetPosition = new THREE.Vector3(); + ComponentMeshPermutation_offsetScale = new THREE.Vector3(); +} ///////////////////////// Methods to override ////////////////////////// GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function(