<script type="module">
import * as THREE from './build/three.module.js';
</script>
<script type="text/javascript" src="main.js" defer></script>
I have many <script type"text/javascript"> files that reference THREE , but when trying to migrate to using the module of THREE, it can’t reference THREE anymore… How can I reference it from my javascript files???
<script type="module">
import * as THREE from './build/three.module.js';
import {OBJLoader} from './examples/jsm/loaders/OBJLoader.js';
import {MTLLoader} from './examples/jsm/loaders/MTLLoader.js';
import {FBXLoader} from './examples/jsm/loaders/FBXLoader.js';
import {GLTFLoader} from './examples/jsm/loaders/GLTFLoader.js';
import {GLTFExporter} from './examples/jsm/exporters/GLTFExporter.js';
import {SceneUtils} from './examples/jsm/utils/SceneUtils.js';
window.THREE = THREE;
window.OBJLoader = OBJLoader;
window.MTLLoader = MTLLoader;
window.FBXLoader = FBXLoader;
window.GLTFLoader = GLTFLoader;
window.GLTFExporter = GLTFExporter;
window.SceneUtils = SceneUtils;
</script>
…will make them accessible in my text/javascript files , but I have to remove the “THREE.” from the THREE.MTLLoader, etc… in the text/javascript files…
Is that okay to do it this way?
I also realized I don’t use the CominedCamera.js, so I removed that… but I do use an OrbitControls.js, which has a bunch of custom modifications… Maybe I can bring those into the newer orbit controls that is a module…
Okay, I got my project running without errors now on version 124 (I need to migrate to buffergeometry before progressing to 125)…
I just need to figure out the orbit controls now…
You would typically declare your environmental variables like so…
Import {x} from x.js
Import {y} from y.js
var loader, controls;
Init()
function init() {
loader = new GLTFLoader();
Const orbit controls = new OrbitControls( camera, renderer.domElement );
Etc...
}