Lambert Material Morph Option Threejs Docs


I’m trying to understand / replicate the animation of expanding and shrinking vertices in the morph targets section. If you go to:
and click on the morph targets check box in controls, you will see what I’m talking about.

It goes from this
to this
and repeats

From looking at the source code on that page, I think I understand that the generateMorphTargets() function has a lot to do with it

function generateMorphTargets( mesh, geometry ) {

	var vertices = [], scale;

	for ( var i = 0; i < geometry.vertices.length; i ++ ) {

		vertices.push( geometry.vertices[ i ].clone() );

		scale = 1 + Math.random() * 0.3;

		vertices[ vertices.length - 1 ].x *= scale;
		vertices[ vertices.length - 1 ].y *= scale;
		vertices[ vertices.length - 1 ].z *= scale;


	geometry.morphTargets.push( { name: 'target1', vertices: vertices } );


but then in the render() section of the source code i don’t understand where mesh.morphTargetInfluences is coming from. Here’s what I mean:

		var render = function () {

				requestAnimationFrame( render );

				var time = * 0.001;

				mesh.rotation.x += 0.005;
				mesh.rotation.y += 0.005;

				if ( prevFog !== scene.fog ) {

					mesh.material.needsUpdate = true;
					prevFog = scene.fog;


				if ( mesh.morphTargetInfluences ) {

					mesh.morphTargetInfluences[ 0 ] = ( 1 + Math.sin( 4 * time ) ) / 2;


				renderer.render( scene, camera );


I would greatly appreciate your help! I just want to learn how to replicate the morph targets effect shown on the threejs docs page for lambert materials! If anyone could provide their code and an explanation for how they did it, I would really appreciate it!

Maybe it would be better to start from something basic? :slight_smile:

I appreciate the quick response but I think I understand the more basic morph target tutorial. Could you explain how to do the more complicated stuff?

I have made this example not very long ago :slight_smile:

I just got it! Thanks! I just had to initialize the array for morphTargetInfluences before I started working on it


This is the example that you should be looking at for morph targets since it uses buffer geometry: