Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions ui/gizmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ function focusCameraOnMesh() {
if (mesh && mesh.name === "ground") mesh = null;
}
if (!mesh) return;
applyMeshSelection(mesh);

mesh.computeWorldMatrix(true);
const { min, max } = mesh.getHierarchyBoundingVectors(true);
Expand All @@ -401,6 +402,36 @@ function focusCameraOnMesh() {
camera.setTarget(newTarget);
}

function applyMeshSelection(pickedMesh, pickedPoint) {
if (pickedMesh && pickedMesh.name !== "ground") {
if (pickedMesh.parent) {
pickedMesh = getRootMesh(pickedMesh.parent);
pickedMesh.visibility = 0.001;
}
const block = meshMap[pickedMesh?.metadata?.blockKey];
highlightBlockById(Blockly.getMainWorkspace(), block);
gizmoManager.attachToMesh(pickedMesh);
enableBoundingBox(pickedMesh);
return;
}

if (pickedMesh && pickedMesh.name === "ground") {
const roundedPosition = roundVectorToFixed(pickedPoint, 2);
flock.printText({
text: translate("position_readout").replace(
"{position}",
String(roundedPosition),
),
duration: 30,
color: "black",
});
}
if (gizmoManager.attachedMesh) {
resetChildMeshesOfAttachedMesh();
gizmoManager.attachToMesh(null);
}
Comment on lines +429 to +432
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Composite mesh root visibility is not restored on deselect — visual regression

When a composite (e.g. glTF) mesh is selected, applyMeshSelection sets its root's visibility to 0.001 (line 409) so the bounding box renders. On deselect, the deselect path (lines 429-432) calls resetChildMeshesOfAttachedMesh() and gizmoManager.attachToMesh(null). The patched attachToMesh internally calls resetAttachedMeshhideBoundingBox, but neither path calls resetBoundingBoxVisibilityIfManuallyChanged, so the root mesh's visibility stays at 0.001 — the model remains fractionally visible after being "deselected".

turnOffAllGizmos handles this correctly (line 1920), but it is not in the click-to-deselect flow.

🐛 Proposed fix
  if (gizmoManager.attachedMesh) {
+   resetBoundingBoxVisibilityIfManuallyChanged(gizmoManager.attachedMesh);
    resetChildMeshesOfAttachedMesh();
    gizmoManager.attachToMesh(null);
  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/gizmos.js` around lines 429 - 432, The deselect path leaves a composite
root's visibility at 0.001 because resetBoundingBoxVisibilityIfManuallyChanged
isn't called; update the click-to-deselect flow so after
resetChildMeshesOfAttachedMesh() (and before or after
gizmoManager.attachToMesh(null)) you explicitly call
resetBoundingBoxVisibilityIfManuallyChanged for the previously attached mesh (or
invoke the same sequence turnOffAllGizmos uses) so the root mesh visibility is
restored; reference functions: applyMeshSelection,
resetChildMeshesOfAttachedMesh, resetBoundingBoxVisibilityIfManuallyChanged,
resetAttachedMesh, hideBoundingBox, gizmoManager.attachToMesh, and
turnOffAllGizmos to locate where to insert the call.

}

function viewMeshWithCamera() {
let mesh = gizmoManager.attachedMesh;
if (mesh && mesh.name === "ground") mesh = null;
Expand Down Expand Up @@ -1774,34 +1805,8 @@ function handleSelectGizmo() {
duration: 30,
color: "black",
});
if (flock.meshDebug) console.log(pickedMesh.parent);
if (pickedMesh.parent) {
pickedMesh = getRootMesh(pickedMesh.parent);
if (flock.meshDebug) console.log(pickedMesh.visibility);
pickedMesh.visibility = 0.001;
if (flock.meshDebug) console.log(pickedMesh.visibility);
}
const block = meshMap[pickedMesh?.metadata?.blockKey];
highlightBlockById(Blockly.getMainWorkspace(), block);
gizmoManager.attachToMesh(pickedMesh);
pickedMesh.showBoundingBox = true;
} else {
if (pickedMesh && pickedMesh.name === "ground") {
const roundedPosition = roundVectorToFixed(pickedPoint, 2);
flock.printText({
text: translate("position_readout").replace(
"{position}",
String(roundedPosition),
),
duration: 30,
color: "black",
});
}
if (gizmoManager.attachedMesh) {
resetChildMeshesOfAttachedMesh();
gizmoManager.attachToMesh(null);
}
}
applyMeshSelection(pickedMesh, pickedPoint);
setTimeout(() => {
if (!getCanvasCircle()) document.body.style.cursor = "crosshair";
}, 0);
Expand Down
Loading