-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(examples): ESMify collada example
- Remove ThreeLoader.js (which was a temporary fix to load pre-v148 ColladaLoader commonJS addons) - Use an importmap to import ColladaLoader addon from a CDN - Refactor this example's script as an ES6 module
- Loading branch information
1 parent
3919b72
commit b82622d
Showing
2 changed files
with
23 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Itowns - collada</title> | ||
|
@@ -21,13 +22,20 @@ | |
<script src="js/GUI/GuiTools.js"></script> | ||
<script src="js/GUI/LoadingScreen.js"></script> | ||
|
||
<!-- Import ThreeLoader plugin to get ColladaLoader from three.js --> | ||
<script src="js/ThreeLoader.js"></script> | ||
|
||
<script type="text/javascript"> | ||
|
||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "https://unpkg.com/[email protected]/build/three.module.js", | ||
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/" | ||
} | ||
} | ||
</script> | ||
|
||
<script type="module"> | ||
// Warning: For now, three is imported twice: in the itowns bundle | ||
// and from the unpkg CDN. | ||
import * as THREE from 'three'; | ||
import { ColladaLoader } from 'three/addons/loaders/ColladaLoader.js'; | ||
|
||
// ---------- CREATE A GlobeView FOR SUPPORTING DATA VISUALIZATION : ---------- | ||
|
||
|
@@ -79,15 +87,10 @@ | |
|
||
// ---------- DISPLAY COLLADA DATA : ---------- | ||
|
||
// ThreeLoader can load each format proposed in ThreeJs examples loaders : | ||
// https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders | ||
// Note : As this previous folder has been removed in three r148, | ||
// TheeLoader will only use loaders from three r147 version. This | ||
// is a temporary solution and shall be updated. | ||
const promiseCollada = ThreeLoader.load( | ||
'Collada', | ||
'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/models/collada/building.dae', | ||
).then(collada => { | ||
const url = 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/models/collada/building.dae'; | ||
|
||
const loader = new ColladaLoader(); | ||
loader.load(url, function (collada) { | ||
const model = collada.scene; | ||
|
||
// building coordinate | ||
|
@@ -109,6 +112,11 @@ | |
view.notifyChange(); | ||
}); | ||
|
||
|
||
// Warning: the following code is not part of this example, those | ||
// variables are only exposed for internal functional test uses. | ||
window.view = view; | ||
|
||
</script> | ||
</body> | ||
</html> |