Skip to content
Merged
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
24 changes: 18 additions & 6 deletions api/csg.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if (!mesh) return null;

// Check if mesh itself has valid geometry using multiple methods
const hasVertices = mesh.getTotalVertices && mesh.getTotalVertices() > 0;

Check failure on line 18 in api/csg.js

View workflow job for this annotation

GitHub Actions / eslint

'hasVertices' is assigned a value but never used
const hasPositions =
mesh.getVerticesData &&
mesh.getVerticesData(flock.BABYLON.VertexBuffer.PositionKind);
Expand All @@ -27,8 +27,11 @@
try {
mesh.convertToUnIndexedMesh();
mesh.forceSharedVertices();
} catch (e) {
// Ignore errors, continue with other approaches
} catch (error) {
console.warn(
"[prepareMeshForCSG] Failed to convert mesh geometry:",
error,
);
}
}

Expand Down Expand Up @@ -77,8 +80,11 @@
) {
meshesWithGeometry.push(child);
}
} catch (e) {
// Ignore
} catch (error) {
console.warn(
"[prepareMeshForCSG] Failed to process child mesh geometry:",
error,
);
}
});
}
Expand Down Expand Up @@ -341,11 +347,12 @@
if (mergedMesh) mergedMesh.dispose();
mergedMesh = null;
}
} catch (e) {
} catch (error) {
const emptyMeshes = flock.scene.meshes.filter(
(m) => m.name === modelId && m.getTotalVertices() === 0,
);
emptyMeshes.forEach((m) => m.dispose());
console.warn("[mergeMeshes] CSG merge attempt failed:", error);
csgSucceeded = false;
}

Expand All @@ -361,6 +368,10 @@
true,
);
} catch (mergeError) {
console.warn(
"[mergeMeshes] Mesh.MergeMeshes fallback failed:",
mergeError,
);
return null;
}
}
Expand Down Expand Up @@ -437,7 +448,7 @@
const blockId = modelId;
modelId += "_" + flock.scene.getUniqueId();

const nodeInfo = (n, depth = undefined) => {

Check failure on line 451 in api/csg.js

View workflow job for this annotation

GitHub Actions / eslint

'nodeInfo' is assigned a value but never used
if (!n) return null;
const isMesh = typeof n.getTotalVertices === "function";
return {
Expand Down Expand Up @@ -504,7 +515,8 @@
const tryCSG = (label, fn) => {
try {
return fn();
} catch (e) {
} catch (error) {
console.warn(`[${label}] CSG operation failed:`, error);
return null;
}
};
Expand Down Expand Up @@ -982,7 +994,7 @@
});
});
},
subtractMeshes(modelId, baseMeshName, meshNames, approach = "merge") {

Check failure on line 997 in api/csg.js

View workflow job for this annotation

GitHub Actions / eslint

Duplicate key 'subtractMeshes'
if (approach === "individual") {
return this.subtractMeshesIndividual(modelId, baseMeshName, meshNames);
} else {
Expand Down
11 changes: 6 additions & 5 deletions api/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

export const flockMaterial = {
adjustMaterialTilingToMesh(mesh, material, unitsPerTile = null) {

Check failure on line 8 in api/material.js

View workflow job for this annotation

GitHub Actions / eslint

'unitsPerTile' is assigned a value but never used
return; // Don't scale textures - need to change the mesh UVs instead
},
adjustMaterialTilingForHierarchy(mesh, unitsPerTile) {
Expand Down Expand Up @@ -83,7 +83,8 @@
const b = parseInt(matches[2]);
const result = flock.rgbToHex(r, g, b);
return result.toLowerCase();
} catch (e) {
} catch (error) {
console.warn("Failed to parse color to hex; using default black:", error);
return "#000000";
}
},
Expand Down Expand Up @@ -153,7 +154,7 @@
return new Promise((resolve) => {
flock.whenModelReady(meshName, (mesh) => {
flock.glowMesh(mesh, color);
mesh.metadata?.clones?.forEach((cloneName) =>

Check failure on line 157 in api/material.js

View workflow job for this annotation

GitHub Actions / eslint

'cloneName' is defined but never used
flock.whenModelReady((cloneMesh) =>
flock.glowMesh(cloneMesh, { color: color }),
),
Expand Down Expand Up @@ -803,7 +804,7 @@
});
});
},
hexToRgb(hex) {

Check failure on line 807 in api/material.js

View workflow job for this annotation

GitHub Actions / eslint

Duplicate key 'hexToRgb'
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result
? {
Expand Down Expand Up @@ -871,7 +872,6 @@
});
},
setMaterialInternal(meshName, materials) {

return new Promise((resolve) => {
flock.whenModelReady(meshName, (mesh) => {
flock.applyMaterialToHierarchy(mesh, materials, {
Expand Down Expand Up @@ -1263,9 +1263,10 @@
),
);

const colorDark = colors.length >= 3
? flock.hexToRgb(flock.getColorFromString(colors[2]))
: { r: 0, g: 0, b: 0 };
const colorDark =
colors.length >= 3
? flock.hexToRgb(flock.getColorFromString(colors[2]))
: { r: 0, g: 0, b: 0 };
shaderMaterial.setVector3(
"darkColor",
new flock.BABYLON.Vector3(
Expand Down Expand Up @@ -1435,7 +1436,7 @@
}
}
},
getOrCreateMaterial(colorInput, alpha = 1, scene) {

Check failure on line 1439 in api/material.js

View workflow job for this annotation

GitHub Actions / eslint

'scene' is defined but never used
const isObject =
typeof colorInput === "object" &&
colorInput !== null &&
Expand Down
7 changes: 4 additions & 3 deletions api/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ export const flockModels = {
});

return meshName;
} catch (e) {
} catch (error) {
console.warn("createObject failed; returning error id:", error);
return "error_" + flock.scene.getUniqueId();
}
},
Expand Down Expand Up @@ -425,8 +426,8 @@ export const flockModels = {
container.textures = [];
container.skeletons = [];
container.animationGroups = [];
} catch (_) {
/* ignore */
} catch (error) {
console.warn("releaseContainer cleanup failed:", error);
}
},
};
16 changes: 8 additions & 8 deletions blocks/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,8 @@ function adoptIsolatedDefaultVarsTo(
if (remaining === 0) {
try {
workspace.deleteVariableById(vid);
} catch (_) {
/* ignore */
} catch (error) {
console.warn("Failed to delete unreferenced variable by id:", error);
}
}
}
Expand Down Expand Up @@ -799,8 +799,11 @@ function normalizeVarNameAndIndex(
workspace
.getVariableMap()
.renameVariable(model, `${prefix}${targetSuffix}`);
} catch (_) {
/* ignore rename failures */
} catch (error) {
console.warn(
"Failed to rename variable to lowest available suffix:",
error,
);
}
}

Expand Down Expand Up @@ -870,10 +873,7 @@ export function ensureFreshVarOnDuplicate(
if (!oldVarId) return false;
const oldVarModel = ws.getVariableById(oldVarId);
const { prefix: duplicatePrefix, suffix: duplicateSuffix } =
deriveVariableNameParts(
oldVarModel?.name,
variableNamePrefix,
);
deriveVariableNameParts(oldVarModel?.name, variableNamePrefix);

if (Number.isInteger(duplicateSuffix)) {
const nextFromSource = duplicateSuffix + 1;
Expand Down
6 changes: 4 additions & 2 deletions blocks/materials.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ export function defineMaterialsBlocks() {
const validatedVal = flock.getColorFromString(newVal) || "#000000";
this.sourceBlock_.setColour(validatedVal);
return newVal;
} catch (e) {
} catch (error) {
console.warn("Failed to validate colour field value:", error);
this.sourceBlock_.setColour("#000000");
return newVal;
}
Expand All @@ -573,7 +574,8 @@ export function defineMaterialsBlocks() {
const initialVal = colorField.getValue();
const validatedVal = flock.getColorFromString(initialVal) || "#000000";
this.setColour(validatedVal);
} catch (e) {
} catch (error) {
console.warn("Failed to initialize colour block value:", error);
this.setColour("#000000");
}
},
Expand Down
4 changes: 2 additions & 2 deletions main/blocklyinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ export function createBlocklyWorkspace() {

// Manually create a navigation-deferring toolbox
class NavigationDeferringToolbox extends Blockly.Toolbox {
onKeyDown_(e) {
onKeyDown_() {
return false; // Defer to keyboard navigation plugin
}
}
Expand All @@ -682,7 +682,7 @@ export function createBlocklyWorkspace() {

// Monkey-patch
const toolbox = workspace.getToolbox();
toolbox.onKeyDown_ = function (e) {
toolbox.onKeyDown_ = function () {
return false;
};

Expand Down
2 changes: 1 addition & 1 deletion main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ window.onload = async function () {

document
.getElementById("info-details")
.addEventListener("toggle", function (e) {
.addEventListener("toggle", function () {
if (this.open) {
setTimeout(() => {
const content = this.querySelector(".content");
Expand Down
13 changes: 10 additions & 3 deletions scripts/run-api-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,11 @@ async function runTests(suiteId = "all") {
window.apiCallLog.push(
`[${timestamp}] ${methodName} (#${count}) ${argsStr}`,
);
} catch (e) {
} catch (error) {
console.warn(
"Failed to serialize API call arguments for logging:",
error,
);
window.apiCallLog.push(
`[${timestamp}] ${methodName} (#${count})`,
);
Expand All @@ -746,8 +750,11 @@ async function runTests(suiteId = "all") {
};
})(prop, window._originalFlockMethods[prop]);
}
} catch (e) {
// Skip properties that can't be accessed
} catch (error) {
console.warn(
"Skipping inaccessible flock property during instrumentation:",
error,
);
}
}

Expand Down
6 changes: 4 additions & 2 deletions ui/colourpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,10 @@ class CustomColorPicker {
const eyeDropper = new EyeDropper();
const result = await eyeDropper.open(); // resolves or throws on cancel
this.setColor(result.sRGBHex);
} catch (e) {
// Cancel or error — just restore UI
} catch (error) {
if (error?.name !== "AbortError") {
console.warn("Eyedropper failed:", error);
}
} finally {
this.restoreUIAfterEyedropper();
}
Expand Down
Loading