@bendyline/molen-ambient 0.0.15 → 0.0.17
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/client.d.mts +18 -3
- package/dist/client.mjs +144 -13
- package/dist/kernel.d.mts +65 -4
- package/dist/kernel.mjs +138 -368
- package/dist/{components-DJINUkXK.mjs → templates-DoMmnJNE.mjs} +362 -3
- package/package.json +7 -7
package/dist/client.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { p as WildlifeSpecies, r as WildlifeAgent } from "./wildlife-CvHzzI9m.mjs";
|
|
2
2
|
import { World } from "@bendyline/molen-kernel/world";
|
|
3
|
-
import { AircraftSpec, VehicleData } from "@bendyline/molen-schema";
|
|
3
|
+
import { AircraftSpec, RailVehicleProfile, VehicleData } from "@bendyline/molen-schema";
|
|
4
4
|
import * as THREE from "three";
|
|
5
5
|
import { FigureData } from "@bendyline/molen-figures/client";
|
|
6
6
|
import { RenderableKind, SceneAdmission } from "@bendyline/molen-client";
|
|
7
|
+
import { SeatData } from "@bendyline/molen-kernel/vehicles";
|
|
7
8
|
|
|
8
9
|
//#region src/client/aircraft.d.ts
|
|
9
10
|
interface AmbientAircraftModels {
|
|
@@ -13,7 +14,7 @@ interface AmbientAircraftModels {
|
|
|
13
14
|
}
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/client/proxies.d.ts
|
|
16
|
-
type ProxyShape = "car" | "bus" | "rail" | "aircraft" | "boat"
|
|
17
|
+
type ProxyShape = "car" | "two-wheeler" | "three-wheeler" | "bus" | "rail" | "aircraft" | "boat" | `rail-${RailVehicleProfile}`;
|
|
17
18
|
interface ProxyDimensions {
|
|
18
19
|
length: number;
|
|
19
20
|
width: number;
|
|
@@ -175,8 +176,22 @@ interface AmbientRendererOptions {
|
|
|
175
176
|
aircraft?: AmbientAircraftModels;
|
|
176
177
|
/** Body heights by type id, for proxies (the kernel stores length and width only). */
|
|
177
178
|
heights?: Readonly<Record<string, number>>;
|
|
179
|
+
/** Rail vehicle silhouettes by type id (`spec.rail.profile`), for train proxies. */
|
|
180
|
+
railProfiles?: Readonly<Record<string, RailVehicleProfile>>;
|
|
181
|
+
/**
|
|
182
|
+
* Car types ridden in the open, by type id: two-wheelers and auto-rickshaws, whose driver is
|
|
183
|
+
* drawn on the saddle (two-wheelers also lean into their turns and draw as two-wheelers).
|
|
184
|
+
*/
|
|
185
|
+
riders?: Readonly<Record<string, AmbientRider>>;
|
|
178
186
|
budget?: Partial<AmbientRenderBudget>;
|
|
179
187
|
}
|
|
188
|
+
/** The driver drawn on a two- or three-wheeler in traffic. */
|
|
189
|
+
interface AmbientRider {
|
|
190
|
+
/** The vehicle's data; `spec.cycle` or `spec.handlebar` places the hands and feet. */
|
|
191
|
+
vehicle: VehicleData;
|
|
192
|
+
/** The driver seat: the pelvis position in model space. */
|
|
193
|
+
seat: SeatData;
|
|
194
|
+
}
|
|
180
195
|
interface AmbientRenderStats {
|
|
181
196
|
cars: number;
|
|
182
197
|
pedestrians: number;
|
|
@@ -244,4 +259,4 @@ interface WildlifeGeometry {
|
|
|
244
259
|
/** +Z is the head/front. All geometry is baked in bind pose and skin weights are rigid. */
|
|
245
260
|
declare function wildlifeGeometry(species: WildlifeSpecies, tier: WildlifeTier): WildlifeGeometry;
|
|
246
261
|
//#endregion
|
|
247
|
-
export { type AmbientAircraftModels, AmbientFigures, type AmbientRenderBudget, type AmbientRenderStats, type AmbientRenderer, type AmbientRendererOptions, type AmbientVehicleKindOptions, type AmbientVehicleModels, type DetailCandidate, type FigureBudget, ProxyBatches, type ProxyDimensions, type ProxyInstance, type ProxyShape, type WalkerView, type WildlifeGeometry, type WildlifeRenderBudget, WildlifeRenderer, type WildlifeTier, ambientVehicleKind, createAmbientRenderer, proxyGeometry, proxyHeight, proxyShapeFor, wildlifeGeometry };
|
|
262
|
+
export { type AmbientAircraftModels, AmbientFigures, type AmbientRenderBudget, type AmbientRenderStats, type AmbientRenderer, type AmbientRendererOptions, type AmbientRider, type AmbientVehicleKindOptions, type AmbientVehicleModels, type DetailCandidate, type FigureBudget, ProxyBatches, type ProxyDimensions, type ProxyInstance, type ProxyShape, type WalkerView, type WildlifeGeometry, type WildlifeRenderBudget, WildlifeRenderer, type WildlifeTier, ambientVehicleKind, createAmbientRenderer, proxyGeometry, proxyHeight, proxyShapeFor, wildlifeGeometry };
|
package/dist/client.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as registerAmbientSchema, n as DEFAULT_TEMPLATES, s as AmbientAgent } from "./templates-DoMmnJNE.mjs";
|
|
2
2
|
import { Transform, componentHandle } from "@bendyline/molen-kernel/world";
|
|
3
|
-
import {
|
|
3
|
+
import { InstanceBatch } from "@bendyline/molen-client/instancing";
|
|
4
|
+
import { createVehicleVisual, railVehicleProxyGeometry, threeWheelerProxyGeometry, twoWheelerProxyGeometry, vehicleProxyGeometry, vehicleProxyMaterial } from "@bendyline/molen-client/vehicles";
|
|
4
5
|
import * as THREE from "three";
|
|
5
6
|
import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
|
|
6
|
-
import { FigureGeometryCache, applyPose, evaluatePose, figureBodyToSkinnedMesh, figureSeed, resolveFigureDescriptor, strideRateFor, worldToFigure } from "@bendyline/molen-figures/client";
|
|
7
|
+
import { FigureGeometryCache, applyPose, cycleRiderPose, evaluatePose, figureBodyToSkinnedMesh, figureSeed, resolveFigureDescriptor, strideRateFor, worldToFigure } from "@bendyline/molen-figures/client";
|
|
7
8
|
import { createAircraftVisual } from "@bendyline/molen-client/aircraft";
|
|
8
9
|
//#region src/client/proxies.ts
|
|
9
10
|
/**
|
|
@@ -78,6 +79,7 @@ function proxyShapeFor(kind, length) {
|
|
|
78
79
|
function proxyHeight(shape, length, width, type) {
|
|
79
80
|
if (shape === "bus") return 3.1;
|
|
80
81
|
if (shape === "rail") return 3.6;
|
|
82
|
+
if (shape.startsWith("rail-")) return 4.5;
|
|
81
83
|
if (shape === "boat") return Math.max(2, length * .18);
|
|
82
84
|
if (shape === "aircraft") return length * .25;
|
|
83
85
|
if (/van/.test(type) || width >= 1.98) return 2;
|
|
@@ -100,8 +102,28 @@ function proxyGeometry(shape, dims) {
|
|
|
100
102
|
wheelTrack: d.width * .84,
|
|
101
103
|
wheelRadius: Math.min(.5, Math.max(.28, d.length * .068))
|
|
102
104
|
});
|
|
105
|
+
else if (shape === "two-wheeler") geometry = twoWheelerProxyGeometry({
|
|
106
|
+
...d,
|
|
107
|
+
wheelbase: d.length * .66,
|
|
108
|
+
wheelTrack: 0,
|
|
109
|
+
wheelRadius: Math.min(.3, Math.max(.12, d.length * .13))
|
|
110
|
+
});
|
|
111
|
+
else if (shape === "three-wheeler") geometry = threeWheelerProxyGeometry({
|
|
112
|
+
...d,
|
|
113
|
+
wheelbase: d.length * .76,
|
|
114
|
+
wheelTrack: d.width * .88,
|
|
115
|
+
wheelRadius: .2
|
|
116
|
+
});
|
|
103
117
|
else if (shape === "bus") geometry = busGeometry(d);
|
|
104
118
|
else if (shape === "rail") geometry = railGeometry(d);
|
|
119
|
+
else if (shape.startsWith("rail-")) geometry = railVehicleProxyGeometry({
|
|
120
|
+
...d,
|
|
121
|
+
wheelRadius: .457,
|
|
122
|
+
rail: {
|
|
123
|
+
truckCenters: d.length * .74,
|
|
124
|
+
profile: shape.slice(5)
|
|
125
|
+
}
|
|
126
|
+
});
|
|
105
127
|
else if (shape === "boat") {
|
|
106
128
|
const hull = box(0, d.height * .08, 0, d.width, d.height * .25, d.length, WHITE);
|
|
107
129
|
const position = hull.getAttribute("position");
|
|
@@ -123,10 +145,11 @@ function proxyKey(shape, dims) {
|
|
|
123
145
|
//#endregion
|
|
124
146
|
//#region src/client/batches.ts
|
|
125
147
|
/**
|
|
126
|
-
* Instanced proxies: one
|
|
148
|
+
* Instanced proxies: one instance batch per proxy shape and size, refilled every frame from the
|
|
127
149
|
* live agents. Matrices are relative to an anchor near the camera (float32 instance matrices lose
|
|
128
150
|
* precision at Web Mercator magnitudes); the anchor group sits at the anchor in absolute
|
|
129
|
-
* coordinates, so the renderer's floating origin never needs a re-upload.
|
|
151
|
+
* coordinates, so the renderer's floating origin never needs a re-upload. Batches of every shape
|
|
152
|
+
* share one WebGPU shader build (see `InstanceBatch`), so growing a batch builds nothing.
|
|
130
153
|
*/
|
|
131
154
|
const ANCHOR_STEP = 250;
|
|
132
155
|
var ProxyBatches = class {
|
|
@@ -187,8 +210,7 @@ var ProxyBatches = class {
|
|
|
187
210
|
}
|
|
188
211
|
grow(key, instance, previous) {
|
|
189
212
|
const capacity = previous === void 0 ? this.initialCapacity : previous.mesh.instanceMatrix.count * 2;
|
|
190
|
-
const
|
|
191
|
-
const mesh = new THREE.InstancedMesh(geometry, vehicleProxyMaterial, capacity);
|
|
213
|
+
const mesh = new InstanceBatch(proxyGeometry(instance.shape, instance.dims), vehicleProxyMaterial, capacity);
|
|
192
214
|
mesh.name = `ambient:${key}`;
|
|
193
215
|
mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
194
216
|
mesh.setColorAt(0, new THREE.Color(1, 1, 1));
|
|
@@ -1047,6 +1069,15 @@ var VehicleDetail = class {
|
|
|
1047
1069
|
get count() {
|
|
1048
1070
|
return this.active.size;
|
|
1049
1071
|
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Meters to the nearest selected car still waiting for a model of `type`. Infinity when none
|
|
1074
|
+
* is, which a frame queue treats as unordered: arrival order, after anything nearer.
|
|
1075
|
+
*/
|
|
1076
|
+
waitingDistance(type) {
|
|
1077
|
+
let nearest = Number.POSITIVE_INFINITY;
|
|
1078
|
+
for (const candidate of this.candidates) if (candidate.type === type && !this.active.has(candidate.id)) nearest = Math.min(nearest, candidate.distance);
|
|
1079
|
+
return nearest;
|
|
1080
|
+
}
|
|
1050
1081
|
/** Choose which cars get full models (call a few times a second). */
|
|
1051
1082
|
select(candidates, exists) {
|
|
1052
1083
|
const near = this.options.near ?? 45;
|
|
@@ -1135,24 +1166,33 @@ var VehicleDetail = class {
|
|
|
1135
1166
|
tintGlass(object);
|
|
1136
1167
|
});
|
|
1137
1168
|
this.group.add(visual.object);
|
|
1169
|
+
visual.object.userData.admissionOrder = () => this.waitingDistance(type);
|
|
1170
|
+
const freeSlot = () => {
|
|
1171
|
+
if (this.loading.get(type) === controller) this.loading.delete(type);
|
|
1172
|
+
};
|
|
1173
|
+
controller.signal.addEventListener("abort", freeSlot, { once: true });
|
|
1138
1174
|
await this.options.prepare?.(visual.object);
|
|
1139
|
-
|
|
1175
|
+
controller.signal.removeEventListener("abort", freeSlot);
|
|
1176
|
+
delete visual.object.userData.admissionOrder;
|
|
1177
|
+
if (this.disposed || this.cacheStats().bytes > this.byteLimit) {
|
|
1140
1178
|
this.release(visual);
|
|
1141
1179
|
return;
|
|
1142
1180
|
}
|
|
1143
|
-
const candidate = this.candidates.find((c) => c.type === type && !this.active.has(c.id));
|
|
1181
|
+
const candidate = this.wanted.has(type) ? this.candidates.find((c) => c.type === type && !this.active.has(c.id)) : void 0;
|
|
1144
1182
|
if (candidate && this.active.size < this.max) this.activate(candidate, visual);
|
|
1145
1183
|
else {
|
|
1146
1184
|
const pool = this.idle.get(type) ?? [];
|
|
1147
1185
|
pool.push(visual);
|
|
1148
1186
|
this.idle.set(type, pool);
|
|
1187
|
+
const resident = this.resident.get(visual);
|
|
1188
|
+
if (resident) resident.used = ++this.clock;
|
|
1149
1189
|
}
|
|
1150
1190
|
this.prune();
|
|
1151
1191
|
} catch {
|
|
1152
1192
|
if (bound) this.release(bound);
|
|
1153
1193
|
if (!controller.signal.aborted) this.missing.add(type);
|
|
1154
1194
|
} finally {
|
|
1155
|
-
this.loading.delete(type);
|
|
1195
|
+
if (this.loading.get(type) === controller) this.loading.delete(type);
|
|
1156
1196
|
}
|
|
1157
1197
|
}
|
|
1158
1198
|
/** Place promoted cars and turn their wheels (every frame). */
|
|
@@ -1245,6 +1285,87 @@ function createAmbientRenderer(options) {
|
|
|
1245
1285
|
}
|
|
1246
1286
|
return color;
|
|
1247
1287
|
};
|
|
1288
|
+
const ridden = /* @__PURE__ */ new Map();
|
|
1289
|
+
let frame = 0;
|
|
1290
|
+
/**
|
|
1291
|
+
* The rider's walker for a ridden agent, and the body rotation both draw with: a two-wheeler
|
|
1292
|
+
* leans into its turn (a = g tan θ, eased) up to the type's lean limit.
|
|
1293
|
+
*/
|
|
1294
|
+
const ride = (id, agent, pos, rot, rider, dt, tick) => {
|
|
1295
|
+
const [qx, qy, qz, qw] = rot;
|
|
1296
|
+
const yaw = Math.atan2(2 * (qx * qz + qw * qy), 1 - 2 * (qx * qx + qy * qy));
|
|
1297
|
+
let state = ridden.get(id);
|
|
1298
|
+
if (state === void 0) {
|
|
1299
|
+
state = {
|
|
1300
|
+
tick,
|
|
1301
|
+
yaw,
|
|
1302
|
+
rate: 0,
|
|
1303
|
+
roll: 0,
|
|
1304
|
+
figure: DEFAULT_TEMPLATES.pedestrian({
|
|
1305
|
+
id,
|
|
1306
|
+
kind: "pedestrian",
|
|
1307
|
+
type: "human.adult",
|
|
1308
|
+
seed: agent.seed
|
|
1309
|
+
}).figure ?? {
|
|
1310
|
+
preset: "human.adult",
|
|
1311
|
+
seed: id
|
|
1312
|
+
},
|
|
1313
|
+
seen: frame
|
|
1314
|
+
};
|
|
1315
|
+
ridden.set(id, state);
|
|
1316
|
+
} else if (tick !== state.tick) {
|
|
1317
|
+
let turn = yaw - state.yaw;
|
|
1318
|
+
if (turn > Math.PI) turn -= 2 * Math.PI;
|
|
1319
|
+
else if (turn < -Math.PI) turn += 2 * Math.PI;
|
|
1320
|
+
state.rate = turn / ((tick - state.tick) / world.tickRate);
|
|
1321
|
+
state.tick = tick;
|
|
1322
|
+
state.yaw = yaw;
|
|
1323
|
+
}
|
|
1324
|
+
state.seen = frame;
|
|
1325
|
+
const spec = rider.vehicle.spec;
|
|
1326
|
+
const maxLean = spec.cycle?.maxLean ?? 0;
|
|
1327
|
+
const target = Math.max(-maxLean, Math.min(maxLean, -Math.atan2(agent.speed * state.rate, 9.81)));
|
|
1328
|
+
state.roll += (target - state.roll) * Math.min(1, dt * 4);
|
|
1329
|
+
let body = [
|
|
1330
|
+
qx,
|
|
1331
|
+
qy,
|
|
1332
|
+
qz,
|
|
1333
|
+
qw
|
|
1334
|
+
];
|
|
1335
|
+
if (maxLean > 0) {
|
|
1336
|
+
const s = Math.sin(state.roll / 2), c = Math.cos(state.roll / 2);
|
|
1337
|
+
body = [
|
|
1338
|
+
qx * c + qy * s,
|
|
1339
|
+
qy * c - qx * s,
|
|
1340
|
+
qz * c + qw * s,
|
|
1341
|
+
qw * c - qz * s
|
|
1342
|
+
];
|
|
1343
|
+
}
|
|
1344
|
+
const steer = Math.max(-spec.maxSteer, Math.min(spec.maxSteer, Math.atan2(spec.wheelbase * state.rate, Math.max(1, agent.speed))));
|
|
1345
|
+
const seat = new THREE.Vector3(...rider.seat.position).applyQuaternion(new THREE.Quaternion(...body));
|
|
1346
|
+
return {
|
|
1347
|
+
rot: body,
|
|
1348
|
+
walker: {
|
|
1349
|
+
id: `${id}:rider`,
|
|
1350
|
+
figure: state.figure,
|
|
1351
|
+
pos: [
|
|
1352
|
+
pos[0] + seat.x,
|
|
1353
|
+
pos[1] + seat.y,
|
|
1354
|
+
pos[2] + seat.z
|
|
1355
|
+
],
|
|
1356
|
+
rot: body,
|
|
1357
|
+
speed: 0,
|
|
1358
|
+
since: agent.spawnedTick,
|
|
1359
|
+
hidden: false,
|
|
1360
|
+
mode: "sit",
|
|
1361
|
+
anchor: "pelvis",
|
|
1362
|
+
riding: cycleRiderPose(rider.vehicle, {
|
|
1363
|
+
steer,
|
|
1364
|
+
speed: agent.speed
|
|
1365
|
+
}, rider.seat)
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
};
|
|
1248
1369
|
let lastSelect = Number.NEGATIVE_INFINITY;
|
|
1249
1370
|
let elapsed = 0;
|
|
1250
1371
|
let counts = {
|
|
@@ -1265,6 +1386,7 @@ function createAmbientRenderer(options) {
|
|
|
1265
1386
|
elapsed += dt;
|
|
1266
1387
|
if (!object.visible) return;
|
|
1267
1388
|
const tick = world.tick;
|
|
1389
|
+
frame++;
|
|
1268
1390
|
batches.begin(camera);
|
|
1269
1391
|
const walkers = [];
|
|
1270
1392
|
const planes = [];
|
|
@@ -1325,6 +1447,13 @@ function createAmbientRenderer(options) {
|
|
|
1325
1447
|
continue;
|
|
1326
1448
|
}
|
|
1327
1449
|
}
|
|
1450
|
+
const rider = agent.kind === "car" ? options.riders?.[agent.type] : void 0;
|
|
1451
|
+
let rot = t.rot;
|
|
1452
|
+
if (rider !== void 0) {
|
|
1453
|
+
const ridden = ride(id, agent, t.pos, t.rot, rider, dt, tick);
|
|
1454
|
+
rot = ridden.rot;
|
|
1455
|
+
walkers.push(ridden.walker);
|
|
1456
|
+
}
|
|
1328
1457
|
if (agent.kind === "car" || agent.kind === "train") {
|
|
1329
1458
|
const distance = Math.max(0, Math.hypot(t.pos[0] - camera[0], t.pos[1] - camera[1], t.pos[2] - camera[2]) - agent.length / 2);
|
|
1330
1459
|
if (distance < 80) candidates.push({
|
|
@@ -1334,11 +1463,12 @@ function createAmbientRenderer(options) {
|
|
|
1334
1463
|
distance
|
|
1335
1464
|
});
|
|
1336
1465
|
if (detail?.has(id) === true) {
|
|
1337
|
-
detail.update(id, t.pos,
|
|
1466
|
+
detail.update(id, t.pos, rot, agent.speed, dt);
|
|
1338
1467
|
continue;
|
|
1339
1468
|
}
|
|
1340
1469
|
}
|
|
1341
|
-
const
|
|
1470
|
+
const profile = agent.kind === "train" ? options.railProfiles?.[agent.type] : void 0;
|
|
1471
|
+
const shape = profile !== void 0 ? `rail-${profile}` : rider?.vehicle.spec.cycle !== void 0 ? "two-wheeler" : rider?.vehicle.spec.bodyStyle === "auto-rickshaw" ? "three-wheeler" : proxyShapeFor(agent.kind, agent.length);
|
|
1342
1472
|
const height = options.heights?.[agent.type] ?? proxyHeight(shape, agent.length, agent.width, agent.type);
|
|
1343
1473
|
const age = tick - agent.spawnedTick;
|
|
1344
1474
|
batches.add({
|
|
@@ -1349,12 +1479,13 @@ function createAmbientRenderer(options) {
|
|
|
1349
1479
|
height
|
|
1350
1480
|
},
|
|
1351
1481
|
pos: t.pos,
|
|
1352
|
-
rot
|
|
1482
|
+
rot,
|
|
1353
1483
|
scale: age >= FADE_TICKS ? 1 : Math.max(.05, age / FADE_TICKS),
|
|
1354
1484
|
color: colorOf(agent.color)
|
|
1355
1485
|
});
|
|
1356
1486
|
}
|
|
1357
1487
|
const proxies = batches.end();
|
|
1488
|
+
for (const [id, state] of ridden) if (state.seen !== frame) ridden.delete(id);
|
|
1358
1489
|
figures.update(walkers, camera, tick, world.tickRate);
|
|
1359
1490
|
aircraft?.sync(planes, dt);
|
|
1360
1491
|
if (detail !== void 0 && elapsed - lastSelect >= .2) {
|
package/dist/kernel.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as WildlifeWorld, c as WILDLIFE_FAMILIES, d as WildlifeHabitat, f as WildlifeMotion, i as WildlifeBudget, l as WildlifeChoice, m as wildlifeSpeciesSchema, n as WILDLIFE_TICK_RATE, o as stepWildlife, p as WildlifeSpecies, r as WildlifeAgent, s as wildlifeCandidates, t as WILDLIFE_CELL_METERS, u as WildlifeFamily } from "./wildlife-CvHzzI9m.mjs";
|
|
2
2
|
import { Quat } from "@bendyline/molen-kernel/determinism";
|
|
3
3
|
import { ComponentType, JsonObject, World } from "@bendyline/molen-kernel/world";
|
|
4
|
-
import { ComponentMap, EntityId, SceneManifest } from "@bendyline/molen-schema";
|
|
4
|
+
import { ComponentMap, EntityId, SceneManifest, SnowCoverData } from "@bendyline/molen-schema";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { TerrainLinePath, TerrainPoiFeature, TerrainTransportationFeature } from "@bendyline/molen-terrain/kernel";
|
|
7
7
|
|
|
@@ -41,6 +41,8 @@ interface AmbientAgentData extends JsonObject {
|
|
|
41
41
|
hidden?: boolean;
|
|
42
42
|
consist?: string;
|
|
43
43
|
carIndex?: number;
|
|
44
|
+
/** Train cars: distance behind the lead's centre, metres (default from `carIndex`). */
|
|
45
|
+
offset?: number;
|
|
44
46
|
trail?: string[];
|
|
45
47
|
served?: string;
|
|
46
48
|
air?: AmbientAirCorridor;
|
|
@@ -71,6 +73,21 @@ interface AmbientRoleData extends JsonObject {
|
|
|
71
73
|
cars?: number;
|
|
72
74
|
colors?: string[];
|
|
73
75
|
visual?: AmbientRoleVisual;
|
|
76
|
+
/** Rail: `light` (tram, light rail) or `heavy` track; absent runs on any. */
|
|
77
|
+
track?: "light" | "heavy";
|
|
78
|
+
/** Rail: a mixed train this type leads. Car types come from the same library. */
|
|
79
|
+
consist?: AmbientRoleConsist;
|
|
80
|
+
}
|
|
81
|
+
/** {@link AmbientRoleData.consist}: car types by id, with draw weights and paints. */
|
|
82
|
+
interface AmbientRoleConsist extends JsonObject {
|
|
83
|
+
units?: [number, number];
|
|
84
|
+
length: [number, number];
|
|
85
|
+
block?: [number, number];
|
|
86
|
+
cars: {
|
|
87
|
+
type: string;
|
|
88
|
+
weight?: number;
|
|
89
|
+
colors?: string[];
|
|
90
|
+
}[];
|
|
74
91
|
}
|
|
75
92
|
interface AmbientObserverState extends JsonObject {
|
|
76
93
|
pos?: [number, number, number];
|
|
@@ -231,6 +248,13 @@ interface TransportLane {
|
|
|
231
248
|
length: number;
|
|
232
249
|
/** Surface lift above the edge's baked heights (sidewalks sit on the kerb). */
|
|
233
250
|
readonly lift: number;
|
|
251
|
+
/**
|
|
252
|
+
* The surface under this lane at each edge path vertex (indexed like the edge's `ys`), sampled
|
|
253
|
+
* at the lane's own offset. A road draped over a hillside tilts across its width, and lanes at
|
|
254
|
+
* the centreline's height ran half a metre into its uphill side. Absent where the edge's heights
|
|
255
|
+
* were given rather than sampled; the lane then follows `ys`.
|
|
256
|
+
*/
|
|
257
|
+
readonly ys?: Float64Array;
|
|
234
258
|
/** Node the lane starts from and ends at. */
|
|
235
259
|
readonly start: string;
|
|
236
260
|
readonly end: string;
|
|
@@ -370,7 +394,9 @@ interface EdgeDraft {
|
|
|
370
394
|
bridgeApproachProfile?: {
|
|
371
395
|
point: Point2;
|
|
372
396
|
elevation: number;
|
|
373
|
-
flatness: number;
|
|
397
|
+
flatness: number; /** See the terrain package's `TerrainBridgeProfileSample`. */
|
|
398
|
+
ground?: number;
|
|
399
|
+
anchor?: number;
|
|
374
400
|
}[];
|
|
375
401
|
}
|
|
376
402
|
/** Design speeds in m/s by kind. */
|
|
@@ -715,6 +741,8 @@ interface AgentEnv {
|
|
|
715
741
|
dt: number;
|
|
716
742
|
/** Solids cars yield to (queried from the world by the caller). */
|
|
717
743
|
solids: readonly AmbientSolid[];
|
|
744
|
+
/** The weather's lying snow: pedestrians wade through it more slowly. */
|
|
745
|
+
snowCover?: SnowCoverData;
|
|
718
746
|
}
|
|
719
747
|
/** Pick the next lane at a lane's end (seeded by the agent and its hop count). */
|
|
720
748
|
declare function chooseNext(lane: TransportLane, seed: number, hops: number): string | undefined;
|
|
@@ -746,11 +774,42 @@ interface AmbientVehicleType {
|
|
|
746
774
|
max?: number;
|
|
747
775
|
/** Body colours to pick from (default: a realistic car palette). */
|
|
748
776
|
colors?: string[];
|
|
749
|
-
/** Rail: cars per consist. */
|
|
777
|
+
/** Rail: cars per consist (every car this type), unless `consist` makes the train up. */
|
|
750
778
|
cars?: number;
|
|
779
|
+
/**
|
|
780
|
+
* Rail: the tracks it runs on. `light` keeps to tram and light-rail lines, `heavy` to the
|
|
781
|
+
* rest; absent runs anywhere.
|
|
782
|
+
*/
|
|
783
|
+
track?: "light" | "heavy";
|
|
784
|
+
/** Rail: a mixed train led by this type (its units, then cars drawn from a pool). */
|
|
785
|
+
consist?: AmbientConsist;
|
|
751
786
|
/** Vessels: ferry service or general navigation channel. */
|
|
752
787
|
waterway?: "ferry" | "channel";
|
|
753
788
|
}
|
|
789
|
+
/** A car a {@link AmbientConsist} draws from. */
|
|
790
|
+
interface AmbientConsistCar {
|
|
791
|
+
/** Content type id. */
|
|
792
|
+
id: string;
|
|
793
|
+
length: number;
|
|
794
|
+
width: number;
|
|
795
|
+
height?: number;
|
|
796
|
+
/** Relative draw weight (default 1). */
|
|
797
|
+
weight?: number;
|
|
798
|
+
colors?: string[];
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* How a train led by a rail type makes up: `units` copies of the lead type (multiple-unit
|
|
802
|
+
* locomotives), then `length` cars drawn in blocks of `block` alike from `cars`.
|
|
803
|
+
*/
|
|
804
|
+
interface AmbientConsist {
|
|
805
|
+
/** Lead units, inclusive range (default [1, 1]). */
|
|
806
|
+
units?: [number, number];
|
|
807
|
+
/** Cars after the units, inclusive range. */
|
|
808
|
+
length: [number, number];
|
|
809
|
+
/** Cars of one type in a row, inclusive range (default [1, 1]). */
|
|
810
|
+
block?: [number, number];
|
|
811
|
+
cars: AmbientConsistCar[];
|
|
812
|
+
}
|
|
754
813
|
interface AmbientPedestrianType {
|
|
755
814
|
preset: "human.adult" | "human.elder" | "human.child";
|
|
756
815
|
weight?: number;
|
|
@@ -956,6 +1015,8 @@ declare function laneEdgeDistance(lane: TransportLane, edge: TransportEdge, s: n
|
|
|
956
1015
|
declare function laneCoordinate(lane: TransportLane, edge: TransportEdge, d: number): number;
|
|
957
1016
|
/** Height of the edge surface at an edge-path distance. */
|
|
958
1017
|
declare function edgeHeight(edge: TransportEdge, d: number): number;
|
|
1018
|
+
/** Height of a lane's own surface at an edge-path distance (see `TransportLane.ys`). */
|
|
1019
|
+
declare function laneHeight(lane: TransportLane, edge: TransportEdge, d: number): number;
|
|
959
1020
|
/** Sample a lane at `s` within [0, length], writing into `out`. */
|
|
960
1021
|
declare function sampleLaneBody(lane: TransportLane, edge: TransportEdge, s: number, out: LaneSample): LaneSample;
|
|
961
1022
|
/** Point and tangent on a movement's connector at arc-length fraction `t` in [0, 1]. */
|
|
@@ -997,4 +1058,4 @@ interface ObserverView {
|
|
|
997
1058
|
keep?: number;
|
|
998
1059
|
}
|
|
999
1060
|
//#endregion
|
|
1000
|
-
export { AMBIENT_AGENT_COMPONENT, AMBIENT_ENTITY, AMBIENT_KINDS, AMBIENT_OBSERVER_COMPONENT, AMBIENT_ROLE_COMPONENT, AMBIENT_STATE_COMPONENT, type AgentEnv, AmbientAgent, type AmbientAgentData, type AmbientAirCorridor, type AmbientBox, type AmbientBudget, type AmbientCapabilityOptions, type AmbientClassPolicy, type AmbientHandle, type AmbientKind, AmbientObserver, type AmbientObserverData, type AmbientObserverState, type AmbientOptions, type AmbientPedestrianType, type AmbientPolicy, type AmbientPolyline, AmbientRole, type AmbientRoleData, type AmbientRoleVisual, type AmbientSolid, type AmbientSpawnInfo, AmbientState, type AmbientStateData, type AmbientStats, type AmbientTemplate, type AmbientTileInput, type AmbientTypes, type AmbientVehicleType, CAR_COLORS, DEFAULT_POLICY, DEFAULT_TEMPLATES, DEFAULT_TYPES, type DeepPartial, type DriverParams, type EdgeDraft, type EdgeSpan, type FleetCatalog, type FleetLibrary, type FleetMix, GRID_CELL, type JunctionArm, type JunctionControl, KIND_SPEED, LaneGrid, type LaneMovement, type LaneSample, type LaneStop, type ObserverView, type PlanarNode, type PlanarPiece, type PlanarResult, type RoadKind, type SignalColor, type SignalTiming, TRANSPORT_NETWORK_EXAMPLE, TRANSPORT_NETWORK_FORMAT, type TransportClass, type TransportCrossing, type TransportEdge, type TransportJunction, type TransportLane, TransportNetwork, type TransportNetworkAerodrome, type TransportNetworkDocument, type TransportNetworkOptions, type TransportNetworkPoint, type TransportNetworkSignal, type TransportNetworkStation, type TransportNetworkStats, type TransportNetworkWay, type TransportNode, type TransportRunway, type TurnKind, WILDLIFE_CELL_METERS, WILDLIFE_FAMILIES, WILDLIFE_TICK_RATE, type WildlifeAgent, type WildlifeBudget, type WildlifeChoice, type WildlifeFamily, type WildlifeHabitat, type WildlifeMotion, type WildlifeSpecies, type WildlifeWorld, type WorldPoi, agentRotation, agentSample, allRed, ambientCapability, ambientOf, ambientScriptApi, chooseNext, classifyFeature, clipPolyline, createFleetLibrary, edgeHeight, featureDrafts, fleetCatalogSchema, fmix32, idmAcceleration, installAmbient, laneCoordinate, laneEdgeDistance, laneSample, mergePolicy, networkToDocument, pickWeighted, planarSplit, policyForBudget, pseudoAngle, registerAmbientSchema, registerFleetSchema, sampleConnector, sampleLaneBody, signalColor, signalTiming, stepAgents, stepWildlife, stoppingDistance, unit01, walkBack, wildlifeCandidates, wildlifeSpeciesSchema };
|
|
1061
|
+
export { AMBIENT_AGENT_COMPONENT, AMBIENT_ENTITY, AMBIENT_KINDS, AMBIENT_OBSERVER_COMPONENT, AMBIENT_ROLE_COMPONENT, AMBIENT_STATE_COMPONENT, type AgentEnv, AmbientAgent, type AmbientAgentData, type AmbientAirCorridor, type AmbientBox, type AmbientBudget, type AmbientCapabilityOptions, type AmbientClassPolicy, type AmbientConsist, type AmbientConsistCar, type AmbientHandle, type AmbientKind, AmbientObserver, type AmbientObserverData, type AmbientObserverState, type AmbientOptions, type AmbientPedestrianType, type AmbientPolicy, type AmbientPolyline, AmbientRole, type AmbientRoleConsist, type AmbientRoleData, type AmbientRoleVisual, type AmbientSolid, type AmbientSpawnInfo, AmbientState, type AmbientStateData, type AmbientStats, type AmbientTemplate, type AmbientTileInput, type AmbientTypes, type AmbientVehicleType, CAR_COLORS, DEFAULT_POLICY, DEFAULT_TEMPLATES, DEFAULT_TYPES, type DeepPartial, type DriverParams, type EdgeDraft, type EdgeSpan, type FleetCatalog, type FleetLibrary, type FleetMix, GRID_CELL, type JunctionArm, type JunctionControl, KIND_SPEED, LaneGrid, type LaneMovement, type LaneSample, type LaneStop, type ObserverView, type PlanarNode, type PlanarPiece, type PlanarResult, type RoadKind, type SignalColor, type SignalTiming, TRANSPORT_NETWORK_EXAMPLE, TRANSPORT_NETWORK_FORMAT, type TransportClass, type TransportCrossing, type TransportEdge, type TransportJunction, type TransportLane, TransportNetwork, type TransportNetworkAerodrome, type TransportNetworkDocument, type TransportNetworkOptions, type TransportNetworkPoint, type TransportNetworkSignal, type TransportNetworkStation, type TransportNetworkStats, type TransportNetworkWay, type TransportNode, type TransportRunway, type TurnKind, WILDLIFE_CELL_METERS, WILDLIFE_FAMILIES, WILDLIFE_TICK_RATE, type WildlifeAgent, type WildlifeBudget, type WildlifeChoice, type WildlifeFamily, type WildlifeHabitat, type WildlifeMotion, type WildlifeSpecies, type WildlifeWorld, type WorldPoi, agentRotation, agentSample, allRed, ambientCapability, ambientOf, ambientScriptApi, chooseNext, classifyFeature, clipPolyline, createFleetLibrary, edgeHeight, featureDrafts, fleetCatalogSchema, fmix32, idmAcceleration, installAmbient, laneCoordinate, laneEdgeDistance, laneHeight, laneSample, mergePolicy, networkToDocument, pickWeighted, planarSplit, policyForBudget, pseudoAngle, registerAmbientSchema, registerFleetSchema, sampleConnector, sampleLaneBody, signalColor, signalTiming, stepAgents, stepWildlife, stoppingDistance, unit01, walkBack, wildlifeCandidates, wildlifeSpeciesSchema };
|