@@ -2271,40 +2271,42 @@ export class _Exporter {
22712271 inverseBindMatrices . push ( bone . getInvertedAbsoluteTransform ( ) ) ;
22722272
22732273 const transformNode = bone . getTransformNode ( ) ;
2274- if ( transformNode ) {
2274+ if ( transformNode && nodeMap [ transformNode . uniqueId ] !== null && nodeMap [ transformNode . uniqueId ] !== undefined ) {
22752275 skin . joints . push ( nodeMap [ transformNode . uniqueId ] ) ;
22762276 } else {
22772277 Tools . Warn ( "Exporting a bone without a linked transform node is currently unsupported" ) ;
22782278 }
22792279 }
22802280
2281- // create buffer view for inverse bind matrices
2282- const byteStride = 64 ; // 4 x 4 matrix of 32 bit float
2283- const byteLength = inverseBindMatrices . length * byteStride ;
2284- const bufferViewOffset = binaryWriter . getByteOffset ( ) ;
2285- const bufferView = _GLTFUtilities . _CreateBufferView ( 0 , bufferViewOffset , byteLength , undefined , "InverseBindMatrices" + " - " + skeleton . name ) ;
2286- this . _bufferViews . push ( bufferView ) ;
2287- const bufferViewIndex = this . _bufferViews . length - 1 ;
2288- const bindMatrixAccessor = _GLTFUtilities . _CreateAccessor (
2289- bufferViewIndex ,
2290- "InverseBindMatrices" + " - " + skeleton . name ,
2291- AccessorType . MAT4 ,
2292- AccessorComponentType . FLOAT ,
2293- inverseBindMatrices . length ,
2294- null ,
2295- null ,
2296- null
2297- ) ;
2298- const inverseBindAccessorIndex = this . _accessors . push ( bindMatrixAccessor ) - 1 ;
2299- skin . inverseBindMatrices = inverseBindAccessorIndex ;
2300- this . _skins . push ( skin ) ;
2301- skinMap [ skeleton . uniqueId ] = this . _skins . length - 1 ;
2302-
2303- inverseBindMatrices . forEach ( ( mat ) => {
2304- mat . m . forEach ( ( cell : number ) => {
2305- binaryWriter . setFloat32 ( cell ) ;
2281+ if ( skin . joints . length > 0 ) {
2282+ // create buffer view for inverse bind matrices
2283+ const byteStride = 64 ; // 4 x 4 matrix of 32 bit float
2284+ const byteLength = inverseBindMatrices . length * byteStride ;
2285+ const bufferViewOffset = binaryWriter . getByteOffset ( ) ;
2286+ const bufferView = _GLTFUtilities . _CreateBufferView ( 0 , bufferViewOffset , byteLength , undefined , "InverseBindMatrices" + " - " + skeleton . name ) ;
2287+ this . _bufferViews . push ( bufferView ) ;
2288+ const bufferViewIndex = this . _bufferViews . length - 1 ;
2289+ const bindMatrixAccessor = _GLTFUtilities . _CreateAccessor (
2290+ bufferViewIndex ,
2291+ "InverseBindMatrices" + " - " + skeleton . name ,
2292+ AccessorType . MAT4 ,
2293+ AccessorComponentType . FLOAT ,
2294+ inverseBindMatrices . length ,
2295+ null ,
2296+ null ,
2297+ null
2298+ ) ;
2299+ const inverseBindAccessorIndex = this . _accessors . push ( bindMatrixAccessor ) - 1 ;
2300+ skin . inverseBindMatrices = inverseBindAccessorIndex ;
2301+ this . _skins . push ( skin ) ;
2302+ skinMap [ skeleton . uniqueId ] = this . _skins . length - 1 ;
2303+
2304+ inverseBindMatrices . forEach ( ( mat ) => {
2305+ mat . m . forEach ( ( cell : number ) => {
2306+ binaryWriter . setFloat32 ( cell ) ;
2307+ } ) ;
23062308 } ) ;
2307- } ) ;
2309+ }
23082310 }
23092311 return promiseChain . then ( ( ) => {
23102312 return skinMap ;
0 commit comments