Skip to content

Commit

Permalink
Merge pull request #12443 from carolhmj/fixCameraClone
Browse files Browse the repository at this point in the history
[Bug] Fix camera cloning by adding newParent parameter
  • Loading branch information
sebavan authored Apr 25, 2022
2 parents 03884e1 + b7caeea commit 891bad0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/dev/core/src/Cameras/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,16 @@ export class Camera extends Node {
/**
* Clones the current camera.
* @param name The cloned camera name
* @param newParent The cloned camera's new parent (none by default)
* @returns the cloned camera
*/
public clone(name: string): Camera {
public clone(name: string, newParent: Nullable<Node> = null): Camera {
const camera = SerializationHelper.Clone(
Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide),
this
);
camera.name = name;
camera.parent = newParent;

this.onClonedObservable.notifyObservers(camera);

Expand Down

0 comments on commit 891bad0

Please sign in to comment.