@drawcall/lod 0.2.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 +6 -7
- package/dist/bake.d.ts +36 -0
- package/dist/bake.js +176 -0
- package/dist/bake.js.map +1 -0
- package/dist/baked/codec.d.ts +3 -6
- package/dist/baked/codec.js +48 -154
- 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 +14 -8
- package/dist/baked/index.js +24 -22
- package/dist/baked/index.js.map +1 -1
- package/dist/baked/interior/faces.d.ts +4 -3
- package/dist/baked/interior/faces.js +16 -11
- 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.d.ts +1 -1
- package/dist/baked/interior/rooms.js +2 -2
- package/dist/baked/interior/rooms.js.map +1 -1
- package/dist/baked/low.js +5 -4
- 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/{mesh/codec.js → codec/mesh.js} +80 -52
- package/dist/codec/mesh.js.map +1 -0
- package/dist/dispose.d.ts +8 -5
- package/dist/dispose.js +22 -24
- 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/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 +22 -14
- package/dist/impostor/bake/index.js +50 -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 +51 -13
- 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 +3 -2
- package/dist/impostor/bake/source.js +9 -20
- package/dist/impostor/bake/source.js.map +1 -1
- package/dist/impostor/codec.d.ts +4 -5
- package/dist/impostor/codec.js +36 -109
- 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 +120 -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 +65 -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 +10 -0
- package/dist/impostor/ktx2/worker.js.map +1 -0
- package/dist/impostor/mesh/card.d.ts +4 -4
- package/dist/impostor/mesh/card.js +7 -7
- package/dist/impostor/mesh/card.js.map +1 -1
- package/dist/impostor/mesh/index.d.ts +7 -6
- package/dist/impostor/mesh/index.js +10 -11
- package/dist/impostor/mesh/index.js.map +1 -1
- package/dist/impostor/mesh/material.d.ts +18 -9
- package/dist/impostor/mesh/material.js +40 -27
- package/dist/impostor/mesh/material.js.map +1 -1
- package/dist/impostor/mesh/surface.d.ts +1 -1
- package/dist/impostor/mesh/surface.js +13 -9
- 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/index.d.ts +13 -11
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/instanced/camera.d.ts +34 -0
- package/dist/instanced/camera.js +45 -0
- package/dist/instanced/camera.js.map +1 -0
- 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 +28 -0
- package/dist/instanced/cull.js +22 -0
- package/dist/instanced/cull.js.map +1 -0
- 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 +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 +131 -0
- package/dist/instanced/levels.js.map +1 -0
- package/dist/instanced/lists.d.ts +57 -0
- package/dist/instanced/lists.js +114 -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 +44 -51
- package/dist/instanced/meshes.js +167 -179
- package/dist/instanced/meshes.js.map +1 -1
- package/dist/instanced/mirror.d.ts +24 -0
- package/dist/instanced/mirror.js +76 -0
- package/dist/instanced/mirror.js.map +1 -0
- package/dist/instanced/raycast.d.ts +10 -11
- package/dist/instanced/raycast.js +31 -41
- package/dist/instanced/raycast.js.map +1 -1
- package/dist/instanced/rows.d.ts +50 -0
- package/dist/instanced/rows.js +36 -0
- package/dist/instanced/rows.js.map +1 -0
- package/dist/instanced/shape.d.ts +27 -0
- package/dist/instanced/shape.js +54 -0
- package/dist/instanced/shape.js.map +1 -0
- package/dist/instanced/sort.d.ts +61 -0
- package/dist/instanced/sort.js +192 -0
- package/dist/instanced/sort.js.map +1 -0
- package/dist/instanced/update.d.ts +34 -0
- package/dist/instanced/update.js +180 -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 +41 -0
- package/dist/levels/compile/index.js +193 -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 +172 -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 +60 -0
- package/dist/levels/fade.js +129 -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 +89 -0
- package/dist/levels/item.js.map +1 -0
- package/dist/levels/load.d.ts +31 -0
- package/dist/levels/load.js +144 -0
- package/dist/levels/load.js.map +1 -0
- package/dist/levels/manager.d.ts +158 -0
- package/dist/levels/manager.js +352 -0
- package/dist/levels/manager.js.map +1 -0
- package/dist/{material.d.ts → levels/material.d.ts} +2 -2
- package/dist/{material.js → levels/material.js} +6 -5
- package/dist/levels/material.js.map +1 -0
- package/dist/levels/renderer.d.ts +32 -0
- package/dist/levels/renderer.js +57 -0
- package/dist/levels/renderer.js.map +1 -0
- package/dist/levels/requests.d.ts +52 -0
- package/dist/levels/requests.js +97 -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/loader/build.d.ts +10 -0
- package/dist/loader/build.js +28 -0
- package/dist/loader/build.js.map +1 -0
- package/dist/loader/context.d.ts +44 -0
- package/dist/loader/context.js +96 -0
- package/dist/loader/context.js.map +1 -0
- 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 +76 -0
- package/dist/loader/index.js +272 -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/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 +54 -0
- package/dist/loader/request.js +19 -0
- package/dist/loader/request.js.map +1 -0
- package/dist/loader/url.d.ts +10 -6
- package/dist/loader/url.js +22 -14
- package/dist/loader/url.js.map +1 -1
- package/dist/lod.d.ts +144 -43
- package/dist/lod.js +354 -163
- package/dist/lod.js.map +1 -1
- package/dist/meshopt.d.ts +6 -0
- package/dist/meshopt.js +20 -0
- package/dist/meshopt.js.map +1 -0
- 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/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} +8 -5
- package/dist/{simplify.js → simplify/index.js} +45 -27
- package/dist/simplify/index.js.map +1 -0
- package/dist/{bounds.d.ts → source/detail.d.ts} +9 -23
- package/dist/{bounds.js → source/detail.js} +28 -58
- package/dist/source/detail.js.map +1 -0
- package/dist/source/deviation.js +6 -6
- package/dist/source/deviation.js.map +1 -1
- 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} +8 -5
- package/dist/source/sampler.js.map +1 -0
- package/dist/source/source.d.ts +1 -1
- package/dist/source/source.js +1 -1
- 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 +19 -30
- package/dist/three.js +30 -57
- package/dist/three.js.map +1 -1
- package/dist/tsl.d.ts +8 -12
- package/dist/tsl.js +11 -39
- 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 +3 -3
- 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 +25 -23
- package/dist/wind/index.js.map +1 -1
- package/dist/wind/sway.d.ts +2 -0
- package/dist/wind/sway.js +4 -1
- package/dist/wind/sway.js.map +1 -1
- package/package.json +24 -10
- package/skills/lod/SKILL.md +120 -32
- package/dist/bounds.js.map +0 -1
- package/dist/compile.d.ts +0 -4
- package/dist/compile.js +0 -100
- package/dist/compile.js.map +0 -1
- package/dist/deferred.d.ts +0 -12
- package/dist/deferred.js +0 -27
- package/dist/deferred.js.map +0 -1
- package/dist/fade.d.ts +0 -36
- package/dist/fade.js +0 -112
- package/dist/fade.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/blocks.d.ts +0 -66
- package/dist/instanced/blocks.js +0 -294
- package/dist/instanced/blocks.js.map +0 -1
- package/dist/instanced/dirty.d.ts +0 -15
- package/dist/instanced/dirty.js +0 -96
- package/dist/instanced/dirty.js.map +0 -1
- package/dist/instanced/index.d.ts +0 -90
- package/dist/instanced/index.js +0 -349
- package/dist/instanced/index.js.map +0 -1
- package/dist/instanced/parts.d.ts +0 -14
- package/dist/instanced/parts.js +0 -79
- package/dist/instanced/parts.js.map +0 -1
- package/dist/instanced/select.d.ts +0 -92
- package/dist/instanced/select.js +0 -315
- package/dist/instanced/select.js.map +0 -1
- package/dist/instanced/store.d.ts +0 -31
- package/dist/instanced/store.js +0 -96
- package/dist/instanced/store.js.map +0 -1
- package/dist/levels.d.ts +0 -95
- package/dist/levels.js +0 -171
- package/dist/levels.js.map +0 -1
- package/dist/loader/bundle.d.ts +0 -25
- package/dist/loader/bundle.js +0 -241
- package/dist/loader/bundle.js.map +0 -1
- package/dist/loader/cache.d.ts +0 -15
- package/dist/loader/cache.js +0 -75
- package/dist/loader/cache.js.map +0 -1
- package/dist/loader/provenance.d.ts +0 -30
- package/dist/loader/provenance.js +0 -105
- package/dist/loader/provenance.js.map +0 -1
- package/dist/loader.d.ts +0 -55
- package/dist/loader.js +0 -239
- package/dist/loader.js.map +0 -1
- package/dist/material.js.map +0 -1
- package/dist/mesh/codec.d.ts +0 -4
- package/dist/mesh/codec.js.map +0 -1
- package/dist/pause.d.ts +0 -6
- package/dist/pause.js.map +0 -1
- package/dist/queue.d.ts +0 -2
- package/dist/queue.js +0 -33
- package/dist/queue.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/residency.d.ts +0 -44
- package/dist/residency.js +0 -205
- package/dist/residency.js.map +0 -1
- package/dist/simplify.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 -45
- package/dist/view.js +0 -131
- package/dist/view.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* there is one, else a message round trip. Unlike setTimeout, neither is throttled
|
|
4
|
-
* one call a second in a background tab.
|
|
2
|
+
* A promise that settles in a later task of the page's event loop: `scheduler.yield()`
|
|
3
|
+
* where there is one, else a message round trip. Unlike setTimeout, neither is throttled
|
|
4
|
+
* to one call a second in a background tab.
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function nextTask() {
|
|
7
7
|
const scheduler = Reflect.get(globalThis, "scheduler");
|
|
8
8
|
const yielding = typeof scheduler === "object" && scheduler !== null ? Reflect.get(scheduler, "yield") : undefined;
|
|
9
9
|
if (typeof yielding === "function")
|
|
@@ -17,4 +17,4 @@ export function pause() {
|
|
|
17
17
|
channel.port2.postMessage(null);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=task.js.map
|
package/dist/task.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,SAAS,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnH,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,EAAE;YAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/three.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MeshStandardNodeMaterial, type BatchedMesh, type Box3, type BufferAttribute, type Color, type
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { InstancedLod } from "./instanced/index.js";
|
|
1
|
+
import { MeshStandardNodeMaterial, type BatchedMesh, type Box3, type BufferAttribute, type Color, type CompressedTexture, type InstancedMesh, type Material, type Matrix4, type Mesh, type MeshPhysicalMaterial, type MeshStandardMaterial, type Node, type NodeMaterial, type Object3D, type Renderer, type Scene, type SkinnedMesh, type StorageInstancedBufferAttribute, type Texture } from "three/webgpu";
|
|
2
|
+
import type { GLTSScene } from "@drawcall/glts";
|
|
3
|
+
import type { Lod } from "./lod.js";
|
|
5
4
|
import type { ImpostorMesh } from "./impostor/mesh/index.js";
|
|
6
5
|
export declare const isObject3D: (value: unknown) => value is Object3D;
|
|
7
6
|
export declare const isNode: (value: unknown) => value is Node;
|
|
@@ -11,13 +10,14 @@ export declare const isInstancedMesh: (node: Object3D) => node is InstancedMesh;
|
|
|
11
10
|
export declare const isBatchedMesh: (node: Object3D) => node is BatchedMesh;
|
|
12
11
|
export declare const isLight: (node: Object3D) => boolean;
|
|
13
12
|
export declare const isScene: (node: Object3D) => node is Scene;
|
|
13
|
+
export declare const isLine: (node: Object3D) => boolean;
|
|
14
|
+
export declare const isPoints: (node: Object3D) => boolean;
|
|
15
|
+
export declare const isSprite: (node: Object3D) => boolean;
|
|
16
|
+
/** A scene a GLTSLoader loaded: its loader gives it a dispose of its own, which a clone, a plain Scene, lacks. */
|
|
14
17
|
export declare const isGLTSScene: (node: Object3D) => node is GLTSScene;
|
|
15
|
-
/** A GLTSLoader, recognized by the bundled module provenance it publishes. */
|
|
16
|
-
export declare const isGLTSLoader: (loader: Loader) => loader is GLTSLoader;
|
|
17
18
|
export declare const isImpostorMesh: (node: Object3D) => node is ImpostorMesh;
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
/** three's LOD and this package's Lod and InstancedLod. */
|
|
19
|
+
export declare const isLod: (node: Object3D) => node is Lod;
|
|
20
|
+
/** three's LOD and this package's Lod. */
|
|
21
21
|
export declare const isLOD: (node: Object3D) => node is Object3D & {
|
|
22
22
|
isLOD: true;
|
|
23
23
|
autoUpdate: boolean;
|
|
@@ -32,36 +32,25 @@ export declare const isNodeMaterial: (material: Material) => material is NodeMat
|
|
|
32
32
|
export declare const isStandardNode: (material: Material) => material is MeshStandardNodeMaterial;
|
|
33
33
|
export declare const isStorageInstanced: (attribute: BufferAttribute) => attribute is StorageInstancedBufferAttribute;
|
|
34
34
|
/**
|
|
35
|
-
* A node material that renders like `material`: a clone when it is one, else the node
|
|
36
|
-
*
|
|
35
|
+
* A node material that renders like `material`: a clone when it is one, else the node material of its type with its
|
|
36
|
+
* values, as three converts it for WebGPU itself. NodeMaterial.copy skips accessors of Material itself, alphaTest among
|
|
37
|
+
* them.
|
|
37
38
|
*/
|
|
38
39
|
export declare function toNodeMaterial(material: Material): NodeMaterial;
|
|
40
|
+
export declare const isBox3: (value: unknown) => value is Box3;
|
|
39
41
|
export declare const isTexture: (value: unknown) => value is Texture;
|
|
42
|
+
export declare const isCompressedTexture: (value: unknown) => value is CompressedTexture;
|
|
40
43
|
export declare const isColor: (value: unknown) => value is Color;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
export declare function gpuRenderer(renderer: unknown): Renderer;
|
|
46
|
-
/** The queue of `renderer`'s WebGPU device; throws until the backend has one. */
|
|
47
|
-
export declare function gpuQueue(renderer: Renderer): GPUQueueLike;
|
|
48
|
-
interface GPUQueueLike {
|
|
49
|
-
onSubmittedWorkDone(): Promise<void>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Whether the scene `node` is in is being drawn into a shadow map: three's shadow pass
|
|
53
|
-
* draws it with its own override material, and calls `update` on every LOD with the
|
|
54
|
-
* light's camera, which must not switch the levels the view chose.
|
|
55
|
-
*/
|
|
56
|
-
export declare function inShadowPass(node: Object3D): boolean;
|
|
44
|
+
export declare const isRenderer: (value: unknown) => value is Renderer;
|
|
45
|
+
/** The root of the tree `node` is in: its scene, once added to one. */
|
|
46
|
+
export declare function rootOf(node: Object3D): Object3D;
|
|
57
47
|
/** Whether `material` is the one three draws shadow maps with (a node material building for a shadow pass has it). */
|
|
58
48
|
export declare const isShadowPass: (material: unknown) => boolean;
|
|
59
|
-
/** The storage matrices of a level draw, an ImpostorMesh, or a storage-backed InstancedMesh; else null. */
|
|
60
|
-
export declare function storageMatrices(object: Object3D): StorageInstancedBufferAttribute | null;
|
|
61
49
|
/** Whether `value` is of exactly `like`'s class: a guard for clone() overrides. */
|
|
62
50
|
export declare const sameClass: <T extends object>(like: T, value: object) => value is T;
|
|
63
51
|
/** Throws if anything under `root` is skinned; `who` names the caller in the message. */
|
|
64
52
|
export declare function rejectSkinned(root: Object3D, who: string): void;
|
|
65
53
|
/** Give `level` the transform of `source`, and its shadows: cast or receive if any mesh of it does. */
|
|
66
54
|
export declare function placeLike(level: Object3D, source: Object3D): void;
|
|
67
|
-
|
|
55
|
+
/** Upper bound on the largest singular value, exact for orthogonal matrix axes. */
|
|
56
|
+
export declare function stretch(matrix: Matrix4): number;
|
package/dist/three.js
CHANGED
|
@@ -10,13 +10,14 @@ export const isInstancedMesh = (node) => flag(node, "isInstancedMesh");
|
|
|
10
10
|
export const isBatchedMesh = (node) => flag(node, "isBatchedMesh");
|
|
11
11
|
export const isLight = (node) => flag(node, "isLight");
|
|
12
12
|
export const isScene = (node) => flag(node, "isScene");
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
export const
|
|
13
|
+
export const isLine = (node) => flag(node, "isLine");
|
|
14
|
+
export const isPoints = (node) => flag(node, "isPoints");
|
|
15
|
+
export const isSprite = (node) => flag(node, "isSprite");
|
|
16
|
+
/** A scene a GLTSLoader loaded: its loader gives it a dispose of its own, which a clone, a plain Scene, lacks. */
|
|
17
|
+
export const isGLTSScene = (node) => isScene(node) && "source" in node && Object.hasOwn(node, "dispose");
|
|
16
18
|
export const isImpostorMesh = (node) => flag(node, "isImpostorMesh");
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
/** three's LOD and this package's Lod and InstancedLod. */
|
|
19
|
+
export const isLod = (node) => flag(node, "isLod");
|
|
20
|
+
/** three's LOD and this package's Lod. */
|
|
20
21
|
export const isLOD = (node) => flag(node, "isLOD");
|
|
21
22
|
export const isStandard = (material) => flag(material, "isMeshStandardMaterial");
|
|
22
23
|
export const isPhysical = (material) => flag(material, "isMeshPhysicalMaterial");
|
|
@@ -35,71 +36,35 @@ const NODE_MATERIALS = {
|
|
|
35
36
|
MeshNormalMaterial: MeshNormalNodeMaterial,
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
|
-
* A node material that renders like `material`: a clone when it is one, else the node
|
|
39
|
-
*
|
|
39
|
+
* A node material that renders like `material`: a clone when it is one, else the node material of its type with its
|
|
40
|
+
* values, as three converts it for WebGPU itself. NodeMaterial.copy skips accessors of Material itself, alphaTest among
|
|
41
|
+
* them.
|
|
40
42
|
*/
|
|
41
43
|
export function toNodeMaterial(material) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
const copy = isNodeMaterial(material) ? material.clone() : new (nodeMaterialOf(material))().copy(material);
|
|
45
|
+
copy.alphaTest = material.alphaTest;
|
|
46
|
+
return copy;
|
|
47
|
+
}
|
|
48
|
+
function nodeMaterialOf(material) {
|
|
48
49
|
const Type = NODE_MATERIALS[material.type];
|
|
49
50
|
if (!Type)
|
|
50
51
|
throw new Error(`@drawcall/lod: ${material.type} has no node material to draw with WebGPU`);
|
|
51
|
-
|
|
52
|
-
const values = Object.fromEntries(Object.entries(material).filter(([key]) => key !== "uuid" && key !== "_listeners"));
|
|
53
|
-
return Object.assign(new Type(), values);
|
|
52
|
+
return Type;
|
|
54
53
|
}
|
|
54
|
+
export const isBox3 = (value) => flag(value, "isBox3");
|
|
55
55
|
export const isTexture = (value) => flag(value, "isTexture");
|
|
56
|
+
export const isCompressedTexture = (value) => flag(value, "isCompressedTexture");
|
|
56
57
|
export const isColor = (value) => flag(value, "isColor");
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
export function gpuRenderer(renderer) {
|
|
62
|
-
if (!isRenderer(renderer))
|
|
63
|
-
throw new Error("@drawcall/lod: draws with three's WebGPURenderer only");
|
|
64
|
-
return renderer;
|
|
65
|
-
}
|
|
66
|
-
const isRenderer = (value) => flag(value, "isRenderer");
|
|
67
|
-
/** The queue of `renderer`'s WebGPU device; throws until the backend has one. */
|
|
68
|
-
export function gpuQueue(renderer) {
|
|
69
|
-
const { backend } = renderer;
|
|
70
|
-
// three's typings declare WebGPUBackend but not its device.
|
|
71
|
-
const device = isWebGPUBackend(backend) && "device" in backend ? backend.device : undefined;
|
|
72
|
-
if (!hasQueue(device))
|
|
73
|
-
throw new Error("@drawcall/lod: level preparation requires an initialized WebGPU device");
|
|
74
|
-
return device.queue;
|
|
75
|
-
}
|
|
76
|
-
const hasQueue = (value) => typeof value === "object" &&
|
|
77
|
-
value !== null &&
|
|
78
|
-
"queue" in value &&
|
|
79
|
-
typeof value.queue === "object" &&
|
|
80
|
-
value.queue !== null &&
|
|
81
|
-
"onSubmittedWorkDone" in value.queue &&
|
|
82
|
-
typeof value.queue.onSubmittedWorkDone === "function";
|
|
83
|
-
const isWebGPUBackend = (backend) => flag(backend, "isWebGPUBackend");
|
|
84
|
-
/**
|
|
85
|
-
* Whether the scene `node` is in is being drawn into a shadow map: three's shadow pass
|
|
86
|
-
* draws it with its own override material, and calls `update` on every LOD with the
|
|
87
|
-
* light's camera, which must not switch the levels the view chose.
|
|
88
|
-
*/
|
|
89
|
-
export function inShadowPass(node) {
|
|
58
|
+
export const isRenderer = (value) => flag(value, "isRenderer");
|
|
59
|
+
/** The root of the tree `node` is in: its scene, once added to one. */
|
|
60
|
+
export function rootOf(node) {
|
|
90
61
|
let root = node;
|
|
91
62
|
while (root.parent)
|
|
92
63
|
root = root.parent;
|
|
93
|
-
return
|
|
64
|
+
return root;
|
|
94
65
|
}
|
|
95
66
|
/** Whether `material` is the one three draws shadow maps with (a node material building for a shadow pass has it). */
|
|
96
67
|
export const isShadowPass = (material) => flag(material, "isShadowPassMaterial");
|
|
97
|
-
/** The storage matrices of a level draw, an ImpostorMesh, or a storage-backed InstancedMesh; else null. */
|
|
98
|
-
export function storageMatrices(object) {
|
|
99
|
-
if (isImpostorMesh(object) || isLodInstances(object))
|
|
100
|
-
return object.instanceMatrix;
|
|
101
|
-
return isInstancedMesh(object) && isStorageInstanced(object.instanceMatrix) ? object.instanceMatrix : null;
|
|
102
|
-
}
|
|
103
68
|
/** Whether `value` is of exactly `like`'s class: a guard for clone() overrides. */
|
|
104
69
|
export const sameClass = (like, value) => Object.getPrototypeOf(value) === Object.getPrototypeOf(like);
|
|
105
70
|
/** Throws if anything under `root` is skinned; `who` names the caller in the message. */
|
|
@@ -121,4 +86,12 @@ export function placeLike(level, source) {
|
|
|
121
86
|
level.receiveShadow ||= node.receiveShadow;
|
|
122
87
|
});
|
|
123
88
|
}
|
|
89
|
+
/** Upper bound on the largest singular value, exact for orthogonal matrix axes. */
|
|
90
|
+
export function stretch(matrix) {
|
|
91
|
+
const e = matrix.elements;
|
|
92
|
+
const xy = Math.abs(e[0] * e[4] + e[1] * e[5] + e[2] * e[6]);
|
|
93
|
+
const xz = Math.abs(e[0] * e[8] + e[1] * e[9] + e[2] * e[10]);
|
|
94
|
+
const yz = Math.abs(e[4] * e[8] + e[5] * e[9] + e[6] * e[10]);
|
|
95
|
+
return Math.sqrt(Math.max(e[0] ** 2 + e[1] ** 2 + e[2] ** 2 + xy + xz, e[4] ** 2 + e[5] ** 2 + e[6] ** 2 + xy + yz, e[8] ** 2 + e[9] ** 2 + e[10] ** 2 + xz + yz));
|
|
96
|
+
}
|
|
124
97
|
//# sourceMappingURL=three.js.map
|
package/dist/three.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three.js","sourceRoot":"","sources":["../src/three.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB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AG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC,IAAI,CACd,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CACjJ,CAAC;AACJ,CAAC"}
|
package/dist/tsl.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Node, NodeBuilder } from "three/webgpu";
|
|
2
2
|
/** Column `i` (0..3) of `m`. */
|
|
3
3
|
export declare const column: (m: Node<"mat4">, i: 0 | 1 | 2 | 3) => Node<"vec4">;
|
|
4
4
|
/** The largest scale `m` applies along an axis. */
|
|
5
5
|
export declare const maxScale: (m: Node<"mat4">) => Node<"float">;
|
|
6
|
+
/** An upper bound on the largest stretch `m` applies to any direction, exact for orthogonal axes (as `stretch` in three.ts). */
|
|
7
|
+
export declare function stretch(m: Node<"mat4">): Node<"float">;
|
|
6
8
|
/** Whether projection `m` is orthographic: its bottom-right element is 1. */
|
|
7
9
|
export declare const isOrthographic: (m: Node<"mat4">) => Node<"bool">;
|
|
8
10
|
/** An affine matrix `m` and the inverse of its linear part, as cofactor columns over the determinant. */
|
|
@@ -25,21 +27,15 @@ export declare function contextNode(builder: NodeBuilder, ...path: string[]): No
|
|
|
25
27
|
* An object that stays the same throughout one build of a shader, to cache per build
|
|
26
28
|
* what several of a material's slots read. Each slot is handed its own proxy of the
|
|
27
29
|
* builder, and three's typings expose no handle of the build itself: this is what the
|
|
28
|
-
* build
|
|
30
|
+
* build holds for `anchor`. `getNodeProperties` is public in three, only missing from
|
|
31
|
+
* its typings.
|
|
29
32
|
*/
|
|
30
33
|
export declare function buildKey(builder: NodeBuilder, anchor: Node): object;
|
|
31
34
|
/**
|
|
32
35
|
* Whether `node` builds to a `type` value, which three's typings leave open for a
|
|
33
36
|
* material's slots. Checked while a shader builds, so a slot of another type fails there.
|
|
34
37
|
*/
|
|
35
|
-
export declare function isNodeOf<T extends
|
|
36
|
-
/**
|
|
37
|
-
export
|
|
38
|
-
export declare const instanceGroup: import("three/webgpu").UniformGroupNode;
|
|
39
|
-
/**
|
|
40
|
-
* A context in which every texture read is `bias` mip levels above the level the
|
|
41
|
-
* hardware would pick: the level from the read's own texel footprint, plus `bias`. Reads
|
|
42
|
-
* with uv of their own making, or with an explicit level or gradients, keep theirs.
|
|
43
|
-
*/
|
|
44
|
-
export declare function biasedTextures(bias: Node<"float">): ContextNode<unknown>;
|
|
38
|
+
export declare function isNodeOf<T extends NodeType>(node: Node, type: T, builder: NodeBuilder): node is Node<T>;
|
|
39
|
+
/** The TSL node types `isNodeOf` tells apart. */
|
|
40
|
+
export type NodeType = "bool" | "float" | "int" | "uint" | "vec2" | "vec3" | "vec4" | "mat4";
|
|
45
41
|
export {};
|
package/dist/tsl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cross, dot, max, vec3, vec4 } from "three/tsl";
|
|
2
2
|
import { isNode } from "./three.js";
|
|
3
3
|
// Matrix access for the shaders, in operations three's typings know: they type no
|
|
4
4
|
// columns, inverses or transposes of matrix nodes. A product with a unit vector picks a
|
|
@@ -7,6 +7,14 @@ import { isNode } from "./three.js";
|
|
|
7
7
|
export const column = (m, i) => m.mul(vec4(i === 0 ? 1 : 0, i === 1 ? 1 : 0, i === 2 ? 1 : 0, i === 3 ? 1 : 0));
|
|
8
8
|
/** The largest scale `m` applies along an axis. */
|
|
9
9
|
export const maxScale = (m) => max(column(m, 0).xyz.length(), max(column(m, 1).xyz.length(), column(m, 2).xyz.length()));
|
|
10
|
+
/** An upper bound on the largest stretch `m` applies to any direction, exact for orthogonal axes (as `stretch` in three.ts). */
|
|
11
|
+
export function stretch(m) {
|
|
12
|
+
const a = column(m, 0).xyz, b = column(m, 1).xyz, c = column(m, 2).xyz;
|
|
13
|
+
const ab = dot(a, b).abs();
|
|
14
|
+
const ac = dot(a, c).abs();
|
|
15
|
+
const bc = dot(b, c).abs();
|
|
16
|
+
return max(dot(a, a).add(ab).add(ac), max(dot(b, b).add(ab).add(bc), dot(c, c).add(ac).add(bc))).sqrt();
|
|
17
|
+
}
|
|
10
18
|
/** Whether projection `m` is orthographic: its bottom-right element is 1. */
|
|
11
19
|
export const isOrthographic = (m) => column(m, 3).w.equal(1);
|
|
12
20
|
export function affine(m) {
|
|
@@ -37,7 +45,8 @@ export function contextNode(builder, ...path) {
|
|
|
37
45
|
* An object that stays the same throughout one build of a shader, to cache per build
|
|
38
46
|
* what several of a material's slots read. Each slot is handed its own proxy of the
|
|
39
47
|
* builder, and three's typings expose no handle of the build itself: this is what the
|
|
40
|
-
* build
|
|
48
|
+
* build holds for `anchor`. `getNodeProperties` is public in three, only missing from
|
|
49
|
+
* its typings.
|
|
41
50
|
*/
|
|
42
51
|
export function buildKey(builder, anchor) {
|
|
43
52
|
const properties = Reflect.apply(Reflect.get(builder, "getNodeProperties"), builder, [anchor]);
|
|
@@ -52,41 +61,4 @@ export function buildKey(builder, anchor) {
|
|
|
52
61
|
export function isNodeOf(node, type, builder) {
|
|
53
62
|
return node.getNodeType(builder) === type;
|
|
54
63
|
}
|
|
55
|
-
const bounds = new WeakMap();
|
|
56
|
-
/** One room-bounds node per buffer; a stable name lets equal shaders share programs. */
|
|
57
|
-
export function roomBounds(attribute) {
|
|
58
|
-
let node = bounds.get(attribute);
|
|
59
|
-
if (!node)
|
|
60
|
-
bounds.set(attribute, (node = storage(attribute, "vec4", 0).setName("lodRoomBounds")));
|
|
61
|
-
return node;
|
|
62
|
-
}
|
|
63
|
-
// Keep replaceable draw buffers out of texture-keyed binding caches. Each render
|
|
64
|
-
// object owns this group's bindings while its shader reads the shared nodes below.
|
|
65
|
-
export const instanceGroup = uniformGroup("lodInstances", 2, NodeUpdateType.OBJECT);
|
|
66
|
-
/** The size in texels of a texture's image, or null when it has none to read. */
|
|
67
|
-
function texelsOf(image) {
|
|
68
|
-
if (typeof image !== "object" || image === null || !("width" in image) || !("height" in image))
|
|
69
|
-
return null;
|
|
70
|
-
const { width, height } = image;
|
|
71
|
-
return typeof width === "number" && typeof height === "number" ? [width, height] : null;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* A context in which every texture read is `bias` mip levels above the level the
|
|
75
|
-
* hardware would pick: the level from the read's own texel footprint, plus `bias`. Reads
|
|
76
|
-
* with uv of their own making, or with an explicit level or gradients, keep theirs.
|
|
77
|
-
*/
|
|
78
|
-
export function biasedTextures(bias) {
|
|
79
|
-
return context({
|
|
80
|
-
getTextureLevel: (node) => {
|
|
81
|
-
const texture = node.value;
|
|
82
|
-
const size = texelsOf(texture.image);
|
|
83
|
-
if (node.uvNode || !size)
|
|
84
|
-
return null;
|
|
85
|
-
// The texture's offset, repeat and rotation, as three applies them.
|
|
86
|
-
const at = uniform(texture.matrix).mul(vec3(uv(texture.channel), 1)).xy;
|
|
87
|
-
const texels = at.mul(vec2(size[0], size[1]));
|
|
88
|
-
return log2(max(max(length(dFdx(texels)), length(dFdy(texels))), 1e-6)).add(bias);
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
64
|
//# sourceMappingURL=tsl.js.map
|
package/dist/tsl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsl.js","sourceRoot":"","sources":["../src/tsl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tsl.js","sourceRoot":"","sources":["../src/tsl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,kFAAkF;AAClF,wFAAwF;AACxF,sFAAsF;AAEtF,gCAAgC;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAe,EAAE,CAAgB,EAAgB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3J,mDAAmD;AACnD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAe,EAAiB,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtJ,gIAAgI;AAChI,MAA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U,EAAE,IAAO,EAAE,OAAoB;IACpF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Node } from "three/webgpu";
|
|
2
|
+
import { type TgpuFn } from "typegpu";
|
|
3
|
+
/** The WGSL types a TypeGPU function given to toTsl takes or returns, by TypeGPU's names, and the TSL node type of each. */
|
|
4
|
+
declare const NODE_TYPES: {
|
|
5
|
+
readonly f32: "float";
|
|
6
|
+
readonly i32: "int";
|
|
7
|
+
readonly u32: "uint";
|
|
8
|
+
readonly vec3f: "vec3";
|
|
9
|
+
readonly vec4f: "vec4";
|
|
10
|
+
readonly mat4x4f: "mat4";
|
|
11
|
+
};
|
|
12
|
+
type WgslType = keyof typeof NODE_TYPES;
|
|
13
|
+
/** The WGSL types such a function returns. */
|
|
14
|
+
type ReturnedType = "f32" | "vec3f" | "vec4f";
|
|
15
|
+
/** A TypeGPU data type, such as `d.f32`, by its WGSL name. */
|
|
16
|
+
type Typed<T extends WgslType = WgslType> = {
|
|
17
|
+
readonly type: T;
|
|
18
|
+
};
|
|
19
|
+
/** A TypeGPU function's argument and return types. */
|
|
20
|
+
interface Shell<A extends readonly Typed[], R extends ReturnedType> {
|
|
21
|
+
readonly argTypes: A;
|
|
22
|
+
readonly returnType: Typed<R>;
|
|
23
|
+
}
|
|
24
|
+
/** The TSL nodes the function takes, by the names `N` of its arguments, typed `A` in their order. */
|
|
25
|
+
type TslInputs<N extends readonly string[], A extends readonly Typed[]> = {
|
|
26
|
+
[I in keyof N & `${number}` as N[I]]: Node<(typeof NODE_TYPES)[A[I & keyof A]["type"]]>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A TSL function of nodes named `names` that calls `fn`, a TypeGPU function, through a WGSL forwarder `name`;
|
|
30
|
+
* TypeGPU's WGSL joins the shader as a library.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toTsl<A extends Typed[], R extends ReturnedType, const N extends {
|
|
33
|
+
[I in keyof A]: string;
|
|
34
|
+
}>(name: string, names: N, fn: TgpuFn & {
|
|
35
|
+
readonly shell: Shell<A, R>;
|
|
36
|
+
}): (inputs: TslInputs<N, A>) => Node<(typeof NODE_TYPES)[R]>;
|
|
37
|
+
export {};
|
package/dist/typegpu.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Fn, code, wgslFn } from "three/tsl";
|
|
2
|
+
import { tgpu } from "typegpu";
|
|
3
|
+
import { at } from "./at.js";
|
|
4
|
+
import { isNodeOf } from "./tsl.js";
|
|
5
|
+
// TypeGPU functions ('use gpu') in three's shaders: one function runs as plain JS on the CPU and, through toTsl, as
|
|
6
|
+
// WGSL in a TSL node graph.
|
|
7
|
+
/** The WGSL types a TypeGPU function given to toTsl takes or returns, by TypeGPU's names, and the TSL node type of each. */
|
|
8
|
+
const NODE_TYPES = {
|
|
9
|
+
f32: "float",
|
|
10
|
+
i32: "int",
|
|
11
|
+
u32: "uint",
|
|
12
|
+
vec3f: "vec3",
|
|
13
|
+
vec4f: "vec4",
|
|
14
|
+
mat4x4f: "mat4"
|
|
15
|
+
};
|
|
16
|
+
// Not generic: three's Fn leaves a generic return type unresolved.
|
|
17
|
+
export function toTsl(name, names, fn) {
|
|
18
|
+
// TgpuFn types its shell loosely; the signature types it by its WGSL types.
|
|
19
|
+
const shell = fn.shell;
|
|
20
|
+
const returned = shell.returnType.type;
|
|
21
|
+
const params = names.map((param, index) => `${param}: ${at(shell.argTypes, index).type}`);
|
|
22
|
+
const signature = `(${params.join(", ")}) -> ${returned}`;
|
|
23
|
+
const library = code(tgpu.resolve({
|
|
24
|
+
template: `fn ${name}Of${signature} { return target(${names.join(", ")}); }`,
|
|
25
|
+
externals: {
|
|
26
|
+
target: fn
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
const call = wgslFn(`fn ${name}${signature} { return ${name}Of(${names.join(", ")}); }`, [library]);
|
|
30
|
+
const type = NODE_TYPES[returned];
|
|
31
|
+
return inputs => Fn(builder => {
|
|
32
|
+
const value = call(inputs);
|
|
33
|
+
if (isNodeOf(value, type, builder)) return value;
|
|
34
|
+
throw new Error(`@drawcall/lod: ${name}'s WGSL returns no ${returned}`);
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=typegpu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Fn","code","wgslFn","tgpu","at","isNodeOf","NODE_TYPES","f32","i32","u32","vec3f","vec4f","mat4x4f","toTsl","name","names","fn","shell","returned","returnType","type","params","map","param","index","argTypes","signature","join","library","resolve","template","externals","target","call","inputs","builder","value","Error"],"sources":["../src/typegpu.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,EAAE,EAAEC,IAAI,EAAEC,MAAM,QAAQ,WAAW;AAC5C,SAASC,IAAI,QAAqB,SAAS;AAC3C,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,QAAQ,QAAuB,UAAU;AAElD;AACA;AAEA;AACA,MAAMC,UAAU,GAAG;EAAEC,GAAG,EAAE,OAAO;EAAEC,GAAG,EAAE,KAAK;EAAEC,GAAG,EAAE,MAAM;EAAEC,KAAK,EAAE,MAAM;EAAEC,KAAK,EAAE,MAAM;EAAEC,OAAO,EAAE;AAAM,CAA8C;AA6BvJ;AACA,OAAM,SAAUC,KAAKA,CACnBC,IAAY,EACZC,KAAwB,EACxBC,EAA6D;EAE7D;EACA,MAAMC,KAAK,GAAiCD,EAAE,CAACC,KAAK;EACpD,MAAMC,QAAQ,GAAGD,KAAK,CAACE,UAAU,CAACC,IAAI;EACtC,MAAMC,MAAM,GAAGN,KAAK,CAACO,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAK,GAAGD,KAAK,KAAKnB,EAAE,CAACa,KAAK,CAACQ,QAAQ,EAAED,KAAK,CAAC,CAACJ,IAAI,EAAE,CAAC;EACzF,MAAMM,SAAS,GAAG,IAAIL,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC,QAAQT,QAAQ,EAAE;EACzD,MAAMU,OAAO,GAAG3B,IAAI,CAACE,IAAI,CAAC0B,OAAO,CAAC;IAAEC,QAAQ,EAAE,MAAMhB,IAAI,KAAKY,SAAS,oBAAoBX,KAAK,CAACY,IAAI,CAAC,IAAI,CAAC,MAAM;IAAEI,SAAS,EAAE;MAAEC,MAAM,EAAEhB;IAAE;EAAE,CAAE,CAAC,CAAC;EAC/I,MAAMiB,IAAI,GAAG/B,MAAM,CAAC,MAAMY,IAAI,GAAGY,SAAS,aAAaZ,IAAI,MAAMC,KAAK,CAACY,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAACC,OAAO,CAAC,CAAC;EACnG,MAAMR,IAAI,GAAGd,UAAU,CAACY,QAAQ,CAAC;EACjC,OAAQgB,MAAM,IACZlC,EAAE,CAAEmC,OAAO,IAAI;IACb,MAAMC,KAAK,GAAGH,IAAI,CAACC,MAAM,CAAC;IAC1B,IAAI7B,QAAQ,CAAC+B,KAAK,EAAEhB,IAAI,EAAEe,OAAO,CAAC,EAAE,OAAOC,KAAK;IAChD,MAAM,IAAIC,KAAK,CAAC,kBAAkBvB,IAAI,sBAAsBI,QAAQ,EAAE,CAAC;EACzE,CAAC,CAAC,EAAE;AACR","ignoreList":[]}
|
package/dist/wind/bounds.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Matrix4, Sphere, Vector3 } from "three/webgpu";
|
|
2
|
-
import {
|
|
2
|
+
import { fadeSourceOf } from "../levels/fade.js";
|
|
3
3
|
import { isImpostorMesh, isInstancedMesh } from "../three.js";
|
|
4
4
|
/** Bound maximum sway on the mesh itself, leaving shared geometry in its rest pose. */
|
|
5
5
|
export function windBounds(mesh, placement, amplitude, baseY, height) {
|
|
@@ -16,8 +16,8 @@ export function windBounds(mesh, placement, amplitude, baseY, height) {
|
|
|
16
16
|
const reach = Math.max(Math.abs(root.min.y - baseY), Math.abs(root.max.y - baseY)) / height;
|
|
17
17
|
rest.radius += amplitude * reach * horizontalScale(placement.clone().invert());
|
|
18
18
|
// An ImpostorMesh of its own measures its shadow casters by this radius too.
|
|
19
|
-
const draw =
|
|
20
|
-
if (draw
|
|
19
|
+
const draw = fadeSourceOf(mesh);
|
|
20
|
+
if (draw)
|
|
21
21
|
draw.radius = rest.radius;
|
|
22
22
|
const instances = isInstancedMesh(mesh) || isImpostorMesh(mesh) ? mesh : null;
|
|
23
23
|
if (!instances) {
|
package/dist/wind/bounds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../src/wind/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAa,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../src/wind/bounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAa,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,uFAAuF;AACvF,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,SAAkB,EAAE,SAAiB,EAAE,KAAa,EAAE,MAAc;IACzG,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC,QAAQ,CAAC,WAAW;QAAE,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACzD,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC;IACjC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;QAAE,OAAO;IAClC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAElG,MA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,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE;YAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3H,CAAC,CAAC;IACF,SAAS,CAAC,qBAAqB,EAAE,CAAC;AACpC,CAAC;AAED,iFAAiF;AACjF,SAAS,eAAe,CAAC,MAAe;IACtC,MAAM,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/wind/hooks.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* How a Lod takes wind: it refuses it once it has rendered or prepares levels, whose shaders would then
|
|
3
|
+
* build in a frame; else it pads its setup-only culling and casters, while the levels it draws hold their rest bounds.
|
|
4
|
+
*/
|
|
5
|
+
export declare const WIND: unique symbol;
|
|
6
|
+
export interface WindTarget {
|
|
7
|
+
[WIND](padding: number, slope: number, baseY: number): void;
|
|
5
8
|
}
|
package/dist/wind/hooks.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* How a Lod takes wind: it refuses it once it has rendered or prepares levels, whose shaders would then
|
|
3
|
+
* build in a frame; else it pads its setup-only culling and casters, while the levels it draws hold their rest bounds.
|
|
4
|
+
*/
|
|
5
|
+
export const WIND = Symbol("wind");
|
|
3
6
|
//# sourceMappingURL=hooks.js.map
|
package/dist/wind/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/wind/hooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/wind/hooks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/wind/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface SwayOptions {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* A shared GPU breeze: an affine sway, fixed at the base and linear with height.
|
|
18
|
-
* Bake/build levels first, apply once to the completed Lod,
|
|
18
|
+
* Bake/build levels first, apply once to the completed Lod, mesh or
|
|
19
19
|
* mesh group, then set time once before rendering each frame. All levels and shadow
|
|
20
20
|
* passes share the motion. Simplified and baked meshes need no special preparation.
|
|
21
21
|
*
|
|
@@ -28,7 +28,7 @@ export interface SwayOptions {
|
|
|
28
28
|
* must stay fixed after applying; move/rotate/scale the root or its instances instead.
|
|
29
29
|
* Nested LODs and nested instance batches must be applied individually; an
|
|
30
30
|
* InstancedMesh sways only with its matrices in a storage buffer (an ImpostorMesh's are).
|
|
31
|
-
* Lod
|
|
31
|
+
* Lod and ImpostorMesh clones retain the shared breeze. For ordinary
|
|
32
32
|
* Mesh/Group clones, apply to each clone too: the material is shared but the sway is
|
|
33
33
|
* the mesh's. Tangent-space normal maps are supported (tangents do not sway);
|
|
34
34
|
* object-space normal maps are not.
|
|
@@ -42,12 +42,12 @@ export declare class Wind {
|
|
|
42
42
|
/** Oscillations per second; zero freezes the time-dependent part of the phase. */
|
|
43
43
|
get speed(): number;
|
|
44
44
|
set speed(value: number);
|
|
45
|
-
/** Global amplitude multiplier in [0, 1]. Zero
|
|
45
|
+
/** Global amplitude multiplier in [0, 1]. Zero draws the rest pose, with the wind shader. */
|
|
46
46
|
get strength(): number;
|
|
47
47
|
set strength(value: number);
|
|
48
48
|
get direction(): readonly [number, number];
|
|
49
49
|
set direction([x, z]: readonly [number, number]);
|
|
50
|
-
/** Attach once, after constructing all levels. Objects without this call
|
|
50
|
+
/** Attach once, after constructing all levels and before a Lod first renders. Objects without this call draw with their original shaders. */
|
|
51
51
|
apply(root: Object3D, { amplitude, baseY, height }: SwayOptions): void;
|
|
52
52
|
/** Attach meshes arriving with a deferred level; existing meshes retain their bounds. */
|
|
53
53
|
private attach;
|