# Vertex positions of morphed geometry

**URL:** <https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643>\
**Category:** Questions\
**Tags:** morph-targets, geometry\
**Created:** [March 22, 2021, 5:57pm UTC](https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643 "2021-03-22T17:57:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atlas](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Atlas](https://discourse.threejs.org/u/Atlas)\
**Post date:** [March 22, 2021, 5:57pm UTC](https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643/1 "2021-03-22T17:57:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [March 22, 2021, 9:18pm UTC](https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643/2 "2021-03-22T21:18:20Z")

</div>

> [@Atlas](#):
>
> 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?

Nope. This is required procedure. However, you can use [BufferGeometryUtils.computeMorphedAttributes()](https://threejs.org/docs/index.html?q=buffer#examples/en/utils/BufferGeometryUtils.computeMorphedAttributes) for this use case.

---

<div class="post-metadata">

**Author:** ![Atlas](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Atlas](https://discourse.threejs.org/u/Atlas)\
**Post date:** [March 22, 2021, 11:56pm UTC](https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643/3 "2021-03-22T23:56:43Z")

</div>

Thanks I’ll try it

---

<div class="post-metadata">

**Author:** ![Atlas](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Atlas](https://discourse.threejs.org/u/Atlas)\
**Post date:** [March 23, 2021, 8:59pm UTC](https://discourse.threejs.org/t/vertex-positions-of-morphed-geometry/24643/5 "2021-03-23T20:59:30Z")

</div>

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 );
                }

            }
```
