Skip to content

Commit

Permalink
Merge pull request #15089 from ryantrem/node-as-root
Browse files Browse the repository at this point in the history
Add directly constructed Nodes to rootNodes
  • Loading branch information
ryantrem committed May 13, 2024
2 parents d457869 + 31300af commit 4cf7f4d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
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);

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

0 comments on commit 4cf7f4d

Please sign in to comment.