@zylem/game-lib 0.9.6 → 0.9.8
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 +99183 -42019
- package/dist/api/game-lib.api.md +3822 -706
- package/dist/api/game-lib.d.ts +8703 -784
- package/dist/api/game-lib.typedoc.json +336362 -193038
- package/dist/audio.js +1 -1
- 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 +16 -4
- package/dist/bridge.js +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/chunk-26EJFYDX.js +1 -0
- package/dist/chunk-2NO4YCLR.js +1 -0
- package/dist/chunk-3LXDHDJB.js +1 -0
- package/dist/chunk-4DAITCJS.js +1 -0
- package/dist/{chunk-Y23IJJPD.js → chunk-5NQGXW75.js} +1 -1
- package/dist/chunk-5WRFDAZN.js +1 -0
- package/dist/{chunk-OCQ7A5IK.js → chunk-B6GDESCB.js} +1 -1
- package/dist/chunk-BIZOIGCZ.js +1 -0
- package/dist/chunk-BJYXY2FB.js +1 -0
- package/dist/chunk-CI7A5N6G.js +1 -0
- package/dist/chunk-GQXYD2JG.js +1 -0
- package/dist/{chunk-KIFB427K.js → chunk-ICJ2E2OV.js} +1 -1
- package/dist/chunk-NPA6GUGE.js +24 -0
- package/dist/chunk-SIRFF4DY.js +1 -0
- package/dist/chunk-T6O2SGH5.js +1 -0
- package/dist/chunk-UNCP6V7I.js +1 -0
- package/dist/chunk-Y5IU6IA5.js +1 -0
- package/dist/chunk-YFXNZ2RS.js +1 -0
- package/dist/chunk-YW2GTHCV.js +19 -0
- package/dist/chunk-YWH5HQDT.js +1 -0
- package/dist/cinematics.d.ts +7 -6
- package/dist/core.d.ts +20 -17
- package/dist/core.js +1 -1
- package/dist/{debug-state-DhVkY2aM.d.ts → debug-state-JRneI6c2.d.ts} +2 -2
- package/dist/debug.d.ts +28 -126
- package/dist/debug.js +1 -1
- 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/fbx-loader-SDI6QYTS.js +1 -0
- package/dist/game-default-AF5QFXSD.js +1 -0
- package/dist/{game-mu6OSCrq.d.ts → game-uQd7k6-m.d.ts} +3 -3
- package/dist/gaussian-splat-loader-ACFJKCCL.js +1 -0
- package/dist/geometry-mesh-loader-XDJV77TU.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/obj-loader-SI5RVY24.js +1 -0
- 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 +12 -10
- package/dist/public.js +1 -1
- package/dist/sog-loader-BZFMQ3ZB.js +1 -0
- package/dist/{stage-B_KdSEK6.d.ts → stage-Dez16Gxm.d.ts} +186 -16
- package/dist/transform-gizmo-DappLQ9w.d.ts +123 -0
- package/dist/usd-loader-PCBATNPM.js +1 -0
- package/dist/web-components.d.ts +9 -8
- package/dist/{zylem-camera-CWhIGXlW.d.ts → zylem-camera-BA3VPFlS.d.ts} +9 -0
- package/package.json +150 -7
- package/dist/chunk-47HAZZWF.js +0 -1
- 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-RPMV7GDX.js +0 -24
- 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/dist/level-types-D10LiOcn.d.ts +0 -91
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as three from 'three';
|
|
2
|
+
import { Vector3, Group, Scene, Camera } from 'three';
|
|
3
|
+
|
|
4
|
+
type GizmoMode = 'translate' | 'rotate' | 'scale';
|
|
5
|
+
/** Single-axis, planar, and uniform handle identifiers. */
|
|
6
|
+
type GizmoAxis = 'x' | 'y' | 'z' | 'xy' | 'yz' | 'xz' | 'xyz';
|
|
7
|
+
/** A raw, unsnapped drag result in world space. */
|
|
8
|
+
type GizmoDelta = {
|
|
9
|
+
kind: 'translate';
|
|
10
|
+
offset: Vector3;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'rotate';
|
|
13
|
+
axis: Vector3;
|
|
14
|
+
angle: number;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'scale';
|
|
17
|
+
factor: Vector3;
|
|
18
|
+
};
|
|
19
|
+
/** A mouse ray in world space. */
|
|
20
|
+
interface GizmoRay {
|
|
21
|
+
origin: Vector3;
|
|
22
|
+
direction: Vector3;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Closest point along an infinite line to a ray, as a distance along the line.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when the ray is close enough to parallel with the line that the
|
|
28
|
+
* closest point becomes unstable; see {@link MAX_DRAG_GAIN}.
|
|
29
|
+
*/
|
|
30
|
+
declare function closestAxisValue(ray: GizmoRay, origin: Vector3, axis: Vector3): number | null;
|
|
31
|
+
/**
|
|
32
|
+
* Intersect a ray with the plane through `origin` with the given normal.
|
|
33
|
+
*
|
|
34
|
+
* Returns `null` for a plane seen too close to edge-on, where the hit point
|
|
35
|
+
* races away across the plane for very little pointer motion.
|
|
36
|
+
*/
|
|
37
|
+
declare function intersectPlane(ray: GizmoRay, origin: Vector3, normal: Vector3, target: Vector3): Vector3 | null;
|
|
38
|
+
declare class TransformGizmo {
|
|
39
|
+
/** Root added to the scene; carries the pivot transform. */
|
|
40
|
+
readonly root: Group<three.Object3DEventMap>;
|
|
41
|
+
private scene;
|
|
42
|
+
private modeGroups;
|
|
43
|
+
private handles;
|
|
44
|
+
private materials;
|
|
45
|
+
private geometries;
|
|
46
|
+
private mode;
|
|
47
|
+
private highlighted;
|
|
48
|
+
private drag;
|
|
49
|
+
private raycaster;
|
|
50
|
+
constructor();
|
|
51
|
+
addTo(scene: Scene): void;
|
|
52
|
+
removeFromScene(): void;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
setMode(mode: GizmoMode): void;
|
|
55
|
+
getMode(): GizmoMode;
|
|
56
|
+
/** Place the gizmo at a pivot and show it. */
|
|
57
|
+
show(pivot: Vector3): void;
|
|
58
|
+
hide(): void;
|
|
59
|
+
get visible(): boolean;
|
|
60
|
+
get pivot(): Vector3;
|
|
61
|
+
/**
|
|
62
|
+
* Keep the gizmo a constant size on screen.
|
|
63
|
+
*
|
|
64
|
+
* A world-sized gizmo is unusable in an orbit view: it fills the screen up
|
|
65
|
+
* close and disappears from a distance.
|
|
66
|
+
*/
|
|
67
|
+
update(camera: Camera): void;
|
|
68
|
+
/**
|
|
69
|
+
* Which handle a ray hits, or `null`.
|
|
70
|
+
*
|
|
71
|
+
* Raycasts the gizmo's own meshes rather than the physics world. Handles are
|
|
72
|
+
* render-only objects with no colliders, so the physics raycast used to pick
|
|
73
|
+
* entities cannot see them at all.
|
|
74
|
+
*/
|
|
75
|
+
pick(ray: GizmoRay): GizmoAxis | null;
|
|
76
|
+
/**
|
|
77
|
+
* Whether a handle can be dragged from the current viewing angle.
|
|
78
|
+
*
|
|
79
|
+
* Each handle type degenerates differently: an arrow aimed at the camera has
|
|
80
|
+
* no screen-space direction left to follow, while a plane quad or rotation
|
|
81
|
+
* ring seen edge-on turns a pixel of motion into a huge sweep across it.
|
|
82
|
+
*/
|
|
83
|
+
private isHandleDraggable;
|
|
84
|
+
/** Tint a handle to show it is hovered or being dragged. */
|
|
85
|
+
setHighlight(axis: GizmoAxis | null): void;
|
|
86
|
+
/**
|
|
87
|
+
* Begin a drag on a handle.
|
|
88
|
+
*
|
|
89
|
+
* @returns `false` when the gesture cannot be tracked (a near-parallel view
|
|
90
|
+
* of the drag axis), so the caller can ignore the press rather than start a
|
|
91
|
+
* drag that would jump.
|
|
92
|
+
*/
|
|
93
|
+
beginDrag(axis: GizmoAxis, ray: GizmoRay, camera: Camera): boolean;
|
|
94
|
+
/** Raw delta for the current pointer position, or `null` when unusable. */
|
|
95
|
+
updateDrag(ray: GizmoRay, camera: Camera): GizmoDelta | null;
|
|
96
|
+
endDrag(): void;
|
|
97
|
+
get isDragging(): boolean;
|
|
98
|
+
get draggingAxis(): GizmoAxis | null;
|
|
99
|
+
private isPlaneAxis;
|
|
100
|
+
/** Signed angle of the ray's hit point around `normal`, in radians. */
|
|
101
|
+
private angleOnPlane;
|
|
102
|
+
/** Distance from pivot to the ray hit on the camera-facing plane. */
|
|
103
|
+
private cameraPlaneRadius;
|
|
104
|
+
private applyModeVisibility;
|
|
105
|
+
private makeMaterial;
|
|
106
|
+
private track;
|
|
107
|
+
/**
|
|
108
|
+
* An invisible, generously sized mesh used only for hit testing.
|
|
109
|
+
*
|
|
110
|
+
* The visible shafts and rings are a couple of pixels wide, which is
|
|
111
|
+
* miserable to click. The raycaster still reaches `visible: false` meshes,
|
|
112
|
+
* so picking accuracy is decoupled from how thin the handle looks.
|
|
113
|
+
*/
|
|
114
|
+
private makePicker;
|
|
115
|
+
private orientAlongAxis;
|
|
116
|
+
private buildTranslate;
|
|
117
|
+
private positionPlaneHandle;
|
|
118
|
+
private buildRotate;
|
|
119
|
+
private orientRing;
|
|
120
|
+
private buildScale;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { type GizmoAxis as G, TransformGizmo as T, type GizmoDelta as a, type GizmoMode as b, closestAxisValue as c, type GizmoRay as d, intersectPlane as i };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./chunk-2NO4YCLR.js";import{h as i,j as s,k as n}from"./chunk-T6O2SGH5.js";import"./chunk-WOT6VMZA.js";var c=new Set(["usd","usda","usdc","usdz"]),d=class{loaderPromise=null;loader(){return this.loaderPromise??=import("three/addons/loaders/USDLoader.js").then(o=>new o.USDLoader),this.loaderPromise}isSupported(o){let e=n(o);return e!==null&&c.has(e)}async load(o,e){let l=await a(o,e),m=await this.loader(),t=await new Promise((p,r)=>{try{m.parse(l,s(o),p,r)}catch(u){r(u)}});return{object:t,animations:t.animations??[]}}clone(o){return{object:i(o.object),animations:o.animations?.map(e=>e.clone())}}};export{d as USDLoaderAdapter};
|
package/dist/web-components.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { G as Game, D as DeviceProfile } from './game-
|
|
2
|
-
import { v as DebugTools } from './debug-state-
|
|
1
|
+
import { G as Game, D as DeviceProfile } from './game-uQd7k6-m.js';
|
|
2
|
+
import { v as DebugTools } from './debug-state-JRneI6c2.js';
|
|
3
3
|
import './base-node-life-cycle-BK9xebT9.js';
|
|
4
4
|
import 'three';
|
|
5
5
|
import './stage-transition-CmGpV4tc.js';
|
|
6
6
|
import './game-interfaces-vF5sRi1n.js';
|
|
7
7
|
import './base-node-idopiSw5.js';
|
|
8
|
-
import './stage-
|
|
9
|
-
import './entity-type-map-
|
|
10
|
-
import './entity-
|
|
8
|
+
import './stage-Dez16Gxm.js';
|
|
9
|
+
import './entity-type-map-BMaPY8cd.js';
|
|
10
|
+
import './entity-CY75JJSw.js';
|
|
11
11
|
import '@zylem/behaviors/core';
|
|
12
12
|
import './simulation-body-zQw-emOr.js';
|
|
13
13
|
import './vector-D3eDzvcA.js';
|
|
14
|
-
import './material-
|
|
14
|
+
import './material-D1IVeQc5.js';
|
|
15
15
|
import 'three/webgpu';
|
|
16
16
|
import './collision-builder-BckxkdmA.js';
|
|
17
17
|
import './events.js';
|
|
@@ -20,9 +20,10 @@ import './selection-bounds-BKmSo9aG.js';
|
|
|
20
20
|
import './entity-BIf_a4dl.js';
|
|
21
21
|
import '@zylem/behaviors/particle-emitter';
|
|
22
22
|
import 'three/addons/lines/webgpu/Line2.js';
|
|
23
|
-
import './zylem-camera-
|
|
23
|
+
import './zylem-camera-BA3VPFlS.js';
|
|
24
|
+
import './placement-session-BNQoL7Jb.js';
|
|
24
25
|
import '@zylem/bridge';
|
|
25
|
-
import './
|
|
26
|
+
import './transform-gizmo-DappLQ9w.js';
|
|
26
27
|
import './default-controls-CAKJ5zlo.js';
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -514,6 +514,8 @@ declare class ZylemCamera {
|
|
|
514
514
|
* to ignore pointer input while another camera is showing.
|
|
515
515
|
*/
|
|
516
516
|
armEditorOrbit(lockRotation: boolean, screenSpacePan?: boolean): void;
|
|
517
|
+
/** Let this camera orbit below the horizon. Set before controls are created. */
|
|
518
|
+
allowFullOrbit(): void;
|
|
517
519
|
/** Ignore pointer input without disposing orbit controls or their pose. */
|
|
518
520
|
disarmEditorOrbit(): void;
|
|
519
521
|
/**
|
|
@@ -566,6 +568,13 @@ declare class ZylemCamera {
|
|
|
566
568
|
* Seed the debug orbit camera to an initial pose.
|
|
567
569
|
*/
|
|
568
570
|
seedDebugOrbitPose(position: Vector3, lookAt: Vector3): void;
|
|
571
|
+
/** Write an orbit pose even when one was already seeded. */
|
|
572
|
+
replaceOrbitPose(position: Vector3, lookAt: Vector3): void;
|
|
573
|
+
/**
|
|
574
|
+
* Resize an orthographic editor view. `frustumSize` is the visible height;
|
|
575
|
+
* width follows the screen aspect, matching {@link resize}.
|
|
576
|
+
*/
|
|
577
|
+
applyOrthographicFrame(frustumSize: number, near: number, far: number): void;
|
|
569
578
|
/** Whether the debug orbit camera has received its initial pose. */
|
|
570
579
|
isDebugOrbitPoseSeeded(): boolean;
|
|
571
580
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zylem/game-lib",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
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,30 +255,33 @@
|
|
|
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.8",
|
|
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"
|
|
130
270
|
},
|
|
271
|
+
"optionalDependencies": {
|
|
272
|
+
"@playcanvas/splat-transform": "3.10.3"
|
|
273
|
+
},
|
|
131
274
|
"peerDependencies": {
|
|
132
275
|
"howler": "^2.2.4",
|
|
133
276
|
"nanoid": "^5.1.5",
|
|
134
|
-
"three": "^0.
|
|
277
|
+
"three": "^0.187.0",
|
|
135
278
|
"valtio": "^2.1.7"
|
|
136
279
|
},
|
|
137
280
|
"devDependencies": {
|
|
138
281
|
"@microsoft/api-extractor": "^7.58.13",
|
|
139
282
|
"@types/node": "^20.19.43",
|
|
140
283
|
"@types/stats.js": "^0.17.4",
|
|
141
|
-
"@types/three": "^0.
|
|
284
|
+
"@types/three": "^0.187.0",
|
|
142
285
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
143
286
|
"happy-dom": "^18.0.1",
|
|
144
287
|
"jsdom": "^27.2.0",
|
|
@@ -150,7 +293,7 @@
|
|
|
150
293
|
"vitest": "^4.0.18"
|
|
151
294
|
},
|
|
152
295
|
"scripts": {
|
|
153
|
-
"build": "tsup && pnpm api:extract && pnpm api:typedoc && pnpm schema:emit",
|
|
296
|
+
"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
297
|
"dev": "tsup --watch",
|
|
155
298
|
"api:extract": "mkdir -p dist/api temp && api-extractor run --local --verbose",
|
|
156
299
|
"api:typedoc": "mkdir -p dist/api && typedoc --options typedoc.json",
|
package/dist/chunk-47HAZZWF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{GridHelper as O,Group as X}from"three";var R=3094855,V=4871528,q=20,_=class{group=new X;scene=null;fine=null;coarse=null;increment=0;constructor(){this.group.name="__zylem_construction_grid__",this.group.renderOrder=-1,this.group.visible=!1}addTo(t){this.scene!==t&&(this.scene=t,t.add(this.group))}setIncrement(t){t<=0||t===this.increment||(this.increment=t,this.rebuild())}setVisible(t){this.group.visible=t}get visible(){return this.group.visible}dispose(){this.clearHelpers(),this.scene?.remove(this.group),this.scene=null}rebuild(){this.clearHelpers();let t=q*2,i=Math.round(t/this.increment);i>0&&i<=400&&(this.fine=new O(t,i,R,R),this.fine.material.transparent=!0,this.fine.material.opacity=.35,this.fine.material.depthWrite=!1,this.group.add(this.fine)),this.coarse=new O(t,t,V,V),this.coarse.material.transparent=!0,this.coarse.material.opacity=.6,this.coarse.material.depthWrite=!1,this.group.add(this.coarse)}clearHelpers(){for(let t of[this.fine,this.coarse])t&&(this.group.remove(t),t.geometry.dispose(),t.material.dispose());this.fine=null,this.coarse=null}};import{BoxGeometry as y,ConeGeometry as W,CylinderGeometry as f,Group as d,Mesh as m,MeshBasicMaterial as D,PlaneGeometry as C,Quaternion as Q,Raycaster as Z,TorusGeometry as S,Vector3 as l}from"three";var H={x:16726867,y:5036364,z:3900150,xy:3900150,yz:16726867,xz:5036364,xyz:14540253},J=16765499,I=.16,h={x:new l(1,0,0),y:new l(0,1,0),z:new l(0,0,1)},z={xy:new l(0,0,1),yz:new l(1,0,0),xz:new l(0,1,0)},A=12,K=Math.sqrt(1-1/A),G=1/A;function U(a,t){return Math.abs(a.dot(t))>K}function M(a,t,i){let e=k.copy(a.origin).sub(t),o=a.direction.dot(i),s=1-o*o;return s<1/A?null:(e.dot(i)-o*e.dot(a.direction))/s}function x(a,t,i,e){let o=i.dot(a.direction);if(Math.abs(o)<G)return null;let s=k.copy(t).sub(a.origin).dot(i)/o;return s<0?null:e.copy(a.direction).multiplyScalar(s).add(a.origin)}var k=new l,w=new l,Y=new l,j=new l,T=new Q,B=class{root=new d;scene=null;modeGroups={translate:new d,rotate:new d,scale:new d};handles={translate:[],rotate:[],scale:[]};materials=[];geometries=[];mode="translate";highlighted=null;drag=null;raycaster=new Z;constructor(){this.root.name="__zylem_transform_gizmo__",this.root.renderOrder=1e3,this.root.visible=!1,this.buildTranslate(),this.buildRotate(),this.buildScale();for(let t of Object.keys(this.modeGroups))this.root.add(this.modeGroups[t]);this.applyModeVisibility()}addTo(t){this.scene!==t&&(this.scene=t,t.add(this.root))}removeFromScene(){this.scene&&(this.scene.remove(this.root),this.scene=null)}dispose(){this.removeFromScene();for(let t of this.geometries)t.dispose();for(let t of this.materials)t.dispose();this.geometries=[],this.materials=[]}setMode(t){this.mode!==t&&(this.mode=t,this.applyModeVisibility())}getMode(){return this.mode}show(t){this.root.position.copy(t),this.root.visible=!0}hide(){this.root.visible=!1,this.setHighlight(null)}get visible(){return this.root.visible}get pivot(){return this.root.position}update(t){if(!this.root.visible)return;let i;if(t.isPerspectiveCamera){let e=t;j.setFromMatrixPosition(e.matrixWorld),i=2*j.distanceTo(this.root.position)*Math.tan(e.fov*Math.PI/360)*I}else if(t.isOrthographicCamera){let e=t;i=(e.top-e.bottom)/(e.zoom||1)*I}else i=1;this.root.scale.setScalar(Math.max(i,1e-4))}pick(t){if(!this.root.visible)return null;this.raycaster.set(t.origin,t.direction);let i=this.handles[this.mode].filter(o=>this.isHandleDraggable(o.axis,t)).map(o=>o.picker),e=this.raycaster.intersectObjects(i,!1);return e.length?e[0].object.userData.gizmoAxis??null:null}isHandleDraggable(t,i){if(t==="xyz")return!0;if(this.isPlaneAxis(t))return Math.abs(i.direction.dot(z[t]))>=G;let e=h[t];return this.mode==="rotate"?Math.abs(i.direction.dot(e))>=G:!U(i.direction,e)}setHighlight(t){if(this.highlighted!==t){this.highlighted=t;for(let i of Object.keys(this.handles))for(let e of this.handles[i]){let o=e.axis===t?J:H[e.axis];for(let s of e.visuals)s.material.color.setHex(o)}}}beginDrag(t,i,e){let o=this.root.position.clone(),s={axis:t,mode:this.mode,pivot:o,startAxisValue:0,startPoint:new l,startAngle:0,startRadius:0};if(t==="xyz"){let r=this.cameraPlaneRadius(i,o,e);if(r===null||r<1e-4)return!1;s.startRadius=r}else if(this.isPlaneAxis(t)){let r=z[t];if(!x(i,o,r,s.startPoint))return!1}else if(this.mode==="rotate"){let r=h[t],n=this.angleOnPlane(i,o,r);if(n===null)return!1;s.startAngle=n}else{let r=M(i,o,h[t]);if(r===null||(s.startAxisValue=r,this.mode==="scale"&&Math.abs(r)<1e-4))return!1}return this.drag=s,this.setHighlight(t),!0}updateDrag(t,i){let e=this.drag;if(!e)return null;if(e.mode==="rotate"){let r=h[e.axis]??h.y,n=this.angleOnPlane(t,e.pivot,r);return n===null?null:{kind:"rotate",axis:r.clone(),angle:n-e.startAngle}}if(e.mode==="scale"){if(e.axis==="xyz"){let u=this.cameraPlaneRadius(t,e.pivot,i);if(u===null)return null;let p=u/e.startRadius;return{kind:"scale",factor:new l(p,p,p)}}let r=M(t,e.pivot,h[e.axis]);if(r===null)return null;let n=r/e.startAxisValue,c=new l(1,1,1);return c[e.axis]=n,{kind:"scale",factor:c}}if(this.isPlaneAxis(e.axis)){let r=z[e.axis],n=x(t,e.pivot,r,w);return n?{kind:"translate",offset:n.clone().sub(e.startPoint)}:null}let o=h[e.axis],s=M(t,e.pivot,o);return s===null?null:{kind:"translate",offset:o.clone().multiplyScalar(s-e.startAxisValue)}}endDrag(){this.drag=null,this.setHighlight(null)}get isDragging(){return this.drag!==null}get draggingAxis(){return this.drag?.axis??null}isPlaneAxis(t){return t==="xy"||t==="yz"||t==="xz"}angleOnPlane(t,i,e){let o=x(t,i,e,w);if(!o)return null;let s=Y.copy(o).sub(i);if(s.lengthSq()<1e-8)return null;let r=Math.abs(e.y)>.9?h.x:h.y,n=k.copy(r).cross(e).normalize(),c=new l().copy(e).cross(n);return Math.atan2(s.dot(c),s.dot(n))}cameraPlaneRadius(t,i,e){T.setFromRotationMatrix(e.matrixWorld);let o=new l(0,0,1).applyQuaternion(T),s=x(t,i,o,w);return s?s.distanceTo(i):null}applyModeVisibility(){for(let t of Object.keys(this.modeGroups))this.modeGroups[t].visible=t===this.mode}makeMaterial(t,i){let e=new D({color:H[t],transparent:!0,opacity:i,depthTest:!1,depthWrite:!1,toneMapped:!1});return this.materials.push(e),e}track(t){return this.geometries.push(t),t}makePicker(t,i,e){let o=new D({visible:!1});this.materials.push(o);let s=new m(this.track(i),o);return s.visible=!1,s.userData.gizmoAxis=t,e(s),s}orientAlongAxis(t,i){i==="x"&&(t.rotation.z=-Math.PI/2),i==="z"&&(t.rotation.x=Math.PI/2)}buildTranslate(){let t=this.modeGroups.translate;for(let i of["x","y","z"]){let e=this.makeMaterial(i,1),o=new m(this.track(new f(.012,.012,.7,8)),e);o.position.y=.35;let s=new m(this.track(new W(.045,.16,12)),e);s.position.y=.78;let r=new d;r.add(o,s),this.orientAlongAxis(r,i);let n=this.makePicker(i,new f(.1,.1,.9,6),u=>{u.position.y=.45}),c=new d;c.add(n),this.orientAlongAxis(c,i),t.add(r,c),this.handles.translate.push({axis:i,visuals:[o,s],picker:n})}for(let i of["xy","yz","xz"]){let e=this.makeMaterial(i,.35),o=new m(this.track(new C(.22,.22)),e);this.positionPlaneHandle(o,i);let s=this.makePicker(i,new C(.22,.22),r=>{this.positionPlaneHandle(r,i)});t.add(o,s),this.handles.translate.push({axis:i,visuals:[o],picker:s})}}positionPlaneHandle(t,i){i==="xy"?t.position.set(.28,.28,0):i==="yz"?(t.position.set(0,.28,.28),t.rotation.y=Math.PI/2):(t.position.set(.28,0,.28),t.rotation.x=-Math.PI/2)}buildRotate(){let t=this.modeGroups.rotate;for(let i of["x","y","z"]){let e=this.makeMaterial(i,1),o=new m(this.track(new S(.68,.01,6,64)),e);this.orientRing(o,i);let s=this.makePicker(i,new S(.68,.08,4,24),r=>this.orientRing(r,i));t.add(o,s),this.handles.rotate.push({axis:i,visuals:[o],picker:s})}}orientRing(t,i){i==="x"&&(t.rotation.y=Math.PI/2),i==="y"&&(t.rotation.x=Math.PI/2)}buildScale(){let t=this.modeGroups.scale;for(let s of["x","y","z"]){let r=this.makeMaterial(s,1),n=new m(this.track(new f(.012,.012,.7,8)),r);n.position.y=.35;let c=new m(this.track(new y(.09,.09,.09)),r);c.position.y=.74;let u=new d;u.add(n,c),this.orientAlongAxis(u,s);let p=this.makePicker(s,new f(.1,.1,.85,6),F=>{F.position.y=.43}),b=new d;b.add(p),this.orientAlongAxis(b,s),t.add(u,b),this.handles.scale.push({axis:s,visuals:[n,c],picker:p})}let i=this.makeMaterial("xyz",.9),e=new m(this.track(new y(.13,.13,.13)),i),o=this.makePicker("xyz",new y(.22,.22,.22),()=>{});t.add(e,o),this.handles.scale.push({axis:"xyz",visuals:[e],picker:o})}};import{Box3 as $,OrthographicCamera as tt,PerspectiveCamera as et,Vector3 as v}from"three";var P=new $,g=new v,E=new v,it=new v;function N(a){P.setFromObject(a),P.getSize(g),P.getCenter(E);let t=Math.max(g.x,1e-4),i=Math.max(g.y,1e-4),e=Math.max(g.z,1e-4),o=Math.max(t,i,e);return{width:t,height:i,depth:e,center:E.clone(),maxDim:o}}function L(a,t,i=1.35){let e=t.fov*(Math.PI/180),o=a/(2*Math.tan(e/2))*i;return Math.max(o,.5)}function ht(a,t,i=1.35){let e=N(a),o=L(e.maxDim,t,i);return t.position.copy(e.center).add(new v(o,o,o)),t.lookAt(e.center),t.near=Math.max(o/100,.01),t.far=Math.max(o*20,100),t.updateProjectionMatrix(),e}function ut(a,t,i,e=1.5){let o=N(a),s=it.copy(i);s.lengthSq()<1e-8&&s.set(1,1,1),s.normalize();let r=o.maxDim*e;if(t instanceof et)r=L(o.maxDim,t,e),t.near=Math.max(r/100,.01),t.far=Math.max(r*20,100),t.updateProjectionMatrix();else if(t instanceof tt){let n=Math.max(t.top-t.bottom,1e-4);t.zoom=n/Math.max(o.maxDim*e,1e-4),t.near=.1,t.far=Math.max(o.maxDim*50,1e3),t.updateProjectionMatrix()}return t.position.copy(o.center).addScaledVector(s,r),t.lookAt(o.center),o}export{ht as a,ut as b,_ as c,M as d,x as e,B as f};
|
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};
|