Hi everyone,
I have some problems rendering my STL file with the STLLoader from ThreeJS.
First, I encountered this error message RangeError: Invalid typed array length: 16367289120.
I imagine it’s because I didn’t give the right path from my file to the loader.
My STL file is in the same directory as my script file (src directory), so I just put the name of the file as the url path like so :
stlLoader.load(‘orthese.stl’, function (geometry) {}
I don’t know which path to give to the loader.
Thanks.
Are you using the latest version of STLLoader
from the three.js
repository?
I did install three.js with npm. I’m actually using the v^0.119.1 from three.js, I don’t know if it’s good or not, let me know if not.
Are you hosting your application on a web server? Please make sure with the browser’s dev tools that the STL asset is actually loaded from your backend.
Here is my project repository : https://github.com/NeroAdvents/threejs-tutorial.git
Feel free to look at the App.js file where I’m using Three.js.
Also, I’m using ReactJS.
Loading the STL file produces this response:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />
<!--
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="/static/js/bundle.js"></script><script src="/static/js/0.chunk.js"></script><script src="/static/js/main.chunk.js"></script></body>
</html>
So there is something wrong with your react app configuration. This issue is unrelated to three.js
.
Yeah, I finally managed to load the model. I guess it wasn’t able to access my src folder because it was private. I put the model inside the public folder and it works fine now.
Thanks for the help !