未验证 提交 4db07eaf 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16890 from vyv03354/fix14875

GLTFLoader: Support multi-type nodes
...@@ -2914,14 +2914,11 @@ THREE.GLTFLoader = ( function () { ...@@ -2914,14 +2914,11 @@ THREE.GLTFLoader = ( function () {
return ( function () { return ( function () {
// .isBone isn't in glTF spec. See .markDefs var pending = [];
if ( nodeDef.isBone === true ) {
return Promise.resolve( new THREE.Bone() );
} else if ( nodeDef.mesh !== undefined ) { if ( nodeDef.mesh !== undefined ) {
return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) { pending.push( parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
var node; var node;
...@@ -2967,25 +2964,58 @@ THREE.GLTFLoader = ( function () { ...@@ -2967,25 +2964,58 @@ THREE.GLTFLoader = ( function () {
return node; return node;
} ); } ) );
}
} else if ( nodeDef.camera !== undefined ) { if ( nodeDef.camera !== undefined ) {
return parser.getDependency( 'camera', nodeDef.camera ); pending.push( parser.getDependency( 'camera', nodeDef.camera ) );
} else if ( nodeDef.extensions }
if ( nodeDef.extensions
&& nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ] && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ]
&& nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light !== undefined ) { && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light !== undefined ) {
return parser.getDependency( 'light', nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light ); pending.push( parser.getDependency( 'light', nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light ) );
}
return Promise.all( pending );
}() ).then( function ( objects ) {
var node;
// .isBone isn't in glTF spec. See .markDefs
if ( nodeDef.isBone === true ) {
node = new THREE.Bone();
} else if ( objects.length > 1 ) {
node = new THREE.Group();
} else if ( objects.length === 1 ) {
node = objects[ 0 ];
} else { } else {
return Promise.resolve( new THREE.Object3D() ); node = new THREE.Object3D();
} }
}() ).then( function ( node ) { if ( node !== objects[ 0 ] ) {
for ( var i = 0, il = objects.length; i < il; i ++ ) {
node.add( objects[ i ] );
}
}
if ( nodeDef.name !== undefined ) { if ( nodeDef.name !== undefined ) {
...@@ -3069,11 +3099,9 @@ THREE.GLTFLoader = ( function () { ...@@ -3069,11 +3099,9 @@ THREE.GLTFLoader = ( function () {
} ).then( function ( jointNodes ) { } ).then( function ( jointNodes ) {
var meshes = node.isGroup === true ? node.children : [ node ]; node.traverse( function ( mesh ) {
for ( var i = 0, il = meshes.length; i < il; i ++ ) {
var mesh = meshes[ i ]; if ( ! mesh.isMesh ) return;
var bones = []; var bones = [];
var boneInverses = []; var boneInverses = [];
...@@ -3106,7 +3134,7 @@ THREE.GLTFLoader = ( function () { ...@@ -3106,7 +3134,7 @@ THREE.GLTFLoader = ( function () {
mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld ); mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld );
} } );
return node; return node;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册