Skip to content
Draft
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions ui/blockmesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const colorFields = {
SLEEVES_COLOR: true,
};

export function getRootMesh(mesh) {
if (flock.meshDebug) console.log(mesh.parent);
if (mesh.parent && mesh.name === "__root__") return mesh.parent;
return getRootMesh(mesh.parent);
}

export function updateOrCreateMeshFromBlock(block, changeEvent) {

if (flock.meshDebug)
Expand Down
12 changes: 10 additions & 2 deletions ui/gizmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -621,7 +621,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
Expand All @@ -639,6 +639,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);
Expand Down