@drawcall/lod 0.1.2 → 0.3.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 +13 -70
- package/dist/at.d.ts +2 -0
- package/dist/at.js +8 -0
- package/dist/at.js.map +1 -0
- package/dist/bake.d.ts +22 -0
- package/dist/bake.js +88 -0
- package/dist/bake.js.map +1 -0
- package/dist/baked/codec.d.ts +5 -5
- package/dist/baked/codec.js +58 -158
- package/dist/baked/codec.js.map +1 -1
- package/dist/baked/coverage.d.ts +6 -3
- package/dist/baked/coverage.js +6 -3
- package/dist/baked/coverage.js.map +1 -1
- package/dist/baked/fields.d.ts +9 -0
- package/dist/baked/fields.js +22 -0
- package/dist/baked/fields.js.map +1 -0
- package/dist/baked/index.d.ts +16 -6
- package/dist/baked/index.js +23 -21
- package/dist/baked/index.js.map +1 -1
- package/dist/baked/interior/faces.d.ts +4 -3
- package/dist/baked/interior/faces.js +13 -10
- package/dist/baked/interior/faces.js.map +1 -1
- package/dist/baked/interior/material.d.ts +7 -10
- package/dist/baked/interior/material.js +29 -36
- package/dist/baked/interior/material.js.map +1 -1
- package/dist/baked/interior/rooms.js +1 -1
- package/dist/baked/interior/rooms.js.map +1 -1
- package/dist/baked/low.d.ts +2 -2
- package/dist/baked/low.js +9 -8
- package/dist/baked/low.js.map +1 -1
- package/dist/baked/raster.js +6 -6
- package/dist/baked/raster.js.map +1 -1
- package/dist/baked/textures.d.ts +17 -0
- package/dist/baked/textures.js +95 -0
- package/dist/baked/textures.js.map +1 -0
- package/dist/baked/transfer.js +19 -18
- package/dist/baked/transfer.js.map +1 -1
- package/dist/baked/unwrap.js +4 -3
- package/dist/baked/unwrap.js.map +1 -1
- package/dist/baked/xatlas.js.map +1 -1
- package/dist/codec/container.d.ts +8 -0
- package/dist/codec/container.js +63 -0
- package/dist/codec/container.js.map +1 -0
- package/dist/codec/mesh.d.ts +8 -0
- package/dist/codec/mesh.js +220 -0
- package/dist/codec/mesh.js.map +1 -0
- package/dist/dispose.d.ts +11 -4
- package/dist/dispose.js +39 -12
- package/dist/dispose.js.map +1 -1
- package/dist/gpu.d.ts +39 -0
- package/dist/gpu.js +41 -0
- package/dist/gpu.js.map +1 -0
- package/dist/impostor/bake/atlas.d.ts +4 -4
- package/dist/impostor/bake/atlas.js +12 -12
- package/dist/impostor/bake/atlas.js.map +1 -1
- package/dist/impostor/bake/fit.d.ts +8 -0
- package/dist/impostor/bake/fit.js +28 -0
- package/dist/impostor/bake/fit.js.map +1 -0
- package/dist/impostor/bake/index.d.ts +23 -14
- package/dist/impostor/bake/index.js +42 -134
- package/dist/impostor/bake/index.js.map +1 -1
- package/dist/impostor/bake/materials.d.ts +3 -3
- package/dist/impostor/bake/materials.js +60 -12
- package/dist/impostor/bake/materials.js.map +1 -1
- package/dist/impostor/bake/sheet.d.ts +8 -0
- package/dist/impostor/bake/sheet.js +90 -0
- package/dist/impostor/bake/sheet.js.map +1 -0
- package/dist/impostor/bake/source.d.ts +2 -2
- package/dist/impostor/bake/source.js +8 -19
- package/dist/impostor/bake/source.js.map +1 -1
- package/dist/impostor/codec.d.ts +5 -11
- package/dist/impostor/codec.js +37 -121
- package/dist/impostor/codec.js.map +1 -1
- package/dist/impostor/impostor.d.ts +31 -7
- package/dist/impostor/impostor.js +21 -6
- package/dist/impostor/impostor.js.map +1 -1
- package/dist/impostor/ktx2/encode.d.ts +26 -0
- package/dist/impostor/ktx2/encode.js +117 -0
- package/dist/impostor/ktx2/encode.js.map +1 -0
- package/dist/impostor/ktx2/transcode.d.ts +3 -0
- package/dist/impostor/ktx2/transcode.js +99 -0
- package/dist/impostor/ktx2/transcode.js.map +1 -0
- package/dist/impostor/ktx2/uastc.d.ts +7 -0
- package/dist/impostor/ktx2/uastc.js +64 -0
- package/dist/impostor/ktx2/uastc.js.map +1 -0
- package/dist/impostor/ktx2/wasm/encoder.d.ts +4 -0
- package/dist/impostor/ktx2/wasm/encoder.js +10 -0
- package/dist/impostor/ktx2/wasm/encoder.js.map +1 -0
- package/dist/impostor/ktx2/wasm/transcoder.d.ts +3 -0
- package/dist/impostor/ktx2/wasm/transcoder.js +9 -0
- package/dist/impostor/ktx2/wasm/transcoder.js.map +1 -0
- package/dist/impostor/ktx2/worker.d.ts +1 -0
- package/dist/impostor/ktx2/worker.js +12 -0
- package/dist/impostor/ktx2/worker.js.map +1 -0
- package/dist/impostor/mesh/card.d.ts +3 -3
- package/dist/impostor/mesh/card.js +11 -8
- package/dist/impostor/mesh/card.js.map +1 -1
- package/dist/impostor/mesh/index.d.ts +10 -7
- package/dist/impostor/mesh/index.js +15 -18
- package/dist/impostor/mesh/index.js.map +1 -1
- package/dist/impostor/mesh/material.d.ts +24 -13
- package/dist/impostor/mesh/material.js +67 -51
- package/dist/impostor/mesh/material.js.map +1 -1
- package/dist/impostor/mesh/surface.d.ts +20 -16
- package/dist/impostor/mesh/surface.js +81 -58
- package/dist/impostor/mesh/surface.js.map +1 -1
- package/dist/impostor/mesh/textures.d.ts +3 -3
- package/dist/impostor/mesh/textures.js +24 -34
- package/dist/impostor/mesh/textures.js.map +1 -1
- package/dist/impostor/octahedral.d.ts +1 -8
- package/dist/impostor/octahedral.js +3 -18
- package/dist/impostor/octahedral.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/instanced/camera.d.ts +46 -0
- package/dist/instanced/camera.js +70 -0
- package/dist/instanced/camera.js.map +1 -0
- package/dist/instanced/chunk.d.ts +97 -0
- package/dist/instanced/chunk.js +156 -0
- package/dist/instanced/chunk.js.map +1 -0
- package/dist/instanced/chunks.d.ts +60 -0
- package/dist/instanced/chunks.js +208 -0
- package/dist/instanced/chunks.js.map +1 -0
- package/dist/instanced/cull.d.ts +28 -0
- package/dist/instanced/cull.js +22 -0
- package/dist/instanced/cull.js.map +1 -0
- package/dist/instanced/index.d.ts +96 -92
- package/dist/instanced/index.js +229 -512
- package/dist/instanced/index.js.map +1 -1
- package/dist/instanced/key.d.ts +19 -0
- package/dist/instanced/key.js +45 -0
- package/dist/instanced/key.js.map +1 -0
- package/dist/instanced/levels.d.ts +60 -0
- package/dist/instanced/levels.js +130 -0
- package/dist/instanced/levels.js.map +1 -0
- package/dist/instanced/lists.d.ts +70 -0
- package/dist/instanced/lists.js +133 -0
- package/dist/instanced/lists.js.map +1 -0
- package/dist/instanced/measure.d.ts +28 -0
- package/dist/instanced/measure.js +203 -0
- package/dist/instanced/measure.js.map +1 -0
- package/dist/instanced/meshes.d.ts +46 -14
- package/dist/instanced/meshes.js +137 -22
- package/dist/instanced/meshes.js.map +1 -1
- package/dist/instanced/mirror.d.ts +20 -0
- package/dist/instanced/mirror.js +37 -0
- package/dist/instanced/mirror.js.map +1 -0
- package/dist/instanced/pages/buffers.d.ts +37 -0
- package/dist/instanced/pages/buffers.js +15 -0
- package/dist/instanced/pages/buffers.js.map +1 -0
- package/dist/instanced/pages/chunk.d.ts +51 -0
- package/dist/instanced/pages/chunk.js +81 -0
- package/dist/instanced/pages/chunk.js.map +1 -0
- package/dist/instanced/pages/index.d.ts +74 -0
- package/dist/instanced/pages/index.js +269 -0
- package/dist/instanced/pages/index.js.map +1 -0
- package/dist/instanced/pages/passes.d.ts +21 -0
- package/dist/instanced/pages/passes.js +52 -0
- package/dist/instanced/pages/passes.js.map +1 -0
- package/dist/instanced/pages/slots.d.ts +11 -0
- package/dist/instanced/pages/slots.js +90 -0
- package/dist/instanced/pages/slots.js.map +1 -0
- package/dist/instanced/pages/workgroup.d.ts +14 -0
- package/dist/instanced/pages/workgroup.js +38 -0
- package/dist/instanced/pages/workgroup.js.map +1 -0
- package/dist/instanced/raycast.d.ts +15 -0
- package/dist/instanced/raycast.js +46 -0
- package/dist/instanced/raycast.js.map +1 -0
- package/dist/instanced/rows.d.ts +108 -0
- package/dist/instanced/rows.js +209 -0
- package/dist/instanced/rows.js.map +1 -0
- package/dist/instanced/shape.d.ts +25 -0
- package/dist/instanced/shape.js +51 -0
- package/dist/instanced/shape.js.map +1 -0
- package/dist/instanced/sort.d.ts +63 -0
- package/dist/instanced/sort.js +162 -0
- package/dist/instanced/sort.js.map +1 -0
- package/dist/instanced/update.d.ts +30 -0
- package/dist/instanced/update.js +207 -0
- package/dist/instanced/update.js.map +1 -0
- package/dist/levels/bounds.d.ts +21 -0
- package/dist/levels/bounds.js +42 -0
- package/dist/levels/bounds.js.map +1 -0
- package/dist/levels/cameras.d.ts +48 -0
- package/dist/levels/cameras.js +122 -0
- package/dist/levels/cameras.js.map +1 -0
- package/dist/levels/compile/contexts.d.ts +30 -0
- package/dist/levels/compile/contexts.js +18 -0
- package/dist/levels/compile/contexts.js.map +1 -0
- package/dist/levels/compile/index.d.ts +39 -0
- package/dist/levels/compile/index.js +185 -0
- package/dist/levels/compile/index.js.map +1 -0
- package/dist/levels/compile/pipelines.d.ts +26 -0
- package/dist/levels/compile/pipelines.js +177 -0
- package/dist/levels/compile/pipelines.js.map +1 -0
- package/dist/levels/compiles.d.ts +29 -0
- package/dist/levels/compiles.js +50 -0
- package/dist/levels/compiles.js.map +1 -0
- package/dist/levels/draw.d.ts +102 -0
- package/dist/levels/draw.js +401 -0
- package/dist/levels/draw.js.map +1 -0
- package/dist/levels/fade.d.ts +69 -0
- package/dist/levels/fade.js +150 -0
- package/dist/levels/fade.js.map +1 -0
- package/dist/levels/index.d.ts +99 -0
- package/dist/levels/index.js +155 -0
- package/dist/levels/index.js.map +1 -0
- package/dist/levels/item.d.ts +38 -0
- package/dist/levels/item.js +97 -0
- package/dist/levels/item.js.map +1 -0
- package/dist/levels/load.d.ts +31 -0
- package/dist/levels/load.js +142 -0
- package/dist/levels/load.js.map +1 -0
- package/dist/levels/manager.d.ts +159 -0
- package/dist/levels/manager.js +339 -0
- package/dist/levels/manager.js.map +1 -0
- package/dist/{material.js → levels/material.js} +13 -7
- package/dist/levels/material.js.map +1 -0
- package/dist/levels/renderer.d.ts +29 -0
- package/dist/levels/renderer.js +41 -0
- package/dist/levels/renderer.js.map +1 -0
- package/dist/levels/requests.d.ts +49 -0
- package/dist/levels/requests.js +95 -0
- package/dist/levels/requests.js.map +1 -0
- package/dist/levels/screen.d.ts +14 -0
- package/dist/levels/screen.js +21 -0
- package/dist/levels/screen.js.map +1 -0
- package/dist/levels/wait.d.ts +27 -0
- package/dist/levels/wait.js +61 -0
- package/dist/levels/wait.js.map +1 -0
- package/dist/loader/build.d.ts +10 -0
- package/dist/loader/build.js +28 -0
- package/dist/loader/build.js.map +1 -0
- package/dist/loader/cache.d.ts +12 -15
- package/dist/loader/cache.js +64 -33
- package/dist/loader/cache.js.map +1 -1
- package/dist/loader/context.d.ts +46 -0
- package/dist/loader/context.js +91 -0
- package/dist/loader/context.js.map +1 -0
- package/dist/loader/dependencies.d.ts +32 -0
- package/dist/loader/dependencies.js +113 -0
- package/dist/loader/dependencies.js.map +1 -0
- package/dist/loader/index.d.ts +62 -0
- package/dist/loader/index.js +284 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/loader/level.d.ts +41 -0
- package/dist/loader/level.js +140 -0
- package/dist/loader/level.js.map +1 -0
- package/dist/loader/request.d.ts +87 -0
- package/dist/loader/request.js +59 -0
- package/dist/loader/request.js.map +1 -0
- package/dist/loader/url.d.ts +16 -0
- package/dist/loader/url.js +35 -0
- package/dist/loader/url.js.map +1 -0
- package/dist/lod.d.ts +79 -49
- package/dist/lod.js +209 -153
- package/dist/lod.js.map +1 -1
- package/dist/meshopt.d.ts +6 -0
- package/dist/meshopt.js +19 -0
- package/dist/meshopt.js.map +1 -0
- package/dist/simplify/cards.d.ts +14 -0
- package/dist/simplify/cards.js +128 -0
- package/dist/simplify/cards.js.map +1 -0
- package/dist/{simplify.d.ts → simplify/index.d.ts} +7 -4
- package/dist/{simplify.js → simplify/index.js} +42 -22
- package/dist/simplify/index.js.map +1 -0
- package/dist/{bounds.d.ts → source/detail.d.ts} +4 -13
- package/dist/{bounds.js → source/detail.js} +62 -32
- package/dist/source/detail.js.map +1 -0
- package/dist/source/{error.d.ts → deviation.d.ts} +3 -3
- package/dist/source/{error.js → deviation.js} +12 -12
- package/dist/source/deviation.js.map +1 -0
- package/dist/source/{shading.d.ts → evaluator.d.ts} +10 -10
- package/dist/source/{shading.js → evaluator.js} +5 -5
- package/dist/source/evaluator.js.map +1 -0
- package/dist/source/{trace.d.ts → raycaster.d.ts} +6 -6
- package/dist/source/{trace.js → raycaster.js} +8 -8
- package/dist/source/raycaster.js.map +1 -0
- package/dist/source/{texels.d.ts → sampler.d.ts} +1 -1
- package/dist/source/{texels.js → sampler.js} +3 -3
- package/dist/source/sampler.js.map +1 -0
- package/dist/source/source.d.ts +2 -2
- package/dist/source/source.js +2 -2
- package/dist/source/source.js.map +1 -1
- package/dist/source/surface.js +1 -1
- package/dist/source/surface.js.map +1 -1
- package/dist/task.d.ts +6 -0
- package/dist/{pause.js → task.js} +5 -5
- package/dist/task.js.map +1 -0
- package/dist/three.d.ts +20 -19
- package/dist/three.js +29 -35
- package/dist/three.js.map +1 -1
- package/dist/tsl.d.ts +10 -14
- package/dist/tsl.js +12 -47
- package/dist/tsl.js.map +1 -1
- package/dist/typegpu.d.ts +37 -0
- package/dist/typegpu.js +37 -0
- package/dist/typegpu.js.map +1 -0
- package/dist/wind/bounds.js +2 -2
- package/dist/wind/bounds.js.map +1 -1
- package/dist/wind/hooks.d.ts +7 -4
- package/dist/wind/hooks.js +5 -2
- package/dist/wind/hooks.js.map +1 -1
- package/dist/wind/index.d.ts +4 -4
- package/dist/wind/index.js +43 -40
- package/dist/wind/index.js.map +1 -1
- package/dist/wind/sway.d.ts +4 -1
- package/dist/wind/sway.js +4 -1
- package/dist/wind/sway.js.map +1 -1
- package/package.json +24 -8
- package/skills/lod/SKILL.md +147 -108
- package/dist/bounds.js.map +0 -1
- package/dist/fade.d.ts +0 -44
- package/dist/fade.js +0 -78
- package/dist/fade.js.map +0 -1
- package/dist/impostor/cache.d.ts +0 -15
- package/dist/impostor/cache.js +0 -44
- package/dist/impostor/cache.js.map +0 -1
- package/dist/instanced/args.d.ts +0 -20
- package/dist/instanced/args.js +0 -77
- package/dist/instanced/args.js.map +0 -1
- package/dist/instanced/bounds.d.ts +0 -50
- package/dist/instanced/bounds.js +0 -271
- package/dist/instanced/bounds.js.map +0 -1
- package/dist/instanced/dirty.d.ts +0 -12
- package/dist/instanced/dirty.js +0 -61
- package/dist/instanced/dirty.js.map +0 -1
- package/dist/instanced/select.d.ts +0 -84
- package/dist/instanced/select.js +0 -264
- package/dist/instanced/select.js.map +0 -1
- package/dist/lazy.d.ts +0 -64
- package/dist/lazy.js +0 -187
- package/dist/lazy.js.map +0 -1
- package/dist/levels.d.ts +0 -72
- package/dist/levels.js +0 -146
- package/dist/levels.js.map +0 -1
- package/dist/loader/dispose.d.ts +0 -3
- package/dist/loader/dispose.js +0 -25
- package/dist/loader/dispose.js.map +0 -1
- package/dist/loader.d.ts +0 -99
- package/dist/loader.js +0 -234
- package/dist/loader.js.map +0 -1
- package/dist/material.js.map +0 -1
- package/dist/pause.d.ts +0 -6
- package/dist/pause.js.map +0 -1
- package/dist/renderer.d.ts +0 -21
- package/dist/renderer.js +0 -83
- package/dist/renderer.js.map +0 -1
- package/dist/simplify.js.map +0 -1
- package/dist/source/error.js.map +0 -1
- package/dist/source/shading.js.map +0 -1
- package/dist/source/texels.js.map +0 -1
- package/dist/source/trace.js.map +0 -1
- package/dist/view.d.ts +0 -30
- package/dist/view.js +0 -75
- package/dist/view.js.map +0 -1
- /package/dist/{material.d.ts → levels/material.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { d } from "typegpu";
|
|
2
|
+
import { type Draw, type DrawLevels } from "./draw.js";
|
|
3
|
+
/**
|
|
4
|
+
* The bits of the levels to load for objects whose heights on a camera's screen lie in `ranges` (shortest and tallest,
|
|
5
|
+
* in px), read from `heights`, all levels loaded: every level a height in a range draws once all are loaded, the finer
|
|
6
|
+
* neighbour inside a fade included, and with any that draws something the coarsest level that draws something, which
|
|
7
|
+
* every draw waits for (see levelsToDraw). None where nothing draws.
|
|
8
|
+
*/
|
|
9
|
+
export declare function levelsToLoad(ranges: Iterable<readonly [shortest: number, tallest: number]>, heights: LevelHeights): number;
|
|
10
|
+
/**
|
|
11
|
+
* The levels levelsToDraw draws with `levels` and the levels of `loaded` loaded, no arrival under way, at every height,
|
|
12
|
+
* by intervals of heights: worked out once, as it walks every chunk's heights each frame and each of its CPU calls
|
|
13
|
+
* through TypeGPU copies its arguments. What it draws changes only at a level's maxPixels and where its fade starts,
|
|
14
|
+
* whatever is loaded (which only says what stands in for a level): it is asked at the ends of a few f32 steps around
|
|
15
|
+
* each such height, and between them where it changes. levelsToDraw stays the only answer; this is where it changes.
|
|
16
|
+
*/
|
|
17
|
+
export declare class LevelHeights {
|
|
18
|
+
readonly levels: d.Infer<typeof DrawLevels>;
|
|
19
|
+
readonly loaded: number;
|
|
20
|
+
/** The last f32 height of every interval but the last, ascending. */
|
|
21
|
+
private readonly ends;
|
|
22
|
+
/** The bits of the levels each interval draws: its level, and inside a fade the finer one too. */
|
|
23
|
+
private readonly drawn;
|
|
24
|
+
constructor(levels: d.Infer<typeof DrawLevels>, loaded?: number);
|
|
25
|
+
/** The bits of the levels objects from `shortest` to `tallest` px tall draw. */
|
|
26
|
+
drawnIn(shortest: number, tallest: number): number;
|
|
27
|
+
/** The interval holding `height`. */
|
|
28
|
+
private interval;
|
|
29
|
+
}
|
|
30
|
+
/** The bits of the levels `draw` draws: its level, and its finer one while it fades; none for level -1. */
|
|
31
|
+
export declare function drawnBits({ level, finer, fade }: d.Infer<typeof Draw>): number;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { at } from "../at.js";
|
|
2
|
+
import { ANY_HEIGHT, FADE, levelsToDraw } from "./draw.js";
|
|
3
|
+
// Which levels a camera needs loaded, and which it can draw.
|
|
4
|
+
/**
|
|
5
|
+
* The bits of the levels to load for objects whose heights on a camera's screen lie in `ranges` (shortest and tallest,
|
|
6
|
+
* in px), read from `heights`, all levels loaded: every level a height in a range draws once all are loaded, the finer
|
|
7
|
+
* neighbour inside a fade included, and with any that draws something the coarsest level that draws something, which
|
|
8
|
+
* every draw waits for (see levelsToDraw). None where nothing draws.
|
|
9
|
+
*/
|
|
10
|
+
export function levelsToLoad(ranges, heights) {
|
|
11
|
+
const { count, empty, coarsest } = heights.levels;
|
|
12
|
+
const all = (1 << count) - 1;
|
|
13
|
+
let wanted = 0;
|
|
14
|
+
for (const [shortest, tallest] of ranges) {
|
|
15
|
+
wanted |= heights.drawnIn(shortest, tallest);
|
|
16
|
+
// Every level that draws something is wanted already.
|
|
17
|
+
if ((wanted & ~empty) === (all & ~empty))
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return wanted & ~empty ? wanted | (1 << coarsest) : wanted;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* How far, in f32 steps, a height where what levelsToDraw draws changes may lie from where `windowsOf` puts it: on the
|
|
24
|
+
* CPU, TypeGPU rounds heights and maxPixels to f32 and computes a fade's start from them, which moves it by a step.
|
|
25
|
+
*/
|
|
26
|
+
const SLACK = 4;
|
|
27
|
+
/**
|
|
28
|
+
* The levels levelsToDraw draws with `levels` and the levels of `loaded` loaded, no arrival under way, at every height,
|
|
29
|
+
* by intervals of heights: worked out once, as it walks every chunk's heights each frame and each of its CPU calls
|
|
30
|
+
* through TypeGPU copies its arguments. What it draws changes only at a level's maxPixels and where its fade starts,
|
|
31
|
+
* whatever is loaded (which only says what stands in for a level): it is asked at the ends of a few f32 steps around
|
|
32
|
+
* each such height, and between them where it changes. levelsToDraw stays the only answer; this is where it changes.
|
|
33
|
+
*/
|
|
34
|
+
export class LevelHeights {
|
|
35
|
+
levels;
|
|
36
|
+
loaded;
|
|
37
|
+
/** The last f32 height of every interval but the last, ascending. */
|
|
38
|
+
ends = [];
|
|
39
|
+
/** The bits of the levels each interval draws: its level, and inside a fade the finer one too. */
|
|
40
|
+
drawn = [];
|
|
41
|
+
constructor(levels, loaded = (1 << levels.count) - 1) {
|
|
42
|
+
this.levels = levels;
|
|
43
|
+
this.loaded = loaded;
|
|
44
|
+
const ask = (height) => drawnBits(levelsToDraw(height, levels, loaded, loaded, 1));
|
|
45
|
+
let below = ask(0);
|
|
46
|
+
this.drawn.push(below);
|
|
47
|
+
for (const [low, high] of windowsOf(levels)) {
|
|
48
|
+
if (ask(low) !== below)
|
|
49
|
+
throw new Error("Lod: levelsToDraw changes away from every maxPixels and fade start");
|
|
50
|
+
const above = ask(high);
|
|
51
|
+
// Every change inside the window: the last f32 height that draws what is below it, found by halving.
|
|
52
|
+
for (let from = low; below !== above;) {
|
|
53
|
+
let last = from;
|
|
54
|
+
let past = high;
|
|
55
|
+
while (step(last, 1) < past) {
|
|
56
|
+
const middle = halfway(last, past);
|
|
57
|
+
if (ask(middle) === below)
|
|
58
|
+
last = middle;
|
|
59
|
+
else
|
|
60
|
+
past = middle;
|
|
61
|
+
}
|
|
62
|
+
below = ask(past);
|
|
63
|
+
this.ends.push(last);
|
|
64
|
+
this.drawn.push(below);
|
|
65
|
+
from = past;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// levelsToDraw takes no infinite f32: the largest finite one stands for every height above.
|
|
69
|
+
if (ask(ANY_HEIGHT) !== below)
|
|
70
|
+
throw new Error("Lod: levelsToDraw changes above every maxPixels");
|
|
71
|
+
}
|
|
72
|
+
/** The bits of the levels objects from `shortest` to `tallest` px tall draw. */
|
|
73
|
+
drawnIn(shortest, tallest) {
|
|
74
|
+
const last = this.interval(tallest);
|
|
75
|
+
let bits = 0;
|
|
76
|
+
for (let i = this.interval(shortest); i <= last; i++)
|
|
77
|
+
bits |= at(this.drawn, i);
|
|
78
|
+
return bits;
|
|
79
|
+
}
|
|
80
|
+
/** The interval holding `height`. */
|
|
81
|
+
interval(height) {
|
|
82
|
+
// levelsToDraw reads a height as an f32.
|
|
83
|
+
const value = Math.fround(height);
|
|
84
|
+
const { ends } = this;
|
|
85
|
+
let index = 0;
|
|
86
|
+
let end = ends.length;
|
|
87
|
+
while (index < end) {
|
|
88
|
+
const middle = (index + end) >>> 1;
|
|
89
|
+
if (value > at(ends, middle))
|
|
90
|
+
index = middle + 1;
|
|
91
|
+
else
|
|
92
|
+
end = middle;
|
|
93
|
+
}
|
|
94
|
+
return index;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** The bits of the levels `draw` draws: its level, and its finer one while it fades; none for level -1. */
|
|
98
|
+
export function drawnBits({ level, finer, fade }) {
|
|
99
|
+
if (level < 0)
|
|
100
|
+
return 0;
|
|
101
|
+
return (1 << level) | (fade > 0 ? 1 << finer : 0);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The f32 heights around which what levelsToDraw draws with `levels` may change, `SLACK` steps either side, ascending
|
|
105
|
+
* and merged where they overlap: every level's maxPixels but the source's, and where its fade starts.
|
|
106
|
+
*/
|
|
107
|
+
function windowsOf(levels) {
|
|
108
|
+
const edges = [];
|
|
109
|
+
levels.maxPixels.forEach((maxPixels, level) => {
|
|
110
|
+
if (level === 0 || level >= levels.count)
|
|
111
|
+
return;
|
|
112
|
+
edges.push(Math.fround(maxPixels), Math.fround(Math.fround(maxPixels) * (1 - FADE)));
|
|
113
|
+
});
|
|
114
|
+
edges.sort((a, b) => a - b);
|
|
115
|
+
const windows = [];
|
|
116
|
+
for (const edge of edges) {
|
|
117
|
+
const low = step(edge, -SLACK);
|
|
118
|
+
const last = windows.at(-1);
|
|
119
|
+
if (last && low <= last[1])
|
|
120
|
+
last[1] = step(edge, SLACK);
|
|
121
|
+
else
|
|
122
|
+
windows.push([low, step(edge, SLACK)]);
|
|
123
|
+
}
|
|
124
|
+
return windows;
|
|
125
|
+
}
|
|
126
|
+
const float = new Float32Array(1);
|
|
127
|
+
const bits = new Uint32Array(float.buffer);
|
|
128
|
+
/** The f32 `steps` steps from `value`, a height at or above 0, not below 0. */
|
|
129
|
+
function step(value, steps) {
|
|
130
|
+
float[0] = value;
|
|
131
|
+
bits[0] = Math.max(at(bits, 0) + steps, 0);
|
|
132
|
+
return at(float, 0);
|
|
133
|
+
}
|
|
134
|
+
/** An f32 between the f32s `low` and `high`, two or more steps apart, at or above 0. */
|
|
135
|
+
function halfway(low, high) {
|
|
136
|
+
float[0] = low;
|
|
137
|
+
const from = at(bits, 0);
|
|
138
|
+
float[0] = high;
|
|
139
|
+
bits[0] = from + Math.floor((at(bits, 0) - from) / 2);
|
|
140
|
+
return at(float, 0);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/levels/load.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAA8B,MAAM,WAAW,CAAC;AAEvF,6DAA6D;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAA8D,EAAE,OAAqB;IAChH,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAClD,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,EAAE,CAAC;QACzC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7C,sDAAsD;QACtD,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;YAAE,MAAM;IAClD,CAAC;IACD,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC7D,CAAC;A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type { LodGpu } from "../gpu.js";
|
|
4
|
+
import { type DrawLevels } from "./draw.js";
|
|
5
|
+
import type { LodLevel } from "./index.js";
|
|
6
|
+
import { LoadingItem } from "./item.js";
|
|
7
|
+
import { CameraRequests } from "./requests.js";
|
|
8
|
+
/** How long an arriving level fades in for, over what drew in its place. */
|
|
9
|
+
export declare const ARRIVAL_MS = 200;
|
|
10
|
+
export interface LodEventMap extends Object3DEventMap {
|
|
11
|
+
/** A compiled level has joined the loaded levels. */
|
|
12
|
+
levelschange: {};
|
|
13
|
+
/** Fetch, decode, or GPU preparation failed; the loaded levels still draw. */
|
|
14
|
+
levelserror: {
|
|
15
|
+
error: Error;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** What a Lod or InstancedLod makes of a level's loaded object: `object` compiles, then joins the loaded levels or is discarded. */
|
|
19
|
+
export interface PreparedLevel {
|
|
20
|
+
object: Object3D;
|
|
21
|
+
/** The level joins the loaded levels: it draws from now on. */
|
|
22
|
+
join(): void;
|
|
23
|
+
/** The compile failed, or the Lod was disposed meanwhile: free what preparing made. */
|
|
24
|
+
discard(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Loads a Lod's or InstancedLod's levels as its cameras request them, never blocking a render. The coarsest level that
|
|
28
|
+
* draws something loads first, as nothing draws before it has (see levelsToDraw); the other levels a camera wants
|
|
29
|
+
* start loading once it has loaded. Each level's load runs once; once the render that asked for it has ended, the Lod
|
|
30
|
+
* prepares it (`prepare`), it compiles for the render context of every camera rendering the Lod and joins the loaded
|
|
31
|
+
* levels. Levels join only between arrivals, each of which fades in for ARRIVAL_MS from the levels loaded `before` it.
|
|
32
|
+
* Each render context seen for the first time compiles in the background every loaded level that draws something,
|
|
33
|
+
* given ones included, that no camera rendering the Lod wants: three skips a draw whose pipeline a compileAsync is
|
|
34
|
+
* still building, in any context that shares it, so a level a camera may draw now builds as it first draws instead.
|
|
35
|
+
* Nothing is evicted: a level stays loaded until the Lod is disposed.
|
|
36
|
+
*
|
|
37
|
+
* A Lod draws with its LodGpu's renderer, whose renders it learns its cameras from. It holds an item on its LoadingManager while anything a camera wants is missing, compiling or arriving,
|
|
38
|
+
* and an InstancedLod's while the GPU has not shown its chunks taken in (see `chunksChanged`).
|
|
39
|
+
*/
|
|
40
|
+
export declare class LodLevelLoadManager {
|
|
41
|
+
private readonly lod;
|
|
42
|
+
private readonly gpu;
|
|
43
|
+
/** The LoadingManager item's name, which errors name too: the kind of Lod and its uuid. */
|
|
44
|
+
private readonly name;
|
|
45
|
+
/** The levels as the Lod was given them: it holds them (see `LodLevel.hold`) until it is disposed. */
|
|
46
|
+
private readonly levels;
|
|
47
|
+
private readonly prepare;
|
|
48
|
+
/** What draws a loaded level, compiled for each render context it is wanted in. */
|
|
49
|
+
private readonly drawnBy;
|
|
50
|
+
/** The bits of the levels that draw: given ones from the start, deferred ones once loaded and compiled. */
|
|
51
|
+
loaded: number;
|
|
52
|
+
/** The bits loaded before the latest arrival (see `progress`). */
|
|
53
|
+
before: number;
|
|
54
|
+
/** The first failure; it stops further loading. */
|
|
55
|
+
error: Error | undefined;
|
|
56
|
+
/** Whether a render has updated the Lod: its shaders are being or have been built. */
|
|
57
|
+
started: boolean;
|
|
58
|
+
/** What draws the Lod: its LodGpu's renderer. */
|
|
59
|
+
readonly renderer: Renderer;
|
|
60
|
+
/** The cameras rendering the Lod, and what they asked for. */
|
|
61
|
+
readonly requests: CameraRequests;
|
|
62
|
+
/** Its item on a LoadingManager. */
|
|
63
|
+
readonly item: LoadingItem;
|
|
64
|
+
/**
|
|
65
|
+
* The bits of the levels that draw nothing, the coarsest level that draws something, and the order levels load in: it
|
|
66
|
+
* first, then coarse to fine.
|
|
67
|
+
*/
|
|
68
|
+
private readonly empty;
|
|
69
|
+
private readonly coarsest;
|
|
70
|
+
private readonly order;
|
|
71
|
+
/** When the latest arrival began. */
|
|
72
|
+
private arrival;
|
|
73
|
+
/** Compiled levels waiting for the arrival under way to end. */
|
|
74
|
+
private readonly ready;
|
|
75
|
+
/** Levels being prepared and compiled to join the loaded ones. */
|
|
76
|
+
private readonly arriving;
|
|
77
|
+
/** The background compiles of loaded levels, per render context. */
|
|
78
|
+
private readonly compiles;
|
|
79
|
+
/** Per level, its load once started. */
|
|
80
|
+
private readonly loads;
|
|
81
|
+
/** What renders told of the cameras that drew the Lod. */
|
|
82
|
+
private readonly seen;
|
|
83
|
+
private disposed;
|
|
84
|
+
/** What `LodLevel.hold` answered, each called once the Lod is disposed. */
|
|
85
|
+
private readonly releases;
|
|
86
|
+
/** An InstancedLod's chunks, while they wait to be shown taken in (see `chunksChanged`); null for a Lod. */
|
|
87
|
+
private readonly wait;
|
|
88
|
+
constructor(lod: Object3D<LodEventMap>, gpu: LodGpu,
|
|
89
|
+
/** The LoadingManager item's name, which errors name too: the kind of Lod and its uuid. */
|
|
90
|
+
name: string,
|
|
91
|
+
/** The levels as the Lod was given them: it holds them (see `LodLevel.hold`) until it is disposed. */
|
|
92
|
+
levels: readonly LodLevel[],
|
|
93
|
+
/** The levels as levelsToDraw reads them, for the ones that draw nothing and the coarsest that draws something. */
|
|
94
|
+
{ empty, coarsest }: d.Infer<typeof DrawLevels>, prepare: (level: number, loaded: Object3D) => PreparedLevel,
|
|
95
|
+
/** What draws a loaded level, compiled for each render context it is wanted in. */
|
|
96
|
+
drawnBy: (level: number) => readonly Object3D[],
|
|
97
|
+
/** An InstancedLod's read of whether the GPU shows every chunk taken in (see `ChunkWait`); null for a Lod. */
|
|
98
|
+
readChunks: (() => Promise<boolean>) | null);
|
|
99
|
+
/** How far the latest arrival has faded in, in [0, 1]: 1 once it has. */
|
|
100
|
+
get progress(): number;
|
|
101
|
+
get pending(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* `camera`, a shadow map's when `shadow`, wants the levels of the bits `wanted` (see levelsToLoad): load what is
|
|
104
|
+
* missing, and answer the bits of the levels loaded now. Outside a Scene a missing level is an error, as no render of it would load it.
|
|
105
|
+
*/
|
|
106
|
+
request(camera: Camera, wanted: number, shadow: boolean): number;
|
|
107
|
+
/**
|
|
108
|
+
* An InstancedLod's chunks were added or removed: hold the item until, a few renders later, the GPU shows each taken
|
|
109
|
+
* in, so that a host waiting for its LoadingManager sees them drawn. A chunk the pool lacks room for is the
|
|
110
|
+
* InstancedLod's error.
|
|
111
|
+
*/
|
|
112
|
+
chunksChanged(): void;
|
|
113
|
+
/**
|
|
114
|
+
* The height `camera`, a shadow map's when `shadow`, draws at (see CameraRenders.heightOf), which levels are chosen
|
|
115
|
+
* at.
|
|
116
|
+
*/
|
|
117
|
+
heightOf(camera: Camera, shadow: boolean): number;
|
|
118
|
+
/** What compiles for `cameras` are for: the shadow maps they drew, and the targets disposed. */
|
|
119
|
+
private compileFor;
|
|
120
|
+
/**
|
|
121
|
+
* Load what the cameras still rendering the Lod want, in `order`, compile for `camera`'s render context every loaded
|
|
122
|
+
* level that draws something, none of them wants and is not yet compiled for it, and prepare the levels that have
|
|
123
|
+
* loaded. `shadow` is whether a shadow map renders it, in the renderer's `frame`.
|
|
124
|
+
*/
|
|
125
|
+
private load;
|
|
126
|
+
/** Run level `level`'s `load`, holding the object it makes. */
|
|
127
|
+
private start;
|
|
128
|
+
private levelAt;
|
|
129
|
+
/** Compile the loaded levels of `bits` for `context`: a background compile (see ContextCompiles). */
|
|
130
|
+
private compileLevels;
|
|
131
|
+
/**
|
|
132
|
+
* Prepare `level` once the render that asked for it has ended, if a camera still wants it then, and compile it for
|
|
133
|
+
* the render context of every camera still rendering the Lod, `context` among them, to join the loaded levels: a
|
|
134
|
+
* slow level never holds another's, and no camera draws it uncompiled.
|
|
135
|
+
*/
|
|
136
|
+
private arrive;
|
|
137
|
+
/** Let compiled levels join the loaded ones, between arrivals: what draws never changes halfway through a fade. */
|
|
138
|
+
private join;
|
|
139
|
+
/**
|
|
140
|
+
* Hold the item while levels a camera wants are missing, compiling or arriving, or chunks wait to be shown taken in,
|
|
141
|
+
* and end it once they are done, so a host waiting for its LoadingManager renders its cameras complete. Called at
|
|
142
|
+
* the end of each request.
|
|
143
|
+
*/
|
|
144
|
+
private sync;
|
|
145
|
+
/**
|
|
146
|
+
* The one failure rule, for a level that fails and for anything that throws while three renders, where a throw would
|
|
147
|
+
* leave its internal target bound: note the error, log it, report it on the LoadingManager the item is held on and
|
|
148
|
+
* end the item, and dispatch `levelserror`. Only the first is reported; it stops further loading.
|
|
149
|
+
*/
|
|
150
|
+
report(error: unknown): void;
|
|
151
|
+
/** Run `action`, part of an update or a draw callback, reporting what it throws instead. */
|
|
152
|
+
guard(action: () => void): void;
|
|
153
|
+
/**
|
|
154
|
+
* Stop loading, then `release` what the Lod made of its levels and let go of what it holds of them (see
|
|
155
|
+
* `LodLevel.hold`), once nothing preparing, compiling or loading still uses them. What the levels gave or loaded is
|
|
156
|
+
* not freed: it is whoever made it's.
|
|
157
|
+
*/
|
|
158
|
+
dispose(release: () => void): void;
|
|
159
|
+
}
|