@bendyline/molen-client 0.0.3 → 0.0.4
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/dist/markers.d.mts +10 -0
- package/dist/markers.mjs +44 -5
- package/dist/navigation.d.mts +31 -3
- package/dist/navigation.mjs +108 -4
- package/dist/vehicles.d.mts +18 -1
- package/dist/vehicles.mjs +15 -4
- package/package.json +3 -3
package/dist/markers.d.mts
CHANGED
|
@@ -72,6 +72,14 @@ interface MarkerLayerOptions {
|
|
|
72
72
|
occlude?: boolean;
|
|
73
73
|
/** Hide ground-snapped markers until their ground height is known (default true). */
|
|
74
74
|
hideUntilGrounded?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Hide markers whose on-screen footprints overlap a more important one: higher `priority`
|
|
77
|
+
* first, then markers already shown (so pins do not flicker as the camera moves), then the
|
|
78
|
+
* nearest. `padding` adds CSS pixels around each footprint (default 4). Off by default.
|
|
79
|
+
*/
|
|
80
|
+
declutter?: boolean | {
|
|
81
|
+
padding?: number;
|
|
82
|
+
};
|
|
75
83
|
renderOrder?: number;
|
|
76
84
|
}
|
|
77
85
|
interface MarkerScreenPosition {
|
|
@@ -109,6 +117,8 @@ declare class MarkerLayer {
|
|
|
109
117
|
* camera's absolute world position (the one given to `setCamera`).
|
|
110
118
|
*/
|
|
111
119
|
update(cameraPosition: readonly [number, number, number]): void;
|
|
120
|
+
/** CSS-pixel projection of rebased sprite positions, set up once per update. */
|
|
121
|
+
private screenProjector;
|
|
112
122
|
/** The front-most drawn marker under a CSS-pixel point, if any. */
|
|
113
123
|
pick(x: number, y: number): string | undefined;
|
|
114
124
|
/** Where a marker's anchor point appears on screen (for DOM callouts), if it exists. */
|
package/dist/markers.mjs
CHANGED
|
@@ -166,20 +166,57 @@ var MarkerLayer = class {
|
|
|
166
166
|
entry.distance = Math.hypot(spec.x - cameraPosition[0], y - cameraPosition[1], spec.z - cameraPosition[2]);
|
|
167
167
|
candidates.push(entry);
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
const declutter = this.options.declutter;
|
|
170
|
+
const padding = typeof declutter === "object" ? declutter.padding ?? 4 : declutter === true ? 4 : 0;
|
|
171
|
+
candidates.sort((a, b) => (b.spec.priority ?? 0) - (a.spec.priority ?? 0) || (declutter ? Number(b.shown) - Number(a.shown) : 0) || a.distance - b.distance || a.spec.id.localeCompare(b.spec.id));
|
|
170
172
|
const budget = this.options.maxVisible ?? 256;
|
|
171
173
|
const fade = this.options.fade;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
const project = declutter ? this.screenProjector() : void 0;
|
|
175
|
+
const taken = [];
|
|
176
|
+
let drawn = 0;
|
|
177
|
+
for (const entry of candidates) {
|
|
178
|
+
entry.shown = false;
|
|
179
|
+
if (drawn >= budget) continue;
|
|
174
180
|
const opacity = fade === void 0 ? 1 : Math.max(0, Math.min(1, (fade.far - entry.distance) / (fade.far - fade.near)));
|
|
175
181
|
if (opacity <= 0) continue;
|
|
176
182
|
const size = entry.spec.size ?? 56;
|
|
183
|
+
if (project !== void 0) {
|
|
184
|
+
const screen = project(entry.sprite.position);
|
|
185
|
+
if (screen !== void 0) {
|
|
186
|
+
const width = size * entry.aspect;
|
|
187
|
+
const top = (entry.spec.anchor ?? "bottom") === "bottom" ? screen[1] - size : screen[1] - size / 2;
|
|
188
|
+
const box = [
|
|
189
|
+
screen[0] - width / 2 - padding,
|
|
190
|
+
top - padding,
|
|
191
|
+
screen[0] + width / 2 + padding,
|
|
192
|
+
top + size + padding
|
|
193
|
+
];
|
|
194
|
+
if (taken.some((other) => box[0] < other[2] && box[2] > other[0] && box[1] < other[3] && box[3] > other[1])) continue;
|
|
195
|
+
taken.push(box);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
drawn++;
|
|
177
199
|
entry.material.opacity = opacity;
|
|
178
200
|
entry.sprite.scale.set(size * entry.aspect * perPixel, size * perPixel, 1);
|
|
179
201
|
entry.sprite.center.set(.5, (entry.spec.anchor ?? "bottom") === "bottom" ? 0 : .5);
|
|
180
202
|
entry.sprite.visible = true;
|
|
203
|
+
entry.shown = true;
|
|
181
204
|
}
|
|
182
205
|
}
|
|
206
|
+
/** CSS-pixel projection of rebased sprite positions, set up once per update. */
|
|
207
|
+
screenProjector() {
|
|
208
|
+
const [width, height] = this.host.getViewportSize();
|
|
209
|
+
this.host.worldRoot.updateWorldMatrix(true, false);
|
|
210
|
+
this.host.camera.updateMatrixWorld();
|
|
211
|
+
const camera = this.host.camera;
|
|
212
|
+
return (position) => {
|
|
213
|
+
const world = this.host.worldRoot.localToWorld(scratch.copy(position));
|
|
214
|
+
viewSpace.copy(world).applyMatrix4(camera.matrixWorldInverse);
|
|
215
|
+
if (viewSpace.z >= 0) return void 0;
|
|
216
|
+
world.project(camera);
|
|
217
|
+
return [(world.x + 1) / 2 * width, (1 - world.y) / 2 * height];
|
|
218
|
+
};
|
|
219
|
+
}
|
|
183
220
|
/** The front-most drawn marker under a CSS-pixel point, if any. */
|
|
184
221
|
pick(x, y) {
|
|
185
222
|
let best;
|
|
@@ -239,7 +276,8 @@ var MarkerLayer = class {
|
|
|
239
276
|
transparent: true,
|
|
240
277
|
depthWrite: false,
|
|
241
278
|
depthTest: this.options.occlude ?? true,
|
|
242
|
-
sizeAttenuation: false
|
|
279
|
+
sizeAttenuation: false,
|
|
280
|
+
fog: false
|
|
243
281
|
});
|
|
244
282
|
const entry = {
|
|
245
283
|
spec: { ...spec },
|
|
@@ -249,7 +287,8 @@ var MarkerLayer = class {
|
|
|
249
287
|
imageKey: spec.image,
|
|
250
288
|
aspect: imageAspect(spec.image) ?? 1,
|
|
251
289
|
groundY: void 0,
|
|
252
|
-
distance: 0
|
|
290
|
+
distance: 0,
|
|
291
|
+
shown: false
|
|
253
292
|
};
|
|
254
293
|
entry.texture = this.acquire(spec.image, entry);
|
|
255
294
|
material.map = entry.texture;
|
package/dist/navigation.d.mts
CHANGED
|
@@ -155,15 +155,39 @@ declare const NAVIGATION_ACTIONS: {
|
|
|
155
155
|
readonly jump: "nav-jump";
|
|
156
156
|
readonly interact: "nav-interact";
|
|
157
157
|
readonly view: "nav-view";
|
|
158
|
+
readonly throttleUp: "nav-throttle-up";
|
|
159
|
+
readonly throttleDown: "nav-throttle-down";
|
|
160
|
+
readonly yawLeft: "nav-yaw-left";
|
|
161
|
+
readonly yawRight: "nav-yaw-right";
|
|
162
|
+
readonly engine: "nav-engine";
|
|
163
|
+
readonly gear: "nav-gear";
|
|
164
|
+
readonly flaps: "nav-flaps";
|
|
165
|
+
readonly recover: "nav-recover";
|
|
158
166
|
};
|
|
159
167
|
/** The navigation modes with a default input profile. */
|
|
160
|
-
type NavigationProfileName = "orbit" | "fly" | "walk" | "drive";
|
|
168
|
+
type NavigationProfileName = "orbit" | "fly" | "walk" | "drive" | "pilot";
|
|
161
169
|
/**
|
|
162
170
|
* Default key/gamepad bindings per navigation mode. Orbit and fly use Q/E for down/up; walk and
|
|
163
171
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, and V to switch
|
|
164
|
-
* the vehicle view.
|
|
172
|
+
* the vehicle view. Pilot flies an aircraft: W/S (or ↑/↓) pitch the nose down/up, A/D (or ←/→)
|
|
173
|
+
* bank, Q/Z work the rudder or pedals, Shift/Ctrl (or +/−, Page Up/Down) set throttle or
|
|
174
|
+
* collective, I toggles the engine, G the gear, F the flaps, R recovers after an impact, Space
|
|
175
|
+
* brakes, V switches the view and E leaves. Hosts may replace any profile through
|
|
176
|
+
* `InputMap.defineProfile`.
|
|
165
177
|
*/
|
|
166
178
|
declare function navigationInputProfiles(): Record<NavigationProfileName, InputProfile>;
|
|
179
|
+
/** Flight controls beyond pitch (`-move.forward`) and roll (`move.right`), in the pilot profile. */
|
|
180
|
+
interface PilotInput {
|
|
181
|
+
/** Held throttle or collective change, -1..1 (more power positive). */
|
|
182
|
+
throttle: number;
|
|
183
|
+
/** Held rudder or pedals, -1..1 (right positive). */
|
|
184
|
+
yaw: number;
|
|
185
|
+
/** Presses since the previous frame (edge-triggered). */
|
|
186
|
+
engine: number;
|
|
187
|
+
gear: number;
|
|
188
|
+
flaps: number;
|
|
189
|
+
recover: number;
|
|
190
|
+
}
|
|
167
191
|
/** Everything a navigation controller reads in one frame. */
|
|
168
192
|
interface NavigationInput {
|
|
169
193
|
/** Movement intent, each -1..1 (forward, right, up). */
|
|
@@ -192,6 +216,8 @@ interface NavigationInput {
|
|
|
192
216
|
x: number;
|
|
193
217
|
y: number;
|
|
194
218
|
}>;
|
|
219
|
+
/** Flight controls, present while the `pilot` profile is active. */
|
|
220
|
+
pilot?: PilotInput;
|
|
195
221
|
}
|
|
196
222
|
/** An input with no intent; controllers treat it as "hold still". */
|
|
197
223
|
declare function idleNavigationInput(): NavigationInput;
|
|
@@ -224,6 +250,8 @@ declare class NavigationInputSource {
|
|
|
224
250
|
readonly pointer: NavigationPointer;
|
|
225
251
|
private interactPresses;
|
|
226
252
|
private viewPresses;
|
|
253
|
+
private profile;
|
|
254
|
+
private readonly pilotPresses;
|
|
227
255
|
private readonly lookSpeed;
|
|
228
256
|
private readonly unsubscribe;
|
|
229
257
|
constructor(options: NavigationInputSourceOptions);
|
|
@@ -526,4 +554,4 @@ declare class WalkController {
|
|
|
526
554
|
private setCapsule;
|
|
527
555
|
}
|
|
528
556
|
//#endregion
|
|
529
|
-
export { type CameraOrientation, CollisionTree, FlyController, type FlyControllerOptions, FollowController, type FollowControllerOptions, type FollowSubject, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, 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, 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, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|
|
557
|
+
export { type CameraOrientation, CollisionTree, FlyController, type FlyControllerOptions, FollowController, type FollowControllerOptions, type FollowSubject, MAX_LOOK_PITCH, NAVIGATION_ACTIONS, 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, createTouchJoystick, idleNavigationInput, navigationInputProfiles, orientationFromDirection, viewNeedsImmediateUpdate };
|
package/dist/navigation.mjs
CHANGED
|
@@ -401,7 +401,15 @@ const NAVIGATION_ACTIONS = {
|
|
|
401
401
|
sprint: "nav-sprint",
|
|
402
402
|
jump: "nav-jump",
|
|
403
403
|
interact: "nav-interact",
|
|
404
|
-
view: "nav-view"
|
|
404
|
+
view: "nav-view",
|
|
405
|
+
throttleUp: "nav-throttle-up",
|
|
406
|
+
throttleDown: "nav-throttle-down",
|
|
407
|
+
yawLeft: "nav-yaw-left",
|
|
408
|
+
yawRight: "nav-yaw-right",
|
|
409
|
+
engine: "nav-engine",
|
|
410
|
+
gear: "nav-gear",
|
|
411
|
+
flaps: "nav-flaps",
|
|
412
|
+
recover: "nav-recover"
|
|
405
413
|
};
|
|
406
414
|
const A = NAVIGATION_ACTIONS;
|
|
407
415
|
const MOVE_KEYS = {
|
|
@@ -461,7 +469,11 @@ const STICKS = [
|
|
|
461
469
|
/**
|
|
462
470
|
* Default key/gamepad bindings per navigation mode. Orbit and fly use Q/E for down/up; walk and
|
|
463
471
|
* drive use E to interact (board or leave a vehicle), Space to jump or brake, and V to switch
|
|
464
|
-
* the vehicle view.
|
|
472
|
+
* the vehicle view. Pilot flies an aircraft: W/S (or ↑/↓) pitch the nose down/up, A/D (or ←/→)
|
|
473
|
+
* bank, Q/Z work the rudder or pedals, Shift/Ctrl (or +/−, Page Up/Down) set throttle or
|
|
474
|
+
* collective, I toggles the engine, G the gear, F the flaps, R recovers after an impact, Space
|
|
475
|
+
* brakes, V switches the view and E leaves. Hosts may replace any profile through
|
|
476
|
+
* `InputMap.defineProfile`.
|
|
465
477
|
*/
|
|
466
478
|
function navigationInputProfiles() {
|
|
467
479
|
const aerial = {
|
|
@@ -520,7 +532,73 @@ function navigationInputProfiles() {
|
|
|
520
532
|
orbit: aerial,
|
|
521
533
|
fly: aerial,
|
|
522
534
|
walk: ground,
|
|
523
|
-
drive: ground
|
|
535
|
+
drive: ground,
|
|
536
|
+
pilot: {
|
|
537
|
+
bindings: {
|
|
538
|
+
KeyW: A.forward,
|
|
539
|
+
ArrowUp: A.forward,
|
|
540
|
+
KeyS: A.back,
|
|
541
|
+
ArrowDown: A.back,
|
|
542
|
+
KeyA: A.left,
|
|
543
|
+
ArrowLeft: A.left,
|
|
544
|
+
KeyD: A.right,
|
|
545
|
+
ArrowRight: A.right,
|
|
546
|
+
KeyQ: A.yawLeft,
|
|
547
|
+
KeyZ: A.yawRight,
|
|
548
|
+
ShiftLeft: A.throttleUp,
|
|
549
|
+
ShiftRight: A.throttleUp,
|
|
550
|
+
Equal: A.throttleUp,
|
|
551
|
+
NumpadAdd: A.throttleUp,
|
|
552
|
+
PageUp: A.throttleUp,
|
|
553
|
+
ControlLeft: A.throttleDown,
|
|
554
|
+
ControlRight: A.throttleDown,
|
|
555
|
+
Minus: A.throttleDown,
|
|
556
|
+
NumpadSubtract: A.throttleDown,
|
|
557
|
+
PageDown: A.throttleDown,
|
|
558
|
+
Space: A.jump,
|
|
559
|
+
KeyE: A.interact,
|
|
560
|
+
KeyV: A.view,
|
|
561
|
+
KeyI: A.engine,
|
|
562
|
+
KeyG: A.gear,
|
|
563
|
+
KeyF: A.flaps,
|
|
564
|
+
KeyR: A.recover
|
|
565
|
+
},
|
|
566
|
+
axes: STICKS,
|
|
567
|
+
buttons: [
|
|
568
|
+
{
|
|
569
|
+
button: 7,
|
|
570
|
+
action: A.throttleUp
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
button: 6,
|
|
574
|
+
action: A.throttleDown
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
button: 4,
|
|
578
|
+
action: A.yawLeft
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
button: 5,
|
|
582
|
+
action: A.yawRight
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
button: 0,
|
|
586
|
+
action: A.jump
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
button: 2,
|
|
590
|
+
action: A.interact
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
button: 3,
|
|
594
|
+
action: A.view
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
button: 1,
|
|
598
|
+
action: A.engine
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
}
|
|
524
602
|
};
|
|
525
603
|
}
|
|
526
604
|
/** An input with no intent; controllers treat it as "hold still". */
|
|
@@ -551,6 +629,13 @@ var NavigationInputSource = class {
|
|
|
551
629
|
pointer;
|
|
552
630
|
interactPresses = 0;
|
|
553
631
|
viewPresses = 0;
|
|
632
|
+
profile;
|
|
633
|
+
pilotPresses = {
|
|
634
|
+
engine: 0,
|
|
635
|
+
gear: 0,
|
|
636
|
+
flaps: 0,
|
|
637
|
+
recover: 0
|
|
638
|
+
};
|
|
554
639
|
lookSpeed;
|
|
555
640
|
unsubscribe;
|
|
556
641
|
constructor(options) {
|
|
@@ -564,7 +649,16 @@ var NavigationInputSource = class {
|
|
|
564
649
|
});
|
|
565
650
|
this.pointer = new NavigationPointer(options.element, options);
|
|
566
651
|
this.lookSpeed = options.gamepadLookSpeed ?? 900;
|
|
652
|
+
this.profile = options.profile ?? "orbit";
|
|
567
653
|
this.unsubscribe = [
|
|
654
|
+
...[
|
|
655
|
+
"engine",
|
|
656
|
+
"gear",
|
|
657
|
+
"flaps",
|
|
658
|
+
"recover"
|
|
659
|
+
].map((name) => this.map.onPress(A[name], () => {
|
|
660
|
+
this.pilotPresses[name]++;
|
|
661
|
+
})),
|
|
568
662
|
this.map.onPress(A.interact, () => {
|
|
569
663
|
this.interactPresses++;
|
|
570
664
|
}),
|
|
@@ -575,6 +669,7 @@ var NavigationInputSource = class {
|
|
|
575
669
|
];
|
|
576
670
|
}
|
|
577
671
|
setProfile(profile) {
|
|
672
|
+
this.profile = profile;
|
|
578
673
|
this.map.setProfile(profile);
|
|
579
674
|
this.pointer.setPointerLock(profile === "walk");
|
|
580
675
|
}
|
|
@@ -599,10 +694,19 @@ var NavigationInputSource = class {
|
|
|
599
694
|
jump: v(A.jump) !== 0,
|
|
600
695
|
interact: this.interactPresses,
|
|
601
696
|
view: this.viewPresses,
|
|
602
|
-
taps: gestures.taps
|
|
697
|
+
taps: gestures.taps,
|
|
698
|
+
...this.profile === "pilot" ? { pilot: {
|
|
699
|
+
throttle: v(A.throttleUp) - v(A.throttleDown),
|
|
700
|
+
yaw: v(A.yawRight) - v(A.yawLeft),
|
|
701
|
+
...this.pilotPresses
|
|
702
|
+
} } : {}
|
|
603
703
|
};
|
|
604
704
|
this.interactPresses = 0;
|
|
605
705
|
this.viewPresses = 0;
|
|
706
|
+
this.pilotPresses.engine = 0;
|
|
707
|
+
this.pilotPresses.gear = 0;
|
|
708
|
+
this.pilotPresses.flaps = 0;
|
|
709
|
+
this.pilotPresses.recover = 0;
|
|
606
710
|
return input;
|
|
607
711
|
}
|
|
608
712
|
dispose() {
|
package/dist/vehicles.d.mts
CHANGED
|
@@ -11,6 +11,23 @@ interface VehicleVisual {
|
|
|
11
11
|
}
|
|
12
12
|
/** Bind a loaded entity GLB to generic wheel/steering animation using external node names. */
|
|
13
13
|
declare function createVehicleVisual(model: THREE.Object3D, vehicle: VehicleData): VehicleVisual;
|
|
14
|
+
/** The dimensions a vehicle proxy is built from (a `VehicleSpec` satisfies it). */
|
|
15
|
+
interface VehicleProxyDimensions {
|
|
16
|
+
width: number;
|
|
17
|
+
length: number;
|
|
18
|
+
height: number;
|
|
19
|
+
wheelbase: number;
|
|
20
|
+
wheelTrack: number;
|
|
21
|
+
wheelRadius: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The parked-car proxy shape with a white body, for instanced rendering: per-instance paint comes
|
|
25
|
+
* from `instanceColor` (three multiplies vertex colours by it, so glass and tyres stay dark).
|
|
26
|
+
* Cached by dimensions; never dispose the returned geometry.
|
|
27
|
+
*/
|
|
28
|
+
declare function vehicleProxyGeometry(dimensions: VehicleProxyDimensions): THREE.BufferGeometry;
|
|
29
|
+
/** The shared vertex-coloured material of parked and proxy vehicles. */
|
|
30
|
+
declare const vehicleProxyMaterial: THREE.MeshStandardMaterial;
|
|
14
31
|
/**
|
|
15
32
|
* Dormant terrain-owned cars merged into one static mesh per tile. A plain mesh shares its
|
|
16
33
|
* compiled shader with every other tile; an instanced batch per model and paint would build one
|
|
@@ -26,4 +43,4 @@ declare function isParkedVehicleHidden(batch: THREE.Mesh, index: number): boolea
|
|
|
26
43
|
*/
|
|
27
44
|
declare function setParkedVehicleHidden(batch: THREE.Mesh, index: number, hidden: boolean): boolean;
|
|
28
45
|
//#endregion
|
|
29
|
-
export { type VehicleCameraOptions, type VehicleCameraPose, type VehicleInteriorSignals, type VehicleInteriorVisual, VehicleVisual, createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose };
|
|
46
|
+
export { type VehicleCameraOptions, type VehicleCameraPose, type VehicleInteriorSignals, type VehicleInteriorVisual, VehicleProxyDimensions, VehicleVisual, createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose, vehicleProxyGeometry, vehicleProxyMaterial };
|
package/dist/vehicles.mjs
CHANGED
|
@@ -36,7 +36,7 @@ function createVehicleVisual(model, vehicle) {
|
|
|
36
36
|
const frontWheels = new Set(vehicle.visual.frontWheelNodes);
|
|
37
37
|
const wheels = [];
|
|
38
38
|
let steeringWheel;
|
|
39
|
-
const color = new THREE.Color(vehicle.color);
|
|
39
|
+
const color = vehicle.color !== void 0 ? new THREE.Color(vehicle.color) : void 0;
|
|
40
40
|
model.traverse((object) => {
|
|
41
41
|
object.userData.vehicleGeometry = true;
|
|
42
42
|
const named = nodes.get(object.name) ?? [];
|
|
@@ -45,11 +45,12 @@ function createVehicleVisual(model, vehicle) {
|
|
|
45
45
|
if (object instanceof THREE.Mesh) {
|
|
46
46
|
object.castShadow = true;
|
|
47
47
|
object.receiveShadow = true;
|
|
48
|
-
|
|
48
|
+
const cloned = (Array.isArray(object.material) ? object.material : [object.material]).map((source) => {
|
|
49
49
|
const material = source.clone();
|
|
50
|
-
if (source.name === vehicle.visual.paintMaterial && "color" in material) material.color.copy(color);
|
|
50
|
+
if (color !== void 0 && source.name === vehicle.visual.paintMaterial && "color" in material) material.color.copy(color);
|
|
51
51
|
return material;
|
|
52
52
|
});
|
|
53
|
+
object.material = Array.isArray(object.material) ? cloned : cloned[0];
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
56
|
for (const name of vehicle.visual.wheelNodes) for (const node of nodes.get(name) ?? []) wheels.push({
|
|
@@ -107,6 +108,16 @@ function coloredBox(x, y, z, width, height, length, color) {
|
|
|
107
108
|
geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
|
|
108
109
|
return geometry;
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The parked-car proxy shape with a white body, for instanced rendering: per-instance paint comes
|
|
113
|
+
* from `instanceColor` (three multiplies vertex colours by it, so glass and tyres stay dark).
|
|
114
|
+
* Cached by dimensions; never dispose the returned geometry.
|
|
115
|
+
*/
|
|
116
|
+
function vehicleProxyGeometry(dimensions) {
|
|
117
|
+
return parkedTemplate(dimensions, "#ffffff");
|
|
118
|
+
}
|
|
119
|
+
/** The shared vertex-coloured material of parked and proxy vehicles. */
|
|
120
|
+
const vehicleProxyMaterial = parkedMaterial;
|
|
110
121
|
/** Generic dimension-driven proxy used only for large dormant parking batches. */
|
|
111
122
|
function parkedTemplate(spec, color) {
|
|
112
123
|
const key = `${spec.width}:${spec.length}:${spec.height}:${spec.wheelbase}:${color}`;
|
|
@@ -228,4 +239,4 @@ function setParkedVehicleHidden(batch, index, hidden) {
|
|
|
228
239
|
return true;
|
|
229
240
|
}
|
|
230
241
|
//#endregion
|
|
231
|
-
export { createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose };
|
|
242
|
+
export { createParkedVehicleBatch, createVehicleInteriorVisual, createVehicleVisual, isParkedVehicleHidden, setParkedVehicleHidden, vehicleCameraPose, vehicleProxyGeometry, vehicleProxyMaterial };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/molen-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"zod": "^4.6.5",
|
|
71
|
-
"@bendyline/molen-materials": "0.0.
|
|
72
|
-
"@bendyline/molen-schema": "0.0.
|
|
71
|
+
"@bendyline/molen-materials": "0.0.4",
|
|
72
|
+
"@bendyline/molen-schema": "0.0.4"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@types/three": ">=0.184.0 <0.187.0",
|