Browse Source

Further updates

removing unneeded functions (transformation)
Raanan Weber 9 years ago
parent
commit
2ecee7b348

+ 15 - 94
src/Math/babylon.math.js

@@ -503,45 +503,12 @@ var BABYLON;
     BABYLON.Vector2 = Vector2;
     var Vector3 = (function (_super) {
         __extends(Vector3, _super);
-        function Vector3(_x, _y, _z) {
+        function Vector3(x, y, z) {
             _super.call(this);
-            this._x = _x;
-            this._y = _y;
-            this._z = _z;
+            this.x = x;
+            this.y = y;
+            this.z = z;
         }
-        Object.defineProperty(Vector3.prototype, "x", {
-            get: function () {
-                return this._x;
-            },
-            set: function (x) {
-                this._x = x;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Vector3.prototype, "y", {
-            get: function () {
-                return this._y;
-            },
-            set: function (y) {
-                this._y = y;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Vector3.prototype, "z", {
-            get: function () {
-                return this._z;
-            },
-            set: function (z) {
-                this._z = z;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
         Vector3.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
         };
@@ -1292,63 +1259,17 @@ var BABYLON;
         return Vector4;
     }());
     BABYLON.Vector4 = Vector4;
-    var Quaternion = (function (_super) {
-        __extends(Quaternion, _super);
-        function Quaternion(_x, _y, _z, _w) {
-            if (_x === void 0) { _x = 0; }
-            if (_y === void 0) { _y = 0; }
-            if (_z === void 0) { _z = 0; }
-            if (_w === void 0) { _w = 1; }
-            _super.call(this);
-            this._x = _x;
-            this._y = _y;
-            this._z = _z;
-            this._w = _w;
+    var Quaternion = (function () {
+        function Quaternion(x, y, z, w) {
+            if (x === void 0) { x = 0; }
+            if (y === void 0) { y = 0; }
+            if (z === void 0) { z = 0; }
+            if (w === void 0) { w = 1; }
+            this.x = x;
+            this.y = y;
+            this.z = z;
+            this.w = w;
         }
-        Object.defineProperty(Quaternion.prototype, "x", {
-            get: function () {
-                return this._x;
-            },
-            set: function (x) {
-                this._x = x;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Quaternion.prototype, "y", {
-            get: function () {
-                return this._y;
-            },
-            set: function (y) {
-                this._y = y;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Quaternion.prototype, "z", {
-            get: function () {
-                return this._z;
-            },
-            set: function (z) {
-                this._z = z;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Quaternion.prototype, "w", {
-            get: function () {
-                return this._w;
-            },
-            set: function (w) {
-                this._w = w;
-                this.triggerChange();
-            },
-            enumerable: true,
-            configurable: true
-        });
         Quaternion.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
         };
@@ -1608,7 +1529,7 @@ var BABYLON;
             return new Quaternion((num3 * left.x) + (num2 * right.x), (num3 * left.y) + (num2 * right.y), (num3 * left.z) + (num2 * right.z), (num3 * left.w) + (num2 * right.w));
         };
         return Quaternion;
-    }(ChangableMathObject));
+    }());
     BABYLON.Quaternion = Quaternion;
     var Matrix = (function () {
         function Matrix() {

+ 4 - 29
src/Mesh/babylon.abstractMesh.js

@@ -13,7 +13,7 @@ var BABYLON;
             _super.call(this, name, scene);
             // Properties
             this.definedFacingForward = true; // orientation for POV movement & rotation
-            this._position = new BABYLON.Vector3(0, 0, 0);
+            this.position = new BABYLON.Vector3(0, 0, 0);
             this._rotation = new BABYLON.Vector3(0, 0, 0);
             this._scaling = new BABYLON.Vector3(1, 1, 1);
             this.billboardMode = AbstractMesh.BILLBOARDMODE_NONE;
@@ -143,20 +143,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(AbstractMesh.prototype, "position", {
-            get: function () {
-                return this._position;
-            },
-            set: function (newPosition) {
-                this._position = newPosition;
-                if (this.physicImpostor) {
-                    this.position.registerOnChange(this.physicImpostor.transformationUpdated);
-                    this.physicImpostor.transformationUpdated();
-                }
-            },
-            enumerable: true,
-            configurable: true
-        });
         Object.defineProperty(AbstractMesh.prototype, "rotation", {
             get: function () {
                 if (this.rotationQuaternion) {
@@ -167,10 +153,10 @@ var BABYLON;
             set: function (newRotation) {
                 this._rotation = newRotation;
                 //check if rotationQuaternion exists, and if it does - update it!
-                if (this._rotationQuaternion) {
+                if (this.rotationQuaternion) {
                     var len = this._rotation.length();
                     if (len) {
-                        this._rotationQuaternion.multiplyInPlace(BABYLON.Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
+                        this.rotationQuaternion.multiplyInPlace(BABYLON.Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
                         this._rotation.copyFromFloats(0, 0, 0);
                     }
                 }
@@ -184,19 +170,8 @@ var BABYLON;
             },
             set: function (newScaling) {
                 this._scaling = newScaling;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(AbstractMesh.prototype, "rotationQuaternion", {
-            get: function () {
-                return this._rotationQuaternion;
-            },
-            set: function (quaternion) {
-                this._rotationQuaternion = quaternion;
                 if (this.physicImpostor) {
-                    this.position.registerOnChange(this.physicImpostor.transformationUpdated);
-                    this.physicImpostor.transformationUpdated();
+                    this.physicImpostor.forceUpdate();
                 }
             },
             enumerable: true,

+ 6 - 27
src/Mesh/babylon.abstractMesh.ts

@@ -29,9 +29,9 @@
 
         // Properties
         public definedFacingForward = true; // orientation for POV movement & rotation
-        private _position = new Vector3(0, 0, 0);
+        public position = new Vector3(0, 0, 0);
         private _rotation = new Vector3(0, 0, 0);
-        private _rotationQuaternion: Quaternion;
+        public rotationQuaternion: Quaternion;
         private _scaling = new Vector3(1, 1, 1);
         public billboardMode = AbstractMesh.BILLBOARDMODE_NONE;
         public visibility = 1.0;
@@ -156,18 +156,6 @@
             scene.addMesh(this);
         }
 
-        public get position(): Vector3 {
-            return this._position;
-        }
-
-        public set position(newPosition: Vector3) {
-            this._position = newPosition;
-            if (this.physicImpostor) {
-                //this.position.registerOnChange(this.physicImpostor.transformationUpdated);
-                this.physicImpostor.transformationUpdated();
-            }
-        }
-
         public get rotation(): Vector3 {
             if (this.rotationQuaternion) {
                 Tools.Warn("Quaternion rotation is used, the rotation value is probably wrong");
@@ -178,10 +166,10 @@
         public set rotation(newRotation: Vector3) {
             this._rotation = newRotation;
             //check if rotationQuaternion exists, and if it does - update it!
-            if (this._rotationQuaternion) {
+            if (this.rotationQuaternion) {
                 var len = this._rotation.length();
                 if (len) {
-                    this._rotationQuaternion.multiplyInPlace(BABYLON.Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z))
+                    this.rotationQuaternion.multiplyInPlace(BABYLON.Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z))
                     this._rotation.copyFromFloats(0, 0, 0);
                 }
             }
@@ -193,17 +181,8 @@
 
         public set scaling(newScaling: Vector3) {
             this._scaling = newScaling;
-        }
-
-        public get rotationQuaternion(): Quaternion {
-            return this._rotationQuaternion;
-        }
-
-        public set rotationQuaternion(quaternion: Quaternion) {
-            this._rotationQuaternion = quaternion;
-            if (this.physicImpostor) {
-                //this.position.registerOnChange(this.physicImpostor.transformationUpdated);
-                this.physicImpostor.transformationUpdated();
+            if(this.physicImpostor) {
+                this.physicImpostor.forceUpdate();
             }
         }
 

+ 1 - 1
src/Physics/babylon.physicsEngine.js

@@ -61,7 +61,7 @@ var BABYLON;
             var _this = this;
             //check if any mesh has no body / requires an update
             this._impostors.forEach(function (impostor) {
-                if (impostor.isUpdateRequired()) {
+                if (impostor.isBodyInitRequired()) {
                     _this._physicsPlugin.generatePhysicsBody(impostor);
                 }
             });

+ 1 - 1
src/Physics/babylon.physicsEngine.ts

@@ -98,7 +98,7 @@
             //check if any mesh has no body / requires an update
             this._impostors.forEach((impostor) => {
 
-                if (impostor.isUpdateRequired()) {
+                if (impostor.isBodyInitRequired()) {
                     this._physicsPlugin.generatePhysicsBody(impostor);
                 }
             });

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

@@ -6,7 +6,6 @@ var BABYLON;
             this._mesh = _mesh;
             this.type = type;
             this._options = _options;
-            this._transformationUpdated = false;
             this._bodyUpdateRequired = false;
             this._onBeforePhysicsStepCallbacks = new Array();
             this._onAfterPhysicsStepCallbacks = new Array();
@@ -68,15 +67,6 @@ var BABYLON;
         PhysicsImpostor.prototype.isBodyInitRequired = function () {
             return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
         };
-        PhysicsImpostor.prototype.isUpdateRequired = function () {
-            return this._transformationUpdated || this.isBodyInitRequired();
-        };
-        PhysicsImpostor.prototype.transformationUpdated = function () {
-            this._transformationUpdated = true;
-            if (this._parent) {
-                this._parent.transformationUpdated();
-            }
-        };
         PhysicsImpostor.prototype.setScalingUpdated = function (updated) {
             this.forceUpdate();
         };
@@ -115,7 +105,6 @@ var BABYLON;
             configurable: true
         });
         PhysicsImpostor.prototype.resetUpdateFlags = function () {
-            this._transformationUpdated = false;
             this._bodyUpdateRequired = false;
         };
         PhysicsImpostor.prototype.getOptions = function () {

+ 0 - 13
src/Physics/babylon.physicsImpostor.ts

@@ -12,7 +12,6 @@ module BABYLON {
         private _physicsEngine: PhysicsEngine;
         //The native cannon/oimo/energy physics body object.
         private _physicsBody: any;
-        private _transformationUpdated: boolean = false;
         private _bodyUpdateRequired: boolean = false;
 
         private _onBeforePhysicsStepCallbacks = new Array<(impostor: PhysicsImpostor) => void>();
@@ -61,17 +60,6 @@ module BABYLON {
             return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
         }
 
-        public isUpdateRequired(): boolean {
-            return this._transformationUpdated || this.isBodyInitRequired();
-        }
-
-        public transformationUpdated() : void {
-            this._transformationUpdated = true;
-            if (this._parent) {
-                this._parent.transformationUpdated();
-            }
-        }
-
         public setScalingUpdated(updated: boolean) {
             this.forceUpdate();
         }
@@ -104,7 +92,6 @@ module BABYLON {
         }
 
         public resetUpdateFlags() {
-            this._transformationUpdated = false;
             this._bodyUpdateRequired = false;
         }