@drawcall/lod 0.3.0 → 0.4.0
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 +5 -8
- package/dist/bake.d.ts +16 -2
- package/dist/bake.js +92 -4
- package/dist/bake.js.map +1 -1
- package/dist/baked/index.d.ts +2 -2
- package/dist/baked/index.js +2 -2
- package/dist/baked/interior/faces.js +4 -2
- package/dist/baked/interior/faces.js.map +1 -1
- package/dist/baked/interior/material.js +1 -1
- package/dist/baked/interior/material.js.map +1 -1
- package/dist/baked/interior/rooms.d.ts +1 -1
- package/dist/baked/interior/rooms.js +1 -1
- package/dist/dispose.d.ts +3 -3
- package/dist/dispose.js +6 -6
- package/dist/dispose.js.map +1 -1
- package/dist/foliage.d.ts +32 -0
- package/dist/foliage.js +137 -0
- package/dist/foliage.js.map +1 -0
- package/dist/impostor/bake/index.d.ts +3 -3
- package/dist/impostor/bake/index.js +12 -3
- package/dist/impostor/bake/index.js.map +1 -1
- package/dist/impostor/bake/source.d.ts +2 -1
- package/dist/impostor/bake/source.js +2 -2
- package/dist/impostor/bake/source.js.map +1 -1
- package/dist/impostor/impostor.d.ts +1 -1
- package/dist/impostor/impostor.js +1 -1
- package/dist/impostor/ktx2/encode.js +5 -2
- package/dist/impostor/ktx2/encode.js.map +1 -1
- package/dist/impostor/ktx2/uastc.js +3 -2
- package/dist/impostor/ktx2/uastc.js.map +1 -1
- package/dist/impostor/ktx2/worker.js +0 -2
- package/dist/impostor/ktx2/worker.js.map +1 -1
- package/dist/impostor/mesh/card.d.ts +1 -1
- package/dist/impostor/mesh/index.d.ts +2 -2
- package/dist/impostor/mesh/index.js +3 -3
- package/dist/impostor/mesh/index.js.map +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/instanced/camera.d.ts +13 -25
- package/dist/instanced/camera.js +17 -42
- package/dist/instanced/camera.js.map +1 -1
- package/dist/instanced/clusters.d.ts +54 -0
- package/dist/instanced/clusters.js +151 -0
- package/dist/instanced/clusters.js.map +1 -0
- package/dist/instanced/cull.d.ts +3 -3
- package/dist/instanced/cull.js +2 -2
- package/dist/instanced/cull.js.map +1 -1
- package/dist/instanced/instances.d.ts +39 -0
- package/dist/instanced/instances.js +104 -0
- package/dist/instanced/instances.js.map +1 -0
- package/dist/instanced/key.d.ts +1 -1
- package/dist/instanced/key.js +1 -1
- package/dist/instanced/key.js.map +1 -1
- package/dist/instanced/levels.d.ts +9 -9
- package/dist/instanced/levels.js +7 -6
- package/dist/instanced/levels.js.map +1 -1
- package/dist/instanced/lists.d.ts +26 -39
- package/dist/instanced/lists.js +42 -61
- package/dist/instanced/lists.js.map +1 -1
- package/dist/instanced/measure.d.ts +2 -2
- package/dist/instanced/measure.js +2 -2
- package/dist/instanced/meshes.d.ts +11 -9
- package/dist/instanced/meshes.js +26 -16
- package/dist/instanced/meshes.js.map +1 -1
- package/dist/instanced/mirror.d.ts +16 -12
- package/dist/instanced/mirror.js +51 -12
- package/dist/instanced/mirror.js.map +1 -1
- package/dist/instanced/raycast.d.ts +6 -9
- package/dist/instanced/raycast.js +15 -18
- package/dist/instanced/raycast.js.map +1 -1
- package/dist/instanced/rows.d.ts +15 -73
- package/dist/instanced/rows.js +16 -189
- package/dist/instanced/rows.js.map +1 -1
- package/dist/instanced/shape.d.ts +3 -1
- package/dist/instanced/shape.js +6 -3
- package/dist/instanced/shape.js.map +1 -1
- package/dist/instanced/sort.d.ts +32 -34
- package/dist/instanced/sort.js +162 -132
- package/dist/instanced/sort.js.map +1 -1
- package/dist/instanced/update.d.ts +16 -12
- package/dist/instanced/update.js +57 -84
- package/dist/instanced/update.js.map +1 -1
- package/dist/levels/compile/index.d.ts +4 -2
- package/dist/levels/compile/index.js +10 -2
- package/dist/levels/compile/index.js.map +1 -1
- package/dist/levels/compile/pipelines.d.ts +1 -1
- package/dist/levels/compile/pipelines.js +1 -6
- package/dist/levels/compile/pipelines.js.map +1 -1
- package/dist/levels/draw.d.ts +1 -1
- package/dist/levels/draw.js +3 -3
- package/dist/levels/fade.d.ts +13 -22
- package/dist/levels/fade.js +17 -38
- package/dist/levels/fade.js.map +1 -1
- package/dist/levels/index.d.ts +7 -7
- package/dist/levels/index.js +1 -1
- package/dist/levels/item.d.ts +10 -10
- package/dist/levels/item.js +15 -23
- package/dist/levels/item.js.map +1 -1
- package/dist/levels/load.d.ts +1 -1
- package/dist/levels/load.js +5 -3
- package/dist/levels/load.js.map +1 -1
- package/dist/levels/manager.d.ts +30 -31
- package/dist/levels/manager.js +75 -62
- package/dist/levels/manager.js.map +1 -1
- package/dist/levels/material.d.ts +2 -2
- package/dist/levels/material.js +2 -2
- package/dist/levels/renderer.d.ts +8 -5
- package/dist/levels/renderer.js +20 -4
- package/dist/levels/renderer.js.map +1 -1
- package/dist/levels/requests.d.ts +4 -1
- package/dist/levels/requests.js +3 -1
- package/dist/levels/requests.js.map +1 -1
- package/dist/loader/context.d.ts +9 -11
- package/dist/loader/context.js +12 -7
- package/dist/loader/context.js.map +1 -1
- package/dist/loader/entry.d.ts +4 -0
- package/dist/loader/entry.js +43 -0
- package/dist/loader/entry.js.map +1 -0
- package/dist/loader/index.d.ts +49 -35
- package/dist/loader/index.js +123 -135
- package/dist/loader/index.js.map +1 -1
- package/dist/loader/level.js +5 -5
- package/dist/loader/level.js.map +1 -1
- package/dist/loader/node.d.ts +26 -0
- package/dist/loader/node.js +199 -0
- package/dist/loader/node.js.map +1 -0
- package/dist/loader/request.d.ts +11 -44
- package/dist/loader/request.js +7 -47
- package/dist/loader/request.js.map +1 -1
- package/dist/loader/url.d.ts +10 -9
- package/dist/loader/url.js +21 -17
- package/dist/loader/url.js.map +1 -1
- package/dist/lod.d.ts +122 -62
- package/dist/lod.js +331 -187
- package/dist/lod.js.map +1 -1
- package/dist/meshopt.d.ts +1 -1
- package/dist/meshopt.js +3 -2
- package/dist/meshopt.js.map +1 -1
- package/dist/node-process.d.ts +5 -0
- package/dist/node-process.js +6 -0
- package/dist/node-process.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +5 -0
- package/dist/node.js.map +1 -0
- package/dist/simplify/index.d.ts +2 -2
- package/dist/simplify/index.js +7 -7
- package/dist/simplify/index.js.map +1 -1
- package/dist/source/detail.d.ts +7 -2
- package/dist/source/detail.js +24 -22
- package/dist/source/detail.js.map +1 -1
- package/dist/source/sampler.js +5 -2
- package/dist/source/sampler.js.map +1 -1
- package/dist/three.d.ts +7 -7
- package/dist/three.js +4 -4
- package/dist/three.js.map +1 -1
- package/dist/wind/bounds.js +1 -1
- package/dist/wind/bounds.js.map +1 -1
- package/dist/wind/hooks.d.ts +1 -1
- package/dist/wind/hooks.js +1 -1
- package/dist/wind/index.d.ts +3 -3
- package/dist/wind/index.js +11 -9
- package/dist/wind/index.js.map +1 -1
- package/package.json +10 -6
- package/skills/lod/SKILL.md +65 -54
- package/dist/gpu.d.ts +0 -39
- package/dist/gpu.js +0 -41
- package/dist/gpu.js.map +0 -1
- package/dist/instanced/chunk.d.ts +0 -97
- package/dist/instanced/chunk.js +0 -156
- package/dist/instanced/chunk.js.map +0 -1
- package/dist/instanced/chunks.d.ts +0 -60
- package/dist/instanced/chunks.js +0 -208
- package/dist/instanced/chunks.js.map +0 -1
- package/dist/instanced/index.d.ts +0 -120
- package/dist/instanced/index.js +0 -290
- package/dist/instanced/index.js.map +0 -1
- package/dist/instanced/pages/buffers.d.ts +0 -37
- package/dist/instanced/pages/buffers.js +0 -15
- package/dist/instanced/pages/buffers.js.map +0 -1
- package/dist/instanced/pages/chunk.d.ts +0 -51
- package/dist/instanced/pages/chunk.js +0 -81
- package/dist/instanced/pages/chunk.js.map +0 -1
- package/dist/instanced/pages/index.d.ts +0 -74
- package/dist/instanced/pages/index.js +0 -269
- package/dist/instanced/pages/index.js.map +0 -1
- package/dist/instanced/pages/passes.d.ts +0 -21
- package/dist/instanced/pages/passes.js +0 -52
- package/dist/instanced/pages/passes.js.map +0 -1
- package/dist/instanced/pages/slots.d.ts +0 -11
- package/dist/instanced/pages/slots.js +0 -90
- package/dist/instanced/pages/slots.js.map +0 -1
- package/dist/instanced/pages/workgroup.d.ts +0 -14
- package/dist/instanced/pages/workgroup.js +0 -38
- package/dist/instanced/pages/workgroup.js.map +0 -1
- package/dist/levels/wait.d.ts +0 -27
- package/dist/levels/wait.js +0 -61
- package/dist/levels/wait.js.map +0 -1
- package/dist/loader/cache.d.ts +0 -12
- package/dist/loader/cache.js +0 -68
- package/dist/loader/cache.js.map +0 -1
- package/dist/loader/dependencies.d.ts +0 -32
- package/dist/loader/dependencies.js +0 -113
- package/dist/loader/dependencies.js.map +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Box3, Sphere, Vector3 } from "three/webgpu";
|
|
2
|
+
import { at } from "../at.js";
|
|
3
|
+
import { isBox3 } from "../three.js";
|
|
4
|
+
import { MAX_SURVIVOR_SCALE } from "./measure.js";
|
|
5
|
+
const area = { start: 0, size: 0, box: null, low: 0, high: 0 };
|
|
6
|
+
const grownBox = new Box3();
|
|
7
|
+
const measuredScratch = new Box3();
|
|
8
|
+
const size3 = new Vector3();
|
|
9
|
+
/**
|
|
10
|
+
* Call `visit` with each cluster of `lod` that holds instances, in one reused Area: its box grown by how far survivors
|
|
11
|
+
* of a cullDistance grow past it, by up to `grow`, about their origins.
|
|
12
|
+
*/
|
|
13
|
+
function forEachArea(lod, measured, shape, grow, visit) {
|
|
14
|
+
const { clusters, count } = lod;
|
|
15
|
+
const fallback = lod.boundingBox ?? (measured && measuredBox(measured, shape, measuredScratch));
|
|
16
|
+
const clusterOf = (start, size, box, minScale, maxScale) => {
|
|
17
|
+
if (size <= 0 || box?.isEmpty())
|
|
18
|
+
return;
|
|
19
|
+
area.start = start;
|
|
20
|
+
area.size = size;
|
|
21
|
+
area.low = minScale ?? measured?.minScale ?? 0;
|
|
22
|
+
area.high = maxScale ?? measured?.maxScale ?? (box && shape.extent > 0 ? box.getSize(size3).length() / shape.extent : Infinity);
|
|
23
|
+
area.box = box && grownBox.copy(box).expandByScalar(shape.originReach * area.high * (grow - 1));
|
|
24
|
+
visit(area);
|
|
25
|
+
};
|
|
26
|
+
if (!clusters)
|
|
27
|
+
return clusterOf(0, count, fallback);
|
|
28
|
+
for (const { start, count: size, boundingBox, minScale, maxScale } of clusters)
|
|
29
|
+
clusterOf(start, Math.min(size, count - start), boundingBox, minScale, maxScale);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Bound every cluster of `lod` into `bounds`, its survivors grown by up to `grow`: what the level meshes are culled and
|
|
33
|
+
* boxed by, which three's Box3.setFromObject reads. Unbounded instances give an infinite sphere and an empty box.
|
|
34
|
+
*/
|
|
35
|
+
export function boundClusters(lod, measured, shape, grow, bounds) {
|
|
36
|
+
let unbounded = false;
|
|
37
|
+
bounds.box.makeEmpty();
|
|
38
|
+
forEachArea(lod, measured, shape, grow, ({ box }) => {
|
|
39
|
+
if (box)
|
|
40
|
+
bounds.box.union(box);
|
|
41
|
+
else
|
|
42
|
+
unbounded = true;
|
|
43
|
+
});
|
|
44
|
+
if (unbounded)
|
|
45
|
+
bounds.sphere.set(bounds.sphere.center.set(0, 0, 0), Infinity);
|
|
46
|
+
else if (bounds.box.isEmpty())
|
|
47
|
+
bounds.sphere.makeEmpty();
|
|
48
|
+
else
|
|
49
|
+
bounds.box.getBoundingSphere(bounds.sphere);
|
|
50
|
+
}
|
|
51
|
+
/** What a camera sees of a Lod's instances (see `ClusterView.see`). */
|
|
52
|
+
export class ClusterView {
|
|
53
|
+
/** The ranges the camera sees, start and count, flat, clipped to `count`. */
|
|
54
|
+
ranges = [];
|
|
55
|
+
/** How many instances the ranges hold. */
|
|
56
|
+
instances = 0;
|
|
57
|
+
/** Whether every range seen lies wholly inside the camera's frustum. */
|
|
58
|
+
inside = true;
|
|
59
|
+
/** The heights the instances of every cluster within cullDistance can have, shortest and tallest: what loads. */
|
|
60
|
+
heights = [];
|
|
61
|
+
/** The same, of the clusters seen: what draws. */
|
|
62
|
+
seen = [];
|
|
63
|
+
/** Whether nothing bounds the instances: a storage instanceMatrix with neither clusters nor a boundingBox. */
|
|
64
|
+
unbounded = false;
|
|
65
|
+
/** See the instances of `lod` from `camera` through `frustum`, both in the Lod's space, thinned out by `cull`. */
|
|
66
|
+
see(lod, measured, shape, frustum, camera, cull) {
|
|
67
|
+
this.ranges.length = this.heights.length = this.seen.length = 0;
|
|
68
|
+
this.instances = 0;
|
|
69
|
+
this.inside = true;
|
|
70
|
+
this.unbounded = false;
|
|
71
|
+
const grow = cull?.survivors ? MAX_SURVIVOR_SCALE : 1;
|
|
72
|
+
forEachArea(lod, measured, shape, grow, ({ start, size, box, low, high }) => {
|
|
73
|
+
if (!box)
|
|
74
|
+
this.unbounded = true;
|
|
75
|
+
if (cull && box && box.distanceToPoint(cull.eye) >= cull.far)
|
|
76
|
+
return;
|
|
77
|
+
const heights = heightsIn(box, low, high * grow, shape, camera);
|
|
78
|
+
this.heights.push(heights);
|
|
79
|
+
if (box && !frustum.intersectsBox(box))
|
|
80
|
+
return;
|
|
81
|
+
this.seen.push(heights);
|
|
82
|
+
this.ranges.push(start, size);
|
|
83
|
+
this.instances += size;
|
|
84
|
+
this.inside &&= box !== null && inside(frustum, box);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** The box around `measured`'s instances at every level and its sway. */
|
|
89
|
+
export function measuredBox({ originBox, maxScale }, shape, into = new Box3()) {
|
|
90
|
+
if (originBox.isEmpty())
|
|
91
|
+
return into.makeEmpty();
|
|
92
|
+
return into.copy(originBox).expandByScalar(shape.originReach * maxScale);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The heights on `camera`'s screen that instances inside `box` (anywhere for none) scaled from `low` to `high` can have:
|
|
96
|
+
* the shortest at its farthest, the tallest at its nearest.
|
|
97
|
+
*/
|
|
98
|
+
function heightsIn(box, low, high, { source }, { eye, scale, ortho }) {
|
|
99
|
+
const diameter = 2 * source.radius * scale;
|
|
100
|
+
if (ortho)
|
|
101
|
+
return [diameter * low, diameter * high];
|
|
102
|
+
if (!box)
|
|
103
|
+
return [0, Infinity];
|
|
104
|
+
const near = Math.max(box.distanceToPoint(eye), 1e-6);
|
|
105
|
+
return [(diameter * low) / farthest(box, eye), (diameter * high) / near];
|
|
106
|
+
}
|
|
107
|
+
/** The distance from `point` to the farthest point of `box`. */
|
|
108
|
+
function farthest(box, point) {
|
|
109
|
+
const { min, max } = box;
|
|
110
|
+
return Math.hypot(Math.max(Math.abs(point.x - min.x), Math.abs(point.x - max.x)), Math.max(Math.abs(point.y - min.y), Math.abs(point.y - max.y)), Math.max(Math.abs(point.z - min.z), Math.abs(point.z - max.z)));
|
|
111
|
+
}
|
|
112
|
+
/** Whether `box` lies wholly inside `frustum`: its corner nearest each plane's outside lies inside. */
|
|
113
|
+
function inside(frustum, box) {
|
|
114
|
+
return frustum.planes.every(({ normal, constant }) => {
|
|
115
|
+
const x = normal.x > 0 ? box.min.x : box.max.x;
|
|
116
|
+
const y = normal.y > 0 ? box.min.y : box.max.y;
|
|
117
|
+
const z = normal.z > 0 ? box.min.z : box.max.z;
|
|
118
|
+
return normal.x * x + normal.y * y + normal.z * z + constant > 0;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Throws unless `clusters` are ranges of a Lod's `capacity` instances, disjoint, each with a box and its scales as
|
|
123
|
+
* `LodCluster` says. Disjointness is checked again only once a range changed: `last` holds the ranges last checked.
|
|
124
|
+
*/
|
|
125
|
+
export function checkClusters(clusters, capacity, last) {
|
|
126
|
+
let changed = last.length !== clusters.length * 2;
|
|
127
|
+
clusters.forEach(({ start, count, boundingBox, minScale, maxScale }, i) => {
|
|
128
|
+
if (!Number.isInteger(start) || !Number.isInteger(count) || start < 0 || count < 0 || start + count > capacity)
|
|
129
|
+
throw new RangeError(`Lod: cluster ${i}, ${count} instances from ${start}, passes the ${capacity} of its instanceMatrix`);
|
|
130
|
+
if (!isBox3(boundingBox))
|
|
131
|
+
throw new TypeError(`Lod: cluster ${i} has no boundingBox`);
|
|
132
|
+
if (minScale !== undefined && !(minScale >= 0 && Number.isFinite(minScale)))
|
|
133
|
+
throw new RangeError(`Lod: cluster ${i}'s minScale must be finite and >= 0, not ${minScale}`);
|
|
134
|
+
if (maxScale !== undefined && !(maxScale >= (minScale ?? 0) && Number.isFinite(maxScale)))
|
|
135
|
+
throw new RangeError(`Lod: cluster ${i}'s maxScale must be finite and >= its minScale, not ${maxScale}`);
|
|
136
|
+
if (last[2 * i] !== start || last[2 * i + 1] !== count)
|
|
137
|
+
changed = true;
|
|
138
|
+
});
|
|
139
|
+
if (!changed)
|
|
140
|
+
return;
|
|
141
|
+
last.length = 0;
|
|
142
|
+
for (const { start, count } of clusters)
|
|
143
|
+
last.push(start, count);
|
|
144
|
+
const sorted = [...clusters.keys()].filter((i) => at(clusters, i).count > 0).sort((a, b) => at(clusters, a).start - at(clusters, b).start);
|
|
145
|
+
for (let k = 1; k < sorted.length; k++) {
|
|
146
|
+
const [before, after] = [at(sorted, k - 1), at(sorted, k)];
|
|
147
|
+
if (at(clusters, before).start + at(clusters, before).count > at(clusters, after).start)
|
|
148
|
+
throw new RangeError(`Lod: clusters ${before} and ${after} overlap: clusters are disjoint`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=clusters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clusters.js","sourceRoot":"","sources":["../../src/instanced/clusters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAgB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA4BlD,MAAM,IAAI,GAAS,EAAE,KAAK,EAAE,CAAC,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AM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,KAAK;YACrF,MAAM,IAAI,UAAU,CAAC,iBAAiB,MAAM,QAAQ,KAAK,iCAAiC,CAAC,CAAC;IAChG,CAAC;AACH,CAAC"}
|
package/dist/instanced/cull.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Matrix4, Vector3, type Camera } from "three/webgpu";
|
|
2
2
|
/**
|
|
3
|
-
* How
|
|
3
|
+
* How a Lod thins its instances out with distance from `camera`, in every camera, as Fog does: every instance
|
|
4
4
|
* draws up to `near` from it, none from `far` on, and in between a share falling linearly, chosen by a hash of each
|
|
5
5
|
* instance's origin (its matrix's translation), the same on the CPU and the GPU. An instance whose translation changes
|
|
6
6
|
* rolls a new value: it may appear or vanish as it moves. With `scaleSurvivors`, the instances drawn grow by 1/√share,
|
|
@@ -12,7 +12,7 @@ export interface CullDistance {
|
|
|
12
12
|
far: number;
|
|
13
13
|
scaleSurvivors?: boolean;
|
|
14
14
|
}
|
|
15
|
-
/** cullDistance in the
|
|
15
|
+
/** cullDistance in the Lod's space. */
|
|
16
16
|
export interface Cull {
|
|
17
17
|
eye: Vector3;
|
|
18
18
|
near: number;
|
|
@@ -20,7 +20,7 @@ export interface Cull {
|
|
|
20
20
|
survivors: boolean;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* `cullDistance`, checked, in the space of `space`,
|
|
23
|
+
* `cullDistance`, checked, in the space of `space`, a Lod's world matrix, written into `target`; null for
|
|
24
24
|
* none. Nothing holds on to what it answers past a sort: the sort and its keys copy its values.
|
|
25
25
|
*/
|
|
26
26
|
export declare function cullIn(cullDistance: CullDistance | null, space: Matrix4, target: Cull): Cull | null;
|
package/dist/instanced/cull.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Matrix4, Vector3 } from "three/webgpu";
|
|
2
2
|
const inverse = new Matrix4();
|
|
3
3
|
/**
|
|
4
|
-
* `cullDistance`, checked, in the space of `space`,
|
|
4
|
+
* `cullDistance`, checked, in the space of `space`, a Lod's world matrix, written into `target`; null for
|
|
5
5
|
* none. Nothing holds on to what it answers past a sort: the sort and its keys copy its values.
|
|
6
6
|
*/
|
|
7
7
|
export function cullIn(cullDistance, space, target) {
|
|
@@ -9,7 +9,7 @@ export function cullIn(cullDistance, space, target) {
|
|
|
9
9
|
return null;
|
|
10
10
|
const { camera, near, far, scaleSurvivors = false } = cullDistance;
|
|
11
11
|
if (!(Number.isFinite(near) && Number.isFinite(far) && near >= 0 && far > near))
|
|
12
|
-
throw new RangeError(`
|
|
12
|
+
throw new RangeError(`Lod: cullDistance needs 0 <= near < far, both finite, got ${near} and ${far}`);
|
|
13
13
|
const scale = space.getMaxScaleOnAxis();
|
|
14
14
|
target.eye.setFromMatrixPosition(camera.matrixWorld).applyMatrix4(inverse.copy(space).invert());
|
|
15
15
|
target.near = near / scale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cull.js","sourceRoot":"","sources":["../../src/instanced/cull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AAwB7D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,YAAiC,EAAE,KAAc,EAAE,MAAY;IACpF,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,EAA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AC;IACzB,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2CAA2C;AAC3C,MAAM,CAAC,MAAM,SAAS,GAAG,GAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Box3, type InstancedBufferAttribute, type StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
|
+
/** A Lod's instancing data, as an InstancedMesh holds it. */
|
|
3
|
+
export interface InstanceAttributes {
|
|
4
|
+
readonly instanceMatrix: InstancedBufferAttribute;
|
|
5
|
+
readonly instanceColor: InstancedBufferAttribute | null;
|
|
6
|
+
readonly count: number;
|
|
7
|
+
}
|
|
8
|
+
/** Of a CPU instanceMatrix's first `count` instances at a scale above 0: their origins' box and scales. */
|
|
9
|
+
export interface Measured {
|
|
10
|
+
readonly originBox: Box3;
|
|
11
|
+
/** No matrix scales its longest axis less. */
|
|
12
|
+
minScale: number;
|
|
13
|
+
/** No matrix stretches any direction more. */
|
|
14
|
+
maxScale: number;
|
|
15
|
+
}
|
|
16
|
+
/** A Lod's instances as storage. */
|
|
17
|
+
export declare class Instances {
|
|
18
|
+
/** Bumped whenever what the storage holds, or how many instances there are, may have changed. */
|
|
19
|
+
version: number;
|
|
20
|
+
/** Measured from a CPU instanceMatrix as it changes; null for a storage one, which the CPU cannot read. */
|
|
21
|
+
measured: Measured | null;
|
|
22
|
+
private matrices;
|
|
23
|
+
private colors;
|
|
24
|
+
private count;
|
|
25
|
+
/** The matrices as the GPU reads them, once taken in. */
|
|
26
|
+
get matrixStorage(): StorageInstancedBufferAttribute;
|
|
27
|
+
/** The colours as the GPU reads them, RGB and a pad: white without. */
|
|
28
|
+
get colorStorage(): StorageInstancedBufferAttribute;
|
|
29
|
+
/**
|
|
30
|
+
* Take in `attributes` as they are: an attribute assigned anew, edits marked by `needsUpdate` (within their update
|
|
31
|
+
* ranges), a new count. A storage instanceMatrix, which the app's GPU passes may write any time, counts as changed
|
|
32
|
+
* at every update. Throws unless they can be drawn.
|
|
33
|
+
*/
|
|
34
|
+
refresh({ instanceMatrix, instanceColor, count }: InstanceAttributes): void;
|
|
35
|
+
/** Release the mirrors; the attributes are the app's. */
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
38
|
+
/** Measure the first `count` instances of `instanceMatrix` at a scale above 0 into `into`, or a new Measured. */
|
|
39
|
+
export declare function measure(instanceMatrix: InstancedBufferAttribute, count: number, into: Measured | null): Measured;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Box3, Matrix4, Vector3 } from "three/webgpu";
|
|
2
|
+
import { white } from "../levels/fade.js";
|
|
3
|
+
import { isStorageInstanced, stretch } from "../three.js";
|
|
4
|
+
import { ColorMirror, Mirror } from "./mirror.js";
|
|
5
|
+
const matrix = new Matrix4();
|
|
6
|
+
const origin = new Vector3();
|
|
7
|
+
/** A Lod's instances as storage. */
|
|
8
|
+
export class Instances {
|
|
9
|
+
/** Bumped whenever what the storage holds, or how many instances there are, may have changed. */
|
|
10
|
+
version = 0;
|
|
11
|
+
/** Measured from a CPU instanceMatrix as it changes; null for a storage one, which the CPU cannot read. */
|
|
12
|
+
measured = null;
|
|
13
|
+
matrices = null;
|
|
14
|
+
colors = null;
|
|
15
|
+
count = -1;
|
|
16
|
+
/** The matrices as the GPU reads them, once taken in. */
|
|
17
|
+
get matrixStorage() {
|
|
18
|
+
const found = this.matrices;
|
|
19
|
+
if (!found)
|
|
20
|
+
throw new Error("Lod: its instances are read before they were taken in");
|
|
21
|
+
return found.mirror?.attribute ?? storageOf(found.source);
|
|
22
|
+
}
|
|
23
|
+
/** The colours as the GPU reads them, RGB and a pad: white without. */
|
|
24
|
+
get colorStorage() {
|
|
25
|
+
const found = this.colors;
|
|
26
|
+
return found ? (found.mirror?.attribute ?? storageOf(found.source)) : white;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Take in `attributes` as they are: an attribute assigned anew, edits marked by `needsUpdate` (within their update
|
|
30
|
+
* ranges), a new count. A storage instanceMatrix, which the app's GPU passes may write any time, counts as changed
|
|
31
|
+
* at every update. Throws unless they can be drawn.
|
|
32
|
+
*/
|
|
33
|
+
refresh({ instanceMatrix, instanceColor, count }) {
|
|
34
|
+
check(instanceMatrix, instanceColor, count);
|
|
35
|
+
let replaced = false;
|
|
36
|
+
if (this.matrices?.source !== instanceMatrix) {
|
|
37
|
+
this.matrices?.mirror?.dispose();
|
|
38
|
+
this.matrices = { source: instanceMatrix, mirror: isStorageInstanced(instanceMatrix) ? null : new Mirror(instanceMatrix) };
|
|
39
|
+
this.measured = null;
|
|
40
|
+
replaced = true;
|
|
41
|
+
}
|
|
42
|
+
if (this.colors?.source !== (instanceColor ?? undefined)) {
|
|
43
|
+
this.colors?.mirror?.dispose();
|
|
44
|
+
this.colors = instanceColor && { source: instanceColor, mirror: isStorageInstanced(instanceColor) ? null : new ColorMirror(instanceColor) };
|
|
45
|
+
replaced = true;
|
|
46
|
+
}
|
|
47
|
+
const { mirror } = this.matrices;
|
|
48
|
+
const moved = mirror ? mirror.refresh() : true;
|
|
49
|
+
const recoloured = this.colors?.mirror?.refresh() ?? false;
|
|
50
|
+
if (mirror && (moved || replaced || count !== this.count || !this.measured))
|
|
51
|
+
this.measured = measure(instanceMatrix, count, this.measured);
|
|
52
|
+
if (replaced || moved || recoloured || count !== this.count)
|
|
53
|
+
this.version++;
|
|
54
|
+
this.count = count;
|
|
55
|
+
}
|
|
56
|
+
/** Release the mirrors; the attributes are the app's. */
|
|
57
|
+
dispose() {
|
|
58
|
+
this.matrices?.mirror?.dispose();
|
|
59
|
+
this.colors?.mirror?.dispose();
|
|
60
|
+
this.matrices = null;
|
|
61
|
+
this.colors = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** `attribute`, which `refresh` found a storage attribute. */
|
|
65
|
+
function storageOf(attribute) {
|
|
66
|
+
if (!isStorageInstanced(attribute))
|
|
67
|
+
throw new TypeError("Lod: an attribute read in place is not a storage attribute");
|
|
68
|
+
return attribute;
|
|
69
|
+
}
|
|
70
|
+
/** Throws unless the attributes hold `count` instances as an InstancedMesh's do; a storage colour pads RGB to four floats. */
|
|
71
|
+
function check(instanceMatrix, instanceColor, count) {
|
|
72
|
+
if (instanceMatrix.itemSize !== 16 || !(instanceMatrix.array instanceof Float32Array) || instanceMatrix.normalized)
|
|
73
|
+
throw new TypeError(`Lod: instanceMatrix holds 16 floats per instance, not ${instanceMatrix.itemSize}${instanceMatrix.normalized ? " normalized" : ""}`);
|
|
74
|
+
if (!Number.isInteger(count) || count < 0 || count > instanceMatrix.count)
|
|
75
|
+
throw new RangeError(`Lod: count must be an integer from 0 to instanceMatrix.count, ${instanceMatrix.count}, not ${count}`);
|
|
76
|
+
if (!instanceColor)
|
|
77
|
+
return;
|
|
78
|
+
const size = isStorageInstanced(instanceColor) ? 4 : 3;
|
|
79
|
+
if (instanceColor.itemSize !== size || !(instanceColor.array instanceof Float32Array) || instanceColor.normalized)
|
|
80
|
+
throw new TypeError(`Lod: instanceColor holds ${size} floats per instance${size === 4 ? " in storage" : ""}, not ${instanceColor.itemSize}`);
|
|
81
|
+
if (instanceColor.count < count)
|
|
82
|
+
throw new RangeError(`Lod: instanceColor holds ${instanceColor.count} instances, fewer than count, ${count}`);
|
|
83
|
+
}
|
|
84
|
+
/** Measure the first `count` instances of `instanceMatrix` at a scale above 0 into `into`, or a new Measured. */
|
|
85
|
+
export function measure(instanceMatrix, count, into) {
|
|
86
|
+
const measured = into ?? { originBox: new Box3(), minScale: 0, maxScale: 0 };
|
|
87
|
+
const { array } = instanceMatrix;
|
|
88
|
+
measured.originBox.makeEmpty();
|
|
89
|
+
measured.minScale = Infinity;
|
|
90
|
+
measured.maxScale = 0;
|
|
91
|
+
for (let i = 0; i < count; i++) {
|
|
92
|
+
matrix.fromArray(array, i * 16);
|
|
93
|
+
const scale = matrix.getMaxScaleOnAxis();
|
|
94
|
+
if (scale === 0)
|
|
95
|
+
continue;
|
|
96
|
+
measured.originBox.expandByPoint(origin.setFromMatrixPosition(matrix));
|
|
97
|
+
measured.minScale = Math.min(measured.minScale, scale);
|
|
98
|
+
measured.maxScale = Math.max(measured.maxScale, stretch(matrix));
|
|
99
|
+
}
|
|
100
|
+
if (measured.originBox.isEmpty())
|
|
101
|
+
measured.minScale = measured.maxScale = 0;
|
|
102
|
+
return measured;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../../src/instanced/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAuE,MAAM,cAAc,CAAC;AAC3H,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAqBlD,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;AAC7B,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;AAE7B,oCAAoC;AACpC,MAAM,OAAO,SAAS;IACpB,iGAAiG;IACjG,OAAO,GAAG,CAAC,CAAC;IACZ,2GAA2G;IAC3G,QAAQ,GAAoB,IAAI,CAAC;IACzB,QAAQ,GAAyF,IAAI,CAAC;IACtG,MAAM,GAA8F,IAAI,CAAC;IACzG,KAAK,GAAG,CAAC,CAAC,CAAC;IAEnB,yDAAyD;IACzD,IAAI,aAAa;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5B,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,uDAAu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,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC7E,MAAM,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACzC,IAAI,KAAK,KAAK,CAAC;YAAE,SAAS;QAC1B,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;QACvE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvD,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/instanced/key.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class Key {
|
|
|
12
12
|
put(value: number): this;
|
|
13
13
|
/** Whether the values written since start differ from the last ones. */
|
|
14
14
|
end(): boolean;
|
|
15
|
-
/** A camera's inputs, everything in the
|
|
15
|
+
/** A camera's inputs, everything in the Lod's space: what sorting for it reads. */
|
|
16
16
|
camera(eye: Vector3, scale: number, ortho: boolean, levels: d.Infer<typeof DrawLevels>, cull: Cull | null, source: Sphere): this;
|
|
17
17
|
/** A camera's inputs but where it looks from: all an orthographic camera measures heights by. */
|
|
18
18
|
screen(scale: number, ortho: boolean, levels: d.Infer<typeof DrawLevels>, cull: Cull | null, source: Sphere): this;
|
package/dist/instanced/key.js
CHANGED
|
@@ -26,7 +26,7 @@ export class Key {
|
|
|
26
26
|
}
|
|
27
27
|
return this.changed;
|
|
28
28
|
}
|
|
29
|
-
/** A camera's inputs, everything in the
|
|
29
|
+
/** A camera's inputs, everything in the Lod's space: what sorting for it reads. */
|
|
30
30
|
camera(eye, scale, ortho, levels, cull, source) {
|
|
31
31
|
return this.put(eye.x).put(eye.y).put(eye.z).screen(scale, ortho, levels, cull, source);
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../src/instanced/key.ts"],"names":[],"mappings":"AAKA,uGAAuG;AAEvG,oHAAoH;AACpH,MAAM,OAAO,GAAG;IACG,MAAM,GAAa,EAAE,CAAC;IAC/B,MAAM,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,KAAK,CAAC;IAExB,sCAAsC;IACtC,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,KAAa;QACf,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;YACjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,wEAAwE;IACxE,GAAG;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,MAA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,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChG,CAAC;CACF"}
|
|
@@ -5,32 +5,32 @@ import type { PreparedLevel } from "../levels/manager.js";
|
|
|
5
5
|
import type { InstanceLists } from "./lists.js";
|
|
6
6
|
import { type Part } from "./meshes.js";
|
|
7
7
|
import type { InstanceShape } from "./shape.js";
|
|
8
|
-
/** What
|
|
8
|
+
/** What a Lod's level meshes draw with: its shape, lists and the instances they draw. */
|
|
9
9
|
export interface Drawing {
|
|
10
10
|
readonly shape: InstanceShape;
|
|
11
11
|
readonly lists: InstanceLists;
|
|
12
|
-
/** What the level meshes draw: the
|
|
12
|
+
/** What the level meshes draw: the Lod's instances, or while survivors scale, their scaled matrices. */
|
|
13
13
|
readonly drawn: DrawnInstances;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* A Lod's level meshes: per level, the meshes drawing it with its debug tint, made from the level's object once there
|
|
17
|
+
* is one and added to the Lod, and the source level's parts, which a raycast hits.
|
|
18
18
|
*/
|
|
19
19
|
export declare class MeshesByLevel {
|
|
20
|
-
/** The
|
|
20
|
+
/** The Lod, which holds the meshes. */
|
|
21
21
|
private readonly parent;
|
|
22
22
|
/** Its levels: a level that joins gets its object. */
|
|
23
23
|
private readonly levels;
|
|
24
24
|
private readonly drawing;
|
|
25
25
|
/** Around every instance, survivors grown: what every level mesh is culled and boxed by. */
|
|
26
26
|
private readonly bounds;
|
|
27
|
-
/** Sorts `camera`'s lists as a mesh
|
|
27
|
+
/** Sorts `camera`'s lists as `renderer` draws a mesh for it. */
|
|
28
28
|
private readonly drawFor;
|
|
29
29
|
private readonly tints;
|
|
30
30
|
private readonly byLevel;
|
|
31
31
|
private sourceParts;
|
|
32
32
|
constructor(
|
|
33
|
-
/** The
|
|
33
|
+
/** The Lod, which holds the meshes. */
|
|
34
34
|
parent: Object3D,
|
|
35
35
|
/** Its levels: a level that joins gets its object. */
|
|
36
36
|
levels: readonly ThresholdedLevel[], drawing: Drawing,
|
|
@@ -39,7 +39,7 @@ export declare class MeshesByLevel {
|
|
|
39
39
|
readonly sphere: Sphere;
|
|
40
40
|
readonly box: Box3;
|
|
41
41
|
},
|
|
42
|
-
/** Sorts `camera`'s lists as a mesh
|
|
42
|
+
/** Sorts `camera`'s lists as `renderer` draws a mesh for it. */
|
|
43
43
|
drawFor: (renderer: unknown, camera: Camera) => void);
|
|
44
44
|
/** The source level's parts, which a raycast hits. */
|
|
45
45
|
get source(): readonly Part[];
|
|
@@ -55,6 +55,6 @@ export declare class MeshesByLevel {
|
|
|
55
55
|
private meshesOf;
|
|
56
56
|
/** Level meshes of `loaded`, level `index`'s object, staged for wind and compiling. */
|
|
57
57
|
prepare(index: number, loaded: Object3D): PreparedLevel;
|
|
58
|
-
/** Take every mesh out of the
|
|
58
|
+
/** Take every mesh out of the Lod and free it. */
|
|
59
59
|
dispose(): void;
|
|
60
60
|
}
|
package/dist/instanced/levels.js
CHANGED
|
@@ -7,8 +7,8 @@ import { has } from "../levels/draw.js";
|
|
|
7
7
|
import { refreshWind } from "../wind/index.js";
|
|
8
8
|
import { freeMesh, levelMeshes, partsOf } from "./meshes.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* A Lod's level meshes: per level, the meshes drawing it with its debug tint, made from the level's object once there
|
|
11
|
+
* is one and added to the Lod, and the source level's parts, which a raycast hits.
|
|
12
12
|
*/
|
|
13
13
|
export class MeshesByLevel {
|
|
14
14
|
parent;
|
|
@@ -20,13 +20,13 @@ export class MeshesByLevel {
|
|
|
20
20
|
byLevel = [];
|
|
21
21
|
sourceParts = [];
|
|
22
22
|
constructor(
|
|
23
|
-
/** The
|
|
23
|
+
/** The Lod, which holds the meshes. */
|
|
24
24
|
parent,
|
|
25
25
|
/** Its levels: a level that joins gets its object. */
|
|
26
26
|
levels, drawing,
|
|
27
27
|
/** Around every instance, survivors grown: what every level mesh is culled and boxed by. */
|
|
28
28
|
bounds,
|
|
29
|
-
/** Sorts `camera`'s lists as a mesh
|
|
29
|
+
/** Sorts `camera`'s lists as `renderer` draws a mesh for it. */
|
|
30
30
|
drawFor) {
|
|
31
31
|
this.parent = parent;
|
|
32
32
|
this.levels = levels;
|
|
@@ -77,9 +77,10 @@ export class MeshesByLevel {
|
|
|
77
77
|
box: this.bounds.box,
|
|
78
78
|
slots: (camera) => lists.slots(camera),
|
|
79
79
|
radius: shape.fadeRadius,
|
|
80
|
+
layers: this.parent.layers,
|
|
80
81
|
drawFor: (renderer, camera) => {
|
|
81
82
|
this.drawFor(renderer, camera);
|
|
82
|
-
return lists.slots(camera)
|
|
83
|
+
return lists.slots(camera)?.args ?? null;
|
|
83
84
|
},
|
|
84
85
|
});
|
|
85
86
|
}
|
|
@@ -113,7 +114,7 @@ export class MeshesByLevel {
|
|
|
113
114
|
},
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
|
-
/** Take every mesh out of the
|
|
117
|
+
/** Take every mesh out of the Lod and free it. */
|
|
117
118
|
dispose() {
|
|
118
119
|
for (const mesh of this.byLevel.flat()) {
|
|
119
120
|
mesh.removeFromParent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"levels.js","sourceRoot":"","sources":["../../src/instanced/levels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkD,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAyB,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,GAAG,E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CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,gFAAgF;AAChF,SAAS,QAAQ,CAAC,KAAoB,EAAE,IAAiB;IACvD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -1,64 +1,51 @@
|
|
|
1
|
-
import { Frustum, Matrix4, type
|
|
1
|
+
import { Frustum, Matrix4, type Camera, type Renderer, type StorageInstancedBufferAttribute } from "three/webgpu";
|
|
2
2
|
import type { InstanceSlots } from "../levels/fade.js";
|
|
3
3
|
import { type LodLevel } from "../levels/index.js";
|
|
4
4
|
import { Key } from "./key.js";
|
|
5
|
-
import type
|
|
5
|
+
import { type RowValues } from "./sort.js";
|
|
6
6
|
import type { IndirectDraw } from "./rows.js";
|
|
7
|
-
/** What one camera's sort reads besides its lists, everything in the
|
|
7
|
+
/** What one camera's sort reads besides its lists, everything in the Lod's space. */
|
|
8
8
|
export interface SortInputs extends Omit<RowValues, "frustum"> {
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/** The instances the camera sees, as start and count, flat (see clusters.ts), and how many in all. */
|
|
10
|
+
ranges: readonly number[];
|
|
11
|
+
instances: number;
|
|
12
|
+
/** Whether every range it sees lies wholly inside its frustum. */
|
|
13
|
+
inside: boolean;
|
|
13
14
|
/**
|
|
14
|
-
* The bit of the one level each instance draws, without a fade, at any height its
|
|
15
|
+
* The bit of the one level each instance draws, without a fade, at any height its range's instances can have, with
|
|
15
16
|
* no cullDistance and no arrival under way; else 0. Inside the camera's frustum, its lists then hold every instance
|
|
16
17
|
* at that level however the camera moves.
|
|
17
18
|
*/
|
|
18
19
|
onlyLevel: number;
|
|
19
|
-
/** Bumped whenever
|
|
20
|
-
|
|
20
|
+
/** Bumped whenever what the instances' storage holds changed. */
|
|
21
|
+
version: number;
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
-
* One camera's lists: what it last sorted with, which a sort is skipped for, and the levels it wants loaded with what
|
|
24
|
-
* they were worked out from.
|
|
25
|
-
*/
|
|
23
|
+
/** One camera's lists: what it last sorted with, which a sort is skipped for. */
|
|
26
24
|
export interface CameraLists {
|
|
27
|
-
/** The camera's frustum in the
|
|
25
|
+
/** The camera's frustum in the Lod's space, as its last update found it (see `frustumIn`). */
|
|
28
26
|
readonly frustum: Frustum;
|
|
29
27
|
/** Whether a sort was written for the camera: until then the level meshes draw nothing for it. */
|
|
30
28
|
written: boolean;
|
|
31
|
-
sortKey: Key;
|
|
32
|
-
heightsKey: Key;
|
|
33
|
-
/** The heights its chunks' instances can have on the camera's screen (see `ChunkSet.heights`), for heightsKey's inputs. */
|
|
34
|
-
heights: [shortest: number, tallest: number][];
|
|
35
|
-
/** How often `heights` was worked out: what shownKey reads of them. */
|
|
36
|
-
heightsVersion: number;
|
|
37
|
-
/** The levels the camera needs loaded, as a mask, for `heights`. */
|
|
38
|
-
wanted: number;
|
|
39
|
-
shownKey: Key;
|
|
40
|
-
/** The levels whose meshes draw for the camera, as a mask, for `heights` and what shownKey holds. */
|
|
41
|
-
shown: number;
|
|
42
|
-
/** The bit of the one level that every chunk's heights draw, without a fade, while no arrival is under way; else 0. */
|
|
43
|
-
onlyLevel: number;
|
|
29
|
+
readonly sortKey: Key;
|
|
44
30
|
}
|
|
45
|
-
/** The lists of every camera drawing one
|
|
31
|
+
/** The lists of every camera drawing one Lod, and the sorts filling them. */
|
|
46
32
|
export declare class InstanceLists {
|
|
47
|
-
private readonly sorter;
|
|
48
33
|
private readonly cameras;
|
|
49
|
-
readonly
|
|
50
|
-
/** `listed` tells per level whether it has an instance list: whether it draws something
|
|
51
|
-
constructor(
|
|
34
|
+
private readonly sorter;
|
|
35
|
+
/** `listed` tells per level whether it has an instance list: whether it draws something. */
|
|
36
|
+
constructor(listed: readonly boolean[]);
|
|
52
37
|
/** `camera`'s lists, made the first time it asks. */
|
|
53
38
|
of(camera: Camera): CameraLists;
|
|
54
|
-
/** Where `camera`'s lists and indirect draws lie. */
|
|
55
|
-
slots(camera: Camera): InstanceSlots;
|
|
39
|
+
/** Where `camera`'s lists and indirect draws lie; null before a sort was written for it. */
|
|
40
|
+
slots(camera: Camera): InstanceSlots | null;
|
|
56
41
|
/** Every camera draws `draws` too, after the draws it has; where they start. */
|
|
57
42
|
appendDraws(draws: readonly IndirectDraw[]): number;
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
/** Sort
|
|
61
|
-
|
|
43
|
+
/** Survivors' scaled matrices for `capacity` instances. */
|
|
44
|
+
scaledMatrices(capacity: number): StorageInstancedBufferAttribute;
|
|
45
|
+
/** Sort for `camera` at its next draw, unless nothing it sorts by changed since its last sort; `limit` bounds its buffers. */
|
|
46
|
+
sort(camera: Camera, sort: SortInputs, limit: number): void;
|
|
47
|
+
/** Sort for `camera` on `renderer`, reading `matrices`, if due: before a level mesh draws for it. */
|
|
48
|
+
drawFor(renderer: Renderer, camera: Camera, matrices: StorageInstancedBufferAttribute): void;
|
|
62
49
|
/** Give back the lists of every camera other than `camera` that `rendering` says stopped drawing, as a clone made for one frame does. */
|
|
63
50
|
prune(camera: Camera, rendering: (camera: Camera) => boolean): void;
|
|
64
51
|
dispose(): void;
|