@margoengine/shader 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +1771 -3
- package/dist/black-hole.d.ts +246 -0
- package/dist/black-hole.js +445 -0
- package/dist/clock-BLGNexlt.js +52 -0
- package/dist/clock.d.ts +42 -0
- package/dist/compute-D-BghbXj.js +354 -0
- package/dist/compute-texture.d.ts +100 -0
- package/dist/compute-texture.js +131 -0
- package/dist/compute-volume.d.ts +57 -0
- package/dist/compute-volume.js +130 -0
- package/dist/compute.d.ts +194 -0
- package/dist/control-DvjfV7R0.js +201 -0
- package/dist/control.d.ts +93 -0
- package/dist/deform.d.ts +111 -0
- package/dist/deform.js +89 -0
- package/dist/display-BrJM_Qkd.js +5 -0
- package/dist/editor-model.d.ts +192 -0
- package/dist/editor-pass.d.ts +71 -0
- package/dist/editor-pass.js +216 -0
- package/dist/editor.d.ts +150 -0
- package/dist/editor.js +1071 -0
- package/dist/effects.d.ts +150 -0
- package/dist/effects.js +87 -0
- package/dist/errors-CsQwshHA.js +7 -0
- package/dist/glsl/emit.d.ts +43 -0
- package/dist/glsl/host.d.ts +55 -0
- package/dist/glsl/material.d.ts +173 -0
- package/dist/glsl/parser.d.ts +76 -0
- package/dist/glsl/preprocess.d.ts +9 -0
- package/dist/glsl/presets.d.ts +33 -0
- package/dist/glsl/program.d.ts +210 -0
- package/dist/glsl/scene.d.ts +9 -0
- package/dist/glsl-material.d.ts +82 -0
- package/dist/glsl-material.js +288 -0
- package/dist/glsl-pass.d.ts +93 -0
- package/dist/glsl-pass.js +186 -0
- package/dist/glsl.d.ts +94 -0
- package/dist/glsl.js +170 -0
- package/dist/gpu-DQ5Jmggz.js +31 -0
- package/dist/graph.d.ts +82 -0
- package/dist/graph.js +365 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/lighting-Dx8_RsBz.js +77 -0
- package/dist/lighting.d.ts +62 -0
- package/dist/lighting.js +1 -0
- package/dist/material-CU7p-Q8u.js +1184 -0
- package/dist/material-REzUrXtu.js +275 -0
- package/dist/material.d.ts +74 -0
- package/dist/node-DzKv9CF2.js +590 -0
- package/dist/node.d.ts +427 -0
- package/dist/noise.d.ts +38 -0
- package/dist/noise.js +107 -0
- package/dist/own-stack-D1XnXrrz.js +11 -0
- package/dist/own-stack.d.ts +12 -0
- package/dist/pass.d.ts +108 -0
- package/dist/pass.js +236 -0
- package/dist/post-DC62ZleD.js +113 -0
- package/dist/post.d.ts +69 -0
- package/dist/preprocess-CWGWlBWQ.js +1195 -0
- package/dist/raw-D0W8U3Qa.js +1351 -0
- package/dist/raw.d.ts +634 -0
- package/dist/raw.js +1 -0
- package/dist/readback.d.ts +42 -0
- package/dist/readback.js +84 -0
- package/dist/scope.d.ts +21 -0
- package/dist/serialization.d.ts +11 -0
- package/dist/serialization.js +192 -0
- package/dist/shadertoy/sound.d.ts +48 -0
- package/dist/shadertoy.d.ts +249 -0
- package/dist/shadertoy.js +909 -0
- package/dist/shared/caster.d.ts +152 -0
- package/dist/shared/fog.d.ts +33 -0
- package/dist/shared/fractal.d.ts +9 -0
- package/dist/shared/msaa.d.ts +25 -0
- package/dist/shared/stack.d.ts +22 -0
- package/dist/sound-CF_dzP41.js +78 -0
- package/dist/storage-format-DWaiSxmq.js +25 -0
- package/dist/storage-format.d.ts +7 -0
- package/dist/subgroups.d.ts +97 -0
- package/dist/subgroups.js +95 -0
- package/dist/texture-D6vy0bam.js +62 -0
- package/dist/texture-array.d.ts +7 -0
- package/dist/texture-array.js +11 -0
- package/dist/texture.d.ts +16 -0
- package/dist/utils.d.ts +106 -0
- package/dist/utils.js +90 -0
- package/dist/view-rect-Bm1ac-TK.js +16 -0
- package/package.json +151 -6
package/dist/raw.d.ts
ADDED
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel, Mesh } from '@margoengine/core';
|
|
3
|
+
import type { Engine, EnginePlugin, FrameGraph, PassContext } from '@margoengine/core/extension';
|
|
4
|
+
import type { BindableTexture } from './texture.js';
|
|
5
|
+
type RawPassContext = Extract<PassContext, {
|
|
6
|
+
backend: 'webgpu';
|
|
7
|
+
}>;
|
|
8
|
+
/** WGSL types of a {@link RawMesh} attribute: 32-bit scalars and 2-4 component vectors of f32, i32 or u32. */
|
|
9
|
+
export type RawAttributeType = 'f32' | 'vec2f' | 'vec3f' | 'vec4f' | 'i32' | 'vec2i' | 'vec3i' | 'vec4i' | 'u32' | 'vec2u' | 'vec3u' | 'vec4u';
|
|
10
|
+
/** WGSL types of a {@link RawShaderMaterial} uniform: every attribute type plus `mat3x3f` and `mat4x4f` (column-major). */
|
|
11
|
+
export type RawUniformType = RawAttributeType | 'mat3x3f' | 'mat4x4f';
|
|
12
|
+
/** One named vertex input. `data` holds `count x components` numbers; `step: 'instance'` advances once per instance. */
|
|
13
|
+
export interface RawAttribute {
|
|
14
|
+
data: ArrayLike<number>;
|
|
15
|
+
type: RawAttributeType;
|
|
16
|
+
/** Default `'vertex'`. */
|
|
17
|
+
step?: 'vertex' | 'instance';
|
|
18
|
+
}
|
|
19
|
+
/** One value of a {@link RawUniform}: a number, a colour string or the numbers of a vector or matrix. */
|
|
20
|
+
export type RawUniformValue = number | string | ArrayLike<number>;
|
|
21
|
+
/**
|
|
22
|
+
* A live uniform: assign `material.uniforms.name.value` any time. A number is an f32 (or the scalar of
|
|
23
|
+
* `type`), 2/3/4/9/16 numbers a vecNf/mat3x3f/mat4x4f, and `'#rrggbb'`/`0xrrggbb` with a vec3f type an sRGB colour
|
|
24
|
+
* decoded to linear. `count` makes an array, whose value is a list of elements or all their numbers in a row. `struct` makes
|
|
25
|
+
* a struct, whose value is an object of fields (with `count`, a list of them). `type`, `count` and `struct` are fixed at
|
|
26
|
+
* construction.
|
|
27
|
+
*/
|
|
28
|
+
export interface RawUniform {
|
|
29
|
+
value: RawUniformValue | readonly RawUniformValue[] | Readonly<Record<string, RawUniformValue>> | readonly Readonly<Record<string, RawUniformValue>>[];
|
|
30
|
+
readonly type?: RawUniformType;
|
|
31
|
+
/**
|
|
32
|
+
* Elements of an `array<type, count>`, read as `uniforms.<name>[i]`. A uniform array's stride is a multiple of 16 bytes, so
|
|
33
|
+
* the element is a vec3, a vec4, a matrix or a struct; a storage buffer holds tighter arrays.
|
|
34
|
+
*/
|
|
35
|
+
readonly count?: number;
|
|
36
|
+
/** Field names and types of a struct, read as `uniforms.<name>.<field>`. A field is not itself an array or a struct. */
|
|
37
|
+
readonly struct?: Readonly<Record<string, RawUniformType>>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A storage buffer a raw shader reads, declared `<name>:array<type>`. A `storage()` node of `@margoengine/shader` fits as it
|
|
41
|
+
* is, so a compute pass can fill what a mesh draws.
|
|
42
|
+
*/
|
|
43
|
+
export interface RawStorage {
|
|
44
|
+
/**
|
|
45
|
+
* A buffer with STORAGE usage on the engine's device, or a function that gives one for a device (called each time the
|
|
46
|
+
* material's bind group is checked, so it should return the same buffer until it means to change). Live. A plain
|
|
47
|
+
* buffer is lost with its device: the material binds a zeroed stand-in, `engine.onError` hears of it once (`'state'`,
|
|
48
|
+
* #borrowed-lost), and assigning a new buffer brings it back; a function is called again on the new device.
|
|
49
|
+
*/
|
|
50
|
+
buffer: GPUBuffer | ((device: GPUDevice) => GPUBuffer);
|
|
51
|
+
/** WGSL element type: a built-in type, or a struct your code declares in every stage that reads the buffer. */
|
|
52
|
+
readonly type: string;
|
|
53
|
+
/** Default `'read'`, bound to both stages. `'read_write'` is bound to the fragment stage only, as WebGPU requires. */
|
|
54
|
+
readonly access?: 'read' | 'read_write';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One extra bind group, read at `@group(2)` then `@group(3)` by bindings your WGSL declares. Called once per device, so a
|
|
58
|
+
* restored device gets a new group.
|
|
59
|
+
*/
|
|
60
|
+
export type RawBindGroup = (device: GPUDevice) => {
|
|
61
|
+
layout: GPUBindGroupLayout;
|
|
62
|
+
group: GPUBindGroup;
|
|
63
|
+
};
|
|
64
|
+
/** A texture a raw shader samples: a GPUTexture or view on the engine's device, or a `@margoengine/materials` Texture. */
|
|
65
|
+
export type RawTextureSource = GPUTexture | GPUTextureView | BindableTexture;
|
|
66
|
+
/** What a raw texture binding takes: a texture source, or `(device) => GPUTexture | GPUTextureView`, called once per device. */
|
|
67
|
+
export type RawTextureInput = RawTextureSource | ((device: GPUDevice) => GPUTexture | GPUTextureView);
|
|
68
|
+
/**
|
|
69
|
+
* A named texture binding: `<name>` and `<name>Sampler` in WGSL. `texture` and `sampler` are live; the rest is fixed.
|
|
70
|
+
* Written as a plain object; any class instance (a GPUTexture or view on either backend, a materials Texture) is taken
|
|
71
|
+
* as the texture itself.
|
|
72
|
+
*/
|
|
73
|
+
export interface RawTexture {
|
|
74
|
+
/**
|
|
75
|
+
* Opaque white (zero for integer textures) while null. A function `(device) => texture` is called once per device, so
|
|
76
|
+
* the texture is back after a device restore. A plain GPUTexture or view is lost with its device: the binding reads
|
|
77
|
+
* opaque white, `engine.onError` hears of it once (`'state'`, #borrowed-lost), and assigning a new texture brings it back.
|
|
78
|
+
*/
|
|
79
|
+
texture: RawTextureInput | null;
|
|
80
|
+
/** Sampler for a GPUTexture or view (default linear, clamp to edge); a materials Texture brings its own unless this is set. */
|
|
81
|
+
sampler?: GPUSamplerDescriptor;
|
|
82
|
+
/** Default `'2d'`. */
|
|
83
|
+
dimension?: '2d' | '2d-array' | 'cube' | '3d';
|
|
84
|
+
/**
|
|
85
|
+
* Default `'float'` (filterable). Integer textures read with textureLoad. `'depth'` binds a depth texture
|
|
86
|
+
* (`texture_depth_2d`, `_cube` or `_2d_array`) with a comparison sampler (`sampler_comparison`, for
|
|
87
|
+
* `textureSampleCompare`); its `sampler.compare` defaults to `'less-equal'`.
|
|
88
|
+
*/
|
|
89
|
+
sampleType?: 'float' | 'unfilterable-float' | 'sint' | 'uint' | 'depth';
|
|
90
|
+
}
|
|
91
|
+
/** Colour blending of a {@link RawShaderMaterial}: a named preset or a WebGPU blend state. */
|
|
92
|
+
export type RawBlending = 'none' | 'normal' | 'additive' | 'subtractive' | 'multiply' | 'premultiplied' | GPUBlendState;
|
|
93
|
+
/** Options for `new RawShaderMaterial(options)`. Render state fields stay live on the material. */
|
|
94
|
+
export interface RawShaderMaterialOptions {
|
|
95
|
+
/** WGSL with a `@vertex fn` (and the `@fragment fn` too when `fragmentShader` is omitted). */
|
|
96
|
+
vertexShader: string;
|
|
97
|
+
/** WGSL with a `@fragment fn`, compiled as its own module (both may then use `main`). */
|
|
98
|
+
fragmentShader?: string;
|
|
99
|
+
/** Vertex entry point name; default the first `@vertex fn` found. */
|
|
100
|
+
vertexEntry?: string;
|
|
101
|
+
/** Fragment entry point name; default the first `@fragment fn` found. */
|
|
102
|
+
fragmentEntry?: string;
|
|
103
|
+
/** Named live uniforms, read as `uniforms.<name>` in WGSL. */
|
|
104
|
+
uniforms?: Record<string, RawUniform>;
|
|
105
|
+
/** Named textures, read as `<name>` with `<name>Sampler` in WGSL. */
|
|
106
|
+
textures?: Record<string, RawTextureInput | RawTexture | null>;
|
|
107
|
+
/** Named storage buffers, read as `<name>[i]` in WGSL. */
|
|
108
|
+
storage?: Record<string, RawStorage>;
|
|
109
|
+
/** At most two extra bind groups, at `@group(2)` and `@group(3)`. */
|
|
110
|
+
groups?: readonly RawBindGroup[];
|
|
111
|
+
/**
|
|
112
|
+
* A `@fragment fn` of the fragment code that returns `margoGBuffer(worldNormal, worldPosition, ambient)`, drawn when the
|
|
113
|
+
* RawShaders is added to SSAO. It gives SSAO the shader's own normals and the ambient light to darken. Without it the mesh's
|
|
114
|
+
* depth still occludes and its pixels are not darkened.
|
|
115
|
+
*/
|
|
116
|
+
gbufferEntry?: string;
|
|
117
|
+
/**
|
|
118
|
+
* A `@vertex fn` of the vertex code that returns `margoVelocity(position, positionBefore)`: where the vertex is now and
|
|
119
|
+
* where it was last frame, both before `mesh.world`. Drawn when the RawShaders is added to TAA (`taa.add(raw)`), it gives
|
|
120
|
+
* TAA the motion of a shape the shader moves, so the shape leaves no ghost trail. It reads `margoBefore.time` (last
|
|
121
|
+
* frame's `camera.time`) and `margoBefore.world`; keep last frame's value of any uniform the move reads beside it. It
|
|
122
|
+
* draws with `depthCompare: 'equal'` against the vertex entry's depth: compute that position as `margoVelocity` does
|
|
123
|
+
* and declare it `@invariant`, as `MargoVelocity` is. A mesh without it gets TAA's camera motion only, from its depth.
|
|
124
|
+
* Default none.
|
|
125
|
+
*/
|
|
126
|
+
velocityEntry?: string;
|
|
127
|
+
/** Draw after the opaque scene, sorted back to front, with blending. Default false. */
|
|
128
|
+
transparent?: boolean;
|
|
129
|
+
/** Default `'normal'`, which blends only when `transparent`. */
|
|
130
|
+
blending?: RawBlending;
|
|
131
|
+
/** Reversed-Z `greater-equal` test against the scene depth. Default true. */
|
|
132
|
+
depthTest?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* The depth test's comparison while `depthTest` is true, in Margo's reversed Z (nearer is greater). Default
|
|
135
|
+
* `'greater-equal'`.
|
|
136
|
+
*/
|
|
137
|
+
depthCompare?: GPUCompareFunction;
|
|
138
|
+
/**
|
|
139
|
+
* Constant depth bias in units of the depth format's smallest step, as WebGPU's `depthBias`; positive values move
|
|
140
|
+
* the surface nearer in reversed Z. Triangles only. Default 0.
|
|
141
|
+
*/
|
|
142
|
+
depthBias?: number;
|
|
143
|
+
/** Depth bias per unit of depth slope, as WebGPU's `depthBiasSlopeScale`. Triangles only. Default 0. */
|
|
144
|
+
depthBiasSlopeScale?: number;
|
|
145
|
+
/** Alpha to coverage: the fragment's alpha masks MSAA samples. Only acts on multisampled targets. Default false. */
|
|
146
|
+
alphaToCoverage?: boolean;
|
|
147
|
+
/** Default true. */
|
|
148
|
+
depthWrite?: boolean;
|
|
149
|
+
/** Faces to cull, counter-clockwise front. Default `'back'`. */
|
|
150
|
+
cull?: 'back' | 'front' | 'none';
|
|
151
|
+
/** Write colour (false: depth only, e.g. an occluder). Default true. */
|
|
152
|
+
colorWrite?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Draw a triangle mesh's edges as a line list, each edge once (lines are 1 pixel wide in WebGPU). Live. Default false.
|
|
155
|
+
*/
|
|
156
|
+
wireframe?: boolean;
|
|
157
|
+
/** Debug and error-message name. Default `'raw:<n>'`. */
|
|
158
|
+
name?: string;
|
|
159
|
+
}
|
|
160
|
+
interface Field {
|
|
161
|
+
name: string;
|
|
162
|
+
type: RawUniformType;
|
|
163
|
+
offset: number;
|
|
164
|
+
}
|
|
165
|
+
interface Member {
|
|
166
|
+
name: string;
|
|
167
|
+
/** A uniform type, or the generated struct's name. */
|
|
168
|
+
type: string;
|
|
169
|
+
offset: number;
|
|
170
|
+
/** Elements of an array, and the bytes from one to the next (a struct's size when it is not an array). */
|
|
171
|
+
count?: number;
|
|
172
|
+
stride?: number;
|
|
173
|
+
fields?: Field[];
|
|
174
|
+
}
|
|
175
|
+
/** Which pipeline of a material: the colour pass, a shadow cascade, SSAO's G-buffer or a pick. */
|
|
176
|
+
type RawPass = 'color' | 'shadow' | 'gbuffer' | 'pick' | 'velocity';
|
|
177
|
+
interface PipelineEntry {
|
|
178
|
+
state: 'pending' | 'ready' | 'failed';
|
|
179
|
+
pipeline?: GPURenderPipeline;
|
|
180
|
+
}
|
|
181
|
+
interface MaterialGpu {
|
|
182
|
+
layout?: GPUBindGroupLayout;
|
|
183
|
+
pipelineLayout: GPUPipelineLayout;
|
|
184
|
+
/** The velocity pass's: group 0 also holds last frame's block. Made on first use. */
|
|
185
|
+
velocityLayout?: GPUPipelineLayout;
|
|
186
|
+
/** Groups 1 and up of `pipelineLayout`. */
|
|
187
|
+
groupLayouts: GPUBindGroupLayout[];
|
|
188
|
+
buffer?: GPUBuffer;
|
|
189
|
+
written?: Uint8Array;
|
|
190
|
+
group?: GPUBindGroup;
|
|
191
|
+
bound: unknown[];
|
|
192
|
+
/** The groups of `groups`, bound after `group`. */
|
|
193
|
+
extras: GPUBindGroup[];
|
|
194
|
+
pass?: number;
|
|
195
|
+
modules: Map<string, GPUShaderModule>;
|
|
196
|
+
pipelines: Map<string, PipelineEntry>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Raw shader material for WebGPU: your own WGSL vertex and fragment entry points, drawn by {@link RawShaders} in
|
|
200
|
+
* the scene's colour and depth pass. A prelude in front of your code declares what you can read: `camera` (view,
|
|
201
|
+
* projection, viewProjection, position, time, resolution, deltaTime, viewport: the view drawn as x, y, width and
|
|
202
|
+
* height in target pixels), `mesh` (world, normal), `uniforms.<name>`, each
|
|
203
|
+
* texture `<name>` with `<name>Sampler`, each storage buffer `<name>`, the `Attributes` struct of the drawn RawMesh, and
|
|
204
|
+
* `margoDisplay(c)` / `margoEncode(c)` to output linear colour like the rest of the scene. Fragment output is written as
|
|
205
|
+
* returned.
|
|
206
|
+
* WGSL errors are reported (`error`, `onError`, else console.error) and that draw is skipped; other draws continue.
|
|
207
|
+
*/
|
|
208
|
+
export declare class RawShaderMaterial<U extends {
|
|
209
|
+
value: unknown;
|
|
210
|
+
} = RawUniform> {
|
|
211
|
+
readonly name: string;
|
|
212
|
+
/**
|
|
213
|
+
* Live values; names and types are fixed at construction. `U` is the entry a subclass shows (ShaderMaterial of
|
|
214
|
+
* `@margoengine/shader/glsl-material` shows its GLSL uniforms); a RawShaderMaterial holds RawUniforms.
|
|
215
|
+
*/
|
|
216
|
+
readonly uniforms: Record<string, U>;
|
|
217
|
+
/** Live `texture` and `sampler`; names, dimension and sample type are fixed at construction. */
|
|
218
|
+
readonly textures: Record<string, RawTexture>;
|
|
219
|
+
/** Live `buffer`; names, types and access are fixed at construction. */
|
|
220
|
+
readonly storage: Record<string, RawStorage>;
|
|
221
|
+
transparent: boolean;
|
|
222
|
+
blending: RawBlending;
|
|
223
|
+
depthTest: boolean;
|
|
224
|
+
depthCompare: GPUCompareFunction;
|
|
225
|
+
depthBias: number;
|
|
226
|
+
depthBiasSlopeScale: number;
|
|
227
|
+
alphaToCoverage: boolean;
|
|
228
|
+
depthWrite: boolean;
|
|
229
|
+
cull: 'back' | 'front' | 'none';
|
|
230
|
+
colorWrite: boolean;
|
|
231
|
+
/** Draws triangle meshes as their edges. */
|
|
232
|
+
wireframe: boolean;
|
|
233
|
+
/** Called with a MargoError `'failed'` naming the stage, line and WGSL message when a pipeline does not compile. */
|
|
234
|
+
onError?: (error: Error) => void;
|
|
235
|
+
/** The latest compile error, or undefined. */
|
|
236
|
+
error?: Error;
|
|
237
|
+
/** @internal Uniform block members with byte offsets; `size` is the block size in bytes. */
|
|
238
|
+
readonly members: readonly Member[];
|
|
239
|
+
/** @internal */ readonly size: number;
|
|
240
|
+
/** @internal */ readonly gpu: Map<GPUDevice, MaterialGpu>;
|
|
241
|
+
/** @internal Bumped when the shader code changes. */ revision: number;
|
|
242
|
+
/** @internal Pipelines finished so far: a static shadow map redraws when a caster's pipeline arrives. */ compiled: number;
|
|
243
|
+
private readonly groups;
|
|
244
|
+
private readonly gbufferName?;
|
|
245
|
+
/** @internal The `velocityEntry`, when the material draws its own motion for TAA. */ readonly velocityName?: string;
|
|
246
|
+
private vertexCode;
|
|
247
|
+
private fragmentCode?;
|
|
248
|
+
private vertexName;
|
|
249
|
+
private fragmentName;
|
|
250
|
+
private readonly entries;
|
|
251
|
+
private readonly data;
|
|
252
|
+
private readonly bytes;
|
|
253
|
+
constructor(options: RawShaderMaterialOptions);
|
|
254
|
+
/** WGSL of the vertex stage (assigning recompiles on the next frame). */
|
|
255
|
+
get vertexShader(): string;
|
|
256
|
+
set vertexShader(code: string);
|
|
257
|
+
/** WGSL of the fragment stage, or undefined when the vertex code holds both entry points. */
|
|
258
|
+
get fragmentShader(): string | undefined;
|
|
259
|
+
set fragmentShader(code: string | undefined);
|
|
260
|
+
private setCode;
|
|
261
|
+
/** The declarations added in front of each stage for `mesh` (its `Attributes` struct) or for no attributes. */
|
|
262
|
+
prelude(mesh?: RawMesh): string;
|
|
263
|
+
/** The whole WGSL module of `stage` for `mesh`: the prelude, then your code. */
|
|
264
|
+
code(stage: 'vertex' | 'fragment', mesh?: RawMesh): string;
|
|
265
|
+
/** Releases this material's GPU objects; it rebuilds them if drawn again. */
|
|
266
|
+
dispose(): void;
|
|
267
|
+
[Symbol.dispose]: () => void;
|
|
268
|
+
/** @internal The render-state part of a pipeline key. */
|
|
269
|
+
state(): string;
|
|
270
|
+
/** @internal */
|
|
271
|
+
blend(): GPUBlendState | undefined;
|
|
272
|
+
/** @internal The RawShaders that drew this material last: the scene values of `ShaderMaterial` lights and fog come from it. */
|
|
273
|
+
drawnBy?: RawShaders;
|
|
274
|
+
/** @internal Uploads changed uniforms and (re)builds the material bind group, once per plugin pass. */
|
|
275
|
+
prepare(device: GPUDevice, pass: number, owner?: RawShaders): MaterialGpu;
|
|
276
|
+
private write;
|
|
277
|
+
private put;
|
|
278
|
+
/** @internal True when the G-buffer pass has a fragment to draw. */
|
|
279
|
+
get writesGBuffer(): boolean;
|
|
280
|
+
/** @internal What differs between the pipelines of one material: the fragment, its targets and the depth state. */
|
|
281
|
+
private target;
|
|
282
|
+
private bias;
|
|
283
|
+
/** @internal The pipeline for `key`, compiling it on first use; undefined while pending or after a failure. */
|
|
284
|
+
pipeline(plugin: RawShaders, gpu: MaterialGpu, device: GPUDevice, mesh: RawMesh, kind: RawPass, c?: RawPassContext, compare?: GPUCompareFunction): GPURenderPipeline | undefined;
|
|
285
|
+
}
|
|
286
|
+
/** Interleaved CPU copy of one step mode's attributes, uploaded whole or by element range. */
|
|
287
|
+
/**
|
|
288
|
+
* A mesh's GPU buffer. Meshes whose packed bytes are equal hold one, counted per device, so draws in a row skip
|
|
289
|
+
* rebinding it. `words` is a copy of those bytes, kept while others may join; a mesh leaves on its first write.
|
|
290
|
+
*/
|
|
291
|
+
interface HeldBuffer {
|
|
292
|
+
buffer: GPUBuffer;
|
|
293
|
+
users: number;
|
|
294
|
+
usage: number;
|
|
295
|
+
label: string;
|
|
296
|
+
key?: string;
|
|
297
|
+
words?: Uint32Array;
|
|
298
|
+
/** Set by {@link ownBuffer} on a new copy: it already holds the mesh's current bytes. */
|
|
299
|
+
fresh?: boolean;
|
|
300
|
+
}
|
|
301
|
+
interface MeshGpu {
|
|
302
|
+
device: GPUDevice;
|
|
303
|
+
/** The index buffer holds the wireframe's edges. */
|
|
304
|
+
wire?: boolean;
|
|
305
|
+
object: GPUBuffer;
|
|
306
|
+
written?: Float32Array;
|
|
307
|
+
vertex?: HeldBuffer;
|
|
308
|
+
instance?: HeldBuffer;
|
|
309
|
+
index?: HeldBuffer;
|
|
310
|
+
/** The group of the latest upload, and one per camera block: colour, each shadow cascade, pick. */
|
|
311
|
+
group?: GPUBindGroup;
|
|
312
|
+
groups: Map<GPUBuffer, GPUBindGroup>;
|
|
313
|
+
}
|
|
314
|
+
/** What one render pass has bound, so draws in a row that share a buffer do not bind it again. */
|
|
315
|
+
interface BoundBuffers {
|
|
316
|
+
slots: (GPUBuffer | undefined)[];
|
|
317
|
+
index?: GPUBuffer;
|
|
318
|
+
format?: GPUIndexFormat;
|
|
319
|
+
}
|
|
320
|
+
/** A sphere around a {@link RawMesh} in its own space, moved by its world matrix. */
|
|
321
|
+
export interface RawBounds {
|
|
322
|
+
center: readonly [number, number, number];
|
|
323
|
+
radius: number;
|
|
324
|
+
}
|
|
325
|
+
/** What `Shadows` hands a {@link RawMesh} for one cascade. */
|
|
326
|
+
export interface RawShadowContext {
|
|
327
|
+
context: RawPassContext;
|
|
328
|
+
/** The cascade's open depth pass. */
|
|
329
|
+
pass: GPURenderPassEncoder;
|
|
330
|
+
/** The cascade's light view-projection matrix. */
|
|
331
|
+
matrix: Float32Array;
|
|
332
|
+
/** Cascade index, 0-3. */
|
|
333
|
+
cascade: number;
|
|
334
|
+
}
|
|
335
|
+
/** Any raw material: a RawShaderMaterial or a subclass such as ShaderMaterial. */
|
|
336
|
+
export type AnyRawShaderMaterial = RawShaderMaterial<{
|
|
337
|
+
value: unknown;
|
|
338
|
+
}>;
|
|
339
|
+
/** Options for `new RawMesh(options)`. */
|
|
340
|
+
export interface RawMeshOptions<M extends AnyRawShaderMaterial = AnyRawShaderMaterial> {
|
|
341
|
+
/** The material that draws it; assignable later (`mesh.material = other`). */
|
|
342
|
+
material: M;
|
|
343
|
+
/** Named attributes; shader locations follow this order (the prelude's `Attributes` struct names them). At most 16. */
|
|
344
|
+
attributes?: Record<string, RawAttribute>;
|
|
345
|
+
/** Triangle (or line/point) indices; omit to draw vertices in order. */
|
|
346
|
+
index?: Uint16Array | Uint32Array | readonly number[] | null;
|
|
347
|
+
/** Instances to draw; default the per-instance attributes' element count, or 1. */
|
|
348
|
+
instanceCount?: number;
|
|
349
|
+
/** Vertices to draw when there are no per-vertex attributes (vertex pulling). */
|
|
350
|
+
vertexCount?: number;
|
|
351
|
+
/** Default `'triangle-list'`. */
|
|
352
|
+
topology?: GPUPrimitiveTopology;
|
|
353
|
+
/** Model matrix (column-major), live in `mesh.matrix`. Default identity. */
|
|
354
|
+
matrix?: ArrayLike<number>;
|
|
355
|
+
/** Follow a core mesh: world = that mesh's world matrix x `matrix`. Hidden with it. */
|
|
356
|
+
mesh?: Mesh | null;
|
|
357
|
+
/** Lower draws first within the opaque or transparent group. Default 0. */
|
|
358
|
+
renderOrder?: number;
|
|
359
|
+
/** Default true. */
|
|
360
|
+
visible?: boolean;
|
|
361
|
+
/** Skip the mesh when its bounds are out of view. Default true. */
|
|
362
|
+
frustumCulled?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* The sphere to cull with. Default: the sphere around a per-vertex vec3f `position`. A mesh with neither, or an instanced one
|
|
365
|
+
* with no `bounds`, is never culled. Give `bounds` (or `frustumCulled: false`) when the vertex shader moves points outside.
|
|
366
|
+
*/
|
|
367
|
+
bounds?: RawBounds | null;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Geometry for a {@link RawShaderMaterial}: any named attributes (per vertex or per instance), an optional index buffer and
|
|
371
|
+
* an instance count. Add it to a {@link RawShaders} plugin to draw it.
|
|
372
|
+
* Per-vertex and per-instance attributes are each interleaved into one vertex buffer; `setAttribute` updates are live.
|
|
373
|
+
*/
|
|
374
|
+
export declare class RawMesh<M extends AnyRawShaderMaterial = AnyRawShaderMaterial> {
|
|
375
|
+
/** The material that draws it; `mesh.material.uniforms` keeps that material's uniform types. */
|
|
376
|
+
material: M;
|
|
377
|
+
readonly matrix: Float32Array;
|
|
378
|
+
/** Core mesh to follow, or null. */
|
|
379
|
+
mesh: Mesh | null;
|
|
380
|
+
visible: boolean;
|
|
381
|
+
renderOrder: number;
|
|
382
|
+
instanceCount?: number;
|
|
383
|
+
vertexCount?: number;
|
|
384
|
+
topology: GPUPrimitiveTopology;
|
|
385
|
+
frustumCulled: boolean;
|
|
386
|
+
/** The sphere to cull with; null uses the one around `position`. */
|
|
387
|
+
bounds: RawBounds | null;
|
|
388
|
+
/** First index (or vertex) and count to draw; count is clamped to what exists. */
|
|
389
|
+
readonly drawRange: {
|
|
390
|
+
start: number;
|
|
391
|
+
count: number;
|
|
392
|
+
};
|
|
393
|
+
/** @internal */ owner?: RawShaders;
|
|
394
|
+
/** @internal */ gpu?: MeshGpu;
|
|
395
|
+
private readonly streams;
|
|
396
|
+
private readonly map;
|
|
397
|
+
private indices;
|
|
398
|
+
private indexDirty;
|
|
399
|
+
private key;
|
|
400
|
+
/** True after `dispose`: `Shadows` drops the mesh. */
|
|
401
|
+
disposed: boolean;
|
|
402
|
+
private changes;
|
|
403
|
+
private sphere;
|
|
404
|
+
private readonly world;
|
|
405
|
+
private readonly object;
|
|
406
|
+
constructor(options: RawMeshOptions<M>);
|
|
407
|
+
/** @internal What the pipeline draws: a triangle topology as a line list while the material is a wireframe. */
|
|
408
|
+
get drawTopology(): GPUPrimitiveTopology;
|
|
409
|
+
private wire?;
|
|
410
|
+
private edges;
|
|
411
|
+
/** Attributes in location order. */
|
|
412
|
+
get layout(): readonly {
|
|
413
|
+
name: string;
|
|
414
|
+
type: RawAttributeType;
|
|
415
|
+
step: 'vertex' | 'instance';
|
|
416
|
+
}[];
|
|
417
|
+
/** @internal Attribute names, types and steps: equal keys share pipelines. */
|
|
418
|
+
get layoutKey(): string;
|
|
419
|
+
/** @internal */
|
|
420
|
+
get indexFormat(): GPUIndexFormat | undefined;
|
|
421
|
+
/** The attribute's current data and layout, or undefined. */
|
|
422
|
+
getAttribute(name: string): RawAttribute | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* Live attribute update. `{data, type, step?}` adds or redefines `name` (a new layout compiles a new pipeline); plain
|
|
425
|
+
* data replaces the values of an existing attribute. `range` = [first element, element count] uploads only those
|
|
426
|
+
* elements of `data` (vertices or instances), which must then keep its length.
|
|
427
|
+
* @throws TypeError for an unknown name with plain data, a bad type or name; RangeError for a length that is not
|
|
428
|
+
* a whole number of elements, a bad range or more than 16 attributes.
|
|
429
|
+
*/
|
|
430
|
+
setAttribute(name: string, data: RawAttribute | ArrayLike<number>, range?: readonly [number, number]): this;
|
|
431
|
+
/** Removes an attribute (the layout changes, so the next draw compiles a new pipeline). */
|
|
432
|
+
removeAttribute(name: string): this;
|
|
433
|
+
/**
|
|
434
|
+
* Replaces the index buffer (Uint16Array, Uint32Array or numbers, which become Uint32Array), or removes it with null.
|
|
435
|
+
* @throws RangeError for a negative or non-integer index.
|
|
436
|
+
*/
|
|
437
|
+
setIndex(index: Uint16Array | Uint32Array | readonly number[] | null): this;
|
|
438
|
+
/** Bumped when a static shadow map must draw this mesh again; `invalidateShadow` bumps it for a moved mesh. */
|
|
439
|
+
get shadowVersion(): number;
|
|
440
|
+
/** Redraws a mesh added with `shadows.add(mesh, {static: true})` after its matrix or material changed. */
|
|
441
|
+
invalidateShadow(): void;
|
|
442
|
+
/** Draws the mesh into a cascade of `@margoengine/shadows`; pass the mesh to `shadows.add`. */
|
|
443
|
+
drawShadow(context: RawShadowContext): void;
|
|
444
|
+
/** Releases the GPU buffers and leaves its RawShaders plugin; the mesh cannot be drawn again. */
|
|
445
|
+
dispose(): void;
|
|
446
|
+
[Symbol.dispose]: () => void;
|
|
447
|
+
/** @internal */
|
|
448
|
+
alive(): void;
|
|
449
|
+
private changed;
|
|
450
|
+
/** The sphere around `position` as [x, y, z, radius], when its points are where the mesh draws. */
|
|
451
|
+
private ownBounds;
|
|
452
|
+
/**
|
|
453
|
+
* @internal True when the mesh's sphere lies wholly outside view-projection `m`. The six planes are sums of the matrix's rows
|
|
454
|
+
* (Gribb and Hartmann 2001). Each is compared unnormalised, as reversed-Z with an infinite far plane has one of zero length.
|
|
455
|
+
*/
|
|
456
|
+
culled(world: ArrayLike<number>, m: ArrayLike<number>): boolean;
|
|
457
|
+
private define;
|
|
458
|
+
private restructure;
|
|
459
|
+
/** @internal Vertex buffer layouts in slot order (vertex stream, then instance stream). */
|
|
460
|
+
buffers(): GPUVertexBufferLayout[];
|
|
461
|
+
/** @internal Releases GPU buffers (device restore, plugin or mesh disposal); the next draw re-uploads everything. */
|
|
462
|
+
release(): void;
|
|
463
|
+
/** @internal The world matrix (null when the followed mesh is hidden or gone). */
|
|
464
|
+
worldMatrix(engine: EngineKernel): Float32Array | null;
|
|
465
|
+
/** @internal Uploads changes and returns [first, count, instances], or undefined when there is nothing to draw. */
|
|
466
|
+
upload(device: GPUDevice, camera: GPUBuffer, world: Float32Array): [number, number, number] | undefined;
|
|
467
|
+
/** @internal */
|
|
468
|
+
draw(pass: GPURenderPassEncoder, first: number, count: number, instances: number, bound: BoundBuffers): void;
|
|
469
|
+
}
|
|
470
|
+
/** Options for `new RawShaders(options)`. */
|
|
471
|
+
export interface RawShadersOptions {
|
|
472
|
+
/** Plugin name, unique per engine. Default `'shader:raw'`. */
|
|
473
|
+
name?: string;
|
|
474
|
+
/** Frame-graph order of opaque raw meshes: after core meshes (0), before gltf\/pbr and materials meshes (1). Default 0.5. */
|
|
475
|
+
opaqueOrder?: number;
|
|
476
|
+
/** Order of transparent raw meshes: after water (4), sky (5) and particles (6), before OIT (8) and lines (20). Default 7. */
|
|
477
|
+
transparentOrder?: number;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Engine plugin that draws {@link RawMesh}es in the scene's main colour and depth targets (WebGPU), with the pass's
|
|
481
|
+
* colour format, MSAA sample count and reversed-Z depth; inside a PostStack they land in its scene capture. Opaque
|
|
482
|
+
* meshes draw in one pass, transparent ones (`material.transparent`) in a later pass sorted back to front.
|
|
483
|
+
* `ssao.add(raw)` draws the meshes whose material has `gbufferEntry` into SSAO's G-buffer.
|
|
484
|
+
*/
|
|
485
|
+
export declare class RawShaders implements EnginePlugin {
|
|
486
|
+
readonly name: string;
|
|
487
|
+
readonly opaqueOrder: number;
|
|
488
|
+
readonly transparentOrder: number;
|
|
489
|
+
/** Counters of the latest frame; `culled` is meshes out of view, `pending` is pipelines still compiling. */
|
|
490
|
+
readonly stats: {
|
|
491
|
+
meshes: number;
|
|
492
|
+
drawCalls: number;
|
|
493
|
+
culled: number;
|
|
494
|
+
pending: number;
|
|
495
|
+
};
|
|
496
|
+
/** @internal {@link RawPicking}s told when a mesh comes or goes. */ readonly watchers: Set<RawPicking>;
|
|
497
|
+
private readonly meshes;
|
|
498
|
+
private readonly jobs;
|
|
499
|
+
private engine?;
|
|
500
|
+
private device?;
|
|
501
|
+
private camera?;
|
|
502
|
+
private readonly shadowCameras;
|
|
503
|
+
private shadowEncoder?;
|
|
504
|
+
private shadowPass;
|
|
505
|
+
private readonly shadowWritten;
|
|
506
|
+
private passes;
|
|
507
|
+
private readonly cameraData;
|
|
508
|
+
private readonly view;
|
|
509
|
+
private readonly inverse;
|
|
510
|
+
/** TAA velocity state per TAA view: its camera block, last frame's time and each mesh's last world matrix. */
|
|
511
|
+
private readonly velocityStates;
|
|
512
|
+
private readonly beforeData;
|
|
513
|
+
/** @internal The latest pass token (see `nextPass`). */
|
|
514
|
+
get pass(): number;
|
|
515
|
+
/** @internal The engine whose lighting scene values read. */
|
|
516
|
+
get kernel(): EngineKernel | undefined;
|
|
517
|
+
/** Same as `engine.use(new RawShaders(...))`; returns the plugin. */
|
|
518
|
+
static attach(engine: EngineKernel, options?: RawShadersOptions): RawShaders;
|
|
519
|
+
constructor(options?: RawShadersOptions);
|
|
520
|
+
/**
|
|
521
|
+
* Draws `mesh` from the next frame on; returns it.
|
|
522
|
+
* @throws MargoError `'attached'` when it belongs to another RawShaders, `'disposed'` after `mesh.dispose()`.
|
|
523
|
+
*/
|
|
524
|
+
add<T extends RawMesh>(mesh: T): T;
|
|
525
|
+
/** Stops drawing `mesh` and releases its GPU buffers; true when it was here. */
|
|
526
|
+
remove(mesh: RawMesh): boolean;
|
|
527
|
+
/** Resolves once every pipeline compiling now has finished (or failed); render again to see them. */
|
|
528
|
+
ready(): Promise<void>;
|
|
529
|
+
/** @internal */
|
|
530
|
+
track(job: Promise<void>): void;
|
|
531
|
+
setup(engine: Engine): void;
|
|
532
|
+
registerPasses(graph: FrameGraph): void;
|
|
533
|
+
onDeviceRestored(engine: Engine): void;
|
|
534
|
+
/** Releases every GPU object; meshes stay registered, so the plugin can be attached again. */
|
|
535
|
+
dispose(): void;
|
|
536
|
+
[Symbol.dispose]: () => void;
|
|
537
|
+
private release;
|
|
538
|
+
private cameraBuffer;
|
|
539
|
+
private writeCamera;
|
|
540
|
+
/**
|
|
541
|
+
* @internal The camera block of `camera` seen through view-projection `m`: `resolution` is the target's size and
|
|
542
|
+
* `viewport` the drawn view's rectangle in target pixels (the whole target without a view).
|
|
543
|
+
*/
|
|
544
|
+
cameraBlock(camera: PassContext['camera'], m: ArrayLike<number>, width: number, height: number, delta: number, encoding: number, view?: ArrayLike<number>): Float32Array<ArrayBuffer>;
|
|
545
|
+
/** @internal The next pass token: a material uploads its uniforms once per token. */
|
|
546
|
+
nextPass(): number;
|
|
547
|
+
/** @internal Draws `mesh` into one shadow cascade. Shadow passes run before the colour pass, so it uploads for itself. */
|
|
548
|
+
shadow(mesh: RawMesh, { context: c, pass, matrix, cascade }: RawShadowContext): void;
|
|
549
|
+
/**
|
|
550
|
+
* The `SSAOSource` contract of `@margoengine/post`: meshes whose material has `gbufferEntry` write their own normals and
|
|
551
|
+
* ambient light into SSAO's open G-buffer pass, over the depth the colour pass left.
|
|
552
|
+
*/
|
|
553
|
+
draw(context: PassContext, mode: 'gbuffer' | 'ambient' | 'occlusion', _color: GPUTextureView, _depth: GPUTextureView, _phase?: 'all' | 'opaque' | 'blend', external?: {
|
|
554
|
+
pass: GPURenderPassEncoder;
|
|
555
|
+
view: ArrayLike<number>;
|
|
556
|
+
depthCompare: GPUCompareFunction;
|
|
557
|
+
}): void;
|
|
558
|
+
/**
|
|
559
|
+
* The `TAAVelocityPass` contract of `@margoengine/taa` (`taa.add(raw)`): opaque meshes whose material has
|
|
560
|
+
* `velocityEntry` draw their own motion into TAA's object velocity pass, with last frame's view-projection, world
|
|
561
|
+
* matrix and time in `margoBefore`, kept per TAA view.
|
|
562
|
+
*/
|
|
563
|
+
drawVelocity(pass: GPURenderPassEncoder, frame: {
|
|
564
|
+
context: PassContext;
|
|
565
|
+
camera: Float32Array;
|
|
566
|
+
key: object;
|
|
567
|
+
}): void;
|
|
568
|
+
/** Forgets a TAA view's velocity state (`TAAVelocityPass`): TAA calls it when the view's history goes. */
|
|
569
|
+
releaseVelocity(key: object): void;
|
|
570
|
+
private execute;
|
|
571
|
+
}
|
|
572
|
+
/** What `Picking` hands an overlay for one pick. */
|
|
573
|
+
export interface RawPickContext {
|
|
574
|
+
encoder: GPUCommandEncoder;
|
|
575
|
+
/** The r32uint pick tile, 3 x 3 pixels around the picked pixel. */
|
|
576
|
+
color: GPUTextureView;
|
|
577
|
+
/** Its depth32float depth, holding the meshes already drawn. */
|
|
578
|
+
depth: GPUTextureView;
|
|
579
|
+
/** The camera's view-projection matrix, cropped to the tile. */
|
|
580
|
+
matrix: Float32Array;
|
|
581
|
+
camera: PassContext['camera'];
|
|
582
|
+
/** The picked view's rectangle in drawing-buffer pixels. */
|
|
583
|
+
rect: readonly number[];
|
|
584
|
+
/** The ID of this overlay's item 0. */
|
|
585
|
+
firstId: number;
|
|
586
|
+
}
|
|
587
|
+
/** What `RawPicking.attach` needs of `@margoengine/selection`'s Picking. */
|
|
588
|
+
export interface RawPickHost {
|
|
589
|
+
addOverlay(overlay: {
|
|
590
|
+
drawPick(context: RawPickContext): void;
|
|
591
|
+
pickHit(index: number): {
|
|
592
|
+
mesh: Mesh;
|
|
593
|
+
} | null;
|
|
594
|
+
}): () => void;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Makes the meshes of a {@link RawShaders} pickable by `@margoengine/selection`'s `Picking`, and so by `engine.pick` once
|
|
598
|
+
* Picking is attached. They share the depth test of the scene's meshes, each with its own vertex shader, so what a shader
|
|
599
|
+
* moves is picked where it shows. One ID covers a mesh: a hit names no instance, and a fragment's `discard` does not cut it.
|
|
600
|
+
* `hit.mesh` is the mesh it follows or else an empty stand-in mesh, as `engine.pick` can only answer meshes (`rawOf` maps it
|
|
601
|
+
* back).
|
|
602
|
+
*/
|
|
603
|
+
export declare class RawPicking {
|
|
604
|
+
readonly raw: RawShaders;
|
|
605
|
+
private hits;
|
|
606
|
+
private camera?;
|
|
607
|
+
private device?;
|
|
608
|
+
private readonly id;
|
|
609
|
+
private readonly standIns;
|
|
610
|
+
private readonly owners;
|
|
611
|
+
private remove?;
|
|
612
|
+
/**
|
|
613
|
+
* Registers `raw` with `picking`; undo with `dispose`.
|
|
614
|
+
* @throws MargoError `state` when `raw` is not attached to an engine yet.
|
|
615
|
+
*/
|
|
616
|
+
static attach(picking: RawPickHost, raw: RawShaders): RawPicking;
|
|
617
|
+
private constructor();
|
|
618
|
+
/** The RawMesh behind `mesh`, a `hit.mesh` or an `engine.pick` answer; null for any other mesh. */
|
|
619
|
+
rawOf(mesh: Mesh | null): RawMesh | null;
|
|
620
|
+
/** @internal A mesh joined: its stand-in is made now, because adding a mesh during a pick would void that pick's answer. */
|
|
621
|
+
added(mesh: RawMesh): void;
|
|
622
|
+
/** @internal A mesh left: its stand-in goes with it. */
|
|
623
|
+
removed(mesh: RawMesh): void;
|
|
624
|
+
/** @internal Picking's turn: draws every visible mesh into the tile, with IDs from `firstId`. */
|
|
625
|
+
drawPick(c: RawPickContext): void;
|
|
626
|
+
/** @internal The hit of ID `index` of the last `drawPick`. */
|
|
627
|
+
pickHit(index: number): {
|
|
628
|
+
mesh: Mesh;
|
|
629
|
+
} | null;
|
|
630
|
+
/** Leaves Picking and frees the stand-in meshes and the GPU buffer. */
|
|
631
|
+
dispose(): void;
|
|
632
|
+
[Symbol.dispose]: () => void;
|
|
633
|
+
}
|
|
634
|
+
export {};
|
package/dist/raw.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as RawMesh, n as RawPicking, r as RawShaderMaterial, i as RawShaders } from "./raw-D0W8U3Qa.js";
|