MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / applyDefaultMetalMaterial

Function applyDefaultMetalMaterial

preview.js:381–397  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

379 }
380 }
381
382 const MAX_STL_TRIANGLES = 10000000;
383
384 function validateSTLBuffer(buffer) {
385 if (buffer.byteLength < 84) throw new Error('STL file too small to be valid');
386 const dv = new DataView(buffer);
387 const triangleCount = dv.getUint32(80, true);
388 const expectedBinarySize = 84 + triangleCount * 50;
389 if (expectedBinarySize === buffer.byteLength && triangleCount > MAX_STL_TRIANGLES) {
390 throw new Error(
391 `STL has too many triangles (${triangleCount.toLocaleString()}). Max ${MAX_STL_TRIANGLES.toLocaleString()}. File may be corrupted.`
392 );
393 }
394 }
395
396 function loadSTLFromPath(filePath, loadToken) {
397 return new Promise((resolve, reject) => {
398 if (!THREE.STLLoader) {
399 reject(new Error('STLLoader not available'));
400 return;

Callers 1

loadPreviewModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected