Просмотр исходного кода

Fix transformNodes storage for gltf assetcontainers

David Catuhe 5 лет назад
Родитель
Сommit
653d3b4a69

+ 2 - 1
loaders/src/glTF/1.0/glTFLoader.ts

@@ -1702,7 +1702,8 @@ export class GLTFLoader implements IGLTFLoader {
                     particleSystems: [],
                     skeletons: skeletons,
                     animationGroups: [],
-                    lights: []
+                    lights: [],
+                    transformNodes: []
                 });
             }, onProgress, (message) => {
                 reject(new Error(message));

+ 17 - 1
loaders/src/glTF/2.0/glTFLoader.ts

@@ -269,7 +269,8 @@ export class GLTFLoader implements IGLTFLoader {
                     particleSystems: [],
                     skeletons: this._getSkeletons(),
                     animationGroups: this._getAnimationGroups(),
-                    lights: this._babylonLights
+                    lights: this._babylonLights,
+                    transformNodes: this._getTransformNodes()
                 };
             });
         });
@@ -565,6 +566,21 @@ export class GLTFLoader implements IGLTFLoader {
         return meshes;
     }
 
+    private _getTransformNodes(): TransformNode[] {
+        const transformNodes = new Array<TransformNode>();
+
+        const nodes = this._gltf.nodes;
+        if (nodes) {
+            for (const node of nodes) {
+                if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") {
+                    transformNodes.push(node._babylonTransformNode);
+                }
+            }
+        }
+
+        return transformNodes;
+    }
+
     private _getSkeletons(): Skeleton[] {
         const skeletons = new Array<Skeleton>();
 

+ 4 - 1
loaders/src/glTF/glTFFileLoader.ts

@@ -18,6 +18,7 @@ import { Logger } from 'babylonjs/Misc/logger';
 import { DataReader, IDataBuffer } from 'babylonjs/Misc/dataReader';
 import { GLTFValidation } from './glTFValidation';
 import { Light } from 'babylonjs/Lights/light';
+import { TransformNode } from 'babylonjs/Meshes/transformNode';
 
 /**
  * Mode that determines the coordinate system to use.
@@ -116,7 +117,8 @@ export interface IImportMeshAsyncOutput {
     particleSystems: IParticleSystem[], 
     skeletons: Skeleton[], 
     animationGroups: AnimationGroup[], 
-    lights: Light[] 
+    lights: Light[],
+    transformNodes: TransformNode[]
 }
 
 /** @hidden */
@@ -605,6 +607,7 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
                 Array.prototype.push.apply(container.materials, materials);
                 Array.prototype.push.apply(container.textures, textures);
                 Array.prototype.push.apply(container.lights, result.lights);
+                Array.prototype.push.apply(container.transformNodes, result.transformNodes);
                 return container;
             });
         });