浏览代码

Fixing bug with scene loading

David Catuhe 11 年之前
父节点
当前提交
7b2dbb8c02

+ 5 - 2
Babylon/Bones/babylon.skeleton.js

@@ -6,6 +6,7 @@
             this.id = id;
             this.bones = new Array();
             this._isDirty = true;
+            this._identity = BABYLON.Matrix.Identity();
             this.bones = [];
 
             this._scene = scene;
@@ -27,8 +28,8 @@
                 return;
             }
 
-            if (!this._transformMatrices || this._transformMatrices.length !== 16 * this.bones.length) {
-                this._transformMatrices = new Float32Array(16 * this.bones.length);
+            if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
+                this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
             }
 
             for (var index = 0; index < this.bones.length; index++) {
@@ -44,6 +45,8 @@
                 bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), this._transformMatrices, index * 16);
             }
 
+            this._identity.copyToArray(this._transformMatrices, this.bones.length * 16);
+
             this._isDirty = false;
         };
 

+ 7 - 2
Babylon/Bones/babylon.skeleton.ts

@@ -6,6 +6,7 @@
         private _isDirty = true;
         private _transformMatrices: Float32Array;
         private _animatables: IAnimatable[];
+        private _identity = Matrix.Identity();
 
         constructor(public name: string, public id: string, scene: Scene) {
             this.bones = [];
@@ -30,8 +31,8 @@
                 return;
             }
 
-            if (!this._transformMatrices || this._transformMatrices.length !== 16 * this.bones.length) {
-                this._transformMatrices = new Float32Array(16 * this.bones.length);
+            if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
+                this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
             }
 
             for (var index = 0; index < this.bones.length; index++) {
@@ -47,6 +48,10 @@
                 bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), this._transformMatrices, index * 16);
             }
 
+
+            this._identity.copyToArray(this._transformMatrices, this.bones.length * 16);
+
+
             this._isDirty = false;
         }
 

+ 1 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -478,7 +478,7 @@ var BABYLON = BABYLON || {};
             return null; // null since geometry could be a primitive
         }
 
-        var geometry = new BABYLON.Geometry(parsedVertexData.id, scene.getEngine());
+        var geometry = new BABYLON.Geometry(parsedVertexData.id, scene);
 
         BABYLON.Tags.AddTagsTo(geometry, parsedVertexData.tags);
 

文件差异内容过多而无法显示
+ 3 - 3
babylon.1.12-rc.js