JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
When running a project through the Jscad CLI some imported STL files may file.
This may also be related to issue #1333.
It seems like registerDeserializer in registerExtensions.js registers a wrapper that loads the file using fs.readFileSync, passing utf-8 as the encoding. However if the file is binary, this may cause codepage translation to corrupt it.
Patching locally to use 'binary' as the encoding works for these STL files but obviously may cause other problems if there are importers that assume utf8....
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
bad triangle vertice coords/normal: 1
WARNING: import errors: 7 (some triangles might be misaligned or missing)
Error: point 1503 must be an array of X, Y, Z values
at /Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/modeling/src/primitives/polyhedron.js:50:41
at Array.forEach ()
at Object.polyhedron (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/modeling/src/primitives/polyhedron.js:49:10)
at toPolyhedron (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:372:21)
at elementFormatterObject (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:54:80)
at deserializeBinarySTL (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:273:11)
at deserialize (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:62:34)
at _require.extensions. [as .stl] (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/core/src/io/registerExtensions.js:20:20)
at Module.load (node:internal/modules/cjs/loader:1282:32)
at Module._load (node:internal/modules/cjs/loader:1098:12)
When running a project through the Jscad CLI some imported STL files may file.
This may also be related to issue #1333.
It seems like registerDeserializer in registerExtensions.js registers a wrapper that loads the file using fs.readFileSync, passing utf-8 as the encoding. However if the file is binary, this may cause codepage translation to corrupt it. Patching locally to use 'binary' as the encoding works for these STL files but obviously may cause other problems if there are importers that assume utf8....
Example project failing:
example_project.zip
CLI command invocation:
node "node_modules/@jscad/cli/cli.js" "/Users/eldan/Desktop/jscadproject" -o "/var/folders/d4/2ffmpbdn51ld1mb7_k7gj4240000gn/T/vscode-jscad-GbnSqf/output.stl"
Output:
bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 bad triangle vertice coords/normal: 1 WARNING: import errors: 7 (some triangles might be misaligned or missing) Error: point 1503 must be an array of X, Y, Z values at /Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/modeling/src/primitives/polyhedron.js:50:41 at Array.forEach ()
at Object.polyhedron (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/modeling/src/primitives/polyhedron.js:49:10)
at toPolyhedron (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:372:21)
at elementFormatterObject (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:54:80)
at deserializeBinarySTL (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:273:11)
at deserialize (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/stl-deserializer/index.js:62:34)
at _require.extensions. [as .stl] (/Users/eldan/dev/priv/vscode-jscad/node_modules/@jscad/core/src/io/registerExtensions.js:20:20)
at Module.load (node:internal/modules/cjs/loader:1282:32)
at Module._load (node:internal/modules/cjs/loader:1098:12)