فهرست منبع

Scene can be retrieved from the object

Scene is optional, as most objects will have the getScene function that
will deliver the scene.
Raanan Weber 10 سال پیش
والد
کامیت
2d04803d90
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      src/Physics/babylon.physicsImpostor.ts

+ 8 - 2
src/Physics/babylon.physicsImpostor.ts

@@ -18,6 +18,7 @@ module BABYLON {
         getChildMeshes?(): Array<AbstractMesh>;
         getVerticesData?(kind: string): Array<number> | Float32Array;
         getIndices?(): Array<number>| Int32Array;
+        getScene?() : Scene;
     }
 
     export class PhysicsImpostor {
@@ -48,8 +49,13 @@ module BABYLON {
             otherImpostor: PhysicsImpostor
         }>;
 
-        constructor(public object: IPhysicsEnabledObject, public type: number, private _options: PhysicsImpostorParameters = { mass: 0 }, private _scene: Scene) {
-            this._physicsEngine = this._scene.getPhysicsEngine();
+        constructor(public object: IPhysicsEnabledObject, public type: number, private _options: PhysicsImpostorParameters = { mass: 0 }, scene?: Scene) {
+            //legacy support for old syntax.
+            if(!scene && object.getScene) {
+                scene = object.getScene()
+            }
+            
+            this._physicsEngine = scene.getPhysicsEngine();
             if (!this._physicsEngine) {
                 Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.")
             } else {