@bendyline/molen-client 0.0.8 → 0.0.10
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 -0
- package/dist/aircraft.d.mts +11 -4
- package/dist/aircraft.mjs +56 -10
- package/dist/audio.d.mts +9 -0
- package/dist/audio.mjs +68 -10
- package/dist/camera-track.d.mts +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +260 -28
- package/dist/{input-CfbIm1MS.mjs → input-BVZjf4T-.mjs} +6 -2
- package/dist/instruments.d.mts +63 -0
- package/dist/instruments.mjs +137 -0
- package/dist/model-signals-BpeXhsim.d.mts +25 -0
- package/dist/model-signals-DLgvjBeZ.mjs +172 -0
- package/dist/navigation.d.mts +25 -2
- package/dist/navigation.mjs +231 -43
- package/dist/{renderer-DPT7XAYh.d.mts → renderer-CtEtmwJG.d.mts} +75 -2
- package/dist/text.d.mts +24 -0
- package/dist/text.mjs +62 -0
- package/dist/{vehicle-interior-0o-8QV_-.d.mts → vehicle-interior-BgcC750p.d.mts} +2 -2
- package/dist/{vehicle-interior-DZT0HmWC.mjs → vehicle-interior-DfpZwWEh.mjs} +4 -1
- package/dist/vehicles.d.mts +20 -4
- package/dist/vehicles.mjs +43 -10
- package/dist/webgpu-ambient-occlusion-9gnp3qOY.mjs +126 -0
- package/dist/{webgpu-driver-Bt2mvZk9.mjs → webgpu-driver-BQnmPRqs.mjs} +41 -1
- package/dist/{webgpu-scene-optimizer-DKRyHBRC.mjs → webgpu-scene-optimizer-Cup4Yvzs.mjs} +9 -2
- package/package.json +12 -4
- package/dist/model-signals-DVlLyP-w.d.mts +0 -17
- package/dist/model-signals-Gw1COJfo.mjs +0 -53
package/README.md
CHANGED
|
@@ -67,6 +67,7 @@ probe — a pinned backend is what makes a captured frame reproducible.
|
|
|
67
67
|
| `./vite` | `molenScripts()` — a Vite plugin that type-strips `*.ts?raw` scene scripts so the browser never sees TypeScript |
|
|
68
68
|
| `./vehicles` | `createVehicleVisual`, `createParkedVehicleBatch`, `vehicleCameraPose` — car visuals and cockpit/chase views, the render half of `@bendyline/molen-kernel/vehicles` |
|
|
69
69
|
| `./aircraft` | `createAircraftVisual`, `aircraftCameraPose` — animated airframe and instrumented cockpit, the render half of `@bendyline/molen-kernel/aircraft` |
|
|
70
|
+
| `./instruments` | Named signal expressions and reusable wiring for calibrated dials, altimeters, attitude indicators, annunciators and seven-segment readouts; geometry stays in each model |
|
|
70
71
|
| `./navigation` | `OrbitController`, `FlyController`, `WalkController` + `WalkCollision`, `FollowController`, `NavigationInputSource` (keys, gamepad, pointer gestures) and `createTouchJoystick` — camera navigation for `createViewer` hosts |
|
|
71
72
|
| `./markers` | `createMarkerLayer`, `composeMarkerImage`, `projectWorldToScreen` — screen-sized, ground-snapped, pickable world markers such as photo pins |
|
|
72
73
|
| `./audio` | `createAudioLayer`, `AudioDirector`, `WebAudioBackend`, `loadPackSoundbanks`, `attachAutoplayUnlock` — plays sound banks and a scene's `audioEnvironment`/`audioSource`/`audioZone` rules and `molen.audio.*` events; three-free at runtime, so the director also runs in Node |
|
package/dist/aircraft.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ModelSignals } from "./model-signals-
|
|
2
|
-
import { a as VehicleCameraPose, i as VehicleCameraOptions, n as VehicleInteriorVisual } from "./vehicle-interior-
|
|
1
|
+
import { n as ModelSignals, t as ModelSignalVisual } from "./model-signals-BpeXhsim.mjs";
|
|
2
|
+
import { a as VehicleCameraPose, i as VehicleCameraOptions, n as VehicleInteriorVisual } from "./vehicle-interior-BgcC750p.mjs";
|
|
3
3
|
import { AircraftInputData, AircraftSpec, AircraftStateData } from "@bendyline/molen-schema";
|
|
4
4
|
import * as THREE from "three";
|
|
5
5
|
|
|
@@ -7,10 +7,17 @@ import * as THREE from "three";
|
|
|
7
7
|
interface AircraftVisual {
|
|
8
8
|
object: THREE.Object3D;
|
|
9
9
|
interior?: VehicleInteriorVisual;
|
|
10
|
-
|
|
10
|
+
/** The spec's exterior `animation` bindings (gear legs and doors, control surfaces). */
|
|
11
|
+
animation?: ModelSignalVisual;
|
|
12
|
+
update(state: AircraftStateData, input: AircraftInputData, altitude: number, signals?: ModelSignals, timeSeconds?: number): void;
|
|
11
13
|
dispose(): void;
|
|
12
14
|
}
|
|
13
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Takes ownership of a loaded library GLB. The named nodes remain editable in a DCC.
|
|
17
|
+
*
|
|
18
|
+
* The gear and flaps follow `state.gearPosition` and `state.flapPosition` as they travel, or the
|
|
19
|
+
* selection in `input` when the state has no positions (helicopters, hosts that animate only).
|
|
20
|
+
*/
|
|
14
21
|
declare function createAircraftVisual(model: THREE.Object3D, spec: AircraftSpec): AircraftVisual;
|
|
15
22
|
interface AircraftCameraPose extends VehicleCameraPose {
|
|
16
23
|
rotation: [number, number, number, number];
|
package/dist/aircraft.mjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as createModelSignalVisual } from "./model-signals-DLgvjBeZ.mjs";
|
|
2
|
+
import { t as createVehicleInteriorVisual } from "./vehicle-interior-DfpZwWEh.mjs";
|
|
2
3
|
import * as THREE from "three";
|
|
3
4
|
//#region src/aircraft.ts
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Takes ownership of a loaded library GLB. The named nodes remain editable in a DCC.
|
|
7
|
+
*
|
|
8
|
+
* The gear and flaps follow `state.gearPosition` and `state.flapPosition` as they travel, or the
|
|
9
|
+
* selection in `input` when the state has no positions (helicopters, hosts that animate only).
|
|
10
|
+
*/
|
|
5
11
|
function createAircraftVisual(model, spec) {
|
|
6
12
|
const interior = spec.visual.interior === void 0 ? void 0 : createVehicleInteriorVisual(model, spec.visual.interior);
|
|
13
|
+
const animation = spec.visual.animation === void 0 ? void 0 : createModelSignalVisual(model, spec.visual.animation);
|
|
7
14
|
const moving = /* @__PURE__ */ new Map();
|
|
8
15
|
model.traverse((o) => {
|
|
9
16
|
o.userData.vehicleGeometry = true;
|
|
@@ -21,37 +28,75 @@ function createAircraftVisual(model, spec) {
|
|
|
21
28
|
return {
|
|
22
29
|
object: model,
|
|
23
30
|
interior,
|
|
24
|
-
|
|
31
|
+
animation,
|
|
32
|
+
update(state, input, altitude, signals, timeSeconds) {
|
|
33
|
+
const gear = state.gearPosition ?? Number(input.gear);
|
|
34
|
+
const flaps = state.flapPosition ?? Number(input.flaps);
|
|
25
35
|
for (const binding of spec.visual.rotors) {
|
|
26
36
|
const engine = binding.engine === void 0 ? void 0 : state.engines?.[binding.engine];
|
|
27
37
|
turn(binding.node, binding.axis, (engine?.rotorAngle ?? state.rotorAngle) * binding.multiplier);
|
|
28
38
|
}
|
|
29
|
-
for (const name of spec.visual.gearNodes) for (const node of moving.get(name) ?? []) node.visible =
|
|
30
|
-
for (const binding of spec.visual.flaps) turn(binding.node, binding.axis,
|
|
39
|
+
for (const name of spec.visual.gearNodes) for (const node of moving.get(name) ?? []) node.visible = gear > 0;
|
|
40
|
+
for (const binding of spec.visual.flaps) turn(binding.node, binding.axis, flaps * binding.multiplier);
|
|
31
41
|
for (const binding of spec.visual.ailerons) turn(binding.node, binding.axis, input.roll * binding.multiplier);
|
|
32
42
|
if (interior === void 0 && spec.visual.controlStick !== void 0) {
|
|
33
43
|
turn(spec.visual.controlStick.node, spec.visual.controlStick.pitchAxis, input.pitch * .22);
|
|
34
44
|
turn(spec.visual.controlStick.node, spec.visual.controlStick.rollAxis, input.roll * .22);
|
|
35
45
|
}
|
|
36
46
|
if (interior === void 0 && spec.visual.collective !== void 0) turn(spec.visual.collective.node, spec.visual.collective.axis, input.power * spec.visual.collective.multiplier);
|
|
37
|
-
|
|
47
|
+
const engineSignals = Object.create(null);
|
|
48
|
+
for (const engine of spec.engines ?? []) {
|
|
49
|
+
const reading = state.engines?.[engine.id];
|
|
50
|
+
const prefix = `engines.${engine.id}.`;
|
|
51
|
+
engineSignals[`${prefix}rpmNormalized`] = reading?.rpm;
|
|
52
|
+
engineSignals[`${prefix}rotorRpm`] = reading === void 0 ? void 0 : reading.rpm * engine.rotorAngularSpeed * 60 / (2 * Math.PI);
|
|
53
|
+
engineSignals[`${prefix}failed`] = reading === void 0 ? void 0 : Number(reading.failed);
|
|
54
|
+
engineSignals[`${prefix}thrustN`] = reading?.thrust;
|
|
55
|
+
engineSignals[`${prefix}afterburner`] = reading?.afterburner ?? 0;
|
|
56
|
+
}
|
|
57
|
+
const telemetry = {
|
|
38
58
|
airspeed: state.airspeed,
|
|
59
|
+
trueAirspeed: state.airspeed,
|
|
60
|
+
equivalentAirspeed: state.equivalentAirspeed,
|
|
61
|
+
mach: state.mach,
|
|
62
|
+
overspeed: Number(state.overspeed ?? false),
|
|
63
|
+
departure: state.departure ?? 0,
|
|
64
|
+
vortexRing: state.vortexRing ?? 0,
|
|
65
|
+
afterburner: Math.max(0, ...Object.values(state.engines ?? {}).map((engine) => engine.afterburner ?? 0)),
|
|
39
66
|
altitude,
|
|
40
67
|
altitudeAGL: state.altitudeAGL,
|
|
41
68
|
heading: state.yaw,
|
|
42
69
|
verticalSpeed: state.verticalSpeed,
|
|
43
70
|
rpm: state.rpm,
|
|
71
|
+
rpmNormalized: state.rpm,
|
|
72
|
+
rotorRpm: spec.engines?.length || spec.engine === void 0 ? void 0 : state.rpm * spec.engine.rotorAngularSpeed * 60 / (2 * Math.PI),
|
|
44
73
|
pitch: state.pitch,
|
|
45
74
|
roll: state.roll,
|
|
75
|
+
pitchRate: state.pitchRate,
|
|
76
|
+
rollRate: state.rollRate,
|
|
77
|
+
yawRate: state.yawRate,
|
|
78
|
+
angleOfAttack: state.angleOfAttack,
|
|
79
|
+
sideslip: state.sideslip,
|
|
80
|
+
loadFactor: state.loadFactor,
|
|
81
|
+
groundSpeed: state.velocity === void 0 ? void 0 : Math.hypot(state.velocity[0], state.velocity[2]),
|
|
82
|
+
stalled: Number(state.stalled),
|
|
83
|
+
crashed: Number(state.crashed),
|
|
46
84
|
power: input.power,
|
|
47
85
|
pitchInput: input.pitch,
|
|
48
86
|
rollInput: input.roll,
|
|
49
87
|
yawInput: input.yaw,
|
|
50
|
-
|
|
51
|
-
|
|
88
|
+
elevator: state.elevator ?? input.pitch,
|
|
89
|
+
gear,
|
|
90
|
+
flaps,
|
|
91
|
+
thrustVector: state.thrustVectorPosition ?? 0,
|
|
52
92
|
engine: Number(input.engine),
|
|
93
|
+
brake: Number(input.brake),
|
|
94
|
+
grounded: Number(state.grounded),
|
|
95
|
+
...engineSignals,
|
|
53
96
|
...signals
|
|
54
|
-
}
|
|
97
|
+
};
|
|
98
|
+
interior?.update(telemetry, timeSeconds);
|
|
99
|
+
animation?.update(telemetry, timeSeconds);
|
|
55
100
|
},
|
|
56
101
|
dispose() {
|
|
57
102
|
const geometries = /* @__PURE__ */ new Set(), materials = /* @__PURE__ */ new Set();
|
|
@@ -83,7 +128,8 @@ function aircraftCameraPose(transform, spec, options) {
|
|
|
83
128
|
const offset = position.clone().sub(target).normalize();
|
|
84
129
|
position.copy(target).addScaledVector(offset, Math.max(.3, hit - .3));
|
|
85
130
|
}
|
|
86
|
-
|
|
131
|
+
const vertical = THREE.MathUtils.smoothstep(Math.abs(direction.y), .7, .95);
|
|
132
|
+
up = new THREE.Vector3(0, 1, 0).lerp(up, vertical).normalize();
|
|
87
133
|
}
|
|
88
134
|
const forward = target.clone().sub(position).normalize();
|
|
89
135
|
const rotation = new THREE.Quaternion().setFromRotationMatrix(new THREE.Matrix4().lookAt(position, target, up));
|
package/dist/audio.d.mts
CHANGED
|
@@ -232,6 +232,8 @@ declare class AudioDirector {
|
|
|
232
232
|
private listenerState;
|
|
233
233
|
private footAcc;
|
|
234
234
|
private footLast;
|
|
235
|
+
private footGrounded;
|
|
236
|
+
private footAt;
|
|
235
237
|
private startMs;
|
|
236
238
|
private lastNow;
|
|
237
239
|
private frame;
|
|
@@ -490,6 +492,8 @@ interface WebAudioBackendOptions {
|
|
|
490
492
|
context?: AudioContext;
|
|
491
493
|
/** Drop a one-shot whose clip is still decoding this many seconds after it was requested. */
|
|
492
494
|
staleOneShotS?: number;
|
|
495
|
+
/** Retain up to this many decoded PCM bytes; playing/fading clips are never evicted (default 96 MiB). */
|
|
496
|
+
maxDecodedBytes?: number;
|
|
493
497
|
onError?: (message: string) => void;
|
|
494
498
|
}
|
|
495
499
|
/** Plays director commands through Web Audio: buses, panners, looped buffers, fades. */
|
|
@@ -499,8 +503,12 @@ declare class WebAudioBackend implements AudioBackend {
|
|
|
499
503
|
private readonly staleS;
|
|
500
504
|
private readonly onError;
|
|
501
505
|
private readonly master;
|
|
506
|
+
private readonly limiter;
|
|
502
507
|
private readonly buses;
|
|
503
508
|
private readonly buffers;
|
|
509
|
+
private readonly bufferSizes;
|
|
510
|
+
private readonly maxDecodedBytes;
|
|
511
|
+
private decodedBytes;
|
|
504
512
|
private readonly voices;
|
|
505
513
|
private decoded;
|
|
506
514
|
private pending;
|
|
@@ -516,6 +524,7 @@ declare class WebAudioBackend implements AudioBackend {
|
|
|
516
524
|
dispose(): void;
|
|
517
525
|
private bus;
|
|
518
526
|
private load;
|
|
527
|
+
private trimBuffers;
|
|
519
528
|
private start;
|
|
520
529
|
private set;
|
|
521
530
|
private stop;
|
package/dist/audio.mjs
CHANGED
|
@@ -301,11 +301,21 @@ function audibility(gain, spatial, d) {
|
|
|
301
301
|
const ref = spatial.refDistance;
|
|
302
302
|
return gain * ref / (ref + spatial.rolloff * Math.max(0, d - ref));
|
|
303
303
|
}
|
|
304
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Vehicles someone is riding: every `mounted` component names one, unless its seat is a
|
|
306
|
+
* `passenger` seat of the vehicle's `mountable` (a companion waiting in a parked car does not
|
|
307
|
+
* start its engine).
|
|
308
|
+
*/
|
|
305
309
|
function occupiedBy(source) {
|
|
306
310
|
const out = /* @__PURE__ */ new Set();
|
|
307
311
|
if (!source) return out;
|
|
308
|
-
for (const [, mounted] of source.each("mounted"))
|
|
312
|
+
for (const [, mounted] of source.each("mounted")) {
|
|
313
|
+
const vehicle = mounted.vehicle;
|
|
314
|
+
if (typeof vehicle !== "string") continue;
|
|
315
|
+
const seats = source.get(vehicle, "mountable")?.seats;
|
|
316
|
+
if ((Array.isArray(seats) ? seats.find((s) => s?.id === mounted.seat) : void 0)?.role === "passenger") continue;
|
|
317
|
+
out.add(vehicle);
|
|
318
|
+
}
|
|
309
319
|
return out;
|
|
310
320
|
}
|
|
311
321
|
var AudioDirector = class {
|
|
@@ -335,6 +345,8 @@ var AudioDirector = class {
|
|
|
335
345
|
listenerState;
|
|
336
346
|
footAcc = 0;
|
|
337
347
|
footLast;
|
|
348
|
+
footGrounded = false;
|
|
349
|
+
footAt = -Infinity;
|
|
338
350
|
startMs;
|
|
339
351
|
lastNow;
|
|
340
352
|
frame = 0;
|
|
@@ -651,8 +663,8 @@ var AudioDirector = class {
|
|
|
651
663
|
fadeS: .05
|
|
652
664
|
});
|
|
653
665
|
}
|
|
654
|
-
const clip = this.pickClip(sound, tick, shot.key);
|
|
655
|
-
const pitch = this.basePitch(sound, tick, shot.key) * shot.pitchMul;
|
|
666
|
+
const clip = this.pickClip(sound, tick, shot.key, this.serial);
|
|
667
|
+
const pitch = this.basePitch(sound, tick, shot.key, this.serial) * shot.pitchMul;
|
|
656
668
|
const voice = `shot:${this.serial++}`;
|
|
657
669
|
const { entry } = sound;
|
|
658
670
|
cmds.push({
|
|
@@ -1025,16 +1037,23 @@ var AudioDirector = class {
|
|
|
1025
1037
|
}
|
|
1026
1038
|
footsteps(env, ctx, now, tick, cmds) {
|
|
1027
1039
|
const f = env?.footsteps;
|
|
1028
|
-
const
|
|
1029
|
-
const delta = this.footLast === void 0 ? 0 :
|
|
1030
|
-
this.footLast =
|
|
1040
|
+
const pos = ctx.listener.position;
|
|
1041
|
+
const delta = this.footLast === void 0 ? 0 : Math.hypot(pos[0] - this.footLast[0], pos[2] - this.footLast[2]);
|
|
1042
|
+
this.footLast = [...pos];
|
|
1043
|
+
const wasGrounded = this.footGrounded;
|
|
1044
|
+
this.footGrounded = !!f && ctx.listener.grounded !== false && evalWhen(f.when, ctx);
|
|
1031
1045
|
if (!f || ctx.listener.grounded === false || !evalWhen(f.when, ctx)) {
|
|
1032
1046
|
this.footAcc = 0;
|
|
1033
1047
|
return;
|
|
1034
1048
|
}
|
|
1049
|
+
if (!wasGrounded || delta > 4) {
|
|
1050
|
+
this.footAcc = 0;
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1035
1053
|
const stride = f.strideM ?? .75;
|
|
1036
1054
|
this.footAcc += delta;
|
|
1037
|
-
if (this.footAcc < stride) return;
|
|
1055
|
+
if (this.footAcc < stride || now - this.footAt < 250) return;
|
|
1056
|
+
this.footAt = now;
|
|
1038
1057
|
this.footAcc -= stride;
|
|
1039
1058
|
if (this.footAcc > stride) this.footAcc = 0;
|
|
1040
1059
|
const surface = ctx.listener.surface;
|
|
@@ -1043,7 +1062,7 @@ var AudioDirector = class {
|
|
|
1043
1062
|
if (!sound) return;
|
|
1044
1063
|
this.fireOneShot({
|
|
1045
1064
|
sound,
|
|
1046
|
-
gain: (sound.entry.gain ?? 1) * (f.gain ?? 1),
|
|
1065
|
+
gain: (sound.entry.gain ?? 1) * (f.gain ?? 1) * Math.max(.4, Math.min(1.15, ctx.listener.speed / 3)) * (.9 + .1 * unitRandom(this.seed, "step-gain", this.serial)),
|
|
1047
1066
|
pitchMul: 1,
|
|
1048
1067
|
bus: sound.entry.bus ?? "sfx",
|
|
1049
1068
|
key: "footstep"
|
|
@@ -1330,8 +1349,12 @@ var WebAudioBackend = class {
|
|
|
1330
1349
|
staleS;
|
|
1331
1350
|
onError;
|
|
1332
1351
|
master;
|
|
1352
|
+
limiter;
|
|
1333
1353
|
buses = /* @__PURE__ */ new Map();
|
|
1334
1354
|
buffers = /* @__PURE__ */ new Map();
|
|
1355
|
+
bufferSizes = /* @__PURE__ */ new Map();
|
|
1356
|
+
maxDecodedBytes;
|
|
1357
|
+
decodedBytes = 0;
|
|
1335
1358
|
voices = /* @__PURE__ */ new Map();
|
|
1336
1359
|
decoded = 0;
|
|
1337
1360
|
pending = 0;
|
|
@@ -1340,10 +1363,18 @@ var WebAudioBackend = class {
|
|
|
1340
1363
|
constructor(opts) {
|
|
1341
1364
|
this.provider = opts.provider;
|
|
1342
1365
|
this.staleS = opts.staleOneShotS ?? .35;
|
|
1366
|
+
this.maxDecodedBytes = Math.max(0, opts.maxDecodedBytes ?? 96 * 1024 * 1024);
|
|
1343
1367
|
this.onError = opts.onError;
|
|
1344
1368
|
this.context = opts.context ?? new AudioContext({ latencyHint: "interactive" });
|
|
1345
1369
|
this.master = this.context.createGain();
|
|
1346
|
-
this.
|
|
1370
|
+
this.limiter = this.context.createDynamicsCompressor();
|
|
1371
|
+
this.limiter.threshold.value = -3;
|
|
1372
|
+
this.limiter.knee.value = 3;
|
|
1373
|
+
this.limiter.ratio.value = 12;
|
|
1374
|
+
this.limiter.attack.value = .003;
|
|
1375
|
+
this.limiter.release.value = .2;
|
|
1376
|
+
this.master.connect(this.limiter);
|
|
1377
|
+
this.limiter.connect(this.context.destination);
|
|
1347
1378
|
for (const bus of AUDIO_BUSES) this.bus(bus);
|
|
1348
1379
|
}
|
|
1349
1380
|
get unlocked() {
|
|
@@ -1393,6 +1424,10 @@ var WebAudioBackend = class {
|
|
|
1393
1424
|
if (this.disposed) return;
|
|
1394
1425
|
for (const id of [...this.voices.keys()]) this.stop(id, 0);
|
|
1395
1426
|
this.disposed = true;
|
|
1427
|
+
this.buffers.clear();
|
|
1428
|
+
this.bufferSizes.clear();
|
|
1429
|
+
this.decodedBytes = 0;
|
|
1430
|
+
this.limiter.disconnect();
|
|
1396
1431
|
this.context.close().catch(() => {});
|
|
1397
1432
|
}
|
|
1398
1433
|
bus(name) {
|
|
@@ -1407,21 +1442,43 @@ var WebAudioBackend = class {
|
|
|
1407
1442
|
}
|
|
1408
1443
|
load(ref) {
|
|
1409
1444
|
let p = this.buffers.get(ref);
|
|
1445
|
+
if (p) {
|
|
1446
|
+
this.buffers.delete(ref);
|
|
1447
|
+
this.buffers.set(ref, p);
|
|
1448
|
+
}
|
|
1410
1449
|
if (!p) {
|
|
1411
1450
|
this.pending++;
|
|
1412
1451
|
p = this.provider.load(ref).then((bytes) => this.context.decodeAudioData(bytes.slice(0))).then((buffer) => {
|
|
1413
1452
|
this.decoded++;
|
|
1453
|
+
if (!this.disposed) {
|
|
1454
|
+
const bytes = buffer.length * buffer.numberOfChannels * 4;
|
|
1455
|
+
this.bufferSizes.set(ref, bytes);
|
|
1456
|
+
this.decodedBytes += bytes;
|
|
1457
|
+
}
|
|
1414
1458
|
return buffer;
|
|
1415
1459
|
}).catch((error) => {
|
|
1416
1460
|
this.onError?.(`audio clip "${ref}" failed to load: ${String(error)}`);
|
|
1417
1461
|
return null;
|
|
1418
1462
|
}).finally(() => {
|
|
1419
1463
|
this.pending--;
|
|
1464
|
+
this.trimBuffers();
|
|
1420
1465
|
});
|
|
1421
1466
|
this.buffers.set(ref, p);
|
|
1422
1467
|
}
|
|
1423
1468
|
return p;
|
|
1424
1469
|
}
|
|
1470
|
+
trimBuffers() {
|
|
1471
|
+
if (this.decodedBytes <= this.maxDecodedBytes) return;
|
|
1472
|
+
const playing = new Set([...this.voices.values()].map((v) => v.cmd.ref));
|
|
1473
|
+
for (const ref of this.buffers.keys()) {
|
|
1474
|
+
const bytes = this.bufferSizes.get(ref);
|
|
1475
|
+
if (bytes === void 0 || playing.has(ref)) continue;
|
|
1476
|
+
this.buffers.delete(ref);
|
|
1477
|
+
this.bufferSizes.delete(ref);
|
|
1478
|
+
this.decodedBytes -= bytes;
|
|
1479
|
+
if (this.decodedBytes <= this.maxDecodedBytes) break;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1425
1482
|
start(cmd) {
|
|
1426
1483
|
if (!cmd.loop && !this.unlocked) return;
|
|
1427
1484
|
this.stop(cmd.voice, 0);
|
|
@@ -1527,6 +1584,7 @@ var WebAudioBackend = class {
|
|
|
1527
1584
|
v.gain.disconnect();
|
|
1528
1585
|
v.panner?.disconnect();
|
|
1529
1586
|
} catch {}
|
|
1587
|
+
this.trimBuffers();
|
|
1530
1588
|
}
|
|
1531
1589
|
setListener(p, f, u) {
|
|
1532
1590
|
const l = this.context.listener;
|
package/dist/camera-track.d.mts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as readModelSignals, n as ModelSignals, r as createModelSignalVisual, t as ModelSignalVisual } from "./model-signals-BpeXhsim.mjs";
|
|
2
2
|
import { a as createUrlAssetProvider, i as UrlAssetProviderOptions, n as AssetProvider, r as LoadedGltf, t as AssetCache } from "./assets-IbO4GJpF.mjs";
|
|
3
|
-
import { A as createWebGlSkyReflectionFilter, C as EarthSkyState, D as SkyReflectionFilter, E as starDirection, F as FrameAdmissionQueue, I as SceneAdmission, M as AdmissionOptions, N as AdmissionSample, O as SkyReflectionState, P as FrameAdmissionOptions, S as CelestialPosition, T as skyTimeMs, _ as SkyFrame, a as RendererBackendPreference, b as SkyVisualOptions, c as TopDownOrtho, d as ShadowFocus, f as ShadowQuality, g as WeatherVisual, h as createGpuFrameTimer, i as RendererBackend, j as reflectionStateFromLights, k as SkyReflections, l as nextWorldOrigin, m as GpuFrameTimerOptions, n as CameraPose, o as RendererOptions, p as GpuFrameTimer, r as Renderer, s as ThreeRenderer, t as AutoWorldOriginOptions, u as orthoFrustum, v as SkyStar, w as evaluateEarthSky, x as defaultSkyPalette, y as SkyVisual } from "./renderer-
|
|
3
|
+
import { A as createWebGlSkyReflectionFilter, C as EarthSkyState, D as SkyReflectionFilter, E as starDirection, F as FrameAdmissionQueue, I as SceneAdmission, M as AdmissionOptions, N as AdmissionSample, O as SkyReflectionState, P as FrameAdmissionOptions, S as CelestialPosition, T as skyTimeMs, _ as SkyFrame, a as RendererBackendPreference, b as SkyVisualOptions, c as TopDownOrtho, d as ShadowFocus, f as ShadowQuality, g as WeatherVisual, h as createGpuFrameTimer, i as RendererBackend, j as reflectionStateFromLights, k as SkyReflections, l as nextWorldOrigin, m as GpuFrameTimerOptions, n as CameraPose, o as RendererOptions, p as GpuFrameTimer, r as Renderer, s as ThreeRenderer, t as AutoWorldOriginOptions, u as orthoFrustum, v as SkyStar, w as evaluateEarthSky, x as defaultSkyPalette, y as SkyVisual } from "./renderer-CtEtmwJG.mjs";
|
|
4
4
|
import { a as normalizeInputAxis, i as InputMapOptions, n as InputGamepad, o as resolveAction, r as InputMap, t as InputBindings } from "./input-CD-dHuv0.mjs";
|
|
5
5
|
import { Command, ControlAction, CustomSkyData, Delta, DiagMessage, EarthObserver, EarthSkyData, EngineEvent, EntityId, JsonObject, JsonValue, Keyframe, MessageLink, ModelSignalSpec, Quat, ResolvedWeather, SceneCamera, SceneInput, SceneManifest, SkyAppearance, SkyBodyData, SkyData, SkyData as SkyData$1, SkyPalette, SkyTime, Vec3, WeatherData, WeatherProfile, resolveWeather, weatherProfile } from "@bendyline/molen-schema";
|
|
6
6
|
import * as THREE from "three";
|
|
@@ -159,6 +159,8 @@ declare class InterpolationBuffer {
|
|
|
159
159
|
get latestTick(): number | undefined;
|
|
160
160
|
/** Number of snapshots currently held (≤ capacity). */
|
|
161
161
|
get size(): number;
|
|
162
|
+
/** Resume wall-clock playback after an intentional pause, retaining poses and the render floor. */
|
|
163
|
+
resumeClock(nowMs: number): void;
|
|
162
164
|
/**
|
|
163
165
|
* Fold one arrival into the smoothed clock offset. Anchoring on the newest arrival instead (the
|
|
164
166
|
* old `latest.tick + (now - latest.recvMs)`) makes every stall a visible rewind: a delta that
|
|
@@ -506,6 +508,7 @@ declare class ThreeSceneBackend implements SceneBackend {
|
|
|
506
508
|
private readonly modelSignals;
|
|
507
509
|
private readonly identities;
|
|
508
510
|
private readonly lights;
|
|
511
|
+
private readonly pointLightSlots;
|
|
509
512
|
/** Refcounted primitive geometry, keyed by `geometryKey`; disposed when the count hits 0. */
|
|
510
513
|
private readonly geometries;
|
|
511
514
|
private readonly entityGeometry;
|
|
@@ -573,6 +576,7 @@ declare class ThreeSceneBackend implements SceneBackend {
|
|
|
573
576
|
/** Exact tick-derived poses on return to view; invisible shadow casters are never skipped. */
|
|
574
577
|
updateLiveAnimations(tick: number, tickRate: number, camera: THREE.Camera): void;
|
|
575
578
|
private updateLocalLights;
|
|
579
|
+
private isSlottedPoint;
|
|
576
580
|
entityForIntersection(hit: THREE.Intersection): EntityId | undefined;
|
|
577
581
|
count(): number;
|
|
578
582
|
dispose(): void;
|