Right now you cannot clone a THREE.Line when it's geometry attribute is a type of THREE.Geometry.
This is because the clone method calls the constructor without parameters so that the new line's geometry attribute will be constructed as a THREE.BufferGeometry by default. Then the copy method tries to copy a THREE.Geometry object into a THREE.BufferGeometry, which doesn't work.
So shouldn't the clone method look like the one in THREE.Mesh ? meaning:
`clone: function () {
return new this.constructor(this.geometry, this.material).copy( this );
}`
This fiddle shows the error:
I don't know but maybe this kind of problem could exist at other places too.
I think this is a duplicate of #15239 and #15064
@Mugen87
What is the solution? Fiddle from master branch still doesn't work: https://jsfiddle.net/dc5fb0x9/.
TypeError: index is undefined
This is already fixed in dev, see https://jsfiddle.net/62s8gxqp/
Will be available with the next release R103.
Great! Thanks.
Here is a workaround until next release.
/**
* @returns {Line}
*/
function cloneLine() {
return new this.constructor(this.geometry, this.material).copy(this);
}
const line = new THREE.Line(lineGeometry, lineMaterial);
line.clone = cloneLine;
line.clone();
Most helpful comment
This is already fixed in
dev, see https://jsfiddle.net/62s8gxqp/Will be available with the next release
R103.