Explorar o código

Add missing serialization on base light

Sébastien Vandenberghe %!s(int64=9) %!d(string=hai) anos
pai
achega
1393eaad0c

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 28 - 22
dist/preview release/babylon.core.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 726 - 716
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 35 - 27
dist/preview release/babylon.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 9957 - 9929
dist/preview release/babylon.max.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 32 - 25
dist/preview release/babylon.noworker.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 9997 - 9924
materialsLibrary/test/refs/babylon.max.js


+ 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

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

+ 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

+ 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) {

+ 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();