Skip to content

Commit bf10efc

Browse files
authored
Update SplatLoader to handle progress updates, both for main file and any extra files, aggregating totals. Misc. improvements to examples. (#112)
1 parent 0cfa39d commit bf10efc

File tree

13 files changed

+162
-91
lines changed

13 files changed

+162
-91
lines changed

examples/dynamic-lighting/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/editor/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/envmap/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">
@@ -39,7 +40,7 @@
3940
</script>
4041
<script type="module">
4142
import * as THREE from "three";
42-
import { SplatMesh, SparkRenderer } from "@sparkjsdev/spark";
43+
import { SplatMesh, SparkRenderer, PackedSplats } from "@sparkjsdev/spark";
4344
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
4445
import { getAssetFileURL } from "/examples/js/get-asset-url.js";
4546

@@ -55,13 +56,14 @@
5556
const spark = new SparkRenderer({ renderer });
5657

5758
const splatURL = await getAssetFileURL("fireplace.spz");
58-
const background = new SplatMesh({ url: splatURL });
59+
const packedSplats = new PackedSplats({ url: splatURL });
60+
const background = new SplatMesh({ packedSplats });
5961
background.quaternion.set(1, 0, 0, 0);
6062
background.position.set(0.5, 0, -1);
6163
background.scale.setScalar(0.5);
6264
scene.add(background);
6365

64-
const background2 = new SplatMesh({ url: splatURL });
66+
const background2 = new SplatMesh({ packedSplats });
6567
background2.quaternion.set(1, 0, 0, 0);
6668
background2.rotation.y = Math.PI;
6769
background2.position.set(-0.5, 0, 0.0);
@@ -81,6 +83,7 @@
8183
scene.add(duck);
8284

8385
let lastTime;
86+
let renderedEnvMap = false;
8487
renderer.setAnimationLoop(function animate(time) {
8588
const deltaTime = time - (lastTime || time);
8689
lastTime = time;

examples/hello-world/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/interactivity/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/multiple-splats/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">
@@ -34,7 +35,7 @@
3435
</script>
3536
<script type="module">
3637
import * as THREE from "three";
37-
import { SplatMesh } from "@sparkjsdev/spark";
38+
import { SplatMesh, PackedSplats } from "@sparkjsdev/spark";
3839
import { EXRLoader } from "three/addons/loaders/EXRLoader.js";
3940
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4041
import { getAssetFileURL } from "/examples/js/get-asset-url.js";
@@ -49,16 +50,17 @@
4950
renderer.setClearColor(new THREE.Color(0xFFFFFF), 1);
5051
document.body.appendChild(renderer.domElement)
5152

53+
let splatURL = await getAssetFileURL("butterfly-ai.spz");
54+
const butterflySplats = new PackedSplats({ url: splatURL });
5255
const butterflies = [];
5356
for (let i = 0; i < 6; i++) {
54-
let splatURL = await getAssetFileURL("butterfly-ai.spz");
55-
const splat = new SplatMesh({ url: splatURL });
57+
const splat = new SplatMesh({ packedSplats: butterflySplats });
5658
splat.quaternion.set(1, 0, 0, 0);
5759
scene.add(splat);
5860
butterflies.push(splat);
5961
}
6062

61-
let splatURL = await getAssetFileURL("cat.spz");
63+
splatURL = await getAssetFileURL("cat.spz");
6264
const cat = new SplatMesh({ url: splatURL });
6365
cat.quaternion.set(1, 0, 0, 0);
6466
cat.scale.setScalar(0.5);

examples/multiple-viewpoints/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/particle-simulation/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<!DOCTYPE html>
2+
<html>
3+
24
<head>
35
<meta charset="utf-8">
46
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

examples/procedural-splats/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">

examples/raycasting/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<html>
23

34
<head>
45
<meta charset="utf-8">
@@ -47,8 +48,9 @@
4748
const NUM_ROBOTS = 5;
4849
const robots = [];
4950
const splatURL = await getAssetFileURL("robot-head.spz");
51+
const packedSplats = new PackedSplats({ url: splatURL });
5052
for (let i = 0; i < NUM_ROBOTS; i++) {
51-
const robot = new SplatMesh({ url: splatURL });
53+
const robot = new SplatMesh({ packedSplats });
5254
robot.rotation.x = Math.PI;
5355
robot.scale.setScalar(0.2);
5456
robot.position.set(0, 0, i);

0 commit comments

Comments
 (0)