-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jscad CLI fails to load some STL files #1365
Comments
Perhaps best to load files as binary and allow the actual serializers to decode as utf-8 if they require text? |
@eldanb thanks for the nice details. in core/web/walkfiletree.js, STL files are treated as binary, and the deserializer actually checks for text versus binary format. So, I think that your analysis is correct. So, if you have time then please create a PR with your change. A reference to the STL file would be nice as well. |
Opened #1366 |
@eldanb please try the new release. If satisfied then close this issue as well. thanks for the fixes! |
Looks great. Thanks so much. |
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)
The text was updated successfully, but these errors were encountered: