Skip to content

Commit fdb80f3

Browse files
committed
fix(reconciler): fix parent logic on highlight layer
1 parent 5d87ba8 commit fdb80f3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/library/src/components/hosts/MeshHost.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe('Meshes tests', () => {
7373
);
7474
const highlightLayer = scene.getHighlightLayerByName(highlightLayerName) as HighlightLayer;
7575
const box = scene.getMeshById(boxName) as BabylonEntity<MeshProps & Mesh>;
76+
expect(box.parent).toBeNull();
7677
expect(box.highlightLayerParent).toBeTruthy();
7778
expect(highlightLayer.hasMesh(box)).toBeTruthy();
7879
});

packages/library/src/reconciler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ const IS_REACT_19 = version.startsWith('19');
1818
type CommitUpdateV19 = [Instance, string, CoreHostProps | GuiHostProps, CoreHostProps | GuiHostProps, any];
1919
type EventPriority = any;
2020

21-
function isParentNeeded(child: BabylonEntity) {
21+
function isParentNeeded(child: BabylonEntity, parent: BabylonEntity) {
2222
if (isInstanceOf(child, 'Material')) {
2323
return false;
2424
}
2525
if (isInstanceOf(child, 'BaseTexture')) {
2626
return false;
2727
}
28-
if (isInstanceOf(child, 'HighlightLayer')) {
28+
if (isInstanceOf(parent, 'HighlightLayer')) {
2929
return false;
3030
}
3131
return true;
@@ -187,7 +187,7 @@ function mountBabylonEntity(parent: Instance | RootContainer, child: Instance, i
187187
// TODO: decouple handlers and Babylon.js entity
188188
child.entity!.handlers?.addChild?.(_parent.entity!, child.entity!, { siblingIndex });
189189
if (child.babylonPackage === BabylonPackages.CORE) {
190-
if (isParentNeeded(child.entity!)) {
190+
if (isParentNeeded(child.entity!, _parent.entity!)) {
191191
try {
192192
child.entity!.parent = _parent.entity;
193193
} catch {

0 commit comments

Comments
 (0)