From ccf218c39461d70cbe16a84b99cb1fb0913fdd89 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:04:54 +0100 Subject: [PATCH 01/23] Add debug message to get parent of picked mesh when using select gizmo --- ui/gizmos.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/gizmos.js b/ui/gizmos.js index d1fb4a7..624ee74 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -639,6 +639,7 @@ export function toggleGizmo(gizmoType) { color: "black" }); + if (flock.meshDebug) console.log(pickedMesh.parent); const block = meshMap[blockKey]; highlightBlockById(Blockly.getMainWorkspace(), block); From 1353acbe7260b3efdb456a5ca2fa8e415ebad4f8 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:16:57 +0100 Subject: [PATCH 02/23] Create function in ui/blockmesh.js for returning the root of a composite mesh --- ui/blockmesh.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/blockmesh.js b/ui/blockmesh.js index 948ced5..1c9a28b 100644 --- a/ui/blockmesh.js +++ b/ui/blockmesh.js @@ -23,6 +23,13 @@ const colorFields = { SLEEVES_COLOR: true, }; +export function getRootMesh(mesh) { + if (mesh.parent && mesh.name === "__root__") { + return mesh; + } + return getRootMesh(mesh.parent); +} + export function updateOrCreateMeshFromBlock(block, changeEvent) { if (flock.meshDebug) console.log("Update or create mesh from block", block.type, changeEvent.type); From 79c632b94ee2fe3149ef8a30eef82acc2d111ab1 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:20:48 +0100 Subject: [PATCH 03/23] Add debug message to getRootMesh and rewrite conditional block in getRootMesh as one line --- ui/blockmesh.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/blockmesh.js b/ui/blockmesh.js index 1c9a28b..e21a923 100644 --- a/ui/blockmesh.js +++ b/ui/blockmesh.js @@ -24,9 +24,8 @@ const colorFields = { }; export function getRootMesh(mesh) { - if (mesh.parent && mesh.name === "__root__") { - return mesh; - } + if (flock.meshDebug) console.log(mesh.parent); + if (mesh.parent && mesh.name === "__root__") return mesh; return getRootMesh(mesh.parent); } From bc54b21fbbb159d0741182c4e2fbac2a9163c8f8 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:21:43 +0100 Subject: [PATCH 04/23] Make pickedMesh no longer a constant in pointerObserver for select gizmo --- ui/gizmos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 624ee74..f7fdbc6 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -621,7 +621,7 @@ export function toggleGizmo(gizmoType) { gizmoManager.attachedMesh, ).metadata.blockKey; } - const pickedMesh = event.pickInfo.pickedMesh; + pickedMesh = event.pickInfo.pickedMesh; if (pickedMesh && pickedMesh.name !== "ground") { // Assuming 'mesh' is your Babylon.js mesh object From cb59285789e984439046ad4c876710ea8e9d7915 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:22:57 +0100 Subject: [PATCH 05/23] Use getRootMesh function from ui/blockmesh.js to retrieve root from composite mesh with select gizmo in ui/gizmos.js --- ui/gizmos.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index f7fdbc6..379d8e6 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -3,7 +3,7 @@ import * as Blockly from "blockly"; import { meshMap, meshBlockIdMap } from "../generators"; import { flock } from "../flock.js"; import { setPositionValues } from "./addmeshes.js"; -import { getMeshFromBlockKey, updateBlockColorAndHighlight } from "./blockmesh.js"; +import { getMeshFromBlockKey, getRootMesh, updateBlockColorAndHighlight } from "./blockmesh.js"; export let gizmoManager; const blueColor = flock.BABYLON.Color3.FromHexString("#0072B2"); // Colour for X-axis @@ -641,6 +641,8 @@ export function toggleGizmo(gizmoType) { if (flock.meshDebug) console.log(pickedMesh.parent); + if (pickedMesh.parent) pickedMesh = getRootMesh(pickedMesh.parent); + const block = meshMap[blockKey]; highlightBlockById(Blockly.getMainWorkspace(), block); From 96017d6dad22bd78cf859f0630ecf530cfac8390 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:24:38 +0100 Subject: [PATCH 06/23] Fix error of undefined pickedMesh by actually defining pickedMesh as a variable (my mistake, sorry) --- ui/gizmos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 379d8e6..7a78422 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -621,7 +621,7 @@ export function toggleGizmo(gizmoType) { gizmoManager.attachedMesh, ).metadata.blockKey; } - pickedMesh = event.pickInfo.pickedMesh; + let pickedMesh = event.pickInfo.pickedMesh; if (pickedMesh && pickedMesh.name !== "ground") { // Assuming 'mesh' is your Babylon.js mesh object From 2f25e0ca1daf03d1a19b4230bd640c0eb0eee12c Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 8 Sep 2025 15:30:50 +0100 Subject: [PATCH 07/23] Rewrite getRootMesh to ensure parent mesh with name "__root__" is returned --- ui/blockmesh.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/blockmesh.js b/ui/blockmesh.js index e21a923..9a77d33 100644 --- a/ui/blockmesh.js +++ b/ui/blockmesh.js @@ -25,7 +25,7 @@ const colorFields = { export function getRootMesh(mesh) { if (flock.meshDebug) console.log(mesh.parent); - if (mesh.parent && mesh.name === "__root__") return mesh; + if (mesh.parent && mesh.parent.name === "__root__") return mesh.parent; return getRootMesh(mesh.parent); } From c26a1bd9c2ed5ae7d9a8b3d6070fefe047f9f730 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 15 Sep 2025 09:16:36 +0100 Subject: [PATCH 08/23] Set root mesh visibility TODO: - Unset it when mesh is deselected - FIgure out why it somehow still isn't working yet --- ui/gizmos.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index f1fe8a1..55b550d 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -641,7 +641,12 @@ export function toggleGizmo(gizmoType) { if (flock.meshDebug) console.log(pickedMesh.parent); - if (pickedMesh.parent) pickedMesh = getRootMesh(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[blockKey]; highlightBlockById(Blockly.getMainWorkspace(), block); From 010a9fd892fee95a1b63ffe89941fbadbf40480e Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Mon, 15 Sep 2025 12:38:30 +0100 Subject: [PATCH 09/23] Get getRootMesh to return parent of "__root__" mesh in order to show bounding box properly TODO: Figure out how to reset parent mesh visibility upon deselection of composite mesh --- ui/blockmesh.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/blockmesh.js b/ui/blockmesh.js index 5235c67..35fdd9b 100644 --- a/ui/blockmesh.js +++ b/ui/blockmesh.js @@ -25,7 +25,7 @@ const colorFields = { export function getRootMesh(mesh) { if (flock.meshDebug) console.log(mesh.parent); - if (mesh.parent && mesh.parent.name === "__root__") return mesh.parent; + if (mesh.parent && mesh.name === "__root__") return mesh.parent; return getRootMesh(mesh.parent); } From c61d0347f5c729bd3edfedb2ba55a6ec9ba06280 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Wed, 17 Sep 2025 10:21:55 +0100 Subject: [PATCH 10/23] Reset bounding box visibility in one place and create empty resetMesh function --- ui/gizmos.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/gizmos.js b/ui/gizmos.js index 55b550d..1eeed10 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -55,6 +55,10 @@ document.addEventListener("DOMContentLoaded", function () { } }); +function resetMesh(mesh) { + +} + function pickMeshFromCanvas() { const canvas = flock.scene.getEngine().getRenderingCanvas(); @@ -1464,6 +1468,7 @@ export function setGizmoManager(value) { } if (gizmoManager.attachedMesh) { + if (gizmoManager.attachedMesh.visibility === 0.001) gizmoManager.attachedMesh.visibility = 0; gizmoManager.attachedMesh.showBoundingBox = false; gizmoManager.attachedMesh .getChildMeshes() From f7cd958e4e37dbf75701d8932e6988f35a1f9f60 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Thu, 18 Sep 2025 12:49:27 +0100 Subject: [PATCH 11/23] Complete resetMesh function and use it to reset bounding box settings in all places --- ui/gizmos.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 1eeed10..d0d23c0 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -56,7 +56,8 @@ document.addEventListener("DOMContentLoaded", function () { }); function resetMesh(mesh) { - + if (mesh.visibility === 0.001) mesh.visibility = 0; + mesh.showBoundingBox = false; } function pickMeshFromCanvas() { @@ -458,10 +459,10 @@ export function toggleGizmo(gizmoType) { gizmoManager.boundingBoxGizmoEnabled = false; if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.showBoundingBox = false; + gizmoManager.attachedMesh.resetMesh(); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (child.resetMesh())); } document.body.style.cursor = "default"; @@ -617,10 +618,10 @@ export function toggleGizmo(gizmoType) { const pointerObserver = pointerObservable.add((event) => { if (event.type === flock.BABYLON.PointerEventTypes.POINTERPICK) { if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.showBoundingBox = false; + gizmoManager.attachedMesh.resetMesh(); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (child.resetMesh())); blockKey = findParentWithBlockId( gizmoManager.attachedMesh, ).metadata.blockKey; @@ -681,7 +682,7 @@ export function toggleGizmo(gizmoType) { if (gizmoManager.attachedMesh) { gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (child.resetMesh())); gizmoManager.attachToMesh(null); // Detach the gizmo } } @@ -1316,10 +1317,10 @@ export function toggleGizmo(gizmoType) { function turnOffAllGizmos() { if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.showBoundingBox = false; + gizmoManager.attachedMesh.resetMesh(); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (child.resetMesh())); } gizmoManager.attachToMesh(null); gizmoManager.positionGizmoEnabled = false; @@ -1468,11 +1469,10 @@ export function setGizmoManager(value) { } if (gizmoManager.attachedMesh) { - if (gizmoManager.attachedMesh.visibility === 0.001) gizmoManager.attachedMesh.visibility = 0; - gizmoManager.attachedMesh.showBoundingBox = false; + gizmoManager.attachedMesh.resetMesh(); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (child.resetMesh())); if (mesh) { while (mesh && mesh.parent && !mesh.parent.physics) { From 1e00cf58de77a729a5051333100309cfe92a18fa Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Thu, 18 Sep 2025 13:01:50 +0100 Subject: [PATCH 12/23] Add debug log for resetMesh --- ui/gizmos.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/gizmos.js b/ui/gizmos.js index d0d23c0..bb911a5 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -58,6 +58,7 @@ document.addEventListener("DOMContentLoaded", function () { function resetMesh(mesh) { if (mesh.visibility === 0.001) mesh.visibility = 0; mesh.showBoundingBox = false; + if (flock.meshDebug) console.log(mesh.visibility); } function pickMeshFromCanvas() { From dc40add1f7be76a6c4cec61dfee360d2873bf53a Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Thu, 18 Sep 2025 13:02:12 +0100 Subject: [PATCH 13/23] Make sure resetMesh gets properly called as a function passing in the mesh itself --- ui/gizmos.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index bb911a5..94e066d 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -460,10 +460,10 @@ export function toggleGizmo(gizmoType) { gizmoManager.boundingBoxGizmoEnabled = false; if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.resetMesh(); + resetMesh(gizmoManager.attachedMesh); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.resetMesh())); + .forEach((child) => (resetMesh(child))); } document.body.style.cursor = "default"; @@ -619,10 +619,10 @@ export function toggleGizmo(gizmoType) { const pointerObserver = pointerObservable.add((event) => { if (event.type === flock.BABYLON.PointerEventTypes.POINTERPICK) { if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.resetMesh(); + resetMesh(gizmoManager.attachedMesh); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.resetMesh())); + .forEach((child) => (resetMesh(child))); blockKey = findParentWithBlockId( gizmoManager.attachedMesh, ).metadata.blockKey; @@ -683,7 +683,7 @@ export function toggleGizmo(gizmoType) { if (gizmoManager.attachedMesh) { gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.resetMesh())); + .forEach((child) => (resetMesh(child))); gizmoManager.attachToMesh(null); // Detach the gizmo } } @@ -1318,10 +1318,10 @@ export function toggleGizmo(gizmoType) { function turnOffAllGizmos() { if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.resetMesh(); + resetMesh(gizmoManager.attachedMesh); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.resetMesh())); + .forEach((child) => (resetMesh(child))); } gizmoManager.attachToMesh(null); gizmoManager.positionGizmoEnabled = false; @@ -1470,10 +1470,10 @@ export function setGizmoManager(value) { } if (gizmoManager.attachedMesh) { - gizmoManager.attachedMesh.resetMesh(); + resetMesh(gizmoManager.attachedMesh); gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.resetMesh())); + .forEach((child) => (resetMesh(child))); if (mesh) { while (mesh && mesh.parent && !mesh.parent.physics) { From 34f3abda34225ffb6822ded50ec7efcdfd816aff Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 12:42:04 +0100 Subject: [PATCH 14/23] Cherry pick c26a1bd9c2ed5ae7d9a8b3d6070fefe047f9f730 "Set root mesh visibility TODO: - Unset it when mesh is deselected - FIgure out why it somehow still isn't working yet" Conflicts: ui/gizmos.js --- ui/gizmos.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/gizmos.js b/ui/gizmos.js index da5b265..748c5ea 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -640,6 +640,14 @@ export function toggleGizmo(gizmoType) { 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[blockKey]; highlightBlockById(Blockly.getMainWorkspace(), block); From 49b67482546ccd6225390ac8a8cb10b4d0261b0a Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 13:38:58 +0100 Subject: [PATCH 15/23] Import getRootMesh from ui/blockmesh.js into ui/gizmos.js (again) so it gets used in ui/gizmos.js when selecting mesh with parent with select gizmo --- ui/gizmos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 748c5ea..8eafc83 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -3,7 +3,7 @@ import * as Blockly from "blockly"; import { meshMap, meshBlockIdMap } from "../generators"; import { flock } from "../flock.js"; import { setPositionValues } from "./addmeshes.js"; -import { getMeshFromBlockKey, updateBlockColorAndHighlight } from "./blockmesh.js"; +import { getMeshFromBlockKey, getRootMesh, updateBlockColorAndHighlight } from "./blockmesh.js"; export let gizmoManager; const blueColor = flock.BABYLON.Color3.FromHexString("#0072B2"); // Colour for X-axis From 3fc7dae2add40237c00f739b185aa81d34d1cd05 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 17:47:23 +0100 Subject: [PATCH 16/23] Turn pickedMesh from constant to variable so that it can be reassigned Bounding box now shows for whole mesh, but visibility still needs to be reset from 0.001 --- ui/gizmos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 8eafc83..937a755 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -622,7 +622,7 @@ export function toggleGizmo(gizmoType) { gizmoManager.attachedMesh, ).metadata.blockKey; } - const pickedMesh = event.pickInfo.pickedMesh; + let pickedMesh = event.pickInfo.pickedMesh; if (pickedMesh && pickedMesh.name !== "ground") { // Assuming 'mesh' is your Babylon.js mesh object From 2754d465efe1ce08df6c7f95be5b0277d5d37897 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 18:53:17 +0100 Subject: [PATCH 17/23] Separate bounding box visibility reset line into own function --- ui/gizmos.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 937a755..e9f382b 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -310,14 +310,18 @@ function findParentWithBlockId(mesh) { return null; } +function resetBoundingBoxVisibility(mesh) { + mesh.showBoundingBox = false; +} + function resetChildMeshesOfAttachedMesh() { gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (child.showBoundingBox = false)); + .forEach((child) => (resetBoundingBoxVisibility(child))); } function resetAttachedMesh() { - gizmoManager.attachedMesh.showBoundingBox = false; + resetBoundingBoxVisibility(gizmoManager.attachedMesh); resetChildMeshesOfAttachedMesh(); } @@ -640,13 +644,13 @@ export function toggleGizmo(gizmoType) { color: "black" }); - if (flock.meshDebug) console.log(pickedMesh.parent); + /* if (flock.meshDebug) */ console.log(pickedMesh.parent); if (pickedMesh.parent) { pickedMesh = getRootMesh(pickedMesh.parent); - if (flock.meshDebug) console.log(pickedMesh.visibility); + /* if (flock.meshDebug) */ console.log(pickedMesh.visibility); pickedMesh.visibility = 0.001; - if (flock.meshDebug) console.log(pickedMesh.visibility); + /* if (flock.meshDebug) */ console.log(pickedMesh.visibility); } const block = meshMap[blockKey]; From b6680452bcc46388f4538c253bfcc76ff6e6b1c4 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 18:55:40 +0100 Subject: [PATCH 18/23] Add manual composite mesh reset code to resetBoundingBoxVisibility --- ui/gizmos.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/gizmos.js b/ui/gizmos.js index e9f382b..eda4a04 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -311,6 +311,7 @@ function findParentWithBlockId(mesh) { } function resetBoundingBoxVisibility(mesh) { + if (mesh.visibility === 0.001) mesh.visibility = 0; mesh.showBoundingBox = false; } From fc9d28dd9733d7298d5bad42245d8cfec7689cb6 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 18:57:34 +0100 Subject: [PATCH 19/23] Rename resetBoundingBoxVisibility to hideBoundingBox --- ui/gizmos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index eda4a04..660921a 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -310,7 +310,7 @@ function findParentWithBlockId(mesh) { return null; } -function resetBoundingBoxVisibility(mesh) { +function hideBoundingBox(mesh) { if (mesh.visibility === 0.001) mesh.visibility = 0; mesh.showBoundingBox = false; } @@ -318,11 +318,11 @@ function resetBoundingBoxVisibility(mesh) { function resetChildMeshesOfAttachedMesh() { gizmoManager.attachedMesh .getChildMeshes() - .forEach((child) => (resetBoundingBoxVisibility(child))); + .forEach((child) => (hideBoundingBox(child))); } function resetAttachedMesh() { - resetBoundingBoxVisibility(gizmoManager.attachedMesh); + hideBoundingBox(gizmoManager.attachedMesh); resetChildMeshesOfAttachedMesh(); } From cc9c712bc1cb03de15a96db375d0bfa443a6a821 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 18:59:38 +0100 Subject: [PATCH 20/23] Separate mesh visibility reset line into own function --- ui/gizmos.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 660921a..93cb9e8 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -310,8 +310,14 @@ function findParentWithBlockId(mesh) { return null; } -function hideBoundingBox(mesh) { +// For composite meshes where visibility needs setting to +// 0.001 in order to show parent mesh's bounding box +function resetBoundingBoxVisibilityIfManuallySet() { if (mesh.visibility === 0.001) mesh.visibility = 0; +} + +function hideBoundingBox(mesh) { + resetBoundingBoxVisibilityIfManuallySet(); mesh.showBoundingBox = false; } From e5a0fb616983e2705e1f7bb77921bafdd65dbb42 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 19:01:08 +0100 Subject: [PATCH 21/23] Do not call resetBoundingBoxVisibilityIfManuallySet in hideBoundingBox --- ui/gizmos.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index 93cb9e8..e60c7d6 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -317,7 +317,7 @@ function resetBoundingBoxVisibilityIfManuallySet() { } function hideBoundingBox(mesh) { - resetBoundingBoxVisibilityIfManuallySet(); + // resetBoundingBoxVisibilityIfManuallySet(); mesh.showBoundingBox = false; } From ab3bda93a69ece333d875c45907e6abcfe925566 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 20:09:48 +0100 Subject: [PATCH 22/23] Only reset bounding box visibility of composite mesh when all gizmos are turned off Done by passing gizmoManager.attachedMesh into resetBoundingBoxVisibilityIfManuallyChanged (renamed from resetBoundingBoxVisibilityIfManuallySet) and checking if it exists inside function and calling newly renamed function in turnOffAllGizmos --- ui/gizmos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index e60c7d6..dcbdd28 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -312,12 +312,11 @@ function findParentWithBlockId(mesh) { // For composite meshes where visibility needs setting to // 0.001 in order to show parent mesh's bounding box -function resetBoundingBoxVisibilityIfManuallySet() { - if (mesh.visibility === 0.001) mesh.visibility = 0; +function resetBoundingBoxVisibilityIfManuallyChanged(mesh) { + if (mesh && mesh.visibility === 0.001) mesh.visibility = 0; } function hideBoundingBox(mesh) { - // resetBoundingBoxVisibilityIfManuallySet(); mesh.showBoundingBox = false; } @@ -1322,6 +1321,7 @@ export function toggleGizmo(gizmoType) { } function turnOffAllGizmos() { + resetBoundingBoxVisibilityIfManuallyChanged(gizmoManager.attachedMesh); resetAttachedMeshIfMeshAttached(); gizmoManager.attachToMesh(null); gizmoManager.positionGizmoEnabled = false; From ea37b75722c32dd6e456d81924496941bbdc6081 Mon Sep 17 00:00:00 2001 From: Zishan Rahman Date: Sat, 20 Sep 2025 20:48:09 +0100 Subject: [PATCH 23/23] Enforce debug flags on comments --- ui/gizmos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/gizmos.js b/ui/gizmos.js index dcbdd28..d53560f 100644 --- a/ui/gizmos.js +++ b/ui/gizmos.js @@ -650,13 +650,13 @@ export function toggleGizmo(gizmoType) { color: "black" }); - /* if (flock.meshDebug) */ console.log(pickedMesh.parent); + if (flock.meshDebug) console.log(pickedMesh.parent); if (pickedMesh.parent) { pickedMesh = getRootMesh(pickedMesh.parent); - /* if (flock.meshDebug) */ console.log(pickedMesh.visibility); + if (flock.meshDebug) console.log(pickedMesh.visibility); pickedMesh.visibility = 0.001; - /* if (flock.meshDebug) */ console.log(pickedMesh.visibility); + if (flock.meshDebug) console.log(pickedMesh.visibility); } const block = meshMap[blockKey];