فهرست منبع

Merge remote-tracking branch 'refs/remotes/BabylonJS/master'

Raanan Weber 9 سال پیش
والد
کامیت
05f59d062d

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 21 - 21
dist/preview release/babylon.core.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 989 - 979
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 23 - 23
dist/preview release/babylon.js


+ 35 - 7
dist/preview release/babylon.max.js

@@ -7432,7 +7432,7 @@ var BABYLON;
          */
         Node.prototype.getChildMeshes = function (directDecendantsOnly) {
             var results = [];
-            this._getDescendants(this._scene.meshes, results, false);
+            this._getDescendants(this._scene.meshes, results, directDecendantsOnly);
             return results;
         };
         Node.prototype._setReady = function (state) {
@@ -8225,7 +8225,7 @@ var BABYLON;
             set: function (quaternion) {
                 this._rotationQuaternion = quaternion;
                 //reset the rotation vector. 
-                if (this.rotation.length()) {
+                if (quaternion && this.rotation.length()) {
                     this.rotation.copyFromFloats(0, 0, 0);
                 }
             },
@@ -9105,6 +9105,9 @@ var BABYLON;
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
+            // Animations  
+            BABYLON.Animation.AppendSerializedAnimations(this, serializationObject);
+            serializationObject.ranges = this.serializeAnimationRanges();
             return serializationObject;
         };
         Light.GetConstructorFromName = function (type, name, scene) {
@@ -15243,7 +15246,7 @@ var BABYLON;
                     source._geometry.applyToMesh(this);
                 }
                 // Deep copy
-                BABYLON.Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], []);
+                BABYLON.Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], ["_poseMatrix"]);
                 // Pivot                
                 this.setPivotMatrix(source.getPivotMatrix());
                 this.id = name + "." + source.id;
@@ -24620,11 +24623,22 @@ var BABYLON;
             }
             gravity = gravity || new BABYLON.Vector3(0, -9.807, 0);
             this.setGravity(gravity);
+            this.setTimeStep();
         }
         PhysicsEngine.prototype.setGravity = function (gravity) {
             this.gravity = gravity;
             this._physicsPlugin.setGravity(this.gravity);
         };
+        /**
+         * Set the time step of the physics engine.
+         * default is 1/60.
+         * To slow it down, enter 1/600 for example.
+         * To speed it up, 1/30
+         */
+        PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
+            if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
+            this._physicsPlugin.setTimeStep(newTimeStep);
+        };
         PhysicsEngine.prototype.dispose = function () {
             this._impostors.forEach(function (impostor) {
                 impostor.dispose();
@@ -31035,8 +31049,11 @@ var BABYLON;
         CannonJSPlugin.prototype.setGravity = function (gravity) {
             this.world.gravity.copy(gravity);
         };
+        CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
+            this._fixedTimeStep = timeStep;
+        };
         CannonJSPlugin.prototype.executeStep = function (delta, impostors) {
-            this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0);
+            this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0, 3);
         };
         CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
             var worldPoint = new CANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
@@ -31188,7 +31205,15 @@ var BABYLON;
             //set the collideConnected flag after the creation, since DistanceJoint ignores it.
             constraint.collideConnected = !!jointData.collision;
             impostorJoint.joint.physicsJoint = constraint;
-            this.world.addConstraint(constraint);
+            //don't add spring as constraint, as it is not one.
+            if (impostorJoint.joint.type !== BABYLON.PhysicsJoint.SpringJoint) {
+                this.world.addConstraint(constraint);
+            }
+            else {
+                impostorJoint.mainImpostor.registerAfterPhysicsStep(function () {
+                    constraint.applyForce();
+                });
+            }
         };
         CannonJSPlugin.prototype.removeJoint = function (joint) {
             //TODO
@@ -31393,6 +31418,9 @@ var BABYLON;
         OimoJSPlugin.prototype.setGravity = function (gravity) {
             this.world.gravity.copy(gravity);
         };
+        OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
+            this.world.timeStep = timeStep;
+        };
         OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
             var _this = this;
             impostors.forEach(function (impostor) {
@@ -34068,9 +34096,9 @@ var BABYLON;
                 this._cacheState = this._sensorDevice.getState();
                 this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x, this._cacheState.orientation.y, this._cacheState.orientation.z, this._cacheState.orientation.w);
                 this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation);
-                this.rotation.x = -this._cacheRotation.z;
+                this.rotation.x = -this._cacheRotation.x;
                 this.rotation.y = -this._cacheRotation.y;
-                this.rotation.z = this._cacheRotation.x;
+                this.rotation.z = this._cacheRotation.z;
             }
             _super.prototype._checkInputs.call(this);
         };

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 23 - 23
dist/preview release/babylon.noworker.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 9997 - 9924
materialsLibrary/test/refs/babylon.max.js


+ 2 - 2
src/Cameras/VR/babylon.webVRCamera.js

@@ -48,9 +48,9 @@ var BABYLON;
                 this._cacheState = this._sensorDevice.getState();
                 this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x, this._cacheState.orientation.y, this._cacheState.orientation.z, this._cacheState.orientation.w);
                 this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation);
-                this.rotation.x = -this._cacheRotation.z;
+                this.rotation.x = -this._cacheRotation.x;
                 this.rotation.y = -this._cacheRotation.y;
-                this.rotation.z = this._cacheRotation.x;
+                this.rotation.z = this._cacheRotation.z;
             }
             _super.prototype._checkInputs.call(this);
         };

+ 5 - 4
src/Cameras/VR/babylon.webVRCamera.ts

@@ -12,7 +12,7 @@ module BABYLON {
 
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true) {
             super(name, position, scene);
-            
+
             var metrics = VRCameraMetrics.GetDefault();
             metrics.compensateDistortion = compensateDistortion;
             this.setCameraRigMode(Camera.RIG_MODE_VR, { vrCameraMetrics: metrics });
@@ -54,9 +54,9 @@ module BABYLON {
                 this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x, this._cacheState.orientation.y, this._cacheState.orientation.z, this._cacheState.orientation.w);
                 this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation);
 
-                this.rotation.x = -this._cacheRotation.z;
+                this.rotation.x = -this._cacheRotation.x;
                 this.rotation.y = -this._cacheRotation.y;
-                this.rotation.z = this._cacheRotation.x;
+                this.rotation.z = this._cacheRotation.z;
             }
 
             super._checkInputs();
@@ -82,4 +82,5 @@ module BABYLON {
             return "WebVRFreeCamera";
         }
     }
-}
+}
+

+ 3 - 0
src/Lights/babylon.light.js

@@ -95,6 +95,9 @@ var BABYLON;
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
+            // Animations  
+            BABYLON.Animation.AppendSerializedAnimations(this, serializationObject);
+            serializationObject.ranges = this.serializeAnimationRanges();
             return serializationObject;
         };
         Light.GetConstructorFromName = function (type, name, scene) {

+ 4 - 0
src/Lights/babylon.light.ts

@@ -146,6 +146,10 @@
                 serializationObject.parentId = this.parent.id;
             }
 
+            // Animations  
+            Animation.AppendSerializedAnimations(this, serializationObject);
+            serializationObject.ranges = this.serializeAnimationRanges();  
+
             return serializationObject;
         }
 

+ 1 - 1
src/Mesh/babylon.abstractMesh.js

@@ -177,7 +177,7 @@ var BABYLON;
             set: function (quaternion) {
                 this._rotationQuaternion = quaternion;
                 //reset the rotation vector. 
-                if (this.rotation.length()) {
+                if (quaternion && this.rotation.length()) {
                     this.rotation.copyFromFloats(0, 0, 0);
                 }
             },

+ 1 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -186,7 +186,7 @@
         public set rotationQuaternion(quaternion: Quaternion) {
             this._rotationQuaternion = quaternion;
             //reset the rotation vector. 
-            if (this.rotation.length()) {
+            if (quaternion && this.rotation.length()) {
                 this.rotation.copyFromFloats(0, 0, 0);
             }
         }

+ 1 - 1
src/Mesh/babylon.mesh.js

@@ -47,7 +47,7 @@ var BABYLON;
                     source._geometry.applyToMesh(this);
                 }
                 // Deep copy
-                BABYLON.Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], []);
+                BABYLON.Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], ["_poseMatrix"]);
                 // Pivot                
                 this.setPivotMatrix(source.getPivotMatrix());
                 this.id = name + "." + source.id;

+ 1 - 1
src/Mesh/babylon.mesh.ts

@@ -93,7 +93,7 @@
                 }
 
                 // Deep copy
-                Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], []);
+                Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances"], ["_poseMatrix"]);
 
                 // Pivot                
                 this.setPivotMatrix(source.getPivotMatrix());

+ 13 - 2
src/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -28,8 +28,11 @@ var BABYLON;
         CannonJSPlugin.prototype.setGravity = function (gravity) {
             this.world.gravity.copy(gravity);
         };
+        CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
+            this._fixedTimeStep = timeStep;
+        };
         CannonJSPlugin.prototype.executeStep = function (delta, impostors) {
-            this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0);
+            this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0, 3);
         };
         CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
             var worldPoint = new CANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
@@ -181,7 +184,15 @@ var BABYLON;
             //set the collideConnected flag after the creation, since DistanceJoint ignores it.
             constraint.collideConnected = !!jointData.collision;
             impostorJoint.joint.physicsJoint = constraint;
-            this.world.addConstraint(constraint);
+            //don't add spring as constraint, as it is not one.
+            if (impostorJoint.joint.type !== BABYLON.PhysicsJoint.SpringJoint) {
+                this.world.addConstraint(constraint);
+            }
+            else {
+                impostorJoint.mainImpostor.registerAfterPhysicsStep(function () {
+                    constraint.applyForce();
+                });
+            }
         };
         CannonJSPlugin.prototype.removeJoint = function (joint) {
             //TODO

+ 5 - 4
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -23,7 +23,7 @@
         public setGravity(gravity: Vector3): void {
             this.world.gravity.copy(gravity);
         }
-        
+
         public setTimeStep(timeStep: number) {
             this._fixedTimeStep = timeStep;
         }
@@ -95,7 +95,7 @@
                 //try to keep the body moving in the right direction by taking old properties.
                 //Should be tested!
                 if (oldBody) {
-                    ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function(param) {
+                    ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
                         impostor.physicsBody[param].copy(oldBody[param]);
                     });
                 }
@@ -196,10 +196,10 @@
             constraint.collideConnected = !!jointData.collision
             impostorJoint.joint.physicsJoint = constraint;
             //don't add spring as constraint, as it is not one.
-            if(impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {
+            if (impostorJoint.joint.type !== PhysicsJoint.SpringJoint) {
                 this.world.addConstraint(constraint);
             } else {
-                impostorJoint.mainImpostor.registerAfterPhysicsStep(function() {
+                impostorJoint.mainImpostor.registerAfterPhysicsStep(function () {
                     constraint.applyForce();
                 });
             }
@@ -447,3 +447,4 @@
 
 
 
+

+ 3 - 0
src/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -13,6 +13,9 @@ var BABYLON;
         OimoJSPlugin.prototype.setGravity = function (gravity) {
             this.world.gravity.copy(gravity);
         };
+        OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
+            this.world.timeStep = timeStep;
+        };
         OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
             var _this = this;
             impostors.forEach(function (impostor) {

+ 4 - 3
src/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -16,7 +16,7 @@ module BABYLON {
         public setGravity(gravity: Vector3) {
             this.world.gravity.copy(gravity);
         }
-        
+
         public setTimeStep(timeStep: number) {
             this.world.timeStep = timeStep;
         }
@@ -25,7 +25,7 @@ module BABYLON {
 
         public executeStep(delta: number, impostors: Array<PhysicsImpostor>) {
 
-            impostors.forEach(function(impostor) {
+            impostors.forEach(function (impostor) {
                 impostor.beforeStep();
             });
 
@@ -103,7 +103,7 @@ module BABYLON {
 
                 var impostors = [impostor];
                 function addToArray(parent: AbstractMesh) {
-                    parent.getChildMeshes().forEach(function(m) {
+                    parent.getChildMeshes().forEach(function (m) {
                         if (m.physicsImpostor) {
                             impostors.push(m.physicsImpostor);
                             m.physicsImpostor._init();
@@ -333,3 +333,4 @@ module BABYLON {
         }
     }
 }
+

+ 11 - 0
src/Physics/babylon.physicsEngine.js

@@ -13,11 +13,22 @@ var BABYLON;
             }
             gravity = gravity || new BABYLON.Vector3(0, -9.807, 0);
             this.setGravity(gravity);
+            this.setTimeStep();
         }
         PhysicsEngine.prototype.setGravity = function (gravity) {
             this.gravity = gravity;
             this._physicsPlugin.setGravity(this.gravity);
         };
+        /**
+         * Set the time step of the physics engine.
+         * default is 1/60.
+         * To slow it down, enter 1/600 for example.
+         * To speed it up, 1/30
+         */
+        PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
+            if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
+            this._physicsPlugin.setTimeStep(newTimeStep);
+        };
         PhysicsEngine.prototype.dispose = function () {
             this._impostors.forEach(function (impostor) {
                 impostor.dispose();

+ 4 - 3
src/Physics/babylon.physicsEngine.ts

@@ -31,12 +31,12 @@
          * To slow it down, enter 1/600 for example.
          * To speed it up, 1/30
          */
-        public setTimeStep(newTimeStep: number = 1/60) {
+        public setTimeStep(newTimeStep: number = 1 / 60) {
             this._physicsPlugin.setTimeStep(newTimeStep);
         }
 
         public dispose(): void {
-            this._impostors.forEach(function(impostor) {
+            this._impostors.forEach(function (impostor) {
                 impostor.dispose();
             })
             this._physicsPlugin.dispose();
@@ -100,7 +100,7 @@
         }
 
         public removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint) {
-            var matchingJoints = this._joints.filter(function(impostorJoint) {
+            var matchingJoints = this._joints.filter(function (impostorJoint) {
                 return (impostorJoint.connectedImpostor === connectedImpostor
                     && impostorJoint.joint === joint
                     && impostorJoint.mainImpostor === mainImpostor)
@@ -167,3 +167,4 @@
         dispose();
     }
 }
+

+ 1 - 1
src/babylon.node.js

@@ -163,7 +163,7 @@ var BABYLON;
          */
         Node.prototype.getChildMeshes = function (directDecendantsOnly) {
             var results = [];
-            this._getDescendants(this._scene.meshes, results, false);
+            this._getDescendants(this._scene.meshes, results, directDecendantsOnly);
             return results;
         };
         Node.prototype._setReady = function (state) {

+ 1 - 1
src/babylon.node.ts

@@ -211,7 +211,7 @@
          */
         public getChildMeshes(directDecendantsOnly?: boolean): AbstractMesh[] {
             var results: Array<AbstractMesh> = [];
-            this._getDescendants(this._scene.meshes, results, false);
+            this._getDescendants(this._scene.meshes, results, directDecendantsOnly);
             return results;
         }