Vertex positions of morphed geometry

Is there a way to access the new vertex positions of a morphed geometry without having to calculate them manually by adding the coordinates of the targets times their influences to the ones of the base geometry? Maybe by saving them in a geometry or in an array

Nope. This is required procedure. However, you can use BufferGeometryUtils.computeMorphedAttributes() for this use case.

1 Like

Thanks I’ll try it

Does it work with multiple targets? I tried implementing it but it tells me
Uncaught (in promise) TypeError: morphAttribute is undefined at line 682

I tried to understand where the error occurs and it seems like it cycles through this loop twice and then stops. Morph attributes starts as the array containing all the different morph targets in the first cycle, so morphAttributes[0] is the float32 array containing the positions of the first target. At the second cycle though morphAttributes starts as an individual target rather than the array containing all the targets, so morphAttributes[1] is undefined, and at the third cycle it stops because it’s trying to get the third element of an undefined array

for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) {

                var influence = morphInfluences[ i ];
                var morphAttribute = morphAttribute[ i ];

                if ( influence === 0 ) continue;
                _tempA.fromBufferAttribute( morphAttribute, a );
                _tempB.fromBufferAttribute( morphAttribute, b );
                _tempC.fromBufferAttribute( morphAttribute, c );

                if ( morphTargetsRelative ) {
                    _morphA.addScaledVector( _tempA, influence );
                    _morphB.addScaledVector( _tempB, influence );
                    _morphC.addScaledVector( _tempC, influence );

                } else {
                    _morphA.addScaledVector( _tempA.sub( _vA ), influence );
                    _morphB.addScaledVector( _tempB.sub( _vB ), influence );
                    _morphC.addScaledVector( _tempC.sub( _vC ), influence );