File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -308,11 +308,6 @@ export class AssetContainer extends AbstractScene {
308308 ...options ,
309309 } ;
310310
311- if ( ! localOptions . doNotInstantiate ) {
312- // Always clone skinned meshes.
313- localOptions . doNotInstantiate = ( node ) => ! ! ( node as AbstractMesh ) . skeleton ;
314- }
315-
316311 const onClone = ( source : TransformNode , clone : TransformNode ) => {
317312 conversionMap [ source . uniqueId ] = clone . uniqueId ;
318313 storeMap [ clone . uniqueId ] = clone ;
@@ -438,7 +433,17 @@ export class AssetContainer extends AbstractScene {
438433 onNewCreated ( instancedNode , replicatedInstancedNode ) ;
439434 } else {
440435 // Mesh or TransformNode
441- const canInstance = ! localOptions ?. doNotInstantiate && ( node as Mesh ) . getTotalVertices ( ) > 0 ;
436+ let canInstance = true ;
437+ if ( node . getClassName ( ) === "TransformNode" || ( node as Mesh ) . skeleton || ( node as Mesh ) . getTotalVertices ( ) === 0 ) {
438+ // Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!
439+ canInstance = false ;
440+ } else if ( localOptions . doNotInstantiate ) {
441+ if ( typeof localOptions . doNotInstantiate === "function" ) {
442+ canInstance = ! localOptions . doNotInstantiate ( node ) ;
443+ } else {
444+ canInstance = ! localOptions . doNotInstantiate ;
445+ }
446+ }
442447 const replicatedNode = canInstance ? ( node as Mesh ) . createInstance ( `instance of ${ node . name } ` ) : node . clone ( `Clone of ${ node . name } ` , null , true ) ;
443448 if ( ! replicatedNode ) {
444449 throw new Error ( `Could not clone or instantiate node on Asset Container ${ node . name } ` ) ;
You can’t perform that action at this time.
0 commit comments