How to get the morphed mesh from MorphTargetManager?

It is not possible easily as the interpolation is done in the vertex shader and you can’t get the output of it.

What you can do is replicate the calculation in javascript. They are not very complicated as it is only linear interpolations. From the shader code:

	positionUpdated += (position{X} - position) * morphTargetInfluences[{X}];
	normalUpdated += (normal{X} - normal) * morphTargetInfluences[{X}];

	#ifdef MORPHTARGETS_TANGENT += (tangent{X} - * morphTargetInfluences[{X}];

	uvUpdated += (uv_{X} - uv) * morphTargetInfluences[{X}];

position is the unmodified position of the mesh (the one you get by doing mesh.getVerticesData("position")). position{X} are the positions for the target 0, 1, …

For eg, if there are two targets, the computation will be:

positionUpdated += (position0 - position) * morphTargetInfluences[0];
positionUpdated += (position1 - position) * morphTargetInfluences[1];

Same thing for the normal, tangent, uv.

…and welcome to the community!

1 Like