浏览代码

TS 2.0 fixings

 - Adding property setter to PhysicsImposter.parent
 - using lambda in transaction.onabort (database.ts)
 - msIndexDB defined as IDBFactory in Window mixin
nockawa 9 年之前
父节点
当前提交
eb1fc530b6

+ 1 - 1
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -116,7 +116,7 @@
                                 this.removePhysicsBody(childImpostor);
                                 childImpostor.physicsBody = null;
                             }
-                            (childImpostor as any).parent = mainImpostor;
+                            childImpostor.parent = mainImpostor;
                             childImpostor.resetUpdateFlags();
                             mainImpostor.physicsBody.addShape(this._createShape(childImpostor), new CANNON.Vec3(localPosition.x, localPosition.y, localPosition.z));
                             //Add the mass of the children.

+ 5 - 1
src/Physics/babylon.physicsImpostor.ts

@@ -143,10 +143,14 @@ module BABYLON {
             return this._parent ? this._parent.physicsBody : this._physicsBody;
         }
 
-        public get parent() {
+        public get parent(): PhysicsImpostor {
             return this._parent;
         }
 
+        public set parent(value: PhysicsImpostor) {
+            this._parent = value;
+        }
+
         /**
          * Set the physics body. Used mainly by the physics engine/plugin
          */

+ 2 - 2
src/Tools/babylon.database.ts

@@ -526,11 +526,11 @@ module BABYLON {
                             var transaction = this.db.transaction([targetStore], "readwrite");
 
                             // the transaction could abort because of a QuotaExceededError error
-                            transaction.onabort = function (event) {
+                            transaction.onabort = (event) => {
                                 try {
                                     //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
                                     if (event.srcElement['error'] && event.srcElement['error'].name === "QuotaExceededError") {
-                                        (this as any).hasReachedQuota = true;
+                                        this.hasReachedQuota = true;
                                     }
                                 }
                                 catch (ex) { }

+ 1 - 1
src/babylon.mixins.ts

@@ -2,7 +2,7 @@
 interface Window {
     mozIndexedDB(func: any): any;
     webkitIndexedDB(func: any): any;
-    msIndexedDB(func: any): any;
+    msIndexedDB: IDBFactory;
     IDBTransaction(func: any): any;
     webkitIDBTransaction(func: any): any;
     msIDBTransaction(func: any): any;