Cannot clone THREE.Line which geometry is type of THREE.Geometry

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.

Three.js version
  • Dev
  • r99
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

1 thought on “Cannot clone THREE.Line which geometry is type of THREE.Geometry

Comments are closed.