@woosh/meep-engine 2.159.0 → 2.161.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/package.json +1 -1
- package/src/engine/.fuse_hidden0000001500000001 +581 -0
- package/src/engine/Engine.d.ts.map +1 -1
- package/src/engine/Engine.js +4 -1
- package/src/engine/graphics/ecs/path/tube/build/compute_smooth_profile_normals.d.ts +8 -0
- package/src/engine/graphics/ecs/path/tube/build/compute_smooth_profile_normals.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/compute_smooth_profile_normals.js +27 -20
- package/src/engine/graphics/ecs/path/tube/build/fix_shape_normal_order.d.ts +11 -5
- package/src/engine/graphics/ecs/path/tube/build/fix_shape_normal_order.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/fix_shape_normal_order.js +25 -31
- package/src/engine/graphics/ecs/path/tube/build/make_cap.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/make_cap.js +25 -0
- package/src/engine/input/devices/GamepadDevice.d.ts +26 -0
- package/src/engine/input/devices/GamepadDevice.d.ts.map +1 -0
- package/src/engine/input/devices/GamepadDevice.js +280 -0
- package/src/engine/input/devices/events/GamepadEvents.d.ts +10 -0
- package/src/engine/input/devices/events/GamepadEvents.d.ts.map +1 -0
- package/src/engine/input/devices/events/GamepadEvents.js +10 -0
- package/src/engine/input/devices/gamepad/GamepadAxes.d.ts +14 -0
- package/src/engine/input/devices/gamepad/GamepadAxes.d.ts.map +1 -0
- package/src/engine/input/devices/gamepad/GamepadAxes.js +15 -0
- package/src/engine/input/devices/gamepad/GamepadButtons.d.ts +28 -0
- package/src/engine/input/devices/gamepad/GamepadButtons.d.ts.map +1 -0
- package/src/engine/input/devices/gamepad/GamepadButtons.js +29 -0
- package/src/engine/input/devices/gamepad/GamepadHandle.d.ts +29 -0
- package/src/engine/input/devices/gamepad/GamepadHandle.d.ts.map +1 -0
- package/src/engine/input/devices/gamepad/GamepadHandle.js +232 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GamepadHandle.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/gamepad/GamepadHandle.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH;IAEI;;;OAGG;IACH,OAFU,MAAM,CAEL;IAEX;;;OAGG;IACH,IAFU,MAAM,CAER;IAER;;;;OAIG;IACH,SAFU,MAAM,CAEH;IAEb;;;;OAIG;IACH,WAFU,OAAO,CAEC;IAElB;;OAEG;IACH;QACI;;;WAGG;cADO,OAAO,MAAM,CAAC;QAGxB;;;WAGG;YADO,OAAO,MAAM,CAAC;QAGxB;;;WAGG;cADO,OAAO,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;MAG1C;IAEF;;;;;;;;;;OAUG;IACH,kBALU,iBAAiB,EAAE,CAKhB;IAEb;;;;;OAKG;IACH,uBAFU,MAAM,EAAE,CAEA;IAElB;;;;;OAKG;IACH,eAFU,MAAM,EAAE,CAER;IAEV;;;;OAIG;IACH,oBAFU,OAAO,CAES;IAE1B;;;;OAIG;IACH,qBAFU,OAAO,CAEU;IAE3B;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,iBAAiB,CAa7B;IAED;;;;;OAKG;IACH,eAHW,OAAO,aACP,MAAM,QAkEhB;IAED;;;OAGG;IACH,cA+BE;CACL;mBAvOkB,0CAA0C;kCAE3B,yBAAyB;oBADvC,kCAAkC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
2
|
+
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
3
|
+
import { InputDeviceSwitch } from "../InputDeviceSwitch.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* State of a single physical gamepad.
|
|
7
|
+
* Native {@link Gamepad} objects are immutable snapshots in most browsers, this class provides a stable, observable
|
|
8
|
+
* representation that is refreshed from those snapshots via {@link GamepadHandle#update}.
|
|
9
|
+
*
|
|
10
|
+
* @author Alex Goldring
|
|
11
|
+
* @copyright Company Named Limited (c) 2026
|
|
12
|
+
*/
|
|
13
|
+
export class GamepadHandle {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Index of the gamepad within {@link Navigator.getGamepads} list
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
19
|
+
index = -1;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Identification string of the hardware, contents are browser-specific
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
id = "";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Button/axis layout, "standard" for the standard mapping
|
|
29
|
+
* see https://w3c.github.io/gamepad/#remapping
|
|
30
|
+
* @type {string}
|
|
31
|
+
*/
|
|
32
|
+
mapping = "";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether the gamepad is currently connected
|
|
36
|
+
* Do not modify directly
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
connected = false;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @readonly
|
|
43
|
+
*/
|
|
44
|
+
on = {
|
|
45
|
+
/**
|
|
46
|
+
* Fires when any button is pressed, dispatches button index
|
|
47
|
+
* @type {Signal<number>}
|
|
48
|
+
*/
|
|
49
|
+
down: new Signal(),
|
|
50
|
+
/**
|
|
51
|
+
* Fires when any button is released, dispatches button index
|
|
52
|
+
* @type {Signal<number>}
|
|
53
|
+
*/
|
|
54
|
+
up: new Signal(),
|
|
55
|
+
/**
|
|
56
|
+
* Fires when an axis value changes, dispatches (axisIndex, value, previousValue)
|
|
57
|
+
* @type {Signal<number, number, number>}
|
|
58
|
+
*/
|
|
59
|
+
axis: new Signal()
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Individual button switches, indexed by button index.
|
|
64
|
+
* For the standard mapping, see {@link GamepadButtons} for valid indices.
|
|
65
|
+
* Populated lazily as buttons are observed; use {@link GamepadHandle#getButton} for safe access.
|
|
66
|
+
*
|
|
67
|
+
* @readonly
|
|
68
|
+
* @type {InputDeviceSwitch[]}
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const is_jumping = pad.buttons[GamepadButtons.a]?.is_down;
|
|
72
|
+
*/
|
|
73
|
+
buttons = [];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Analog values of the buttons in the range [0,1], indexed by button index.
|
|
77
|
+
* Useful for analog triggers.
|
|
78
|
+
* @readonly
|
|
79
|
+
* @type {number[]}
|
|
80
|
+
*/
|
|
81
|
+
buttonValues = [];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Axis values in the range [-1,1], after dead-zone filtering.
|
|
85
|
+
* For the standard mapping, see {@link GamepadAxes} for valid indices.
|
|
86
|
+
* @readonly
|
|
87
|
+
* @type {number[]}
|
|
88
|
+
*/
|
|
89
|
+
axes = [];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Convenience accessor for axes 0 and 1 of the standard mapping
|
|
93
|
+
* @readonly
|
|
94
|
+
* @type {Vector2}
|
|
95
|
+
*/
|
|
96
|
+
stickLeft = new Vector2();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Convenience accessor for axes 2 and 3 of the standard mapping
|
|
100
|
+
* @readonly
|
|
101
|
+
* @type {Vector2}
|
|
102
|
+
*/
|
|
103
|
+
stickRight = new Vector2();
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Returns switch for a given button index, creating it if it doesn't exist yet
|
|
107
|
+
*
|
|
108
|
+
* @param {number} index
|
|
109
|
+
* @returns {InputDeviceSwitch}
|
|
110
|
+
*/
|
|
111
|
+
getButton(index) {
|
|
112
|
+
let button = this.buttons[index];
|
|
113
|
+
|
|
114
|
+
if (button === undefined) {
|
|
115
|
+
button = new InputDeviceSwitch();
|
|
116
|
+
|
|
117
|
+
this.buttons[index] = button;
|
|
118
|
+
this.buttonValues[index] = 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return button;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Refresh state from a native {@link Gamepad} snapshot
|
|
126
|
+
*
|
|
127
|
+
* @param {Gamepad} source native gamepad object
|
|
128
|
+
* @param {number} [deadZone] axis values with magnitude below this are clamped to 0
|
|
129
|
+
*/
|
|
130
|
+
update(source, deadZone = 0) {
|
|
131
|
+
|
|
132
|
+
this.index = source.index;
|
|
133
|
+
this.id = source.id;
|
|
134
|
+
this.mapping = source.mapping;
|
|
135
|
+
|
|
136
|
+
// buttons
|
|
137
|
+
const sourceButtons = source.buttons;
|
|
138
|
+
const buttonCount = sourceButtons.length;
|
|
139
|
+
|
|
140
|
+
for (let i = 0; i < buttonCount; i++) {
|
|
141
|
+
const sourceButton = sourceButtons[i];
|
|
142
|
+
|
|
143
|
+
const button = this.getButton(i);
|
|
144
|
+
|
|
145
|
+
this.buttonValues[i] = sourceButton.value;
|
|
146
|
+
|
|
147
|
+
if (sourceButton.pressed) {
|
|
148
|
+
|
|
149
|
+
if (button.is_up) {
|
|
150
|
+
button.press();
|
|
151
|
+
|
|
152
|
+
this.on.down.send1(i);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
} else if (button.is_down) {
|
|
156
|
+
button.release();
|
|
157
|
+
|
|
158
|
+
this.on.up.send1(i);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// axes
|
|
163
|
+
const sourceAxes = source.axes;
|
|
164
|
+
const axisCount = sourceAxes.length;
|
|
165
|
+
|
|
166
|
+
for (let i = 0; i < axisCount; i++) {
|
|
167
|
+
let value = sourceAxes[i];
|
|
168
|
+
|
|
169
|
+
if (Math.abs(value) < deadZone) {
|
|
170
|
+
// inside dead-zone, treat as neutral
|
|
171
|
+
value = 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const oldValue = this.axes[i] !== undefined ? this.axes[i] : 0;
|
|
175
|
+
|
|
176
|
+
if (value !== oldValue) {
|
|
177
|
+
this.axes[i] = value;
|
|
178
|
+
|
|
179
|
+
this.on.axis.send3(i, value, oldValue);
|
|
180
|
+
} else {
|
|
181
|
+
this.axes[i] = value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this.stickLeft.set(
|
|
186
|
+
this.axes[0] !== undefined ? this.axes[0] : 0,
|
|
187
|
+
this.axes[1] !== undefined ? this.axes[1] : 0
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
this.stickRight.set(
|
|
191
|
+
this.axes[2] !== undefined ? this.axes[2] : 0,
|
|
192
|
+
this.axes[3] !== undefined ? this.axes[3] : 0
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Release all buttons and reset axes to neutral.
|
|
198
|
+
* Used when the gamepad disconnects, to avoid inputs getting "stuck" in pressed state.
|
|
199
|
+
*/
|
|
200
|
+
reset() {
|
|
201
|
+
const buttons = this.buttons;
|
|
202
|
+
const n = buttons.length;
|
|
203
|
+
|
|
204
|
+
for (let i = 0; i < n; i++) {
|
|
205
|
+
const button = buttons[i];
|
|
206
|
+
|
|
207
|
+
if (button !== undefined && button.is_down) {
|
|
208
|
+
button.release();
|
|
209
|
+
|
|
210
|
+
this.on.up.send1(i);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this.buttonValues[i] = 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const axes = this.axes;
|
|
217
|
+
const m = axes.length;
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < m; i++) {
|
|
220
|
+
const oldValue = axes[i];
|
|
221
|
+
|
|
222
|
+
if (oldValue !== 0) {
|
|
223
|
+
axes[i] = 0;
|
|
224
|
+
|
|
225
|
+
this.on.axis.send3(i, 0, oldValue);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.stickLeft.set(0, 0);
|
|
230
|
+
this.stickRight.set(0, 0);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -64,11 +64,11 @@ export class FluidObstacleSystem extends System<any, any, any, any, any> {
|
|
|
64
64
|
/**
|
|
65
65
|
* @param {FluidComponent} fluid
|
|
66
66
|
*/
|
|
67
|
-
static "__#
|
|
67
|
+
static "__#144@#refresh_masks"(fluid: FluidComponent): void;
|
|
68
68
|
/**
|
|
69
69
|
* @param {FluidComponent} fluid
|
|
70
70
|
*/
|
|
71
|
-
static "__#
|
|
71
|
+
static "__#144@#clear_field"(fluid: FluidComponent): void;
|
|
72
72
|
/**
|
|
73
73
|
* Mark every cell of `fluid` whose centre lies within `inflation` of the
|
|
74
74
|
* posed shape as solid. Iteration is clipped to the shape's world AABB
|
|
@@ -80,7 +80,7 @@ export class FluidObstacleSystem extends System<any, any, any, any, any> {
|
|
|
80
80
|
* @param {number} inflation world-units SDF threshold
|
|
81
81
|
* @param {Float64Array} point length-3 scratch
|
|
82
82
|
*/
|
|
83
|
-
static "__#
|
|
83
|
+
static "__#144@#voxelize"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array): void;
|
|
84
84
|
/**
|
|
85
85
|
* Write the obstacle's translation velocity onto every face of every cell
|
|
86
86
|
* it voxelized — the moving-wall boundary condition. Runs AFTER the mask
|
|
@@ -100,7 +100,7 @@ export class FluidObstacleSystem extends System<any, any, any, any, any> {
|
|
|
100
100
|
* @param {number} wvy
|
|
101
101
|
* @param {number} wvz
|
|
102
102
|
*/
|
|
103
|
-
static "__#
|
|
103
|
+
static "__#144@#stamp_wall_velocity"(fluid: FluidComponent, posed: PosedShape3D, aabb: Float64Array, inflation: number, point: Float64Array, wvx: number, wvy: number, wvz: number): void;
|
|
104
104
|
constructor();
|
|
105
105
|
dependencies: (typeof FluidObstacle)[];
|
|
106
106
|
components_used: (ResourceAccessSpecification<typeof RigidBody> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof Transform> | ResourceAccessSpecification<typeof FluidComponent> | ResourceAccessSpecification<typeof FluidObstacle>)[];
|
|
@@ -38,7 +38,7 @@ export class FluidSystem extends System<any, any, any, any, any> {
|
|
|
38
38
|
* @param {FluidEffectorsComponent} effectors_component
|
|
39
39
|
* @param {Transform} transform
|
|
40
40
|
*/
|
|
41
|
-
static "__#
|
|
41
|
+
static "__#143@#sync_effectors_from_transform"(effectors_component: FluidEffectorsComponent, transform: Transform): void;
|
|
42
42
|
/**
|
|
43
43
|
* Visitor for the (FluidComponent, Transform) traversal — keeps the field's
|
|
44
44
|
* grid origin locked to a cell-aligned position near the transform.
|
|
@@ -61,7 +61,7 @@ export class FluidSystem extends System<any, any, any, any, any> {
|
|
|
61
61
|
* @param {FluidComponent} component
|
|
62
62
|
* @param {Transform} transform
|
|
63
63
|
*/
|
|
64
|
-
static "__#
|
|
64
|
+
static "__#143@#reanchor_field"(component: FluidComponent, transform: Transform): void;
|
|
65
65
|
/**
|
|
66
66
|
* Write the world-to-grid affine for a FluidComponent into `out`. Axis-aligned,
|
|
67
67
|
* uniform-scale, so the matrix is sparse:
|
|
@@ -76,7 +76,7 @@ export class FluidSystem extends System<any, any, any, any, any> {
|
|
|
76
76
|
* @param {Float32Array} out length-16
|
|
77
77
|
* @param {FluidComponent} component
|
|
78
78
|
*/
|
|
79
|
-
static "__#
|
|
79
|
+
static "__#143@#build_world_to_grid"(out: Float32Array, component: FluidComponent): void;
|
|
80
80
|
constructor();
|
|
81
81
|
dependencies: (typeof FluidComponent)[];
|
|
82
82
|
/**
|