@holtjs/stage 0.0.0-stage → 0.3.0
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/CHANGELOG.md +62 -0
- package/LICENSE +201 -0
- package/NOTICE +13 -0
- package/README.md +172 -2
- package/dist/audio.d.ts +159 -0
- package/dist/audio.js +781 -0
- package/dist/ecs.d.ts +172 -0
- package/dist/ecs.js +537 -0
- package/dist/flex.d.ts +113 -0
- package/dist/flex.js +426 -0
- package/dist/game-BHDcwovp.js +6725 -0
- package/dist/game-NqFMKsuL.d.ts +1205 -0
- package/dist/headless.d.ts +147 -0
- package/dist/headless.js +327 -0
- package/dist/hit.d.ts +63 -0
- package/dist/hit.js +185 -0
- package/dist/index.d.ts +307 -0
- package/dist/index.js +45 -0
- package/dist/joystick.d.ts +233 -0
- package/dist/joystick.js +763 -0
- package/dist/nav.d.ts +119 -0
- package/dist/nav.js +342 -0
- package/dist/particles.d.ts +219 -0
- package/dist/particles.js +478 -0
- package/dist/spatial.d.ts +70 -0
- package/dist/spatial.js +165 -0
- package/dist/surfaces.d.ts +209 -0
- package/dist/surfaces.js +567 -0
- package/dist/trace.d.ts +143 -0
- package/dist/trace.js +246 -0
- package/dist/tween-D3Ztppuz.d.ts +91 -0
- package/dist/tween.d.ts +2 -0
- package/dist/tween.js +312 -0
- package/dist/types-ChGhuDNX.js +165 -0
- package/llms.txt +40 -0
- package/package.json +107 -4
- package/skills/stage/SKILL.md +282 -0
- package/skills/stage/references/subpaths.md +74 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { O as Container, V as PanelObject, u as Scene, y as Pointer } from "./game-NqFMKsuL.js";
|
|
2
|
+
export type VirtualJoystickMode = 'floating' | 'fixed';
|
|
3
|
+
export interface JoystickVector {
|
|
4
|
+
/** Normalized X axis in [-1, 1] after deadzone remapping. */
|
|
5
|
+
x: number;
|
|
6
|
+
/** Normalized Y axis in [-1, 1] after deadzone remapping. */
|
|
7
|
+
y: number;
|
|
8
|
+
/** Normalized magnitude in [0, 1] after deadzone remapping. */
|
|
9
|
+
magnitude: number;
|
|
10
|
+
/** Direction in radians (`Math.atan2(y, x)`), or `0` when inside deadzone. */
|
|
11
|
+
angle: number;
|
|
12
|
+
/** Raw Euclidean distance from origin before clamping. */
|
|
13
|
+
rawDistance: number;
|
|
14
|
+
/** Clamped visual knob X offset relative to base origin. */
|
|
15
|
+
knobDx: number;
|
|
16
|
+
/** Clamped visual knob Y offset relative to base origin. */
|
|
17
|
+
knobDy: number;
|
|
18
|
+
}
|
|
19
|
+
export interface JoystickState extends JoystickVector {
|
|
20
|
+
active: boolean;
|
|
21
|
+
pointerId: number | null;
|
|
22
|
+
originX: number;
|
|
23
|
+
originY: number;
|
|
24
|
+
knobX: number;
|
|
25
|
+
knobY: number;
|
|
26
|
+
}
|
|
27
|
+
export interface JoystickZoneRect {
|
|
28
|
+
/** Left bound: pixels (> 1) or viewport fraction (<= 1, e.g. `0.55`). */
|
|
29
|
+
left?: number;
|
|
30
|
+
top?: number;
|
|
31
|
+
right?: number;
|
|
32
|
+
bottom?: number;
|
|
33
|
+
}
|
|
34
|
+
export type JoystickZonePredicate = (x: number, y: number, viewW: number, viewH: number) => boolean;
|
|
35
|
+
export type JoystickZone = JoystickZoneRect | JoystickZonePredicate;
|
|
36
|
+
export interface JoystickViewport {
|
|
37
|
+
w: number;
|
|
38
|
+
h: number;
|
|
39
|
+
safeLeft?: number;
|
|
40
|
+
safeRight?: number;
|
|
41
|
+
safeTop?: number;
|
|
42
|
+
safeBottom?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface VirtualJoystickStyle {
|
|
45
|
+
baseFill?: number;
|
|
46
|
+
baseAlpha?: number;
|
|
47
|
+
baseBorder?: number;
|
|
48
|
+
baseBorderAlpha?: number;
|
|
49
|
+
baseBorderWidth?: number;
|
|
50
|
+
innerRingColor?: number;
|
|
51
|
+
innerRingAlpha?: number;
|
|
52
|
+
knobFill?: number;
|
|
53
|
+
knobAlpha?: number;
|
|
54
|
+
knobBorder?: number;
|
|
55
|
+
knobBorderAlpha?: number;
|
|
56
|
+
knobBorderWidth?: number;
|
|
57
|
+
activeKnobFill?: number;
|
|
58
|
+
activeKnobAlpha?: number;
|
|
59
|
+
activeKnobBorder?: number;
|
|
60
|
+
activeKnobBorderAlpha?: number;
|
|
61
|
+
tickColor?: number;
|
|
62
|
+
tickAlpha?: number;
|
|
63
|
+
tickActiveColor?: number;
|
|
64
|
+
tickActiveBorder?: number;
|
|
65
|
+
idleAlpha?: number;
|
|
66
|
+
activeAlpha?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface JoystickDpad {
|
|
69
|
+
readonly up: boolean;
|
|
70
|
+
readonly down: boolean;
|
|
71
|
+
readonly left: boolean;
|
|
72
|
+
readonly right: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface JoystickDpadOptions {
|
|
75
|
+
/** Minimum unit-axis projection (`0.1..0.95`) required to engage an axis in 8-way mode. Default `0.44`. */
|
|
76
|
+
axisThreshold?: number;
|
|
77
|
+
/** Optional previous D-pad state for boundary hysteresis so near-border angles never flicker. */
|
|
78
|
+
prev?: JoystickDpad | null;
|
|
79
|
+
/** Projection hysteresis margin (`0..0.25`) around `axisThreshold` when `prev` is provided. Default `0.06`. */
|
|
80
|
+
hysteresis?: number;
|
|
81
|
+
/** Force strictly 4-way cardinal output (no diagonals). Default `false`. */
|
|
82
|
+
fourWay?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface VirtualJoystickOptions {
|
|
85
|
+
mode?: VirtualJoystickMode;
|
|
86
|
+
/** Initial / fixed center X (in CSS/screen coordinates matching `coordScale`). */
|
|
87
|
+
x?: number;
|
|
88
|
+
/** Initial / fixed center Y (in CSS/screen coordinates matching `coordScale`). */
|
|
89
|
+
y?: number;
|
|
90
|
+
/** Visual base ring radius (px). Default `52`. */
|
|
91
|
+
baseRadius?: number;
|
|
92
|
+
/** Max travel radius of the thumb knob center (px). Defaults to `baseRadius`. */
|
|
93
|
+
maxTravel?: number;
|
|
94
|
+
/** Visual thumb knob radius (px). Default `22`. */
|
|
95
|
+
knobRadius?: number;
|
|
96
|
+
/** Deadzone as a fraction of `maxTravel` (`0..0.95`). Default `0.12`. */
|
|
97
|
+
deadzone?: number;
|
|
98
|
+
/** Render a subtle concentric inner guide ring inside the base & thumb cap. Default `false`. */
|
|
99
|
+
innerRing?: boolean;
|
|
100
|
+
/** Render 4 cardinal direction indicator pips (N/S/E/W) inside the base rim. Default `false`. */
|
|
101
|
+
cardinalTicks?: boolean;
|
|
102
|
+
/** In `floating` mode, smoothly pull origin when thumb drags past `maxTravel + followSlack`. */
|
|
103
|
+
follow?: boolean;
|
|
104
|
+
/** Extra travel past `maxTravel` before origin starts following (px). Default `12`. */
|
|
105
|
+
followSlack?: number;
|
|
106
|
+
/** Hit radius around fixed center (px). Defaults to `baseRadius * 1.45`. */
|
|
107
|
+
captureRadius?: number;
|
|
108
|
+
/** Capture region in `floating` mode. Defaults to left 55% of viewport. */
|
|
109
|
+
zone?: JoystickZone;
|
|
110
|
+
/** Optional guard invoked before capturing a pointer (return `false` to let HUD/buttons take priority). */
|
|
111
|
+
canCapture?: (pointer: Pointer, x: number, y: number) => boolean;
|
|
112
|
+
/** When `true`, only touch pointers (`pointer.wasTouch`) activate the joystick. Default `false`. */
|
|
113
|
+
touchOnly?: boolean;
|
|
114
|
+
/** Scale factor dividing Stage2D `Pointer.x/y` into screen/UI coordinates. Defaults to `scene.dpr || 1`. */
|
|
115
|
+
coordScale?: () => number;
|
|
116
|
+
/** Viewport size & safe areas for clamping floating origins. */
|
|
117
|
+
viewport?: () => JoystickViewport;
|
|
118
|
+
/** Optional parent Container (e.g. a UiRoot HUD layer). If omitted, mounts directly on the Scene. */
|
|
119
|
+
parent?: Container | null;
|
|
120
|
+
/** Display depth when mounted directly on the Scene. Default `3_500_000`. */
|
|
121
|
+
depth?: number;
|
|
122
|
+
/** Skip visual SDF panels (input-only mode for custom game art). */
|
|
123
|
+
headless?: boolean;
|
|
124
|
+
style?: VirtualJoystickStyle;
|
|
125
|
+
trackId?: string | null;
|
|
126
|
+
surface?: string | null;
|
|
127
|
+
onStart?: (state: Readonly<JoystickState>) => void;
|
|
128
|
+
onChange?: (state: Readonly<JoystickState>) => void;
|
|
129
|
+
onEnd?: (state: Readonly<JoystickState>) => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Pure radial deadzone & clamping math for a virtual joystick.
|
|
133
|
+
* Inside `deadzone * maxRadius`, returns zero output; outside, smoothly remaps magnitude across `[0, 1]`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function computeJoystickVector(dx: number, dy: number, maxRadius: number, deadzone?: number): JoystickVector;
|
|
136
|
+
/** Test whether screen-space point `(x, y)` lies inside a `JoystickZone` rect or predicate. */
|
|
137
|
+
export declare function isInJoystickZone(zone: JoystickZone, x: number, y: number, w: number, h: number): boolean;
|
|
138
|
+
/** Clamp a floating joystick origin cleanly within viewport bounds + safe-area insets + `margin`. */
|
|
139
|
+
export declare function clampJoystickOrigin(x: number, y: number, margin: number, vp: JoystickViewport): {
|
|
140
|
+
x: number;
|
|
141
|
+
y: number;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Pull a floating/follow joystick origin along whenever the pointer `(px, py)` extends past `pullRadius`,
|
|
145
|
+
* optionally clamping the new origin via `clamp`.
|
|
146
|
+
*/
|
|
147
|
+
export declare function pullJoystickOrigin(originX: number, originY: number, px: number, py: number, pullRadius: number, clamp?: (x: number, y: number) => {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
}): {
|
|
151
|
+
originX: number;
|
|
152
|
+
originY: number;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Quantize a normalized joystick vector into crisp 8-way (or 4-way) directional booleans with
|
|
156
|
+
* optional hysteresis so dragging smoothly around the rim never flickers on sector boundaries.
|
|
157
|
+
*/
|
|
158
|
+
export declare function quantizeJoystickDpad(v: Pick<JoystickVector, 'x' | 'y' | 'magnitude'>, opts?: JoystickDpadOptions): JoystickDpad;
|
|
159
|
+
export declare class VirtualJoystick {
|
|
160
|
+
readonly scene: Scene;
|
|
161
|
+
readonly container: Container | null;
|
|
162
|
+
readonly basePanel: PanelObject | null;
|
|
163
|
+
readonly knobPanel: PanelObject | null;
|
|
164
|
+
readonly mode: VirtualJoystickMode;
|
|
165
|
+
readonly baseRadius: number;
|
|
166
|
+
readonly maxTravel: number;
|
|
167
|
+
readonly knobRadius: number;
|
|
168
|
+
readonly deadzone: number;
|
|
169
|
+
readonly follow: boolean;
|
|
170
|
+
readonly followSlack: number;
|
|
171
|
+
readonly captureRadius: number;
|
|
172
|
+
readonly touchOnly: boolean;
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
destroyed: boolean;
|
|
175
|
+
private readonly state;
|
|
176
|
+
private zone;
|
|
177
|
+
private readonly canCapture?;
|
|
178
|
+
private readonly getScale;
|
|
179
|
+
private readonly getViewport;
|
|
180
|
+
private readonly resolvedStyle;
|
|
181
|
+
private readonly knobGroup;
|
|
182
|
+
private readonly innerRingPanel;
|
|
183
|
+
private readonly knobInnerPanel;
|
|
184
|
+
private readonly tickPanels;
|
|
185
|
+
private highlightSig;
|
|
186
|
+
private highlightedDpad;
|
|
187
|
+
private readonly startListeners;
|
|
188
|
+
private readonly changeListeners;
|
|
189
|
+
private readonly endListeners;
|
|
190
|
+
private fadeTween;
|
|
191
|
+
private springX;
|
|
192
|
+
private springY;
|
|
193
|
+
private readonly handleDown;
|
|
194
|
+
private readonly handleMove;
|
|
195
|
+
private readonly handleUp;
|
|
196
|
+
private readonly handleSceneDestroy;
|
|
197
|
+
private detachContainerDispose;
|
|
198
|
+
constructor(scene: Scene, opts?: VirtualJoystickOptions);
|
|
199
|
+
/** Live read-only snapshot of joystick output (zero allocation). */
|
|
200
|
+
get value(): Readonly<JoystickState>;
|
|
201
|
+
get active(): boolean;
|
|
202
|
+
get x(): number;
|
|
203
|
+
get y(): number;
|
|
204
|
+
get magnitude(): number;
|
|
205
|
+
get angle(): number;
|
|
206
|
+
get pointerId(): number | null;
|
|
207
|
+
onStart(fn: (state: Readonly<JoystickState>) => void): () => void;
|
|
208
|
+
onChange(fn: (state: Readonly<JoystickState>) => void): () => void;
|
|
209
|
+
onEnd(fn: (state: Readonly<JoystickState>) => void): () => void;
|
|
210
|
+
setZone(zone: JoystickZone): this;
|
|
211
|
+
/** Hot-update visual palette (e.g. Data Pack `touchTheme` changes) without recreating the joystick. */
|
|
212
|
+
setStyle(patch: VirtualJoystickStyle): this;
|
|
213
|
+
/** Highlight active cardinal rim ticks (when constructed with `cardinalTicks: true`). */
|
|
214
|
+
setCardinalHighlight(dpad: JoystickDpad | null): this;
|
|
215
|
+
setPosition(x: number, y: number): this;
|
|
216
|
+
setEnabled(on: boolean): this;
|
|
217
|
+
/** Force-release any captured finger and zero the vector. */
|
|
218
|
+
reset(): this;
|
|
219
|
+
private wakeScene;
|
|
220
|
+
private syncKnobStyle;
|
|
221
|
+
private syncTickStyles;
|
|
222
|
+
private toScreen;
|
|
223
|
+
private clampOrigin;
|
|
224
|
+
private stopAnimations;
|
|
225
|
+
private onPointerDown;
|
|
226
|
+
private onPointerMove;
|
|
227
|
+
private onPointerUp;
|
|
228
|
+
private updateFromPoint;
|
|
229
|
+
private release;
|
|
230
|
+
private emit;
|
|
231
|
+
private teardown;
|
|
232
|
+
destroy(): void;
|
|
233
|
+
}
|