@bendyline/molen-client 0.0.11 → 0.0.12
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 +3 -27
- package/dist/aircraft.mjs +229 -215
- package/dist/audio.d.mts +10 -1
- package/dist/audio.mjs +131 -6
- package/dist/camera-track.d.mts +1 -1
- package/dist/clouds-DmASLVoe.mjs +862 -0
- package/dist/glass.d.mts +19 -0
- package/dist/glass.mjs +249 -0
- package/dist/index.d.mts +14 -3
- package/dist/index.mjs +577 -147
- package/dist/{livery-C0abgthY.mjs → livery-qcDLzbU9.mjs} +7 -2
- package/dist/navigation.d.mts +19 -6
- package/dist/navigation.mjs +133 -83
- package/dist/{renderer-Dzus24ZF.d.mts → renderer-DAk7C8jH.d.mts} +234 -17
- package/dist/vehicle-interior-B8TpzTAx.d.mts +56 -0
- package/dist/vehicle-interior-CeyzF5El.mjs +455 -0
- package/dist/vehicles.d.mts +25 -20
- package/dist/vehicles.mjs +270 -66
- package/dist/webgpu-clouds-H03g7ID1.mjs +186 -0
- package/package.json +7 -3
- package/dist/vehicle-interior-BgcC750p.d.mts +0 -31
- package/dist/vehicle-interior-DfpZwWEh.mjs +0 -15
|
@@ -149,8 +149,8 @@ function applyLivery(model, data) {
|
|
|
149
149
|
for (const [name, binding] of Object.entries(data.slots)) {
|
|
150
150
|
const subtree = binding.node === void 0 ? model : model.getObjectByName(binding.node);
|
|
151
151
|
const meshes = [], bounds = new THREE.Box3();
|
|
152
|
-
|
|
153
|
-
if (!(object instanceof THREE.Mesh) || !materialsOf(object).some((m) => binding.materials.includes(m.name))) return;
|
|
152
|
+
const collect = (object) => {
|
|
153
|
+
if (!(object instanceof THREE.Mesh) || meshes.includes(object) || !materialsOf(object).some((m) => binding.materials.includes(m.name))) return;
|
|
154
154
|
if (object.isSkinnedMesh || object.morphTargetInfluences?.length) {
|
|
155
155
|
warnings.push(`Slot ${name}: deforming mesh ${object.name} is unsupported`);
|
|
156
156
|
return;
|
|
@@ -161,6 +161,11 @@ function applyLivery(model, data) {
|
|
|
161
161
|
surface.computeBoundingBox();
|
|
162
162
|
if (surface.boundingBox) bounds.union(surface.boundingBox);
|
|
163
163
|
surface.dispose();
|
|
164
|
+
};
|
|
165
|
+
subtree?.traverse(collect);
|
|
166
|
+
if (binding.node !== void 0) model.traverse((object) => {
|
|
167
|
+
const sources = object.userData.liverySourceNodes;
|
|
168
|
+
if (Array.isArray(sources) && sources.includes(binding.node)) collect(object);
|
|
164
169
|
});
|
|
165
170
|
if (!meshes.length || bounds.isEmpty()) warnings.push(`Slot ${name}: no matching surface`);
|
|
166
171
|
slots.set(name, {
|
package/dist/navigation.d.mts
CHANGED
|
@@ -183,7 +183,7 @@ type NavigationProfileName = "orbit" | "fly" | "walk" | "drive" | "pilot";
|
|
|
183
183
|
* Default key/gamepad bindings per navigation mode. Orbit and fly use Q/E for down/up; walk and
|
|
184
184
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, Shift to sprint
|
|
185
185
|
* 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
|
-
* bank,
|
|
186
|
+
* bank, Z/C work the rudder or pedals, =/− (or numpad +/−, Page Up/Down) set throttle or
|
|
187
187
|
* collective, I toggles the engine, G the gear, F the flaps, R recovers after an impact, Space
|
|
188
188
|
* brakes, V switches the view and E leaves. T toggles travel boost in walk, drive and pilot.
|
|
189
189
|
* Hosts may replace any profile through
|
|
@@ -208,6 +208,10 @@ interface PilotInput {
|
|
|
208
208
|
}
|
|
209
209
|
/** Everything a navigation controller reads in one frame. */
|
|
210
210
|
interface NavigationInput {
|
|
211
|
+
/** Repair presses in the drive profile (R); the host requires a stopped vehicle. */
|
|
212
|
+
recover?: number;
|
|
213
|
+
/** Edge-triggered model mechanism toggles; unsupported mechanisms are ignored by hosts. */
|
|
214
|
+
actuators?: Record<string, number>;
|
|
211
215
|
/** Movement intent, each -1..1 (forward, right, up). */
|
|
212
216
|
move: {
|
|
213
217
|
forward: number;
|
|
@@ -271,6 +275,7 @@ declare class NavigationInputSource {
|
|
|
271
275
|
private interactPresses;
|
|
272
276
|
private viewPresses;
|
|
273
277
|
private boostPresses;
|
|
278
|
+
private actuatorPresses;
|
|
274
279
|
private profile;
|
|
275
280
|
private readonly pilotPresses;
|
|
276
281
|
private readonly lookSpeed;
|
|
@@ -536,8 +541,10 @@ interface WalkCollisionOptions {
|
|
|
536
541
|
/**
|
|
537
542
|
* A small collision neighborhood in metric coordinates, independent of floating-origin shifts.
|
|
538
543
|
* Only visible, resident geometry under `root` participates; evicted tiles and hidden layers
|
|
539
|
-
* disappear on the next scan,
|
|
540
|
-
*
|
|
544
|
+
* disappear on the next scan, including meshes with all render layers disabled unless marked
|
|
545
|
+
* `userData.walkCollisionOnly` (for example, a smooth staircase proxy). Instance
|
|
546
|
+
* transforms are expanded only inside the neighborhood. Large geometries (terrain tiles,
|
|
547
|
+
* building cells) are walked through a per-geometry
|
|
541
548
|
* spatial index, so a rebuild costs the triangles near the subject rather than the whole tile.
|
|
542
549
|
* Meshes opt out with `userData.walkIgnore`, and water materials (`userData.terrainWaterMaterial`)
|
|
543
550
|
* are never solid. Land cover is a solid walking surface: its visible elevation can differ from
|
|
@@ -582,6 +589,7 @@ declare class WalkCollision {
|
|
|
582
589
|
declare const WALK_EYE_HEIGHT: number;
|
|
583
590
|
declare const WALK_SPEED: number;
|
|
584
591
|
declare const RUN_SPEED: number;
|
|
592
|
+
declare const SWIM_SPEED: number;
|
|
585
593
|
/**
|
|
586
594
|
* How far from the requested spot `place` may land the body, including its radius: the ground a
|
|
587
595
|
* host should have loaded (terrain and anything built on it) before calling `place`.
|
|
@@ -598,14 +606,18 @@ interface WalkInput {
|
|
|
598
606
|
* First-person walking over streamed geometry: a 1.8 m capsule with gravity, jumping, wall
|
|
599
607
|
* sliding and a 50° walkable-slope limit, integrated at a fixed 120 Hz so results agree across
|
|
600
608
|
* frame rates. `feet` is the world position; put the camera `WALK_EYE_HEIGHT` above it. Missing
|
|
601
|
-
* terrain pauses movement (it is never a bottomless pit) until coverage arrives.
|
|
609
|
+
* terrain pauses movement (it is never a bottomless pit) until coverage arrives. Set
|
|
610
|
+
* `sampleWaterHeight` to float in deep water and automatically walk again in the shallows.
|
|
602
611
|
*/
|
|
603
612
|
declare class WalkController {
|
|
604
|
-
/** Four times walking/running speed; jump height and look response stay normal. */
|
|
613
|
+
/** Four times walking/running/swimming speed; jump height and look response stay normal. */
|
|
605
614
|
boostMode: boolean;
|
|
606
615
|
readonly feet: THREE.Vector3;
|
|
607
616
|
readonly velocity: THREE.Vector3;
|
|
608
617
|
grounded: boolean;
|
|
618
|
+
swimming: boolean;
|
|
619
|
+
/** Water surface in world meters; null means dry, undefined means coverage is loading. */
|
|
620
|
+
sampleWaterHeight?: (x: number, z: number) => number | null | undefined;
|
|
609
621
|
ready: boolean;
|
|
610
622
|
waitingForTerrain: boolean;
|
|
611
623
|
private accumulator;
|
|
@@ -615,10 +627,11 @@ declare class WalkController {
|
|
|
615
627
|
/**
|
|
616
628
|
* Find supported open ground. A separate `groundCollision` can exclude vehicles from the
|
|
617
629
|
* landing ray while `collision` still rejects body overlaps, placing people beside cars.
|
|
630
|
+
* Deep water supports placement even when no solid lake bed is rendered.
|
|
618
631
|
*/
|
|
619
632
|
place(collision: WalkCollision, sampleHeight: (x: number, z: number) => number | undefined, groundCollision?: WalkCollision): boolean;
|
|
620
633
|
update(dt: number, input: WalkInput, collision: WalkCollision, sampleHeight: (x: number, z: number) => number | undefined): void;
|
|
621
634
|
private setCapsule;
|
|
622
635
|
}
|
|
623
636
|
//#endregion
|
|
624
|
-
export { type CameraOrientation, CollisionTree, FlyController, type FlyControllerOptions, FollowController, type FollowControllerOptions, type FollowSubject, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, type NavigationControls, type NavigationControlsOptions, type NavigationEnvironment, type NavigationGestures, type NavigationInput, NavigationInputSource, type NavigationInputSourceOptions, type NavigationKeyTarget, NavigationPointer, type NavigationPointerEvent, type NavigationPointerOptions, type NavigationPointerSurface, type NavigationPose, type NavigationProfileName, type NavigationVector, type NavigationWheelEvent, OrbitController, type OrbitControllerOptions, type OrbitFlyToOptions, type OrbitState, type PilotInput, RUN_SPEED, type TouchJoystick, type TouchJoystickOptions, TouchStick, type TouchStickOptions, WALK_EYE_HEIGHT, WALK_PLACEMENT_RADIUS, WALK_SPEED, WalkCollision, type WalkCollisionOptions, WalkController, type WalkInput, applyCameraLookDelta, cameraForward, cameraPlanarForward, cameraRight, createNavigationControls, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|
|
637
|
+
export { type CameraOrientation, CollisionTree, FlyController, type FlyControllerOptions, FollowController, type FollowControllerOptions, type FollowSubject, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, type NavigationControls, type NavigationControlsOptions, type NavigationEnvironment, type NavigationGestures, type NavigationInput, NavigationInputSource, type NavigationInputSourceOptions, type NavigationKeyTarget, NavigationPointer, type NavigationPointerEvent, type NavigationPointerOptions, type NavigationPointerSurface, type NavigationPose, type NavigationProfileName, type NavigationVector, type NavigationWheelEvent, OrbitController, type OrbitControllerOptions, type OrbitFlyToOptions, type OrbitState, type PilotInput, RUN_SPEED, SWIM_SPEED, type TouchJoystick, type TouchJoystickOptions, TouchStick, type TouchStickOptions, WALK_EYE_HEIGHT, WALK_PLACEMENT_RADIUS, WALK_SPEED, WalkCollision, type WalkCollisionOptions, WalkController, type WalkInput, applyCameraLookDelta, cameraForward, cameraPlanarForward, cameraRight, createNavigationControls, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|
package/dist/navigation.mjs
CHANGED
|
@@ -371,6 +371,20 @@ const NAVIGATION_ACTIONS = {
|
|
|
371
371
|
vector: "nav-vector",
|
|
372
372
|
recover: "nav-recover"
|
|
373
373
|
};
|
|
374
|
+
const ACTUATOR_KEYS = {
|
|
375
|
+
KeyB: "speedBrake",
|
|
376
|
+
KeyH: "tailHook",
|
|
377
|
+
KeyO: "canopy",
|
|
378
|
+
KeyK: "wipers",
|
|
379
|
+
KeyL: "headlights",
|
|
380
|
+
Digit1: "doorFrontLeft",
|
|
381
|
+
Digit2: "doorFrontRight",
|
|
382
|
+
Digit3: "doorRearLeft",
|
|
383
|
+
Digit4: "doorRearRight",
|
|
384
|
+
Digit5: "hood",
|
|
385
|
+
Digit6: "trunk"
|
|
386
|
+
};
|
|
387
|
+
const ACTUATOR_BINDINGS = Object.fromEntries(Object.entries(ACTUATOR_KEYS).map(([key, name]) => [key, `nav-actuator-${name}`]));
|
|
374
388
|
const A = NAVIGATION_ACTIONS;
|
|
375
389
|
const MOVE_KEYS = {
|
|
376
390
|
KeyW: A.forward,
|
|
@@ -430,7 +444,7 @@ const STICKS = [
|
|
|
430
444
|
* Default key/gamepad bindings per navigation mode. Orbit and fly use Q/E for down/up; walk and
|
|
431
445
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, Shift to sprint
|
|
432
446
|
* 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 ←/→)
|
|
433
|
-
* bank,
|
|
447
|
+
* bank, Z/C work the rudder or pedals, =/− (or numpad +/−, Page Up/Down) set throttle or
|
|
434
448
|
* collective, I toggles the engine, G the gear, F the flaps, R recovers after an impact, Space
|
|
435
449
|
* brakes, V switches the view and E leaves. T toggles travel boost in walk, drive and pilot.
|
|
436
450
|
* Hosts may replace any profile through
|
|
@@ -490,79 +504,84 @@ function navigationInputProfiles() {
|
|
|
490
504
|
}
|
|
491
505
|
]
|
|
492
506
|
};
|
|
507
|
+
const pilot = {
|
|
508
|
+
bindings: {
|
|
509
|
+
...ACTUATOR_BINDINGS,
|
|
510
|
+
KeyW: A.forward,
|
|
511
|
+
ArrowUp: A.forward,
|
|
512
|
+
KeyS: A.back,
|
|
513
|
+
ArrowDown: A.back,
|
|
514
|
+
KeyA: A.left,
|
|
515
|
+
ArrowLeft: A.left,
|
|
516
|
+
KeyD: A.right,
|
|
517
|
+
ArrowRight: A.right,
|
|
518
|
+
KeyZ: A.yawLeft,
|
|
519
|
+
KeyC: A.yawRight,
|
|
520
|
+
Equal: A.throttleUp,
|
|
521
|
+
NumpadAdd: A.throttleUp,
|
|
522
|
+
PageUp: A.throttleUp,
|
|
523
|
+
Minus: A.throttleDown,
|
|
524
|
+
NumpadSubtract: A.throttleDown,
|
|
525
|
+
PageDown: A.throttleDown,
|
|
526
|
+
Space: A.jump,
|
|
527
|
+
KeyE: A.interact,
|
|
528
|
+
KeyV: A.view,
|
|
529
|
+
KeyT: A.boost,
|
|
530
|
+
KeyI: A.engine,
|
|
531
|
+
KeyG: A.gear,
|
|
532
|
+
KeyF: A.flaps,
|
|
533
|
+
KeyJ: A.vector,
|
|
534
|
+
KeyR: A.recover
|
|
535
|
+
},
|
|
536
|
+
axes: STICKS,
|
|
537
|
+
buttons: [
|
|
538
|
+
{
|
|
539
|
+
button: 7,
|
|
540
|
+
action: A.throttleUp
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
button: 6,
|
|
544
|
+
action: A.throttleDown
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
button: 4,
|
|
548
|
+
action: A.yawLeft
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
button: 5,
|
|
552
|
+
action: A.yawRight
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
button: 0,
|
|
556
|
+
action: A.jump
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
button: 2,
|
|
560
|
+
action: A.interact
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
button: 3,
|
|
564
|
+
action: A.view
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
button: 1,
|
|
568
|
+
action: A.engine
|
|
569
|
+
}
|
|
570
|
+
]
|
|
571
|
+
};
|
|
493
572
|
return {
|
|
494
573
|
orbit: aerial,
|
|
495
574
|
fly: aerial,
|
|
496
575
|
walk: ground,
|
|
497
|
-
drive:
|
|
498
|
-
|
|
576
|
+
drive: {
|
|
577
|
+
...ground,
|
|
499
578
|
bindings: {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
KeyS: A.back,
|
|
503
|
-
ArrowDown: A.back,
|
|
504
|
-
KeyA: A.left,
|
|
505
|
-
ArrowLeft: A.left,
|
|
506
|
-
KeyD: A.right,
|
|
507
|
-
ArrowRight: A.right,
|
|
508
|
-
KeyQ: A.yawLeft,
|
|
509
|
-
KeyZ: A.yawRight,
|
|
510
|
-
ShiftLeft: A.throttleUp,
|
|
511
|
-
ShiftRight: A.throttleUp,
|
|
512
|
-
Equal: A.throttleUp,
|
|
513
|
-
NumpadAdd: A.throttleUp,
|
|
514
|
-
PageUp: A.throttleUp,
|
|
515
|
-
ControlLeft: A.throttleDown,
|
|
516
|
-
ControlRight: A.throttleDown,
|
|
517
|
-
Minus: A.throttleDown,
|
|
518
|
-
NumpadSubtract: A.throttleDown,
|
|
519
|
-
PageDown: A.throttleDown,
|
|
520
|
-
Space: A.jump,
|
|
521
|
-
KeyE: A.interact,
|
|
522
|
-
KeyV: A.view,
|
|
523
|
-
KeyT: A.boost,
|
|
524
|
-
KeyI: A.engine,
|
|
525
|
-
KeyG: A.gear,
|
|
526
|
-
KeyF: A.flaps,
|
|
527
|
-
KeyJ: A.vector,
|
|
579
|
+
...ground.bindings,
|
|
580
|
+
...ACTUATOR_BINDINGS,
|
|
528
581
|
KeyR: A.recover
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
{
|
|
533
|
-
button: 7,
|
|
534
|
-
action: A.throttleUp
|
|
535
|
-
},
|
|
536
|
-
{
|
|
537
|
-
button: 6,
|
|
538
|
-
action: A.throttleDown
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
button: 4,
|
|
542
|
-
action: A.yawLeft
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
button: 5,
|
|
546
|
-
action: A.yawRight
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
button: 0,
|
|
550
|
-
action: A.jump
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
button: 2,
|
|
554
|
-
action: A.interact
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
button: 3,
|
|
558
|
-
action: A.view
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
button: 1,
|
|
562
|
-
action: A.engine
|
|
563
|
-
}
|
|
564
|
-
]
|
|
565
|
-
}
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
pilot
|
|
566
585
|
};
|
|
567
586
|
}
|
|
568
587
|
/** An input with no intent; controllers treat it as "hold still". */
|
|
@@ -594,6 +613,7 @@ var NavigationInputSource = class {
|
|
|
594
613
|
interactPresses = 0;
|
|
595
614
|
viewPresses = 0;
|
|
596
615
|
boostPresses = 0;
|
|
616
|
+
actuatorPresses = {};
|
|
597
617
|
profile;
|
|
598
618
|
pilotPresses = {
|
|
599
619
|
engine: 0,
|
|
@@ -617,6 +637,9 @@ var NavigationInputSource = class {
|
|
|
617
637
|
this.lookSpeed = options.gamepadLookSpeed ?? 900;
|
|
618
638
|
this.profile = options.profile ?? "orbit";
|
|
619
639
|
this.unsubscribe = [
|
|
640
|
+
...Object.values(ACTUATOR_KEYS).map((name) => this.map.onPress(`nav-actuator-${name}`, () => {
|
|
641
|
+
this.actuatorPresses[name] = (this.actuatorPresses[name] ?? 0) + 1;
|
|
642
|
+
})),
|
|
620
643
|
...[
|
|
621
644
|
"engine",
|
|
622
645
|
"gear",
|
|
@@ -640,6 +663,7 @@ var NavigationInputSource = class {
|
|
|
640
663
|
this.interactPresses = 0;
|
|
641
664
|
this.viewPresses = 0;
|
|
642
665
|
this.boostPresses = 0;
|
|
666
|
+
this.actuatorPresses = {};
|
|
643
667
|
this.pilotPresses.engine = 0;
|
|
644
668
|
this.pilotPresses.gear = 0;
|
|
645
669
|
this.pilotPresses.flaps = 0;
|
|
@@ -687,6 +711,8 @@ var NavigationInputSource = class {
|
|
|
687
711
|
view: this.viewPresses,
|
|
688
712
|
...this.boostPresses > 0 ? { boost: this.boostPresses } : {},
|
|
689
713
|
taps: gestures.taps,
|
|
714
|
+
...Object.keys(this.actuatorPresses).length ? { actuators: { ...this.actuatorPresses } } : {},
|
|
715
|
+
...this.profile === "drive" && this.pilotPresses.recover > 0 ? { recover: this.pilotPresses.recover } : {},
|
|
690
716
|
...this.profile === "pilot" ? { pilot: {
|
|
691
717
|
...this.map.hasAxis(A.power) ? { power: v(A.power) } : {},
|
|
692
718
|
throttle: v(A.throttleUp) - v(A.throttleDown),
|
|
@@ -702,6 +728,7 @@ var NavigationInputSource = class {
|
|
|
702
728
|
this.pilotPresses.flaps = 0;
|
|
703
729
|
this.pilotPresses.vector = 0;
|
|
704
730
|
this.pilotPresses.recover = 0;
|
|
731
|
+
this.actuatorPresses = {};
|
|
705
732
|
return input;
|
|
706
733
|
}
|
|
707
734
|
dispose() {
|
|
@@ -1653,8 +1680,10 @@ function requireFinite(value, name, allowZero) {
|
|
|
1653
1680
|
/**
|
|
1654
1681
|
* A small collision neighborhood in metric coordinates, independent of floating-origin shifts.
|
|
1655
1682
|
* Only visible, resident geometry under `root` participates; evicted tiles and hidden layers
|
|
1656
|
-
* disappear on the next scan,
|
|
1657
|
-
*
|
|
1683
|
+
* disappear on the next scan, including meshes with all render layers disabled unless marked
|
|
1684
|
+
* `userData.walkCollisionOnly` (for example, a smooth staircase proxy). Instance
|
|
1685
|
+
* transforms are expanded only inside the neighborhood. Large geometries (terrain tiles,
|
|
1686
|
+
* building cells) are walked through a per-geometry
|
|
1658
1687
|
* spatial index, so a rebuild costs the triangles near the subject rather than the whole tile.
|
|
1659
1688
|
* Meshes opt out with `userData.walkIgnore`, and water materials (`userData.terrainWaterMaterial`)
|
|
1660
1689
|
* are never solid. Land cover is a solid walking surface: its visible elevation can differ from
|
|
@@ -1727,7 +1756,7 @@ var WalkCollision = class {
|
|
|
1727
1756
|
for (const child of object.children) visit(child, inspect);
|
|
1728
1757
|
};
|
|
1729
1758
|
visit(root, (object) => {
|
|
1730
|
-
if (!(object instanceof THREE.Mesh) || object.userData.walkIgnore === true) return;
|
|
1759
|
+
if (!(object instanceof THREE.Mesh) || object.userData.walkIgnore === true || object.layers.mask === 0 && object.userData.walkCollisionOnly !== true) return;
|
|
1731
1760
|
if (this.ignoreVehicles && (object.userData.vehicleIds || object.userData.vehicleGeometry)) return;
|
|
1732
1761
|
if ((Array.isArray(object.material) ? object.material : [object.material]).every((material) => material.userData.terrainWaterMaterial === true)) return;
|
|
1733
1762
|
const matrix = candidate.multiplyMatrices(inverse, object.matrixWorld);
|
|
@@ -1951,6 +1980,8 @@ function addBox(tree, box, transform) {
|
|
|
1951
1980
|
const WALK_EYE_HEIGHT = 1.7;
|
|
1952
1981
|
const WALK_SPEED = 1.5;
|
|
1953
1982
|
const RUN_SPEED = 4;
|
|
1983
|
+
const SWIM_SPEED = 1.2;
|
|
1984
|
+
const SWIM_DEPTH = WALK_EYE_HEIGHT - .45;
|
|
1954
1985
|
const BODY_HEIGHT = 1.8;
|
|
1955
1986
|
const BODY_RADIUS = .3;
|
|
1956
1987
|
/** `place` tries rings of landing spots this far apart, out to this many rings. */
|
|
@@ -1968,14 +1999,18 @@ const FLOOR_NORMAL = Math.cos(Math.PI / 3.6);
|
|
|
1968
1999
|
* First-person walking over streamed geometry: a 1.8 m capsule with gravity, jumping, wall
|
|
1969
2000
|
* sliding and a 50° walkable-slope limit, integrated at a fixed 120 Hz so results agree across
|
|
1970
2001
|
* frame rates. `feet` is the world position; put the camera `WALK_EYE_HEIGHT` above it. Missing
|
|
1971
|
-
* terrain pauses movement (it is never a bottomless pit) until coverage arrives.
|
|
2002
|
+
* terrain pauses movement (it is never a bottomless pit) until coverage arrives. Set
|
|
2003
|
+
* `sampleWaterHeight` to float in deep water and automatically walk again in the shallows.
|
|
1972
2004
|
*/
|
|
1973
2005
|
var WalkController = class {
|
|
1974
|
-
/** Four times walking/running speed; jump height and look response stay normal. */
|
|
2006
|
+
/** Four times walking/running/swimming speed; jump height and look response stay normal. */
|
|
1975
2007
|
boostMode = false;
|
|
1976
2008
|
feet = new THREE.Vector3();
|
|
1977
2009
|
velocity = new THREE.Vector3();
|
|
1978
2010
|
grounded = false;
|
|
2011
|
+
swimming = false;
|
|
2012
|
+
/** Water surface in world meters; null means dry, undefined means coverage is loading. */
|
|
2013
|
+
sampleWaterHeight;
|
|
1979
2014
|
ready = false;
|
|
1980
2015
|
waitingForTerrain = false;
|
|
1981
2016
|
accumulator = 0;
|
|
@@ -1985,6 +2020,7 @@ var WalkController = class {
|
|
|
1985
2020
|
this.feet.set(x, 0, z);
|
|
1986
2021
|
this.velocity.set(0, 0, 0);
|
|
1987
2022
|
this.grounded = false;
|
|
2023
|
+
this.swimming = false;
|
|
1988
2024
|
this.ready = false;
|
|
1989
2025
|
this.waitingForTerrain = true;
|
|
1990
2026
|
this.accumulator = 0;
|
|
@@ -1993,6 +2029,7 @@ var WalkController = class {
|
|
|
1993
2029
|
/**
|
|
1994
2030
|
* Find supported open ground. A separate `groundCollision` can exclude vehicles from the
|
|
1995
2031
|
* landing ray while `collision` still rejects body overlaps, placing people beside cars.
|
|
2032
|
+
* Deep water supports placement even when no solid lake bed is rendered.
|
|
1996
2033
|
*/
|
|
1997
2034
|
place(collision, sampleHeight, groundCollision = collision) {
|
|
1998
2035
|
const centerX = this.feet.x;
|
|
@@ -2003,17 +2040,21 @@ var WalkController = class {
|
|
|
2003
2040
|
const x = centerX + Math.cos(i / count * Math.PI * 2) * ring * PLACEMENT_RING_SPACING;
|
|
2004
2041
|
const z = centerZ + Math.sin(i / count * Math.PI * 2) * ring * PLACEMENT_RING_SPACING;
|
|
2005
2042
|
const ground = sampleHeight(x, z);
|
|
2006
|
-
|
|
2007
|
-
|
|
2043
|
+
const water = this.sampleWaterHeight?.(x, z);
|
|
2044
|
+
if (ground === void 0 && water == null) continue;
|
|
2045
|
+
const ray = new THREE.Ray(new THREE.Vector3(x - groundCollision.origin.x, Math.max(ground ?? -Infinity, water ?? -Infinity) + 1e4, z - groundCollision.origin.z), new THREE.Vector3(0, -1, 0));
|
|
2008
2046
|
const hit = groundCollision.octree.rayIntersect(ray);
|
|
2009
|
-
|
|
2010
|
-
|
|
2047
|
+
const afloat = water != null && (!hit || hit.position.y < water - SWIM_DEPTH);
|
|
2048
|
+
if (!afloat && (!hit || hit.position.y > (ground ?? water ?? 0) + 3)) continue;
|
|
2049
|
+
this.feet.set(x, afloat ? water - SWIM_DEPTH : hit ? hit.position.y + .02 : 0, z);
|
|
2011
2050
|
this.setCapsule(collision);
|
|
2012
2051
|
const overlap = collision.octree.capsuleIntersect(this.capsule);
|
|
2013
2052
|
if (overlap && (overlap.normal.y < FLOOR_NORMAL || overlap.depth > .15)) continue;
|
|
2014
2053
|
this.ready = true;
|
|
2015
2054
|
this.waitingForTerrain = false;
|
|
2016
|
-
this.grounded =
|
|
2055
|
+
this.grounded = !afloat;
|
|
2056
|
+
this.swimming = afloat;
|
|
2057
|
+
this.velocity.set(0, 0, 0);
|
|
2017
2058
|
return true;
|
|
2018
2059
|
}
|
|
2019
2060
|
}
|
|
@@ -2037,15 +2078,18 @@ var WalkController = class {
|
|
|
2037
2078
|
this.grounded = false;
|
|
2038
2079
|
}
|
|
2039
2080
|
const length = Math.max(1, Math.hypot(input.forward, input.right));
|
|
2040
|
-
const
|
|
2041
|
-
const
|
|
2042
|
-
const vz = (Math.sin(input.yaw) * input.forward + Math.cos(input.yaw) * input.right) / length * speed;
|
|
2081
|
+
const forwardX = (Math.cos(input.yaw) * input.forward - Math.sin(input.yaw) * input.right) / length;
|
|
2082
|
+
const forwardZ = (Math.sin(input.yaw) * input.forward + Math.cos(input.yaw) * input.right) / length;
|
|
2043
2083
|
this.accumulator += Math.min(.1, Math.max(0, dt));
|
|
2044
2084
|
while (this.accumulator >= STEP) {
|
|
2045
2085
|
this.accumulator -= STEP;
|
|
2086
|
+
const speed = (this.swimming ? SWIM_SPEED * (input.sprint ? 1.5 : 1) : input.sprint ? 4 : WALK_SPEED) * boostSpeedMultiplier(this.boostMode);
|
|
2087
|
+
const vx = forwardX * speed;
|
|
2088
|
+
const vz = forwardZ * speed;
|
|
2046
2089
|
const nextX = this.feet.x + vx * STEP;
|
|
2047
2090
|
const nextZ = this.feet.z + vz * STEP;
|
|
2048
|
-
|
|
2091
|
+
const water = this.sampleWaterHeight?.(nextX, nextZ);
|
|
2092
|
+
this.waitingForTerrain = sampleHeight(nextX, nextZ) === void 0 && water == null || this.swimming && this.sampleWaterHeight !== void 0 && water === void 0;
|
|
2049
2093
|
if (this.waitingForTerrain) {
|
|
2050
2094
|
this.velocity.set(0, 0, 0);
|
|
2051
2095
|
this.accumulator = 0;
|
|
@@ -2055,6 +2099,11 @@ var WalkController = class {
|
|
|
2055
2099
|
this.velocity.z = vz;
|
|
2056
2100
|
this.velocity.y = Math.max(-35, this.velocity.y - GRAVITY * STEP);
|
|
2057
2101
|
this.feet.addScaledVector(this.velocity, STEP);
|
|
2102
|
+
const floatingFeet = water == null ? -Infinity : water - SWIM_DEPTH;
|
|
2103
|
+
if (this.feet.y <= floatingFeet) {
|
|
2104
|
+
this.feet.y = floatingFeet;
|
|
2105
|
+
this.velocity.y = 0;
|
|
2106
|
+
}
|
|
2058
2107
|
this.setCapsule(collision);
|
|
2059
2108
|
this.grounded = false;
|
|
2060
2109
|
for (let pass = 0; pass < 4; pass++) {
|
|
@@ -2076,6 +2125,7 @@ var WalkController = class {
|
|
|
2076
2125
|
}
|
|
2077
2126
|
this.feet.copy(this.capsule.start).add(collision.origin);
|
|
2078
2127
|
this.feet.y -= BODY_RADIUS;
|
|
2128
|
+
this.swimming = !this.grounded && this.feet.y <= floatingFeet + .05;
|
|
2079
2129
|
}
|
|
2080
2130
|
}
|
|
2081
2131
|
setCapsule(collision) {
|
|
@@ -2087,4 +2137,4 @@ var WalkController = class {
|
|
|
2087
2137
|
}
|
|
2088
2138
|
};
|
|
2089
2139
|
//#endregion
|
|
2090
|
-
export { CollisionTree, FlyController, FollowController, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, NavigationInputSource, NavigationPointer, OrbitController, RUN_SPEED, TouchStick, WALK_EYE_HEIGHT, WALK_PLACEMENT_RADIUS, WALK_SPEED, WalkCollision, WalkController, applyCameraLookDelta, cameraForward, cameraPlanarForward, cameraRight, createNavigationControls, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|
|
2140
|
+
export { CollisionTree, FlyController, FollowController, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, NavigationInputSource, NavigationPointer, OrbitController, RUN_SPEED, SWIM_SPEED, TouchStick, WALK_EYE_HEIGHT, WALK_PLACEMENT_RADIUS, WALK_SPEED, WalkCollision, WalkController, applyCameraLookDelta, cameraForward, cameraPlanarForward, cameraRight, createNavigationControls, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|