Morph targets with Line2 / LineGeometry not working?

Hi, I’m trying to use the line objects from the examples. I created a Line2 object and I want to modify the line with morph targets, but setting morphTargetInfluences does not have any effect. I’m trying to modify the instanceStart and instanceEnd attributes, as it seems that the line shape depends on these.

In short:


// points is an array of the line points

const geometry = new LineGeometry();
geometry.setPositions(points);
const instanceBuffer = new THREE.InstancedInterleavedBuffer(new Float32Array(points.map(x => -x)), 6, 1);
geometry.morphAttributes.instanceStart = [new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 )];
geometry.morphAttributes.instanceEnd = [new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 )];
let matLine = new LineMaterial({ ... })
let mesh = new Line2(geometry, matLine);
mesh.morphTargetInfluences[0] = 0.5; // no effect

What I am doing wrong?

Thanks

Wide lines do not support morph targets. Even if you configure them on geometry level, the respective line material (to be more precise its shader) does not process them.

1 Like

Ah, thanks! It would be great to put that information somewhere as a comment.

How hard would it be to modify the shader so that it supports it? I’m not familiar with shader development, but if it’s easy enough I can try?

The wide line implementation uses instanced rendering which makes a solution harder. Especially if you are not familiar with instanced rendering.

Besides, do you want to morph each instance separately or all instances equally? The solution for both use cases is different.

I’m okay with having all instances morph equally. For my use case I only have one instance on the screen anyway.