Skip to content

Commit

Permalink
fix: Fix the tag scaling with parent scale regression (#282)
Browse files Browse the repository at this point in the history
* Fix the tag scaling with parent scale regression

* Re-add the change to handl the submodel ref as a parent
  • Loading branch information
jwills-jdubs committed Oct 18, 2022
1 parent 775446a commit 4483140
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/scene-composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"jest": {
"coverageThreshold": {
"global": {
"lines": 76.84,
"statements": 75.97,
"functions": 76.16,
"branches": 62.5,
"lines": 77.40,
"statements": 76.52,
"functions": 77.02,
"branches": 63.51,
"branchesTrue": 100
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,16 @@ export function AsyncLoadedAnchorWidget({
const parentScale = new THREE.Vector3(1, 1, 1);
let targetParent;
if (parent) {
targetParent = getObject3DFromSceneNodeRef(parent.userData.targetRef);
targetParent ? targetParent.getWorldScale(parentScale) : parent.getWorldScale(parentScale);
const hierarchicalParentNode = getSceneNodeByRef(parent.userData.nodeRef);
let physicalParent = parent;
if (findComponentByType(hierarchicalParentNode, KnownComponentType.SubModelRef)) {
while (physicalParent) {
if (physicalParent.userData.componentTypes?.includes(KnownComponentType.ModelRef)) break;
physicalParent = physicalParent.parent as THREE.Object3D<Event>;
}
}
targetParent = physicalParent;
targetParent.getWorldScale(parentScale);
}

const finalScale = targetParent ? new THREE.Vector3(1, 1, 1).divide(parentScale) : new THREE.Vector3(1, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('AnchorWidget', () => {

const parent = new THREE.Group();
parent.scale.set(2, 2, 2);
getObject3DBySceneNodeRef.mockReturnValue(parent);
getObject3DBySceneNodeRef.mockReturnValueOnce(parent);

const container = renderer.create(<AnchorWidget node={node as any} defaultIcon={DefaultAnchorStatus.Info} />);

Expand Down

0 comments on commit 4483140

Please sign in to comment.