aftre last update, I can’t find threejs and threejs.min.js files inside build folder. any one can descriibe me details about file name changing and how can I use now within html file. please help me.
These files are gone since Three.js r161:
Now we’ve switched to using “import” to load libraries and components.
Put this script tag in your HTML BEFORE any other scripts:
<script type="importmap">
{
"imports": {
"three": "https://threejs.org/build/three.module.js",
"three/addons/": "https://threejs.org/examples/jsm/"
}
}</script>
Load your own script after like:
<script type="module" src="./YourMainScript.js"></script>
(notice the type = ‘module’ means you can now use “import” in your scripts)
Then in YourMainScript.js:
use:
import *as THREE from "three"
import {OrbitControls} from "three/addons/controls/OrbitControls.js"
To load the different things.
With this setup, now you can change where you are pulling threejs and its components, just by changing the importmap. It’s a more flexible mechanism and keeps most of the code interaction in the .js files instead of woven through the html.
awesome, thanks, it’s working perfectly for me.
Thank you for the code manthrax.
But I would like to use threejs in a Blazor hybrid desktop application on a PC which is not always connected to the web.
Is it possible to install it locally?
I have downloaded the three.module.js and three.core.js. and made the déclaration like so
But I get the following error
How can I solve this issue?