@needle-tools/three 0.154.2 → 0.154.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PropertyBinding,
|
|
8
8
|
QuaternionKeyframeTrack,
|
|
9
9
|
VectorKeyframeTrack,
|
|
10
|
+
SkinnedMesh
|
|
10
11
|
} from 'three';
|
|
11
12
|
|
|
12
13
|
// DUPLICATED from GLTFLoader.js
|
|
@@ -465,89 +466,124 @@ class GLTFAnimationPointerExtension {
|
|
|
465
466
|
animationPointerPropertyPath = animationPointerPropertyPath.replaceAll( '/', '.' );
|
|
466
467
|
// replace node/material/camera/light ID by UUID
|
|
467
468
|
const parts = animationPointerPropertyPath.split( '.' );
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
console.log( node, inputAccessor, outputAccessor, target, animationPointerPropertyPath );
|
|
469
|
+
const hasName = node.name !== undefined && node.name !== null;
|
|
470
|
+
var nodeTargetName = hasName ? node.name : node.uuid;
|
|
471
|
+
parts[ 2 ] = nodeTargetName;
|
|
472
472
|
|
|
473
|
-
|
|
473
|
+
// specially handle the morphTargetInfluences property for multi-material meshes
|
|
474
|
+
// in which case the target object is a Group and the children are the actual targets
|
|
475
|
+
// see NE-3311
|
|
476
|
+
if ( parts[ 3 ] === "morphTargetInfluences" ) {
|
|
474
477
|
|
|
475
|
-
|
|
478
|
+
if( node.type === "Group" ) {
|
|
476
479
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
else
|
|
489
|
-
TypedKeyframeTrack = ColorKeyframeTrack;
|
|
480
|
+
if ( _animationPointerDebug )
|
|
481
|
+
console.log( "Detected multi-material skinnedMesh export", animationPointerPropertyPath, node );
|
|
482
|
+
|
|
483
|
+
// We assume the children are skinned meshes
|
|
484
|
+
for ( const ch of node.children ) {
|
|
485
|
+
if( ch instanceof SkinnedMesh && ch.morphTargetInfluences ) {
|
|
486
|
+
parts[ 3 ] = ch.name;
|
|
487
|
+
parts[ 4 ] = "morphTargetInfluences";
|
|
488
|
+
__createTrack( this.parser );
|
|
489
|
+
}
|
|
490
|
+
}
|
|
490
491
|
|
|
491
|
-
|
|
492
|
+
return tracks;
|
|
493
|
+
}
|
|
492
494
|
|
|
493
495
|
}
|
|
494
496
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
497
|
+
// default
|
|
498
|
+
__createTrack(this.parser);
|
|
499
|
+
|
|
500
|
+
/** Create a new track using the current parts array */
|
|
501
|
+
function __createTrack( parser ) {
|
|
498
502
|
|
|
499
|
-
|
|
500
|
-
if ( animationPointerPropertyPath.endsWith( '.fov' ) ) {
|
|
501
|
-
|
|
502
|
-
outputArray = outputArray.map( value => value / Math.PI * 180 );
|
|
503
|
+
animationPointerPropertyPath = parts.join( '.' );
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
if ( _animationPointerDebug )
|
|
506
|
+
console.log( node, inputAccessor, outputAccessor, target, animationPointerPropertyPath );
|
|
505
507
|
|
|
506
|
-
|
|
507
|
-
animationPointerPropertyPath,
|
|
508
|
-
inputAccessor.array,
|
|
509
|
-
outputArray,
|
|
510
|
-
interpolation
|
|
511
|
-
);
|
|
508
|
+
let TypedKeyframeTrack;
|
|
512
509
|
|
|
513
|
-
|
|
514
|
-
if ( interpolation === 'CUBICSPLINE' ) {
|
|
510
|
+
switch ( outputAccessor.itemSize ) {
|
|
515
511
|
|
|
516
|
-
|
|
512
|
+
case 1:
|
|
513
|
+
TypedKeyframeTrack = NumberKeyframeTrack;
|
|
514
|
+
break;
|
|
515
|
+
case 2:
|
|
516
|
+
case 3:
|
|
517
|
+
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
518
|
+
break;
|
|
519
|
+
case 4:
|
|
517
520
|
|
|
518
|
-
|
|
521
|
+
if ( animationPointerPropertyPath.endsWith( '.quaternion' ) )
|
|
522
|
+
TypedKeyframeTrack = QuaternionKeyframeTrack;
|
|
523
|
+
else
|
|
524
|
+
TypedKeyframeTrack = ColorKeyframeTrack;
|
|
519
525
|
|
|
520
|
-
|
|
526
|
+
break;
|
|
521
527
|
|
|
522
|
-
|
|
523
|
-
// so we need to split that up here and create a separate opacity track if that is animated.
|
|
524
|
-
if ( animationPointerPropertyPath && outputAccessor.itemSize === 4 &&
|
|
525
|
-
animationPointerPropertyPath.startsWith( '.materials.' ) && animationPointerPropertyPath.endsWith( '.color' ) ) {
|
|
528
|
+
}
|
|
526
529
|
|
|
527
|
-
const
|
|
530
|
+
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
|
|
528
531
|
|
|
529
|
-
|
|
532
|
+
let outputArray = parser._getArrayFromAccessor( outputAccessor );
|
|
530
533
|
|
|
531
|
-
|
|
534
|
+
// convert fov values from radians to degrees
|
|
535
|
+
if ( animationPointerPropertyPath.endsWith( '.fov' ) ) {
|
|
536
|
+
|
|
537
|
+
outputArray = outputArray.map( value => value / Math.PI * 180 );
|
|
532
538
|
|
|
533
539
|
}
|
|
534
540
|
|
|
535
|
-
const
|
|
536
|
-
animationPointerPropertyPath
|
|
541
|
+
const track = new TypedKeyframeTrack(
|
|
542
|
+
animationPointerPropertyPath,
|
|
537
543
|
inputAccessor.array,
|
|
538
|
-
|
|
544
|
+
outputArray,
|
|
539
545
|
interpolation
|
|
540
546
|
);
|
|
541
547
|
|
|
542
548
|
// Override interpolation with custom factory method.
|
|
543
549
|
if ( interpolation === 'CUBICSPLINE' ) {
|
|
544
550
|
|
|
545
|
-
|
|
551
|
+
parser._createCubicSplineTrackInterpolant( track );
|
|
546
552
|
|
|
547
553
|
}
|
|
548
554
|
|
|
549
|
-
tracks.push(
|
|
555
|
+
tracks.push( track );
|
|
550
556
|
|
|
557
|
+
// glTF has opacity animation as last component of baseColorFactor,
|
|
558
|
+
// so we need to split that up here and create a separate opacity track if that is animated.
|
|
559
|
+
if ( animationPointerPropertyPath && outputAccessor.itemSize === 4 &&
|
|
560
|
+
animationPointerPropertyPath.startsWith( '.materials.' ) && animationPointerPropertyPath.endsWith( '.color' ) ) {
|
|
561
|
+
|
|
562
|
+
const opacityArray = new Float32Array( outputArray.length / 4 );
|
|
563
|
+
|
|
564
|
+
for ( let j = 0, jl = outputArray.length / 4; j < jl; j += 1 ) {
|
|
565
|
+
|
|
566
|
+
opacityArray[ j ] = outputArray[ j * 4 + 3 ];
|
|
567
|
+
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const opacityTrack = new TypedKeyframeTrack(
|
|
571
|
+
animationPointerPropertyPath.replace( '.color', '.opacity' ),
|
|
572
|
+
inputAccessor.array,
|
|
573
|
+
opacityArray,
|
|
574
|
+
interpolation
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
// Override interpolation with custom factory method.
|
|
578
|
+
if ( interpolation === 'CUBICSPLINE' ) {
|
|
579
|
+
|
|
580
|
+
parser._createCubicSplineTrackInterpolant( track );
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
tracks.push( opacityTrack );
|
|
585
|
+
|
|
586
|
+
}
|
|
551
587
|
}
|
|
552
588
|
|
|
553
589
|
return tracks;
|