diff --git a/src/foundation/components/SceneGraphComponent.ts b/src/foundation/components/SceneGraphComponent.ts index 95b3ccc0e..3a74b0e9a 100644 --- a/src/foundation/components/SceneGraphComponent.ts +++ b/src/foundation/components/SceneGraphComponent.ts @@ -24,6 +24,7 @@ export default class SceneGraphComponent extends Component { private static __sceneGraphs: SceneGraphComponent[] = []; public isAbleToBeParent: boolean; private __children: Array = []; + private __gizmoChildren: Array = []; private _worldMatrix: MutableMatrix44 = MutableMatrix44.dummy(); private _normalMatrix: MutableMatrix33 = MutableMatrix33.dummy(); private __isWorldMatrixUpToDate = false; @@ -164,13 +165,22 @@ export default class SceneGraphComponent extends Component { this.parent?.setWorldAABBDirtyParentRecursively(); } - addChild(sg: SceneGraphComponent) { - if (this.__children != null) { - sg.__parent = this; - this.__children.push(sg); - } else { - console.error('This is not allowed to have children.'); - } + /** + * add a SceneGraph component as a child of this + * @param sg a SceneGraph component of Gizmo + */ + public addChild(sg: SceneGraphComponent): void { + sg.__parent = this; + this.__children.push(sg); + } + + /** + * add a SceneGraph component as a child of this (But Gizmo only) + * @param sg a SceneGraph component of Gizmo + */ + _addGizmoChild(sg: SceneGraphComponent): void { + sg.__parent = this; + this.__gizmoChildren.push(sg); } get isTopLevel() { diff --git a/src/foundation/gizmos/AABBGizmo.ts b/src/foundation/gizmos/AABBGizmo.ts index 42192904f..ca47ced0c 100644 --- a/src/foundation/gizmos/AABBGizmo.ts +++ b/src/foundation/gizmos/AABBGizmo.ts @@ -63,7 +63,7 @@ export default class AABBGizmo extends Gizmo { ]); this.__topEntity.tryToSetUniqueName(`AABBGizmo_of_${this.__target.uniqueName}`, true); this.__topEntity.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix = true; - this.__target.getSceneGraph().addChild(this.__topEntity.getSceneGraph()); + this.__target.getSceneGraph()._addGizmoChild(this.__topEntity.getSceneGraph()); const meshComponent = this.__topEntity.getMesh(); AABBGizmo.__mesh = new Mesh(); diff --git a/src/foundation/gizmos/LocatorGizmo.ts b/src/foundation/gizmos/LocatorGizmo.ts index 4a9409287..54f2f787a 100644 --- a/src/foundation/gizmos/LocatorGizmo.ts +++ b/src/foundation/gizmos/LocatorGizmo.ts @@ -71,7 +71,7 @@ export default class LocatorGizmo extends Gizmo { ]); this.__topEntity.tryToSetUniqueName(`LocatorGizmo_of_${this.__target.uniqueName}`, true); this.__topEntity.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix = true; - this.__target.getSceneGraph().addChild(this.__topEntity.getSceneGraph()); + this.__target.getSceneGraph()._addGizmoChild(this.__topEntity.getSceneGraph()); const meshComponent = this.__topEntity.getMesh(); LocatorGizmo.__mesh = new Mesh();