MCPcopy Create free account
hub / github.com/CNCKitchen/stlTexturizer / parseTransform

Function parseTransform

js/stlLoader.js:347–360  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

345 // transform — both rotation/scale parts and translation parts.
346 const rootUnit = (rootDoc.documentElement.getAttribute('unit') || 'millimeter').toLowerCase();
347 const unitScale = UNIT_TO_MM[rootUnit] ?? 1;
348 const unitMatrix = new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale);
349
350 // Collect final mesh instances: { meshKey, matrix }
351 const instances = [];
352
353 function parseTransform(str) {
354 if (!str) return new THREE.Matrix4();
355 const v = str.trim().split(/\s+/).map(Number);
356 if (v.length === 12) {
357 // 3MF row-major 3×4: m00 m01 m02 m10 m11 m12 m20 m21 m22 tx ty tz
358 return new THREE.Matrix4().set(
359 v[0], v[3], v[6], v[9],
360 v[1], v[4], v[7], v[10],
361 v[2], v[5], v[8], v[11],
362 0, 0, 0, 1,
363 );

Callers 2

resolveObjectFunction · 0.85
parse3MFFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected