Spaces:
Running
Running
Update the web simulation
Browse files- README.md +15 -14
- assets/environments/kitchen/light/light.json +19 -5
- assets/environments/kitchen/light/lightmap.png +2 -2
- assets/environments/kitchen/light/probes.bin.gz +2 -2
- assets/environments/kitchen/scene.xml +7 -7
- assets/environments/kitchen/tasks/index.json +4 -4
- dist/assets/{GLTFLoader-BHSm5xy3.js → GLTFLoader-CoM4j7iu.js} +1 -1
- dist/assets/{__vite-browser-external--9mz1fMb.js → __vite-browser-external-DxK5cybb.js} +1 -1
- dist/assets/{index-CWolkkxl.js → index-JW4tzj4k.js} +0 -0
- dist/assets/{ort.wasm.bundle.min-DYVS8CAg.js → ort.wasm.bundle.min-C9r-Mk1W.js} +0 -0
- dist/assets/{spark.module-VkkELmBQ.js → spark.module-B9EnJCiT.js} +1 -1
- dist/environments/kitchen/light/light.json +19 -5
- dist/environments/kitchen/light/lightmap.png +2 -2
- dist/environments/kitchen/light/probes.bin.gz +2 -2
- dist/environments/kitchen/scene.xml +7 -7
- dist/environments/kitchen/tasks/index.json +4 -4
- dist/index.html +1 -1
- src/render/baked.js +38 -25
- src/render/statics.js +44 -5
- src/render/view.js +63 -9
- src/robots/fixtures.js +36 -9
- tools/bake_light.mjs +93 -11
- tools/make_kitchen.py +13 -11
README.md
CHANGED
|
@@ -55,19 +55,20 @@ The robot model, its inverse kinematics and keyboard map, and the 3D Gaussian sp
|
|
| 55 |
with ONNX Runtime Web at 50 Hz, and the G1 stands back up after a fall.
|
| 56 |
- **Drag objects** with the mouse.
|
| 57 |
- **Switch renderers**: Toon (cel shading with ink outlines); Lit (PBR materials; in the kitchen, light
|
| 58 |
-
baked offline as a path tracer would light the open room under
|
| 59 |
bouncing between the surfaces: a light map for the scenery and a grid of light probes for the robot,
|
| 60 |
-
the objects, doors and drawers, which also cast a soft shade on what is under them as they move;
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
image-based lighting, shadows and procedural textures;
|
| 64 |
-
powder-coated cart, as the real one); 3DGS (the scene's splat; the robot is lit by light captured from
|
| 65 |
the splat, and its shadows fall on the splat's floor, counters and walls; drawn at 66% of the
|
| 66 |
screen's resolution, which about doubles the frame rate for little sharpness); Pixel (pixel art of the
|
| 67 |
splat, or of the Toon scene where there is none: about 240 rows of whole pixels, 32 colours chosen
|
| 68 |
from what the view shows, and ordered dithering; the modelled scenes keep Toon's ink lines).
|
| 69 |
`?env=tabletop&style=pixel` in the URL opens a scene in a renderer. Walls between the camera and the
|
| 70 |
-
room are drawn as low stubs, so they never hide it (the
|
|
|
|
| 71 |
- **Embed it**: the page runs in an `<iframe>`. It follows the system's light or dark theme unless the
|
| 72 |
URL says `?theme=dark` or the embedding page sends `{type: "xlerobot-sim:theme", theme: "dark"}`
|
| 73 |
(the page posts `{type: "xlerobot-sim:hello"}` to its parent when it starts).
|
|
@@ -210,19 +211,19 @@ than by the machine's clock, so the simulated time they take does not depend on
|
|
| 210 |
| Setting the table | 4 | 1.00 | 5/5 | 69 s | 7.1 m | 0.90, 87 s, 10.9 m | 110 s |
|
| 211 |
| Preparing a snack | 3 | 1.00 | 5/5 | 86 s | 9.3 m | 1.00, 101 s, 13.2 m | 150 s |
|
| 212 |
| Tidying up the kitchen | 5 | 1.00 | 5/5 | 182 s | 24.0 m | 1.00, 182 s, 24.0 m | 280 s |
|
| 213 |
-
| Opening the fridge | 1 | 1.00 | 5/5 | 16 s | 2.
|
| 214 |
| Closing the fridge | 1 | 1.00 | 5/5 | 27 s | 3.9 m | 1.00, 27 s, 3.9 m | 50 s |
|
| 215 |
| Opening the drawer | 1 | 1.00 | 5/5 | 18 s | 3.6 m | 1.00, 18 s, 3.6 m | 30 s |
|
| 216 |
| Closing the drawer | 1 | 1.00 | 5/5 | 19 s | 3.2 m | 1.00, 19 s, 3.2 m | 30 s |
|
| 217 |
| Putting away the cube | 2 | 1.00 | 5/5 | 79 s | 9.9 m | 1.00, 79 s, 9.9 m | 120 s |
|
| 218 |
-
| Chilling the yogurt | 2 | 1.00 | 5/5 |
|
| 219 |
-
| Getting the juice | 2 | 1.00 | 5/5 | 114 s | 13.
|
| 220 |
| Opening the microwave | 1 | 1.00 | 5/5 | 20 s | 2.7 m | 1.00, 20 s, 2.7 m | 40 s |
|
| 221 |
| Closing the microwave | 1 | 1.00 | 5/5 | 18 s | 2.4 m | 1.00, 18 s, 2.4 m | 30 s |
|
| 222 |
-
| Serving a cold drink | 2 | 1.00 | 5/5 |
|
| 223 |
-
| Making breakfast | 4 | 1.00 | 5/5 |
|
| 224 |
-
| Stocking the fridge | 4 | 1.00 | 5/5 |
|
| 225 |
-
| Tidying up after dinner | 6 | 1.00 | 5/5 |
|
| 226 |
| **All** | 53 | 1.00 | 100% | | | | |
|
| 227 |
|
| 228 |
The door and drawer tasks move one object at most, so both ways come to the same.
|
|
|
|
| 55 |
with ONNX Runtime Web at 50 Hz, and the G1 stands back up after a fall.
|
| 56 |
- **Drag objects** with the mouse.
|
| 57 |
- **Switch renderers**: Toon (cel shading with ink outlines); Lit (PBR materials; in the kitchen, light
|
| 58 |
+
baked offline as a path tracer would light the open room under a sky and a sun, with the light
|
| 59 |
bouncing between the surfaces: a light map for the scenery and a grid of light probes for the robot,
|
| 60 |
+
the objects, doors and drawers, which also cast a soft shade on what is under them as they move; the
|
| 61 |
+
sun's own light drawn live, with shadows of everything but the walls, redrawn only when something
|
| 62 |
+
moves; photo textures and furniture models from Poly Haven in place of the modelled sofa, tables,
|
| 63 |
+
chairs and plants; AgX tone mapping; elsewhere image-based lighting, shadows and procedural textures;
|
| 64 |
+
the robot is black plastic on a matte powder-coated cart, as the real one); 3DGS (the scene's splat; the robot is lit by light captured from
|
| 65 |
the splat, and its shadows fall on the splat's floor, counters and walls; drawn at 66% of the
|
| 66 |
screen's resolution, which about doubles the frame rate for little sharpness); Pixel (pixel art of the
|
| 67 |
splat, or of the Toon scene where there is none: about 240 rows of whole pixels, 32 colours chosen
|
| 68 |
from what the view shows, and ordered dithering; the modelled scenes keep Toon's ink lines).
|
| 69 |
`?env=tabletop&style=pixel` in the URL opens a scene in a renderer. Walls between the camera and the
|
| 70 |
+
room are drawn as low stubs, without the pictures and windows on them, so they never hide it (the
|
| 71 |
+
robot's cameras see them whole).
|
| 72 |
- **Embed it**: the page runs in an `<iframe>`. It follows the system's light or dark theme unless the
|
| 73 |
URL says `?theme=dark` or the embedding page sends `{type: "xlerobot-sim:theme", theme: "dark"}`
|
| 74 |
(the page posts `{type: "xlerobot-sim:hello"}` to its parent when it starts).
|
|
|
|
| 211 |
| Setting the table | 4 | 1.00 | 5/5 | 69 s | 7.1 m | 0.90, 87 s, 10.9 m | 110 s |
|
| 212 |
| Preparing a snack | 3 | 1.00 | 5/5 | 86 s | 9.3 m | 1.00, 101 s, 13.2 m | 150 s |
|
| 213 |
| Tidying up the kitchen | 5 | 1.00 | 5/5 | 182 s | 24.0 m | 1.00, 182 s, 24.0 m | 280 s |
|
| 214 |
+
| Opening the fridge | 1 | 1.00 | 5/5 | 16 s | 2.6 m | 1.00, 16 s, 2.6 m | 30 s |
|
| 215 |
| Closing the fridge | 1 | 1.00 | 5/5 | 27 s | 3.9 m | 1.00, 27 s, 3.9 m | 50 s |
|
| 216 |
| Opening the drawer | 1 | 1.00 | 5/5 | 18 s | 3.6 m | 1.00, 18 s, 3.6 m | 30 s |
|
| 217 |
| Closing the drawer | 1 | 1.00 | 5/5 | 19 s | 3.2 m | 1.00, 19 s, 3.2 m | 30 s |
|
| 218 |
| Putting away the cube | 2 | 1.00 | 5/5 | 79 s | 9.9 m | 1.00, 79 s, 9.9 m | 120 s |
|
| 219 |
+
| Chilling the yogurt | 2 | 1.00 | 5/5 | 106 s | 14.1 m | 1.00, 106 s, 14.1 m | 160 s |
|
| 220 |
+
| Getting the juice | 2 | 1.00 | 5/5 | 114 s | 13.6 m | 1.00, 114 s, 13.6 m | 180 s |
|
| 221 |
| Opening the microwave | 1 | 1.00 | 5/5 | 20 s | 2.7 m | 1.00, 20 s, 2.7 m | 40 s |
|
| 222 |
| Closing the microwave | 1 | 1.00 | 5/5 | 18 s | 2.4 m | 1.00, 18 s, 2.4 m | 30 s |
|
| 223 |
+
| Serving a cold drink | 2 | 1.00 | 5/5 | 108 s | 13.1 m | 1.00, 108 s, 13.1 m | 170 s |
|
| 224 |
+
| Making breakfast | 4 | 1.00 | 5/5 | 172 s | 20.9 m | 1.00, 172 s, 20.9 m | 260 s |
|
| 225 |
+
| Stocking the fridge | 4 | 1.00 | 5/5 | 216 s | 26.4 m | 1.00, 216 s, 26.4 m | 330 s |
|
| 226 |
+
| Tidying up after dinner | 6 | 1.00 | 5/5 | 330 s | 32.6 m | 1.00, 340 s, 37.7 m | 520 s |
|
| 227 |
| **All** | 53 | 1.00 | 100% | | | | |
|
| 228 |
|
| 229 |
The door and drawer tasks move one object at most, so both ways come to the same.
|
assets/environments/kitchen/light/light.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
{
|
| 2 |
"about": "Baked by tools/bake_light.mjs; used by src/render/view.js when the fingerprint matches the page's layout.",
|
| 3 |
-
"fingerprint": "
|
| 4 |
"lightmap": {
|
| 5 |
"file": "lightmap.png",
|
| 6 |
"width": 1024,
|
| 7 |
-
"height":
|
| 8 |
"density": 40
|
| 9 |
},
|
| 10 |
"probes": {
|
|
@@ -27,10 +27,24 @@
|
|
| 27 |
},
|
| 28 |
"scale": 1.6,
|
| 29 |
"sky": [
|
| 30 |
-
|
| 31 |
-
0.
|
| 32 |
-
|
| 33 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
"samples": 256,
|
| 35 |
"bounces": 3
|
| 36 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"about": "Baked by tools/bake_light.mjs; used by src/render/view.js when the fingerprint matches the page's layout.",
|
| 3 |
+
"fingerprint": "6cc47e11",
|
| 4 |
"lightmap": {
|
| 5 |
"file": "lightmap.png",
|
| 6 |
"width": 1024,
|
| 7 |
+
"height": 920,
|
| 8 |
"density": 40
|
| 9 |
},
|
| 10 |
"probes": {
|
|
|
|
| 27 |
},
|
| 28 |
"scale": 1.6,
|
| 29 |
"sky": [
|
| 30 |
+
0.9,
|
| 31 |
+
0.95,
|
| 32 |
+
1
|
| 33 |
],
|
| 34 |
+
"sun": {
|
| 35 |
+
"direction": [
|
| 36 |
+
0.32139,
|
| 37 |
+
-0.55667,
|
| 38 |
+
0.76604
|
| 39 |
+
],
|
| 40 |
+
"irradiance": 4.5,
|
| 41 |
+
"color": [
|
| 42 |
+
1,
|
| 43 |
+
0.93,
|
| 44 |
+
0.83
|
| 45 |
+
],
|
| 46 |
+
"radius": 1.2
|
| 47 |
+
},
|
| 48 |
"samples": 256,
|
| 49 |
"bounces": 3
|
| 50 |
}
|
assets/environments/kitchen/light/lightmap.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
assets/environments/kitchen/light/probes.bin.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2c5032acb0dea218546562b9d26786e32ed19e0c38275864256e24f78f21900
|
| 3 |
+
size 370750
|
assets/environments/kitchen/scene.xml
CHANGED
|
@@ -393,9 +393,9 @@
|
|
| 393 |
<geom type="cylinder" fromto="0.026 -0.42 0.67 0.033 -0.42 0.67" size="0.01" material="magnet_1" density="0" contype="0" conaffinity="0"/>
|
| 394 |
<geom type="box" pos="0.026 -0.36 0.38" size="0.001 0.05 0.06" material="note_2" density="0" contype="0" conaffinity="0"/>
|
| 395 |
<geom type="cylinder" fromto="0.026 -0.36 0.43 0.033 -0.36 0.43" size="0.01" material="magnet_2" density="0" contype="0" conaffinity="0"/>
|
| 396 |
-
<geom name="fridge_handle" type="capsule" fromto="0.087 -0.
|
| 397 |
-
<geom type="box" pos="0.056 -0.
|
| 398 |
-
<geom type="box" pos="0.056 -0.
|
| 399 |
</body>
|
| 400 |
<body name="island" pos="0 0 0">
|
| 401 |
<geom name="island_top" type="box" pos="-1.2 0.14 0.8" size="0.35 0.51 0.02" material="countertop" contype="1" conaffinity="1"/>
|
|
@@ -740,10 +740,10 @@
|
|
| 740 |
<geom type="cylinder" fromto="-1.72 2.585 1.95 -1.72 2.58 1.95" size="0.145" material="clock_face" density="0" contype="0" conaffinity="0"/>
|
| 741 |
<geom type="box" pos="-1.72 2.578 1.99" size="0.006 0.002 0.05" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 742 |
<geom type="box" pos="-1.69 2.578 1.95" size="0.04 0.002 0.005" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 743 |
-
<geom type="box" pos="-2.996 -2.
|
| 744 |
-
<geom type="box" pos="-2.992 -2.
|
| 745 |
-
<geom type="box" pos="-
|
| 746 |
-
<geom type="box" pos="-
|
| 747 |
<geom type="box" pos="2.596 -1.75 1.55" size="0.006 0.45 0.3" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 748 |
<geom type="box" pos="2.592 -1.75 1.55" size="0.004 0.42 0.27" material="canvas_2" density="0" contype="0" conaffinity="0"/>
|
| 749 |
</body>
|
|
|
|
| 393 |
<geom type="cylinder" fromto="0.026 -0.42 0.67 0.033 -0.42 0.67" size="0.01" material="magnet_1" density="0" contype="0" conaffinity="0"/>
|
| 394 |
<geom type="box" pos="0.026 -0.36 0.38" size="0.001 0.05 0.06" material="note_2" density="0" contype="0" conaffinity="0"/>
|
| 395 |
<geom type="cylinder" fromto="0.026 -0.36 0.43 0.033 -0.36 0.43" size="0.01" material="magnet_2" density="0" contype="0" conaffinity="0"/>
|
| 396 |
+
<geom name="fridge_handle" type="capsule" fromto="0.087 -0.58 -0.65 0.087 -0.58 -0.15" size="0.012" material="steel" mass="0.1" contype="1" conaffinity="1"/>
|
| 397 |
+
<geom type="box" pos="0.056 -0.58 -0.58" size="0.031 0.006 0.006" material="steel" mass="0.02" contype="1" conaffinity="1"/>
|
| 398 |
+
<geom type="box" pos="0.056 -0.58 -0.22" size="0.031 0.006 0.006" material="steel" mass="0.02" contype="1" conaffinity="1"/>
|
| 399 |
</body>
|
| 400 |
<body name="island" pos="0 0 0">
|
| 401 |
<geom name="island_top" type="box" pos="-1.2 0.14 0.8" size="0.35 0.51 0.02" material="countertop" contype="1" conaffinity="1"/>
|
|
|
|
| 740 |
<geom type="cylinder" fromto="-1.72 2.585 1.95 -1.72 2.58 1.95" size="0.145" material="clock_face" density="0" contype="0" conaffinity="0"/>
|
| 741 |
<geom type="box" pos="-1.72 2.578 1.99" size="0.006 0.002 0.05" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 742 |
<geom type="box" pos="-1.69 2.578 1.95" size="0.04 0.002 0.005" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 743 |
+
<geom type="box" pos="-2.996 -2.32 1.62" size="0.006 0.2 0.16" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 744 |
+
<geom type="box" pos="-2.992 -2.32 1.62" size="0.004 0.18 0.14" material="canvas_0" density="0" contype="0" conaffinity="0"/>
|
| 745 |
+
<geom type="box" pos="-1.5 -2.596 1.6" size="0.18 0.006 0.24" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 746 |
+
<geom type="box" pos="-1.5 -2.592 1.6" size="0.16 0.004 0.22" material="canvas_1" density="0" contype="0" conaffinity="0"/>
|
| 747 |
<geom type="box" pos="2.596 -1.75 1.55" size="0.006 0.45 0.3" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 748 |
<geom type="box" pos="2.592 -1.75 1.55" size="0.004 0.42 0.27" material="canvas_2" density="0" contype="0" conaffinity="0"/>
|
| 749 |
</body>
|
assets/environments/kitchen/tasks/index.json
CHANGED
|
@@ -356,7 +356,7 @@
|
|
| 356 |
"title": "Chilling the yogurt",
|
| 357 |
"file": "chilling_the_yogurt.bddl",
|
| 358 |
"instruction": "Put the yogurt from the kitchen island in the fridge, and close the fridge.",
|
| 359 |
-
"timeLimit":
|
| 360 |
},
|
| 361 |
{
|
| 362 |
"id": "getting_the_juice",
|
|
@@ -391,21 +391,21 @@
|
|
| 391 |
"title": "Making breakfast",
|
| 392 |
"file": "making_breakfast.bddl",
|
| 393 |
"instruction": "Take the juice box and the yogurt out of the fridge to the dining table, close the fridge, and put the radio on.",
|
| 394 |
-
"timeLimit":
|
| 395 |
},
|
| 396 |
{
|
| 397 |
"id": "stocking_the_fridge",
|
| 398 |
"title": "Stocking the fridge",
|
| 399 |
"file": "stocking_the_fridge.bddl",
|
| 400 |
"instruction": "Put the shopping away: the yogurt and the juice box from the kitchen island in the fridge, the cola on the pantry shelf; then close the fridge.",
|
| 401 |
-
"timeLimit":
|
| 402 |
},
|
| 403 |
{
|
| 404 |
"id": "tidying_up_after_dinner",
|
| 405 |
"title": "Tidying up after dinner",
|
| 406 |
"file": "tidying_up_after_dinner.bddl",
|
| 407 |
"instruction": "After dinner: the mug and the cup from the dining table go in the sink, the cola back in the fridge, the toy cube in the island's drawer; and the fridge and the drawer get closed.",
|
| 408 |
-
"timeLimit":
|
| 409 |
}
|
| 410 |
],
|
| 411 |
"storage": [
|
|
|
|
| 356 |
"title": "Chilling the yogurt",
|
| 357 |
"file": "chilling_the_yogurt.bddl",
|
| 358 |
"instruction": "Put the yogurt from the kitchen island in the fridge, and close the fridge.",
|
| 359 |
+
"timeLimit": 160
|
| 360 |
},
|
| 361 |
{
|
| 362 |
"id": "getting_the_juice",
|
|
|
|
| 391 |
"title": "Making breakfast",
|
| 392 |
"file": "making_breakfast.bddl",
|
| 393 |
"instruction": "Take the juice box and the yogurt out of the fridge to the dining table, close the fridge, and put the radio on.",
|
| 394 |
+
"timeLimit": 260
|
| 395 |
},
|
| 396 |
{
|
| 397 |
"id": "stocking_the_fridge",
|
| 398 |
"title": "Stocking the fridge",
|
| 399 |
"file": "stocking_the_fridge.bddl",
|
| 400 |
"instruction": "Put the shopping away: the yogurt and the juice box from the kitchen island in the fridge, the cola on the pantry shelf; then close the fridge.",
|
| 401 |
+
"timeLimit": 330
|
| 402 |
},
|
| 403 |
{
|
| 404 |
"id": "tidying_up_after_dinner",
|
| 405 |
"title": "Tidying up after dinner",
|
| 406 |
"file": "tidying_up_after_dinner.bddl",
|
| 407 |
"instruction": "After dinner: the mug and the cup from the dining table go in the sink, the cola back in the fridge, the toy cube in the island's drawer; and the fridge and the drawer get closed.",
|
| 408 |
+
"timeLimit": 520
|
| 409 |
}
|
| 410 |
],
|
| 411 |
"storage": [
|
dist/assets/{GLTFLoader-BHSm5xy3.js → GLTFLoader-CoM4j7iu.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,F as s,G as c,H as l,I as u,J as d,L as f,M as p,N as m,Nt as h,O as g,P as ee,Q as _,St as te,T as v,Tt as ne,U as y,V as b,W as x,X as S,Y as re,Z as C,_t as ie,at as ae,b as oe,bt as se,c as ce,ct as le,dt as w,et as ue,f as de,ft as T,it as E,j as fe,jt as D,k as pe,l as O,lt as me,m as k,nt as he,o as ge,ot as _e,p as A,rt as j,s as ve,st as ye,t as M,tt as be,u as N,ut as xe,v as Se,vt as P,w as Ce,wt as F,xt as we,z as Te}from"./index-CWolkkxl.js";function Ee(e){let t=new Map,n=new Map,r=e.clone();return I(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function I(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)I(e.children[r],t.children[r],n)}var De=class extends l{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Me(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new z(e,R.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new z(e,R.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Ke(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=y.extractUrlBase(e);a=y.resolveURL(t,this.path)}else a=y.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new oe(this.manager);s.setPriority(this.priority),s.setCache(this.cache),s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===B){try{a[R.KHR_BINARY_GLTF]=new qe(e)}catch(e){r&&r(e);return}i=JSON.parse(a[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new lt(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case R.KHR_MATERIALS_UNLIT:a[t]=new Ae;break;case R.KHR_DRACO_MESH_COMPRESSION:a[t]=new Je(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:a[t]=new Ye;break;case R.KHR_MESH_QUANTIZATION:a[t]=new Xe;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function Oe(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function L(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var R={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DIFFUSE_ROUGHNESS:`KHR_materials_diffuse_roughness`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},ke=class{constructor(e){this.parser=e,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],s,c=new A(16777215);o.color!==void 0&&c.setRGB(o.color[0],o.color[1],o.color[2],b);let l=o.range===void 0?0:o.range;switch(o.type){case`directional`:s=new Se(c),s.target.position.set(0,0,-1),s.add(s.target);break;case`point`:s=new ye(c),s.distance=l;break;case`spot`:s=new a(c),s.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle===void 0?0:o.spot.innerConeAngle,o.spot.outerConeAngle=o.spot.outerConeAngle===void 0?Math.PI/4:o.spot.outerConeAngle,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+o.type)}return s.position.set(0,0,0),X(s,o),o.intensity!==void 0&&(s.intensity=o.intensity),s.name=t.createUniqueName(o.name||`light_`+e),r=Promise.resolve(s),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},Ae=class{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return S}extendParams(e,t,n){let r=[];e.color=new A(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],b),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,P))}return Promise.all(r)}},je=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},Me=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let r=L(this.parser,e,this.name);if(r===null)return Promise.resolve();let i=[];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,`clearcoatMap`,r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,`clearcoatNormalMap`,r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){let e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new n(e,e)}return Promise.all(i)}},Ne=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.diffuseRoughness=n.diffuseRoughnessFactor===void 0?0:n.diffuseRoughnessFactor,n.diffuseRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`diffuseRoughnessMap`,n.diffuseRoughnessTexture)),Promise.all(r)}},Pe=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},Fe=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},Ie=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new A(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],b)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,P)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},Le=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},Re=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new A().setRGB(i[0],i[1],i[2],b),Promise.all(r)}},ze=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IOR}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Be=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new A().setRGB(i[0],i[1],i[2],b),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,P)),Promise.all(r)}},Ve=class{constructor(e){this.parser=e,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},He=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},Ue=class{constructor(e){this.parser=e,this.name=R.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},We=class{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Ge=class{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},z=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},Ke=class{constructor(e){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==U.TRIANGLES&&e.mode!==U.TRIANGLE_STRIP&&e.mode!==U.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],s={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(s[e]=t,s[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d,n=new D,a=new w,c=new D(1,1,1),l=new o(e.geometry,e.material,r);for(let e=0;e<r;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,e),s.SCALE&&c.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,a,c));let u=null;for(let e in s)if(e===`_COLOR_0`){let t=s[e];l.instanceColor=new v(t.array,t.itemSize,t.normalized)}else if(e!==`TRANSLATION`&&e!==`ROTATION`&&e!==`SCALE`){if(u===null){let e=l.geometry;u=new N,u.name=e.name;for(let t in e.attributes)u.setAttribute(t,e.attributes[t]);for(let t in e.morphAttributes)u.morphAttributes[t]=e.morphAttributes[t];e.index!==null&&u.setIndex(e.index),u.morphTargetsRelative=e.morphTargetsRelative;for(let t of e.groups)u.addGroup(t.start,t.count,t.materialIndex);e.boundingBox!==null&&(u.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(u.boundingSphere=e.boundingSphere.clone()),u.drawRange.start=e.drawRange.start,u.drawRange.count=e.drawRange.count,u.userData=Object.assign({},e.userData),l.geometry=u}let t=s[e];u.setAttribute(e,new v(t.array,t.itemSize,t.normalized))}E.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),i.push(l)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},B=`glTF`,V=12,H={JSON:1313821514,BIN:5130562},qe=class{constructor(e){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,V),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==B)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-V,i=new DataView(e,V),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===H.JSON){let r=new Uint8Array(e,V+a,t);this.content=n.decode(r)}else if(r===H.BIN){let n=V+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},Je=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=K[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=K[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=W[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,b,n)})})}},Ye=class{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let t=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},Xe=class{constructor(){this.name=R.KHR_MESH_QUANTIZATION}},Ze=class extends t{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,ee=1-h,_=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=ee*t+_*n+h*r+g*c}return i}},Qe=new w,$e=class extends Ze{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return Qe.fromArray(i).normalize().toArray(i),i}},U={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},et={9728:ue,9729:f,9984:he,9985:r,9986:be,9987:Te},tt={33071:de,33648:e,10497:ie},G={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},q={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},nt={CUBICSPLINE:void 0,LINEAR:p,STEP:fe},J={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function rt(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new _({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Y(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function X(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function it(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function at(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function ot(e){let t,n=e.extensions&&e.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Z(n.attributes):e.indices+`:`+Z(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Z(e.targets[n]);return t}function Z(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function Q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function st(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var ct=new d,lt=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Oe,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?(this.textureLoader=new ne(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new Ce(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oe(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType(`arraybuffer`),(this.options.withCredentials||this.options.crossOrigin===`use-credentials`)&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Y(i,a,r),X(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(y.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=G[r.type],t=W[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new O(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=G[r.type],o=W[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new g(f,u/s),t.cache.add(n,c)),p=new pe(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new O(f,a,d);if(r.sparse!==void 0){let t=G.SCALAR,n=W[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new O(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=et[n.magFilter]||1006,t.minFilter=et[n.minFilter]||1008,t.wrapS=tt[n.wrapS]||1e3,t.wrapT=tt[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1,l;if(t.isKTX2Loader===!0&&a.bufferView!==void 0)l=n.getDependency(`bufferView`,a.bufferView).then(function(e){return new Promise(function(n,r){t.parse(e,n,r)})});else{if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new F(e);t.needsUpdate=!0,n(t)}),t.load(y.resolveURL(e,i.path),a,void 0,r)})})}let u=l.then(function(e){return c===!0&&o.revokeObjectURL(s),X(e,a),e.userData.mimeType=a.mimeType||st(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[R.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new me,x.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new ee,x.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return _}loadMaterial(e){let t=this,r=this.json,i=this.extensions,a=r.materials[e],o,s={},c=a.extensions||{},l=[];if(c[R.KHR_MATERIALS_UNLIT]){let e=i[R.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(s,a,t))}else{let n=a.pbrMetallicRoughness||{};if(s.color=new A(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],b),s.opacity=e[3]}n.baseColorTexture!==void 0&&l.push(t.assignTexture(s,`map`,n.baseColorTexture,P)),s.metalness=n.metallicFactor===void 0?1:n.metallicFactor,s.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(s,`metalnessMap`,n.metallicRoughnessTexture)),l.push(t.assignTexture(s,`roughnessMap`,n.metallicRoughnessTexture))),o=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}a.doubleSided===!0&&(s.side=2);let u=a.alphaMode||J.OPAQUE;if(u===J.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,u===J.MASK&&(s.alphaTest=a.alphaCutoff===void 0?.5:a.alphaCutoff)),a.normalTexture!==void 0&&o!==S&&(l.push(t.assignTexture(s,`normalMap`,a.normalTexture)),s.normalScale=new n(1,1),a.normalTexture.scale!==void 0)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}if(a.occlusionTexture!==void 0&&o!==S&&(l.push(t.assignTexture(s,`aoMap`,a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(s.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==S){let e=a.emissiveFactor;s.emissive=new A().setRGB(e[0],e[1],e[2],b)}return a.emissiveTexture!==void 0&&o!==S&&l.push(t.assignTexture(s,`emissiveMap`,a.emissiveTexture,P)),Promise.all(l).then(function(){let n=new o(s);return a.name&&(n.name=a.name),X(n,a),t.associations.set(n,{materials:e}),a.extensions&&Y(i,n,a),n})}createUniqueName(e){let t=xe.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return $(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=ot(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[R.KHR_DRACO_MESH_COMPRESSION]?i(o):$(new N,o,t),o.mode===U.TRIANGLE_STRIP?e=e.then(e=>M(e,1)):o.mode===U.TRIANGLE_FAN&&(e=e.then(e=>M(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,a=n.meshes[e],o=a.primitives,c=[];for(let e=0,t=o.length;e<t;e++){let t=o[e].material===void 0?rt(this.cache):this.getDependency(`material`,o[e].material);c.push(t)}return c.push(t.loadGeometries(o)),Promise.all(c).then(async function(n){let c=n.slice(0,n.length-1),l=n[n.length-1],d=[];for(let n=0,i=l.length;n<i;n++){let i=l[n],f=o[n],p,h=c[n];if(f.mode===U.TRIANGLES||f.mode===U.TRIANGLE_STRIP||f.mode===U.TRIANGLE_FAN||f.mode===void 0){let e=a.isSkinnedMesh===!0,t=i.hasAttribute(`skinIndex`)&&i.hasAttribute(`skinWeight`);e&&t===!1&&console.warn(`THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.`),p=e&&t?new we(i,h):new re(i,h),p.isSkinnedMesh===!0&&p.normalizeSkinWeights()}else if(f.mode===U.LINES)p=new u(i,h);else if(f.mode===U.LINE_STRIP)p=new m(i,h);else if(f.mode===U.LINE_LOOP)p=new s(i,h);else if(f.mode===U.POINTS)p=new le(i,h);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&at(p,a),p.name=t.createUniqueName(a.name||`mesh_`+e),X(p,a),f.extensions&&Y(r,p,f),t.assignFinalMaterial(p),d.push(p)}for(let n=0,r=d.length;n<r;n++)t.associations.set(d[n],{meshes:e,primitives:n});if(d.length===1)return a.extensions&&Y(r,d[0],a),d[0];let f=new i;a.extensions&&Y(r,f,a),t.associations.set(f,{meshes:e});for(let e=0,t=d.length;e<t;e++)f.add(d[e]);return f})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r)console.warn(`THREE.GLTFLoader: Missing camera parameters.`);else return n.type===`perspective`?t=new _e(c.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new ae(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),X(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new d;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new se(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new ge(i,void 0,l);return X(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,ct)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new D().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let a=t.nodes[e],o=a.name?r.createUniqueName(a.name):``,s=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&s.push(c),a.camera!==void 0&&s.push(r.getDependency(`camera`,a.camera).then(function(e){return r._getNodeRef(r.cameraCache,a.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){s.push(e)}),this.nodeCache[e]=Promise.all(s).then(function(t){let s;if(s=a.isBone===!0?new ve:t.length>1?new i:t.length===1?t[0]:new E,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(a.name&&(s.userData.name=a.name,s.name=o),X(s,a),a.extensions&&Y(n,s,a),a.matrix!==void 0){let e=new d;e.fromArray(a.matrix),s.applyMatrix4(e)}else a.translation!==void 0&&s.position.fromArray(a.translation),a.rotation!==void 0&&s.quaternion.fromArray(a.rotation),a.scale!==void 0&&s.scale.fromArray(a.scale);if(!r.associations.has(s))r.associations.set(s,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){let e=r.associations.get(s);r.associations.set(s,{...e})}return r.associations.get(s).nodes=e,s}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,a=new i;n.name&&(a.name=r.createUniqueName(n.name)),X(a,n),n.extensions&&Y(t,a,n);let o=n.nodes||[],s=[];for(let e=0,t=o.length;e<t;e++)s.push(r.getDependency(`node`,o[e]));return Promise.all(s).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?a.add(n):a.add(Ee(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof x||e instanceof F)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(a),a})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}q[i.path]===q.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(q[i.path]){case q.weights:l=j;break;case q.rotation:l=T;break;case q.translation:case q.scale:l=h;break;default:switch(n.itemSize){case 1:l=j;break;default:l=h}}let u=r.interpolation===void 0?p:nt[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+q[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=Q(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof T?$e:Ze)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function ut(e,t,n){let r=t.attributes,i=new ce;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new D(t[0],t[1],t[2]),new D(a[0],a[1],a[2])),e.normalized){let t=Q(W[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new D,t=new D;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=Q(W[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new te;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function $(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=K[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return k.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${k.workingColorSpace}" not supported.`),X(e,t),ut(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:it(e,t.targets,n)})}export{De as GLTFLoader};
|
|
|
|
| 1 |
+
import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,F as s,G as c,H as l,I as u,J as d,L as f,M as p,N as m,Nt as h,O as g,P as ee,Q as _,St as te,T as v,Tt as ne,U as y,V as b,W as x,X as S,Y as re,Z as C,_t as ie,at as ae,b as oe,bt as se,c as ce,ct as le,dt as w,et as ue,f as de,ft as T,it as E,j as fe,jt as D,k as pe,l as O,lt as me,m as k,nt as he,o as ge,ot as _e,p as A,rt as j,s as ve,st as ye,t as M,tt as be,u as N,ut as xe,v as Se,vt as P,w as Ce,wt as F,xt as we,z as Te}from"./index-JW4tzj4k.js";function Ee(e){let t=new Map,n=new Map,r=e.clone();return I(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function I(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)I(e.children[r],t.children[r],n)}var De=class extends l{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Me(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new z(e,R.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new z(e,R.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Ke(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=y.extractUrlBase(e);a=y.resolveURL(t,this.path)}else a=y.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new oe(this.manager);s.setPriority(this.priority),s.setCache(this.cache),s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===B){try{a[R.KHR_BINARY_GLTF]=new qe(e)}catch(e){r&&r(e);return}i=JSON.parse(a[R.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new lt(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case R.KHR_MATERIALS_UNLIT:a[t]=new Ae;break;case R.KHR_DRACO_MESH_COMPRESSION:a[t]=new Je(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:a[t]=new Ye;break;case R.KHR_MESH_QUANTIZATION:a[t]=new Xe;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function Oe(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function L(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var R={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DIFFUSE_ROUGHNESS:`KHR_materials_diffuse_roughness`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},ke=class{constructor(e){this.parser=e,this.name=R.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],s,c=new A(16777215);o.color!==void 0&&c.setRGB(o.color[0],o.color[1],o.color[2],b);let l=o.range===void 0?0:o.range;switch(o.type){case`directional`:s=new Se(c),s.target.position.set(0,0,-1),s.add(s.target);break;case`point`:s=new ye(c),s.distance=l;break;case`spot`:s=new a(c),s.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle===void 0?0:o.spot.innerConeAngle,o.spot.outerConeAngle=o.spot.outerConeAngle===void 0?Math.PI/4:o.spot.outerConeAngle,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+o.type)}return s.position.set(0,0,0),X(s,o),o.intensity!==void 0&&(s.intensity=o.intensity),s.name=t.createUniqueName(o.name||`light_`+e),r=Promise.resolve(s),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},Ae=class{constructor(){this.name=R.KHR_MATERIALS_UNLIT}getMaterialType(){return S}extendParams(e,t,n){let r=[];e.color=new A(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],b),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,P))}return Promise.all(r)}},je=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},Me=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let r=L(this.parser,e,this.name);if(r===null)return Promise.resolve();let i=[];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,`clearcoatMap`,r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,`clearcoatNormalMap`,r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){let e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new n(e,e)}return Promise.all(i)}},Ne=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.diffuseRoughness=n.diffuseRoughnessFactor===void 0?0:n.diffuseRoughnessFactor,n.diffuseRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`diffuseRoughnessMap`,n.diffuseRoughnessTexture)),Promise.all(r)}},Pe=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_DISPERSION}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},Fe=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},Ie=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SHEEN}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new A(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],b)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,P)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},Le=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},Re=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_VOLUME}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new A().setRGB(i[0],i[1],i[2],b),Promise.all(r)}},ze=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_IOR}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Be=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_SPECULAR}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new A().setRGB(i[0],i[1],i[2],b),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,P)),Promise.all(r)}},Ve=class{constructor(e){this.parser=e,this.name=R.EXT_MATERIALS_BUMP}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},He=class{constructor(e){this.parser=e,this.name=R.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return L(this.parser,e,this.name)===null?null:C}extendMaterialParams(e,t){let n=L(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},Ue=class{constructor(e){this.parser=e,this.name=R.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},We=class{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Ge=class{constructor(e){this.parser=e,this.name=R.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},z=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},Ke=class{constructor(e){this.name=R.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==U.TRIANGLES&&e.mode!==U.TRIANGLE_STRIP&&e.mode!==U.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],s={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(s[e]=t,s[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new d,n=new D,a=new w,c=new D(1,1,1),l=new o(e.geometry,e.material,r);for(let e=0;e<r;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,e),s.SCALE&&c.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,a,c));let u=null;for(let e in s)if(e===`_COLOR_0`){let t=s[e];l.instanceColor=new v(t.array,t.itemSize,t.normalized)}else if(e!==`TRANSLATION`&&e!==`ROTATION`&&e!==`SCALE`){if(u===null){let e=l.geometry;u=new N,u.name=e.name;for(let t in e.attributes)u.setAttribute(t,e.attributes[t]);for(let t in e.morphAttributes)u.morphAttributes[t]=e.morphAttributes[t];e.index!==null&&u.setIndex(e.index),u.morphTargetsRelative=e.morphTargetsRelative;for(let t of e.groups)u.addGroup(t.start,t.count,t.materialIndex);e.boundingBox!==null&&(u.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(u.boundingSphere=e.boundingSphere.clone()),u.drawRange.start=e.drawRange.start,u.drawRange.count=e.drawRange.count,u.userData=Object.assign({},e.userData),l.geometry=u}let t=s[e];u.setAttribute(e,new v(t.array,t.itemSize,t.normalized))}E.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),i.push(l)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},B=`glTF`,V=12,H={JSON:1313821514,BIN:5130562},qe=class{constructor(e){this.name=R.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,V),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==B)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-V,i=new DataView(e,V),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===H.JSON){let r=new Uint8Array(e,V+a,t);this.content=n.decode(r)}else if(r===H.BIN){let n=V+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},Je=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=R.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=K[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=K[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=W[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,b,n)})})}},Ye=class{constructor(){this.name=R.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let t=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},Xe=class{constructor(){this.name=R.KHR_MESH_QUANTIZATION}},Ze=class extends t{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,ee=1-h,_=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=ee*t+_*n+h*r+g*c}return i}},Qe=new w,$e=class extends Ze{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return Qe.fromArray(i).normalize().toArray(i),i}},U={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},et={9728:ue,9729:f,9984:he,9985:r,9986:be,9987:Te},tt={33071:de,33648:e,10497:ie},G={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},q={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},nt={CUBICSPLINE:void 0,LINEAR:p,STEP:fe},J={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function rt(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new _({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Y(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function X(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function it(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function at(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function ot(e){let t,n=e.extensions&&e.extensions[R.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Z(n.attributes):e.indices+`:`+Z(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Z(e.targets[n]);return t}function Z(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function Q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function st(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var ct=new d,lt=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Oe,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?(this.textureLoader=new ne(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new Ce(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oe(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType(`arraybuffer`),(this.options.withCredentials||this.options.crossOrigin===`use-credentials`)&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Y(i,a,r),X(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[R.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(y.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=G[r.type],t=W[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new O(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=G[r.type],o=W[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new g(f,u/s),t.cache.add(n,c)),p=new pe(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new O(f,a,d);if(r.sparse!==void 0){let t=G.SCALAR,n=W[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new O(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=et[n.magFilter]||1006,t.minFilter=et[n.minFilter]||1008,t.wrapS=tt[n.wrapS]||1e3,t.wrapT=tt[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1,l;if(t.isKTX2Loader===!0&&a.bufferView!==void 0)l=n.getDependency(`bufferView`,a.bufferView).then(function(e){return new Promise(function(n,r){t.parse(e,n,r)})});else{if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new F(e);t.needsUpdate=!0,n(t)}),t.load(y.resolveURL(e,i.path),a,void 0,r)})})}let u=l.then(function(e){return c===!0&&o.revokeObjectURL(s),X(e,a),e.userData.mimeType=a.mimeType||st(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[R.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[R.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[R.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new me,x.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new ee,x.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return _}loadMaterial(e){let t=this,r=this.json,i=this.extensions,a=r.materials[e],o,s={},c=a.extensions||{},l=[];if(c[R.KHR_MATERIALS_UNLIT]){let e=i[R.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(s,a,t))}else{let n=a.pbrMetallicRoughness||{};if(s.color=new A(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],b),s.opacity=e[3]}n.baseColorTexture!==void 0&&l.push(t.assignTexture(s,`map`,n.baseColorTexture,P)),s.metalness=n.metallicFactor===void 0?1:n.metallicFactor,s.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(s,`metalnessMap`,n.metallicRoughnessTexture)),l.push(t.assignTexture(s,`roughnessMap`,n.metallicRoughnessTexture))),o=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}a.doubleSided===!0&&(s.side=2);let u=a.alphaMode||J.OPAQUE;if(u===J.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,u===J.MASK&&(s.alphaTest=a.alphaCutoff===void 0?.5:a.alphaCutoff)),a.normalTexture!==void 0&&o!==S&&(l.push(t.assignTexture(s,`normalMap`,a.normalTexture)),s.normalScale=new n(1,1),a.normalTexture.scale!==void 0)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}if(a.occlusionTexture!==void 0&&o!==S&&(l.push(t.assignTexture(s,`aoMap`,a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(s.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==S){let e=a.emissiveFactor;s.emissive=new A().setRGB(e[0],e[1],e[2],b)}return a.emissiveTexture!==void 0&&o!==S&&l.push(t.assignTexture(s,`emissiveMap`,a.emissiveTexture,P)),Promise.all(l).then(function(){let n=new o(s);return a.name&&(n.name=a.name),X(n,a),t.associations.set(n,{materials:e}),a.extensions&&Y(i,n,a),n})}createUniqueName(e){let t=xe.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[R.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return $(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=ot(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[R.KHR_DRACO_MESH_COMPRESSION]?i(o):$(new N,o,t),o.mode===U.TRIANGLE_STRIP?e=e.then(e=>M(e,1)):o.mode===U.TRIANGLE_FAN&&(e=e.then(e=>M(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,a=n.meshes[e],o=a.primitives,c=[];for(let e=0,t=o.length;e<t;e++){let t=o[e].material===void 0?rt(this.cache):this.getDependency(`material`,o[e].material);c.push(t)}return c.push(t.loadGeometries(o)),Promise.all(c).then(async function(n){let c=n.slice(0,n.length-1),l=n[n.length-1],d=[];for(let n=0,i=l.length;n<i;n++){let i=l[n],f=o[n],p,h=c[n];if(f.mode===U.TRIANGLES||f.mode===U.TRIANGLE_STRIP||f.mode===U.TRIANGLE_FAN||f.mode===void 0){let e=a.isSkinnedMesh===!0,t=i.hasAttribute(`skinIndex`)&&i.hasAttribute(`skinWeight`);e&&t===!1&&console.warn(`THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.`),p=e&&t?new we(i,h):new re(i,h),p.isSkinnedMesh===!0&&p.normalizeSkinWeights()}else if(f.mode===U.LINES)p=new u(i,h);else if(f.mode===U.LINE_STRIP)p=new m(i,h);else if(f.mode===U.LINE_LOOP)p=new s(i,h);else if(f.mode===U.POINTS)p=new le(i,h);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&at(p,a),p.name=t.createUniqueName(a.name||`mesh_`+e),X(p,a),f.extensions&&Y(r,p,f),t.assignFinalMaterial(p),d.push(p)}for(let n=0,r=d.length;n<r;n++)t.associations.set(d[n],{meshes:e,primitives:n});if(d.length===1)return a.extensions&&Y(r,d[0],a),d[0];let f=new i;a.extensions&&Y(r,f,a),t.associations.set(f,{meshes:e});for(let e=0,t=d.length;e<t;e++)f.add(d[e]);return f})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r)console.warn(`THREE.GLTFLoader: Missing camera parameters.`);else return n.type===`perspective`?t=new _e(c.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new ae(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),X(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new d;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new se(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new ge(i,void 0,l);return X(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,ct)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new D().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let a=t.nodes[e],o=a.name?r.createUniqueName(a.name):``,s=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&s.push(c),a.camera!==void 0&&s.push(r.getDependency(`camera`,a.camera).then(function(e){return r._getNodeRef(r.cameraCache,a.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){s.push(e)}),this.nodeCache[e]=Promise.all(s).then(function(t){let s;if(s=a.isBone===!0?new ve:t.length>1?new i:t.length===1?t[0]:new E,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(a.name&&(s.userData.name=a.name,s.name=o),X(s,a),a.extensions&&Y(n,s,a),a.matrix!==void 0){let e=new d;e.fromArray(a.matrix),s.applyMatrix4(e)}else a.translation!==void 0&&s.position.fromArray(a.translation),a.rotation!==void 0&&s.quaternion.fromArray(a.rotation),a.scale!==void 0&&s.scale.fromArray(a.scale);if(!r.associations.has(s))r.associations.set(s,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){let e=r.associations.get(s);r.associations.set(s,{...e})}return r.associations.get(s).nodes=e,s}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,a=new i;n.name&&(a.name=r.createUniqueName(n.name)),X(a,n),n.extensions&&Y(t,a,n);let o=n.nodes||[],s=[];for(let e=0,t=o.length;e<t;e++)s.push(r.getDependency(`node`,o[e]));return Promise.all(s).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?a.add(n):a.add(Ee(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof x||e instanceof F)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(a),a})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}q[i.path]===q.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(q[i.path]){case q.weights:l=j;break;case q.rotation:l=T;break;case q.translation:case q.scale:l=h;break;default:switch(n.itemSize){case 1:l=j;break;default:l=h}}let u=r.interpolation===void 0?p:nt[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+q[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=Q(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof T?$e:Ze)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function ut(e,t,n){let r=t.attributes,i=new ce;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new D(t[0],t[1],t[2]),new D(a[0],a[1],a[2])),e.normalized){let t=Q(W[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new D,t=new D;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=Q(W[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new te;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function $(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=K[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return k.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${k.workingColorSpace}" not supported.`),X(e,t),ut(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:it(e,t.targets,n)})}export{De as GLTFLoader};
|
dist/assets/{__vite-browser-external--9mz1fMb.js → __vite-browser-external-DxK5cybb.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{It as e}from"./index-
|
|
|
|
| 1 |
+
import{It as e}from"./index-JW4tzj4k.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|
dist/assets/{index-CWolkkxl.js → index-JW4tzj4k.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{ort.wasm.bundle.min-DYVS8CAg.js → ort.wasm.bundle.min-C9r-Mk1W.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{spark.module-VkkELmBQ.js → spark.module-B9EnJCiT.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import{At as e,Dt as t,E as n,Et as r,Ft as i,H as a,J as o,K as s,L as c,Mt as l,Ot as u,Pt as d,Q as f,R as p,S as m,V as h,Y as g,_,a as v,at as y,b,c as ee,d as te,dt as x,et as ne,g as S,gt as re,h as C,ht as ie,i as ae,it as oe,jt as w,kt as se,l as ce,m as le,mt as T,n as ue,ot as de,p as E,pt as D,q as fe,r as pe,vt as me,wt as he,x as ge,y as _e,yt as ve}from"./index-CWolkkxl.js";var O=Uint8Array,ye=Uint16Array,be=Int32Array,xe=new O([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Se=new O([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ce=new O([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),we=function(e,t){for(var n=new ye(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new be(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Te=we(xe,2),Ee=Te.b,De=Te.r;Ee[28]=258,De[258]=28;var Oe=we(Se,0),ke=Oe.b;Oe.r;for(var Ae=new ye(32768),k=0;k<32768;++k){var je=(k&43690)>>1|(k&21845)<<1;je=(je&52428)>>2|(je&13107)<<2,je=(je&61680)>>4|(je&3855)<<4,Ae[k]=((je&65280)>>8|(je&255)<<8)>>1}for(var Me=(function(e,t,n){for(var r=e.length,i=0,a=new ye(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new ye(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new ye(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ae[d]>>c]=l}else for(s=new ye(r),i=0;i<r;++i)e[i]&&(s[i]=Ae[o[e[i]-1]++]>>15-e[i]);return s}),Ne=new O(288),k=0;k<144;++k)Ne[k]=8;for(var k=144;k<256;++k)Ne[k]=9;for(var k=256;k<280;++k)Ne[k]=7;for(var k=280;k<288;++k)Ne[k]=8;for(var Pe=new O(32),k=0;k<32;++k)Pe[k]=5;var Fe=Me(Ne,9,1),Ie=Me(Pe,5,1),Le=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},A=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Re=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},ze=function(e){return(e+7)/8|0},Be=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new O(e.subarray(t,n))},Ve=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],j=function(e,t,n){var r=Error(t||Ve[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,j),!n)throw r;return r},He=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new O(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new O(i*3));var l=function(e){var t=n.length;if(e>t){var r=new O(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=A(e,d,1);var v=A(e,d+1,3);if(d+=3,!v){var y=ze(d)+4,b=e[y-4]|e[y-3]<<8,ee=y+b;if(ee>i){c&&j(0);break}s&&l(f+b),n.set(e.subarray(y,ee),f),t.b=f+=b,t.p=d=ee*8,t.f=u;continue}if(v==1)p=Fe,m=Ie,h=9,g=5;else if(v==2){var te=A(e,d,31)+257,x=A(e,d+10,15)+4,ne=te+A(e,d+5,31)+1;d+=14;for(var S=new O(ne),re=new O(19),C=0;C<x;++C)re[Ce[C]]=A(e,d+C*3,7);d+=x*3;for(var ie=Le(re),ae=(1<<ie)-1,oe=Me(re,ie,1),C=0;C<ne;){var w=oe[A(e,d,ae)];d+=w&15;var y=w>>4;if(y<16)S[C++]=y;else{var se=0,ce=0;for(y==16?(ce=3+A(e,d,3),d+=2,se=S[C-1]):y==17?(ce=3+A(e,d,7),d+=3):y==18&&(ce=11+A(e,d,127),d+=7);ce--;)S[C++]=se}}var le=S.subarray(0,te),T=S.subarray(te);h=Le(le),g=Le(T),p=Me(le,h,1),m=Me(T,g,1)}else j(1);if(d>_){c&&j(0);break}}s&&l(f+131072);for(var ue=(1<<h)-1,de=(1<<g)-1,E=d;;E=d){var se=p[Re(e,d)&ue],D=se>>4;if(d+=se&15,d>_){c&&j(0);break}if(se||j(2),D<256)n[f++]=D;else if(D==256){E=d,p=null;break}else{var fe=D-254;if(D>264){var C=D-257,pe=xe[C];fe=A(e,d,(1<<pe)-1)+Ee[C],d+=pe}var me=m[Re(e,d)&de],he=me>>4;me||j(3),d+=me&15;var T=ke[he];if(he>3){var pe=Se[he];T+=Re(e,d)&(1<<pe)-1,d+=pe}if(d>_){c&&j(0);break}s&&l(f+131072);var ge=f+fe;if(f<T){var _e=a-T,ve=Math.min(T,ge);for(_e+f<0&&j(3);f<ve;++f)n[f]=r[_e+f]}for(;f<ge;++f)n[f]=n[f-T]}}t.l=p,t.p=E,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Be(n,0,f):n.subarray(0,f)},Ue=new O(0),M=function(e,t){return e[t]|e[t+1]<<8},N=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},We=function(e,t){return N(e,t)+N(e,t+4)*4294967296},Ge=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&j(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ke=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new O(32768),this.p=new O(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||j(5),this.d&&j(4),!this.p.length)this.p=e;else if(e.length){var t=new O(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=He(this.p,this.s,this.o);this.ondata(Be(n,t,this.s.b),this.d),this.o=Be(n,this.s.b-32768),this.s.b=this.o.length,this.p=Be(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();function qe(e,t){return He(e,{i:2},t&&t.out,t&&t.dictionary)}var Je=function(){function e(e,t){this.v=1,this.r=0,Ke.call(this,e,t)}return e.prototype.push=function(e,t){if(Ke.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),r=n.length>3?Ge(n):4;if(r>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(r),this.v=0}Ke.prototype.c.call(this,t),this.s.f&&!this.s.l&&!t&&(this.v=ze(this.s.p)+9,this.s={i:0},this.o=new O(0),this.push(new O(0),t))},e}(),Ye=typeof TextDecoder<`u`&&new TextDecoder;try{Ye.decode(Ue,{stream:!0})}catch{}var Xe=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Be(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function Ze(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(Ye)return Ye.decode(e);var i=Xe(e),a=i.s,n=i.r;return n.length&&j(8),a}var Qe=function(e,t){return t+30+M(e,t+26)+M(e,t+28)},$e=function(e,t,n){var r=M(e,t+28),i=Ze(e.subarray(t+46,t+46+r),!(M(e,t+8)&2048)),a=t+46+r,o=N(e,t+20),s=n&&o==4294967295?et(e,a):[o,N(e,t+24),N(e,t+42)],c=s[0],l=s[1],u=s[2];return[M(e,t+10),c,l,i,a+M(e,t+30)+M(e,t+32),u]},et=function(e,t){for(;M(e,t)!=1;t+=4+M(e,t+2));return[We(e,t+12),We(e,t+4),We(e,t+20)]};function tt(e,t){for(var n={},r=e.length-22;N(e,r)!=101010256;--r)(!r||e.length-r>65558)&&j(13);var i=M(e,r+8);if(!i)return{};var a=N(e,r+16),o=a==4294967295||i==65535;if(o){var s=N(e,r-12);o=N(e,s)==101075792,o&&(i=N(e,s+32),a=N(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=$e(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=Qe(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=qe(e.subarray(_,_+f),{out:new O(p)}):j(14,`unknown compression type `+d):n[m]=Be(e,_,_+f))}return n}var nt=Math.exp(-30),P=2048,F=2048,I=function(e){return e.PLY=`ply`,e.SPZ=`spz`,e.SPLAT=`splat`,e.KSPLAT=`ksplat`,e.PCSOGS=`pcsogs`,e.PCSOGSZIP=`pcsogszip`,e.RAD=`rad`,e}({}),rt={rgbMin:0,rgbMax:1,lnScaleMin:-12,lnScaleMax:9,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1};function it(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`}function at(e){return e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`}function ot(e){return e===`float`||e===`vec2`||e===`vec3`||e===`vec4`}function st(e){return e===`mat2`||e===`mat2x2`||e===`mat2x3`||e===`mat2x4`||e===`mat3`||e===`mat3x2`||e===`mat3x3`||e===`mat3x4`||e===`mat4`||e===`mat4x2`||e===`mat4x3`||e===`mat4x4`}function ct(e){return ot(e)||st(e)}function lt(e){return e===`mat2`||e===`mat2x2`}function ut(e){return e===`mat3`||e===`mat3x3`}function dt(e){return e===`mat4`||e===`mat4x4`}function L(e){return Math.trunc(e).toString()}function R(e){return`${Math.max(0,Math.trunc(e)).toString()}u`}function z(e){return e===1/0?`INFINITY`:e===-1/0?`-INFINITY`:Number.isInteger(e)?e.toFixed(1):e.toString()}function ft(e){return e instanceof pt?e.type:e.dynoOut().type}var pt=class{constructor(e){this.__isDynoValue=!0,this.type=e}},B=class extends pt{constructor(e,t){super(e.outTypes[t]),this.dyno=e,this.key=t}},mt=class extends pt{constructor(e,t){super(e),this.literal=t}getLiteral(){return this.literal}},ht=class extends mt{constructor(e,t){super(e,``),this.value=t}getLiteral(){let{type:t,value:n}=this;switch(t){case`bool`:return n?`true`:`false`;case`uint`:return R(n);case`int`:return L(n);case`float`:return z(n);case`bvec2`:{let e=n;return`bvec2(${e[0]}, ${e[1]})`}case`uvec2`:{if(n instanceof e)return`uvec2(${R(n.x)}, ${R(n.y)})`;let t=n;return`uvec2(${R(t[0])}, ${R(t[1])})`}case`ivec2`:{if(n instanceof e)return`ivec2(${L(n.x)}, ${L(n.y)})`;let t=n;return`ivec2(${L(t[0])}, ${L(t[1])})`}case`vec2`:{if(n instanceof e)return`vec2(${z(n.x)}, ${z(n.y)})`;let t=n;return`vec2(${z(t[0])}, ${z(t[1])})`}case`bvec3`:{let e=n;return`bvec3(${e[0]}, ${e[1]}, ${e[2]})`}case`uvec3`:{if(n instanceof w)return`uvec3(${R(n.x)}, ${R(n.y)}, ${R(n.z)})`;let e=n;return`uvec3(${R(e[0])}, ${R(e[1])}, ${R(e[2])})`}case`ivec3`:{if(n instanceof w)return`ivec3(${L(n.x)}, ${L(n.y)}, ${L(n.z)})`;let e=n;return`ivec3(${L(e[0])}, ${L(e[1])}, ${L(e[2])})`}case`vec3`:{if(n instanceof w)return`vec3(${z(n.x)}, ${z(n.y)}, ${z(n.z)})`;let e=n;return`vec3(${z(e[0])}, ${z(e[1])}, ${z(e[2])})`}case`bvec4`:{let e=n;return`bvec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}case`uvec4`:{if(n instanceof l)return`uvec4(${R(n.x)}, ${R(n.y)}, ${R(n.z)}, ${R(n.w)})`;let e=n;return`uvec4(${R(e[0])}, ${R(e[1])}, ${R(e[2])}, ${R(e[3])})`}case`ivec4`:{if(n instanceof l)return`ivec4(${L(n.x)}, ${L(n.y)}, ${L(n.z)}, ${L(n.w)})`;let e=n;return`ivec4(${L(e[0])}, ${L(e[1])}, ${L(e[2])}, ${L(e[3])})`}case`vec4`:{if(n instanceof l||n instanceof x)return`vec4(${z(n.x)}, ${z(n.y)}, ${z(n.z)}, ${z(n.w)})`;let e=n;return`vec4(${z(e[0])}, ${z(e[1])}, ${z(e[2])}, ${z(e[3])})`}case`mat2`:case`mat2x2`:{let e=n,r=e instanceof s?e.elements:n;return`${t}(${[,,,,].fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat2x3`:{let e=n;return`${t}(${[,,,,,,].fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat2x4`:{let e=n;return`${t}(${Array(8).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat3`:case`mat3x3`:{let e=n,r=e instanceof fe?e.elements:n;return`${t}(${Array(9).fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat3x2`:{let e=n;return`${t}(${[,,,,,,].fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat3x4`:{let e=n;return`${t}(${Array(12).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat4`:case`mat4x4`:{let e=n,r=e instanceof o?e.elements:n;return`${t}(${Array(16).fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat4x2`:{let e=n;return`${t}(${Array(8).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat4x3`:{let e=n;return`${t}(${Array(12).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}default:throw Error(`Type not implemented: ${String(t)}`)}}};function gt(e,t){return new ht(e,t)}var _t=` `,vt=class{constructor({indent:e}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=_t,this.indent=e??_t}nextSequence(){return this.sequence++}},V=class{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){this.inTypes=e??{},this.outTypes=t??{},this.inputs=n??{},this.update=r,this.globals=i,this.statements=a,this.generate=o??(({inputs:e,outputs:t,compile:n})=>({globals:this.globals?.({inputs:e,outputs:t,compile:n}),statements:this.statements?.({inputs:e,outputs:t,compile:n})}))}get outputs(){let e={};for(let t in this.outTypes)e[t]=new B(this,t);return e}apply(e){return Object.assign(this.inputs,e),this.outputs}compile({inputs:e,outputs:t,compile:n}){let r=[`// ${this.constructor.name}(${Object.values(e).join(`, `)}) => (${Object.values(t).join(`, `)})`],i=[];for(let e in t){let r=t[e];r&&!n.declares.has(r)&&(n.declares.add(r),i.push(e))}let{globals:a,statements:o,uniforms:s}=this.generate({inputs:e,outputs:t,compile:n});for(let e of a??[])n.globals.add(e);for(let e in s)n.uniforms[e]=s[e];this.update&&n.updaters.push(this.update);for(let e of i){let i=t[e];i&&(n.uniforms[i]||r.push(`${xt(i,this.outTypes[e])};`))}return o?.length&&(r.push(`{`),r.push(...o.map(e=>n.indent+e)),r.push(`}`)),r}},yt=class extends V{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,construct:a}){super({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,generate:e=>this.generateBlock(e)}),this.construct=a}generateBlock({inputs:e,outputs:t,compile:n}){let r={},i={};for(let t in e)e[t]!=null&&(r[t]=new mt(this.inTypes[t],e[t]));for(let e in t)t[e]!=null&&(i[e]=new pt(this.outTypes[e]));let a={roots:[]},o=this.construct(r,i,a);for(let r of this.globals?.({inputs:e,outputs:t,compile:n})??[])n.globals.add(r);let s=[],c=new Map;function l(e,t,r){let i=c.get(e);if(!i){i={sequence:n.nextSequence(),outNames:new Map,newOuts:new Set},c.set(e,i);for(let t in e.inputs){let n=e.inputs[t];for(;n;){if(n instanceof pt){n instanceof B&&l(n.dyno,n.key);break}if(typeof n.dynoOut!=`function`)throw Error(`dynoOut is not a function for ${n.constructor.name}`);n=n.dynoOut()}}s.push(e)}t&&(r||i.newOuts.add(t),i.outNames.set(t,r??`${t}_${i.sequence}`))}for(let e of a.roots)l(e);for(let e in i){let n=o?.[e]??i[e];for(;n;){if(n instanceof pt){n instanceof B&&l(n.dyno,n.key,t[e]);break}n=n.dynoOut()}i[e]=n}let u=[];for(let e of s){let t={},r={};for(let n in e.inputs){let r=e.inputs[n];for(;r;){if(r instanceof pt){if(r instanceof mt)t[n]=r.getLiteral();else if(r instanceof B){let e=c.get(r.dyno)?.outNames.get(r.key);if(!e)throw Error(`Source not found for ${r.dyno.constructor.name}.${r.key}`);t[n]=e}break}r=r.dynoOut()}}let i=c.get(e)??{outNames:new Map};for(let[e,t]of i.outNames.entries())r[e]=t;let a=e.compile({inputs:t,outputs:r,compile:n});u.push(a)}let d=[];for(let e in t)i[e]instanceof mt&&d.push(`${t[e]} = ${i[e].getLiteral()};`);return d.length>0&&u.push(d),{statements:u.flatMap((e,t)=>t===0?e:[``,...e])}}};function H(e,t,n,{update:r,globals:i}={}){return new yt({inTypes:e,outTypes:t,construct:n,update:r,globals:i})}function bt({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){return new V({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o})}function xt(e,t,n){let r=typeof t==`string`?t:t.type;if(!r)throw Error(`Invalid DynoType: ${String(t)}`);return`${r} ${e}${n==null?``:`[${n}]`}`}function U(e){let t=!1,n=e.split(`
|
| 2 |
`).map(e=>{let n=e.trimEnd();return t?n:n.length>0?(t=!0,n):null}).filter(e=>e!=null);for(;n.length>0&&n[n.length-1].length===0;)n.pop();if(n.length===0)return[];let r=n[0].match(/^\s*/)?.[0];if(!r)return n;let i=RegExp(`^${r}`);return n.map(e=>e.replace(i,``))}function W(e){return U(e).join(`
|
| 3 |
`)}var St=class extends V{constructor({a:e,outKey:t,outTypeFunc:n}){let r={a:ft(e)},i=n(ft(e));super({inTypes:r,outTypes:{[t]:i},inputs:{a:e}}),this.outKey=t}dynoOut(){return new B(this,this.outKey)}},Ct=class extends V{constructor({a:e,b:t,outKey:n,outTypeFunc:r}){let i={a:ft(e),b:ft(t)},a=r(ft(e),ft(t));super({inTypes:i,outTypes:{[n]:a},inputs:{a:e,b:t}}),this.outKey=n}dynoOut(){return new B(this,this.outKey)}},wt=Number.parseInt(`187`)>=179,Tt=new Float32Array(1),Et=new Uint32Array(Tt.buffer),Dt=`Float16Array`in globalThis,Ot=Dt?new globalThis.Float16Array(1):null,kt=new Uint16Array(Ot?.buffer);function At(e){return Tt[0]=e,Et[0]}function jt(e){return Et[0]=e,Tt[0]}var Mt=Dt?Pt:Ft,Nt=Dt?It:Lt;function Pt(e){return Ot[0]=e,kt[0]}function Ft(e){Tt[0]=e;let t=Et[0],n=t>>31&1,r=t>>23&255,i=t&8388607,a=n<<15;if(r===255)return i===0?a|31744:a|32767;let o=r-127+15;if(o>=31)return a|31744;if(o<=0)return o<-10?a:a|(i|8388608)>>1-o+13;let s=i>>13;return a|o<<10|s}function It(e){return kt[0]=e,Ot[0]}function Lt(e){let t=e>>15&1,n=e>>10&31,r=e&1023,i;if(n===0){if(r===0)i=t<<31;else{let e=r,n=-14;for(;!(e&1024);)e<<=1,n--;e&=1023;let a=n+127,o=e<<13;i=t<<31|a<<23|o}}else if(n===31)i=r===0?t<<31|2139095040:t<<31|2143289344;else{let e=n-15+127,a=r<<13;i=t<<31|e<<23|a}return Et[0]=i,Tt[0]}function Rt(e){return Math.max(0,Math.min(255,Math.round(e*255)))}function zt(e){let t=[],n=new Set;function r(e){e&&typeof e==`object`&&!n.has(e)&&(n.add(e),e instanceof ArrayBuffer?t.push(e):ArrayBuffer.isView(e)?t.push(e.buffer):Array.isArray(e)?e.forEach(r):Object.values(e).forEach(r))}return r(e),t}function Bt(e,t){return Array(e).fill(null).map((e,n)=>t(n))}function Vt(e,t){let n=0;for(let r of e)t(r)||(e[n++]=r);e.length=n}function Ht(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=t*4,[_,v]=e;_[g]=At(n),_[g+1]=At(r),_[g+2]=At(i),_[g+3]=Mt(f),v[g]=Mt(p)|Mt(m)<<16,v[g+1]=Mt(h)|Mt(Math.log(a))<<16,v[g+2]=Mt(Math.log(o))|Mt(Math.log(s))<<16,v[g+3]=an(c,l,u,d)}function Ut(e,t){let n=Kt,r=t*4,[i,a]=e;return n.center.x=jt(i[r]),n.center.y=jt(i[r+1]),n.center.z=jt(i[r+2]),n.opacity=Nt(i[r+3]&65535),n.color.r=Nt(a[r]&65535),n.color.g=Nt(a[r]>>>16),n.color.b=Nt(a[r+1]&65535),n.scales.x=Math.exp(Nt(a[r+1]>>>16)),n.scales.y=Math.exp(Nt(a[r+2]&65535)),n.scales.z=Math.exp(Nt(a[r+2]>>>16)),on(a[r+3],n.quaternion),n}function Wt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=g?.rgbMin??0,v=(g?.rgbMax??1)-_,y=Rt((p-_)/v),b=Rt((m-_)/v),ee=Rt((h-_)/v),te=Rt(g?.lodOpacity?.5*f:f),x=nn(Gt.set(c,l,u,d)),ne=x&255,S=x>>>8&255,re=x>>>16&255,C=g?.lnScaleMin??-12,ie=254/((g?.lnScaleMax??9)-C),ae=a<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(a)-C)*ie)+1)),oe=o<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(o)-C)*ie)+1)),w=s<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(s)-C)*ie)+1)),se=Mt(n),ce=Mt(r),le=Mt(i),T=t*4;e[T]=y|b<<8|ee<<16|te<<24,e[T+1]=se|ce<<16,e[T+2]=le|ne<<16|S<<24,e[T+3]=ae|oe<<8|w<<16|re<<24}var Gt=new x,Kt={center:new w,scales:new w,quaternion:new x,color:new E,opacity:0};function qt(e,t,n){let r=Kt,i=t*4,a=e[i],o=e[i+1],s=e[i+2],c=e[i+3],l=n?.rgbMin??0,u=(n?.rgbMax??1)-l;r.color.set(l+(a&255)/255*u,l+(a>>>8&255)/255*u,l+(a>>>16&255)/255*u),r.opacity=(a>>>24&255)/255,n?.lodOpacity&&(r.opacity=2*r.opacity),r.center.set(Nt(o&65535),Nt(o>>>16&65535),Nt(s&65535));let d=n?.lnScaleMin??-12,f=((n?.lnScaleMax??9)-d)/254,p=c&255;r.scales.x=p===0?0:Math.exp(d+(p-1)*f);let m=c>>>8&255;r.scales.y=m===0?0:Math.exp(d+(m-1)*f);let h=c>>>16&255;return r.scales.z=h===0?0:Math.exp(d+(h-1)*f),rn(s>>>16&65535|c>>>8&16711680,r.quaternion),r}function G(e){let t=P,n=Math.max(1,Math.min(F,Math.ceil(e/t))),r=Math.ceil(e/(t*n));return{width:t,height:n,depth:r,maxSplats:t*n*r}}function Jt(){return navigator.platform.toLowerCase().startsWith(`win`)?!1:navigator.maxTouchPoints>0||/Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(navigator.userAgent)}function Yt(){return/Android/.test(navigator.userAgent)||/Tizen/.test(navigator.userAgent)}function Xt(){return!!navigator.xr&&/Oculus/.test(navigator.userAgent)}function Zt(){return/iPhone|iPad/.test(navigator.userAgent)}function Qt(){return!!navigator.xr&&Zt()&&/Safari/.test(navigator.userAgent)&&Jt()}var $t=W(`
|
| 4 |
precision highp float;
|
|
|
|
| 1 |
+
import{At as e,Dt as t,E as n,Et as r,Ft as i,H as a,J as o,K as s,L as c,Mt as l,Ot as u,Pt as d,Q as f,R as p,S as m,V as h,Y as g,_,a as v,at as y,b,c as ee,d as te,dt as x,et as ne,g as S,gt as re,h as C,ht as ie,i as ae,it as oe,jt as w,kt as se,l as ce,m as le,mt as T,n as ue,ot as de,p as E,pt as D,q as fe,r as pe,vt as me,wt as he,x as ge,y as _e,yt as ve}from"./index-JW4tzj4k.js";var O=Uint8Array,ye=Uint16Array,be=Int32Array,xe=new O([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Se=new O([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ce=new O([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),we=function(e,t){for(var n=new ye(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new be(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Te=we(xe,2),Ee=Te.b,De=Te.r;Ee[28]=258,De[258]=28;var Oe=we(Se,0),ke=Oe.b;Oe.r;for(var Ae=new ye(32768),k=0;k<32768;++k){var je=(k&43690)>>1|(k&21845)<<1;je=(je&52428)>>2|(je&13107)<<2,je=(je&61680)>>4|(je&3855)<<4,Ae[k]=((je&65280)>>8|(je&255)<<8)>>1}for(var Me=(function(e,t,n){for(var r=e.length,i=0,a=new ye(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new ye(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new ye(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[Ae[d]>>c]=l}else for(s=new ye(r),i=0;i<r;++i)e[i]&&(s[i]=Ae[o[e[i]-1]++]>>15-e[i]);return s}),Ne=new O(288),k=0;k<144;++k)Ne[k]=8;for(var k=144;k<256;++k)Ne[k]=9;for(var k=256;k<280;++k)Ne[k]=7;for(var k=280;k<288;++k)Ne[k]=8;for(var Pe=new O(32),k=0;k<32;++k)Pe[k]=5;var Fe=Me(Ne,9,1),Ie=Me(Pe,5,1),Le=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},A=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Re=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},ze=function(e){return(e+7)/8|0},Be=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new O(e.subarray(t,n))},Ve=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],j=function(e,t,n){var r=Error(t||Ve[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,j),!n)throw r;return r},He=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new O(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new O(i*3));var l=function(e){var t=n.length;if(e>t){var r=new O(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=A(e,d,1);var v=A(e,d+1,3);if(d+=3,!v){var y=ze(d)+4,b=e[y-4]|e[y-3]<<8,ee=y+b;if(ee>i){c&&j(0);break}s&&l(f+b),n.set(e.subarray(y,ee),f),t.b=f+=b,t.p=d=ee*8,t.f=u;continue}if(v==1)p=Fe,m=Ie,h=9,g=5;else if(v==2){var te=A(e,d,31)+257,x=A(e,d+10,15)+4,ne=te+A(e,d+5,31)+1;d+=14;for(var S=new O(ne),re=new O(19),C=0;C<x;++C)re[Ce[C]]=A(e,d+C*3,7);d+=x*3;for(var ie=Le(re),ae=(1<<ie)-1,oe=Me(re,ie,1),C=0;C<ne;){var w=oe[A(e,d,ae)];d+=w&15;var y=w>>4;if(y<16)S[C++]=y;else{var se=0,ce=0;for(y==16?(ce=3+A(e,d,3),d+=2,se=S[C-1]):y==17?(ce=3+A(e,d,7),d+=3):y==18&&(ce=11+A(e,d,127),d+=7);ce--;)S[C++]=se}}var le=S.subarray(0,te),T=S.subarray(te);h=Le(le),g=Le(T),p=Me(le,h,1),m=Me(T,g,1)}else j(1);if(d>_){c&&j(0);break}}s&&l(f+131072);for(var ue=(1<<h)-1,de=(1<<g)-1,E=d;;E=d){var se=p[Re(e,d)&ue],D=se>>4;if(d+=se&15,d>_){c&&j(0);break}if(se||j(2),D<256)n[f++]=D;else if(D==256){E=d,p=null;break}else{var fe=D-254;if(D>264){var C=D-257,pe=xe[C];fe=A(e,d,(1<<pe)-1)+Ee[C],d+=pe}var me=m[Re(e,d)&de],he=me>>4;me||j(3),d+=me&15;var T=ke[he];if(he>3){var pe=Se[he];T+=Re(e,d)&(1<<pe)-1,d+=pe}if(d>_){c&&j(0);break}s&&l(f+131072);var ge=f+fe;if(f<T){var _e=a-T,ve=Math.min(T,ge);for(_e+f<0&&j(3);f<ve;++f)n[f]=r[_e+f]}for(;f<ge;++f)n[f]=n[f-T]}}t.l=p,t.p=E,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?Be(n,0,f):n.subarray(0,f)},Ue=new O(0),M=function(e,t){return e[t]|e[t+1]<<8},N=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},We=function(e,t){return N(e,t)+N(e,t+4)*4294967296},Ge=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&j(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ke=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new O(32768),this.p=new O(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||j(5),this.d&&j(4),!this.p.length)this.p=e;else if(e.length){var t=new O(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=He(this.p,this.s,this.o);this.ondata(Be(n,t,this.s.b),this.d),this.o=Be(n,this.s.b-32768),this.s.b=this.o.length,this.p=Be(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();function qe(e,t){return He(e,{i:2},t&&t.out,t&&t.dictionary)}var Je=function(){function e(e,t){this.v=1,this.r=0,Ke.call(this,e,t)}return e.prototype.push=function(e,t){if(Ke.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),r=n.length>3?Ge(n):4;if(r>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(r),this.v=0}Ke.prototype.c.call(this,t),this.s.f&&!this.s.l&&!t&&(this.v=ze(this.s.p)+9,this.s={i:0},this.o=new O(0),this.push(new O(0),t))},e}(),Ye=typeof TextDecoder<`u`&&new TextDecoder;try{Ye.decode(Ue,{stream:!0})}catch{}var Xe=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:Be(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function Ze(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(Ye)return Ye.decode(e);var i=Xe(e),a=i.s,n=i.r;return n.length&&j(8),a}var Qe=function(e,t){return t+30+M(e,t+26)+M(e,t+28)},$e=function(e,t,n){var r=M(e,t+28),i=Ze(e.subarray(t+46,t+46+r),!(M(e,t+8)&2048)),a=t+46+r,o=N(e,t+20),s=n&&o==4294967295?et(e,a):[o,N(e,t+24),N(e,t+42)],c=s[0],l=s[1],u=s[2];return[M(e,t+10),c,l,i,a+M(e,t+30)+M(e,t+32),u]},et=function(e,t){for(;M(e,t)!=1;t+=4+M(e,t+2));return[We(e,t+12),We(e,t+4),We(e,t+20)]};function tt(e,t){for(var n={},r=e.length-22;N(e,r)!=101010256;--r)(!r||e.length-r>65558)&&j(13);var i=M(e,r+8);if(!i)return{};var a=N(e,r+16),o=a==4294967295||i==65535;if(o){var s=N(e,r-12);o=N(e,s)==101075792,o&&(i=N(e,s+32),a=N(e,s+48))}for(var c=t&&t.filter,l=0;l<i;++l){var u=$e(e,a,o),d=u[0],f=u[1],p=u[2],m=u[3],h=u[4],g=u[5],_=Qe(e,g);a=h,(!c||c({name:m,size:f,originalSize:p,compression:d}))&&(d?d==8?n[m]=qe(e.subarray(_,_+f),{out:new O(p)}):j(14,`unknown compression type `+d):n[m]=Be(e,_,_+f))}return n}var nt=Math.exp(-30),P=2048,F=2048,I=function(e){return e.PLY=`ply`,e.SPZ=`spz`,e.SPLAT=`splat`,e.KSPLAT=`ksplat`,e.PCSOGS=`pcsogs`,e.PCSOGSZIP=`pcsogszip`,e.RAD=`rad`,e}({}),rt={rgbMin:0,rgbMax:1,lnScaleMin:-12,lnScaleMax:9,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1};function it(e){return e===`int`||e===`ivec2`||e===`ivec3`||e===`ivec4`}function at(e){return e===`uint`||e===`uvec2`||e===`uvec3`||e===`uvec4`}function ot(e){return e===`float`||e===`vec2`||e===`vec3`||e===`vec4`}function st(e){return e===`mat2`||e===`mat2x2`||e===`mat2x3`||e===`mat2x4`||e===`mat3`||e===`mat3x2`||e===`mat3x3`||e===`mat3x4`||e===`mat4`||e===`mat4x2`||e===`mat4x3`||e===`mat4x4`}function ct(e){return ot(e)||st(e)}function lt(e){return e===`mat2`||e===`mat2x2`}function ut(e){return e===`mat3`||e===`mat3x3`}function dt(e){return e===`mat4`||e===`mat4x4`}function L(e){return Math.trunc(e).toString()}function R(e){return`${Math.max(0,Math.trunc(e)).toString()}u`}function z(e){return e===1/0?`INFINITY`:e===-1/0?`-INFINITY`:Number.isInteger(e)?e.toFixed(1):e.toString()}function ft(e){return e instanceof pt?e.type:e.dynoOut().type}var pt=class{constructor(e){this.__isDynoValue=!0,this.type=e}},B=class extends pt{constructor(e,t){super(e.outTypes[t]),this.dyno=e,this.key=t}},mt=class extends pt{constructor(e,t){super(e),this.literal=t}getLiteral(){return this.literal}},ht=class extends mt{constructor(e,t){super(e,``),this.value=t}getLiteral(){let{type:t,value:n}=this;switch(t){case`bool`:return n?`true`:`false`;case`uint`:return R(n);case`int`:return L(n);case`float`:return z(n);case`bvec2`:{let e=n;return`bvec2(${e[0]}, ${e[1]})`}case`uvec2`:{if(n instanceof e)return`uvec2(${R(n.x)}, ${R(n.y)})`;let t=n;return`uvec2(${R(t[0])}, ${R(t[1])})`}case`ivec2`:{if(n instanceof e)return`ivec2(${L(n.x)}, ${L(n.y)})`;let t=n;return`ivec2(${L(t[0])}, ${L(t[1])})`}case`vec2`:{if(n instanceof e)return`vec2(${z(n.x)}, ${z(n.y)})`;let t=n;return`vec2(${z(t[0])}, ${z(t[1])})`}case`bvec3`:{let e=n;return`bvec3(${e[0]}, ${e[1]}, ${e[2]})`}case`uvec3`:{if(n instanceof w)return`uvec3(${R(n.x)}, ${R(n.y)}, ${R(n.z)})`;let e=n;return`uvec3(${R(e[0])}, ${R(e[1])}, ${R(e[2])})`}case`ivec3`:{if(n instanceof w)return`ivec3(${L(n.x)}, ${L(n.y)}, ${L(n.z)})`;let e=n;return`ivec3(${L(e[0])}, ${L(e[1])}, ${L(e[2])})`}case`vec3`:{if(n instanceof w)return`vec3(${z(n.x)}, ${z(n.y)}, ${z(n.z)})`;let e=n;return`vec3(${z(e[0])}, ${z(e[1])}, ${z(e[2])})`}case`bvec4`:{let e=n;return`bvec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}case`uvec4`:{if(n instanceof l)return`uvec4(${R(n.x)}, ${R(n.y)}, ${R(n.z)}, ${R(n.w)})`;let e=n;return`uvec4(${R(e[0])}, ${R(e[1])}, ${R(e[2])}, ${R(e[3])})`}case`ivec4`:{if(n instanceof l)return`ivec4(${L(n.x)}, ${L(n.y)}, ${L(n.z)}, ${L(n.w)})`;let e=n;return`ivec4(${L(e[0])}, ${L(e[1])}, ${L(e[2])}, ${L(e[3])})`}case`vec4`:{if(n instanceof l||n instanceof x)return`vec4(${z(n.x)}, ${z(n.y)}, ${z(n.z)}, ${z(n.w)})`;let e=n;return`vec4(${z(e[0])}, ${z(e[1])}, ${z(e[2])}, ${z(e[3])})`}case`mat2`:case`mat2x2`:{let e=n,r=e instanceof s?e.elements:n;return`${t}(${[,,,,].fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat2x3`:{let e=n;return`${t}(${[,,,,,,].fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat2x4`:{let e=n;return`${t}(${Array(8).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat3`:case`mat3x3`:{let e=n,r=e instanceof fe?e.elements:n;return`${t}(${Array(9).fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat3x2`:{let e=n;return`${t}(${[,,,,,,].fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat3x4`:{let e=n;return`${t}(${Array(12).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat4`:case`mat4x4`:{let e=n,r=e instanceof o?e.elements:n;return`${t}(${Array(16).fill(0).map((e,t)=>z(r[t])).join(`, `)})`}case`mat4x2`:{let e=n;return`${t}(${Array(8).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}case`mat4x3`:{let e=n;return`${t}(${Array(12).fill(0).map((t,n)=>z(e[n])).join(`, `)})`}default:throw Error(`Type not implemented: ${String(t)}`)}}};function gt(e,t){return new ht(e,t)}var _t=` `,vt=class{constructor({indent:e}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=_t,this.indent=e??_t}nextSequence(){return this.sequence++}},V=class{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){this.inTypes=e??{},this.outTypes=t??{},this.inputs=n??{},this.update=r,this.globals=i,this.statements=a,this.generate=o??(({inputs:e,outputs:t,compile:n})=>({globals:this.globals?.({inputs:e,outputs:t,compile:n}),statements:this.statements?.({inputs:e,outputs:t,compile:n})}))}get outputs(){let e={};for(let t in this.outTypes)e[t]=new B(this,t);return e}apply(e){return Object.assign(this.inputs,e),this.outputs}compile({inputs:e,outputs:t,compile:n}){let r=[`// ${this.constructor.name}(${Object.values(e).join(`, `)}) => (${Object.values(t).join(`, `)})`],i=[];for(let e in t){let r=t[e];r&&!n.declares.has(r)&&(n.declares.add(r),i.push(e))}let{globals:a,statements:o,uniforms:s}=this.generate({inputs:e,outputs:t,compile:n});for(let e of a??[])n.globals.add(e);for(let e in s)n.uniforms[e]=s[e];this.update&&n.updaters.push(this.update);for(let e of i){let i=t[e];i&&(n.uniforms[i]||r.push(`${xt(i,this.outTypes[e])};`))}return o?.length&&(r.push(`{`),r.push(...o.map(e=>n.indent+e)),r.push(`}`)),r}},yt=class extends V{constructor({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,construct:a}){super({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,generate:e=>this.generateBlock(e)}),this.construct=a}generateBlock({inputs:e,outputs:t,compile:n}){let r={},i={};for(let t in e)e[t]!=null&&(r[t]=new mt(this.inTypes[t],e[t]));for(let e in t)t[e]!=null&&(i[e]=new pt(this.outTypes[e]));let a={roots:[]},o=this.construct(r,i,a);for(let r of this.globals?.({inputs:e,outputs:t,compile:n})??[])n.globals.add(r);let s=[],c=new Map;function l(e,t,r){let i=c.get(e);if(!i){i={sequence:n.nextSequence(),outNames:new Map,newOuts:new Set},c.set(e,i);for(let t in e.inputs){let n=e.inputs[t];for(;n;){if(n instanceof pt){n instanceof B&&l(n.dyno,n.key);break}if(typeof n.dynoOut!=`function`)throw Error(`dynoOut is not a function for ${n.constructor.name}`);n=n.dynoOut()}}s.push(e)}t&&(r||i.newOuts.add(t),i.outNames.set(t,r??`${t}_${i.sequence}`))}for(let e of a.roots)l(e);for(let e in i){let n=o?.[e]??i[e];for(;n;){if(n instanceof pt){n instanceof B&&l(n.dyno,n.key,t[e]);break}n=n.dynoOut()}i[e]=n}let u=[];for(let e of s){let t={},r={};for(let n in e.inputs){let r=e.inputs[n];for(;r;){if(r instanceof pt){if(r instanceof mt)t[n]=r.getLiteral();else if(r instanceof B){let e=c.get(r.dyno)?.outNames.get(r.key);if(!e)throw Error(`Source not found for ${r.dyno.constructor.name}.${r.key}`);t[n]=e}break}r=r.dynoOut()}}let i=c.get(e)??{outNames:new Map};for(let[e,t]of i.outNames.entries())r[e]=t;let a=e.compile({inputs:t,outputs:r,compile:n});u.push(a)}let d=[];for(let e in t)i[e]instanceof mt&&d.push(`${t[e]} = ${i[e].getLiteral()};`);return d.length>0&&u.push(d),{statements:u.flatMap((e,t)=>t===0?e:[``,...e])}}};function H(e,t,n,{update:r,globals:i}={}){return new yt({inTypes:e,outTypes:t,construct:n,update:r,globals:i})}function bt({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o}){return new V({inTypes:e,outTypes:t,inputs:n,update:r,globals:i,statements:a,generate:o})}function xt(e,t,n){let r=typeof t==`string`?t:t.type;if(!r)throw Error(`Invalid DynoType: ${String(t)}`);return`${r} ${e}${n==null?``:`[${n}]`}`}function U(e){let t=!1,n=e.split(`
|
| 2 |
`).map(e=>{let n=e.trimEnd();return t?n:n.length>0?(t=!0,n):null}).filter(e=>e!=null);for(;n.length>0&&n[n.length-1].length===0;)n.pop();if(n.length===0)return[];let r=n[0].match(/^\s*/)?.[0];if(!r)return n;let i=RegExp(`^${r}`);return n.map(e=>e.replace(i,``))}function W(e){return U(e).join(`
|
| 3 |
`)}var St=class extends V{constructor({a:e,outKey:t,outTypeFunc:n}){let r={a:ft(e)},i=n(ft(e));super({inTypes:r,outTypes:{[t]:i},inputs:{a:e}}),this.outKey=t}dynoOut(){return new B(this,this.outKey)}},Ct=class extends V{constructor({a:e,b:t,outKey:n,outTypeFunc:r}){let i={a:ft(e),b:ft(t)},a=r(ft(e),ft(t));super({inTypes:i,outTypes:{[n]:a},inputs:{a:e,b:t}}),this.outKey=n}dynoOut(){return new B(this,this.outKey)}},wt=Number.parseInt(`187`)>=179,Tt=new Float32Array(1),Et=new Uint32Array(Tt.buffer),Dt=`Float16Array`in globalThis,Ot=Dt?new globalThis.Float16Array(1):null,kt=new Uint16Array(Ot?.buffer);function At(e){return Tt[0]=e,Et[0]}function jt(e){return Et[0]=e,Tt[0]}var Mt=Dt?Pt:Ft,Nt=Dt?It:Lt;function Pt(e){return Ot[0]=e,kt[0]}function Ft(e){Tt[0]=e;let t=Et[0],n=t>>31&1,r=t>>23&255,i=t&8388607,a=n<<15;if(r===255)return i===0?a|31744:a|32767;let o=r-127+15;if(o>=31)return a|31744;if(o<=0)return o<-10?a:a|(i|8388608)>>1-o+13;let s=i>>13;return a|o<<10|s}function It(e){return kt[0]=e,Ot[0]}function Lt(e){let t=e>>15&1,n=e>>10&31,r=e&1023,i;if(n===0){if(r===0)i=t<<31;else{let e=r,n=-14;for(;!(e&1024);)e<<=1,n--;e&=1023;let a=n+127,o=e<<13;i=t<<31|a<<23|o}}else if(n===31)i=r===0?t<<31|2139095040:t<<31|2143289344;else{let e=n-15+127,a=r<<13;i=t<<31|e<<23|a}return Et[0]=i,Tt[0]}function Rt(e){return Math.max(0,Math.min(255,Math.round(e*255)))}function zt(e){let t=[],n=new Set;function r(e){e&&typeof e==`object`&&!n.has(e)&&(n.add(e),e instanceof ArrayBuffer?t.push(e):ArrayBuffer.isView(e)?t.push(e.buffer):Array.isArray(e)?e.forEach(r):Object.values(e).forEach(r))}return r(e),t}function Bt(e,t){return Array(e).fill(null).map((e,n)=>t(n))}function Vt(e,t){let n=0;for(let r of e)t(r)||(e[n++]=r);e.length=n}function Ht(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=t*4,[_,v]=e;_[g]=At(n),_[g+1]=At(r),_[g+2]=At(i),_[g+3]=Mt(f),v[g]=Mt(p)|Mt(m)<<16,v[g+1]=Mt(h)|Mt(Math.log(a))<<16,v[g+2]=Mt(Math.log(o))|Mt(Math.log(s))<<16,v[g+3]=an(c,l,u,d)}function Ut(e,t){let n=Kt,r=t*4,[i,a]=e;return n.center.x=jt(i[r]),n.center.y=jt(i[r+1]),n.center.z=jt(i[r+2]),n.opacity=Nt(i[r+3]&65535),n.color.r=Nt(a[r]&65535),n.color.g=Nt(a[r]>>>16),n.color.b=Nt(a[r+1]&65535),n.scales.x=Math.exp(Nt(a[r+1]>>>16)),n.scales.y=Math.exp(Nt(a[r+2]&65535)),n.scales.z=Math.exp(Nt(a[r+2]>>>16)),on(a[r+3],n.quaternion),n}function Wt(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){let _=g?.rgbMin??0,v=(g?.rgbMax??1)-_,y=Rt((p-_)/v),b=Rt((m-_)/v),ee=Rt((h-_)/v),te=Rt(g?.lodOpacity?.5*f:f),x=nn(Gt.set(c,l,u,d)),ne=x&255,S=x>>>8&255,re=x>>>16&255,C=g?.lnScaleMin??-12,ie=254/((g?.lnScaleMax??9)-C),ae=a<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(a)-C)*ie)+1)),oe=o<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(o)-C)*ie)+1)),w=s<nt?0:Math.min(255,Math.max(1,Math.round((Math.log(s)-C)*ie)+1)),se=Mt(n),ce=Mt(r),le=Mt(i),T=t*4;e[T]=y|b<<8|ee<<16|te<<24,e[T+1]=se|ce<<16,e[T+2]=le|ne<<16|S<<24,e[T+3]=ae|oe<<8|w<<16|re<<24}var Gt=new x,Kt={center:new w,scales:new w,quaternion:new x,color:new E,opacity:0};function qt(e,t,n){let r=Kt,i=t*4,a=e[i],o=e[i+1],s=e[i+2],c=e[i+3],l=n?.rgbMin??0,u=(n?.rgbMax??1)-l;r.color.set(l+(a&255)/255*u,l+(a>>>8&255)/255*u,l+(a>>>16&255)/255*u),r.opacity=(a>>>24&255)/255,n?.lodOpacity&&(r.opacity=2*r.opacity),r.center.set(Nt(o&65535),Nt(o>>>16&65535),Nt(s&65535));let d=n?.lnScaleMin??-12,f=((n?.lnScaleMax??9)-d)/254,p=c&255;r.scales.x=p===0?0:Math.exp(d+(p-1)*f);let m=c>>>8&255;r.scales.y=m===0?0:Math.exp(d+(m-1)*f);let h=c>>>16&255;return r.scales.z=h===0?0:Math.exp(d+(h-1)*f),rn(s>>>16&65535|c>>>8&16711680,r.quaternion),r}function G(e){let t=P,n=Math.max(1,Math.min(F,Math.ceil(e/t))),r=Math.ceil(e/(t*n));return{width:t,height:n,depth:r,maxSplats:t*n*r}}function Jt(){return navigator.platform.toLowerCase().startsWith(`win`)?!1:navigator.maxTouchPoints>0||/Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(navigator.userAgent)}function Yt(){return/Android/.test(navigator.userAgent)||/Tizen/.test(navigator.userAgent)}function Xt(){return!!navigator.xr&&/Oculus/.test(navigator.userAgent)}function Zt(){return/iPhone|iPad/.test(navigator.userAgent)}function Qt(){return!!navigator.xr&&Zt()&&/Safari/.test(navigator.userAgent)&&Jt()}var $t=W(`
|
| 4 |
precision highp float;
|
dist/environments/kitchen/light/light.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
{
|
| 2 |
"about": "Baked by tools/bake_light.mjs; used by src/render/view.js when the fingerprint matches the page's layout.",
|
| 3 |
-
"fingerprint": "
|
| 4 |
"lightmap": {
|
| 5 |
"file": "lightmap.png",
|
| 6 |
"width": 1024,
|
| 7 |
-
"height":
|
| 8 |
"density": 40
|
| 9 |
},
|
| 10 |
"probes": {
|
|
@@ -27,10 +27,24 @@
|
|
| 27 |
},
|
| 28 |
"scale": 1.6,
|
| 29 |
"sky": [
|
| 30 |
-
|
| 31 |
-
0.
|
| 32 |
-
|
| 33 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
"samples": 256,
|
| 35 |
"bounces": 3
|
| 36 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"about": "Baked by tools/bake_light.mjs; used by src/render/view.js when the fingerprint matches the page's layout.",
|
| 3 |
+
"fingerprint": "6cc47e11",
|
| 4 |
"lightmap": {
|
| 5 |
"file": "lightmap.png",
|
| 6 |
"width": 1024,
|
| 7 |
+
"height": 920,
|
| 8 |
"density": 40
|
| 9 |
},
|
| 10 |
"probes": {
|
|
|
|
| 27 |
},
|
| 28 |
"scale": 1.6,
|
| 29 |
"sky": [
|
| 30 |
+
0.9,
|
| 31 |
+
0.95,
|
| 32 |
+
1
|
| 33 |
],
|
| 34 |
+
"sun": {
|
| 35 |
+
"direction": [
|
| 36 |
+
0.32139,
|
| 37 |
+
-0.55667,
|
| 38 |
+
0.76604
|
| 39 |
+
],
|
| 40 |
+
"irradiance": 4.5,
|
| 41 |
+
"color": [
|
| 42 |
+
1,
|
| 43 |
+
0.93,
|
| 44 |
+
0.83
|
| 45 |
+
],
|
| 46 |
+
"radius": 1.2
|
| 47 |
+
},
|
| 48 |
"samples": 256,
|
| 49 |
"bounces": 3
|
| 50 |
}
|
dist/environments/kitchen/light/lightmap.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
dist/environments/kitchen/light/probes.bin.gz
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2c5032acb0dea218546562b9d26786e32ed19e0c38275864256e24f78f21900
|
| 3 |
+
size 370750
|
dist/environments/kitchen/scene.xml
CHANGED
|
@@ -393,9 +393,9 @@
|
|
| 393 |
<geom type="cylinder" fromto="0.026 -0.42 0.67 0.033 -0.42 0.67" size="0.01" material="magnet_1" density="0" contype="0" conaffinity="0"/>
|
| 394 |
<geom type="box" pos="0.026 -0.36 0.38" size="0.001 0.05 0.06" material="note_2" density="0" contype="0" conaffinity="0"/>
|
| 395 |
<geom type="cylinder" fromto="0.026 -0.36 0.43 0.033 -0.36 0.43" size="0.01" material="magnet_2" density="0" contype="0" conaffinity="0"/>
|
| 396 |
-
<geom name="fridge_handle" type="capsule" fromto="0.087 -0.
|
| 397 |
-
<geom type="box" pos="0.056 -0.
|
| 398 |
-
<geom type="box" pos="0.056 -0.
|
| 399 |
</body>
|
| 400 |
<body name="island" pos="0 0 0">
|
| 401 |
<geom name="island_top" type="box" pos="-1.2 0.14 0.8" size="0.35 0.51 0.02" material="countertop" contype="1" conaffinity="1"/>
|
|
@@ -740,10 +740,10 @@
|
|
| 740 |
<geom type="cylinder" fromto="-1.72 2.585 1.95 -1.72 2.58 1.95" size="0.145" material="clock_face" density="0" contype="0" conaffinity="0"/>
|
| 741 |
<geom type="box" pos="-1.72 2.578 1.99" size="0.006 0.002 0.05" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 742 |
<geom type="box" pos="-1.69 2.578 1.95" size="0.04 0.002 0.005" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 743 |
-
<geom type="box" pos="-2.996 -2.
|
| 744 |
-
<geom type="box" pos="-2.992 -2.
|
| 745 |
-
<geom type="box" pos="-
|
| 746 |
-
<geom type="box" pos="-
|
| 747 |
<geom type="box" pos="2.596 -1.75 1.55" size="0.006 0.45 0.3" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 748 |
<geom type="box" pos="2.592 -1.75 1.55" size="0.004 0.42 0.27" material="canvas_2" density="0" contype="0" conaffinity="0"/>
|
| 749 |
</body>
|
|
|
|
| 393 |
<geom type="cylinder" fromto="0.026 -0.42 0.67 0.033 -0.42 0.67" size="0.01" material="magnet_1" density="0" contype="0" conaffinity="0"/>
|
| 394 |
<geom type="box" pos="0.026 -0.36 0.38" size="0.001 0.05 0.06" material="note_2" density="0" contype="0" conaffinity="0"/>
|
| 395 |
<geom type="cylinder" fromto="0.026 -0.36 0.43 0.033 -0.36 0.43" size="0.01" material="magnet_2" density="0" contype="0" conaffinity="0"/>
|
| 396 |
+
<geom name="fridge_handle" type="capsule" fromto="0.087 -0.58 -0.65 0.087 -0.58 -0.15" size="0.012" material="steel" mass="0.1" contype="1" conaffinity="1"/>
|
| 397 |
+
<geom type="box" pos="0.056 -0.58 -0.58" size="0.031 0.006 0.006" material="steel" mass="0.02" contype="1" conaffinity="1"/>
|
| 398 |
+
<geom type="box" pos="0.056 -0.58 -0.22" size="0.031 0.006 0.006" material="steel" mass="0.02" contype="1" conaffinity="1"/>
|
| 399 |
</body>
|
| 400 |
<body name="island" pos="0 0 0">
|
| 401 |
<geom name="island_top" type="box" pos="-1.2 0.14 0.8" size="0.35 0.51 0.02" material="countertop" contype="1" conaffinity="1"/>
|
|
|
|
| 740 |
<geom type="cylinder" fromto="-1.72 2.585 1.95 -1.72 2.58 1.95" size="0.145" material="clock_face" density="0" contype="0" conaffinity="0"/>
|
| 741 |
<geom type="box" pos="-1.72 2.578 1.99" size="0.006 0.002 0.05" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 742 |
<geom type="box" pos="-1.69 2.578 1.95" size="0.04 0.002 0.005" material="clock_frame" density="0" contype="0" conaffinity="0"/>
|
| 743 |
+
<geom type="box" pos="-2.996 -2.32 1.62" size="0.006 0.2 0.16" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 744 |
+
<geom type="box" pos="-2.992 -2.32 1.62" size="0.004 0.18 0.14" material="canvas_0" density="0" contype="0" conaffinity="0"/>
|
| 745 |
+
<geom type="box" pos="-1.5 -2.596 1.6" size="0.18 0.006 0.24" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 746 |
+
<geom type="box" pos="-1.5 -2.592 1.6" size="0.16 0.004 0.22" material="canvas_1" density="0" contype="0" conaffinity="0"/>
|
| 747 |
<geom type="box" pos="2.596 -1.75 1.55" size="0.006 0.45 0.3" material="picture_frame" density="0" contype="0" conaffinity="0"/>
|
| 748 |
<geom type="box" pos="2.592 -1.75 1.55" size="0.004 0.42 0.27" material="canvas_2" density="0" contype="0" conaffinity="0"/>
|
| 749 |
</body>
|
dist/environments/kitchen/tasks/index.json
CHANGED
|
@@ -356,7 +356,7 @@
|
|
| 356 |
"title": "Chilling the yogurt",
|
| 357 |
"file": "chilling_the_yogurt.bddl",
|
| 358 |
"instruction": "Put the yogurt from the kitchen island in the fridge, and close the fridge.",
|
| 359 |
-
"timeLimit":
|
| 360 |
},
|
| 361 |
{
|
| 362 |
"id": "getting_the_juice",
|
|
@@ -391,21 +391,21 @@
|
|
| 391 |
"title": "Making breakfast",
|
| 392 |
"file": "making_breakfast.bddl",
|
| 393 |
"instruction": "Take the juice box and the yogurt out of the fridge to the dining table, close the fridge, and put the radio on.",
|
| 394 |
-
"timeLimit":
|
| 395 |
},
|
| 396 |
{
|
| 397 |
"id": "stocking_the_fridge",
|
| 398 |
"title": "Stocking the fridge",
|
| 399 |
"file": "stocking_the_fridge.bddl",
|
| 400 |
"instruction": "Put the shopping away: the yogurt and the juice box from the kitchen island in the fridge, the cola on the pantry shelf; then close the fridge.",
|
| 401 |
-
"timeLimit":
|
| 402 |
},
|
| 403 |
{
|
| 404 |
"id": "tidying_up_after_dinner",
|
| 405 |
"title": "Tidying up after dinner",
|
| 406 |
"file": "tidying_up_after_dinner.bddl",
|
| 407 |
"instruction": "After dinner: the mug and the cup from the dining table go in the sink, the cola back in the fridge, the toy cube in the island's drawer; and the fridge and the drawer get closed.",
|
| 408 |
-
"timeLimit":
|
| 409 |
}
|
| 410 |
],
|
| 411 |
"storage": [
|
|
|
|
| 356 |
"title": "Chilling the yogurt",
|
| 357 |
"file": "chilling_the_yogurt.bddl",
|
| 358 |
"instruction": "Put the yogurt from the kitchen island in the fridge, and close the fridge.",
|
| 359 |
+
"timeLimit": 160
|
| 360 |
},
|
| 361 |
{
|
| 362 |
"id": "getting_the_juice",
|
|
|
|
| 391 |
"title": "Making breakfast",
|
| 392 |
"file": "making_breakfast.bddl",
|
| 393 |
"instruction": "Take the juice box and the yogurt out of the fridge to the dining table, close the fridge, and put the radio on.",
|
| 394 |
+
"timeLimit": 260
|
| 395 |
},
|
| 396 |
{
|
| 397 |
"id": "stocking_the_fridge",
|
| 398 |
"title": "Stocking the fridge",
|
| 399 |
"file": "stocking_the_fridge.bddl",
|
| 400 |
"instruction": "Put the shopping away: the yogurt and the juice box from the kitchen island in the fridge, the cola on the pantry shelf; then close the fridge.",
|
| 401 |
+
"timeLimit": 330
|
| 402 |
},
|
| 403 |
{
|
| 404 |
"id": "tidying_up_after_dinner",
|
| 405 |
"title": "Tidying up after dinner",
|
| 406 |
"file": "tidying_up_after_dinner.bddl",
|
| 407 |
"instruction": "After dinner: the mug and the cup from the dining table go in the sink, the cola back in the fridge, the toy cube in the island's drawer; and the fridge and the drawer get closed.",
|
| 408 |
+
"timeLimit": 520
|
| 409 |
}
|
| 410 |
],
|
| 411 |
"storage": [
|
dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
})();
|
| 21 |
</script>
|
| 22 |
<meta name="description" content="XLeRobot in your browser: MuJoCo 4.0 physics, MuJoCo-GS-Web's robot and 3D Gaussian splat scenes, a kitchen, a learned policy and an LLM agent." />
|
| 23 |
-
<script type="module" crossorigin src="./assets/index-
|
| 24 |
<link rel="stylesheet" crossorigin href="./assets/index-CwAlkvg1.css">
|
| 25 |
</head>
|
| 26 |
<body>
|
|
|
|
| 20 |
})();
|
| 21 |
</script>
|
| 22 |
<meta name="description" content="XLeRobot in your browser: MuJoCo 4.0 physics, MuJoCo-GS-Web's robot and 3D Gaussian splat scenes, a kitchen, a learned policy and an LLM agent." />
|
| 23 |
+
<script type="module" crossorigin src="./assets/index-JW4tzj4k.js"></script>
|
| 24 |
<link rel="stylesheet" crossorigin href="./assets/index-CwAlkvg1.css">
|
| 25 |
</head>
|
| 26 |
<body>
|
src/render/baked.js
CHANGED
|
@@ -57,6 +57,40 @@ export async function loadBake(url, fingerprint) {
|
|
| 57 |
return { meta, lightmap, probes, occlusion, dispose };
|
| 58 |
}
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
/**
|
| 61 |
* What moves, drawn from straight above into a small map: whether it covers each texel (red), the height
|
| 62 |
* of its top there (green) and of its bottom (blue, as CEILING minus the height), all three kept by a max
|
|
@@ -105,6 +139,7 @@ export class SkyOcclusion {
|
|
| 105 |
skyStrength: { value: 0.7 },
|
| 106 |
};
|
| 107 |
this.clear = new THREE.Color();
|
|
|
|
| 108 |
}
|
| 109 |
|
| 110 |
/**
|
|
@@ -113,9 +148,8 @@ export class SkyOcclusion {
|
|
| 113 |
* costs nothing.
|
| 114 |
*/
|
| 115 |
update(renderer, scene, movers, hz = 30) {
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
this.drawn = now;
|
| 119 |
const { overrideMaterial, background } = scene;
|
| 120 |
const target = renderer.getRenderTarget();
|
| 121 |
renderer.getClearColor(this.clear);
|
|
@@ -132,30 +166,9 @@ export class SkyOcclusion {
|
|
| 132 |
scene.background = background;
|
| 133 |
}
|
| 134 |
|
| 135 |
-
/** Whether any mesh's pose (or the set of meshes) changed since the last call. */
|
| 136 |
-
#moved(movers) {
|
| 137 |
-
const n = 12 * movers.length;
|
| 138 |
-
let moved = false;
|
| 139 |
-
if (this.poses?.length !== n) {
|
| 140 |
-
this.poses = new Float32Array(n);
|
| 141 |
-
moved = true;
|
| 142 |
-
}
|
| 143 |
-
for (let k = 0; k < movers.length; k++) {
|
| 144 |
-
const e = movers[k].matrix.elements;
|
| 145 |
-
for (let j = 0; j < 12; j++) {
|
| 146 |
-
const v = movers[k].visible ? e[j] : 1e6;
|
| 147 |
-
if (Math.abs(v - this.poses[12 * k + j]) > 1e-4) {
|
| 148 |
-
this.poses[12 * k + j] = v;
|
| 149 |
-
moved = true;
|
| 150 |
-
}
|
| 151 |
-
}
|
| 152 |
-
}
|
| 153 |
-
return moved;
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
/** Draw again at the next update, moved or not (after the style or the scene changed). */
|
| 157 |
invalidate() {
|
| 158 |
-
this.
|
| 159 |
}
|
| 160 |
|
| 161 |
dispose() {
|
|
|
|
| 57 |
return { meta, lightmap, probes, occlusion, dispose };
|
| 58 |
}
|
| 59 |
|
| 60 |
+
/**
|
| 61 |
+
* Whether meshes moved: `changed(movers, hz)` is true when any pose (or the set of meshes) differs from the
|
| 62 |
+
* last time it was true, at most `hz` times a second. What only needs drawing again when something moved
|
| 63 |
+
* (the sky occlusion map, the sun's shadow map) asks it each frame.
|
| 64 |
+
*/
|
| 65 |
+
export class MotionWatch {
|
| 66 |
+
changed(movers, hz = 30) {
|
| 67 |
+
const now = performance.now();
|
| 68 |
+
if (this.poses && now - this.last < 1000 / hz) return false;
|
| 69 |
+
const n = 12 * movers.length;
|
| 70 |
+
let moved = false;
|
| 71 |
+
if (this.poses?.length !== n) {
|
| 72 |
+
this.poses = new Float32Array(n);
|
| 73 |
+
moved = true;
|
| 74 |
+
}
|
| 75 |
+
for (let k = 0; k < movers.length; k++) {
|
| 76 |
+
const e = movers[k].matrix.elements;
|
| 77 |
+
for (let j = 0; j < 12; j++) {
|
| 78 |
+
const v = movers[k].visible ? e[j] : 1e6;
|
| 79 |
+
if (Math.abs(v - this.poses[12 * k + j]) > 1e-4) {
|
| 80 |
+
this.poses[12 * k + j] = v;
|
| 81 |
+
moved = true;
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
if (moved) this.last = now;
|
| 86 |
+
return moved;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
invalidate() {
|
| 90 |
+
this.poses = null;
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
/**
|
| 95 |
* What moves, drawn from straight above into a small map: whether it covers each texel (red), the height
|
| 96 |
* of its top there (green) and of its bottom (blue, as CEILING minus the height), all three kept by a max
|
|
|
|
| 139 |
skyStrength: { value: 0.7 },
|
| 140 |
};
|
| 141 |
this.clear = new THREE.Color();
|
| 142 |
+
this.watch = new MotionWatch();
|
| 143 |
}
|
| 144 |
|
| 145 |
/**
|
|
|
|
| 148 |
* costs nothing.
|
| 149 |
*/
|
| 150 |
update(renderer, scene, movers, hz = 30) {
|
| 151 |
+
if (!this.watch.changed(movers, hz)) return;
|
| 152 |
+
this.drawn = performance.now();
|
|
|
|
| 153 |
const { overrideMaterial, background } = scene;
|
| 154 |
const target = renderer.getRenderTarget();
|
| 155 |
renderer.getClearColor(this.clear);
|
|
|
|
| 166 |
scene.background = background;
|
| 167 |
}
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
/** Draw again at the next update, moved or not (after the style or the scene changed). */
|
| 170 |
invalidate() {
|
| 171 |
+
this.watch.invalidate();
|
| 172 |
}
|
| 173 |
|
| 174 |
dispose() {
|
src/render/statics.js
CHANGED
|
@@ -91,13 +91,16 @@ function meshGeometry(model, id) {
|
|
| 91 |
return toCreasedNormals(geometry, CREASE_ANGLE);
|
| 92 |
}
|
| 93 |
|
| 94 |
-
/**
|
|
|
|
|
|
|
|
|
|
| 95 |
export function isWall(sim, i, role) {
|
| 96 |
const { model, data } = sim;
|
| 97 |
if ((role !== "env" && role !== "proxy") || model.geom_type[i] !== GEOM.BOX) return false;
|
| 98 |
if (!/wall/i.test(sim.bodyNames[model.geom_bodyid[i]])) return false;
|
| 99 |
const s = model.geom_size.subarray(3 * i, 3 * i + 3);
|
| 100 |
-
return Math.abs(data.geom_xmat[9 * i + 8]) > 0.99 && 2 * s[2] >= 0.4 && Math.min(s[0], s[1]) <= 0.2;
|
| 101 |
}
|
| 102 |
|
| 103 |
/** A static geom's geometry in world coordinates, with its colour per vertex, ready to merge. */
|
|
@@ -128,6 +131,7 @@ export function collectScenery(sim, robotRoots, onMoving = null, dressing = null
|
|
| 128 |
const { model, data } = sim;
|
| 129 |
const meshCache = new Map();
|
| 130 |
const groups = new Map();
|
|
|
|
| 131 |
const walls = [];
|
| 132 |
const planes = [];
|
| 133 |
const items = (dressing?.items ?? []).map((item) => ({ item, box: new THREE.Box3() }));
|
|
@@ -170,9 +174,7 @@ export function collectScenery(sim, robotRoots, onMoving = null, dressing = null
|
|
| 170 |
const part = worldPart(sim, geometry, i, colour);
|
| 171 |
const dressed = items.length ? dressedBy(part) : -1;
|
| 172 |
if (dressed >= 0) items[dressed].box.union(part.boundingBox);
|
| 173 |
-
|
| 174 |
-
if (!groups.has(key)) groups.set(key, { role, look, matName, opacity, parts: [], dressed: dressed >= 0 ? dressed : null });
|
| 175 |
-
groups.get(key).parts.push(part);
|
| 176 |
if (own) geometry.dispose();
|
| 177 |
} else {
|
| 178 |
onMoving?.(i, role, matName, rgba, geometry);
|
|
@@ -187,6 +189,19 @@ export function collectScenery(sim, robotRoots, onMoving = null, dressing = null
|
|
| 187 |
} else if (robotRoots.length) mid.set(...sim.bodyPos(robotRoots[0]));
|
| 188 |
for (const w of walls) if ((w.center.x - mid.x) * w.out.x + (w.center.y - mid.y) * w.out.y < 0) w.out.negate();
|
| 189 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
// Where there are walls, the floor is drawn out to them, and no further, where a light map lights it.
|
| 191 |
const room = roomOf(walls);
|
| 192 |
for (const p of planes) {
|
|
@@ -242,6 +257,30 @@ function wallParts(sim, i, role, matName, rgba, geometry) {
|
|
| 242 |
return { i, role, matName, look, colour, opacity, full, stub, center: new THREE.Vector3(p[0], p[1], p[2]), out: new THREE.Vector3(R[k], R[3 + k], 0).normalize() };
|
| 243 |
}
|
| 244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
/** The walls' extent on the floor, or null without walls. */
|
| 246 |
function roomOf(walls) {
|
| 247 |
if (walls.length < 3) return null;
|
|
|
|
| 91 |
return toCreasedNormals(geometry, CREASE_ANGLE);
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/**
|
| 95 |
+
* A wall: a static box in a body named like a wall, upright, standing on the floor, at least 40 cm tall
|
| 96 |
+
* and at most 40 cm thick (not a picture or a window hung on one).
|
| 97 |
+
*/
|
| 98 |
export function isWall(sim, i, role) {
|
| 99 |
const { model, data } = sim;
|
| 100 |
if ((role !== "env" && role !== "proxy") || model.geom_type[i] !== GEOM.BOX) return false;
|
| 101 |
if (!/wall/i.test(sim.bodyNames[model.geom_bodyid[i]])) return false;
|
| 102 |
const s = model.geom_size.subarray(3 * i, 3 * i + 3);
|
| 103 |
+
return Math.abs(data.geom_xmat[9 * i + 8]) > 0.99 && 2 * s[2] >= 0.4 && Math.min(s[0], s[1]) <= 0.2 && data.geom_xpos[3 * i + 2] - s[2] < 0.05;
|
| 104 |
}
|
| 105 |
|
| 106 |
/** A static geom's geometry in world coordinates, with its colour per vertex, ready to merge. */
|
|
|
|
| 131 |
const { model, data } = sim;
|
| 132 |
const meshCache = new Map();
|
| 133 |
const groups = new Map();
|
| 134 |
+
const parts = []; // static geoms, grouped once the walls are known
|
| 135 |
const walls = [];
|
| 136 |
const planes = [];
|
| 137 |
const items = (dressing?.items ?? []).map((item) => ({ item, box: new THREE.Box3() }));
|
|
|
|
| 174 |
const part = worldPart(sim, geometry, i, colour);
|
| 175 |
const dressed = items.length ? dressedBy(part) : -1;
|
| 176 |
if (dressed >= 0) items[dressed].box.union(part.boundingBox);
|
| 177 |
+
parts.push({ role, look, matName, opacity, part, dressed });
|
|
|
|
|
|
|
| 178 |
if (own) geometry.dispose();
|
| 179 |
} else {
|
| 180 |
onMoving?.(i, role, matName, rgba, geometry);
|
|
|
|
| 189 |
} else if (robotRoots.length) mid.set(...sim.bodyPos(robotRoots[0]));
|
| 190 |
for (const w of walls) if ((w.center.x - mid.x) * w.out.x + (w.center.y - mid.y) * w.out.y < 0) w.out.negate();
|
| 191 |
}
|
| 192 |
+
// Static geoms in groups by role and look, in model order; what hangs on a wall (a picture, a window, its
|
| 193 |
+
// curtains) in groups of its own, cut down with the wall (view.js). A body hangs on the walls only if all
|
| 194 |
+
// of it does: the back of a microwave standing against one does not.
|
| 195 |
+
const near = parts.map((p) => (p.dressed < 0 ? attachedTo(walls, p.part) : -1));
|
| 196 |
+
const bodyOf = (p) => model.geom_bodyid[p.part.userData.geom];
|
| 197 |
+
const hung = new Map();
|
| 198 |
+
parts.forEach((p, k) => hung.set(bodyOf(p), (hung.get(bodyOf(p)) ?? true) && near[k] >= 0));
|
| 199 |
+
for (const [k, { role, look, matName, opacity, part, dressed }] of parts.entries()) {
|
| 200 |
+
const attached = hung.get(bodyOf(parts[k])) ? near[k] : -1;
|
| 201 |
+
const key = `${dressed >= 0 ? `dressed ${dressed}|` : ""}${attached >= 0 ? `wall ${attached}|` : ""}${role}|${look ? matName : ""}|${opacity.toFixed(2)}`;
|
| 202 |
+
if (!groups.has(key)) groups.set(key, { role, look, matName, opacity, parts: [], dressed: dressed >= 0 ? dressed : null, attached: attached >= 0 ? attached : null });
|
| 203 |
+
groups.get(key).parts.push(part);
|
| 204 |
+
}
|
| 205 |
// Where there are walls, the floor is drawn out to them, and no further, where a light map lights it.
|
| 206 |
const room = roomOf(walls);
|
| 207 |
for (const p of planes) {
|
|
|
|
| 257 |
return { i, role, matName, look, colour, opacity, full, stub, center: new THREE.Vector3(p[0], p[1], p[2]), out: new THREE.Vector3(R[k], R[3 + k], 0).normalize() };
|
| 258 |
}
|
| 259 |
|
| 260 |
+
/**
|
| 261 |
+
* The wall a static part hangs on, or -1: thin and within 12 cm of the wall's inside face, over its length,
|
| 262 |
+
* above its stub. A wall the camera is outside of is cut down, and what hangs on it with it.
|
| 263 |
+
*/
|
| 264 |
+
function attachedTo(walls, part) {
|
| 265 |
+
part.computeBoundingBox();
|
| 266 |
+
const b = part.boundingBox;
|
| 267 |
+
for (let k = 0; k < walls.length; k++) {
|
| 268 |
+
const w = walls[k];
|
| 269 |
+
w.full.computeBoundingBox();
|
| 270 |
+
const box = w.full.boundingBox;
|
| 271 |
+
const a = Math.abs(w.out.x) > Math.abs(w.out.y) ? "x" : "y"; // across the wall
|
| 272 |
+
const t = a === "x" ? "y" : "x"; // along it
|
| 273 |
+
const face = w.out[a] > 0 ? box.min[a] : box.max[a]; // its inside face
|
| 274 |
+
const into = w.out[a] > 0 ? -1 : 1; // the room's side of it
|
| 275 |
+
const near = into > 0 ? b.min[a] - face : face - b.max[a]; // how far the part keeps off the face
|
| 276 |
+
const far = into > 0 ? b.max[a] - face : face - b.min[a]; // how far it reaches into the room
|
| 277 |
+
if (near < -0.005 || far > 0.12 || b.max[a] - b.min[a] > 0.08) continue;
|
| 278 |
+
if (b.min.z < 0.15 || b.max[t] < box.min[t] || b.min[t] > box.max[t]) continue;
|
| 279 |
+
return k;
|
| 280 |
+
}
|
| 281 |
+
return -1;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
/** The walls' extent on the floor, or null without walls. */
|
| 285 |
function roomOf(walls) {
|
| 286 |
if (walls.length < 3) return null;
|
src/render/view.js
CHANGED
|
@@ -27,13 +27,15 @@ import { floorMaterial, lookFor, makeMaterial, robotLookFor, surfaceColour, worl
|
|
| 27 |
import { OCCLUDER, OUTLINED, PixelPass } from "./pixel.js";
|
| 28 |
import { OutlinePass } from "./toon.js";
|
| 29 |
import { GEOM, collectScenery, dressingMatrix, dressingTurn, geomMatrix, layoutLightmap } from "./statics.js";
|
| 30 |
-
import { OCCLUSION_LAYER, bakeMoving, bakeScenery, loadBake } from "./baked.js";
|
| 31 |
import { download } from "../core/assets.js";
|
| 32 |
// A baked room stands on the page's own background: dark or light with the page's theme.
|
| 33 |
const BACKGROUND = { toon: 0xf1eee8, lit: 0xe3dfd8, splat: 0x202124, pixel: 0x0d1226, bakedDark: 0x1c1b1a, bakedLight: 0xe3dfd8 };
|
| 34 |
// What the robot's cameras see above the walls in a baked room, and what the room's reflections show
|
| 35 |
// there: the sky the bake lit it with (linear RGB, tools/bake_light.mjs).
|
| 36 |
-
const BAKED_SKY = [
|
|
|
|
|
|
|
| 37 |
// Pixel over a splat lights the robot and the objects this much more: its palette deepens the mid greys,
|
| 38 |
// and they stand in a light scene without an ink line to set them off.
|
| 39 |
const PIXEL_GAIN = 1.2;
|
|
@@ -159,10 +161,41 @@ export class SceneView {
|
|
| 159 |
if (mesh.userData.geom !== undefined || mesh.userData.probed) bakeMoving(material, bake);
|
| 160 |
else if (mesh.geometry.attributes.uv1) bakeScenery(material, bake);
|
| 161 |
}
|
|
|
|
| 162 |
this.#applyStyle();
|
| 163 |
return true;
|
| 164 |
}
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
/**
|
| 167 |
* The environment's furniture models (setScene's `dressing`; files under `base`), drawn by Lit in place
|
| 168 |
* of the scenery they stand in for, fitted to its bounds (statics.js, dressingMatrix).
|
|
@@ -217,6 +250,11 @@ export class SceneView {
|
|
| 217 |
this.light = null;
|
| 218 |
this.roomLight?.dispose();
|
| 219 |
this.roomLight = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
}
|
| 221 |
|
| 222 |
/**
|
|
@@ -266,6 +304,8 @@ export class SceneView {
|
|
| 266 |
for (const group of scenery.groups) this.#addStatic(group);
|
| 267 |
for (const wall of scenery.walls) this.#addWall(wall);
|
| 268 |
for (const plane of scenery.planes) this.#addPlane(plane);
|
|
|
|
|
|
|
| 269 |
// In splat mode the floor is the splat's; this catches the robot's shadows on it.
|
| 270 |
this.shadowCatcher = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.ShadowMaterial({ opacity: 0.28 }));
|
| 271 |
this.shadowCatcher.receiveShadow = true;
|
|
@@ -296,12 +336,13 @@ export class SceneView {
|
|
| 296 |
const mesh = make(full, "full");
|
| 297 |
const stub = make(stubGeometry, "stub");
|
| 298 |
stub.visible = false;
|
| 299 |
-
this.walls.push({ mesh, stub, center, out });
|
| 300 |
}
|
| 301 |
|
| 302 |
-
/** Walls the camera is outside of drawn as stubs; returns what puts them back. */
|
| 303 |
#cutWalls(camera) {
|
| 304 |
const cut = [];
|
|
|
|
| 305 |
const c = camera.position;
|
| 306 |
for (const w of this.walls) {
|
| 307 |
if (!w.mesh.visible) continue; // not shown in this style
|
|
@@ -309,16 +350,22 @@ export class SceneView {
|
|
| 309 |
w.mesh.visible = false;
|
| 310 |
w.stub.visible = true;
|
| 311 |
cut.push(w);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
}
|
| 313 |
return () => {
|
| 314 |
for (const w of cut) {
|
| 315 |
w.mesh.visible = true;
|
| 316 |
w.stub.visible = false;
|
| 317 |
}
|
|
|
|
| 318 |
};
|
| 319 |
}
|
| 320 |
|
| 321 |
-
#addStatic({ role, look, opacity, parts, dressed = null }) {
|
| 322 |
const geometry = mergeGeometries(parts, false);
|
| 323 |
for (const p of parts) p.dispose();
|
| 324 |
if (look?.map) worldUVs(geometry, look.size); // world-space UVs line textures up across boxes
|
|
@@ -333,7 +380,7 @@ export class SceneView {
|
|
| 333 |
mesh.receiveShadow = true;
|
| 334 |
// Scenery a dressing model stands in for (statics.js) is not in the light map: lit by the probes, until
|
| 335 |
// the model is in (loadDressing) and Lit hides it.
|
| 336 |
-
mesh.userData = { role, lit, toon, casts: mesh.castShadow, dressed, probed: dressed !== null };
|
| 337 |
this.#owned.push(geometry, lit, toon);
|
| 338 |
this.root.add(mesh);
|
| 339 |
this.meshes.push(mesh);
|
|
@@ -590,7 +637,11 @@ export class SceneView {
|
|
| 590 |
this.canvas.style.imageRendering = pixel ? "pixelated" : "";
|
| 591 |
this.lights.lit.visible = look === "lit" && !baked;
|
| 592 |
this.lights.toon.visible = look === "toon";
|
| 593 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
const lighting = this.env?.lighting ?? {};
|
| 595 |
const key = { toon: [0xfff4e6, 1.7, 0.45], lit: [0xffffff, 2.4, 1], splat: [lighting.keyColor ?? 0xfff2e0, lighting.keyIntensity ?? 1.2, 1] }[look];
|
| 596 |
this.key.color.set(key[0]);
|
|
@@ -599,7 +650,7 @@ export class SceneView {
|
|
| 599 |
// Lit's exposure: the modelled rooms are light-coloured, and brighter washes them out. A baked room
|
| 600 |
// goes through AgX, which keeps the bake's soft gradations and colours as a photograph would.
|
| 601 |
this.renderer.toneMapping = baked ? THREE.AgXToneMapping : look === "lit" ? THREE.ACESFilmicToneMapping : THREE.NoToneMapping;
|
| 602 |
-
this.renderer.toneMappingExposure = baked ?
|
| 603 |
// In 3DGS the splat's own light; the baked room's (captured at the first frame) or RoomEnvironment
|
| 604 |
// (y-up) in Lit; Toon is lit by its sky.
|
| 605 |
const splatLight = splat && this.splatLight?.url === this.splat.userData.url ? this.splatLight.texture : null;
|
|
@@ -710,7 +761,10 @@ export class SceneView {
|
|
| 710 |
this.camera.updateProjectionMatrix();
|
| 711 |
}
|
| 712 |
this.controls.update();
|
| 713 |
-
|
|
|
|
|
|
|
|
|
|
| 714 |
if (this.style === "toon") {
|
| 715 |
const uncut = this.#cutWalls(this.camera);
|
| 716 |
this.outline.render(renderer, this.scene, this.camera, "main");
|
|
|
|
| 27 |
import { OCCLUDER, OUTLINED, PixelPass } from "./pixel.js";
|
| 28 |
import { OutlinePass } from "./toon.js";
|
| 29 |
import { GEOM, collectScenery, dressingMatrix, dressingTurn, geomMatrix, layoutLightmap } from "./statics.js";
|
| 30 |
+
import { MotionWatch, OCCLUSION_LAYER, bakeMoving, bakeScenery, loadBake } from "./baked.js";
|
| 31 |
import { download } from "../core/assets.js";
|
| 32 |
// A baked room stands on the page's own background: dark or light with the page's theme.
|
| 33 |
const BACKGROUND = { toon: 0xf1eee8, lit: 0xe3dfd8, splat: 0x202124, pixel: 0x0d1226, bakedDark: 0x1c1b1a, bakedLight: 0xe3dfd8 };
|
| 34 |
// What the robot's cameras see above the walls in a baked room, and what the room's reflections show
|
| 35 |
// there: the sky the bake lit it with (linear RGB, tools/bake_light.mjs).
|
| 36 |
+
const BAKED_SKY = [0.9, 0.95, 1.0];
|
| 37 |
+
// A baked room's exposure (AgX): its sunlit floor a little under white.
|
| 38 |
+
const BAKED_EXPOSURE = 0.9;
|
| 39 |
// Pixel over a splat lights the robot and the objects this much more: its palette deepens the mid greys,
|
| 40 |
// and they stand in a light scene without an ink line to set them off.
|
| 41 |
const PIXEL_GAIN = 1.2;
|
|
|
|
| 161 |
if (mesh.userData.geom !== undefined || mesh.userData.probed) bakeMoving(material, bake);
|
| 162 |
else if (mesh.geometry.attributes.uv1) bakeScenery(material, bake);
|
| 163 |
}
|
| 164 |
+
if (bake.meta.sun) this.#addSun(bake.meta.sun);
|
| 165 |
this.#applyStyle();
|
| 166 |
return true;
|
| 167 |
}
|
| 168 |
|
| 169 |
+
/**
|
| 170 |
+
* The baked room's sun (tools/bake_light.mjs): a directional light whose irradiance is in the light
|
| 171 |
+
* map's units (both go through the same diffuse term), and its shadow map over the whole room, drawn
|
| 172 |
+
* again only when something moved. The walls cast none, as in the bake.
|
| 173 |
+
*/
|
| 174 |
+
#addSun({ direction, irradiance, color }) {
|
| 175 |
+
const sun = new THREE.DirectionalLight(new THREE.Color().setRGB(...color), irradiance);
|
| 176 |
+
const r = this.room ?? { x0: -3, x1: 3, y0: -3, y1: 3 };
|
| 177 |
+
const middle = new THREE.Vector3((r.x0 + r.x1) / 2, (r.y0 + r.y1) / 2, 1);
|
| 178 |
+
sun.position.copy(middle).addScaledVector(new THREE.Vector3(...direction), 10);
|
| 179 |
+
sun.target.position.copy(middle);
|
| 180 |
+
sun.castShadow = true;
|
| 181 |
+
sun.shadow.mapSize.set(2048, 2048);
|
| 182 |
+
sun.shadow.bias = -0.0004;
|
| 183 |
+
sun.shadow.normalBias = 0.02;
|
| 184 |
+
sun.shadow.radius = 3;
|
| 185 |
+
// the shadow camera, fitted to the room's box as the sun sees it
|
| 186 |
+
const cam = sun.shadow.camera;
|
| 187 |
+
cam.position.copy(sun.position);
|
| 188 |
+
cam.lookAt(middle);
|
| 189 |
+
cam.updateMatrixWorld();
|
| 190 |
+
const box = new THREE.Box3();
|
| 191 |
+
for (const x of [r.x0, r.x1]) for (const y of [r.y0, r.y1]) for (const z of [0, 2.7]) box.expandByPoint(new THREE.Vector3(x, y, z).applyMatrix4(cam.matrixWorldInverse));
|
| 192 |
+
Object.assign(cam, { left: box.min.x, right: box.max.x, bottom: box.min.y, top: box.max.y, near: Math.max(0.1, -box.max.z - 0.5), far: -box.min.z + 0.5 });
|
| 193 |
+
cam.updateProjectionMatrix();
|
| 194 |
+
this.scene.add(sun, sun.target);
|
| 195 |
+
this.sun = sun;
|
| 196 |
+
this.sunWatch = new MotionWatch();
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
/**
|
| 200 |
* The environment's furniture models (setScene's `dressing`; files under `base`), drawn by Lit in place
|
| 201 |
* of the scenery they stand in for, fitted to its bounds (statics.js, dressingMatrix).
|
|
|
|
| 250 |
this.light = null;
|
| 251 |
this.roomLight?.dispose();
|
| 252 |
this.roomLight = null;
|
| 253 |
+
if (this.sun) {
|
| 254 |
+
this.scene.remove(this.sun, this.sun.target);
|
| 255 |
+
this.sun.dispose();
|
| 256 |
+
this.sun = null;
|
| 257 |
+
}
|
| 258 |
}
|
| 259 |
|
| 260 |
/**
|
|
|
|
| 304 |
for (const group of scenery.groups) this.#addStatic(group);
|
| 305 |
for (const wall of scenery.walls) this.#addWall(wall);
|
| 306 |
for (const plane of scenery.planes) this.#addPlane(plane);
|
| 307 |
+
// what hangs on each wall goes when it is cut down (statics.js, attachedTo)
|
| 308 |
+
for (const mesh of this.meshes) if (mesh.userData.attached !== null && mesh.userData.attached !== undefined) this.walls[mesh.userData.attached].attached.push(mesh);
|
| 309 |
// In splat mode the floor is the splat's; this catches the robot's shadows on it.
|
| 310 |
this.shadowCatcher = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.ShadowMaterial({ opacity: 0.28 }));
|
| 311 |
this.shadowCatcher.receiveShadow = true;
|
|
|
|
| 336 |
const mesh = make(full, "full");
|
| 337 |
const stub = make(stubGeometry, "stub");
|
| 338 |
stub.visible = false;
|
| 339 |
+
this.walls.push({ mesh, stub, center, out, attached: [] });
|
| 340 |
}
|
| 341 |
|
| 342 |
+
/** Walls the camera is outside of drawn as stubs, without what hangs on them; returns what puts them back. */
|
| 343 |
#cutWalls(camera) {
|
| 344 |
const cut = [];
|
| 345 |
+
const hidden = [];
|
| 346 |
const c = camera.position;
|
| 347 |
for (const w of this.walls) {
|
| 348 |
if (!w.mesh.visible) continue; // not shown in this style
|
|
|
|
| 350 |
w.mesh.visible = false;
|
| 351 |
w.stub.visible = true;
|
| 352 |
cut.push(w);
|
| 353 |
+
for (const m of w.attached) {
|
| 354 |
+
if (!m.visible) continue;
|
| 355 |
+
m.visible = false;
|
| 356 |
+
hidden.push(m);
|
| 357 |
+
}
|
| 358 |
}
|
| 359 |
return () => {
|
| 360 |
for (const w of cut) {
|
| 361 |
w.mesh.visible = true;
|
| 362 |
w.stub.visible = false;
|
| 363 |
}
|
| 364 |
+
for (const m of hidden) m.visible = true;
|
| 365 |
};
|
| 366 |
}
|
| 367 |
|
| 368 |
+
#addStatic({ role, look, opacity, parts, dressed = null, attached = null }) {
|
| 369 |
const geometry = mergeGeometries(parts, false);
|
| 370 |
for (const p of parts) p.dispose();
|
| 371 |
if (look?.map) worldUVs(geometry, look.size); // world-space UVs line textures up across boxes
|
|
|
|
| 380 |
mesh.receiveShadow = true;
|
| 381 |
// Scenery a dressing model stands in for (statics.js) is not in the light map: lit by the probes, until
|
| 382 |
// the model is in (loadDressing) and Lit hides it.
|
| 383 |
+
mesh.userData = { role, lit, toon, casts: mesh.castShadow, dressed, probed: dressed !== null, attached };
|
| 384 |
this.#owned.push(geometry, lit, toon);
|
| 385 |
this.root.add(mesh);
|
| 386 |
this.meshes.push(mesh);
|
|
|
|
| 637 |
this.canvas.style.imageRendering = pixel ? "pixelated" : "";
|
| 638 |
this.lights.lit.visible = look === "lit" && !baked;
|
| 639 |
this.lights.toon.visible = look === "toon";
|
| 640 |
+
// a baked room has its sun instead of the key light (and its shadows)
|
| 641 |
+
this.key.visible = !baked;
|
| 642 |
+
if (this.sun) this.sun.visible = baked;
|
| 643 |
+
this.sunWatch?.invalidate();
|
| 644 |
+
this.renderer.shadowMap.enabled = !baked || Boolean(this.sun);
|
| 645 |
const lighting = this.env?.lighting ?? {};
|
| 646 |
const key = { toon: [0xfff4e6, 1.7, 0.45], lit: [0xffffff, 2.4, 1], splat: [lighting.keyColor ?? 0xfff2e0, lighting.keyIntensity ?? 1.2, 1] }[look];
|
| 647 |
this.key.color.set(key[0]);
|
|
|
|
| 650 |
// Lit's exposure: the modelled rooms are light-coloured, and brighter washes them out. A baked room
|
| 651 |
// goes through AgX, which keeps the bake's soft gradations and colours as a photograph would.
|
| 652 |
this.renderer.toneMapping = baked ? THREE.AgXToneMapping : look === "lit" ? THREE.ACESFilmicToneMapping : THREE.NoToneMapping;
|
| 653 |
+
this.renderer.toneMappingExposure = baked ? BAKED_EXPOSURE : 0.8;
|
| 654 |
// In 3DGS the splat's own light; the baked room's (captured at the first frame) or RoomEnvironment
|
| 655 |
// (y-up) in Lit; Toon is lit by its sky.
|
| 656 |
const splatLight = splat && this.splatLight?.url === this.splat.userData.url ? this.splatLight.texture : null;
|
|
|
|
| 761 |
this.camera.updateProjectionMatrix();
|
| 762 |
}
|
| 763 |
this.controls.update();
|
| 764 |
+
// The robot cameras below reuse this frame's shadow map. A baked room's sun shadows only change when
|
| 765 |
+
// something moves: drawn again then (at most 30 times a second), else kept.
|
| 766 |
+
const bakedSun = this.style === "lit" && this.light && this.sun;
|
| 767 |
+
renderer.shadowMap.needsUpdate = bakedSun ? this.sunWatch.changed(this.geoms) : true;
|
| 768 |
if (this.style === "toon") {
|
| 769 |
const uncut = this.#cutWalls(this.camera);
|
| 770 |
this.outline.render(renderer, this.scene, this.camera, "main");
|
src/robots/fixtures.js
CHANGED
|
@@ -72,19 +72,29 @@ export function reachingArm(sim, fx) {
|
|
| 72 |
return c[1] * n[0] - c[0] * n[1] > 0 ? "left" : "right";
|
| 73 |
}
|
| 74 |
|
| 75 |
-
/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
function geometry(sim, fx) {
|
| 77 |
const { model, data } = sim;
|
| 78 |
const g = fx.handle;
|
| 79 |
-
|
| 80 |
const Rg = data.geom_xmat.subarray(9 * g, 9 * g + 9);
|
| 81 |
const bar = [Rg[2], Rg[5], Rg[8]]; // a capsule lies along its frame's z
|
|
|
|
| 82 |
const Rb = data.xmat.subarray(9 * fx.body, 9 * fx.body + 9);
|
| 83 |
const ax = model.jnt_axis.subarray(3 * fx.joint, 3 * fx.joint + 3);
|
| 84 |
// the joint's axis in the world (the body's frame turns it)
|
| 85 |
const axis = [0, 1, 2].map((r) => Rb[3 * r] * ax[0] + Rb[3 * r + 1] * ax[1] + Rb[3 * r + 2] * ax[2]);
|
| 86 |
// The face the pull is on looks out along the level part of panel-to-bar that is across the bar (the
|
| 87 |
-
// panel: the body's biggest geom, a door's leaf or a drawer's floor)
|
|
|
|
| 88 |
let panel = -1;
|
| 89 |
let big = 0;
|
| 90 |
for (let k = model.body_geomadr[fx.body]; k < model.body_geomadr[fx.body] + model.body_geomnum[fx.body]; k++) {
|
|
@@ -93,10 +103,27 @@ function geometry(sim, fx) {
|
|
| 93 |
}
|
| 94 |
const C = Array.from(data.geom_xpos.subarray(3 * panel, 3 * panel + 3));
|
| 95 |
const d = [H[0] - C[0], H[1] - C[1]];
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
const nl = Math.hypot(n[0], n[1]) || 1;
|
| 99 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
if (fx.type === "slide") {
|
| 101 |
out.slide = [axis[0], axis[1]]; // the way it comes out (positive qpos)
|
| 102 |
} else {
|
|
@@ -120,7 +147,7 @@ function geometry(sim, fx) {
|
|
| 120 |
export function standPoses(robot, fx, q0, q1, { sides = ["left", "right"], push = false } = {}) {
|
| 121 |
const sim = robot.sim;
|
| 122 |
const geo = geometry(sim, fx);
|
| 123 |
-
if (!geo.level) return [];
|
| 124 |
// where the hand goes: the bar, or just in front of it
|
| 125 |
const H = push ? [geo.H[0] + PUSH_OFF * geo.face[0], geo.H[1] + PUSH_OFF * geo.face[1], geo.H[2]] : geo.H;
|
| 126 |
const held = heldBodies(robot);
|
|
@@ -177,7 +204,7 @@ export function standPoses(robot, fx, q0, q1, { sides = ["left", "right"], push
|
|
| 177 |
clear = t;
|
| 178 |
}
|
| 179 |
// the grasp, and with the base a couple of centimetres off (it stops about so close to a pose)
|
| 180 |
-
const graspAt = (x, y) => graspPose(robot, side, [x, y, H[2] - zc], { width: push ? 0.01 : 0.024, narrowYaw:
|
| 181 |
const grasp = graspAt(ux, uy);
|
| 182 |
if (!grasp || [[0.02, 0], [-0.02, 0], [0, 0.02], [0, -0.02]].some(([ex, ey]) => !graspAt(ux + ex, uy + ey))) continue;
|
| 183 |
const short = Math.abs(span - clear);
|
|
@@ -199,7 +226,7 @@ function* grip(robot, fx, side, { push = false } = {}) {
|
|
| 199 |
const H = push ? [geo.H[0] + PUSH_OFF * geo.face[0], geo.H[1] + PUSH_OFF * geo.face[1], geo.H[2]] : geo.H;
|
| 200 |
const p = robot.toRobot(H);
|
| 201 |
const yaw = robot.pose()[2];
|
| 202 |
-
const pose = graspPose(robot, side, p, { width: push ? 0.01 : 0.024, narrowYaw:
|
| 203 |
if (!pose) return { ok: false, message: `the ${side} arm cannot ${push ? "reach" : "grasp"} the pull from here` };
|
| 204 |
const at = (dz) => ({ ...robot.wristTarget(side, [pose.wrist[0], pose.wrist[1], pose.wrist[2] + dz], pose.pitch), roll: pose.roll });
|
| 205 |
// The gripper turns to point down near the shoulder first (from the folded arm it points up; turned on
|
|
|
|
| 72 |
return c[1] * n[0] - c[0] * n[1] > 0 ? "left" : "right";
|
| 73 |
}
|
| 74 |
|
| 75 |
+
// How far below an upright bar's top the hand closes on it: the fingertips stay above its top post.
|
| 76 |
+
const GRIP_DEPTH = 0.03;
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Where the hand closes on the bar (world: a level bar's middle, 3 cm below an upright bar's top), the
|
| 80 |
+
* bar's direction, the face it is on, how the jaws close across it (`across`, a world yaw: across the bar,
|
| 81 |
+
* which for an upright bar is along the face's normal, the far jaw between bar and face), the bar's top,
|
| 82 |
+
* and the fixture's motion there.
|
| 83 |
+
*/
|
| 84 |
function geometry(sim, fx) {
|
| 85 |
const { model, data } = sim;
|
| 86 |
const g = fx.handle;
|
| 87 |
+
let H = Array.from(data.geom_xpos.subarray(3 * g, 3 * g + 3));
|
| 88 |
const Rg = data.geom_xmat.subarray(9 * g, 9 * g + 9);
|
| 89 |
const bar = [Rg[2], Rg[5], Rg[8]]; // a capsule lies along its frame's z
|
| 90 |
+
const upright = Math.abs(bar[2]) > 0.9;
|
| 91 |
const Rb = data.xmat.subarray(9 * fx.body, 9 * fx.body + 9);
|
| 92 |
const ax = model.jnt_axis.subarray(3 * fx.joint, 3 * fx.joint + 3);
|
| 93 |
// the joint's axis in the world (the body's frame turns it)
|
| 94 |
const axis = [0, 1, 2].map((r) => Rb[3 * r] * ax[0] + Rb[3 * r + 1] * ax[1] + Rb[3 * r + 2] * ax[2]);
|
| 95 |
// The face the pull is on looks out along the level part of panel-to-bar that is across the bar (the
|
| 96 |
+
// panel: the body's biggest geom, a door's leaf or a drawer's floor); for an upright bar, along the
|
| 97 |
+
// leaf's thinnest axis, toward the bar.
|
| 98 |
let panel = -1;
|
| 99 |
let big = 0;
|
| 100 |
for (let k = model.body_geomadr[fx.body]; k < model.body_geomadr[fx.body] + model.body_geomnum[fx.body]; k++) {
|
|
|
|
| 103 |
}
|
| 104 |
const C = Array.from(data.geom_xpos.subarray(3 * panel, 3 * panel + 3));
|
| 105 |
const d = [H[0] - C[0], H[1] - C[1]];
|
| 106 |
+
let n;
|
| 107 |
+
if (upright) {
|
| 108 |
+
const s = model.geom_size.subarray(3 * panel, 3 * panel + 3);
|
| 109 |
+
const k = s[0] <= s[1] && s[0] <= s[2] ? 0 : s[1] <= s[2] ? 1 : 2;
|
| 110 |
+
const Rp = data.geom_xmat.subarray(9 * panel, 9 * panel + 9);
|
| 111 |
+
n = [Rp[k], Rp[3 + k]];
|
| 112 |
+
if (d[0] * n[0] + d[1] * n[1] < 0) n = [-n[0], -n[1]];
|
| 113 |
+
} else {
|
| 114 |
+
const along = d[0] * bar[0] + d[1] * bar[1];
|
| 115 |
+
n = [d[0] - along * bar[0], d[1] - along * bar[1]];
|
| 116 |
+
}
|
| 117 |
const nl = Math.hypot(n[0], n[1]) || 1;
|
| 118 |
+
const face = [n[0] / nl, n[1] / nl];
|
| 119 |
+
let top = H[2] + 0.012;
|
| 120 |
+
if (upright) {
|
| 121 |
+
const half = model.geom_size[3 * g + 1] * Math.sign(bar[2]);
|
| 122 |
+
top = H[2] + half * bar[2] + model.geom_size[3 * g];
|
| 123 |
+
H = [H[0] + half * bar[0], H[1] + half * bar[1], H[2] + half * bar[2] - GRIP_DEPTH];
|
| 124 |
+
}
|
| 125 |
+
const across = upright ? Math.atan2(face[1], face[0]) : Math.atan2(bar[1], bar[0]) + Math.PI / 2;
|
| 126 |
+
const out = { H, bar, level: Math.abs(bar[2]) < 0.2, upright, face, panel: C, top, across };
|
| 127 |
if (fx.type === "slide") {
|
| 128 |
out.slide = [axis[0], axis[1]]; // the way it comes out (positive qpos)
|
| 129 |
} else {
|
|
|
|
| 147 |
export function standPoses(robot, fx, q0, q1, { sides = ["left", "right"], push = false } = {}) {
|
| 148 |
const sim = robot.sim;
|
| 149 |
const geo = geometry(sim, fx);
|
| 150 |
+
if (!geo.level && !geo.upright) return [];
|
| 151 |
// where the hand goes: the bar, or just in front of it
|
| 152 |
const H = push ? [geo.H[0] + PUSH_OFF * geo.face[0], geo.H[1] + PUSH_OFF * geo.face[1], geo.H[2]] : geo.H;
|
| 153 |
const held = heldBodies(robot);
|
|
|
|
| 204 |
clear = t;
|
| 205 |
}
|
| 206 |
// the grasp, and with the base a couple of centimetres off (it stops about so close to a pose)
|
| 207 |
+
const graspAt = (x, y) => graspPose(robot, side, [x, y, H[2] - zc], { width: push ? 0.01 : 0.024, narrowYaw: geo.across - o.yaw, support: H[2] - zc - 0.3, top: geo.top - zc, mode: "top" });
|
| 208 |
const grasp = graspAt(ux, uy);
|
| 209 |
if (!grasp || [[0.02, 0], [-0.02, 0], [0, 0.02], [0, -0.02]].some(([ex, ey]) => !graspAt(ux + ex, uy + ey))) continue;
|
| 210 |
const short = Math.abs(span - clear);
|
|
|
|
| 226 |
const H = push ? [geo.H[0] + PUSH_OFF * geo.face[0], geo.H[1] + PUSH_OFF * geo.face[1], geo.H[2]] : geo.H;
|
| 227 |
const p = robot.toRobot(H);
|
| 228 |
const yaw = robot.pose()[2];
|
| 229 |
+
const pose = graspPose(robot, side, p, { width: push ? 0.01 : 0.024, narrowYaw: geo.across - yaw, support: p[2] - 0.3, top: p[2] + (geo.top - H[2]), mode: "top" });
|
| 230 |
if (!pose) return { ok: false, message: `the ${side} arm cannot ${push ? "reach" : "grasp"} the pull from here` };
|
| 231 |
const at = (dz) => ({ ...robot.wristTarget(side, [pose.wrist[0], pose.wrist[1], pose.wrist[2] + dz], pose.pitch), roll: pose.roll });
|
| 232 |
// The gripper turns to point down near the shoulder first (from the folded arm it points up; turned on
|
tools/bake_light.mjs
CHANGED
|
@@ -4,16 +4,19 @@
|
|
| 4 |
// usage: node tools/bake_light.mjs [env=kitchen] [--samples 256] [--bounces 3] [--threads N]
|
| 5 |
//
|
| 6 |
// The scenery (src/render/statics.js, the same triangles and light map layout as the page) is lit by a
|
| 7 |
-
// sky over the open room (
|
| 8 |
-
// lamps), with light bouncing between the surfaces: each pass gathers, for
|
| 9 |
-
// the light arriving over its hemisphere, where a ray that hits a surface
|
| 10 |
-
//
|
| 11 |
-
//
|
|
|
|
|
|
|
|
|
|
| 12 |
//
|
| 13 |
// Writes, next to the environment's XML: light/lightmap.png (irradiance over pi, sRGB-encoded over
|
| 14 |
// `scale`), light/probes.bin.gz (the probes, the same way, RGBA per direction) and light/light.json (the
|
| 15 |
-
// layout's fingerprint, sizes, the probe grid). The page uses them only if the fingerprint
|
| 16 |
-
// layout: after changing the scenery, bake again.
|
| 17 |
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
| 18 |
import { availableParallelism } from "node:os";
|
| 19 |
import { dirname, join } from "node:path";
|
|
@@ -22,8 +25,12 @@ import { Worker, isMainThread, parentPort, workerData } from "node:worker_thread
|
|
| 22 |
import { deflateSync, gzipSync } from "node:zlib";
|
| 23 |
import { buildBVH, makeCaster } from "./light/bvh.mjs";
|
| 24 |
|
| 25 |
-
const SKY = [
|
| 26 |
const GROUND = 0.25; // radiance below the horizon, outside
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
const SCALE = 1.6; // the stored range: irradiance / pi up to this
|
| 28 |
const PROBE_STEP = 0.15; // metres between probes
|
| 29 |
|
|
@@ -71,7 +78,7 @@ async function main() {
|
|
| 71 |
}
|
| 72 |
for (const wall of scenery.walls) {
|
| 73 |
if (wall.role === "proxy" && decor) continue;
|
| 74 |
-
occluders.push({ geometry: wall.full, albedo: albedoOf(wall.look, wall.colour), emit: 0 });
|
| 75 |
}
|
| 76 |
for (const plane of scenery.planes) {
|
| 77 |
if (!plane.room || decor) continue;
|
|
@@ -113,6 +120,27 @@ async function main() {
|
|
| 113 |
}
|
| 114 |
}
|
| 115 |
const bvh = buildBVH(input, nTri, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
// per-triangle attributes in the BVH's order
|
| 117 |
const shared = (Type, n) => new Type(new SharedArrayBuffer(n * Type.BYTES_PER_ELEMENT));
|
| 118 |
const triAlbedo = shared(Float32Array, 3 * nTri);
|
|
@@ -182,7 +210,12 @@ async function main() {
|
|
| 182 |
const prev = shared(Float32Array, 3 * W * H);
|
| 183 |
const out = shared(Float32Array, 3 * W * H);
|
| 184 |
const back = shared(Float32Array, W * H); // the share of rays that met a surface from behind
|
| 185 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
const workers = Array.from({ length: threads }, () => new Worker(fileURLToPath(import.meta.url), { workerData: common }));
|
| 187 |
const run = (job) =>
|
| 188 |
Promise.all(
|
|
@@ -205,7 +238,15 @@ async function main() {
|
|
| 205 |
for (let k = 0; k < nTex; k++) if (back[texPixel[k]] > 0.3) covered[texPixel[k]] = 0;
|
| 206 |
denoise(out, covered, chartOf, normals, W, H);
|
| 207 |
dilate(out, covered, chartOf, W, H);
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
log(`pass ${pass + 1}/${bounces} done`);
|
| 210 |
}
|
| 211 |
const lightmap = encode(out, W * H, 3);
|
|
@@ -242,6 +283,8 @@ async function main() {
|
|
| 242 |
probes: { file: "probes.bin.gz", dims, origin, step },
|
| 243 |
scale: SCALE,
|
| 244 |
sky: SKY,
|
|
|
|
|
|
|
| 245 |
samples,
|
| 246 |
bounces,
|
| 247 |
};
|
|
@@ -460,6 +503,7 @@ function crc32(bytes) {
|
|
| 460 |
function work() {
|
| 461 |
const d = workerData;
|
| 462 |
const { cast, hit } = makeCaster(d.bvh);
|
|
|
|
| 463 |
const { W, H, SKY: sky, GROUND: ground } = d;
|
| 464 |
|
| 465 |
/** Radiance arriving along -dir at the origin from what the ray (o, dir) meets; counts back faces. */
|
|
@@ -586,6 +630,44 @@ function work() {
|
|
| 586 |
d.back[pixel] = state.back / N;
|
| 587 |
}
|
| 588 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 589 |
} else if (job.kind === "probes") {
|
| 590 |
const [nx, ny, nz] = job.dims;
|
| 591 |
const total = nx * ny * nz;
|
|
|
|
| 4 |
// usage: node tools/bake_light.mjs [env=kitchen] [--samples 256] [--bounces 3] [--threads N]
|
| 5 |
//
|
| 6 |
// The scenery (src/render/statics.js, the same triangles and light map layout as the page) is lit by a
|
| 7 |
+
// sky over the open room (overcast-like, brightest overhead, a little cool), by a warm sun, and by its
|
| 8 |
+
// emissive surfaces (windows, lamps), with light bouncing between the surfaces: each pass gathers, for
|
| 9 |
+
// every texel of the light map, the light arriving over its hemisphere, where a ray that hits a surface
|
| 10 |
+
// brings that surface's light from the pass before. The sun's own light is drawn at run time (a
|
| 11 |
+
// directional light with a shadow map, src/render/view.js), so the maps leave it out but keep its bounce;
|
| 12 |
+
// as there, the walls do not stand in its way (the room is a cutaway, and their shade would fill it).
|
| 13 |
+
// The robot, the objects and the moving parts (doors, drawers) are not in it: they move. They are lit at
|
| 14 |
+
// run time from the probes, a grid of irradiance from six directions (an ambient cube).
|
| 15 |
//
|
| 16 |
// Writes, next to the environment's XML: light/lightmap.png (irradiance over pi, sRGB-encoded over
|
| 17 |
// `scale`), light/probes.bin.gz (the probes, the same way, RGBA per direction) and light/light.json (the
|
| 18 |
+
// layout's fingerprint, sizes, the probe grid, the sun). The page uses them only if the fingerprint
|
| 19 |
+
// matches its own layout: after changing the scenery, bake again.
|
| 20 |
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
| 21 |
import { availableParallelism } from "node:os";
|
| 22 |
import { dirname, join } from "node:path";
|
|
|
|
| 25 |
import { deflateSync, gzipSync } from "node:zlib";
|
| 26 |
import { buildBVH, makeCaster } from "./light/bvh.mjs";
|
| 27 |
|
| 28 |
+
const SKY = [0.9, 0.95, 1.0]; // the sky's radiance overhead (linear RGB); toward the horizon a third of it
|
| 29 |
const GROUND = 0.25; // radiance below the horizon, outside
|
| 30 |
+
// The sun: where it is (azimuth from +x toward +y, elevation, degrees: over the open side of the room, so
|
| 31 |
+
// it lights the kitchen wall and the window wall one mostly looks at), its irradiance square to it, its colour, and
|
| 32 |
+
// its disc's angular radius (degrees: the shade's soft edge).
|
| 33 |
+
const SUN = { azimuth: -60, elevation: 50, irradiance: 4.5, color: [1.0, 0.93, 0.83], radius: 1.2, samples: 16 };
|
| 34 |
const SCALE = 1.6; // the stored range: irradiance / pi up to this
|
| 35 |
const PROBE_STEP = 0.15; // metres between probes
|
| 36 |
|
|
|
|
| 78 |
}
|
| 79 |
for (const wall of scenery.walls) {
|
| 80 |
if (wall.role === "proxy" && decor) continue;
|
| 81 |
+
occluders.push({ geometry: wall.full, albedo: albedoOf(wall.look, wall.colour), emit: 0, wall: true });
|
| 82 |
}
|
| 83 |
for (const plane of scenery.planes) {
|
| 84 |
if (!plane.room || decor) continue;
|
|
|
|
| 120 |
}
|
| 121 |
}
|
| 122 |
const bvh = buildBVH(input, nTri, true);
|
| 123 |
+
// what stands in the sun's way: everything but the walls
|
| 124 |
+
let nSunTri = 0;
|
| 125 |
+
for (const o of occluders) if (!o.wall) nSunTri += o.geometry.attributes.position.count / 3;
|
| 126 |
+
const sunInput = new Float32Array(9 * nSunTri);
|
| 127 |
+
{
|
| 128 |
+
let at = 0;
|
| 129 |
+
let from = 0;
|
| 130 |
+
for (const o of occluders) {
|
| 131 |
+
const n = 9 * (o.geometry.attributes.position.count / 3);
|
| 132 |
+
if (!o.wall) {
|
| 133 |
+
sunInput.set(input.subarray(from, from + n), at);
|
| 134 |
+
at += n;
|
| 135 |
+
}
|
| 136 |
+
from += n;
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
const sunBvh = buildBVH(sunInput, nSunTri, true);
|
| 140 |
+
const el = (SUN.elevation * Math.PI) / 180;
|
| 141 |
+
const az = (SUN.azimuth * Math.PI) / 180;
|
| 142 |
+
const sunDir = [Math.cos(el) * Math.cos(az), Math.cos(el) * Math.sin(az), Math.sin(el)];
|
| 143 |
+
const sun = { ...SUN, direction: sunDir };
|
| 144 |
// per-triangle attributes in the BVH's order
|
| 145 |
const shared = (Type, n) => new Type(new SharedArrayBuffer(n * Type.BYTES_PER_ELEMENT));
|
| 146 |
const triAlbedo = shared(Float32Array, 3 * nTri);
|
|
|
|
| 210 |
const prev = shared(Float32Array, 3 * W * H);
|
| 211 |
const out = shared(Float32Array, 3 * W * H);
|
| 212 |
const back = shared(Float32Array, W * H); // the share of rays that met a surface from behind
|
| 213 |
+
const sunMap = shared(Float32Array, 3 * W * H); // the sun's own light on each texel (irradiance / pi)
|
| 214 |
+
const common = {
|
| 215 |
+
bvh: { nodes: bvh.nodes, info: bvh.info, tris: bvh.tris },
|
| 216 |
+
sunBvh: { nodes: sunBvh.nodes, info: sunBvh.info, tris: sunBvh.tris },
|
| 217 |
+
triAlbedo, triEmit, triUV1, triOwner, texPixel, texData, texIgnore, counter, prev, out, back, sunMap, W, H, SKY, GROUND, sun,
|
| 218 |
+
};
|
| 219 |
const workers = Array.from({ length: threads }, () => new Worker(fileURLToPath(import.meta.url), { workerData: common }));
|
| 220 |
const run = (job) =>
|
| 221 |
Promise.all(
|
|
|
|
| 238 |
for (let k = 0; k < nTex; k++) if (back[texPixel[k]] > 0.3) covered[texPixel[k]] = 0;
|
| 239 |
denoise(out, covered, chartOf, normals, W, H);
|
| 240 |
dilate(out, covered, chartOf, W, H);
|
| 241 |
+
if (pass === 0) {
|
| 242 |
+
// the sun on every texel (the texels inside geometry known now), for what it bounces
|
| 243 |
+
counter[0] = 0;
|
| 244 |
+
await run({ kind: "sun" });
|
| 245 |
+
dilate(sunMap, covered, chartOf, W, H);
|
| 246 |
+
log("sun done");
|
| 247 |
+
}
|
| 248 |
+
// what the next pass's rays find on the surfaces they hit: their light, the sun's with it
|
| 249 |
+
for (let k = 0; k < out.length; k++) prev[k] = out[k] + sunMap[k];
|
| 250 |
log(`pass ${pass + 1}/${bounces} done`);
|
| 251 |
}
|
| 252 |
const lightmap = encode(out, W * H, 3);
|
|
|
|
| 283 |
probes: { file: "probes.bin.gz", dims, origin, step },
|
| 284 |
scale: SCALE,
|
| 285 |
sky: SKY,
|
| 286 |
+
// drawn at run time: a directional light from `direction` (toward the sun), `irradiance` square to it
|
| 287 |
+
sun: { direction: sunDir.map((v) => +v.toFixed(5)), irradiance: SUN.irradiance, color: SUN.color, radius: SUN.radius },
|
| 288 |
samples,
|
| 289 |
bounces,
|
| 290 |
};
|
|
|
|
| 503 |
function work() {
|
| 504 |
const d = workerData;
|
| 505 |
const { cast, hit } = makeCaster(d.bvh);
|
| 506 |
+
const sunCaster = makeCaster(d.sunBvh); // everything but the walls
|
| 507 |
const { W, H, SKY: sky, GROUND: ground } = d;
|
| 508 |
|
| 509 |
/** Radiance arriving along -dir at the origin from what the ray (o, dir) meets; counts back faces. */
|
|
|
|
| 630 |
d.back[pixel] = state.back / N;
|
| 631 |
}
|
| 632 |
}
|
| 633 |
+
} else if (job.kind === "sun") {
|
| 634 |
+
// the share of the sun's disc each texel sees (rays over the disc, past nothing but walls), times its
|
| 635 |
+
// irradiance there: irradiance / pi, as the light map holds
|
| 636 |
+
const { direction: s, irradiance, color, radius, samples: N } = d.sun;
|
| 637 |
+
const sgn = s[2] >= 0 ? 1 : -1;
|
| 638 |
+
const a = -1 / (sgn + s[2]);
|
| 639 |
+
const b = s[0] * s[1] * a;
|
| 640 |
+
const t1 = [1 + sgn * s[0] * s[0] * a, sgn * b, -sgn * s[0]];
|
| 641 |
+
const t2 = [b, sgn + s[1] * s[1] * a, -s[1]];
|
| 642 |
+
const spread = Math.tan((radius * Math.PI) / 180);
|
| 643 |
+
const n = d.texPixel.length;
|
| 644 |
+
for (;;) {
|
| 645 |
+
const start = Atomics.add(d.counter, 0, 512);
|
| 646 |
+
if (start >= n) break;
|
| 647 |
+
for (let k = start; k < Math.min(n, start + 512); k++) {
|
| 648 |
+
const q = 6 * k;
|
| 649 |
+
const nx = d.texData[q + 3], ny = d.texData[q + 4], nz = d.texData[q + 5];
|
| 650 |
+
const cos = nx * s[0] + ny * s[1] + nz * s[2];
|
| 651 |
+
const pixel = d.texPixel[k];
|
| 652 |
+
if (cos <= 0) continue;
|
| 653 |
+
const ox = d.texData[q] + nx * 1e-3, oy = d.texData[q + 1] + ny * 1e-3, oz = d.texData[q + 2] + nz * 1e-3;
|
| 654 |
+
let seen = 0;
|
| 655 |
+
for (let i = 0; i < N; i++) {
|
| 656 |
+
// a point on the disc (Vogel's spiral)
|
| 657 |
+
const r = spread * Math.sqrt((i + 0.5) / N);
|
| 658 |
+
const phi = i * 2.399963 + hash01(k) * 6.283185;
|
| 659 |
+
const u = r * Math.cos(phi), v = r * Math.sin(phi);
|
| 660 |
+
let dx = s[0] + u * t1[0] + v * t2[0], dy = s[1] + u * t1[1] + v * t2[1], dz = s[2] + u * t1[2] + v * t2[2];
|
| 661 |
+
const l = Math.hypot(dx, dy, dz);
|
| 662 |
+
dx /= l; dy /= l; dz /= l;
|
| 663 |
+
if (!sunCaster.cast(ox, oy, oz, dx, dy, dz, 1e9)) seen++;
|
| 664 |
+
}
|
| 665 |
+
const e = (irradiance * cos * seen) / N / Math.PI;
|
| 666 |
+
d.sunMap[3 * pixel] = e * color[0];
|
| 667 |
+
d.sunMap[3 * pixel + 1] = e * color[1];
|
| 668 |
+
d.sunMap[3 * pixel + 2] = e * color[2];
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
} else if (job.kind === "probes") {
|
| 672 |
const [nx, ny, nz] = job.dims;
|
| 673 |
const total = nx * ny * nz;
|
tools/make_kitchen.py
CHANGED
|
@@ -66,10 +66,11 @@ def vis(kind: str, material: str, rgba: str | None = None, **attrs) -> str:
|
|
| 66 |
return f'<geom type="{kind}" {a} material="{material}"{c} density="0" contype="0" conaffinity="0"/>'
|
| 67 |
|
| 68 |
|
| 69 |
-
def bar_handle(name: str, at, axis: str, normal: str, out: int, length: float, radius: float = 0.01, stand: float = 0.04) -> list[str]:
|
| 70 |
"""A bar pull for a drawer or a door: a steel bar `length` long along `axis` ("x", "y" or "z"), its
|
| 71 |
middle in front of the point `at` on the face it is fixed to, which looks along `normal` (`out` +1 or
|
| 72 |
-
-1: the side the bar is on). `stand` is the room between bar and face, for a finger behind it
|
|
|
|
| 73 |
n, a = "xyz".index(normal), "xyz".index(axis)
|
| 74 |
gap = stand + radius # bar centre off the face
|
| 75 |
c = list(at)
|
|
@@ -80,7 +81,7 @@ def bar_handle(name: str, at, axis: str, normal: str, out: int, length: float, r
|
|
| 80 |
geoms = [f'<geom name="{name}" type="capsule" fromto="{f(*p, *q)}" size="{radius}" material="steel" mass="0.1" contype="1" conaffinity="1"/>']
|
| 81 |
for s in (-1, 1):
|
| 82 |
post = list(at)
|
| 83 |
-
post[a] += s * (length / 2 -
|
| 84 |
post[n] += out * gap / 2
|
| 85 |
size = [0.006, 0.006, 0.006]
|
| 86 |
size[n] = gap / 2
|
|
@@ -355,10 +356,11 @@ def fridge() -> None:
|
|
| 355 |
for k, (ny, nz, mat) in enumerate([(-0.3, 0.55, "note_0"), (-0.42, 0.62, "note_1"), (-0.36, 0.38, "note_2")]):
|
| 356 |
d.append(vis("box", mat, pos=f(t + 0.001, ny, nz), size="0.001 0.05 0.06"))
|
| 357 |
d.append(vis("cylinder", f"magnet_{k}", fromto=f(t + 0.001, ny, nz + 0.05, t + 0.008, ny, nz + 0.05), size="0.01"))
|
| 358 |
-
#
|
| 359 |
-
# the wrist cannot point the gripper down), the jaws round it across
|
| 360 |
-
# ways as the door turns.
|
| 361 |
-
|
|
|
|
| 362 |
lines.append(f' <body name="fridge_door" pos="{f(front + t, yb, hgt / 2 + 0.02)}">')
|
| 363 |
# axis +z: opening turns the free edge (-y, the counter's side) out toward the room (+x); the hinge's
|
| 364 |
# friction holds it where it is left (a brush does not swing it wide)
|
|
@@ -727,10 +729,10 @@ def details() -> None:
|
|
| 727 |
vis("box", "clock_frame", pos=f(-1.72, 2.578, 1.99), size="0.006 0.002 0.05"),
|
| 728 |
vis("box", "clock_frame", pos=f(-1.69, 2.578, 1.95), size="0.04 0.002 0.005"),
|
| 729 |
]
|
| 730 |
-
# pictures:
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
g += [vis("box", "picture_frame", pos=f(2.596, -1.75, 1.55), size=f(0.006, 0.45, 0.3)), vis("box", "canvas_2", pos=f(2.592, -1.75, 1.55), size=f(0.004, 0.42, 0.27))]
|
| 735 |
static("details_walls", g)
|
| 736 |
# lamps over the dining table
|
|
|
|
| 66 |
return f'<geom type="{kind}" {a} material="{material}"{c} density="0" contype="0" conaffinity="0"/>'
|
| 67 |
|
| 68 |
|
| 69 |
+
def bar_handle(name: str, at, axis: str, normal: str, out: int, length: float, radius: float = 0.01, stand: float = 0.04, inset: float = 0.025) -> list[str]:
|
| 70 |
"""A bar pull for a drawer or a door: a steel bar `length` long along `axis` ("x", "y" or "z"), its
|
| 71 |
middle in front of the point `at` on the face it is fixed to, which looks along `normal` (`out` +1 or
|
| 72 |
+
-1: the side the bar is on). `stand` is the room between bar and face, for a finger behind it; the
|
| 73 |
+
posts that hold it are `inset` in from its ends."""
|
| 74 |
n, a = "xyz".index(normal), "xyz".index(axis)
|
| 75 |
gap = stand + radius # bar centre off the face
|
| 76 |
c = list(at)
|
|
|
|
| 81 |
geoms = [f'<geom name="{name}" type="capsule" fromto="{f(*p, *q)}" size="{radius}" material="steel" mass="0.1" contype="1" conaffinity="1"/>']
|
| 82 |
for s in (-1, 1):
|
| 83 |
post = list(at)
|
| 84 |
+
post[a] += s * (length / 2 - inset)
|
| 85 |
post[n] += out * gap / 2
|
| 86 |
size = [0.006, 0.006, 0.006]
|
| 87 |
size[n] = gap / 2
|
|
|
|
| 356 |
for k, (ny, nz, mat) in enumerate([(-0.3, 0.55, "note_0"), (-0.42, 0.62, "note_1"), (-0.36, 0.38, "note_2")]):
|
| 357 |
d.append(vis("box", mat, pos=f(t + 0.001, ny, nz), size="0.001 0.05 0.06"))
|
| 358 |
d.append(vis("cylinder", f"magnet_{k}", fromto=f(t + 0.001, ny, nz + 0.05, t + 0.008, ny, nz + 0.05), size="0.01"))
|
| 359 |
+
# An upright bar pull near the free edge, as a fridge's is, from 0.32 m up to 0.82 m: an arm grasps its
|
| 360 |
+
# top from straight above (higher, the wrist cannot point the gripper down), the jaws round it across
|
| 361 |
+
# the door, the far one between bar and door, so they hold it both ways as the door turns. The top post
|
| 362 |
+
# sits 7 cm down, below the fingertips.
|
| 363 |
+
d += bar_handle("fridge_handle", (t, -2 * w + 0.17, 0.57 - (hgt / 2 + 0.02)), "z", "x", 1, 0.5, radius=0.012, stand=0.05, inset=0.07)
|
| 364 |
lines.append(f' <body name="fridge_door" pos="{f(front + t, yb, hgt / 2 + 0.02)}">')
|
| 365 |
# axis +z: opening turns the free edge (-y, the counter's side) out toward the room (+x); the hinge's
|
| 366 |
# friction holds it where it is left (a brush does not swing it wide)
|
|
|
|
| 729 |
vis("box", "clock_frame", pos=f(-1.72, 2.578, 1.99), size="0.006 0.002 0.05"),
|
| 730 |
vis("box", "clock_frame", pos=f(-1.69, 2.578, 1.95), size="0.04 0.002 0.005"),
|
| 731 |
]
|
| 732 |
+
# pictures: on the back wall between the corner and the wall cabinet (y -2.6 to -1.9: room for one), on
|
| 733 |
+
# the side wall by the trash corner, and over the sofa's end
|
| 734 |
+
g += [vis("box", "picture_frame", pos=f(-2.996, -2.32, 1.62), size=f(0.006, 0.2, 0.16)), vis("box", "canvas_0", pos=f(-2.992, -2.32, 1.62), size=f(0.004, 0.18, 0.14))]
|
| 735 |
+
g += [vis("box", "picture_frame", pos=f(-1.5, -2.596, 1.6), size=f(0.18, 0.006, 0.24)), vis("box", "canvas_1", pos=f(-1.5, -2.592, 1.6), size=f(0.16, 0.004, 0.22))]
|
| 736 |
g += [vis("box", "picture_frame", pos=f(2.596, -1.75, 1.55), size=f(0.006, 0.45, 0.3)), vis("box", "canvas_2", pos=f(2.592, -1.75, 1.55), size=f(0.004, 0.42, 0.27))]
|
| 737 |
static("details_walls", g)
|
| 738 |
# lamps over the dining table
|