Skip to content

Commit 0668e95

Browse files
committed
Add three as a dev dependency instead of using cdn packages.
1 parent a2a1db2 commit 0668e95

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

examples/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
<body>
1515
<h1>Spark.js Examples</h1>
1616
<ul id="examples">
17-
<li><a href="basic.html">Basic spark.js example</a></li>
18-
<li><a href="three-basic.html">Basic three.js + spark.js example</a></li>
17+
<li><a href="basic.html">spark.js basic example</a></li>
18+
<li><a href="three-basic.html">three.js + spark.js basic example</a></li>
19+
<li><a href="three-gltf.html">three.js + spark.js GLTF example</a></li>
1920
</ul>
2021
</body>
2122
</html>

examples/three-basic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<body>
1515
<script type="module">
16-
import * as THREE from "https://unpkg.com/three/build/three.webgpu.js";
16+
import * as THREE from "three/webgpu";
1717
import { Spark } from "@ludicon/spark.js";
1818

1919
const errorHTML = `

examples/three-gltf.html

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212

1313
<body>
1414
<script type="module">
15-
import * as THREE from '../../three.js/build/three.webgpu.js';
16-
import { OrbitControls } from '../../three.js/examples/jsm/controls/OrbitControls.js';
17-
import { GLTFLoader } from '../../three.js/examples/jsm/loaders/GLTFLoader.js';
18-
import { RoomEnvironment } from '../../three.js/examples/jsm/environments/RoomEnvironment.js';
19-
import { DRACOLoader } from '../../three.js/examples/jsm/loaders/DRACOLoader.js';
15+
import * as THREE from "three/webgpu";
16+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
17+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
18+
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
2019

21-
import { Spark } from '../dist/index.esm.js';
20+
import { Spark } from "@ludicon/spark.js";
2221

2322
const errorHTML = `
2423
<div style="color: #FFF; padding: 2em; font-family: sans-serif; max-width: 600px; margin: 5em auto; text-align: center;">
@@ -258,21 +257,9 @@ <h1>WebGPU Not Supported</h1>
258257
const loader = new GLTFLoader()
259258
loader.register(parser => new GLTFSparkPlugin(parser, spark));
260259

261-
// Hook up DRACOLoader
262-
const dracoLoader = new DRACOLoader();
263-
dracoLoader.setDecoderPath('./libs/draco/');
264-
loader.setDRACOLoader(dracoLoader);
265-
266260
const gltf = await loader.loadAsync("./assets/DamagedHelmet.glb");
267-
//const gltf = await loader.loadAsync( './assets/LittlestTokyo.glb' );
268-
//const gltf = await loader.loadAsync( './assets/FlightHelmet.gltf' );
269-
//const gltf = await loader.loadAsync( './assets/SciFiHelmet.gltf' );
270-
//const gltf = await loader.loadAsync( './assets/forest_house.glb' );
271-
272261

273262
const box = new THREE.Box3().setFromObject(gltf.scene);
274-
const offset = box.getCenter(new THREE.Vector3());
275-
//gltf.scene.position.sub(offset);
276263
const scale = box.getSize(new THREE.Vector3()).length();
277264
gltf.scene.scale.multiplyScalar(4 / scale);
278265

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@
6161
"npm-run-all": "^4.1.5",
6262
"prettier": "^3.0.0",
6363
"rimraf": "^5.0.0",
64+
"three": "^0.180.0",
6465
"vite": "^7.0.0"
6566
},
67+
"peerDependencies": {
68+
"three": "^0.180.0"
69+
},
6670
"publishConfig": {
6771
"access": "public"
6872
},

0 commit comments

Comments
 (0)