|
@@ -100,9 +100,7 @@
|
|
|
// console.log( FBXTree );
|
|
|
|
|
|
var connections = parseConnections( FBXTree );
|
|
|
-
|
|
|
var images = parseImages( FBXTree );
|
|
|
-
|
|
|
var textures = parseTextures( FBXTree, new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ), images, connections );
|
|
|
var materials = parseMaterials( FBXTree, textures, connections );
|
|
|
var skeletons = parseDeformers( FBXTree, connections );
|
|
@@ -165,14 +163,11 @@
|
|
|
|
|
|
// Parse FBXTree.Objects.Video for embedded image data
|
|
|
// These images are connected to textures in FBXTree.Objects.Textures
|
|
|
- // via FBXTree.Connections. Note that images can be duplicated here, in which case only one
|
|
|
- // may have a .Content field - we'll check for this and duplicate the data in the imageMap
|
|
|
+ // via FBXTree.Connections.
|
|
|
function parseImages( FBXTree ) {
|
|
|
|
|
|
- var imageMap = new Map();
|
|
|
-
|
|
|
- var names = {};
|
|
|
- var duplicates = [];
|
|
|
+ var images = {};
|
|
|
+ var blobs = {};
|
|
|
|
|
|
if ( 'Video' in FBXTree.Objects ) {
|
|
|
|
|
@@ -184,22 +179,21 @@
|
|
|
|
|
|
var id = parseInt( nodeID );
|
|
|
|
|
|
- // check whether the file name is used by another videoNode
|
|
|
- // and if so keep a record of both ids as a duplicate pair [ id1, id2 ]
|
|
|
- if ( videoNode.FileName in names ) {
|
|
|
+ images[ id ] = videoNode.Filename;
|
|
|
|
|
|
- duplicates.push( [ id, names[ videoNode.FileName ] ] );
|
|
|
+ // raw image data is in videoNode.Content
|
|
|
+ if ( 'Content' in videoNode ) {
|
|
|
|
|
|
- }
|
|
|
+ var arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 );
|
|
|
+ var base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' );
|
|
|
|
|
|
- names[ videoNode.FileName ] = id;
|
|
|
+ if ( arrayBufferContent || base64Content ) {
|
|
|
|
|
|
- // raw image data is in videoNode.Content
|
|
|
- if ( 'Content' in videoNode && videoNode.Content !== '' ) {
|
|
|
+ var image = parseImage( videoNodes[ nodeID ] );
|
|
|
|
|
|
- var image = parseImage( videoNodes[ nodeID ] );
|
|
|
+ blobs[ videoNode.Filename ] = image;
|
|
|
|
|
|
- imageMap.set( id, image );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -207,28 +201,16 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+ for ( var id in images ) {
|
|
|
|
|
|
- // check each duplicate pair - if only one is in the image map then
|
|
|
- // create an entry for the other id containing the same image data
|
|
|
- // Note: it seems to be possible for entries to have the same file name but different
|
|
|
- // content, we won't overwrite these
|
|
|
- duplicates.forEach( function ( duplicatePair ) {
|
|
|
-
|
|
|
- if ( imageMap.has( duplicatePair[ 0 ] ) && ! imageMap.has( duplicatePair[ 1 ] ) ) {
|
|
|
+ var filename = images[ id ];
|
|
|
|
|
|
- var image = imageMap.get( duplicatePair[ 0 ] );
|
|
|
- imageMap.set( duplicatePair[ 1 ], image );
|
|
|
+ if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ];
|
|
|
+ else images[ id ] = images[ id ].split( '\\' ).pop();
|
|
|
|
|
|
- } else if ( imageMap.has( duplicatePair[ 1 ] ) && ! imageMap.has( duplicatePair[ 0 ] ) ) {
|
|
|
-
|
|
|
- var image = imageMap.get( duplicatePair[ 1 ] );
|
|
|
- imageMap.set( duplicatePair[ 0 ], image );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
- return imageMap;
|
|
|
+ return images;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -287,7 +269,7 @@
|
|
|
// Parse nodes in FBXTree.Objects.Texture
|
|
|
// These contain details such as UV scaling, cropping, rotation etc and are connected
|
|
|
// to images in FBXTree.Objects.Video
|
|
|
- function parseTextures( FBXTree, loader, imageMap, connections ) {
|
|
|
+ function parseTextures( FBXTree, loader, images, connections ) {
|
|
|
|
|
|
var textureMap = new Map();
|
|
|
|
|
@@ -296,7 +278,7 @@
|
|
|
var textureNodes = FBXTree.Objects.Texture;
|
|
|
for ( var nodeID in textureNodes ) {
|
|
|
|
|
|
- var texture = parseTexture( textureNodes[ nodeID ], loader, imageMap, connections );
|
|
|
+ var texture = parseTexture( textureNodes[ nodeID ], loader, images, connections );
|
|
|
textureMap.set( parseInt( nodeID ), texture );
|
|
|
|
|
|
}
|
|
@@ -308,9 +290,9 @@
|
|
|
}
|
|
|
|
|
|
// Parse individual node in FBXTree.Objects.Texture
|
|
|
- function parseTexture( textureNode, loader, imageMap, connections ) {
|
|
|
+ function parseTexture( textureNode, loader, images, connections ) {
|
|
|
|
|
|
- var texture = loadTexture( textureNode, loader, imageMap, connections );
|
|
|
+ var texture = loadTexture( textureNode, loader, images, connections );
|
|
|
|
|
|
texture.ID = textureNode.id;
|
|
|
|
|
@@ -342,40 +324,15 @@
|
|
|
}
|
|
|
|
|
|
// load a texture specified as a blob or data URI, or via an external URL using THREE.TextureLoader
|
|
|
- function loadTexture( textureNode, loader, imageMap, connections ) {
|
|
|
+ function loadTexture( textureNode, loader, images, connections ) {
|
|
|
|
|
|
var fileName;
|
|
|
|
|
|
- var filePath = textureNode.FileName;
|
|
|
- var relativeFilePath = textureNode.RelativeFilename;
|
|
|
-
|
|
|
var children = connections.get( textureNode.id ).children;
|
|
|
|
|
|
- if ( children !== undefined && children.length > 0 && imageMap.has( children[ 0 ].ID ) ) {
|
|
|
+ if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) {
|
|
|
|
|
|
- fileName = imageMap.get( children[ 0 ].ID );
|
|
|
-
|
|
|
- }
|
|
|
- // check that relative path is not an actually an absolute path and if so use it to load texture
|
|
|
- else if ( relativeFilePath !== undefined && relativeFilePath[ 0 ] !== '/' && relativeFilePath.match( /^[a-zA-Z]:/ ) === null ) {
|
|
|
-
|
|
|
- fileName = relativeFilePath;
|
|
|
-
|
|
|
- }
|
|
|
- // texture specified by absolute path
|
|
|
- else {
|
|
|
-
|
|
|
- var split = filePath.split( /[\\\/]/ );
|
|
|
-
|
|
|
- if ( split.length > 0 ) {
|
|
|
-
|
|
|
- fileName = split[ split.length - 1 ];
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- fileName = filePath;
|
|
|
-
|
|
|
- }
|
|
|
+ fileName = images[ children[ 0 ].ID ];
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1519,7 +1476,6 @@
|
|
|
|
|
|
} );
|
|
|
|
|
|
-
|
|
|
bindSkeleton( FBXTree, skeletons, geometryMap, modelMap, connections, sceneGraph );
|
|
|
|
|
|
addAnimations( FBXTree, connections, sceneGraph );
|
|
@@ -2368,6 +2324,7 @@
|
|
|
|
|
|
if ( rawClips === undefined ) return;
|
|
|
|
|
|
+
|
|
|
for ( var key in rawClips ) {
|
|
|
|
|
|
var rawClip = rawClips[ key ];
|