Summary
scissionGeom3.js converts vec3 arrays to strings for use as Map keys, which is expensive when done repeatedly.
Usage Frequency: LOW
Only used by scission() operation.
Typical model usage: Rare - maybe 1% of models
Problem
File: packages/modeling/src/operations/booleans/scissionGeom3.js
Lines: 9-22, 35
const insertMapping = (map, point, index) => {
const key = \`\${point}\` // Calls toString on array, creates string
const mapping = map.get(key)
if (mapping === undefined) {
map.set(key, [index])
} else {
mapping.push(index)
}
}
const findMapping = (map, point) => {
const key = \`\${point}\` // String creation again
return map.get(key)
}
Called in loops:
polygons.forEach((polygon, index) => {
polygon.vertices.forEach((point) => {
insertMapping(indexesPerPoint, vec3.snap(temp, point, eps), index)
})
})
For a geometry with 10,000 vertices, this creates 10,000+ strings just for lookups.
Suggested Fix
Consider alternative approaches:
- Use a spatial hash with integer keys
- Cache the string representation on first computation
- Use a custom Map implementation that handles vec3 keys directly
// Option 1: Spatial hash with integer key
const spatialKey = (point, eps) => {
const scale = 1 / eps
return \`\${Math.round(point[0] * scale)},\${Math.round(point[1] * scale)},\${Math.round(point[2] * scale)}\`
}
// This still creates strings but they're shorter and computed once per lookup
Impact
Low overall (rare operation), but contributes to overhead when scission is used.
Summary
scissionGeom3.jsconverts vec3 arrays to strings for use as Map keys, which is expensive when done repeatedly.Usage Frequency: LOW
Only used by
scission()operation.Typical model usage: Rare - maybe 1% of models
Problem
File:
packages/modeling/src/operations/booleans/scissionGeom3.jsLines: 9-22, 35
Called in loops:
For a geometry with 10,000 vertices, this creates 10,000+ strings just for lookups.
Suggested Fix
Consider alternative approaches:
Impact
Low overall (rare operation), but contributes to overhead when scission is used.