@zylem/game-lib 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +3 -3
- package/dist/api/game-lib.api.json +99547 -42343
- package/dist/api/game-lib.api.md +3809 -682
- package/dist/api/game-lib.d.ts +8657 -687
- package/dist/api/game-lib.typedoc.json +325514 -191323
- package/dist/behavior/action/fighting.d.ts +1 -0
- package/dist/behavior/action/fighting.js +1 -0
- package/dist/behavior/action/pinball.d.ts +1 -0
- package/dist/behavior/action/pinball.js +1 -0
- package/dist/behavior/action/platform.d.ts +1 -0
- package/dist/behavior/action/platform.js +1 -0
- package/dist/behavior/action/rhythm.d.ts +1 -0
- package/dist/behavior/action/rhythm.js +1 -0
- package/dist/behavior/action/shooter/first-person.d.ts +1 -0
- package/dist/behavior/action/shooter/first-person.js +1 -0
- package/dist/behavior/action/shooter/shoot-em-up.d.ts +1 -0
- package/dist/behavior/action/shooter/shoot-em-up.js +1 -0
- package/dist/behavior/action/shooter.d.ts +1 -0
- package/dist/behavior/action/shooter.js +1 -0
- package/dist/behavior/action/stealth.d.ts +1 -0
- package/dist/behavior/action/stealth.js +1 -0
- package/dist/behavior/action/survival.d.ts +1 -0
- package/dist/behavior/action/survival.js +1 -0
- package/dist/behavior/action-adventure.d.ts +1 -0
- package/dist/behavior/action-adventure.js +1 -0
- package/dist/behavior/action.d.ts +1 -0
- package/dist/behavior/action.js +1 -0
- package/dist/behavior/genre-map.d.ts +1 -0
- package/dist/behavior/genre-map.js +1 -0
- package/dist/behavior/mechanics.d.ts +1 -0
- package/dist/behavior/mechanics.js +1 -0
- package/dist/behavior/puzzle/physics.d.ts +1 -0
- package/dist/behavior/puzzle/physics.js +1 -0
- package/dist/behavior/puzzle/tile-matching.d.ts +1 -0
- package/dist/behavior/puzzle/tile-matching.js +1 -0
- package/dist/behavior/puzzle.d.ts +1 -0
- package/dist/behavior/puzzle.js +1 -0
- package/dist/behavior/role-playing/action-rpg.d.ts +1 -0
- package/dist/behavior/role-playing/action-rpg.js +1 -0
- package/dist/behavior/role-playing/monster-taming.d.ts +1 -0
- package/dist/behavior/role-playing/monster-taming.js +1 -0
- package/dist/behavior/role-playing/tactical-rpg.d.ts +1 -0
- package/dist/behavior/role-playing/tactical-rpg.js +1 -0
- package/dist/behavior/role-playing/turn-based.d.ts +1 -0
- package/dist/behavior/role-playing/turn-based.js +1 -0
- package/dist/behavior/role-playing.d.ts +1 -0
- package/dist/behavior/role-playing.js +1 -0
- package/dist/behavior/simulation/life.d.ts +1 -0
- package/dist/behavior/simulation/life.js +1 -0
- package/dist/behavior/simulation/vehicle/racing.d.ts +1 -0
- package/dist/behavior/simulation/vehicle/racing.js +1 -0
- package/dist/behavior/simulation/vehicle.d.ts +1 -0
- package/dist/behavior/simulation/vehicle.js +1 -0
- package/dist/behavior/simulation.d.ts +1 -0
- package/dist/behavior/simulation.js +1 -0
- package/dist/behavior/sports/golf.d.ts +1 -0
- package/dist/behavior/sports/golf.js +1 -0
- package/dist/behavior/sports/racing.d.ts +1 -0
- package/dist/behavior/sports/racing.js +1 -0
- package/dist/behavior/sports/racket.d.ts +1 -0
- package/dist/behavior/sports/racket.js +1 -0
- package/dist/behavior/sports/skate.d.ts +1 -0
- package/dist/behavior/sports/skate.js +1 -0
- package/dist/behavior/sports.d.ts +1 -0
- package/dist/behavior/sports.js +1 -0
- package/dist/behavior/strategy/real-time-tactics.d.ts +1 -0
- package/dist/behavior/strategy/real-time-tactics.js +1 -0
- package/dist/behavior/strategy/tower-defense.d.ts +1 -0
- package/dist/behavior/strategy/tower-defense.js +1 -0
- package/dist/behavior/strategy/turn-based-tactics.d.ts +1 -0
- package/dist/behavior/strategy/turn-based-tactics.js +1 -0
- package/dist/behavior/strategy.d.ts +1 -0
- package/dist/behavior/strategy.js +1 -0
- package/dist/behavior.d.ts +34 -0
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/chunk-4DAITCJS.js +1 -0
- package/dist/chunk-63T3K5EQ.js +1 -0
- package/dist/chunk-AJSIVGDX.js +1 -0
- package/dist/{chunk-Y23IJJPD.js → chunk-CVKEWWIH.js} +1 -1
- package/dist/chunk-DYD7MDWO.js +1 -0
- package/dist/chunk-IHGRFR4H.js +1 -0
- package/dist/{chunk-RPMV7GDX.js → chunk-JJEYLGD2.js} +2 -2
- package/dist/chunk-KL7NGD76.js +1 -0
- package/dist/chunk-M2FZ224T.js +1 -0
- package/dist/chunk-MJ7RGE47.js +1 -0
- package/dist/chunk-Q22Z4PBD.js +19 -0
- package/dist/{chunk-KIFB427K.js → chunk-SD7EHS4W.js} +1 -1
- package/dist/chunk-UKNMIHAP.js +1 -0
- package/dist/chunk-Y5IU6IA5.js +1 -0
- package/dist/cinematics.d.ts +7 -5
- package/dist/core.d.ts +11 -9
- package/dist/core.js +1 -1
- package/dist/{debug-state-DhVkY2aM.d.ts → debug-state-BgX5Q0Ff.d.ts} +1 -1
- package/dist/debug.d.ts +6 -125
- package/dist/{entity-DC0P747T.d.ts → entity-CY75JJSw.d.ts} +78 -4
- package/dist/{entity-type-map-B0S5cfv7.d.ts → entity-type-map-BMaPY8cd.d.ts} +2 -2
- package/dist/entity.d.ts +5 -5
- package/dist/entity.js +1 -1
- package/dist/{game-mu6OSCrq.d.ts → game-CmkhPP-9.d.ts} +3 -3
- package/dist/game-default-LAGMEHNQ.js +1 -0
- package/dist/graphics.d.ts +3 -3
- package/dist/graphics.js +1 -1
- package/dist/{material-CxxAyJYp.d.ts → material-D1IVeQc5.d.ts} +48 -2
- package/dist/placement-session-BNQoL7Jb.d.ts +82 -0
- package/dist/placement.d.ts +52 -0
- package/dist/placement.js +1 -0
- package/dist/public.d.ts +11 -8
- package/dist/public.js +1 -1
- package/dist/{stage-B_KdSEK6.d.ts → stage-CCGJh9TD.d.ts} +176 -7
- package/dist/transform-gizmo-DappLQ9w.d.ts +123 -0
- package/dist/web-components.d.ts +9 -7
- package/dist/{zylem-camera-CWhIGXlW.d.ts → zylem-camera-BA3VPFlS.d.ts} +9 -0
- package/package.json +147 -7
- package/dist/chunk-5V52N34T.js +0 -1
- package/dist/chunk-6FGXC4T6.js +0 -19
- package/dist/chunk-FUZDTRCU.js +0 -1
- package/dist/chunk-P6IOYQHU.js +0 -1
- package/dist/chunk-QB3NL7VQ.js +0 -1
- package/dist/chunk-VKWJHFUR.js +0 -1
- package/dist/chunk-VXE3CV3K.js +0 -1
- package/dist/chunk-YRHRMVHS.js +0 -1
- package/dist/game-default-VUMUMTXA.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zylem/game-lib",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A powerful and easy-to-use framework for creating simple 3D digital interactive applications using TypeScript.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,6 +29,142 @@
|
|
|
29
29
|
"types": "./dist/behavior.d.ts",
|
|
30
30
|
"import": "./dist/behavior.js"
|
|
31
31
|
},
|
|
32
|
+
"./behavior/genre-map": {
|
|
33
|
+
"types": "./dist/behavior/genre-map.d.ts",
|
|
34
|
+
"import": "./dist/behavior/genre-map.js"
|
|
35
|
+
},
|
|
36
|
+
"./behavior/mechanics": {
|
|
37
|
+
"types": "./dist/behavior/mechanics.d.ts",
|
|
38
|
+
"import": "./dist/behavior/mechanics.js"
|
|
39
|
+
},
|
|
40
|
+
"./behavior/action": {
|
|
41
|
+
"types": "./dist/behavior/action.d.ts",
|
|
42
|
+
"import": "./dist/behavior/action.js"
|
|
43
|
+
},
|
|
44
|
+
"./behavior/action/platform": {
|
|
45
|
+
"types": "./dist/behavior/action/platform.d.ts",
|
|
46
|
+
"import": "./dist/behavior/action/platform.js"
|
|
47
|
+
},
|
|
48
|
+
"./behavior/action/shooter": {
|
|
49
|
+
"types": "./dist/behavior/action/shooter.d.ts",
|
|
50
|
+
"import": "./dist/behavior/action/shooter.js"
|
|
51
|
+
},
|
|
52
|
+
"./behavior/action/shooter/first-person": {
|
|
53
|
+
"types": "./dist/behavior/action/shooter/first-person.d.ts",
|
|
54
|
+
"import": "./dist/behavior/action/shooter/first-person.js"
|
|
55
|
+
},
|
|
56
|
+
"./behavior/action/shooter/shoot-em-up": {
|
|
57
|
+
"types": "./dist/behavior/action/shooter/shoot-em-up.d.ts",
|
|
58
|
+
"import": "./dist/behavior/action/shooter/shoot-em-up.js"
|
|
59
|
+
},
|
|
60
|
+
"./behavior/action/fighting": {
|
|
61
|
+
"types": "./dist/behavior/action/fighting.d.ts",
|
|
62
|
+
"import": "./dist/behavior/action/fighting.js"
|
|
63
|
+
},
|
|
64
|
+
"./behavior/action/stealth": {
|
|
65
|
+
"types": "./dist/behavior/action/stealth.d.ts",
|
|
66
|
+
"import": "./dist/behavior/action/stealth.js"
|
|
67
|
+
},
|
|
68
|
+
"./behavior/action/survival": {
|
|
69
|
+
"types": "./dist/behavior/action/survival.d.ts",
|
|
70
|
+
"import": "./dist/behavior/action/survival.js"
|
|
71
|
+
},
|
|
72
|
+
"./behavior/action/rhythm": {
|
|
73
|
+
"types": "./dist/behavior/action/rhythm.d.ts",
|
|
74
|
+
"import": "./dist/behavior/action/rhythm.js"
|
|
75
|
+
},
|
|
76
|
+
"./behavior/action/pinball": {
|
|
77
|
+
"types": "./dist/behavior/action/pinball.d.ts",
|
|
78
|
+
"import": "./dist/behavior/action/pinball.js"
|
|
79
|
+
},
|
|
80
|
+
"./behavior/action-adventure": {
|
|
81
|
+
"types": "./dist/behavior/action-adventure.d.ts",
|
|
82
|
+
"import": "./dist/behavior/action-adventure.js"
|
|
83
|
+
},
|
|
84
|
+
"./behavior/puzzle": {
|
|
85
|
+
"types": "./dist/behavior/puzzle.d.ts",
|
|
86
|
+
"import": "./dist/behavior/puzzle.js"
|
|
87
|
+
},
|
|
88
|
+
"./behavior/puzzle/physics": {
|
|
89
|
+
"types": "./dist/behavior/puzzle/physics.d.ts",
|
|
90
|
+
"import": "./dist/behavior/puzzle/physics.js"
|
|
91
|
+
},
|
|
92
|
+
"./behavior/puzzle/tile-matching": {
|
|
93
|
+
"types": "./dist/behavior/puzzle/tile-matching.d.ts",
|
|
94
|
+
"import": "./dist/behavior/puzzle/tile-matching.js"
|
|
95
|
+
},
|
|
96
|
+
"./behavior/role-playing": {
|
|
97
|
+
"types": "./dist/behavior/role-playing.d.ts",
|
|
98
|
+
"import": "./dist/behavior/role-playing.js"
|
|
99
|
+
},
|
|
100
|
+
"./behavior/role-playing/action-rpg": {
|
|
101
|
+
"types": "./dist/behavior/role-playing/action-rpg.d.ts",
|
|
102
|
+
"import": "./dist/behavior/role-playing/action-rpg.js"
|
|
103
|
+
},
|
|
104
|
+
"./behavior/role-playing/turn-based": {
|
|
105
|
+
"types": "./dist/behavior/role-playing/turn-based.d.ts",
|
|
106
|
+
"import": "./dist/behavior/role-playing/turn-based.js"
|
|
107
|
+
},
|
|
108
|
+
"./behavior/role-playing/monster-taming": {
|
|
109
|
+
"types": "./dist/behavior/role-playing/monster-taming.d.ts",
|
|
110
|
+
"import": "./dist/behavior/role-playing/monster-taming.js"
|
|
111
|
+
},
|
|
112
|
+
"./behavior/role-playing/tactical-rpg": {
|
|
113
|
+
"types": "./dist/behavior/role-playing/tactical-rpg.d.ts",
|
|
114
|
+
"import": "./dist/behavior/role-playing/tactical-rpg.js"
|
|
115
|
+
},
|
|
116
|
+
"./behavior/simulation": {
|
|
117
|
+
"types": "./dist/behavior/simulation.d.ts",
|
|
118
|
+
"import": "./dist/behavior/simulation.js"
|
|
119
|
+
},
|
|
120
|
+
"./behavior/simulation/life": {
|
|
121
|
+
"types": "./dist/behavior/simulation/life.d.ts",
|
|
122
|
+
"import": "./dist/behavior/simulation/life.js"
|
|
123
|
+
},
|
|
124
|
+
"./behavior/simulation/vehicle": {
|
|
125
|
+
"types": "./dist/behavior/simulation/vehicle.d.ts",
|
|
126
|
+
"import": "./dist/behavior/simulation/vehicle.js"
|
|
127
|
+
},
|
|
128
|
+
"./behavior/simulation/vehicle/racing": {
|
|
129
|
+
"types": "./dist/behavior/simulation/vehicle/racing.d.ts",
|
|
130
|
+
"import": "./dist/behavior/simulation/vehicle/racing.js"
|
|
131
|
+
},
|
|
132
|
+
"./behavior/strategy": {
|
|
133
|
+
"types": "./dist/behavior/strategy.d.ts",
|
|
134
|
+
"import": "./dist/behavior/strategy.js"
|
|
135
|
+
},
|
|
136
|
+
"./behavior/strategy/real-time-tactics": {
|
|
137
|
+
"types": "./dist/behavior/strategy/real-time-tactics.d.ts",
|
|
138
|
+
"import": "./dist/behavior/strategy/real-time-tactics.js"
|
|
139
|
+
},
|
|
140
|
+
"./behavior/strategy/tower-defense": {
|
|
141
|
+
"types": "./dist/behavior/strategy/tower-defense.d.ts",
|
|
142
|
+
"import": "./dist/behavior/strategy/tower-defense.js"
|
|
143
|
+
},
|
|
144
|
+
"./behavior/strategy/turn-based-tactics": {
|
|
145
|
+
"types": "./dist/behavior/strategy/turn-based-tactics.d.ts",
|
|
146
|
+
"import": "./dist/behavior/strategy/turn-based-tactics.js"
|
|
147
|
+
},
|
|
148
|
+
"./behavior/sports": {
|
|
149
|
+
"types": "./dist/behavior/sports.d.ts",
|
|
150
|
+
"import": "./dist/behavior/sports.js"
|
|
151
|
+
},
|
|
152
|
+
"./behavior/sports/racing": {
|
|
153
|
+
"types": "./dist/behavior/sports/racing.d.ts",
|
|
154
|
+
"import": "./dist/behavior/sports/racing.js"
|
|
155
|
+
},
|
|
156
|
+
"./behavior/sports/skate": {
|
|
157
|
+
"types": "./dist/behavior/sports/skate.d.ts",
|
|
158
|
+
"import": "./dist/behavior/sports/skate.js"
|
|
159
|
+
},
|
|
160
|
+
"./behavior/sports/golf": {
|
|
161
|
+
"types": "./dist/behavior/sports/golf.d.ts",
|
|
162
|
+
"import": "./dist/behavior/sports/golf.js"
|
|
163
|
+
},
|
|
164
|
+
"./behavior/sports/racket": {
|
|
165
|
+
"types": "./dist/behavior/sports/racket.d.ts",
|
|
166
|
+
"import": "./dist/behavior/sports/racket.js"
|
|
167
|
+
},
|
|
32
168
|
"./audio": {
|
|
33
169
|
"types": "./dist/audio.d.ts",
|
|
34
170
|
"import": "./dist/audio.js"
|
|
@@ -53,6 +189,10 @@
|
|
|
53
189
|
"types": "./dist/input-ui.d.ts",
|
|
54
190
|
"import": "./dist/input-ui.js"
|
|
55
191
|
},
|
|
192
|
+
"./placement": {
|
|
193
|
+
"types": "./dist/placement.d.ts",
|
|
194
|
+
"import": "./dist/placement.js"
|
|
195
|
+
},
|
|
56
196
|
"./graphics": {
|
|
57
197
|
"types": "./dist/graphics.d.ts",
|
|
58
198
|
"import": "./dist/graphics.js"
|
|
@@ -115,15 +255,15 @@
|
|
|
115
255
|
"@dgreenheck/three-pinata": "^2.0.1",
|
|
116
256
|
"@sinclair/typebox": "^0.34.52",
|
|
117
257
|
"@types/howler": "^2.2.13",
|
|
118
|
-
"@zylem/behaviors": "^0.8.
|
|
119
|
-
"@zylem/bridge": "^0.9.
|
|
258
|
+
"@zylem/behaviors": "^0.8.12",
|
|
259
|
+
"@zylem/bridge": "^0.9.7",
|
|
120
260
|
"comlink": "^4.4.2",
|
|
121
261
|
"howler": "^2.2.4",
|
|
122
262
|
"idb-keyval": "^6.2.6",
|
|
123
263
|
"msgpackr": "^1.11.14",
|
|
124
264
|
"nanoid": "^5.1.16",
|
|
125
265
|
"stats.js": "^0.17.0",
|
|
126
|
-
"three": "^0.
|
|
266
|
+
"three": "^0.187.0",
|
|
127
267
|
"tone": "^15.1.23",
|
|
128
268
|
"typescript-fsm": "^1.6.0",
|
|
129
269
|
"valtio": "^2.1.8"
|
|
@@ -131,14 +271,14 @@
|
|
|
131
271
|
"peerDependencies": {
|
|
132
272
|
"howler": "^2.2.4",
|
|
133
273
|
"nanoid": "^5.1.5",
|
|
134
|
-
"three": "^0.
|
|
274
|
+
"three": "^0.187.0",
|
|
135
275
|
"valtio": "^2.1.7"
|
|
136
276
|
},
|
|
137
277
|
"devDependencies": {
|
|
138
278
|
"@microsoft/api-extractor": "^7.58.13",
|
|
139
279
|
"@types/node": "^20.19.43",
|
|
140
280
|
"@types/stats.js": "^0.17.4",
|
|
141
|
-
"@types/three": "^0.
|
|
281
|
+
"@types/three": "^0.187.0",
|
|
142
282
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
143
283
|
"happy-dom": "^18.0.1",
|
|
144
284
|
"jsdom": "^27.2.0",
|
|
@@ -150,7 +290,7 @@
|
|
|
150
290
|
"vitest": "^4.0.18"
|
|
151
291
|
},
|
|
152
292
|
"scripts": {
|
|
153
|
-
"build": "tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
|
|
293
|
+
"build": "node --experimental-strip-types ../../../simulation/packages/behaviors/scripts/sync-genre-entries.ts && NODE_OPTIONS=--max-old-space-size=8192 tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
|
|
154
294
|
"dev": "tsup --watch",
|
|
155
295
|
"api:extract": "mkdir -p dist/api temp && api-extractor run --local --verbose",
|
|
156
296
|
"api:typedoc": "mkdir -p dist/api && typedoc --options typedoc.json",
|
package/dist/chunk-5V52N34T.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as G,c as xt,d as Ot,e as St,f as wt,g as vt,h as Ct,r as p,s as f,t as c,v as b,w as V,x as A,y as M,z as R}from"./chunk-VXE3CV3K.js";import{j as bt}from"./chunk-6FGXC4T6.js";import{a as yt,b as Y,c as gt,d as ft,g as U,h as j,i as z}from"./chunk-7WRQ2UAN.js";import{BoxGeometry as Qt,CapsuleGeometry as te,ConeGeometry as Pt,CylinderGeometry as ee,Mesh as _,MeshStandardMaterial as ie,SphereGeometry as oe}from"three";function D(e,t=Symbol("mesh")){if(e.material||e.color){let i=new bt;if(i.build({...e.material,color:e.color??e.material?.color},t),i.materials.length>0)return i.materials}return[new ie]}function Z(e,t){if(t.position){let i=j(t.position,gt);e.position.set(i.x,i.y,i.z)}return e.castShadow=!0,e.receiveShadow=!0,e}function Mt(e={}){let t=j(e.size,ft),i=new Qt(t.x,t.y,t.z),o=D(e);return Z(new _(i,o.at(-1)),e)}function Rt(e={}){let t=new oe(e.radius??1),i=D(e);return Z(new _(t,i.at(-1)),e)}function _t(e={}){let t=new Pt(e.radius??1,e.height??2,e.radialSegments??32),i=D(e);return Z(new _(t,i.at(-1)),e)}function Dt(e={}){let t=new Pt(e.radius??1,e.height??2,4),i=D(e);return Z(new _(t,i.at(-1)),e)}function Zt(e={}){let t=new ee(e.radiusTop??1,e.radiusBottom??1,e.height??2,e.radialSegments??32),i=D(e);return Z(new _(t,i.at(-1)),e)}function Tt(e={}){let t=new te(e.radius??.5,e.length??1,e.capSegments??10,e.radialSegments??20),i=D(e);return Z(new _(t,i.at(-1)),e)}import{Vector3 as le}from"three";import{MeshStandardMaterial as ne,MeshBasicMaterial as se,MeshPhongMaterial as re}from"three";function ae(e){return e&&typeof e.getDebugInfo=="function"}var m=class{entity;constructor(t){this.entity=t}getPositionString(){if(this.entity.mesh){let{x:n,y:s,z:l}=this.entity.mesh.position;return`${n.toFixed(2)}, ${s.toFixed(2)}, ${l.toFixed(2)}`}let{x:t,y:i,z:o}=this.entity.options.position||{x:0,y:0,z:0};return`${t.toFixed(2)}, ${i.toFixed(2)}, ${o.toFixed(2)}`}getRotationString(){if(this.entity.mesh){let{x:s,y:l,z:r}=this.entity.mesh.rotation,a=u=>(u*180/Math.PI).toFixed(1);return`${a(s)}\xB0, ${a(l)}\xB0, ${a(r)}\xB0`}let{x:t,y:i,z:o}=this.entity.options.rotation||{x:0,y:0,z:0},n=s=>(s*180/Math.PI).toFixed(1);return`${n(t)}\xB0, ${n(i)}\xB0, ${n(o)}\xB0`}getMaterialInfo(){if(!this.entity.mesh||!this.entity.mesh.material)return{type:"none"};let t=Array.isArray(this.entity.mesh.material)?this.entity.mesh.material[0]:this.entity.mesh.material,i={type:t.type};return(t instanceof ne||t instanceof se||t instanceof re)&&(i.color=`#${t.color.getHexString()}`,i.opacity=t.opacity,i.transparent=t.transparent),"roughness"in t&&(i.roughness=t.roughness),"metalness"in t&&(i.metalness=t.metalness),i}getPhysicsInfo(){if(!this.entity.body)return null;let t={type:this.entity.body.bodyType(),mass:this.entity.body.mass(),isEnabled:this.entity.body.isEnabled(),isSleeping:this.entity.body.isSleeping()},i=this.entity.body.linvel();return t.velocity=`${i.x.toFixed(2)}, ${i.y.toFixed(2)}, ${i.z.toFixed(2)}`,t}buildDebugInfo(){let t={name:this.entity.name||this.entity.uuid,uuid:this.entity.uuid,position:this.getPositionString(),rotation:this.getRotationString(),material:this.getMaterialInfo()},i=this.getPhysicsInfo();if(i&&(t.physics=i),ae(this.entity)){let o=this.entity.getDebugInfo();return{...t,...o}}return t}};var Et={...p,size:new le(1,1,1)},ce=Symbol("Box"),q=class e extends c{static type=ce;constructor(t){super(),this.options={...Et,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),{x:o,y:n,z:s}=this.options.size??{x:1,y:1,z:1};return{...i,type:String(e.type),size:`${o}, ${n}, ${s}`}}};function he(...e){let t=f(e,Et),i=new q(t);return i.add(Mt({size:t.size,material:t.material,color:t.color}),xt({size:t.size,static:t.collision?.static,sensor:t.collision?.sensor,canSleep:t.collision?.canSleep,ccdEnabled:t.collision?.ccdEnabled,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>he(o??{}))}var zt={...p,radius:1},me=Symbol("Sphere"),J=class e extends c{static type=me;constructor(t){super(),this.options={...zt,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.radius??1;return{...i,type:String(e.type),radius:o.toFixed(2)}}};function pe(...e){let t=f(e,zt),i=new J(t);return i.add(Rt({radius:t.radius,material:t.material,color:t.color}),Ot({radius:t.radius,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>pe(o??{}))}var It={...p,radius:1,height:2,radialSegments:32},ue=Symbol("Cone"),K=class e extends c{static type=ue;constructor(t){super(),this.options={...It,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...i,type:String(e.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function de(...e){let t=f(e,It),i=new K(t);return i.add(_t({radius:t.radius,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),St({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>de(o??{}))}var Bt={...p,radius:1,height:2},ye=Symbol("Pyramid"),Q=class e extends c{static type=ye;constructor(t){super(),this.options={...Bt,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...i,type:String(e.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function ge(...e){let t=f(e,Bt),i=new Q(t);return i.add(Dt({radius:t.radius,height:t.height,material:t.material,color:t.color}),wt({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>ge(o??{}))}var Lt={...p,radiusTop:1,radiusBottom:1,height:2,radialSegments:32},fe=Symbol("Cylinder"),tt=class e extends c{static type=fe;constructor(t){super(),this.options={...Lt,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.radiusTop??1,n=this.options.radiusBottom??1,s=this.options.height??2;return{...i,type:String(e.type),radiusTop:o.toFixed(2),radiusBottom:n.toFixed(2),height:s.toFixed(2)}}};function be(...e){let t=f(e,Lt),i=new tt(t);return i.add(Zt({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),vt({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>be(o??{}))}var kt={...p,radius:.5,length:1,capSegments:10,radialSegments:20},xe=Symbol("Pill"),et=class e extends c{static type=xe;constructor(t){super(),this.options={...kt,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.radius??.5,n=this.options.length??1;return{...i,type:String(e.type),radius:o.toFixed(2),length:n.toFixed(2)}}};function Oe(...e){let t=f(e,kt),i=new et(t);return i.add(Tt({radius:t.radius,length:t.length,capSegments:t.capSegments,radialSegments:t.radialSegments,material:t.material,color:t.color}),Ct({radius:t.radius,length:t.length,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),b(i,o=>Oe(o??{}))}import{Group as Se,RingGeometry as we}from"three";var Ft={...p,innerRadius:0,outerRadius:1,thetaSegments:32},it=class extends V{collider(t){let i=t.outerRadius??1;return{shape:{type:"cylinder",halfHeight:.1/2,radius:i}}}},ot=class extends A{build(t){let i=t.innerRadius??0,o=t.outerRadius??1,n=t.thetaSegments??32,s=new we(i,o,n);return s.rotateX(-Math.PI/2),s}},nt=class extends M{createEntity(t){return new I(t)}build(){let t=super.build();return t.mesh&&!t.group&&(t.group=new Se,t.group.add(t.mesh)),t}},ve=Symbol("Disk"),I=class e extends c{static type=ve;constructor(t){super(),this.options={...Ft,...t}}buildInfo(){let i=new m(this).buildDebugInfo(),o=this.options.innerRadius??0,n=this.options.outerRadius??1;return{...i,type:String(e.type),innerRadius:o.toFixed(2),outerRadius:n.toFixed(2)}}};function Ce(...e){return R({args:e,defaultConfig:Ft,EntityClass:I,BuilderClass:nt,MeshBuilderClass:ot,CollisionBuilderClass:it,entityType:I.type,cloneFactory:t=>Ce(t??{})})}import{PlaneGeometry as Me,Vector2 as Gt,Vector3 as Vt}from"three";import{BufferGeometry as Pe,Float32BufferAttribute as st}from"three";var H=class e extends Pe{constructor(t=1,i=1,o=1,n=1){super(),this.type="XZPlaneGeometry",this.parameters={width:t,height:i,widthSegments:o,heightSegments:n};let s=t/2,l=i/2,r=Math.floor(o),a=Math.floor(n),u=r+1,v=a+1,w=t/r,g=i/a,d=[],x=[],O=[],T=[];for(let y=0;y<v;y++){let h=y*g-l;for(let S=0;S<u;S++){let P=S*w-s;x.push(P,0,h),O.push(0,1,0),T.push(S/r),T.push(1-y/a)}}for(let y=0;y<a;y++)for(let h=0;h<r;h++){let S=h+u*y,P=h+u*(y+1),E=h+1+u*(y+1),C=h+1+u*y;d.push(S,P,C),d.push(P,E,C)}this.setIndex(d),this.setAttribute("position",new st(x,3)),this.setAttribute("normal",new st(O,3)),this.setAttribute("uv",new st(T,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}};var N=4,At={...p,tile:new Gt(10,10),repeat:new Gt(1,1),collision:{static:!0},subdivisions:N,randomizeHeight:!1,heightScale:1};function Ht(e){let t=e.subdivisions??N,i=e.heightMap2D,o=e.heightMap,n=e.subdivisionsX??t,s=e.subdivisionsZ??t;return i&&i.length>0&&i[0]?.length>0?(s=i.length-1,n=i[0].length-1):o&&o.length>0&&(n=o.length-1),{subdivisionsX:n,subdivisionsZ:s}}var rt=class extends V{collider(t){let i=z(t.tile,Y),{subdivisionsX:o,subdivisionsZ:n}=Ht(t),s=new Vt(i.x,1,i.y),l=t._builders?.meshBuilder?.heightData??new Float32Array((o+1)*(n+1));return{shape:{type:"heightfield",rows:o,cols:n,heights:l,scale:[s.x,1,s.z]}}}},at=class extends A{heightData=new Float32Array;columnsRows=new Map;subdivisionsX=N;subdivisionsZ=N;build(t){let i=z(t.tile,Y),{subdivisionsX:o,subdivisionsZ:n}=Ht(t);this.subdivisionsX=o,this.subdivisionsZ=n;let s=new Vt(i.x,1,i.y),l=t.heightScale??1,r=new H(s.x,s.z,o,n),a=new Me(s.x,s.z,o,n),u=o>0?s.x/o:1,v=n>0?s.z/n:1,w=r.attributes.position.array,g=a.attributes.position.array,d=new Map,x=t.heightMap2D,O=t.heightMap,T=t.randomizeHeight??!1,y=(h,S)=>h<0?0:h>S?S:h;for(let h=0;h<g.length;h+=3){let S=g[h],P=g[h+1],E=y(Math.round((S+s.x/2)/u),o),C=y(Math.round((s.z/2-P)/v),n),F=0;if(x){let dt=x[C];dt&&(F=dt[E]??0)}else O&&O.length>0?F=O[E]??0:T&&(F=Math.random()*4);let X=F*l;g[h+2]=X,w[h+1]=X,d.get(C)||d.set(C,new Map),d.get(C).set(E,X)}return this.columnsRows=d,r}postBuild(){let t=[];for(let i=0;i<=this.subdivisionsX;++i)for(let o=0;o<=this.subdivisionsZ;++o){let n=this.columnsRows.get(o);t.push(n?.get(i)??0)}this.heightData=new Float32Array(t)}},lt=class extends M{createEntity(t){return new B(t)}},Re=Symbol("Plane"),B=class extends c{static type=Re;constructor(t){super(),this.options=G(At,t)}};function _e(...e){return R({args:e,defaultConfig:At,EntityClass:B,BuilderClass:lt,MeshBuilderClass:at,CollisionBuilderClass:rt,entityType:B.type,cloneFactory:t=>_e(t??{})})}import{Color as Xt,Group as Ze,Sprite as Te,SpriteMaterial as Ee,CanvasTexture as Yt,LinearFilter as $,Vector2 as mt,ClampToEdgeWrapping as Ut,ShaderMaterial as jt,Mesh as ze,PlaneGeometry as Ie,Vector3 as qt}from"three";var Nt={"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},center:{x:.5,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1}};function ct(e){return Nt[e]??Nt["top-left"]}function $t(e,t,i){let o=ct(e);return{x:o.x*i.width+t.x,y:o.y*i.height+t.y}}function ht(e){return{width:Math.max(1,e?.screenResolution?.x??1),height:Math.max(1,e?.screenResolution?.y??1)}}function De(e,t){let i=e.zoom||1;if(e.isPerspectiveCamera){let o=e,n=Math.tan(o.fov*Math.PI/180/2)*t/i;return{halfWidth:n*o.aspect,halfHeight:n}}if(e.isOrthographicCamera){let o=e;return{halfWidth:(o.right-o.left)/2/i,halfHeight:(o.top-o.bottom)/2/i}}return{halfWidth:1,halfHeight:1}}function Wt(e){let t=Math.max(.001,e.zDistance),{halfWidth:i,halfHeight:o}=De(e.camera,t),n=o*2/e.viewport.height,s=Math.max(1e-4,e.size.width*n),l=Math.max(1e-4,e.size.height*n),r=e.point.x/e.viewport.width*2-1,a=1-e.point.y/e.viewport.height*2;return{position:{x:r*i+(.5-e.pivot.x)*s,y:a*o+(e.pivot.y-.5)*l,z:-t},scale:{x:s,y:l}}}var W={position:void 0,width:120,height:48,fillColor:"#FFFFFF",strokeColor:null,strokeWidth:0,radius:0,padding:0,shape:"rect",image:null,stickToViewport:!0,screenPosition:new mt(24,24),zDistance:1},pt=class extends M{createEntity(t){return new L(t)}},Be=Symbol("Rect"),L=class e extends c{static type=Be;_sprite=null;_mesh=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_lastCanvasW=0;_lastCanvasH=0;_image=null;_imageSource=null;constructor(t){super(),this.options=G(W,t),this.options.screenPosition=z(this.options.screenPosition,W.screenPosition),this.group=new Ze,this.createSprite(),this.prependSetup(this.rectSetup.bind(this)),this.prependUpdate(this.rectUpdate.bind(this))}createSprite(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._texture=new Yt(this._canvas),this._texture.minFilter=$,this._texture.magFilter=$;let t=new Ee({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.01});this._sprite=new Te(t),this.group?.add(this._sprite),this.loadImage(),this.redrawRect()}loadImage(){let t=this.options.image||null;if(t===this._imageSource||(this._imageSource=t,this._image=null,!t))return;let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this._imageSource===t&&(this._image=i,this.redrawRect())},i.src=t}redrawRect(){if(!this._canvas||!this._ctx)return;let t=Math.max(2,Math.floor(this.options.width??120)),i=Math.max(2,Math.floor(this.options.height??48)),o=this.options.padding??0,n=this.options.strokeWidth??0,s=t+o*2+n,l=i+o*2+n,r=Math.max(2,s),a=Math.max(2,l),u=r!==this._lastCanvasW||a!==this._lastCanvasH;this._canvas.width=r,this._canvas.height=a,this._lastCanvasW=r,this._lastCanvasH=a,this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height);let v=Math.max(0,this.options.radius??0),w=Math.floor(o+n/2),g=Math.floor(o+n/2),d=Math.floor(t),x=Math.floor(i);if(this._ctx.beginPath(),this.options.shape==="ellipse"?this._ctx.ellipse(w+d/2,g+x/2,d/2,x/2,0,0,Math.PI*2):v>0?this.roundedRectPath(this._ctx,w,g,d,x,v):this._ctx.rect(w,g,d,x),this.options.fillColor&&(this._ctx.fillStyle=this.toCssColor(this.options.fillColor),this._ctx.fill()),this._image&&(this._ctx.save(),this._ctx.clip(),this._ctx.drawImage(this._image,w,g,d,x),this._ctx.restore()),this.options.strokeColor&&n>0&&(this._ctx.lineWidth=n,this._ctx.strokeStyle=this.toCssColor(this.options.strokeColor),this._ctx.stroke()),this._texture){if(u&&(this._texture.dispose(),this._texture=new Yt(this._canvas),this._texture.minFilter=$,this._texture.magFilter=$,this._texture.wrapS=Ut,this._texture.wrapT=Ut,this._sprite&&this._sprite.material instanceof jt)){let O=this._sprite.material;O.uniforms?.tDiffuse&&(O.uniforms.tDiffuse.value=this._texture),O.uniforms?.iResolution&&O.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)}this._texture.image=this._canvas,this._texture.needsUpdate=!0,this._sprite&&this._sprite.material&&(this._sprite.material.map=this._texture,this._sprite.material.needsUpdate=!0)}}getWidth(){return this.options.width??0}getHeight(){return this.options.height??0}roundedRectPath(t,i,o,n,s,l){let r=Math.min(l,Math.floor(Math.min(n,s)/2));t.moveTo(i+r,o),t.lineTo(i+n-r,o),t.quadraticCurveTo(i+n,o,i+n,o+r),t.lineTo(i+n,o+s-r),t.quadraticCurveTo(i+n,o+s,i+n-r,o+s),t.lineTo(i+r,o+s),t.quadraticCurveTo(i,o+s,i,o+s-r),t.lineTo(i,o+r),t.quadraticCurveTo(i,o,i+r,o)}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof Xt?t:new Xt(t)).getHexString()}`}rectSetup(t){if(this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&this._cameraRef.camera.add(this.group),this.materials?.length&&this._sprite){let i=this.materials[0];i instanceof jt&&(i.transparent=!0,i.depthTest=!1,i.depthWrite=!1,this._texture&&(i.uniforms?.tDiffuse&&(i.uniforms.tDiffuse.value=this._texture),i.uniforms?.iResolution&&this._canvas&&i.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)),this._mesh=new ze(new Ie(1,1),i),this.group?.add(this._mesh),this._sprite.visible=!1)}}rectUpdate(t){if(this._sprite){if(this._cameraRef&&this.options.bounds){let i=this.computeScreenBoundsFromOptions(this.options.bounds);if(i){let{x:o,y:n,width:s,height:l}=i,r=Math.max(2,Math.floor(s)),a=Math.max(2,Math.floor(l)),u=r!==(this.options.width??0)||a!==(this.options.height??0);this.options.screenPosition=new mt(Math.floor(o),Math.floor(n)),this.options.width=r,this.options.height=a,this.options.anchor=new mt(0,0),u&&this.redrawRect()}}this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}}screenPoint(t){let i=U(this.options.screenPosition,W.screenPosition);return this.options.screenAnchor&&!this.options.bounds?$t(this.options.screenAnchor,i,t):i}pivot(){if(this.options.anchor!=null){let t=U(this.options.anchor,yt);return{x:Math.min(100,Math.max(0,t.x))/100,y:Math.min(100,Math.max(0,t.y))/100}}return this.options.screenAnchor?ct(this.options.screenAnchor):{x:0,y:0}}updateStickyTransform(){if(!this._sprite||!this._cameraRef||!this._canvas)return;let t=ht(this._cameraRef),i=Wt({camera:this._cameraRef.camera,viewport:t,point:this.screenPoint(t),pivot:this.pivot(),size:{width:this._canvas.width,height:this._canvas.height},zDistance:this.options.zDistance??1});this._sprite.scale.set(i.scale.x,i.scale.y,1),this._mesh&&this._mesh.scale.set(i.scale.x,i.scale.y,1),this.group?.position.set(i.position.x,i.position.y,i.position.z)}worldToScreen(t){if(!this._cameraRef)return{x:0,y:0};let i=this._cameraRef.camera,{width:o,height:n}=ht(this._cameraRef),s=t.clone().project(i),l=(s.x+1)/2*o,r=(1-s.y)/2*n;return{x:l,y:r}}computeScreenBoundsFromOptions(t){if(!this._cameraRef)return null;if(t.screen)return{...t.screen};if(t.world){let{left:i,right:o,top:n,bottom:s,z:l=0}=t.world,r=this.worldToScreen(new qt(i,n,l)),a=this.worldToScreen(new qt(o,s,l)),u=Math.min(r.x,a.x),v=Math.min(r.y,a.y),w=Math.abs(a.x-r.x),g=Math.abs(a.y-r.y);return{x:u,y:v,width:w,height:g}}return null}updateRect(t){this.options={...this.options,...t},this.loadImage(),this.redrawRect(),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}buildInfo(){return{...new m(this).buildDebugInfo(),type:String(e.type),width:this.options.width??0,height:this.options.height??0,shape:this.options.shape??"rect",sticky:this.options.stickToViewport}}};function Le(...e){return R({args:e,defaultConfig:{...W},EntityClass:L,BuilderClass:pt,entityType:L.type,cloneFactory:t=>Le(t??{})})}import{AmbientLight as ke,DirectionalLight as Fe,Group as Ge,HemisphereLight as Ve,Object3D as Ae,PointLight as He,SpotLight as Ne}from"three";var $e=Symbol("Light"),We={x:0,y:0,z:0},k=16777215,Xe={mapSize:2048,near:.1,far:500,bias:0,radius:1,left:-100,right:100,top:100,bottom:-100},Ye={mapSize:1024,near:.1,far:500,bias:0,radius:1},ut=class extends c{static type=$e;light=null;lightTarget=null;constructor(t){super(),this.options={...t}}create(){super.create();let t=new Ge,{light:i,target:o}=Ue(this.options);return t.add(i),o&&t.add(o),this.group=t,this.light=i,this.lightTarget=o,this}_cleanup(t){this.light?.shadow?.map?.dispose?.(),this.light=null,this.lightTarget=null,super._cleanup(t)}};function Ue(e){switch(e.type){case"ambient":return{light:je(e),target:null};case"hemisphere":return{light:qe(e),target:null};case"directional":return Je(e);case"point":return{light:Ke(e),target:null};case"spot":return Qe(e)}}function je(e){let t=new ke(e.color??k,e.intensity??1);return e.name&&(t.name=e.name),t}function qe(e){let t=e.skyColor??e.color??k,i=e.groundColor??0,o=new Ve(t,i,e.intensity??1);return e.name&&(o.name=e.name),o}function Je(e){let t=new Fe(e.color??k,e.intensity??1);e.name&&(t.name=e.name),ti(t,e.castShadow??!1,e.shadow);let i=Jt(e.position,e.target);return i&&(t.target=i),{light:t,target:i}}function Ke(e){let t=new He(e.color??k,e.intensity??1,e.distance,e.decay);return e.name&&(t.name=e.name),Kt(t,e.castShadow??!1,e.shadow),t}function Qe(e){let t=new Ne(e.color??k,e.intensity??1,e.distance,e.angle,e.penumbra,e.decay);e.name&&(t.name=e.name),Kt(t,e.castShadow??!1,e.shadow);let i=Jt(e.position,e.target);return i&&(t.target=i),{light:t,target:i}}function Jt(e,t){if(!t)return null;let i=e??We,o=new Ae;return o.position.set(t.x-i.x,t.y-i.y,t.z-i.z),o}function ti(e,t,i){if(!t){e.castShadow=!1;return}e.castShadow=!0;let o={...Xe,...i??{}};e.shadow.mapSize.set(o.mapSize,o.mapSize),e.shadow.camera.near=o.near,e.shadow.camera.far=o.far,e.shadow.camera.left=o.left,e.shadow.camera.right=o.right,e.shadow.camera.top=o.top,e.shadow.camera.bottom=o.bottom,e.shadow.bias=o.bias,e.shadow.radius=o.radius,e.shadow.camera.updateProjectionMatrix()}function Kt(e,t,i){if(!t){e.castShadow=!1;return}e.castShadow=!0;let o={...Ye,...i??{}};e.shadow.mapSize.set(o.mapSize,o.mapSize),e.shadow.camera.near=o.near,e.shadow.camera.far=o.far,e.shadow.bias=o.bias,e.shadow.radius=o.radius,e.shadow.camera.updateProjectionMatrix()}function Fo(e){return new ut(e)}export{m as a,Mt as b,Rt as c,_t as d,Dt as e,Zt as f,Tt as g,ce as h,q as i,he as j,me as k,J as l,pe as m,ue as n,K as o,de as p,ye as q,Q as r,ge as s,fe as t,tt as u,be as v,xe as w,et as x,Oe as y,ve as z,I as A,Ce as B,Re as C,B as D,_e as E,ct as F,$t as G,ht as H,Wt as I,Be as J,L as K,Le as L,$e as M,ut as N,Fo as O};
|
package/dist/chunk-6FGXC4T6.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{a as R}from"./chunk-QXVH6POE.js";import{b as p,i as h}from"./chunk-7WRQ2UAN.js";var C=`
|
|
2
|
-
uniform vec2 uvScale;
|
|
3
|
-
varying vec2 vUv;
|
|
4
|
-
|
|
5
|
-
void main() {
|
|
6
|
-
vUv = uv;
|
|
7
|
-
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
8
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
9
|
-
}
|
|
10
|
-
`;var D=`
|
|
11
|
-
uniform sampler2D tDiffuse;
|
|
12
|
-
varying vec2 vUv;
|
|
13
|
-
|
|
14
|
-
void main() {
|
|
15
|
-
vec4 texel = texture2D( tDiffuse, vUv );
|
|
16
|
-
|
|
17
|
-
gl_FragColor = texel;
|
|
18
|
-
}
|
|
19
|
-
`,O={vertex:C,fragment:D};import{Color as F,RepeatWrapping as v,SRGBColorSpace as te}from"three";import{MeshBasicNodeMaterial as re,MeshStandardNodeMaterial as P}from"three/webgpu";function G(s){let e=Object.keys(s).sort().reduce((t,r)=>(t[r]=s[r],t),{});return JSON.stringify(e)}function E(s){let e=0;for(let t=0;t<s.length;t++)e=Math.imul(31,e)+s.charCodeAt(t)|0;return e.toString(36)}import{LoadingManager as ee,Cache as k}from"three";import{TextureLoader as X,RepeatWrapping as B}from"three";var b=16,L=class{loader;constructor(){this.loader=new X}isSupported(e){let t=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","bmp","tga"].includes(t||"")}async load(e,t){let r=await this.loader.loadAsync(e,a=>{t?.onProgress&&a.lengthComputable&&t.onProgress(a.loaded/a.total)});return t?.repeat&&r.repeat.copy(h(t.repeat,p)),r.wrapS=t?.wrapS??B,r.wrapT=t?.wrapT??B,t?.colorSpace!==void 0&&(r.colorSpace=t.colorSpace),r.anisotropy=t?.anisotropy??b,r}clone(e){let t=e.clone();return t.anisotropy=e.anisotropy||b,t.needsUpdate=!0,t}};import{GLTFLoader as J}from"three/addons/loaders/GLTFLoader.js";import{DRACOLoader as K}from"three/addons/loaders/DRACOLoader.js";import{KTX2Loader as Z}from"three/addons/loaders/KTX2Loader.js";import{MeshoptDecoder as $}from"three/addons/libs/meshopt_decoder.module.js";import{Mesh as j}from"three";import{clone as W}from"three/addons/utils/SkeletonUtils.js";function u(s){let e=W(s),t=[],r=[];s.traverse(a=>t.push(a)),e.traverse(a=>r.push(a));for(let a=0;a<t.length;a++){let o=t[a],n=r[a];!(o instanceof j)||!(n instanceof j)||(o.geometry?.clone&&(n.geometry=o.geometry.clone()),o.material&&(n.material=Array.isArray(o.material)?o.material.map(i=>i.clone()):o.material.clone()))}return e}function I(s){let e=s.indexOf("?"),t=s.indexOf("#"),r=[e,t].filter(a=>a>=0).reduce((a,o)=>Math.min(a,o),s.length);return s.slice(0,r)}function c(s){let e=I(s),t=e.lastIndexOf("/"),r=t>=0?e.slice(t+1):e,a=r.lastIndexOf(".");return a<0||a===r.length-1?null:r.slice(a+1).toLowerCase()}var V=["map","normalMap","roughnessMap","metalnessMap","emissiveMap","aoMap"],H="https://www.gstatic.com/draco/v1/decoders/",g=class{loader;dracoLoader;ktx2Loader=null;meshoptEnabled=!1;configuredRenderer=null;ktx2TranscoderPath=null;constructor(){this.dracoLoader=new K,this.dracoLoader.setDecoderPath(H),this.loader=new J,this.loader.setDRACOLoader(this.dracoLoader),this.setMeshoptEnabled(!0)}isSupported(e){let t=c(e);return["gltf","glb"].includes(t||"")}async configureRuntime({meshopt:e=!0,ktx2TranscoderPath:t,renderer:r=null}={}){this.setMeshoptEnabled(e!==!1);let a=this.normalizeTranscoderPath(t);if(!a){this.clearKTX2Loader();return}if(!r)throw new Error("GLTFLoaderAdapter.configureRuntime requires a renderer when ktx2TranscoderPath is provided.");(!this.ktx2Loader||this.ktx2TranscoderPath!==a)&&(this.clearKTX2Loader(),this.ktx2Loader=new Z,this.ktx2Loader.setTranscoderPath(a),this.loader.setKTX2Loader(this.ktx2Loader),this.ktx2TranscoderPath=a,this.configuredRenderer=null),!(!this.ktx2Loader||this.configuredRenderer===r)&&(this.ktx2Loader.detectSupport(r),this.configuredRenderer=r)}async load(e,t){return t?.useAsyncFetch?this.loadWithAsyncFetch(e,t):this.loadMainThread(e,t)}async loadWithAsyncFetch(e,t){try{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);let a=await r.arrayBuffer(),o=await this.loader.parseAsync(a,e);return this.applyTextureAnisotropy(o.scene),{object:o.scene,animations:o.animations,gltf:o}}catch(r){return console.error(`Async fetch GLTF load failed for ${e}, falling back to loader.load():`,r),this.loadMainThread(e,t)}}async loadMainThread(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>{this.applyTextureAnisotropy(o.scene),r({object:o.scene,animations:o.animations,gltf:o})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}clone(e){return{object:u(e.object),animations:e.animations?.map(t=>t.clone()),gltf:e.gltf}}applyTextureAnisotropy(e){e.traverse(t=>{let r=t.material;if(!r)return;let a=Array.isArray(r)?r:[r];for(let o of a)for(let n of V){let i=o[n];if(i&&i.isTexture){let d=i;d.anisotropy=b,d.needsUpdate=!0}}})}setMeshoptEnabled(e){if(e){if(this.meshoptEnabled)return;this.loader.setMeshoptDecoder($),this.meshoptEnabled=!0;return}this.meshoptEnabled&&(this.loader.setMeshoptDecoder(void 0),this.meshoptEnabled=!1)}clearKTX2Loader(){this.ktx2Loader&&(this.ktx2Loader.dispose(),this.ktx2Loader=null),this.loader.setKTX2Loader(void 0),this.configuredRenderer=null,this.ktx2TranscoderPath=null}normalizeTranscoderPath(e){if(!e)return null;let t=String(e);return t.endsWith("/")?t:`${t}/`}};import{FBXLoader as _}from"three/addons/loaders/FBXLoader.js";var T=class{loader;constructor(){this.loader=new _}isSupported(e){return c(e)==="fbx"}async load(e,t){return t?.useAsyncFetch?this.loadWithAsyncFetch(e,t):this.loadMainThread(e,t)}async loadWithAsyncFetch(e,t){try{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);let a=await r.arrayBuffer(),o=this.loader.parse(a,e);return{object:o,animations:o.animations||[]}}catch(r){return console.error(`Async fetch FBX load failed for ${e}, falling back to loader.load():`,r),this.loadMainThread(e,t)}}async loadMainThread(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>{r({object:o,animations:o.animations||[]})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}clone(e){return{object:u(e.object),animations:e.animations?.map(t=>t.clone())}}};import{OBJLoader as z}from"three/addons/loaders/OBJLoader.js";import{MTLLoader as Y}from"three/addons/loaders/MTLLoader.js";var y=class{loader;mtlLoader;constructor(){this.loader=new z,this.mtlLoader=new Y}isSupported(e){return c(e)==="obj"}async load(e,t){return t?.mtlPath&&await this.loadMTL(t.mtlPath),new Promise((r,a)=>{this.loader.load(e,o=>{r({object:o,animations:[]})},o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}async loadMTL(e){return new Promise((t,r)=>{this.mtlLoader.load(e,a=>{a.preload(),this.loader.setMaterials(a),t()},void 0,a=>r(a))})}clone(e){return{object:u(e.object),animations:[]}}};import{AudioLoader as q}from"three";var x=class{loader;constructor(){this.loader=new q}isSupported(e){let t=c(e);return["mp3","ogg","wav","flac","aac","m4a"].includes(t||"")}async load(e,t){return new Promise((r,a)=>{this.loader.load(e,o=>r(o),o=>{t?.onProgress&&o.lengthComputable&&t.onProgress(o.loaded/o.total)},o=>a(o))})}};import{FileLoader as Q}from"three";var m=class{loader;constructor(){this.loader=new Q}isSupported(e){return!0}async load(e,t){let r=t?.responseType??"text";return this.loader.setResponseType(r),new Promise((a,o)=>{this.loader.load(e,n=>a(n),n=>{t?.onProgress&&n.lengthComputable&&t.onProgress(n.loaded/n.total)},n=>o(n))})}},M=class{fileLoader;constructor(){this.fileLoader=new m}isSupported(e){return c(e)==="json"}async load(e,t){return await this.fileLoader.load(e,{...t,responseType:"json"})}};var w=class s{static instance=null;textureCache=new Map;modelCache=new Map;audioCache=new Map;fileCache=new Map;jsonCache=new Map;pendingGLTFRuntimePath=null;pendingGLTFRuntimePromise=null;pendingGLTFRuntimeResolve=null;textureLoader;gltfLoader;fbxLoader;objLoader;audioLoader;fileLoader;jsonLoader;loadingManager;events;stats={texturesLoaded:0,modelsLoaded:0,audioLoaded:0,filesLoaded:0,cacheHits:0,cacheMisses:0};constructor(){this.textureLoader=new L,this.gltfLoader=new g,this.fbxLoader=new T,this.objLoader=new y,this.audioLoader=new x,this.fileLoader=new m,this.jsonLoader=new M,this.loadingManager=new ee,this.loadingManager.onProgress=(e,t,r)=>{this.events.emit("batch:progress",{loaded:t,total:r})},this.events=R(),k.enabled=!0}static getInstance(){return s.instance||(s.instance=new s),s.instance}static resetInstance(){s.instance&&(s.instance.clearCache(),s.instance=null)}async loadTexture(e,t){return this.loadWithCache(e,"texture",this.textureCache,()=>this.textureLoader.load(e,t),t,r=>{if(!t?.clone)return r;let a=this.textureLoader.clone(r);return t.repeat&&a.repeat.copy(h(t.repeat,p)),t.wrapS!==void 0&&(a.wrapS=t.wrapS),t.wrapT!==void 0&&(a.wrapT=t.wrapT),a})}async loadGLTF(e,t){return await this.waitForPreparedGLTFRuntime(),this.loadWithCache(e,"gltf",this.modelCache,()=>this.gltfLoader.load(e,t),t,r=>t?.clone?this.gltfLoader.clone(r):r)}prepareGLTFRuntime(e){let t=this.normalizeTranscoderPath(e?.ktx2TranscoderPath);t&&(this.pendingGLTFRuntimePath===t&&this.pendingGLTFRuntimePromise||(this.pendingGLTFRuntimePath=t,this.pendingGLTFRuntimePromise||(this.pendingGLTFRuntimePromise=new Promise(r=>{this.pendingGLTFRuntimeResolve=r}))))}async configureGLTFRuntime(e){await this.gltfLoader.configureRuntime(e);let t=this.normalizeTranscoderPath(e?.ktx2TranscoderPath);t&&e?.renderer&&this.resolvePreparedGLTFRuntime(t)}async loadFBX(e,t){return this.loadWithCache(e,"fbx",this.modelCache,()=>this.fbxLoader.load(e,t),t,r=>t?.clone?this.fbxLoader.clone(r):r)}async loadOBJ(e,t){let r=t?.mtlPath?`${e}:${t.mtlPath}`:e;return this.loadWithCache(r,"obj",this.modelCache,()=>this.objLoader.load(e,t),t,a=>t?.clone?this.objLoader.clone(a):a)}async loadModel(e,t){let r=c(e);switch(r){case"gltf":case"glb":return this.loadGLTF(e,t);case"fbx":return this.loadFBX(e,t);case"obj":return this.loadOBJ(e,t);default:throw new Error(`Unsupported model format: ${r}`)}}async loadAudio(e,t){return this.loadWithCache(e,"audio",this.audioCache,()=>this.audioLoader.load(e,t),t)}async loadFile(e,t){let r=t?.responseType?`${e}:${t.responseType}`:e;return this.loadWithCache(r,"file",this.fileCache,()=>this.fileLoader.load(e,t),t)}async loadJSON(e,t){return this.loadWithCache(e,"json",this.jsonCache,()=>this.jsonLoader.load(e,t),t)}async loadBatch(e){let t=new Map,r=e.map(async a=>{try{let o;switch(a.type){case"texture":o=await this.loadTexture(a.url,a.options);break;case"gltf":o=await this.loadGLTF(a.url,a.options);break;case"fbx":o=await this.loadFBX(a.url,a.options);break;case"obj":o=await this.loadOBJ(a.url,a.options);break;case"audio":o=await this.loadAudio(a.url,a.options);break;case"file":o=await this.loadFile(a.url,a.options);break;case"json":o=await this.loadJSON(a.url,a.options);break;default:throw new Error(`Unknown asset type: ${a.type}`)}t.set(a.url,o)}catch(o){throw this.events.emit("asset:error",{url:a.url,type:a.type,error:o}),o}});return await Promise.all(r),this.events.emit("batch:complete",{urls:e.map(a=>a.url)}),t}async preload(e){await this.loadBatch(e)}isCached(e){return this.textureCache.has(e)||this.modelCache.has(e)||this.audioCache.has(e)||this.fileCache.has(e)||this.jsonCache.has(e)}clearCache(e){e?(this.textureCache.delete(e),this.modelCache.delete(e),this.audioCache.delete(e),this.fileCache.delete(e),this.jsonCache.delete(e)):(this.textureCache.clear(),this.modelCache.clear(),this.audioCache.clear(),this.fileCache.clear(),this.jsonCache.clear(),k.clear(),this.pendingGLTFRuntimePath=null,this.pendingGLTFRuntimePromise=null,this.pendingGLTFRuntimeResolve=null)}getStats(){return{...this.stats}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}async loadWithCache(e,t,r,a,o,n){o?.forceReload&&r.delete(e);let i=r.get(e);if(i){this.stats.cacheHits++,this.events.emit("asset:loaded",{url:e,type:t,fromCache:!0});let l=await i.promise;return n?n(l):l}this.stats.cacheMisses++,this.events.emit("asset:loading",{url:e,type:t});let d=a(),f={promise:d,loadedAt:Date.now()};r.set(e,f);try{let l=await d;return f.result=l,this.updateStats(t),this.events.emit("asset:loaded",{url:e,type:t,fromCache:!1}),n?n(l):l}catch(l){throw r.delete(e),this.events.emit("asset:error",{url:e,type:t,error:l}),l}}updateStats(e){switch(e){case"texture":this.stats.texturesLoaded++;break;case"gltf":case"fbx":case"obj":this.stats.modelsLoaded++;break;case"audio":this.stats.audioLoaded++;break;case"file":case"json":this.stats.filesLoaded++;break}}async waitForPreparedGLTFRuntime(){this.pendingGLTFRuntimePromise&&await this.pendingGLTFRuntimePromise}resolvePreparedGLTFRuntime(e){this.pendingGLTFRuntimePath&&this.pendingGLTFRuntimePath!==e||(this.pendingGLTFRuntimeResolve?.(),this.pendingGLTFRuntimeResolve=null,this.pendingGLTFRuntimePromise=null,this.pendingGLTFRuntimePath=null)}normalizeTranscoderPath(e){if(!e)return null;let t=String(e);return t.endsWith("/")?t:`${t}/`}},A=w.getInstance();import{uniform as vt,uv as Ot,time as wt,vec3 as At,vec4 as Ft,float as Pt,Fn as St}from"three/tsl";function ae(s){return"colorNode"in s}function N(s){return"fragment"in s&&"vertex"in s}function oe(s){return!!s&&N(s)&&s.vertex===O.vertex&&s.fragment===O.fragment}var U=class s{static sharedMaterialMap=new Map;static clearSharedMaterialCache(){s.sharedMaterialMap.clear()}materials=[];useTSL;constructor(e=!0){this.useTSL=e}trackSharedMaterial(e,t){let r=E(G(e)),a=s.sharedMaterialMap.get(r);if(a){let o=a.geometryMap.get(t);o?a.geometryMap.set(t,o+1):a.geometryMap.set(t,1)}else s.sharedMaterialMap.set(r,{geometryMap:new Map([[t,1]]),material:this.materials[0]})}build(e,t){let{path:r,normalMap:a,repeat:o,color:n,shader:i,opacity:d}=e,f=oe(i),l=!!i&&!f,S=!!r&&(!i||f);S?this.setTexture(r??null,o,!0,d,n):l&&i?ae(i)?this.setTSLShader(i,d):N(i)&&(console.warn("MaterialBuilder: GLSL shaders are not supported on the WebGPU renderer. Author custom shaders as TSL (ZylemTSLShader). Falling back to a default node material."),this.setColor(n??new F("#ffffff"),!0,d)):r&&this.setTexture(r,o,!0,d,n),n&&!S&&!l&&this.withColor(n,!0,d),this.materials.length===0&&this.setColor(new F("#ffffff"),!0,d),a&&this.materials.length>0&&this.setNormalMap(a,o),this.trackSharedMaterial(e,t)}withColor(e,t=!1,r){return this.setColor(e,t,r),this}withShader(e,t){return this.setShader(e,t),this}withTSLShader(e,t){return this.setTSLShader(e,t),this}applyOpacity(e,t,r=!1){t!==void 0&&(e.opacity=t),e.transparent=r||t!==void 0&&t<1,e.needsUpdate=!0}setTexture(e=null,t=p,r=!0,a,o){if(!e)return;let n=new P;o&&(n.color=o),this.applyOpacity(n,a),this.materials.push(n),A.loadTexture(e,{clone:!0,repeat:h(t,p),colorSpace:te}).then(i=>{i.wrapS=v,i.wrapT=v,n.map=i,n.needsUpdate=!0})}setNormalMap(e,t=p){let r=this.materials[this.materials.length-1];r&&A.loadTexture(e,{clone:!0,repeat:h(t,p)}).then(a=>{a.wrapS=v,a.wrapT=v,r instanceof P&&(r.normalMap=a,r.needsUpdate=!0)})}setColor(e,t=!0,r){let a=new P;a.color=e,this.applyOpacity(a,r),this.materials.push(a)}setShader(e,t){console.warn("MaterialBuilder.setShader: GLSL shaders are not supported on the WebGPU renderer. Author custom shaders as TSL (ZylemTSLShader). Falling back to a default node material."),this.setColor(new F("#ffffff"),!0,t)}setTSLShader(e,t){this.materials.push(se(e,t))}};function se(s,e){let t=new re;return t.colorNode=s.colorNode,s.positionNode&&(t.positionNode=s.positionNode),s.normalNode&&(t.normalNode=s.normalNode),s.blending!==void 0&&(t.blending=s.blending),s.side!==void 0&&(t.side=s.side),s.depthTest!==void 0&&(t.depthTest=s.depthTest),e!==void 0&&(t.opacity=e),t.transparent=!!s.transparent||e!==void 0&&e<1,t.needsUpdate=!0,t}export{G as a,E as b,C as c,O as d,b as e,c as f,A as g,ae as h,N as i,U as j,se as k,vt as l,Ot as m,wt as n,At as o,Ft as p,Pt as q,St as r};
|
package/dist/chunk-FUZDTRCU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as q,q as $,r as X,t as D,w as J,y as Q,z as ee}from"./chunk-VXE3CV3K.js";import{d as K,f as H,g as j}from"./chunk-6FGXC4T6.js";import{c as B,d as P,h as M,j as Y}from"./chunk-7WRQ2UAN.js";import{Box3 as I,BufferAttribute as Ae,SkinnedMesh as Me,MeshStandardMaterial as Fe,Group as Oe,Vector3 as x,Matrix4 as se}from"three";var S=class{async loadFile(e,t){switch(H(e)){case"fbx":{let i=await j.loadFBX(e,t);return{object:i.object,animation:i.animations?.[0]}}case"gltf":case"glb":{let i=await j.loadGLTF(e,t);return{object:i.object,gltf:i.gltf}}case"obj":return{object:(await j.loadOBJ(e,t)).object};default:throw new Error(`Unsupported file type: ${e}`)}}};import{AnimationMixer as ge,Bone as te,LoopOnce as be,LoopRepeat as xe}from"three";function _e(n){let e=n.lastIndexOf(".");return e>=0?n.slice(0,e):n}function ie(n,e){if(!n?.name?.endsWith(".position"))return!1;let t=_e(n.name),o=e.get(t);return o instanceof te?!(o.parent instanceof te):/hips\.position$/i.test(n.name)||/root\.position$/i.test(n.name)}function ve(n,e,t,o){for(let i of n.tracks){if(!ie(i,e)||!i.values||i.values.length<3)continue;let s=i.values[0],r=o??i.values[1],a=i.values[2];for(let l=0;l<i.values.length;l+=3)i.values[l]=s,t&&(i.values[l+1]=r),i.values[l+2]=a}return n}function Se(n,e){for(let t of n.tracks)if(ie(t,e)&&!(!t.values||t.values.length<3))return t.values[1];return null}var E=class{constructor(e){this.target=e}_mixer=null;_actions={};_animations=[];_currentAction=null;_pauseAtPercentage=0;_isPaused=!1;_queuedKey=null;_fadeDuration=.5;_currentKey="";_assetLoader=new S;async loadAnimations(e,t={}){if(!e.length)return;let o=t.stripRootMotionY??!1,i=t.referenceRootY,s=t.referenceAnimationPath,r=await Promise.all(e.map(c=>this._assetLoader.loadFile(c.path))),a=new Map;this.target.traverse(c=>{c.name&&a.set(c.name,c)});let l=[];if(r.forEach((c,u)=>{c.animation&&l.push({key:e[u].key||u.toString(),clip:c.animation,path:e[u].path})}),!l.length)return;let h=i;if(o&&h===void 0){let c=s?l.findIndex(p=>p.path===s):0,u=c>=0?[c,...l.map((p,f)=>f).filter(p=>p!==c)]:l.map((p,f)=>f);for(let p of u){let f=Se(l[p].clip,a);if(f!==null){h=f;break}}}let d=l.map(({key:c,clip:u})=>({key:c,clip:ve(u,a,o,h)}));this._animations=d.map(c=>c.clip),this._mixer=new ge(this.target),d.forEach(({key:c,clip:u})=>{this._actions[c]=this._mixer.clipAction(u)}),this.playAnimation({key:d[0].key})}update(e){if(!this._mixer||!this._currentAction)return;this._mixer.update(e);let t=this._currentAction.getClip().duration*(this._pauseAtPercentage/100);if(!this._isPaused&&this._pauseAtPercentage>0&&this._currentAction.time>=t&&(this._currentAction.time=t,this._currentAction.paused=!0,this._isPaused=!0,this._queuedKey!==null)){let o=this._actions[this._queuedKey];o.reset().play(),this._currentAction.crossFadeTo(o,this._fadeDuration,!1),this._currentAction=o,this._currentKey=this._queuedKey,this._queuedKey=null}}playAnimation(e){if(!this._mixer)return;let{key:t,pauseAtPercentage:o=0,pauseAtEnd:i=!1,fadeToKey:s,fadeDuration:r=.5}=e;if(t===this._currentKey)return;let a=this._actions[t];if(!a)return;if(a===this._currentAction){this._currentKey=t;return}this._queuedKey=s||null,this._fadeDuration=r,this._pauseAtPercentage=i?100:o,this._isPaused=!1;let l=this._currentAction;this._pauseAtPercentage>0?(a.setLoop(be,1/0),a.clampWhenFinished=!0):(a.setLoop(xe,1/0),a.clampWhenFinished=!1),a.reset().play(),l&&l.crossFadeTo(a,r,!1),this._currentAction=a,this._currentKey=t}dispose(){Object.values(this._actions).forEach(e=>{e.stop()}),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this.target),this._mixer=null),this._actions={},this._animations=[],this._currentAction=null,this._currentKey=""}get currentAnimationKey(){return this._currentKey}get animations(){return this._animations}};var re={...X,material:{shader:K},animations:[],models:[],collisionShape:"capsule"};function F(n){return Y(n.scale,P)}var Ce=1e-4,je=/foot$/i,Z=new x,w=new x,ne=new x,T=new x,oe=new se;function De(n){let e=1/0,t=!1;return n.traverse(o=>{if(!o.isSkinnedMesh)return;let i=o,s=i.geometry,r=s.attributes.position,a=s.attributes.skinIndex,l=s.attributes.skinWeight,h=i.skeleton;if(!r||!a||!l||!h)return;t=!0,h.update(),i.updateMatrixWorld(!0);let d=h.boneMatrices;if(d)for(let c=0;c<r.count;c++){ne.fromBufferAttribute(r,c).applyMatrix4(i.bindMatrix),T.set(0,0,0);for(let u=0;u<4;u++){let p=l.getComponent(c,u);if(p===0)continue;let f=a.getComponent(c,u);oe.fromArray(d,f*16),T.addScaledVector(w.copy(ne).applyMatrix4(oe),p)}T.applyMatrix4(i.bindMatrixInverse).applyMatrix4(i.matrixWorld),e=Math.min(e,T.y)}}),!t||!Number.isFinite(e)?null:e}function Ee(n,e){e.updateMatrixWorld(!0);let t=e.getWorldPosition(Z).y,o=De(n)??1/0;if(n.traverse(i=>{!i.isBone||!je.test(i.name)||(i.getWorldPosition(Z),o=Math.min(o,Z.y))}),Number.isFinite(o)||n.traverse(i=>{if(!i.isSkinnedMesh)return;let s=i;if(s.computeBoundingBox(),!s.boundingBox)return;let{min:r,max:a}=s.boundingBox;for(let l of[[r.x,r.y,r.z],[r.x,r.y,a.z],[r.x,a.y,r.z],[r.x,a.y,a.z],[a.x,r.y,r.z],[a.x,r.y,a.z],[a.x,a.y,r.z],[a.x,a.y,a.z]])w.set(l[0],l[1],l[2]),w.applyMatrix4(s.matrixWorld),o=Math.min(o,w.y)}),!Number.isFinite(o)){let i=new I().setFromObject(n);if(i.isEmpty())return null;o=i.min.y}return o-t}function Te(n,e,t){return n.stripRootMotionY!==void 0?n.stripRootMotionY:!!(e&&t.some(o=>o===e))}function C(n){let e=n.collision?.position;return e?M(e,B):null}function R(n){return!!n.collision?.size}function ze(n){n.hasWarnedDynamicTrimesh||(n.hasWarnedDynamicTrimesh=!0,console.warn(`Actor "${n.name||n.uuid}" requested collisionShape="trimesh" on a dynamic body; falling back to bounds.`))}function ae(n,e,t){let o=n==="model"?"bounds":n??"capsule";return o==="trimesh"&&!e?(t?.(),"bounds"):o}function le(n,e){let t=n.x||.5,o=n.y||1,i=n.z||.5,s=Math.max(t,i)/2,r=o/2;return{shape:{type:"capsule",halfHeight:Math.max(0,r-s),radius:s},offset:[e.x,e.y,e.z],sensor:!1}}function v(n){let e=M(n.collision?.size??n.size,{x:.5,y:1,z:.5}),t=e.y||1,o=C(n);return le({x:e.x||.5,y:t,z:e.z||.5},o??{x:0,y:t/2,z:0})}function ce(n){let e=n.collision?.size;if(!e)return null;let t=M(e,B),o=t.x/2,i=t.y/2,s=t.z/2,r=C(n);return{shape:{type:"box",halfExtents:[o,i,s]},offset:[r?.x??0,r?.y??i,r?.z??0],sensor:!1}}function ue(n,e,t){let i=e.matrixWorld.clone().invert().multiply(n.matrixWorld);return new se().makeScale(t.x,t.y,t.z).multiply(i)}function V(n,e,t){n.updateMatrixWorld(!0);let o=!1,i=new I;if(n.traverse(a=>{if(!a.isMesh)return;let l=a,h=l.geometry;if(!h)return;let d=null;if(l instanceof Me?(l.computeBoundingBox(),d=l.boundingBox?.clone()??null):(h.computeBoundingBox(),d=h.boundingBox?.clone()??null),!d)return;let c=d.applyMatrix4(ue(l,e,t));if(!o){i.copy(c),o=!0;return}i.union(c)}),!o||i.isEmpty())return null;let s=new x,r=new x;return i.getSize(s),i.getCenter(r),{size:s,center:r}}function we(n,e,t){n.updateMatrixWorld(!0);let o=[],i=[],s=new I,r=new x,a=!1;if(n.traverse(h=>{if(!h.isMesh)return;let d=h,c=d.geometry;if(!c)return;let u=c.getAttribute("position");if(!(u instanceof Ae))return;let p=ue(d,e,t),f=o.length/3;for(let m=0;m<u.count;m++)r.set(u.getX(m),u.getY(m),u.getZ(m)),r.applyMatrix4(p),o.push(r.x,r.y,r.z),s.expandByPoint(r);let A=c.getIndex();if(A)for(let m=0;m<A.count;m++)i.push(f+A.getX(m));else for(let m=0;m<u.count;m++)i.push(f+m);a=!0}),!a||o.length===0||i.length===0)return null;let l=new x;return s.getCenter(l),{vertices:new Float32Array(o),indices:new Uint32Array(i),center:l}}function he(n,e,t){let o=ce(t);if(o)return o;if(!n||!e)return v(t);let i=V(n,e,F(t));if(!i)return v(t);let s=C(t);return{shape:{type:"box",halfExtents:[i.size.x/2,i.size.y/2,i.size.z/2]},offset:[s?.x??i.center.x,s?.y??i.center.y,s?.z??i.center.z],sensor:!1}}function de(n,e,t,o,i){if(R(i)||!n||!e)return v(i);let s=V(n,e,F(i));if(!s)return v(i);let a=C(i);if(!a){let l=t&&o?V(t,o,F(i)):null;a=l?{x:l.center.x,y:l.center.y,z:l.center.z}:{x:s.center.x,y:s.center.y,z:s.center.z}}return le({x:s.size.x,y:s.size.y,z:s.size.z},a)}function pe(n,e,t){let o=ce(t);if(o)return o;if(!n||!e)return v(t);let i=we(n,e,F(t));if(!i)return v(t);let s=C(t);return{shape:{type:"trimesh",vertices:i.vertices,indices:i.indices},offset:s?[s.x-i.center.x,s.y-i.center.y,s.z-i.center.z]:[0,0,0],sensor:!1}}function z(n){n&&n.traverse(e=>{if(!e.isMesh)return;let t=e;t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(o=>o.dispose()):t.material?.dispose()})}var k=class extends J{objectModel=null;collisionSource=null;collisionShape="capsule";constructor(e){super(),this.objectModel=e.objectModel,this.collisionSource=e.collisionSource??e.objectModel??null,this.collisionShape=e.collisionShape??"capsule"}collider(e){let t=ae(this.collisionShape,!!e.collision?.static);return t==="bounds"?he(this.objectModel,this.objectModel,e):t==="trimesh"?pe(this.objectModel,this.objectModel,e):de(this.collisionSource,this.collisionSource,this.objectModel,this.objectModel,e)}},U=class extends Q{createEntity(e){return new O(e)}},Le=Symbol("Actor"),O=class extends D{static type=Le;_object=null;_collisionSource=null;_animationDelegate=null;_modelFileNames=[];_assetLoader=new S;_loadGeneration=0;_loadStatus="idle";controlledRotation=!1;hasWarnedDynamicTrimesh=!1;constructor(e){super(),this.options=q(re,e),this.prependUpdate(this.actorUpdate.bind(this)),this.controlledRotation=!0}create(){return this._loadStatus==="idle"&&(this.options.models?.length??0)>0&&this.load(),super.create()}load(){this._loadStatus==="loading"||this._loadStatus==="loaded"||(this._modelFileNames=[...this.options.models||[]],this._modelFileNames.length!==0&&(this.disposeRuntimeState(!0),this._loadStatus="loading",this.loadModelsDeferred(++this._loadGeneration)))}data(){return{animations:this._animationDelegate?.animations,objectModel:this._object,collisionSource:this._collisionSource??this._object,collisionShape:this.options.collisionShape}}needsDeferredModelCollision(){return this.requiresLoadedCollisionSource()?!this.getRuntimeCollisionSource():!1}synchronizeRuntimeCollider(){let e=this.getResolvedCollisionShape(),t;if(e==="bounds")t=he(this._object,this.group??this._object,this.options);else if(e==="trimesh")t=pe(this._object,this.group??this._object,this.options);else{let o=this.getRuntimeCollisionSource();t=de(o,o,this._object,this._object,this.options)}this.colliderDesc=t,this.colliderDescs.length>0?this.colliderDescs[0]=t:this.colliderDescs.push(t)}actorUpdate(e){this._animationDelegate?.update(e.delta)}actorDestroy(){this._loadGeneration+=1,this._loadStatus="idle",this.disposeRuntimeState(!0),this._modelFileNames=[]}_cleanup(e){super._cleanup(e),this.actorDestroy()}playAnimation(e){this._animationDelegate?.playAnimation(e)}get object(){return this._object}get collisionSource(){return this._collisionSource??this._object}getDebugInfo(){let e={type:"Actor",models:this._modelFileNames.length>0?this._modelFileNames:"none",modelLoaded:!!this._object,scale:(()=>{let t=M(this.options.scale,P);return`${t.x}, ${t.y}, ${t.z}`})(),collisionShape:this.getResolvedCollisionShape()};if(this._animationDelegate&&(e.currentAnimation=this._animationDelegate.currentAnimationKey||"none",e.animationsCount=this.options.animations?.length||0),this._object){let t=0,o=0;this._object.traverse(i=>{if(!i.isMesh)return;t++;let s=i.geometry;s?.attributes.position&&(o+=s.attributes.position.count)}),e.meshCount=t,e.vertexCount=o}return e}getResolvedCollisionShape(){return ae(this.options.collisionShape,!!this.options.collision?.static,()=>ze(this))}requiresLoadedCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?!R(this.options):e==="capsule"?!R(this.options)&&this.getCollisionSourceSelection().file!==null:!1}getRuntimeCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?this._object:this._collisionSource??this._object}getCollisionSourceSelection(){let e=this.options.models?.[0]??null,t=this.options.animations?.[0]?.path??null;return t?{file:t,reuseVisibleModel:t===e}:{file:e,reuseVisibleModel:!0}}disposeRuntimeState(e){this._animationDelegate&&(this._animationDelegate.dispose(),this._animationDelegate=null);let t=this._collisionSource;z(this._object),t&&t!==this._object&&z(t),this._object=null,this._collisionSource=null,e&&this.group&&(this.group.clear(),this.group=void 0)}loadModelsDeferred(e){this.dispatch("entity:model:loading",{entityId:this.uuid,files:this._modelFileNames});let t=this.getCollisionSourceSelection(),o=this._modelFileNames.map(s=>this._assetLoader.loadFile(s,{clone:!0})),i=t.file&&!t.reuseVisibleModel?this._assetLoader.loadFile(t.file,{clone:!0}):Promise.resolve(null);Promise.all([Promise.all(o),i]).then(([s,r])=>{if(e!==this._loadGeneration){s.forEach(l=>z(l.object??null)),r?.object&&z(r.object);return}this._object=s[0]?.object??null,this._collisionSource=t.reuseVisibleModel?this._object:r?.object??this._object,this._loadStatus=this._object?"loaded":"idle";let a=0;if(this._object){this._object.traverse(u=>{u.isMesh&&a++}),this.group=new Oe,this.group.add(this._object),this.group.scale.copy(F(this.options)),$(this),this.applyMaterialOverrides(),this._animationDelegate=new E(this._object);let l=this.options.animations||[],h=this.options.models?.[0],d=l.map(u=>u.path),c=Te(this.options,h,d);l.length>0?this._animationDelegate.loadAnimations(l,{stripRootMotionY:c,referenceAnimationPath:h}).then(()=>{e===this._loadGeneration&&(this.alignVisualModelToGround(),this.dispatch("entity:animation:loaded",{entityId:this.uuid,animationCount:l.length}))}):this.alignVisualModelToGround()}this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!!this._object,meshCount:a})}).catch(s=>{e===this._loadGeneration&&(this._loadStatus="idle",console.error("Failed to load actor model",s),this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!1,meshCount:0,errorMessage:s instanceof Error?s.message:String(s)}))})}alignVisualModelToGround(){if(!this._object||!this.group)return;this._animationDelegate?.update(0),this._object.updateMatrixWorld(!0);let e=Ee(this._object,this.group);if(e===null||Math.abs(e)<Ce)return;let t=this.group.scale.y||1;this._object.position.y-=e/t}applyMaterialOverrides(){let e=this.options.material;!e||!e.color&&!e.path&&e.opacity===void 0||this._object&&this._object.traverse(t=>{if(!t.isMesh)return;let o=t;o.material=Array.isArray(o.material)?o.material.map(i=>this.tintMaterial(i,e)):this.tintMaterial(o.material,e),e.color&&(o.castShadow=!0,o.receiveShadow=!0)})}tintMaterial(e,t){let o="color"in e,i=!!t.color,s=t.opacity!==void 0;if(!i&&!s)return e;if(i&&!o)return new Fe({color:t.color,emissiveIntensity:.5,lightMapIntensity:.5,fog:!0,opacity:t.opacity??1,transparent:s&&t.opacity<1});let r=e.clone();if(i&&"color"in r&&r.color.copy(t.color),s&&"opacity"in r&&"transparent"in r){let a=r;a.opacity=t.opacity,a.transparent=t.opacity<1}return r.needsUpdate=!0,r}};function Be(...n){return ee({args:n,defaultConfig:re,EntityClass:O,BuilderClass:U,CollisionBuilderClass:k,entityType:O.type,cloneFactory:e=>Be(e??{})})}import{Color as We,Fog as Ye,FogExp2 as Ke,Group as He}from"three";import{Color as Pe}from"three";import{Fn as fe,fog as Ze,positionWorld as me,positionView as Re,uniform as y,float as Ve,vec3 as g,clamp as N,mix as b,max as ke,smoothstep as Ue,floor as Ie,fract as G,dot as Ne}from"three/tsl";var L=class{values;u={time:y(0),heightEnabled:y(0),heightLevel:y(0),heightFalloff:y(0),noiseEnabled:y(0),noiseScale:y(0),noiseStrength:y(0),noiseSpeed:y(0)};attachedScene=null;constructor(e){this.values={...e},this.syncUniforms()}setValues(e){Object.assign(this.values,e),this.syncUniforms()}tick(e){this.values.time+=e,this.u.time.value=this.values.time}scan(e){if(this.attachedScene===e)return;let t=e.fog;t&&(e.fogNode=this.buildFogNode(t),this.attachedScene=e)}unpatchAll(){this.attachedScene&&(this.attachedScene.fogNode=null,this.attachedScene=null)}syncUniforms(){this.u.time.value=this.values.time,this.u.heightEnabled.value=this.values.heightEnabled,this.u.heightLevel.value=this.values.heightLevel,this.u.heightFalloff.value=this.values.heightFalloff,this.u.noiseEnabled.value=this.values.noiseEnabled,this.u.noiseScale.value=this.values.noiseScale,this.u.noiseStrength.value=this.values.noiseStrength,this.u.noiseSpeed.value=this.values.noiseSpeed}buildFogNode(e){let t=e.isFogExp2===!0,o=y(new Pe(e.color)),i=Re.z.negate(),s=t?this.exp2Factor(y(e.density),i):Ue(y(e.near),y(e.far),i),r=this.u.heightLevel.sub(me.y),a=N(r.mul(ke(this.u.heightFalloff,0)),0,1),l=b(s,s.mul(a),this.u.heightEnabled),h=me.mul(this.u.noiseScale).add(g(this.u.time.mul(this.u.noiseSpeed),0,this.u.time.mul(this.u.noiseSpeed).mul(.5))),c=Ge(h).sub(.5).mul(2).mul(N(this.u.noiseStrength,0,1)),u=N(l.add(l.mul(c)),0,1),p=b(l,u,this.u.noiseEnabled);return Ze(o,p)}exp2Factor(e,t){return e.mul(e).mul(t).mul(t).negate().exp().oneMinus()}},_=fe(([n])=>{let e=G(n.mul(g(443.8975,397.2973,491.1871))),t=e.add(Ne(e,e.yzx.add(19.27)));return G(t.x.add(t.y).mul(t.z))}),Ge=fe(([n])=>{let e=Ie(n),t=G(n),o=t.mul(t).mul(Ve(3).sub(t.mul(2))),i=_(e.add(g(0,0,0))),s=_(e.add(g(1,0,0))),r=_(e.add(g(0,1,0))),a=_(e.add(g(1,1,0))),l=_(e.add(g(0,0,1))),h=_(e.add(g(1,0,1))),d=_(e.add(g(0,1,1))),c=_(e.add(g(1,1,1))),u=b(i,s,o.x),p=b(r,a,o.x),f=b(l,h,o.x),A=b(d,c,o.x),m=b(u,p,o.y),ye=b(f,A,o.y);return b(m,ye,o.z)});var qe=Symbol("Fog"),$e="#9aa3ad",Xe=.015,Je=10,Qe=250,et=5,tt=.2,it=.05,nt=.15,ot=.1,W=class extends D{static type=qe;threeFog=null;attachedScene=null;patcher;patcherEnabled;constructor(e={}){super(),this.options={...e};let t=this.resolveUniformValues(this.options);this.patcher=new L(t),this.patcherEnabled=rt(this.options)}create(){return super.create(),this.threeFog=st(this.options),this.group=new He,this.group.name=this.name?`Fog:${this.name}`:"Fog",this}attachToScene(e){this.threeFog&&(this.attachedScene=e,e.fog=this.threeFog,this.patcherEnabled&&this.patcher.scan(e))}_update(e){super._update(e),!(!this.attachedScene||!this.patcherEnabled)&&(this.patcher.tick(e.delta),this.patcher.scan(this.attachedScene))}_cleanup(e){this.patcher.unpatchAll(),this.attachedScene&&this.attachedScene.fog===this.threeFog&&(this.attachedScene.fog=null),this.attachedScene=null,this.threeFog=null,super._cleanup(e)}resolveUniformValues(e){let t=e.height,o=e.noise;return{time:0,heightEnabled:t?.enabled?1:0,heightLevel:t?.level??et,heightFalloff:t?.falloff??tt,noiseEnabled:o?1:0,noiseScale:o?.scale??it,noiseStrength:o?.strength??nt,noiseSpeed:o?.speed??ot}}};function st(n){let e=new We(n.color??$e);return(n.type??"linear")==="exp2"?new Ke(e,n.density??Xe):new Ye(e,n.start??Je,n.end??Qe)}function rt(n){let e=!!n.height?.enabled,t=!!n.noise;return e||t}function Nt(n={}){return new W(n)}export{Le as a,O as b,Be as c,qe as d,W as e,Nt as f};
|