Skip to content

CameraHelper: .clone() is broken #13565

@carstenschwede

Description

@carstenschwede
Description of the problem

CameraHelper::constructor expects a Camera argument, but since CameraHelper::clone is not overwritten it will forward to LineSegments::constructor which expects a geometry and a material.

As a result cameraHelper.camera won't be set and cameraHelper.clone() throws via .update() (see https://jsfiddle.net/bbnk59af/).

Overwriting CameraHelper::clone to account for its own constructor solves the issue (see https://jsfiddle.net/bbnk59af/1/):

THREE.CameraHelper.prototype.clone = function () {
	var clone = new this.constructor(this.camera).copy(this);
	return clone;
}

I am not sure what the intended behaviour is in the case that cameraHelper.clone() gets called as a child of scene.clone(). The cameras and their helpers would be cloned individually, but the cloned helpers would point to the original cameras instead of the cloned ones.

Three.js version
  • Dev
  • r90
Browser
  • All of them
OS
  • All of them

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions