@threenative/terrain 0.1.11 → 0.1.13
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/bake-DJ5cxg0C.d.ts +82 -0
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/server.d.ts +2 -2
- package/dist/editor/worker.d.ts +1 -1
- package/dist/editor/worker.js +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/index.d.ts +51 -222
- package/dist/index.js +111 -2
- package/dist/kit-world.d.ts +107 -0
- package/dist/kit-world.js +5134 -0
- package/dist/kit.d.ts +21 -4
- package/dist/kit.js +19 -4
- package/dist/mcp/cook-child.js +9 -6
- package/dist/mcp/server.js +14 -4
- package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
- package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
- package/dist/starter.d.ts +1141 -6
- package/dist/starter.js +1999 -17
- package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
- package/dist/three.d.ts +1 -1
- package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
- package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
- package/docs/authoring/new-environment.md +97 -0
- package/package.json +8 -8
- package/starter/alpine/README.md +22 -14
- package/starter/alpine/bake.mjs +14 -1
- package/starter/alpine/biome.data.json +187 -25
- package/starter/alpine/heightmap.r16 +0 -0
- package/starter/alpine/playerRig.ts +89 -0
- package/starter/alpine/recipe.json +169 -15
- package/starter/alpine/render/bakedFile.ts +17 -0
- package/starter/alpine/render/benchmark.ts +77 -0
- package/starter/alpine/render/biomeData.ts +14 -0
- package/starter/alpine/render/biomes.ts +687 -0
- package/starter/alpine/render/ground/cover.ts +565 -0
- package/starter/alpine/render/ground/horizon.ts +219 -0
- package/starter/alpine/render/ground/palette.d.ts +1 -0
- package/starter/alpine/render/ground/palette.js +11 -0
- package/starter/alpine/render/ground/scatter.ts +104 -0
- package/starter/alpine/render/ground/terrain.ts +1860 -0
- package/starter/alpine/render/kitAssets.ts +28 -0
- package/starter/alpine/render/loading.ts +354 -0
- package/starter/alpine/render/lookKnobs.ts +37 -0
- package/starter/alpine/render/orbitCamera.ts +155 -0
- package/starter/alpine/render/props/farForest.ts +94 -0
- package/starter/alpine/render/props/pack.ts +1114 -0
- package/starter/alpine/render/props/prepared.ts +225 -0
- package/starter/alpine/render/props/propMaterials.ts +1239 -0
- package/starter/alpine/render/props/propProgress.ts +2 -0
- package/starter/alpine/render/props/propWorld.ts +105 -0
- package/starter/alpine/render/props/props.ts +633 -0
- package/starter/alpine/render/props/spruce.ts +440 -0
- package/starter/alpine/render/sky/atmosphere.ts +329 -0
- package/starter/alpine/render/sky/sky.ts +382 -0
- package/starter/alpine/render/texturePreparation.ts +135 -0
- package/starter/alpine/render/water/river.ts +1132 -0
- package/starter/alpine/render/worldNames.ts +6 -0
- package/starter/alpine/scene.ts +715 -0
- package/starter/alpine/sceneProps.ts +561 -0
- package/starter/alpine/sceneState.ts +33 -0
- package/starter/alpine/world/terrainAssets.ts +145 -0
- package/starter/alpine/world/walkBand.ts +47 -0
- package/starter/alpine/world/water.ts +74 -0
- package/starter/alpine/worlds.ts +13 -0
- package/starter/coastal/README.md +26 -27
- package/starter/coastal/assets.json +10 -0
- package/starter/coastal/bake.mjs +14 -1
- package/starter/coastal/biome.data.json +18 -3
- package/starter/coastal/playerRig.ts +89 -0
- package/starter/coastal/recipe.json +220 -18
- package/starter/coastal/render/bakedFile.ts +17 -0
- package/starter/coastal/render/benchmark.ts +81 -0
- package/starter/coastal/render/biomeData.ts +14 -0
- package/starter/coastal/render/biomes.ts +678 -0
- package/starter/coastal/render/ground/cover.ts +565 -0
- package/starter/coastal/render/ground/horizon.ts +219 -0
- package/starter/coastal/render/ground/palette.d.ts +1 -0
- package/starter/coastal/render/ground/palette.js +11 -0
- package/starter/coastal/render/ground/scatter.ts +104 -0
- package/starter/coastal/render/ground/terrain.ts +1829 -0
- package/starter/coastal/render/kitAssets.ts +28 -0
- package/starter/coastal/render/loading.ts +354 -0
- package/starter/coastal/render/lookKnobs.ts +37 -0
- package/starter/coastal/render/orbitCamera.ts +155 -0
- package/starter/coastal/render/props/farForest.ts +94 -0
- package/starter/coastal/render/props/pack.ts +1109 -0
- package/starter/coastal/render/props/prepared.ts +225 -0
- package/starter/coastal/render/props/propMaterials.ts +1239 -0
- package/starter/coastal/render/props/propProgress.ts +2 -0
- package/starter/coastal/render/props/propWorld.ts +105 -0
- package/starter/coastal/render/props/props.ts +633 -0
- package/starter/coastal/render/props/spruce.ts +440 -0
- package/starter/coastal/render/sky/atmosphere.ts +329 -0
- package/starter/coastal/render/sky/sky.ts +382 -0
- package/starter/coastal/render/texturePreparation.ts +135 -0
- package/starter/coastal/render/water/ocean.ts +284 -0
- package/starter/coastal/render/water/river.ts +1132 -0
- package/starter/coastal/render/worldNames.ts +6 -0
- package/starter/coastal/scene.ts +740 -0
- package/starter/coastal/sceneProps.ts +559 -0
- package/starter/coastal/sceneState.ts +33 -0
- package/starter/coastal/world/terrainAssets.ts +151 -0
- package/starter/coastal/world/walkBand.ts +47 -0
- package/starter/coastal/world/water.ts +74 -0
- package/starter/coastal/worlds.ts +13 -0
- package/starter/desert/README.md +51 -25
- package/starter/desert/bake-flora.mjs +142 -0
- package/starter/desert/bake-rocks.mjs +291 -0
- package/starter/desert/bake.mjs +14 -1
- package/starter/desert/biome.data.json +24 -12
- package/starter/desert/playerRig.ts +89 -0
- package/starter/desert/recipe.json +63 -16
- package/starter/desert/render/bakedFile.ts +17 -0
- package/starter/desert/render/benchmark.ts +79 -0
- package/starter/desert/render/biomeData.ts +14 -0
- package/starter/desert/render/biomes.ts +660 -0
- package/starter/desert/render/ground/cover.ts +565 -0
- package/starter/desert/render/ground/debris.ts +136 -0
- package/starter/desert/render/ground/horizon.ts +219 -0
- package/starter/desert/render/ground/palette.d.ts +1 -0
- package/starter/desert/render/ground/palette.js +11 -0
- package/starter/desert/render/ground/scatter.ts +104 -0
- package/starter/desert/render/ground/terrain.ts +1854 -0
- package/starter/desert/render/kitAssets.ts +28 -0
- package/starter/desert/render/loading.ts +354 -0
- package/starter/desert/render/lookKnobs.ts +37 -0
- package/starter/desert/render/orbitCamera.ts +155 -0
- package/starter/desert/render/props/farForest.ts +96 -0
- package/starter/desert/render/props/formations.ts +630 -0
- package/starter/desert/render/props/pack.ts +1195 -0
- package/starter/desert/render/props/prepared.ts +225 -0
- package/starter/desert/render/props/propMaterials.ts +1255 -0
- package/starter/desert/render/props/propProgress.ts +2 -0
- package/starter/desert/render/props/propWorld.ts +105 -0
- package/starter/desert/render/props/props.ts +624 -0
- package/starter/desert/render/props/spruce.ts +440 -0
- package/starter/desert/render/sand.ts +581 -0
- package/starter/desert/render/sky/atmosphere.ts +329 -0
- package/starter/desert/render/sky/sky.ts +382 -0
- package/starter/desert/render/texturePreparation.ts +135 -0
- package/starter/desert/render/water/river.ts +1132 -0
- package/starter/desert/render/worldNames.ts +6 -0
- package/starter/desert/scene.ts +748 -0
- package/starter/desert/sceneProps.ts +562 -0
- package/starter/desert/sceneState.ts +33 -0
- package/starter/desert/world/terrainAssets.ts +162 -0
- package/starter/desert/world/walkBand.ts +47 -0
- package/starter/desert/world/water.ts +74 -0
- package/starter/desert/worlds.ts +13 -0
- package/starter/forest/README.md +8 -5
- package/starter/forest/bake.mjs +21 -413
- package/starter/forest/playerRig.ts +37 -171
- package/starter/forest/recipe.json +237 -47
- package/starter/forest/render/biomes.ts +2 -1
- package/starter/forest/render/ground/horizon.ts +4 -302
- package/starter/forest/render/ground/terrain.ts +14 -32
- package/starter/forest/render/kitAssets.ts +3 -2
- package/starter/forest/render/props/farForest.ts +2 -1
- package/starter/forest/render/props/pack.ts +4 -2
- package/starter/forest/render/props/prepared.ts +2 -1
- package/starter/forest/render/props/propProgress.ts +1 -11
- package/starter/forest/render/props/propWorld.ts +48 -662
- package/starter/forest/render/props/props.ts +64 -248
- package/starter/forest/render/sky/sky.ts +2 -1
- package/starter/forest/render/worldNames.ts +6 -2
- package/starter/forest/scene.ts +34 -25
- package/starter/forest/sceneProps.ts +2 -2
- package/starter/forest/sceneState.ts +5 -4
- package/starter/forest/surface.json +2 -2
- package/starter/forest/worlds.ts +3 -2
- package/starter/tundra/README.md +35 -16
- package/starter/tundra/bake.mjs +14 -1
- package/starter/tundra/biome.data.json +6 -6
- package/starter/tundra/playerRig.ts +89 -0
- package/starter/tundra/recipe.json +111 -110
- package/starter/tundra/render/bakedFile.ts +17 -0
- package/starter/tundra/render/benchmark.ts +79 -0
- package/starter/tundra/render/biomeData.ts +14 -0
- package/starter/tundra/render/biomes.ts +714 -0
- package/starter/tundra/render/ground/cover.ts +565 -0
- package/starter/tundra/render/ground/horizon.ts +219 -0
- package/starter/tundra/render/ground/palette.d.ts +1 -0
- package/starter/tundra/render/ground/palette.js +11 -0
- package/starter/tundra/render/ground/scatter.ts +104 -0
- package/starter/tundra/render/ground/terrain.ts +1874 -0
- package/starter/tundra/render/kitAssets.ts +28 -0
- package/starter/tundra/render/loading.ts +354 -0
- package/starter/tundra/render/lookKnobs.ts +37 -0
- package/starter/tundra/render/orbitCamera.ts +155 -0
- package/starter/tundra/render/props/farForest.ts +96 -0
- package/starter/tundra/render/props/pack.ts +1088 -0
- package/starter/tundra/render/props/prepared.ts +225 -0
- package/starter/tundra/render/props/propMaterials.ts +1247 -0
- package/starter/tundra/render/props/propProgress.ts +2 -0
- package/starter/tundra/render/props/propWorld.ts +105 -0
- package/starter/tundra/render/props/props.ts +624 -0
- package/starter/tundra/render/props/spruce.ts +440 -0
- package/starter/tundra/render/sky/atmosphere.ts +329 -0
- package/starter/tundra/render/sky/sky.ts +382 -0
- package/starter/tundra/render/texturePreparation.ts +135 -0
- package/starter/tundra/render/water/river.ts +1132 -0
- package/starter/tundra/render/worldNames.ts +6 -0
- package/starter/tundra/scene.ts +715 -0
- package/starter/tundra/sceneProps.ts +559 -0
- package/starter/tundra/sceneState.ts +33 -0
- package/starter/tundra/world/terrainAssets.ts +159 -0
- package/starter/tundra/world/walkBand.ts +47 -0
- package/starter/tundra/world/water.ts +74 -0
- package/starter/tundra/worlds.ts +13 -0
- package/starter-assets.json +4 -4
- package/starter-credits.json +613 -10
- package/starter/forest/diagnostics.ts +0 -1020
- package/starter/forest/render/sky/skyVisibility.ts +0 -121
- package/starter/forest/spawnGate.ts +0 -183
- package/starter/forest/viewStatistics.ts +0 -47
- package/starter/forest/world/streamedGround.ts +0 -139
|
@@ -1,1020 +0,0 @@
|
|
|
1
|
-
import { VirtualShadowNode } from "@threenative/core";
|
|
2
|
-
import type { IFrameBudgetWindow, IRaycastOptions } from "@threenative/core";
|
|
3
|
-
import type { CharacterBody3D, IPhysicsContext } from "@threenative/physics";
|
|
4
|
-
import { CollisionShape3D } from "@threenative/physics";
|
|
5
|
-
import type { Box3 } from "three";
|
|
6
|
-
import {
|
|
7
|
-
Frustum,
|
|
8
|
-
InstancedMesh,
|
|
9
|
-
type Intersection,
|
|
10
|
-
Matrix4,
|
|
11
|
-
type Mesh,
|
|
12
|
-
type Object3D,
|
|
13
|
-
type PerspectiveCamera,
|
|
14
|
-
Vector3,
|
|
15
|
-
} from "three";
|
|
16
|
-
import type { WorldName } from "./render/biomes.js";
|
|
17
|
-
import {
|
|
18
|
-
beginViewVisit,
|
|
19
|
-
medianOfGrowingSamples as median,
|
|
20
|
-
retainViewWindow,
|
|
21
|
-
} from "./viewStatistics.js";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* What this example measures about its own frame, and the state it reports those measurements
|
|
25
|
-
* through. `src/game.ts` wires the scene; the counters live here.
|
|
26
|
-
*
|
|
27
|
-
* The window groups and the drawn-frame counts are module-level on purpose: `ctx.goto` builds a new
|
|
28
|
-
* scene for the next world, and the numbers a run reports are the run's, not one scene's.
|
|
29
|
-
*/
|
|
30
|
-
export const initialDiagnosticsState = {
|
|
31
|
-
elevationMin: 0,
|
|
32
|
-
elevationMax: 0,
|
|
33
|
-
snowFrom: 0,
|
|
34
|
-
snowTo: 0,
|
|
35
|
-
worldReady: false,
|
|
36
|
-
spawnReadiness: [] as Array<Record<string, string | number | boolean>>,
|
|
37
|
-
loadingError: "",
|
|
38
|
-
spawnCellsRequired: 0,
|
|
39
|
-
spawnCellsLoaded: 0,
|
|
40
|
-
streamingResidentCells: 0,
|
|
41
|
-
streamingLoadedCells: 0,
|
|
42
|
-
streamingEvictions: 0,
|
|
43
|
-
streamingInstances: 0,
|
|
44
|
-
streamingFailures: 0,
|
|
45
|
-
streamingPendingPrewarm: 0,
|
|
46
|
-
streamingLoadsInFlight: 0,
|
|
47
|
-
streamingAdmissionMs: 0,
|
|
48
|
-
streamingAdmissionBacklog: 0,
|
|
49
|
-
timeToReadyMs: -1,
|
|
50
|
-
enterMs: -1,
|
|
51
|
-
tasksAvailable: false,
|
|
52
|
-
longestLoadTaskMs: -1,
|
|
53
|
-
afterFirstFrameTaskMs: -1,
|
|
54
|
-
maxViewGpuMs: -1,
|
|
55
|
-
measuredGpuViewCount: 0,
|
|
56
|
-
viewGpu: [] as {
|
|
57
|
-
view: string;
|
|
58
|
-
gpuMs: number;
|
|
59
|
-
gpuMain: number;
|
|
60
|
-
gpuShadow: number;
|
|
61
|
-
gpuOther: number;
|
|
62
|
-
windows: number;
|
|
63
|
-
passes: Record<string, { triangles: number; draws: number }>;
|
|
64
|
-
scale: number;
|
|
65
|
-
samples: number;
|
|
66
|
-
}[],
|
|
67
|
-
world: "forest",
|
|
68
|
-
groundBiome: "baked",
|
|
69
|
-
terrainTransportBound: false,
|
|
70
|
-
erosionFlowSamples: 0,
|
|
71
|
-
erosionDepositSamples: 0,
|
|
72
|
-
frames: 0,
|
|
73
|
-
travel: 0,
|
|
74
|
-
/** The farthest the player stood from where it spawned, in a straight line on the ground plane. */
|
|
75
|
-
straightTravel: 0,
|
|
76
|
-
edgeOvershoot: Number.NEGATIVE_INFINITY,
|
|
77
|
-
grounded: false,
|
|
78
|
-
/** Rock and trunk bodies resident around the player (`ScatterColliders`). */
|
|
79
|
-
propColliders: 0,
|
|
80
|
-
/** Frames the player's capsule crossed into a rock or trunk; 0 while props are solid. */
|
|
81
|
-
propOverlapFrames: 0,
|
|
82
|
-
swimming: false,
|
|
83
|
-
immersionDepth: 0,
|
|
84
|
-
swimSamples: 0,
|
|
85
|
-
swimFloatSamples: 0,
|
|
86
|
-
swimExits: 0,
|
|
87
|
-
/** Metres the river current carried the player along itself, while swimming. */
|
|
88
|
-
swimDrift: 0,
|
|
89
|
-
contactSamples: 0,
|
|
90
|
-
maxContactError: 0,
|
|
91
|
-
bilinearDifference: 0,
|
|
92
|
-
oceanSteps: 0,
|
|
93
|
-
waveSamples: 0,
|
|
94
|
-
waveRange: 0,
|
|
95
|
-
sampleSlopeRange: 0,
|
|
96
|
-
lakePlacementError: 1,
|
|
97
|
-
lakeSurfaceCount: 0,
|
|
98
|
-
riverSurfaceCount: 0,
|
|
99
|
-
lakeTriangles: 0,
|
|
100
|
-
lakeFootprintError: 1,
|
|
101
|
-
sunX: -180,
|
|
102
|
-
propDraws: 0,
|
|
103
|
-
propInstances: 0,
|
|
104
|
-
propTriangles: 0,
|
|
105
|
-
/** Drawn prop instances within 40 m of the eye in a fixed view (0 in the player view). */
|
|
106
|
-
coverNearEye: 0,
|
|
107
|
-
/** Drawn grass instances 100-200 m from the eye in a fixed view: the far slopes' cover. */
|
|
108
|
-
coverFar: 0,
|
|
109
|
-
/** Spruce planted past the square (`farForest.ts`), and those drawn inside the view's frustum. */
|
|
110
|
-
farForest: 0,
|
|
111
|
-
farForestInView: 0,
|
|
112
|
-
preparedLodBaseSpread: 0,
|
|
113
|
-
compressedTexturesPrepared: 0,
|
|
114
|
-
preparedLevelsWithoutSolid: 0,
|
|
115
|
-
view: "player",
|
|
116
|
-
revealComplete: false,
|
|
117
|
-
windowDrawCalls: 0,
|
|
118
|
-
windowFrameMs: 0,
|
|
119
|
-
currentViewWindows: 0,
|
|
120
|
-
viewFrameP50s: [] as { view: string; p50: number; presentedP95: number; windows: number }[],
|
|
121
|
-
maxViewFrameP50: 0,
|
|
122
|
-
maxViewPresentedP95: 0,
|
|
123
|
-
measuredViewCount: 0,
|
|
124
|
-
riverFrameP50: 0,
|
|
125
|
-
playerFrameP50: 0,
|
|
126
|
-
meadowFrameP50: 0,
|
|
127
|
-
meadowFrameP99: 0,
|
|
128
|
-
meadowTriangles: 0,
|
|
129
|
-
overviewFrameP50: 0,
|
|
130
|
-
overviewFrameP99: 0,
|
|
131
|
-
overviewTriangles: 0,
|
|
132
|
-
alpineRenderedFrames: 0,
|
|
133
|
-
desertRenderedFrames: 0,
|
|
134
|
-
tundraRenderedFrames: 0,
|
|
135
|
-
alpineFrameP50: 0,
|
|
136
|
-
desertFrameP50: 0,
|
|
137
|
-
tundraFrameP50: 0,
|
|
138
|
-
alpineOverviewFrameP50: 0,
|
|
139
|
-
desertOverviewFrameP50: 0,
|
|
140
|
-
tundraOverviewFrameP50: 0,
|
|
141
|
-
};
|
|
142
|
-
export type DiagnosticsState = typeof initialDiagnosticsState;
|
|
143
|
-
|
|
144
|
-
/** The last closed frame-budget window, published into state by the scene. */
|
|
145
|
-
export const budget = {
|
|
146
|
-
drawCalls: 0,
|
|
147
|
-
frameMs: 0,
|
|
148
|
-
tasksAvailable: false,
|
|
149
|
-
longestTaskMs: -1,
|
|
150
|
-
afterFirstFrameTaskMs: -1,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export const launchedAt =
|
|
154
|
-
typeof performance !== "undefined" && Number.isFinite(performance.timeOrigin)
|
|
155
|
-
? performance.timeOrigin
|
|
156
|
-
: Date.now();
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Per-view frame cost, latched across the windows that closed while that camera was up.
|
|
160
|
-
*
|
|
161
|
-
* `budget` alone cannot answer "did the trees cost more at the meadow or at the overview": a playtest
|
|
162
|
-
* cycles the cameras faster than a window closes, so the one number it holds belongs to whichever
|
|
163
|
-
* view happened to be current. This keeps every window grouped by the view that was on screen, and
|
|
164
|
-
* reports the median of each group's p50s and the worst p99 — the worst, because a LOD band that pops
|
|
165
|
-
* once is a one-frame cost the median hides.
|
|
166
|
-
*/
|
|
167
|
-
export interface IViewWindow {
|
|
168
|
-
readonly view: string;
|
|
169
|
-
readonly p50s: number[];
|
|
170
|
-
readonly p99s: number[];
|
|
171
|
-
/** Presented-frame interval p95 per window: the whole frame the player sees, GPU included. */
|
|
172
|
-
readonly presentedP95s: number[];
|
|
173
|
-
readonly triangles: number[];
|
|
174
|
-
readonly gpuMs: number[];
|
|
175
|
-
readonly gpuMain: number[];
|
|
176
|
-
readonly gpuShadow: number[];
|
|
177
|
-
readonly gpuOther: number[];
|
|
178
|
-
readonly passes: Record<string, { triangles: number; draws: number }>[];
|
|
179
|
-
readonly surfaces: { scale: number; samples: number }[];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** The view on screen and the GPU frame its first sample belongs to. */
|
|
183
|
-
const views = {
|
|
184
|
-
current: "",
|
|
185
|
-
visit: beginViewVisit(),
|
|
186
|
-
measured: "",
|
|
187
|
-
firstGpuFrame: Number.POSITIVE_INFINITY,
|
|
188
|
-
};
|
|
189
|
-
export const viewBudgets = new Map<string, IViewWindow>();
|
|
190
|
-
/** Frames this run drew in each world; a world the run did not reach reports zero. */
|
|
191
|
-
const rendered = new Map<string, number>();
|
|
192
|
-
|
|
193
|
-
/** A group to latch a closed window into: the same accumulator, one per world and view. */
|
|
194
|
-
export function viewGroup(view: string): IViewWindow {
|
|
195
|
-
return {
|
|
196
|
-
view,
|
|
197
|
-
p50s: [],
|
|
198
|
-
p99s: [],
|
|
199
|
-
presentedP95s: [],
|
|
200
|
-
triangles: [],
|
|
201
|
-
gpuMs: [],
|
|
202
|
-
gpuMain: [],
|
|
203
|
-
gpuShadow: [],
|
|
204
|
-
gpuOther: [],
|
|
205
|
-
passes: [],
|
|
206
|
-
surfaces: [],
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/** Start a scene's view accounting: the player view it opens in, and nothing measured yet. */
|
|
211
|
-
export function beginScene(world: string): void {
|
|
212
|
-
views.current = `${world}:player`;
|
|
213
|
-
views.visit = beginViewVisit();
|
|
214
|
-
views.firstGpuFrame = Number.POSITIVE_INFINITY;
|
|
215
|
-
views.measured = "";
|
|
216
|
-
const group = viewGroup(views.current);
|
|
217
|
-
viewBudgets.set(views.current, group);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** The camera cycle moved to another view: a keyed group for it, and a fresh measurement. */
|
|
221
|
-
export function enterView(world: string, view: string): { current: string; windows: number } {
|
|
222
|
-
views.current = `${world}:${view}`;
|
|
223
|
-
views.visit = beginViewVisit();
|
|
224
|
-
views.firstGpuFrame = Number.POSITIVE_INFINITY;
|
|
225
|
-
views.measured = "";
|
|
226
|
-
// Cumulative, not reset: a view is entered once per cycle but latched across every pass the run
|
|
227
|
-
// makes through it, so a second visit measures the same framing with more samples behind it
|
|
228
|
-
// rather than starting the count from nothing.
|
|
229
|
-
if (!viewBudgets.has(views.current)) viewBudgets.set(views.current, viewGroup(views.current));
|
|
230
|
-
return { current: views.current, windows: views.visit.windows };
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/** What a scene says about itself for one report: everything the counters cannot know. */
|
|
234
|
-
export interface ISceneFacts {
|
|
235
|
-
readonly world: WorldName;
|
|
236
|
-
readonly groundBiome: string;
|
|
237
|
-
readonly elevation: readonly [number, number];
|
|
238
|
-
readonly snowBand: readonly [number, number];
|
|
239
|
-
readonly worldReady: boolean;
|
|
240
|
-
readonly spawnReadiness: DiagnosticsState["spawnReadiness"];
|
|
241
|
-
readonly spawnCells: { readonly required: number; readonly loaded: number };
|
|
242
|
-
readonly streaming:
|
|
243
|
-
| {
|
|
244
|
-
readonly residentCells: number;
|
|
245
|
-
readonly loadedCells: number;
|
|
246
|
-
readonly evictions: number;
|
|
247
|
-
readonly instances: number;
|
|
248
|
-
readonly failures: number;
|
|
249
|
-
readonly pendingPrewarm: number;
|
|
250
|
-
readonly loadsInFlight: number;
|
|
251
|
-
readonly admissionMs: number;
|
|
252
|
-
readonly admissionBacklog: number;
|
|
253
|
-
}
|
|
254
|
-
| undefined;
|
|
255
|
-
readonly terrainTransportBound: boolean;
|
|
256
|
-
readonly erosion: { readonly flow: number; readonly deposition: number };
|
|
257
|
-
readonly sunX: number;
|
|
258
|
-
readonly frames: number;
|
|
259
|
-
readonly travel: number;
|
|
260
|
-
readonly straightTravel: number;
|
|
261
|
-
readonly edgeOvershoot: number;
|
|
262
|
-
readonly grounded: boolean;
|
|
263
|
-
readonly propColliders: number;
|
|
264
|
-
readonly propOverlapFrames: number;
|
|
265
|
-
readonly swimming: boolean;
|
|
266
|
-
readonly immersionDepth: number;
|
|
267
|
-
readonly swimSamples: number;
|
|
268
|
-
readonly swimFloatSamples: number;
|
|
269
|
-
readonly swimExits: number;
|
|
270
|
-
readonly swimDrift: number;
|
|
271
|
-
readonly contactSamples: number;
|
|
272
|
-
readonly maxContactError: number;
|
|
273
|
-
readonly bilinearDifference: number;
|
|
274
|
-
readonly oceanSteps: number;
|
|
275
|
-
readonly waveSamples: number;
|
|
276
|
-
readonly waveRange: number;
|
|
277
|
-
readonly sampleSlopeRange: number;
|
|
278
|
-
readonly propCounts: {
|
|
279
|
-
readonly draws: number;
|
|
280
|
-
readonly instances: number;
|
|
281
|
-
readonly triangles: number;
|
|
282
|
-
};
|
|
283
|
-
readonly coverNearEye: number;
|
|
284
|
-
readonly coverFar: number;
|
|
285
|
-
readonly farForest: number;
|
|
286
|
-
readonly farForestInView: number;
|
|
287
|
-
readonly preparedLodBaseSpread: number;
|
|
288
|
-
readonly compressedTexturesPrepared: number;
|
|
289
|
-
readonly preparedLevelsWithoutSolid: number;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/** The frame-budget window closed: latch it, and update the numbers the run reports. */
|
|
293
|
-
export function observeWindow(window: IFrameBudgetWindow): void {
|
|
294
|
-
budget.drawCalls = Object.values(window.passes ?? {}).reduce(
|
|
295
|
-
(sum, pass) => sum + (pass.draws.mean * pass.frames) / window.frames,
|
|
296
|
-
0,
|
|
297
|
-
);
|
|
298
|
-
budget.frameMs = window.frame.p50;
|
|
299
|
-
budget.tasksAvailable = window.longTasks.available;
|
|
300
|
-
if (window.longTasks.available) {
|
|
301
|
-
budget.longestTaskMs = window.longTasks.longestMs;
|
|
302
|
-
budget.afterFirstFrameTaskMs = window.longTasks.afterFirstFrameMs;
|
|
303
|
-
}
|
|
304
|
-
const group = viewBudgets.get(views.current);
|
|
305
|
-
if (group && retainViewWindow(views.visit, window, views.firstGpuFrame)) {
|
|
306
|
-
if (
|
|
307
|
-
window.gpuMs !== undefined &&
|
|
308
|
-
window.gpuFrames &&
|
|
309
|
-
window.gpuFrames.first >= views.firstGpuFrame &&
|
|
310
|
-
window.surface?.compiling !== true
|
|
311
|
-
) {
|
|
312
|
-
group.gpuMs.push(window.gpuMs);
|
|
313
|
-
if (window.gpuMain !== undefined) group.gpuMain.push(window.gpuMain);
|
|
314
|
-
if (window.gpuShadow !== undefined) group.gpuShadow.push(window.gpuShadow);
|
|
315
|
-
if (window.gpuOther !== undefined) group.gpuOther.push(window.gpuOther);
|
|
316
|
-
group.passes.push(
|
|
317
|
-
Object.fromEntries(
|
|
318
|
-
Object.entries(window.passes ?? {}).map(([pass, counts]) => [
|
|
319
|
-
pass,
|
|
320
|
-
// A kind can run several times per frame (world + fullscreen AO are nested).
|
|
321
|
-
// Summarising individual calls' p50 hides the world behind the one-triangle quads.
|
|
322
|
-
{
|
|
323
|
-
triangles: Math.round((counts.triangles.mean * counts.frames) / window.frames),
|
|
324
|
-
draws: (counts.draws.mean * counts.frames) / window.frames,
|
|
325
|
-
},
|
|
326
|
-
]),
|
|
327
|
-
),
|
|
328
|
-
);
|
|
329
|
-
if (window.surface)
|
|
330
|
-
group.surfaces.push({
|
|
331
|
-
scale: window.surface.resolutionScale,
|
|
332
|
-
samples: window.surface.sampleCount,
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
group.p50s.push(window.frame.p50);
|
|
336
|
-
group.p99s.push(window.frame.p99);
|
|
337
|
-
group.presentedP95s.push(window.presented.p95);
|
|
338
|
-
group.triangles.push(
|
|
339
|
-
// The world pass is nested beneath AO; its full-screen passes submit one triangle.
|
|
340
|
-
Object.values(window.passes ?? {}).reduce((sum, pass) => sum + pass.triangles.max, 0),
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/** The scene it is counting and the phase the run is in: what a frame counter asks the game. */
|
|
346
|
-
export interface ICounterCtx {
|
|
347
|
-
readonly startup: { readonly phase: string };
|
|
348
|
-
readonly renderer: {
|
|
349
|
-
readonly gpuFrameSample?: () => { readonly frame: number } | undefined;
|
|
350
|
-
readonly gpuFrameAge?: () => number | undefined;
|
|
351
|
-
};
|
|
352
|
-
readonly state: { getState: () => DiagnosticsState };
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* One world frame was drawn: count it, and open a fresh GPU sample window if the view or the
|
|
357
|
-
* readiness changed. Called from the render hook, before the camera is placed.
|
|
358
|
-
*/
|
|
359
|
-
export function observeFrame(world: string, ctx: ICounterCtx): void {
|
|
360
|
-
rendered.set(world, (rendered.get(world) ?? 0) + 1);
|
|
361
|
-
views.visit.ready = ctx.state.getState().worldReady && ctx.startup.phase === "ready";
|
|
362
|
-
if (!views.visit.ready) views.visit.discard = true;
|
|
363
|
-
const ready = ctx.state.getState().worldReady && ctx.startup.phase === "ready";
|
|
364
|
-
if (views.measured !== views.current || !ready) {
|
|
365
|
-
views.measured = views.current;
|
|
366
|
-
views.firstGpuFrame = Number.POSITIVE_INFINITY;
|
|
367
|
-
}
|
|
368
|
-
if (views.firstGpuFrame === Number.POSITIVE_INFINITY && ready) {
|
|
369
|
-
const sample = ctx.renderer.gpuFrameSample?.();
|
|
370
|
-
const age = ctx.renderer.gpuFrameAge?.();
|
|
371
|
-
if (sample && age !== undefined) views.firstGpuFrame = sample.frame + age + 1;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/** The windows that closed while a view was up, as the run report reads them. */
|
|
376
|
-
function viewReports(): {
|
|
377
|
-
viewFrameP50s: DiagnosticsState["viewFrameP50s"];
|
|
378
|
-
viewGpu: DiagnosticsState["viewGpu"];
|
|
379
|
-
} {
|
|
380
|
-
const viewFrameP50s = [...viewBudgets.values()].map((group) => ({
|
|
381
|
-
view: group.view,
|
|
382
|
-
p50: median(group.p50s),
|
|
383
|
-
presentedP95: median(group.presentedP95s),
|
|
384
|
-
windows: group.p50s.length,
|
|
385
|
-
}));
|
|
386
|
-
const viewGpu = [...viewBudgets.values()]
|
|
387
|
-
.filter((group) => group.gpuMs.length > 0)
|
|
388
|
-
.map((group) => ({
|
|
389
|
-
view: group.view,
|
|
390
|
-
gpuMs: median(group.gpuMs),
|
|
391
|
-
gpuMain: group.gpuMain.length ? median(group.gpuMain) : -1,
|
|
392
|
-
gpuShadow: group.gpuShadow.length ? median(group.gpuShadow) : -1,
|
|
393
|
-
gpuOther: group.gpuOther.length ? median(group.gpuOther) : -1,
|
|
394
|
-
windows: group.gpuMs.length,
|
|
395
|
-
passes: Object.fromEntries(
|
|
396
|
-
Object.keys(group.passes[0] ?? {}).map((pass) => [
|
|
397
|
-
pass,
|
|
398
|
-
{
|
|
399
|
-
triangles: median(group.passes.map((window) => window[pass]?.triangles ?? 0)),
|
|
400
|
-
draws: median(group.passes.map((window) => window[pass]?.draws ?? 0)),
|
|
401
|
-
},
|
|
402
|
-
]),
|
|
403
|
-
),
|
|
404
|
-
scale: median(group.surfaces.map((surface) => surface.scale)),
|
|
405
|
-
samples: median(group.surfaces.map((surface) => surface.samples)),
|
|
406
|
-
}));
|
|
407
|
-
return { viewFrameP50s, viewGpu };
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** A view's median p50, and its worst p99: a band that pops once is a cost the median hides. */
|
|
411
|
-
const p50Of = (view: string): number => median(viewBudgets.get(view)?.p50s ?? []);
|
|
412
|
-
const p99Of = (view: string): number => Math.max(0, ...(viewBudgets.get(view)?.p99s ?? []));
|
|
413
|
-
const trianglesOf = (view: string): number => median(viewBudgets.get(view)?.triangles ?? []);
|
|
414
|
-
|
|
415
|
-
/** Publish the measurements and the scene's own facts into state, twice per second. */
|
|
416
|
-
export function publish(
|
|
417
|
-
ctx: {
|
|
418
|
-
readonly state: {
|
|
419
|
-
set: (patch: Partial<DiagnosticsState>) => void;
|
|
420
|
-
getState: () => DiagnosticsState;
|
|
421
|
-
};
|
|
422
|
-
},
|
|
423
|
-
facts: ISceneFacts,
|
|
424
|
-
): void {
|
|
425
|
-
const { viewFrameP50s, viewGpu } = viewReports();
|
|
426
|
-
const [elevationMin, elevationMax] = facts.elevation;
|
|
427
|
-
const [snowFrom, snowTo] = facts.snowBand;
|
|
428
|
-
const streaming = facts.streaming;
|
|
429
|
-
ctx.state.set({
|
|
430
|
-
viewGpu,
|
|
431
|
-
elevationMin,
|
|
432
|
-
elevationMax,
|
|
433
|
-
snowFrom,
|
|
434
|
-
snowTo,
|
|
435
|
-
maxViewGpuMs: viewGpu.length ? Math.max(...viewGpu.map((group) => group.gpuMs)) : -1,
|
|
436
|
-
measuredGpuViewCount: viewGpu.length,
|
|
437
|
-
tasksAvailable: budget.tasksAvailable,
|
|
438
|
-
longestLoadTaskMs: budget.longestTaskMs,
|
|
439
|
-
afterFirstFrameTaskMs: budget.afterFirstFrameTaskMs,
|
|
440
|
-
currentViewWindows: views.visit.windows,
|
|
441
|
-
viewFrameP50s,
|
|
442
|
-
maxViewFrameP50: Math.max(0, ...viewFrameP50s.map((group) => group.p50)),
|
|
443
|
-
maxViewPresentedP95: Math.max(0, ...viewFrameP50s.map((group) => group.presentedP95)),
|
|
444
|
-
measuredViewCount: viewFrameP50s.filter((group) => group.windows > 0).length,
|
|
445
|
-
world: facts.world,
|
|
446
|
-
groundBiome: facts.groundBiome,
|
|
447
|
-
worldReady: facts.worldReady,
|
|
448
|
-
spawnReadiness: facts.spawnReadiness,
|
|
449
|
-
spawnCellsRequired: facts.spawnCells.required,
|
|
450
|
-
spawnCellsLoaded: facts.spawnCells.loaded,
|
|
451
|
-
streamingResidentCells: streaming?.residentCells ?? 0,
|
|
452
|
-
streamingLoadedCells: streaming?.loadedCells ?? 0,
|
|
453
|
-
streamingEvictions: streaming?.evictions ?? 0,
|
|
454
|
-
streamingInstances: streaming?.instances ?? 0,
|
|
455
|
-
streamingFailures: streaming?.failures ?? 0,
|
|
456
|
-
streamingPendingPrewarm: streaming?.pendingPrewarm ?? 0,
|
|
457
|
-
streamingLoadsInFlight: streaming?.loadsInFlight ?? 0,
|
|
458
|
-
streamingAdmissionMs: streaming?.admissionMs ?? 0,
|
|
459
|
-
streamingAdmissionBacklog: streaming?.admissionBacklog ?? 0,
|
|
460
|
-
terrainTransportBound: facts.terrainTransportBound,
|
|
461
|
-
erosionFlowSamples: facts.erosion.flow,
|
|
462
|
-
erosionDepositSamples: facts.erosion.deposition,
|
|
463
|
-
sunX: facts.sunX,
|
|
464
|
-
frames: facts.frames,
|
|
465
|
-
travel: facts.travel,
|
|
466
|
-
straightTravel: facts.straightTravel,
|
|
467
|
-
edgeOvershoot: facts.edgeOvershoot,
|
|
468
|
-
grounded: facts.grounded,
|
|
469
|
-
propColliders: facts.propColliders,
|
|
470
|
-
propOverlapFrames: facts.propOverlapFrames,
|
|
471
|
-
swimming: facts.swimming,
|
|
472
|
-
immersionDepth: facts.immersionDepth,
|
|
473
|
-
swimSamples: facts.swimSamples,
|
|
474
|
-
swimFloatSamples: facts.swimFloatSamples,
|
|
475
|
-
swimExits: facts.swimExits,
|
|
476
|
-
swimDrift: facts.swimDrift,
|
|
477
|
-
contactSamples: facts.contactSamples,
|
|
478
|
-
maxContactError: facts.maxContactError,
|
|
479
|
-
bilinearDifference: facts.bilinearDifference,
|
|
480
|
-
oceanSteps: facts.oceanSteps,
|
|
481
|
-
waveSamples: facts.waveSamples,
|
|
482
|
-
waveRange: facts.waveRange,
|
|
483
|
-
sampleSlopeRange: facts.sampleSlopeRange,
|
|
484
|
-
propDraws: facts.propCounts.draws,
|
|
485
|
-
propInstances: facts.propCounts.instances,
|
|
486
|
-
propTriangles: facts.propCounts.triangles,
|
|
487
|
-
coverNearEye: facts.coverNearEye,
|
|
488
|
-
coverFar: facts.coverFar,
|
|
489
|
-
farForest: facts.farForest,
|
|
490
|
-
farForestInView: facts.farForestInView,
|
|
491
|
-
preparedLodBaseSpread: facts.preparedLodBaseSpread,
|
|
492
|
-
compressedTexturesPrepared: facts.compressedTexturesPrepared,
|
|
493
|
-
preparedLevelsWithoutSolid: facts.preparedLevelsWithoutSolid,
|
|
494
|
-
windowDrawCalls: budget.drawCalls,
|
|
495
|
-
windowFrameMs: budget.frameMs,
|
|
496
|
-
// Every camera cost, published as plain state so the run report carries the numbers rather than
|
|
497
|
-
// a console ring buffer that outlives neither run.
|
|
498
|
-
riverFrameP50: p50Of("forest:river"),
|
|
499
|
-
playerFrameP50: p50Of("forest:player"),
|
|
500
|
-
meadowFrameP50: p50Of("forest:meadow-close"),
|
|
501
|
-
meadowFrameP99: p99Of("forest:meadow-close"),
|
|
502
|
-
meadowTriangles: trianglesOf("forest:meadow-close"),
|
|
503
|
-
overviewFrameP50: p50Of("forest:overview"),
|
|
504
|
-
overviewFrameP99: p99Of("forest:overview"),
|
|
505
|
-
overviewTriangles: trianglesOf("forest:overview"),
|
|
506
|
-
alpineRenderedFrames: rendered.get("alpine") ?? 0,
|
|
507
|
-
desertRenderedFrames: rendered.get("desert") ?? 0,
|
|
508
|
-
tundraRenderedFrames: rendered.get("tundra") ?? 0,
|
|
509
|
-
alpineFrameP50: p50Of("alpine:ridge"),
|
|
510
|
-
desertFrameP50: p50Of("desert:mesa"),
|
|
511
|
-
tundraFrameP50: p50Of("tundra:plain"),
|
|
512
|
-
alpineOverviewFrameP50: p50Of("alpine:overview"),
|
|
513
|
-
desertOverviewFrameP50: p50Of("desert:overview"),
|
|
514
|
-
tundraOverviewFrameP50: p50Of("tundra:overview"),
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/** The scene is gone: nothing is on screen, so no window can belong to a view. */
|
|
519
|
-
export function leaveScene(): void {
|
|
520
|
-
views.current = "";
|
|
521
|
-
views.visit = beginViewVisit();
|
|
522
|
-
views.firstGpuFrame = Number.POSITIVE_INFINITY;
|
|
523
|
-
views.measured = "";
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* What one scene measures about the player, the ground and the props, step by step.
|
|
528
|
-
*
|
|
529
|
-
* The scene builds the world and calls `step()` from its physics hook; the counters and the probes
|
|
530
|
-
* live here. Each probe fails closed by the same rule the scene had: a contact the run cannot
|
|
531
|
-
* observe throws rather than publishing a healthy-looking zero.
|
|
532
|
-
*/
|
|
533
|
-
export interface IMeasureOptions {
|
|
534
|
-
readonly world: string;
|
|
535
|
-
readonly physics: IPhysicsContext;
|
|
536
|
-
readonly raycast: (options: IRaycastOptions) => Intersection | undefined;
|
|
537
|
-
readonly actor: Mesh;
|
|
538
|
-
readonly player: CharacterBody3D;
|
|
539
|
-
/** The baked world's own size, in metres: the square the player can walk off. */
|
|
540
|
-
readonly size: number;
|
|
541
|
-
readonly mesh: Mesh | undefined;
|
|
542
|
-
/** The drawn triangles of the staged world's ground, when the run draws a staged world. */
|
|
543
|
-
readonly stage: IStagedWorld | undefined;
|
|
544
|
-
/** The invisible asymmetric fixture the bilinear-difference probe walks. */
|
|
545
|
-
readonly fixture: { heightAt: (x: number, z: number) => number };
|
|
546
|
-
readonly probeMesh: Mesh;
|
|
547
|
-
/** True while the figure plays a swim clip: the playtest reads swimming that way. */
|
|
548
|
-
readonly swimmingClip: () => boolean;
|
|
549
|
-
/** True once the scene holds prop colliders to probe. */
|
|
550
|
-
readonly hasPropColliders: () => boolean;
|
|
551
|
-
readonly eye: () => Vector3;
|
|
552
|
-
readonly camera: () => PerspectiveCamera;
|
|
553
|
-
readonly ocean: IOceanSample | undefined;
|
|
554
|
-
readonly spawnReady: () => boolean;
|
|
555
|
-
readonly terrainTargets: () => Object3D | readonly Object3D[] | undefined;
|
|
556
|
-
readonly view: () => string;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
interface IStagedWorld {
|
|
560
|
-
readonly world: {
|
|
561
|
-
stats: () => unknown;
|
|
562
|
-
traverseVisible: (callback: (object: Object3D) => void) => void;
|
|
563
|
-
};
|
|
564
|
-
readonly ground: { readonly body: { readonly id: number | string } };
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
interface IOceanSample {
|
|
568
|
-
readonly steps: number;
|
|
569
|
-
readonly sampleHeight: (x: number, z: number) => { readonly height: number } | undefined;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/** The measurements a scene publishes each time `publish` runs. */
|
|
573
|
-
export interface IMeasureFacts {
|
|
574
|
-
readonly travel: number;
|
|
575
|
-
readonly straightTravel: number;
|
|
576
|
-
readonly edgeOvershoot: number;
|
|
577
|
-
readonly grounded: boolean;
|
|
578
|
-
readonly propOverlapFrames: number;
|
|
579
|
-
readonly swimming: boolean;
|
|
580
|
-
readonly immersionDepth: number;
|
|
581
|
-
readonly swimSamples: number;
|
|
582
|
-
readonly swimFloatSamples: number;
|
|
583
|
-
readonly swimExits: number;
|
|
584
|
-
readonly swimDrift: number;
|
|
585
|
-
readonly contactSamples: number;
|
|
586
|
-
readonly maxContactError: number;
|
|
587
|
-
readonly bilinearDifference: number;
|
|
588
|
-
readonly oceanSteps: number;
|
|
589
|
-
readonly waveSamples: number;
|
|
590
|
-
readonly waveRange: number;
|
|
591
|
-
readonly sampleSlopeRange: number;
|
|
592
|
-
readonly propCounts: {
|
|
593
|
-
readonly draws: number;
|
|
594
|
-
readonly instances: number;
|
|
595
|
-
readonly triangles: number;
|
|
596
|
-
};
|
|
597
|
-
readonly coverNearEye: number;
|
|
598
|
-
readonly coverFar: number;
|
|
599
|
-
readonly farForestInView: number;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
export interface IMeasure {
|
|
603
|
-
/** One fixed physics step: travel, contact, the edge, the swim and the water's own samples. */
|
|
604
|
-
readonly step: () => void;
|
|
605
|
-
/** The drawn prop counts and the cover in front of the eye, every thirtieth step. */
|
|
606
|
-
readonly countProps: (meshes: InstancedMesh[], farWorld: Object3D | undefined) => void;
|
|
607
|
-
readonly facts: () => IMeasureFacts;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* The asymmetric fixture: eight seeded points where a bilinear height and the drawn triangle disagree,
|
|
612
|
-
* walked by both paths — the picker's triangles and the solver's own ray. It throws when either path
|
|
613
|
-
* answers nothing, because a run that cannot see the ground must not publish a healthy zero.
|
|
614
|
-
*/
|
|
615
|
-
export interface IContactProbeOptions {
|
|
616
|
-
readonly mesh: { updateMatrixWorld: (force?: boolean) => unknown } | undefined;
|
|
617
|
-
readonly probeMesh: { updateMatrixWorld: (force?: boolean) => unknown };
|
|
618
|
-
readonly raycast: (options: IRaycastOptions) => Intersection | undefined;
|
|
619
|
-
readonly physics: IPhysicsContext;
|
|
620
|
-
readonly fixture: { heightAt: (x: number, z: number) => number };
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
export interface IContactWitness {
|
|
624
|
-
readonly bilinearDifference: number;
|
|
625
|
-
readonly contactSamples: number;
|
|
626
|
-
readonly maxContactError: number;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
export function witnessAsymmetricContact(options: IContactProbeOptions): IContactWitness {
|
|
630
|
-
options.probeMesh.updateMatrixWorld(true);
|
|
631
|
-
options.mesh?.updateMatrixWorld(true);
|
|
632
|
-
let maxContactError = 0;
|
|
633
|
-
let bilinearDifference = 0;
|
|
634
|
-
let contactSamples = 0;
|
|
635
|
-
const points = [
|
|
636
|
-
[-7.75, -7.75],
|
|
637
|
-
[-7.25, -7.25],
|
|
638
|
-
[-7.75, -7.25],
|
|
639
|
-
[-7.25, -7.75],
|
|
640
|
-
[-8, -8],
|
|
641
|
-
[-7, -8],
|
|
642
|
-
[0, 0],
|
|
643
|
-
[7.5, 7.5],
|
|
644
|
-
];
|
|
645
|
-
for (const [x, z] of points) {
|
|
646
|
-
const wx = 600 + (x as number);
|
|
647
|
-
const visual = options.raycast({
|
|
648
|
-
origin: new Vector3(wx, 200, z),
|
|
649
|
-
direction: new Vector3(0, -1, 0),
|
|
650
|
-
targets: options.probeMesh as Object3D,
|
|
651
|
-
});
|
|
652
|
-
const physical = options.physics.directSpaceState.intersectRay({
|
|
653
|
-
from: { x: wx, y: 200, z: z as number },
|
|
654
|
-
to: { x: wx, y: -100, z: z as number },
|
|
655
|
-
collisionMask: 2,
|
|
656
|
-
});
|
|
657
|
-
if (!visual || !physical) throw new Error("Missing asymmetric terrain contact");
|
|
658
|
-
maxContactError = Math.max(maxContactError, Math.abs(visual.point.y - physical.position.y));
|
|
659
|
-
bilinearDifference = Math.max(
|
|
660
|
-
bilinearDifference,
|
|
661
|
-
Math.abs(visual.point.y - options.fixture.heightAt(x as number, z as number)),
|
|
662
|
-
);
|
|
663
|
-
contactSamples++;
|
|
664
|
-
}
|
|
665
|
-
return { bilinearDifference, contactSamples, maxContactError };
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
export function createMeasure(options: IMeasureOptions): IMeasure {
|
|
669
|
-
const { actor, physics, player } = options;
|
|
670
|
-
const previous = actor.position.clone();
|
|
671
|
-
const origin = actor.position.clone();
|
|
672
|
-
// The owner's report, measured the same with or without prop collision: frames in which the
|
|
673
|
-
// player's capsule, less a 5 cm skin, crosses into a rock or trunk body.
|
|
674
|
-
const propProbe = CollisionShape3D.capsule(0.5, 0.3);
|
|
675
|
-
const farFrustum = new Frustum();
|
|
676
|
-
const farMatrix = new Matrix4();
|
|
677
|
-
const farPoint = new Vector3();
|
|
678
|
-
let travel = 0;
|
|
679
|
-
let straightTravel = 0;
|
|
680
|
-
let propOverlapFrames = 0;
|
|
681
|
-
// Metres past the playable square's edge the player reached: onto the surroundings' hills.
|
|
682
|
-
let edgeOvershoot = Number.NEGATIVE_INFINITY;
|
|
683
|
-
// Swimming as the playtest reads it: samples swimming with a swim clip on, those of them off
|
|
684
|
-
// the bed, and how many times the player climbed back out.
|
|
685
|
-
let swimSamples = 0;
|
|
686
|
-
let swimFloatSamples = 0;
|
|
687
|
-
let swimExits = 0;
|
|
688
|
-
let swimDrift = 0;
|
|
689
|
-
let wasSwimming = false;
|
|
690
|
-
let contactSamples = 0;
|
|
691
|
-
let maxContactError = 0;
|
|
692
|
-
let bilinearDifference = 0;
|
|
693
|
-
let waveSamples = 0;
|
|
694
|
-
let minWave = Number.POSITIVE_INFINITY;
|
|
695
|
-
let maxWave = Number.NEGATIVE_INFINITY;
|
|
696
|
-
let minSlope = Number.POSITIVE_INFINITY;
|
|
697
|
-
let maxSlope = Number.NEGATIVE_INFINITY;
|
|
698
|
-
let propCounts = { draws: 0, instances: 0, triangles: 0 };
|
|
699
|
-
let coverNearEye = 0;
|
|
700
|
-
let coverFar = 0;
|
|
701
|
-
let farForestInView = 0;
|
|
702
|
-
let frames = 0;
|
|
703
|
-
|
|
704
|
-
const step = (): void => {
|
|
705
|
-
const dx = actor.position.x - previous.x;
|
|
706
|
-
const dz = actor.position.z - previous.z;
|
|
707
|
-
travel += Math.hypot(dx, dz);
|
|
708
|
-
previous.copy(actor.position);
|
|
709
|
-
straightTravel = Math.max(
|
|
710
|
-
straightTravel,
|
|
711
|
-
Math.hypot(actor.position.x - origin.x, actor.position.z - origin.z),
|
|
712
|
-
);
|
|
713
|
-
// What the water moved, not what the keys moved: the share of this step's travel along the
|
|
714
|
-
// current, counted only while swimming with no input of the player's own. 0 with
|
|
715
|
-
// `?current=off`, which is its before arm.
|
|
716
|
-
if (player.swimming && player.velocity.x === 0 && player.velocity.z === 0) {
|
|
717
|
-
const { x: cx, z: cz } = player.currentVelocity;
|
|
718
|
-
const speed = Math.hypot(cx, cz);
|
|
719
|
-
if (speed > 0) swimDrift += (dx * cx + dz * cz) / speed;
|
|
720
|
-
}
|
|
721
|
-
if (
|
|
722
|
-
options.hasPropColliders() &&
|
|
723
|
-
physics.directSpaceState.intersectShape({
|
|
724
|
-
shape: propProbe,
|
|
725
|
-
position: actor.position,
|
|
726
|
-
collisionMask: 16,
|
|
727
|
-
maxResults: 1,
|
|
728
|
-
}).length > 0
|
|
729
|
-
)
|
|
730
|
-
propOverlapFrames++;
|
|
731
|
-
// Query actual triangles, not bilinear interpolation, after the shared solver step.
|
|
732
|
-
if (frames === 0) {
|
|
733
|
-
const witness = witnessAsymmetricContact({
|
|
734
|
-
mesh: options.mesh,
|
|
735
|
-
probeMesh: options.probeMesh,
|
|
736
|
-
raycast: options.raycast,
|
|
737
|
-
physics,
|
|
738
|
-
fixture: options.fixture,
|
|
739
|
-
});
|
|
740
|
-
contactSamples = witness.contactSamples;
|
|
741
|
-
maxContactError = Math.max(maxContactError, witness.maxContactError);
|
|
742
|
-
bilinearDifference = Math.max(bilinearDifference, witness.bilinearDifference);
|
|
743
|
-
}
|
|
744
|
-
// A staged world admits no terrain tile before its first update, which the loop's settle
|
|
745
|
-
// steps precede, so its contact is observed once its spawn region is ready.
|
|
746
|
-
// A staged world streams around the camera, so a benchmark view far from the player has no
|
|
747
|
-
// ground under it; the player is held there (see the scene) and its contact is not asked for.
|
|
748
|
-
// Past the square the player stands on the surroundings, whose collider is their drawn
|
|
749
|
-
// triangles (see the walls the scene builds): physics alone answers there, and no picking tree
|
|
750
|
-
// is built.
|
|
751
|
-
const onSurroundings =
|
|
752
|
-
options.stage === undefined &&
|
|
753
|
-
Math.max(Math.abs(actor.position.x), Math.abs(actor.position.z)) > options.size / 2 - 1;
|
|
754
|
-
edgeOvershoot = Math.max(
|
|
755
|
-
edgeOvershoot,
|
|
756
|
-
Math.max(Math.abs(actor.position.x), Math.abs(actor.position.z)) - options.size / 2,
|
|
757
|
-
);
|
|
758
|
-
if (player.swimming && options.swimmingClip()) swimSamples++;
|
|
759
|
-
if (player.swimming && !player.grounded) swimFloatSamples++;
|
|
760
|
-
if (wasSwimming && !player.swimming) swimExits++;
|
|
761
|
-
wasSwimming = player.swimming;
|
|
762
|
-
if (options.stage === undefined || (options.spawnReady() && options.view() === "player")) {
|
|
763
|
-
const terrainTargets = options.terrainTargets();
|
|
764
|
-
const visual =
|
|
765
|
-
!onSurroundings &&
|
|
766
|
-
terrainTargets &&
|
|
767
|
-
options.raycast({
|
|
768
|
-
origin: new Vector3(actor.position.x, 300, actor.position.z),
|
|
769
|
-
direction: new Vector3(1, -400, 1).normalize(),
|
|
770
|
-
targets: terrainTargets,
|
|
771
|
-
});
|
|
772
|
-
// The same line as the visual ray, started a metre above the feet: from 300 m, a stage
|
|
773
|
-
// tree the player stands against is the first body under it, not the ground.
|
|
774
|
-
const start = options.stage || onSurroundings ? actor.position.y + 1 : 300;
|
|
775
|
-
const lead = (300 - start) / 400;
|
|
776
|
-
const physical = physics.directSpaceState.intersectRay({
|
|
777
|
-
from: { x: actor.position.x + lead, y: start, z: actor.position.z + lead },
|
|
778
|
-
to: { x: actor.position.x + 1, y: -100, z: actor.position.z + 1 },
|
|
779
|
-
// The kit's ground keeps the default layer; here the ground alone, not a rock beside it.
|
|
780
|
-
collisionMask: options.stage ? 1 : 8,
|
|
781
|
-
});
|
|
782
|
-
if (
|
|
783
|
-
(!visual && !onSurroundings) ||
|
|
784
|
-
!physical ||
|
|
785
|
-
(options.stage && physical.body.id !== options.stage.ground.body.id)
|
|
786
|
-
)
|
|
787
|
-
throw new Error(
|
|
788
|
-
`Missing playable terrain contact: world=${options.world}, frame=${frames}, player=${actor.position.toArray()}, visual=${!!visual}, physical=${!!physical}, body=${physical?.body.id}:${physical?.body.entity}, expectedGround=${options.stage?.ground.body.id}, terrain=${options.mesh?.position.toArray() ?? "stage"}`,
|
|
789
|
-
);
|
|
790
|
-
if (visual) {
|
|
791
|
-
maxContactError = Math.max(maxContactError, Math.abs(visual.point.y - physical.position.y));
|
|
792
|
-
contactSamples++;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
const wave = options.ocean?.sampleHeight(130, 140);
|
|
796
|
-
const east = options.ocean?.sampleHeight(131, 140);
|
|
797
|
-
if (wave && east) {
|
|
798
|
-
waveSamples++;
|
|
799
|
-
minWave = Math.min(minWave, wave.height);
|
|
800
|
-
maxWave = Math.max(maxWave, wave.height);
|
|
801
|
-
// Stale CPU sample slopes are a proxy; they do not qualify rendered normals.
|
|
802
|
-
const slope = east.height - wave.height;
|
|
803
|
-
minSlope = Math.min(minSlope, slope);
|
|
804
|
-
maxSlope = Math.max(maxSlope, slope);
|
|
805
|
-
}
|
|
806
|
-
frames++;
|
|
807
|
-
};
|
|
808
|
-
|
|
809
|
-
const countProps = (meshes: InstancedMesh[], farWorld: Object3D | undefined): void => {
|
|
810
|
-
propCounts = {
|
|
811
|
-
draws: meshes.length,
|
|
812
|
-
instances: meshes.reduce((sum, draw) => sum + draw.count, 0),
|
|
813
|
-
triangles: meshes.reduce(
|
|
814
|
-
(sum, draw) => sum + (draw.count * (draw.geometry.index?.count ?? 0)) / 3,
|
|
815
|
-
0,
|
|
816
|
-
),
|
|
817
|
-
};
|
|
818
|
-
// What the vista's meadow puts in front of the eye; skipped in the player view.
|
|
819
|
-
coverNearEye = 0;
|
|
820
|
-
coverFar = 0;
|
|
821
|
-
if (options.view() !== "player") {
|
|
822
|
-
const eye = options.eye();
|
|
823
|
-
for (const draw of meshes) {
|
|
824
|
-
const grass = /^(grass|meadow):/.test(draw.name);
|
|
825
|
-
const local = draw.instanceMatrix.array;
|
|
826
|
-
const world = draw.matrixWorld.elements;
|
|
827
|
-
for (let i = 0; i < draw.count; i++) {
|
|
828
|
-
const x = local[i * 16 + 12] as number;
|
|
829
|
-
const y = local[i * 16 + 13] as number;
|
|
830
|
-
const z = local[i * 16 + 14] as number;
|
|
831
|
-
const dx =
|
|
832
|
-
(world[0] as number) * x +
|
|
833
|
-
(world[4] as number) * y +
|
|
834
|
-
(world[8] as number) * z +
|
|
835
|
-
(world[12] as number) -
|
|
836
|
-
eye.x;
|
|
837
|
-
const dz =
|
|
838
|
-
(world[2] as number) * x +
|
|
839
|
-
(world[6] as number) * y +
|
|
840
|
-
(world[10] as number) * z +
|
|
841
|
-
(world[14] as number) -
|
|
842
|
-
eye.z;
|
|
843
|
-
const square = dx * dx + dz * dz;
|
|
844
|
-
if (square < 1600) coverNearEye++;
|
|
845
|
-
if (grass && square >= 10000 && square < 40000) coverFar++;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
// The far forest's drawn instances whose root is inside the camera's frustum.
|
|
850
|
-
farForestInView = 0;
|
|
851
|
-
if (farWorld && options.view() !== "player") {
|
|
852
|
-
const camera = options.camera();
|
|
853
|
-
camera.updateMatrixWorld(true);
|
|
854
|
-
farFrustum.setFromProjectionMatrix(
|
|
855
|
-
farMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse),
|
|
856
|
-
camera.coordinateSystem,
|
|
857
|
-
);
|
|
858
|
-
farWorld.traverse((node) => {
|
|
859
|
-
if (!(node instanceof InstancedMesh) || !node.visible || !node.layers.isEnabled(0)) return;
|
|
860
|
-
const local = node.instanceMatrix.array;
|
|
861
|
-
for (let i = 0; i < node.count; i++) {
|
|
862
|
-
farPoint
|
|
863
|
-
.set(
|
|
864
|
-
local[i * 16 + 12] as number,
|
|
865
|
-
local[i * 16 + 13] as number,
|
|
866
|
-
local[i * 16 + 14] as number,
|
|
867
|
-
)
|
|
868
|
-
.applyMatrix4(node.matrixWorld);
|
|
869
|
-
if (farFrustum.containsPoint(farPoint)) farForestInView++;
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
return {
|
|
876
|
-
step,
|
|
877
|
-
countProps,
|
|
878
|
-
facts: () => ({
|
|
879
|
-
travel,
|
|
880
|
-
straightTravel,
|
|
881
|
-
edgeOvershoot,
|
|
882
|
-
grounded: player.grounded,
|
|
883
|
-
propOverlapFrames,
|
|
884
|
-
swimming: player.swimming,
|
|
885
|
-
immersionDepth: player.immersionDepth,
|
|
886
|
-
swimSamples,
|
|
887
|
-
swimFloatSamples,
|
|
888
|
-
swimExits,
|
|
889
|
-
swimDrift,
|
|
890
|
-
contactSamples,
|
|
891
|
-
maxContactError,
|
|
892
|
-
bilinearDifference,
|
|
893
|
-
oceanSteps: options.ocean?.steps ?? 0,
|
|
894
|
-
waveSamples,
|
|
895
|
-
waveRange: waveSamples ? maxWave - minWave : 0,
|
|
896
|
-
sampleSlopeRange: waveSamples ? maxSlope - minSlope : 0,
|
|
897
|
-
propCounts,
|
|
898
|
-
coverNearEye,
|
|
899
|
-
coverFar,
|
|
900
|
-
farForestInView,
|
|
901
|
-
}),
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* What the reveal cost, measured from the frame it completes: batches published in view, shadows
|
|
907
|
-
* invalidated, impostors still pending, and every pipeline the device created since.
|
|
908
|
-
*
|
|
909
|
-
* One source counts the pipelines, picked at the reveal: three's census on its backend, else the
|
|
910
|
-
* owned engine's own compile count. The owned engine builds pipelines inside Wasm, where the census
|
|
911
|
-
* sees none and stays incomplete.
|
|
912
|
-
*/
|
|
913
|
-
export interface IRevealProbeOptions {
|
|
914
|
-
readonly camera: () => PerspectiveCamera;
|
|
915
|
-
readonly pipelineCensus: () =>
|
|
916
|
-
| { readonly complete: boolean; readonly counts: { readonly deviceCreations?: number } }
|
|
917
|
-
| undefined;
|
|
918
|
-
readonly engineCompiles: () => number | undefined;
|
|
919
|
-
/** True while a loading overlay covers the world: the reveal has not happened yet. */
|
|
920
|
-
readonly covered: () => boolean;
|
|
921
|
-
readonly phase: () => string;
|
|
922
|
-
readonly shadowNode: () => unknown;
|
|
923
|
-
/** Impostors still pending across every streamed world. */
|
|
924
|
-
readonly pendingImpostors: () => number;
|
|
925
|
-
readonly released: () => boolean;
|
|
926
|
-
readonly afterPhysics: (callback: () => void) => unknown;
|
|
927
|
-
readonly revealed: () => void;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
export interface IRevealProbe {
|
|
931
|
-
/** The loading screen reported its reveal: take the baseline this probe measures against. */
|
|
932
|
-
readonly initialize: () => void;
|
|
933
|
-
/** A props batch was published; count it when the reveal frustum holds it. */
|
|
934
|
-
readonly publishedBatch: (bounds: Box3) => void;
|
|
935
|
-
/** The measured numbers as plain data: the run report's `props.reveal` readout. */
|
|
936
|
-
readonly readout: () => Readonly<Record<string, number | string | boolean>>;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
export function createRevealProbe(options: IRevealProbeOptions): IRevealProbe {
|
|
940
|
-
const reveal = {
|
|
941
|
-
startedMs: -1,
|
|
942
|
-
elapsedMs: 0,
|
|
943
|
-
complete: false,
|
|
944
|
-
samples: 0,
|
|
945
|
-
publishedBatchesInView: -1,
|
|
946
|
-
shadowInvalidated: -1,
|
|
947
|
-
impostorPendingPeak: -1,
|
|
948
|
-
pipelinesCreated: -1,
|
|
949
|
-
pipelineCensusAvailable: false,
|
|
950
|
-
pipelineSource: "none",
|
|
951
|
-
// Device pipeline creations from the reveal to now, for the whole session: a walk and a
|
|
952
|
-
// camera turn must build none either (`playtests/loop.playtest.json`). -1: not measured.
|
|
953
|
-
pipelinesSinceReveal: -1,
|
|
954
|
-
};
|
|
955
|
-
let shadowAtReveal = -1;
|
|
956
|
-
let pipelinesAtReveal: number | undefined;
|
|
957
|
-
let pipelineSource: "census" | "engine" | undefined;
|
|
958
|
-
const frustum = new Frustum();
|
|
959
|
-
const matrix = new Matrix4();
|
|
960
|
-
const idle = (): boolean =>
|
|
961
|
-
options.released() || reveal.complete || reveal.startedMs < 0 || options.covered();
|
|
962
|
-
const shadows = (): { readonly stats: { readonly byInvalidation: number } } => {
|
|
963
|
-
const node = options.shadowNode();
|
|
964
|
-
if (!(node instanceof VirtualShadowNode))
|
|
965
|
-
throw new Error("Reveal probe requires virtual shadows");
|
|
966
|
-
return node;
|
|
967
|
-
};
|
|
968
|
-
const pipelineCount = (source: typeof pipelineSource): number | undefined => {
|
|
969
|
-
if (source === "census") {
|
|
970
|
-
const census = options.pipelineCensus();
|
|
971
|
-
return census?.complete === true ? census.counts.deviceCreations : undefined;
|
|
972
|
-
}
|
|
973
|
-
return source === "engine" ? options.engineCompiles() : undefined;
|
|
974
|
-
};
|
|
975
|
-
const initialize = (): void => {
|
|
976
|
-
if (options.released() || reveal.complete || reveal.startedMs >= 0) return;
|
|
977
|
-
if (options.covered() || options.phase() !== "ready")
|
|
978
|
-
throw new Error("Reveal probe requires ready props and an uncovered world");
|
|
979
|
-
const node = shadows();
|
|
980
|
-
pipelineSource = pipelineCount("census") !== undefined ? "census" : "engine";
|
|
981
|
-
reveal.startedMs = performance.now();
|
|
982
|
-
reveal.publishedBatchesInView = 0;
|
|
983
|
-
shadowAtReveal = node.stats.byInvalidation;
|
|
984
|
-
pipelinesAtReveal = pipelineCount(pipelineSource);
|
|
985
|
-
if (pipelinesAtReveal !== undefined) reveal.pipelineSource = pipelineSource;
|
|
986
|
-
const camera = options.camera();
|
|
987
|
-
camera.updateMatrixWorld(true);
|
|
988
|
-
frustum.setFromProjectionMatrix(
|
|
989
|
-
matrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse),
|
|
990
|
-
camera.coordinateSystem,
|
|
991
|
-
);
|
|
992
|
-
};
|
|
993
|
-
options.afterPhysics(() => {
|
|
994
|
-
if (idle() || options.phase() !== "ready") return;
|
|
995
|
-
const node = shadows();
|
|
996
|
-
const creations = pipelineCount(pipelineSource);
|
|
997
|
-
reveal.samples++;
|
|
998
|
-
reveal.elapsedMs = performance.now() - reveal.startedMs;
|
|
999
|
-
reveal.shadowInvalidated = node.stats.byInvalidation - shadowAtReveal;
|
|
1000
|
-
reveal.impostorPendingPeak = Math.max(reveal.impostorPendingPeak, options.pendingImpostors());
|
|
1001
|
-
reveal.pipelineCensusAvailable = creations !== undefined && pipelinesAtReveal !== undefined;
|
|
1002
|
-
if (creations !== undefined && pipelinesAtReveal !== undefined)
|
|
1003
|
-
reveal.pipelinesCreated = creations - pipelinesAtReveal;
|
|
1004
|
-
reveal.complete = reveal.elapsedMs >= 3000;
|
|
1005
|
-
if (reveal.complete) options.revealed();
|
|
1006
|
-
});
|
|
1007
|
-
options.afterPhysics(() => {
|
|
1008
|
-
if (options.released() || pipelinesAtReveal === undefined) return;
|
|
1009
|
-
const creations = pipelineCount(pipelineSource);
|
|
1010
|
-
reveal.pipelinesSinceReveal = creations === undefined ? -1 : creations - pipelinesAtReveal;
|
|
1011
|
-
});
|
|
1012
|
-
return {
|
|
1013
|
-
initialize,
|
|
1014
|
-
readout: () => ({ ...reveal }),
|
|
1015
|
-
publishedBatch: (bounds) => {
|
|
1016
|
-
if (reveal.startedMs < 0 || reveal.complete) return;
|
|
1017
|
-
if (frustum.intersectsBox(bounds)) reveal.publishedBatchesInView++;
|
|
1018
|
-
},
|
|
1019
|
-
};
|
|
1020
|
-
}
|