Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add directly constructed Nodes to rootNodes #15089

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dev/core/src/Bones/bone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class Bone extends Node {
bindMatrix: Nullable<Matrix> = null,
index: Nullable<number> = null
) {
super(name, skeleton.getScene());
super(name, skeleton.getScene(), false);
this._skeleton = skeleton;
this._localMatrix = localMatrix?.clone() ?? Matrix.Identity();
this._restMatrix = restMatrix ?? this._localMatrix.clone();
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Cameras/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export class Camera extends Node {
* @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
*/
constructor(name: string, position: Vector3, scene?: Scene, setActiveOnSceneIfNoneActive = true) {
super(name, scene);
super(name, scene, false);

this.getScene().addCamera(this);

Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Lights/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export abstract class Light extends Node implements ISortableLight {
* @param scene The scene the light belongs too
*/
constructor(name: string, scene?: Scene) {
super(name, scene);
super(name, scene, false);
this.getScene().addLight(this);
this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);
this._buildUniformLayout();
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Meshes/transformNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class TransformNode extends Node {
public onAfterWorldMatrixUpdateObservable = new Observable<TransformNode>();

constructor(name: string, scene: Nullable<Scene> = null, isPure = true) {
super(name, scene);
super(name, scene, false);
sebavan marked this conversation as resolved.
Show resolved Hide resolved

if (isPure) {
this.getScene().addTransformNode(this);
Expand Down
7 changes: 6 additions & 1 deletion packages/dev/core/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,18 @@ export class Node implements IBehaviorAware<Node> {
* Creates a new Node
* @param name the name and id to be given to this node
* @param scene the scene this node will be added to
* @param isPure indicates this Node is just a Node, and not a derived class like Mesh or Camera
*/
constructor(name: string, scene: Nullable<Scene> = null) {
public constructor(name: string, scene: Nullable<Scene> = null, isPure = true) {
this.name = name;
this.id = name;
this._scene = <Scene>(scene || EngineStore.LastCreatedScene);
this.uniqueId = this._scene.getUniqueId();
this._initCache();

if (isPure) {
this._addToSceneRootNodes();
}
}

/**
Expand Down