# Updating morph targets, Does threejs geometry strores final positions or deltas for morph targets when using GLTF/GLB objec?

**URL:** <https://discourse.threejs.org/t/updating-morph-targets-does-threejs-geometry-strores-final-positions-or-deltas-for-morph-targets-when-using-gltf-glb-objec/68401>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [July 21, 2024, 12:59pm UTC](https://discourse.threejs.org/t/updating-morph-targets-does-threejs-geometry-strores-final-positions-or-deltas-for-morph-targets-when-using-gltf-glb-objec/68401 "2024-07-21T12:59:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobby\_S](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/bobby_s/32/49338_2.png) [@Bobby\_S](https://discourse.threejs.org/u/Bobby_S)\
**Post date:** [July 21, 2024, 12:59pm UTC](https://discourse.threejs.org/t/updating-morph-targets-does-threejs-geometry-strores-final-positions-or-deltas-for-morph-targets-when-using-gltf-glb-objec/68401/1 "2024-07-21T12:59:48Z")

</div>

Hi, I have a gltf model B having morph targets. I want to access the total difference(delta) between the final position and base vertex position.Is it possible without applying the morphTargetInfluences.  
Actualy , I want to assign the morph targets of object B to object A. Object A have same geometry but slight difference in vertices positions than B(I am updating it dynamically) .The morph targets should behave relative to A’s base positions not relative to B.Here’s the code I am using .

```javascript
  let positionsA = objA.geometry.attributes.position;
  let morphAttributesB = objA.geometry.morphAttributes.position = [];
  let morphAttributesB = objB.geometry.morphAttributes.position;
  let positionsBaseB =objB.geometry.attributes.position;
 
  const morphDictionary = {}
  // Loop through morph targets 
for ( var j = 0, jl = morphAttributesB.length; j < jl; j ++ ) {
    const targetVertices = [];
    var key = Object.keys(objB.morphTargetDictionary)[j];

    for(var i = 0; i< morphAttributesB[j].array.length;i++){
// calculate delta % per base position change

     let delta = (morphAttributesB[j].array[i] - positionsBaseB.array[i]) / positionsBaseB.array[i] ;
   
     targetVertices[i] = positionsA.array[i] + delta * positionsA.array[i]
     }
    const morphAttribute = new THREE.BufferAttribute(new Float32Array(targetVertices), 3);
    objA.geometry.morphAttributes.position.push(morphAttribute);
    morphDictionary[key] = j;
}
objA.geometry.morphTargetsNeedUpdate = true;

```

However , this is not working and throwing error in render loop.

> Uncaught TypeError: Cannot read properties of undefined (reading ‘length’)  
> at Object.update (three.module.js:17910:1)  
> at setProgram (three.module.js:30554:1)  
> at WebGLRenderer.renderBufferDirect (three.module.js:29235:1)  
> at renderObject (three.module.js:30110:1)  
> at renderObjects (three.module.js:30081:1)  
> at renderScene (three.module.js:29924:1)  
> at WebGLRenderer.render (three.module.js:29742:1)  
> at render$1 (index-99983b2d.esm.js:1544:1)  
> at loop (index-99983b2d.esm.js:1570:1)

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [July 23, 2024, 3:11pm UTC](https://discourse.threejs.org/t/updating-morph-targets-does-threejs-geometry-strores-final-positions-or-deltas-for-morph-targets-when-using-gltf-glb-objec/68401/3 "2024-07-23T15:11:24Z")

</div>

> Does threejs geometry strores final positions or deltas for morph targets when using GLTF/GLB objec?

This is determined by the `geometry.morphTargetsRelative` property. When it’s true, the values stored in the morph targets are assumed to be deltas. Otherwise they are final positions. For geometry loaded from a glTF model, the property will always be true and the attributes will always contain deltas.
