@bendyline/molen-client 0.0.12 → 0.0.15
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/README.md +1 -1
- package/dist/aircraft.d.mts +16 -6
- package/dist/aircraft.mjs +627 -20
- package/dist/camera-track.d.mts +1 -1
- package/dist/glass.mjs +2 -1
- package/dist/index.d.mts +31 -3
- package/dist/index.mjs +578 -105
- package/dist/{input-BliZYUY1.mjs → input-CzlS1f2N.mjs} +5 -3
- package/dist/instance-batch-CO4YD6rd.d.mts +69 -0
- package/dist/instance-batch-Ds-oKQW4.mjs +222 -0
- package/dist/instancing.d.mts +2 -0
- package/dist/instancing.mjs +2 -0
- package/dist/navigation.d.mts +12 -3
- package/dist/navigation.mjs +25 -7
- package/dist/{renderer-DAk7C8jH.d.mts → renderer-4kSVioiH.d.mts} +95 -3
- package/dist/snow-cover-Bh0woabf.mjs +218 -0
- package/dist/snow-cover-tEG1uO98.d.mts +67 -0
- package/dist/snow.d.mts +2 -0
- package/dist/snow.mjs +2 -0
- package/dist/{vehicle-interior-CeyzF5El.mjs → vehicle-interior-CNLLi38s.mjs} +22 -1
- package/dist/vehicle-interior-XC2tAySI.d.mts +232 -0
- package/dist/vehicles.d.mts +43 -3
- package/dist/vehicles.mjs +595 -5
- package/dist/{webgpu-clouds-H03g7ID1.mjs → webgpu-clouds-DwSBoV8A.mjs} +15 -11
- package/dist/{webgpu-driver-BQnmPRqs.mjs → webgpu-driver-YWVTLOY7.mjs} +103 -4
- package/dist/webgpu-snow-cover-CiqYhvPq.mjs +55 -0
- package/package.json +11 -3
- package/dist/vehicle-interior-B8TpzTAx.d.mts +0 -56
|
@@ -214,8 +214,10 @@ var InputMap = class {
|
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
attach(target) {
|
|
217
|
-
const editable = (ev) => {
|
|
218
|
-
|
|
217
|
+
const editable = (ev, code) => {
|
|
218
|
+
const control = ev.target?.closest?.("input, textarea, select, button, a, summary, [contenteditable]:not([contenteditable=\"false\"]), [data-molen-input-editor]");
|
|
219
|
+
if (!control) return false;
|
|
220
|
+
return !(String(control.tagName).toUpperCase() === "INPUT" && String(control.type).toLowerCase() === "checkbox") || code === void 0 || code === "Space";
|
|
219
221
|
};
|
|
220
222
|
const add = (type, fn) => {
|
|
221
223
|
target.addEventListener(type, fn);
|
|
@@ -223,7 +225,7 @@ var InputMap = class {
|
|
|
223
225
|
};
|
|
224
226
|
add("keydown", (ev) => {
|
|
225
227
|
const event = ev;
|
|
226
|
-
if (editable(ev) || event.defaultPrevented || event.isComposing) return;
|
|
228
|
+
if (editable(ev, event.code) || event.defaultPrevented || event.isComposing) return;
|
|
227
229
|
if (event.metaKey || event.ctrlKey && !event.code.startsWith("Control") && resolveAction(this.profile.bindings, "ControlLeft") === void 0 && resolveAction(this.profile.bindings, "ControlRight") === void 0 || event.altKey && !event.code.startsWith("Alt") && resolveAction(this.profile.bindings, "AltLeft") === void 0 && resolveAction(this.profile.bindings, "AltRight") === void 0) return;
|
|
228
230
|
if (this.accepting && resolveAction(this.profile.bindings, event.code) !== void 0) event.preventDefault?.();
|
|
229
231
|
this.press(event.code);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
|
|
3
|
+
//#region src/three/instance-batch.d.ts
|
|
4
|
+
/** The geometry attributes a batch's instance matrices are read through, one matrix column each. */
|
|
5
|
+
declare const INSTANCE_BATCH_MATRIX_COLUMNS: readonly string[];
|
|
6
|
+
/** The geometry attribute a batch's instance colors are read through, when it has colors. */
|
|
7
|
+
declare const INSTANCE_BATCH_COLOR = "instanceColor";
|
|
8
|
+
/**
|
|
9
|
+
* A batch's instance matrices: one interleaved buffer that WebGL reads as a `mat4` attribute and
|
|
10
|
+
* WebGPU as four `vec4` columns, so either backend uploads it once. It keeps the `version` and
|
|
11
|
+
* `usage` an `InstancedBufferAttribute` reports, which its buffer holds.
|
|
12
|
+
*/
|
|
13
|
+
declare class InstanceMatrixAttribute extends THREE.InterleavedBufferAttribute {
|
|
14
|
+
readonly isInstanceMatrixAttribute = true;
|
|
15
|
+
constructor(buffer: THREE.InstancedInterleavedBuffer);
|
|
16
|
+
get version(): number;
|
|
17
|
+
get usage(): THREE.Usage;
|
|
18
|
+
setUsage(usage: THREE.Usage): this;
|
|
19
|
+
get updateRanges(): {
|
|
20
|
+
start: number;
|
|
21
|
+
count: number;
|
|
22
|
+
}[];
|
|
23
|
+
addUpdateRange(start: number, count: number): void;
|
|
24
|
+
clearUpdateRanges(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An `InstancedMesh` whose instances live in a geometry of its own, so WebGPU builds its shaders
|
|
28
|
+
* once for every batch of the same material and model layout instead of once per batch.
|
|
29
|
+
*
|
|
30
|
+
* Three's WebGPU renderer keys an instanced mesh's node build by the mesh, since its instance
|
|
31
|
+
* matrices are a node bound to that mesh's buffer: every batch streamed in paid a build of its own,
|
|
32
|
+
* about 10 ms of main thread each, which was most of a flight's streaming work. A batch instead
|
|
33
|
+
* carries its matrices and colors as instanced vertex attributes of an `InstancedBufferGeometry`
|
|
34
|
+
* that shares the model geometry's buffers, and the WebGPU driver reads them by name, the way it
|
|
35
|
+
* reads `position`: one build serves every batch, and each draw binds its own batch's vertex
|
|
36
|
+
* buffers, which a recorded render bundle replays as recorded. WebGL draws it as the
|
|
37
|
+
* `InstancedMesh` it is, with no setup, through three's own instancing.
|
|
38
|
+
*
|
|
39
|
+
* It keeps `InstancedMesh`'s API: `count`, `setMatrixAt`, `setColorAt`, bounds, raycasting and
|
|
40
|
+
* `dispose`. Assigning `geometry` selects the model it draws (a level of detail can swap it each
|
|
41
|
+
* frame without a new build, as long as the models share an attribute layout); `geometry` then reads
|
|
42
|
+
* back as the batch's own geometry and `sourceGeometry` as the model. Set colors before the first
|
|
43
|
+
* draw: a batch drawn without colors keeps its build. Models with morph targets are not supported.
|
|
44
|
+
*/
|
|
45
|
+
declare class InstanceBatch<TMaterial extends THREE.Material | THREE.Material[] = THREE.Material | THREE.Material[]> extends THREE.InstancedMesh<THREE.BufferGeometry, TMaterial> {
|
|
46
|
+
readonly isInstanceBatch: true;
|
|
47
|
+
constructor(geometry: THREE.BufferGeometry, material: TMaterial, count: number);
|
|
48
|
+
/** The model geometry this batch draws (what `geometry` was last set to). */
|
|
49
|
+
get sourceGeometry(): THREE.BufferGeometry;
|
|
50
|
+
/**
|
|
51
|
+
* Draw the instances in `matrices`, sixteen floats each as `Matrix4.elements` lays them out.
|
|
52
|
+
* The batch takes the array over; set `count` to match.
|
|
53
|
+
*/
|
|
54
|
+
setInstanceMatrices(matrices: Float32Array): this;
|
|
55
|
+
/** Every geometry of this batch's own, one per model it has drawn. */
|
|
56
|
+
batchGeometries(): THREE.BufferGeometry[];
|
|
57
|
+
override copy(source: InstanceBatch<TMaterial>, recursive?: boolean): this;
|
|
58
|
+
/**
|
|
59
|
+
* Release the batch's buffers. Its own geometries are released with it, but not the model
|
|
60
|
+
* geometry's buffers, which other batches share: a disposed batch is not drawn again.
|
|
61
|
+
*/
|
|
62
|
+
override dispose(): this;
|
|
63
|
+
}
|
|
64
|
+
/** Whether `object` is an `InstanceBatch`. */
|
|
65
|
+
declare function isInstanceBatch(object: unknown): object is InstanceBatch;
|
|
66
|
+
/** Whether `geometry` is one of an `InstanceBatch`'s own geometries. */
|
|
67
|
+
declare function isInstanceBatchGeometry(geometry: THREE.BufferGeometry): boolean;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { isInstanceBatch as a, InstanceMatrixAttribute as i, INSTANCE_BATCH_MATRIX_COLUMNS as n, isInstanceBatchGeometry as o, InstanceBatch as r, INSTANCE_BATCH_COLOR as t };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
//#region src/three/instance-batch.ts
|
|
3
|
+
/** The geometry attributes a batch's instance matrices are read through, one matrix column each. */
|
|
4
|
+
const INSTANCE_BATCH_MATRIX_COLUMNS = [
|
|
5
|
+
"instanceMatrix0",
|
|
6
|
+
"instanceMatrix1",
|
|
7
|
+
"instanceMatrix2",
|
|
8
|
+
"instanceMatrix3"
|
|
9
|
+
];
|
|
10
|
+
/** The geometry attribute a batch's instance colors are read through, when it has colors. */
|
|
11
|
+
const INSTANCE_BATCH_COLOR = "instanceColor";
|
|
12
|
+
/**
|
|
13
|
+
* A batch's instance matrices: one interleaved buffer that WebGL reads as a `mat4` attribute and
|
|
14
|
+
* WebGPU as four `vec4` columns, so either backend uploads it once. It keeps the `version` and
|
|
15
|
+
* `usage` an `InstancedBufferAttribute` reports, which its buffer holds.
|
|
16
|
+
*/
|
|
17
|
+
var InstanceMatrixAttribute = class extends THREE.InterleavedBufferAttribute {
|
|
18
|
+
isInstanceMatrixAttribute = true;
|
|
19
|
+
constructor(buffer) {
|
|
20
|
+
super(buffer, 16, 0);
|
|
21
|
+
}
|
|
22
|
+
get version() {
|
|
23
|
+
return this.data.version;
|
|
24
|
+
}
|
|
25
|
+
get usage() {
|
|
26
|
+
return this.data.usage;
|
|
27
|
+
}
|
|
28
|
+
setUsage(usage) {
|
|
29
|
+
this.data.setUsage(usage);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
get updateRanges() {
|
|
33
|
+
return this.data.updateRanges;
|
|
34
|
+
}
|
|
35
|
+
addUpdateRange(start, count) {
|
|
36
|
+
this.data.addUpdateRange(start, count);
|
|
37
|
+
}
|
|
38
|
+
clearUpdateRanges() {
|
|
39
|
+
this.data.clearUpdateRanges();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const INSTANCED = new Set([...INSTANCE_BATCH_MATRIX_COLUMNS, INSTANCE_BATCH_COLOR]);
|
|
43
|
+
const STATE = Symbol("molen.instanceBatch");
|
|
44
|
+
/** Marks a batch's own geometry with the model geometry it draws. */
|
|
45
|
+
const SOURCE = Symbol("molen.instanceBatch.source");
|
|
46
|
+
function stateOf(batch) {
|
|
47
|
+
const owner = batch;
|
|
48
|
+
let state = owner[STATE];
|
|
49
|
+
if (state === void 0) {
|
|
50
|
+
state = {
|
|
51
|
+
geometries: /* @__PURE__ */ new Map(),
|
|
52
|
+
current: void 0,
|
|
53
|
+
matrices: void 0,
|
|
54
|
+
colors: null,
|
|
55
|
+
count: 0,
|
|
56
|
+
constructed: false
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(owner, STATE, { value: state });
|
|
59
|
+
}
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* An `InstancedMesh` whose instances live in a geometry of its own, so WebGPU builds its shaders
|
|
64
|
+
* once for every batch of the same material and model layout instead of once per batch.
|
|
65
|
+
*
|
|
66
|
+
* Three's WebGPU renderer keys an instanced mesh's node build by the mesh, since its instance
|
|
67
|
+
* matrices are a node bound to that mesh's buffer: every batch streamed in paid a build of its own,
|
|
68
|
+
* about 10 ms of main thread each, which was most of a flight's streaming work. A batch instead
|
|
69
|
+
* carries its matrices and colors as instanced vertex attributes of an `InstancedBufferGeometry`
|
|
70
|
+
* that shares the model geometry's buffers, and the WebGPU driver reads them by name, the way it
|
|
71
|
+
* reads `position`: one build serves every batch, and each draw binds its own batch's vertex
|
|
72
|
+
* buffers, which a recorded render bundle replays as recorded. WebGL draws it as the
|
|
73
|
+
* `InstancedMesh` it is, with no setup, through three's own instancing.
|
|
74
|
+
*
|
|
75
|
+
* It keeps `InstancedMesh`'s API: `count`, `setMatrixAt`, `setColorAt`, bounds, raycasting and
|
|
76
|
+
* `dispose`. Assigning `geometry` selects the model it draws (a level of detail can swap it each
|
|
77
|
+
* frame without a new build, as long as the models share an attribute layout); `geometry` then reads
|
|
78
|
+
* back as the batch's own geometry and `sourceGeometry` as the model. Set colors before the first
|
|
79
|
+
* draw: a batch drawn without colors keeps its build. Models with morph targets are not supported.
|
|
80
|
+
*/
|
|
81
|
+
var InstanceBatch = class extends THREE.InstancedMesh {
|
|
82
|
+
constructor(geometry, material, count) {
|
|
83
|
+
super(geometry, material, count);
|
|
84
|
+
stateOf(this).constructed = true;
|
|
85
|
+
}
|
|
86
|
+
/** The model geometry this batch draws (what `geometry` was last set to). */
|
|
87
|
+
get sourceGeometry() {
|
|
88
|
+
return stateOf(this).current?.[SOURCE];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Draw the instances in `matrices`, sixteen floats each as `Matrix4.elements` lays them out.
|
|
92
|
+
* The batch takes the array over; set `count` to match.
|
|
93
|
+
*/
|
|
94
|
+
setInstanceMatrices(matrices) {
|
|
95
|
+
const buffer = new THREE.InstancedInterleavedBuffer(matrices, 16, 1);
|
|
96
|
+
adoptMatrices(stateOf(this), new InstanceMatrixAttribute(buffer));
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/** Every geometry of this batch's own, one per model it has drawn. */
|
|
100
|
+
batchGeometries() {
|
|
101
|
+
return [...stateOf(this).geometries.values()];
|
|
102
|
+
}
|
|
103
|
+
copy(source, recursive) {
|
|
104
|
+
THREE.Mesh.prototype.copy.call(this, source, recursive);
|
|
105
|
+
const state = stateOf(this);
|
|
106
|
+
const from = stateOf(source);
|
|
107
|
+
if (from.matrices !== void 0) {
|
|
108
|
+
const buffer = from.matrices.data;
|
|
109
|
+
const copied = new THREE.InstancedInterleavedBuffer(new Float32Array(buffer.array), 16, buffer.meshPerAttribute);
|
|
110
|
+
copied.setUsage(buffer.usage);
|
|
111
|
+
state.matrices = new InstanceMatrixAttribute(copied);
|
|
112
|
+
}
|
|
113
|
+
this.instanceColor = from.colors === null ? null : from.colors.clone();
|
|
114
|
+
this.count = from.count;
|
|
115
|
+
for (const geometry of state.geometries.values()) attachInstances(geometry, state);
|
|
116
|
+
this.boundingBox = source.boundingBox?.clone() ?? null;
|
|
117
|
+
this.boundingSphere = source.boundingSphere?.clone() ?? null;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Release the batch's buffers. Its own geometries are released with it, but not the model
|
|
122
|
+
* geometry's buffers, which other batches share: a disposed batch is not drawn again.
|
|
123
|
+
*/
|
|
124
|
+
dispose() {
|
|
125
|
+
super.dispose();
|
|
126
|
+
for (const geometry of stateOf(this).geometries.values()) {
|
|
127
|
+
const shared = Object.keys(geometry.attributes).filter((name) => !INSTANCED.has(name));
|
|
128
|
+
const kept = { ...geometry.attributes };
|
|
129
|
+
const index = geometry.index;
|
|
130
|
+
for (const name of shared) geometry.deleteAttribute(name);
|
|
131
|
+
geometry.index = null;
|
|
132
|
+
geometry.dispose();
|
|
133
|
+
geometry.index = index;
|
|
134
|
+
for (const name of shared) geometry.setAttribute(name, kept[name]);
|
|
135
|
+
}
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
Object.defineProperty(InstanceBatch.prototype, "isInstanceBatch", { value: true });
|
|
140
|
+
/** Whether `object` is an `InstanceBatch`. */
|
|
141
|
+
function isInstanceBatch(object) {
|
|
142
|
+
return object?.isInstanceBatch === true;
|
|
143
|
+
}
|
|
144
|
+
/** Whether `geometry` is one of an `InstanceBatch`'s own geometries. */
|
|
145
|
+
function isInstanceBatchGeometry(geometry) {
|
|
146
|
+
return geometry[SOURCE] !== void 0;
|
|
147
|
+
}
|
|
148
|
+
function attachInstances(geometry, state) {
|
|
149
|
+
const matrices = state.matrices;
|
|
150
|
+
if (matrices !== void 0) INSTANCE_BATCH_MATRIX_COLUMNS.forEach((name, column) => {
|
|
151
|
+
if (geometry.getAttribute(name)?.data !== matrices.data) geometry.setAttribute(name, new THREE.InterleavedBufferAttribute(matrices.data, 4, column * 4));
|
|
152
|
+
});
|
|
153
|
+
if (state.colors === null) geometry.deleteAttribute(INSTANCE_BATCH_COLOR);
|
|
154
|
+
else if (geometry.getAttribute("instanceColor") !== state.colors) geometry.setAttribute(INSTANCE_BATCH_COLOR, state.colors);
|
|
155
|
+
geometry.instanceCount = state.count;
|
|
156
|
+
}
|
|
157
|
+
function batchGeometry(state, source) {
|
|
158
|
+
let geometry = state.geometries.get(source);
|
|
159
|
+
if (geometry !== void 0) return geometry;
|
|
160
|
+
if (source.isInstancedBufferGeometry === true) throw new Error("An InstanceBatch draws a plain model geometry; its instances are its own");
|
|
161
|
+
if (Object.keys(source.morphAttributes).length > 0) throw new Error("An InstanceBatch cannot draw a model with morph targets");
|
|
162
|
+
geometry = new THREE.InstancedBufferGeometry();
|
|
163
|
+
geometry.name = source.name;
|
|
164
|
+
geometry.index = source.index;
|
|
165
|
+
for (const [name, attribute] of Object.entries(source.attributes)) geometry.setAttribute(name, attribute);
|
|
166
|
+
for (const group of source.groups) geometry.addGroup(group.start, group.count, group.materialIndex);
|
|
167
|
+
geometry.drawRange = source.drawRange;
|
|
168
|
+
geometry.boundingBox = source.boundingBox;
|
|
169
|
+
geometry.boundingSphere = source.boundingSphere;
|
|
170
|
+
geometry.userData = source.userData;
|
|
171
|
+
geometry[SOURCE] = source;
|
|
172
|
+
attachInstances(geometry, state);
|
|
173
|
+
state.geometries.set(source, geometry);
|
|
174
|
+
return geometry;
|
|
175
|
+
}
|
|
176
|
+
function adoptMatrices(state, value) {
|
|
177
|
+
if (value.isInstanceMatrixAttribute === true) state.matrices = value;
|
|
178
|
+
else if (!state.constructed && value.itemSize === 16) state.matrices = new InstanceMatrixAttribute(new THREE.InstancedInterleavedBuffer(value.array, 16, 1));
|
|
179
|
+
else throw new Error("An InstanceBatch's instanceMatrix is its own or another batch's (to share instances)");
|
|
180
|
+
for (const geometry of state.geometries.values()) attachInstances(geometry, state);
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperties(InstanceBatch.prototype, {
|
|
183
|
+
geometry: {
|
|
184
|
+
get() {
|
|
185
|
+
return stateOf(this).current;
|
|
186
|
+
},
|
|
187
|
+
set(value) {
|
|
188
|
+
const state = stateOf(this);
|
|
189
|
+
state.current = batchGeometry(state, value[SOURCE] ?? value);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
instanceMatrix: {
|
|
193
|
+
get() {
|
|
194
|
+
return stateOf(this).matrices;
|
|
195
|
+
},
|
|
196
|
+
set(value) {
|
|
197
|
+
adoptMatrices(stateOf(this), value);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
instanceColor: {
|
|
201
|
+
get() {
|
|
202
|
+
return stateOf(this).colors;
|
|
203
|
+
},
|
|
204
|
+
set(value) {
|
|
205
|
+
const state = stateOf(this);
|
|
206
|
+
state.colors = value;
|
|
207
|
+
for (const geometry of state.geometries.values()) attachInstances(geometry, state);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
count: {
|
|
211
|
+
get() {
|
|
212
|
+
return stateOf(this).count;
|
|
213
|
+
},
|
|
214
|
+
set(value) {
|
|
215
|
+
const state = stateOf(this);
|
|
216
|
+
state.count = value;
|
|
217
|
+
for (const geometry of state.geometries.values()) geometry.instanceCount = value;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
//#endregion
|
|
222
|
+
export { isInstanceBatch as a, InstanceMatrixAttribute as i, INSTANCE_BATCH_MATRIX_COLUMNS as n, isInstanceBatchGeometry as o, InstanceBatch as r, INSTANCE_BATCH_COLOR as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as isInstanceBatch, i as InstanceMatrixAttribute, n as INSTANCE_BATCH_MATRIX_COLUMNS, o as isInstanceBatchGeometry, r as InstanceBatch, t as INSTANCE_BATCH_COLOR } from "./instance-batch-CO4YD6rd.mjs";
|
|
2
|
+
export { INSTANCE_BATCH_COLOR, INSTANCE_BATCH_MATRIX_COLUMNS, InstanceBatch, InstanceMatrixAttribute, isInstanceBatch, isInstanceBatchGeometry };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as isInstanceBatch, i as InstanceMatrixAttribute, n as INSTANCE_BATCH_MATRIX_COLUMNS, o as isInstanceBatchGeometry, r as InstanceBatch, t as INSTANCE_BATCH_COLOR } from "./instance-batch-Ds-oKQW4.mjs";
|
|
2
|
+
export { INSTANCE_BATCH_COLOR, INSTANCE_BATCH_MATRIX_COLUMNS, InstanceBatch, InstanceMatrixAttribute, isInstanceBatch, isInstanceBatchGeometry };
|
package/dist/navigation.d.mts
CHANGED
|
@@ -175,6 +175,7 @@ declare const NAVIGATION_ACTIONS: {
|
|
|
175
175
|
readonly gear: "nav-gear";
|
|
176
176
|
readonly flaps: "nav-flaps";
|
|
177
177
|
readonly vector: "nav-vector";
|
|
178
|
+
readonly cyclic: "nav-cyclic";
|
|
178
179
|
readonly recover: "nav-recover";
|
|
179
180
|
};
|
|
180
181
|
/** The navigation modes with a default input profile. */
|
|
@@ -184,9 +185,9 @@ type NavigationProfileName = "orbit" | "fly" | "walk" | "drive" | "pilot";
|
|
|
184
185
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, Shift to sprint
|
|
185
186
|
* or pull the handbrake, and V to switch the vehicle view. Pilot flies an aircraft: W/S (or ↑/↓) pitch the nose down/up, A/D (or ←/→)
|
|
186
187
|
* bank, Z/C work the rudder or pedals, =/− (or numpad +/−, Page Up/Down) set throttle or
|
|
187
|
-
* collective,
|
|
188
|
-
*
|
|
189
|
-
* Hosts may replace any profile through
|
|
188
|
+
* collective, and Ctrl stays free for browser shortcuts such as Ctrl+W. I toggles the engine, G
|
|
189
|
+
* the gear, F the flaps, M a helicopter's cyclic between assisted and direct, R recovers after
|
|
190
|
+
* an impact, Space brakes, V switches the view and E leaves. T toggles travel boost in walk, drive and pilot. Hosts may replace any profile through
|
|
190
191
|
* `InputMap.defineProfile`.
|
|
191
192
|
*/
|
|
192
193
|
declare function navigationInputProfiles(): Record<NavigationProfileName, InputProfile>;
|
|
@@ -204,6 +205,8 @@ interface PilotInput {
|
|
|
204
205
|
flaps: number;
|
|
205
206
|
/** Powered-lift lever advances through 0, 25, 50, 75, 100 percent on each press. */
|
|
206
207
|
vector?: number;
|
|
208
|
+
/** Helicopter cyclic toggles between assisted and direct (full authority). */
|
|
209
|
+
cyclic?: number;
|
|
207
210
|
recover: number;
|
|
208
211
|
}
|
|
209
212
|
/** Everything a navigation controller reads in one frame. */
|
|
@@ -618,6 +621,12 @@ declare class WalkController {
|
|
|
618
621
|
swimming: boolean;
|
|
619
622
|
/** Water surface in world meters; null means dry, undefined means coverage is loading. */
|
|
620
623
|
sampleWaterHeight?: (x: number, z: number) => number | null | undefined;
|
|
624
|
+
/**
|
|
625
|
+
* Share of walking and running speed left at the feet (world meters): what the ground costs,
|
|
626
|
+
* such as deep snow (`snowWalkingPace`). Default 1; values are kept within 0.1–1, and swimming
|
|
627
|
+
* ignores it.
|
|
628
|
+
*/
|
|
629
|
+
paceAt?: (x: number, y: number, z: number) => number;
|
|
621
630
|
ready: boolean;
|
|
622
631
|
waitingForTerrain: boolean;
|
|
623
632
|
private accumulator;
|
package/dist/navigation.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { t as InputMap } from "./input-
|
|
1
|
+
import { t as InputMap } from "./input-CzlS1f2N.mjs";
|
|
2
|
+
import { a as isInstanceBatch } from "./instance-batch-Ds-oKQW4.mjs";
|
|
2
3
|
import { boostSpeedMultiplier } from "@bendyline/molen-schema";
|
|
3
4
|
import * as THREE from "three";
|
|
4
5
|
import { Octree } from "three/addons/math/Octree.js";
|
|
@@ -252,6 +253,9 @@ var NavigationPointer = class {
|
|
|
252
253
|
}
|
|
253
254
|
down(event) {
|
|
254
255
|
this.surface.focus?.({ preventScroll: true });
|
|
256
|
+
try {
|
|
257
|
+
this.surface.setPointerCapture?.(event.pointerId);
|
|
258
|
+
} catch {}
|
|
255
259
|
if (this.pointerLock && event.pointerType !== "touch" && !this.locked()) {
|
|
256
260
|
const request = this.surface.requestPointerLock?.();
|
|
257
261
|
if (request instanceof Promise) request.catch(() => {});
|
|
@@ -267,7 +271,6 @@ var NavigationPointer = class {
|
|
|
267
271
|
pan: button === 1 || button === 2 || event.shiftKey === true
|
|
268
272
|
});
|
|
269
273
|
if (this.pointers.size > 1) for (const pointer of this.pointers.values()) pointer.moved = true;
|
|
270
|
-
this.surface.setPointerCapture?.(event.pointerId);
|
|
271
274
|
}
|
|
272
275
|
move(event) {
|
|
273
276
|
if (this.locked() && this.pointers.size <= 1) {
|
|
@@ -369,6 +372,7 @@ const NAVIGATION_ACTIONS = {
|
|
|
369
372
|
gear: "nav-gear",
|
|
370
373
|
flaps: "nav-flaps",
|
|
371
374
|
vector: "nav-vector",
|
|
375
|
+
cyclic: "nav-cyclic",
|
|
372
376
|
recover: "nav-recover"
|
|
373
377
|
};
|
|
374
378
|
const ACTUATOR_KEYS = {
|
|
@@ -445,9 +449,9 @@ const STICKS = [
|
|
|
445
449
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, Shift to sprint
|
|
446
450
|
* or pull the handbrake, and V to switch the vehicle view. Pilot flies an aircraft: W/S (or ↑/↓) pitch the nose down/up, A/D (or ←/→)
|
|
447
451
|
* bank, Z/C work the rudder or pedals, =/− (or numpad +/−, Page Up/Down) set throttle or
|
|
448
|
-
* collective,
|
|
449
|
-
*
|
|
450
|
-
* Hosts may replace any profile through
|
|
452
|
+
* collective, and Ctrl stays free for browser shortcuts such as Ctrl+W. I toggles the engine, G
|
|
453
|
+
* the gear, F the flaps, M a helicopter's cyclic between assisted and direct, R recovers after
|
|
454
|
+
* an impact, Space brakes, V switches the view and E leaves. T toggles travel boost in walk, drive and pilot. Hosts may replace any profile through
|
|
451
455
|
* `InputMap.defineProfile`.
|
|
452
456
|
*/
|
|
453
457
|
function navigationInputProfiles() {
|
|
@@ -531,6 +535,7 @@ function navigationInputProfiles() {
|
|
|
531
535
|
KeyG: A.gear,
|
|
532
536
|
KeyF: A.flaps,
|
|
533
537
|
KeyJ: A.vector,
|
|
538
|
+
KeyM: A.cyclic,
|
|
534
539
|
KeyR: A.recover
|
|
535
540
|
},
|
|
536
541
|
axes: STICKS,
|
|
@@ -620,6 +625,7 @@ var NavigationInputSource = class {
|
|
|
620
625
|
gear: 0,
|
|
621
626
|
flaps: 0,
|
|
622
627
|
vector: 0,
|
|
628
|
+
cyclic: 0,
|
|
623
629
|
recover: 0
|
|
624
630
|
};
|
|
625
631
|
lookSpeed;
|
|
@@ -645,6 +651,7 @@ var NavigationInputSource = class {
|
|
|
645
651
|
"gear",
|
|
646
652
|
"flaps",
|
|
647
653
|
"vector",
|
|
654
|
+
"cyclic",
|
|
648
655
|
"recover"
|
|
649
656
|
].map((name) => this.map.onPress(A[name], () => {
|
|
650
657
|
this.pilotPresses[name]++;
|
|
@@ -668,6 +675,7 @@ var NavigationInputSource = class {
|
|
|
668
675
|
this.pilotPresses.gear = 0;
|
|
669
676
|
this.pilotPresses.flaps = 0;
|
|
670
677
|
this.pilotPresses.vector = 0;
|
|
678
|
+
this.pilotPresses.cyclic = 0;
|
|
671
679
|
this.pilotPresses.recover = 0;
|
|
672
680
|
})
|
|
673
681
|
];
|
|
@@ -727,6 +735,7 @@ var NavigationInputSource = class {
|
|
|
727
735
|
this.pilotPresses.gear = 0;
|
|
728
736
|
this.pilotPresses.flaps = 0;
|
|
729
737
|
this.pilotPresses.vector = 0;
|
|
738
|
+
this.pilotPresses.cyclic = 0;
|
|
730
739
|
this.pilotPresses.recover = 0;
|
|
731
740
|
this.actuatorPresses = {};
|
|
732
741
|
return input;
|
|
@@ -952,6 +961,7 @@ function createNavigationControls(source, options) {
|
|
|
952
961
|
[NAVIGATION_ACTIONS.gear, "Landing gear"],
|
|
953
962
|
[NAVIGATION_ACTIONS.flaps, "Flaps"],
|
|
954
963
|
[NAVIGATION_ACTIONS.vector, "Thrust vector"],
|
|
964
|
+
[NAVIGATION_ACTIONS.cyclic, "Helicopter cyclic: assisted / direct"],
|
|
955
965
|
[NAVIGATION_ACTIONS.recover, "Recover"]
|
|
956
966
|
] : [
|
|
957
967
|
[NAVIGATION_ACTIONS.sprint, "Sprint / handbrake"],
|
|
@@ -1827,7 +1837,7 @@ var WalkCollision = class {
|
|
|
1827
1837
|
const c = new THREE.Vector3();
|
|
1828
1838
|
const inside = () => bounds.min.x <= radius && bounds.max.x >= -radius && bounds.min.z <= radius && bounds.max.z >= -radius && bounds.min.y <= maxY && bounds.max.y >= minY;
|
|
1829
1839
|
for (const { mesh, matrix, count } of meshes) {
|
|
1830
|
-
const geometry = mesh.geometry;
|
|
1840
|
+
const geometry = isInstanceBatch(mesh) ? mesh.sourceGeometry : mesh.geometry;
|
|
1831
1841
|
const position = geometry.getAttribute("position");
|
|
1832
1842
|
if (position === void 0) continue;
|
|
1833
1843
|
geometryBounds(geometry);
|
|
@@ -2011,6 +2021,12 @@ var WalkController = class {
|
|
|
2011
2021
|
swimming = false;
|
|
2012
2022
|
/** Water surface in world meters; null means dry, undefined means coverage is loading. */
|
|
2013
2023
|
sampleWaterHeight;
|
|
2024
|
+
/**
|
|
2025
|
+
* Share of walking and running speed left at the feet (world meters): what the ground costs,
|
|
2026
|
+
* such as deep snow (`snowWalkingPace`). Default 1; values are kept within 0.1–1, and swimming
|
|
2027
|
+
* ignores it.
|
|
2028
|
+
*/
|
|
2029
|
+
paceAt;
|
|
2014
2030
|
ready = false;
|
|
2015
2031
|
waitingForTerrain = false;
|
|
2016
2032
|
accumulator = 0;
|
|
@@ -2083,7 +2099,9 @@ var WalkController = class {
|
|
|
2083
2099
|
this.accumulator += Math.min(.1, Math.max(0, dt));
|
|
2084
2100
|
while (this.accumulator >= STEP) {
|
|
2085
2101
|
this.accumulator -= STEP;
|
|
2086
|
-
const
|
|
2102
|
+
const moving = input.forward !== 0 || input.right !== 0;
|
|
2103
|
+
const pace = this.swimming || !moving || this.paceAt === void 0 ? 1 : Math.min(1, Math.max(.1, this.paceAt(this.feet.x, this.feet.y, this.feet.z)));
|
|
2104
|
+
const speed = (this.swimming ? SWIM_SPEED * (input.sprint ? 1.5 : 1) : (input.sprint ? 4 : WALK_SPEED) * pace) * boostSpeedMultiplier(this.boostMode);
|
|
2087
2105
|
const vx = forwardX * speed;
|
|
2088
2106
|
const vz = forwardZ * speed;
|
|
2089
2107
|
const nextX = this.feet.x + vx * STEP;
|