@margoengine/gltf 0.0.0-stage → 1.0.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 +1753 -2
- package/dist/accessor-CU_1uSZ1.js +1 -0
- package/dist/accessor-DuqjpuxI.js +1 -0
- package/dist/accessor.d.ts +12 -0
- package/dist/asset-DN3ocEdY.js +4 -0
- package/dist/asset-entry.d.ts +1 -0
- package/dist/asset-entry.js +1 -0
- package/dist/asset.d.ts +395 -0
- package/dist/audio.d.ts +47 -0
- package/dist/audio.js +1 -0
- package/dist/auto.d.ts +29 -0
- package/dist/auto.js +1 -0
- package/dist/base-textures.d.ts +20 -0
- package/dist/coalesce.d.ts +29 -0
- package/dist/compression-CUOCmjmE.js +1 -0
- package/dist/compression.d.ts +21 -0
- package/dist/coordinates.d.ts +1 -0
- package/dist/coordinates.js +1 -0
- package/dist/dds.d.ts +7 -0
- package/dist/dds.js +1 -0
- package/dist/decoder-default-CxLH8Vz0.js +1 -0
- package/dist/decoder-default.d.ts +5 -0
- package/dist/default-materials.d.ts +10 -0
- package/dist/default-transmission.d.ts +13 -0
- package/dist/draco-state.d.ts +7 -0
- package/dist/draw-batch.d.ts +83 -0
- package/dist/draw-memo.d.ts +136 -0
- package/dist/extended.d.ts +12 -0
- package/dist/extended.js +1 -0
- package/dist/gltf.worker.d.ts +1 -0
- package/dist/group.d.ts +18 -0
- package/dist/image-limit-DvFSfR5T.js +1 -0
- package/dist/image-limit.d.ts +6 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +1 -0
- package/dist/instanced-shader-C9ZMazvo.js +5 -0
- package/dist/instanced-shader.d.ts +14 -0
- package/dist/instancing.d.ts +9 -0
- package/dist/instancing.js +1 -0
- package/dist/interactivity-graph.d.ts +193 -0
- package/dist/interactivity-model.d.ts +94 -0
- package/dist/interactivity-ops.d.ts +20 -0
- package/dist/interactivity.d.ts +33 -0
- package/dist/interactivity.js +1 -0
- package/dist/lights.d.ts +98 -0
- package/dist/lights.js +1 -0
- package/dist/limits-_LZ441oV.js +1 -0
- package/dist/material-draw-state-GKiHDb0p.js +1 -0
- package/dist/material-draw-state.d.ts +7 -0
- package/dist/material-draw.d.ts +18 -0
- package/dist/material-draw.js +1 -0
- package/dist/material-extension.d.ts +96 -0
- package/dist/mesh-source-DvU8YvMc.js +1 -0
- package/dist/meshopt.d.ts +9 -0
- package/dist/meshopt.js +1 -0
- package/dist/metadata.d.ts +114 -0
- package/dist/metadata.js +1 -0
- package/dist/mipmaps-38NmjDc3.js +21 -0
- package/dist/model-C77ATxi1.js +25 -0
- package/dist/model-entry.d.ts +2 -0
- package/dist/model-entry.js +1 -0
- package/dist/model.d.ts +1088 -0
- package/dist/native-glass-D85twud0.js +19 -0
- package/dist/node-image-decode.d.ts +6 -0
- package/dist/node-matrix-R9BipGnp.js +1 -0
- package/dist/node-matrix.d.ts +16 -0
- package/dist/occlusion.d.ts +8 -0
- package/dist/pack-DdxRO8k6.js +1 -0
- package/dist/pack.d.ts +27 -0
- package/dist/parts.d.ts +54 -0
- package/dist/pbr-instancing.d.ts +83 -0
- package/dist/pbr-instancing.js +1 -0
- package/dist/pbr.d.ts +13 -0
- package/dist/pbr.js +1 -0
- package/dist/physics.d.ts +148 -0
- package/dist/physics.js +1 -0
- package/dist/prepare.d.ts +26 -0
- package/dist/prepare.js +1 -0
- package/dist/progressive-lod.d.ts +13 -0
- package/dist/progressive.d.ts +62 -0
- package/dist/progressive.js +4 -0
- package/dist/progressive.worker.d.ts +1 -0
- package/dist/quantized.d.ts +8 -0
- package/dist/quantized.js +1 -0
- package/dist/render-state.d.ts +18 -0
- package/dist/replica.d.ts +37 -0
- package/dist/report.d.ts +128 -0
- package/dist/report.js +1 -0
- package/dist/scene-data.d.ts +61 -0
- package/dist/scene-data.js +1 -0
- package/dist/scene-scope-CZDEkd24.js +4 -0
- package/dist/scene.d.ts +61 -0
- package/dist/scene.js +4 -0
- package/dist/shader-C29RtPAw.js +409 -0
- package/dist/shader.d.ts +246 -0
- package/dist/shared/caster.d.ts +159 -0
- package/dist/shared/gltf.d.ts +257 -0
- package/dist/shared/iridescence.d.ts +2 -0
- package/dist/shared/prepared-geometry.d.ts +8 -0
- package/dist/side-shader.d.ts +1 -0
- package/dist/soft-mesh.d.ts +132 -0
- package/dist/soft-mesh.js +4 -0
- package/dist/spec-gloss.d.ts +21 -0
- package/dist/spec-gloss.js +18 -0
- package/dist/splat-state.d.ts +7 -0
- package/dist/splats.d.ts +18 -0
- package/dist/splats.js +1 -0
- package/dist/src-Btvz5f6i.js +4 -0
- package/dist/stream-CrfNNCRd.js +1 -0
- package/dist/stream.d.ts +104 -0
- package/dist/stroke-width-B2cnYGgn.js +1 -0
- package/dist/stroke-width.d.ts +18 -0
- package/dist/strokes.d.ts +12 -0
- package/dist/strokes.js +1 -0
- package/dist/texture-coordinates-XFsEMdU6.js +2 -0
- package/dist/texture-coordinates.d.ts +26 -0
- package/dist/texture-stream-Cu_XpyVO.js +4 -0
- package/dist/texture-stream.d.ts +88 -0
- package/dist/textured.d.ts +34 -0
- package/dist/textured.js +5 -0
- package/dist/transmission.d.ts +81 -0
- package/dist/transmission.js +66 -0
- package/dist/uniform-arena.d.ts +78 -0
- package/dist/version-B6NE5cJf.js +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/vertex-inputs.d.ts +53 -0
- package/dist/view-uniform.d.ts +13 -0
- package/dist/visibility-C_Oqz9Sr.js +1 -0
- package/dist/warning-UqjZyyqW.js +89 -0
- package/dist/warning.d.ts +24 -0
- package/dist/worker-CY1TQnYX.js +1 -0
- package/dist/worker.d.ts +21 -0
- package/dist/worker.js +4 -0
- package/dist/workers/gltf.js +322 -0
- package/dist/workers/progressive.js +1 -0
- package/package.json +232 -4
package/dist/shader.d.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { PassContext } from '@margoengine/core/extension';
|
|
2
|
+
export { iridescenceWgsl } from './shared/iridescence.js';
|
|
3
|
+
export declare const pbrShader: string;
|
|
4
|
+
export declare const extendedPBRShader: string;
|
|
5
|
+
/**
|
|
6
|
+
* Lighting hooks of the PBR fragment (contract version 1, README "Lighting hooks"). A `LightingEffect.pbr(group)` returns one;
|
|
7
|
+
* gltf/pbr composes it into the standard and physical shaders, so effects never search gltf/pbr's WGSL. In scope: `i` (Out),
|
|
8
|
+
* `s` (Surface: base, n, roughness, metal, occlusion, emissive), `v` (to the eye), `f` (Frame: eye, light, radiance...).
|
|
9
|
+
*/
|
|
10
|
+
export interface PBRLighting {
|
|
11
|
+
/** Module-scope WGSL put before the shader: the effect's bindings in the group passed to `pbr(group)`, helper functions. */
|
|
12
|
+
readonly declarations: string;
|
|
13
|
+
/**
|
|
14
|
+
* Wraps the directional light term (shadows), e.g. `direct => \`shadowLit(${direct},i.position,s.n)\``. `normal`, when
|
|
15
|
+
* given, is the WGSL of the normal to use there in place of `s.n`: a surface lit from behind gives the side facing the light.
|
|
16
|
+
*/
|
|
17
|
+
direct?(direct: string, normal?: string): string;
|
|
18
|
+
/** vec3f light added before the directional term (local lights). */
|
|
19
|
+
readonly light?: string;
|
|
20
|
+
/** vec3f replacing the hemisphere ambient (image-based lighting). SSAO's ambient replay returns it. At most one effect. */
|
|
21
|
+
readonly ambient?: string;
|
|
22
|
+
/**
|
|
23
|
+
* vec3f sky light toward the unit normal `n`, an expression in `n` (environment's HemisphereLight): it replaces the
|
|
24
|
+
* built-in sky gradient times its strength `f.radiance.w` wherever the shader uses it (the hemisphere ambient, the
|
|
25
|
+
* clearcoat and sheen defaults, an ambient hook's own fallback to it such as light probes'). An ambient hook that does
|
|
26
|
+
* not fall back to the gradient (image-based lighting) keeps the sky ambient beside its own, in either order. At most
|
|
27
|
+
* one effect.
|
|
28
|
+
*/
|
|
29
|
+
readonly sky?: string;
|
|
30
|
+
/**
|
|
31
|
+
* vec3f ambient light of the clearcoat layer, before its Fresnel, in terms of `s` (Surface: `s.cn` coat normal, `s.cr`
|
|
32
|
+
* coat roughness) and `v` (unit vector to the eye); replaces the hemisphere in physical materials (image-based
|
|
33
|
+
* lighting: prefiltered radiance along the coat's reflection). Shaders without a coat ignore it. At most one effect.
|
|
34
|
+
*/
|
|
35
|
+
readonly coat?: string;
|
|
36
|
+
/** vec3f ambient light of the sheen layer, before its colour (`s`, `v` as for `coat`); as `coat`, for sheen. */
|
|
37
|
+
readonly sheen?: string;
|
|
38
|
+
/** Wraps the display colour after tone mapping, before sRGB encoding (fog). */
|
|
39
|
+
output?(color: string): string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Transparency hook (contract version 1, README "Transparency hook"), set with `PBRModel.setTransparency`. While set, BLEND
|
|
43
|
+
* primitives (no transmission, no `renderState`) leave the beauty pass and draw only when the owner calls
|
|
44
|
+
* `model.draw(c, 'transparent', ...)`, into `begin()`'s pass with these `targets`, depth tested (greater-equal) and not
|
|
45
|
+
* written. Their fragment returns `margoTransparent(color, i)` instead of `color` (the beauty colour, alpha included).
|
|
46
|
+
* `targets` may be empty for a hook that writes storage: `MargoTransparent` then still needs one member. Declarations
|
|
47
|
+
* holding `var<private> margoCoverage:u32` get the fragment's sample coverage in it before the call.
|
|
48
|
+
* With `blends` the hook also takes additive and multiply materials and native transmission (see `blends`).
|
|
49
|
+
*/
|
|
50
|
+
export interface PBRTransparency {
|
|
51
|
+
/** Module-scope WGSL: `struct MargoTransparent` (one output per target), `fn margoTransparent(color:vec4f,i:Out)->MargoTransparent`, its bindings in `group`. Return the same string on steady frames. */
|
|
52
|
+
declarations(group: number): string;
|
|
53
|
+
/** Group-2 entries for those bindings (after any lighting effects' entries). */
|
|
54
|
+
bindings(): GPUBindGroupEntry[];
|
|
55
|
+
/**
|
|
56
|
+
* True: BLEND materials whose `renderState` holds nothing but an additive (`src-alpha`, `one`) or multiply (`zero`,
|
|
57
|
+
* `src`) colour blend, and native transmission when no transmission hook is set, draw here too. Declarations then hold
|
|
58
|
+
* `override margoKind:u32`, set per pipeline: 0 normal, 1 additive, 2 multiply, 3 the lit draw of a transmissive surface.
|
|
59
|
+
* Its tint draw runs first, entry `margoTint`, through `fn margoTransparentTint(share:vec4f)->MargoTransparent`, which
|
|
60
|
+
* may use no bindings: a tint with no maps binds only the frame group.
|
|
61
|
+
*/
|
|
62
|
+
readonly blends?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* True: the surfaces write depth, and native transmission draws here whatever transmission hook is set, without its
|
|
65
|
+
* tint draw. For a hook used through `PBRModel.drawTransparent` after the colour has drawn.
|
|
66
|
+
*/
|
|
67
|
+
readonly depthWrite?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Present: BLEND materials whose `renderState` holds nothing but `blendSpace: 'linear'` draw here too, with the
|
|
70
|
+
* pipeline constant `margoLinear` true on a display-encoded target (declarations then hold `override margoLinear:bool`).
|
|
71
|
+
* A draw holding such a surface calls it once with `scene`, which copies the colour drawn so far into the native glass
|
|
72
|
+
* capture's snapshot and returns that view, for a composite in linear light; `scene` is absent until the capture runs
|
|
73
|
+
* (from the frame after a model first draws the option). KB3148d.
|
|
74
|
+
*/
|
|
75
|
+
linearLayers?(scene?: () => GPUTextureView): void;
|
|
76
|
+
/** Colour targets of the transparent pass, in `MargoTransparent` location order. */
|
|
77
|
+
readonly targets: readonly GPUColorTargetState[];
|
|
78
|
+
/** This frame's transparent pass: the scene depth read-only and these targets; begun on the first draw, ended by the owner. */
|
|
79
|
+
begin(): GPURenderPassEncoder;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `code` with its face and alpha tests behind pipeline constants (margoFaceTest, margoAlphaTest): a pipeline that sets
|
|
83
|
+
* both false compiles without a discard and keeps early depth testing. Every compact-path pipeline sets them.
|
|
84
|
+
*/
|
|
85
|
+
export declare function compactTests(code: string): string;
|
|
86
|
+
/** `code` (the lit PBR shader) with a `transparent` entry point returning `margoTransparent(<beauty colour>, i)`. */
|
|
87
|
+
export declare function transparentPBR(code: string, declarations: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* `code` (the beauty shader of a transmissive surface, tint variants applied) with one entry `margoDual` returning the
|
|
90
|
+
* lit colour and the transmission tint as the two blend sources of location 0 (WGSL `enable dual_source_blending;`,
|
|
91
|
+
* `@blend_src(0|1)`; WebGPU feature `dual-source-blending`). With colour factors `one` and `src1` one draw gives the
|
|
92
|
+
* lit colour plus what is behind times the tint, the two draws of the tinted path in one (Porter and Duff 1984 "over"
|
|
93
|
+
* with a coloured transmittance; McGuire and Mara 2016, "A Phenomenological Scattering Model for Order-Independent
|
|
94
|
+
* Transparency", I3D, per-channel transmission). Undefined when either entry point is not the standard one (a shading
|
|
95
|
+
* hook rewrote it, or the surface reads sample coverage): the surface then keeps its two draws.
|
|
96
|
+
*/
|
|
97
|
+
export declare function dualTintShader(code: string): string | undefined;
|
|
98
|
+
/** `code` (`transparentPBR`, tint variants applied) with the transmission tint draw returning `margoTransparentTint`. */
|
|
99
|
+
export declare function transparentTintPBR(code: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Material capture hook (contract version 1, README "Capture hook"), set with `PBRModel.setCapture`; screen-space
|
|
102
|
+
* reflections (`@margoengine/post` SSR) use it. While set, `model.draw(c, 'capture', ...)` draws the model's opaque and
|
|
103
|
+
* MASK primitives (not BLEND, transmission or unlit) into `begin()`'s pass with these `targets`, depth tested
|
|
104
|
+
* (greater-equal) and written. The shader is the lit beauty shader, its lighting in a dead block (every binding stays,
|
|
105
|
+
* nothing is lit), with an entry point `capture` returning `margoCapture(s, v, k)`: `s` the Surface, `v` toward the eye,
|
|
106
|
+
* `k` the share of the base layer's light left after clearcoat and sheen, a material extension's coat included
|
|
107
|
+
* (vec3f(1) for standard materials). Declarations holding `var<private> margoBeauty:vec4f` turn the block on: the entry
|
|
108
|
+
* point stores the beauty colour there first.
|
|
109
|
+
*/
|
|
110
|
+
export interface PBRCapture {
|
|
111
|
+
/** Module-scope WGSL for the lit shader `code`: `struct MargoCapture` (one output per target) and `fn margoCapture(s:Surface,v:vec3f,k:vec3f)->MargoCapture`. Return the same string for the same code. */
|
|
112
|
+
declarations(code: string): string;
|
|
113
|
+
/** Colour targets of the capture pass, in `MargoCapture` location order. */
|
|
114
|
+
readonly targets: readonly GPUColorTargetState[];
|
|
115
|
+
/** This frame's capture pass: these targets and a depth attachment of the context's format; begun on the first draw, ended by the owner. */
|
|
116
|
+
begin(): GPURenderPassEncoder;
|
|
117
|
+
}
|
|
118
|
+
/** `code` (the lit PBR shader) with a `capture` entry point returning `margoCapture(s,v,k)`; the beauty fragment becomes a dead `margoShade` call. */
|
|
119
|
+
export declare function capturePBR(code: string, declarations: string, keep?: string): string;
|
|
120
|
+
export declare const physicalMaps: string[];
|
|
121
|
+
export declare const extendedMaps: string[];
|
|
122
|
+
/** Stable unmodified physical source contract for material and node-shader consumers. */
|
|
123
|
+
export declare const physicalShader: () => string;
|
|
124
|
+
/** Map slots whose textures decode as sRGB: base colour, emissive, sheen colour, specular colour, diffuse transmission colour, multi-scatter colour. */
|
|
125
|
+
export declare const srgbSlots: readonly number[];
|
|
126
|
+
/**
|
|
127
|
+
* The slot whose texture binding extension slot `k` (5 or more) samples, among slots 5 to `end - 1`: `k` itself, or a slot
|
|
128
|
+
* holding the same glTF texture (the same image and sampler) in a view that decodes `k`'s channels right; -1 when `k` has
|
|
129
|
+
* no map. Slots of one colour space share; a slot reading only alpha also joins an sRGB view. sRGB slots own first, so
|
|
130
|
+
* specular (A) and specular colour (RGB) in one texture, the layout KHR_materials_specular suggests, share its sRGB view,
|
|
131
|
+
* while clearcoat (R, linear) and sheen colour (RGB, sRGB) in one texture keep two views. Each slot keeps its UV row.
|
|
132
|
+
*/
|
|
133
|
+
export declare function shareOwner(maps: readonly unknown[], k: number, end?: number): number;
|
|
134
|
+
/**
|
|
135
|
+
* Native glTF physical maps: absent extension slots have their exact one-texel fallback value without a sampler, and
|
|
136
|
+
* slots sharing a glTF texture sample one binding (`shareOwner`), so a material with clearcoat R + roughness G, sheen
|
|
137
|
+
* RGB + A and specular A + RGB packed as the extensions suggest binds 5 extension textures, not 8. `packed` reads the
|
|
138
|
+
* five base maps from one array (`packBaseShader`); gltf/pbr asks for it only when the composed shader would pass the
|
|
139
|
+
* device's per-stage texture limit. Defaults to false.
|
|
140
|
+
*/
|
|
141
|
+
export declare function sparsePhysicalShader(maps: readonly unknown[], packed?: boolean): string;
|
|
142
|
+
/** Retain the complete material/effect resource interface for a texture-dependent tint draw. */
|
|
143
|
+
export declare function texturedTintPBR(code: string): string;
|
|
144
|
+
/** `code` with a tint draw that reads the whole surface: the same bindings as the lit draw, the base colour and transmission maps included. The tint lanes hold optical depth (-1 for an opaque channel). */
|
|
145
|
+
export declare function surfaceTintPBR(code: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* `code` (physicalShader, or factorPhysicalShader for materials built in code) for KHR_materials_transmission
|
|
148
|
+
* materials. Ambient and local-light hooks are evaluated (by lightPBR)
|
|
149
|
+
* on `margoFront(s)`, whose diffuse colour keeps only the untransmitted share (1 - transmission), as the physical
|
|
150
|
+
* shader's own direct and hemisphere terms do; before, an IBL lit clear glass as an opaque white diffuser. The
|
|
151
|
+
* `margoTint` entry is the draw that multiplies the background by the transmission tint.
|
|
152
|
+
*/
|
|
153
|
+
export declare function transmissiveShader(code?: string): string;
|
|
154
|
+
/** physicalShader with extension maps replaced by their neutral values: factors only, extendedPBRShader's five group-1 textures.
|
|
155
|
+
* Drawn for physical materials whose `maps` hold only the five core slots (`@margoengine/materials`). */
|
|
156
|
+
export declare const factorPhysicalShader: () => string;
|
|
157
|
+
/**
|
|
158
|
+
* Transmission hook (contract version 1, README "Transmission hook"), set with `PBRModel.setTransmission`;
|
|
159
|
+
* `@margoengine/materials/transmission` uses it to refract the scene. While set, primitives with transmission (no
|
|
160
|
+
* `renderState`) leave the beauty pass and draw only when the owner calls `model.draw(c, 'transmission', ...)`, into
|
|
161
|
+
* `begin()`'s pass with these `targets`, depth tested (greater-equal) and not written. Their shader is the lit physical
|
|
162
|
+
* beauty shader with `margoTransmission(s, v, i)` (vec3f: light arriving through the surface) added to the base layer under
|
|
163
|
+
* clearcoat and sheen; `margoVolume` (group 0) holds the thickness factor and the per-unit-length transmittance of KHR_materials_volume.
|
|
164
|
+
*/
|
|
165
|
+
export interface PBRTransmission {
|
|
166
|
+
/** Module-scope WGSL: `fn margoTransmission(s:Surface,v:vec3f,i:Out)->vec3f` and its bindings in `group`. Return the same string on steady frames. */
|
|
167
|
+
declarations(group: number): string;
|
|
168
|
+
/** Group-2 entries for those bindings (after any lighting effects' entries). */
|
|
169
|
+
bindings(): GPUBindGroupEntry[];
|
|
170
|
+
/** Colour targets of the transmission pass. */
|
|
171
|
+
readonly targets: readonly GPUColorTargetState[];
|
|
172
|
+
/** This frame's transmission pass: the scene colour and depth (read-only); begun on the first draw, ended by the owner. */
|
|
173
|
+
begin(): GPURenderPassEncoder;
|
|
174
|
+
/**
|
|
175
|
+
* Whether the hook draws this view's transmissive primitives (it has a scene to read in `context`). When false they
|
|
176
|
+
* keep the tinted blend in the beauty pass. Omitted: always true.
|
|
177
|
+
*/
|
|
178
|
+
takes?(context: Extract<PassContext, {
|
|
179
|
+
backend: 'webgpu';
|
|
180
|
+
}>): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* True: OPAQUE and MASK transmissive primitives draw unblended and write depth (`begin()` opens a writable depth
|
|
183
|
+
* attachment), so glass hides the glass behind it in any draw order; BLEND ones stay blended without depth writes.
|
|
184
|
+
* Default false: every primitive blends with `targets` and depth is read-only.
|
|
185
|
+
*/
|
|
186
|
+
readonly depthWrite?: boolean;
|
|
187
|
+
}
|
|
188
|
+
/** `code` (the lit physical shader) with `margoTransmission(s,v,i)` added under the clearcoat and sheen layers. */
|
|
189
|
+
export declare function transmissionPBR(code: string, declarations: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* What an extended material shades (KHR_materials_iridescence, anisotropy, diffuse_transmission and EXT_materials_bump
|
|
192
|
+
* and KHR_materials_volume_scatter
|
|
193
|
+
* in use) and which group-1 texture each map slot 5-20 samples: `slots[k]` is a binding index j (`margoMap{j}` at binding 10 + 2j) or
|
|
194
|
+
* -1 for the slot's default value. Base slots 0-4 always keep their own bindings 0-9 (text patches use them).
|
|
195
|
+
*/
|
|
196
|
+
export interface ExtendedPlan {
|
|
197
|
+
/**
|
|
198
|
+
* The five base maps read from one array, freeing four texture units. gltf/pbr sets it on the plan it composes only when
|
|
199
|
+
* the shader with its lighting would pass the device's per-stage texture limit; `extendedPlan` leaves it unset.
|
|
200
|
+
*/
|
|
201
|
+
readonly packedBase?: boolean;
|
|
202
|
+
/** Optional spec/gloss conversion, implemented only by the spec-gloss entry. Defaults to false. */
|
|
203
|
+
readonly specularGlossiness?: boolean;
|
|
204
|
+
readonly slots: readonly number[];
|
|
205
|
+
readonly iridescence: boolean;
|
|
206
|
+
readonly anisotropy: boolean;
|
|
207
|
+
readonly diffuseTransmission: boolean;
|
|
208
|
+
readonly bump?: boolean;
|
|
209
|
+
readonly scatter?: boolean;
|
|
210
|
+
/** KHR_materials_diffuse_roughness in use: the energy-preserving rough diffuse lobe. Defaults to false. */
|
|
211
|
+
readonly diffuseRoughness?: boolean;
|
|
212
|
+
}
|
|
213
|
+
/** Extension textures an extended material may bind: 5 base + 8 = 13, so shadows, IBL and LocalShadows (3) still fit WebGPU's 16. */
|
|
214
|
+
export declare const extendedTextureLimit = 8;
|
|
215
|
+
/**
|
|
216
|
+
* Binding plan for an extended material's 21 map slots (22 with a diffuse roughness texture): slots sharing a glTF texture
|
|
217
|
+
* in one colour space share one binding (`shareOwner`, over slots 5 to the last; their UV rows stay per slot), so specular
|
|
218
|
+
* (A) and specular colour (RGB) packed in one texture read its sRGB view, while clearcoat (R, linear) and sheen colour
|
|
219
|
+
* (RGB, sRGB) in one texture bind twice. Bindings follow each group's first slot; at most `extendedTextureLimit`, later
|
|
220
|
+
* groups beyond that fall back to their defaults. The view a binding holds is its first sRGB slot's, else its first slot's.
|
|
221
|
+
*/
|
|
222
|
+
export declare function extendedPlan(maps: readonly ({
|
|
223
|
+
index: number;
|
|
224
|
+
} | undefined)[], features: Omit<ExtendedPlan, 'slots'>): ExtendedPlan;
|
|
225
|
+
export declare const eonWgsl = "fn margoEONE(mu:f32,r:f32)->f32 {let m=1-mu; return (1+r*m*(0.0571085289+m*(0.491881867+m*(-0.332181442+m*0.0714429953))))/(1+0.28779341*r);}\nfn margoEONScatter(rho:vec3f,r:f32)->vec4f {let avg=(1+0.07248822*r)/(1+0.28779341*r); let c=clamp(rho,vec3f(0),vec3f(1)); return vec4f(c*c*avg/(1-c*(1-avg)),avg);}\nfn margoEON(rho:vec3f,r:f32,nl:f32,nv:f32,st:f32)->vec3f {\n let t=st/select(1.0,max(max(nl,nv),0.0001),st>0.0); let m=margoEONScatter(rho,r);\n return rho*((1+r*t)/(1+0.28779341*r))+m.rgb*(max(1-margoEONE(nv,r),0.0)*max(1-margoEONE(nl,r),0.0)/max(1-m.a,0.0000001));\n}\nfn margoEONAlbedo(rho:vec3f,r:f32,nv:f32)->vec3f {let e=margoEONE(nv,r); return rho*e+margoEONScatter(rho,r).rgb*(1-e);}\n";
|
|
226
|
+
/**
|
|
227
|
+
* Direct light: GGX (Burley's anisotropic form when anisotropic, with the height-correlated visibility of the
|
|
228
|
+
* KHR_materials_anisotropy notes), Fresnel mixed with the thin-film Fresnel (diffuse weighted by 1 - its largest channel),
|
|
229
|
+
* diffuse reduced by transmission and split into reflection and back-side transmission (KHR_materials_diffuse_transmission),
|
|
230
|
+
* both rough (`eonWgsl`) when `rough` (KHR_materials_diffuse_roughness; the transmitted side mirrors the light, which keeps
|
|
231
|
+
* the tangent-plane dot).
|
|
232
|
+
* Sources: anisotropic D and V: KHR_materials_anisotropy "Implementation" (Burley 2012; Heitz 2014); isotropic
|
|
233
|
+
* height-correlated Smith V = G2 / (4 nl nv) = 0.5 / (nl sqrt(a2 + (1 - a2) nv^2) + nv sqrt(a2 + (1 - a2) nl^2)):
|
|
234
|
+
* Heitz 2014, JCGT 3(2), and glTF 2.0 Appendix B.3.2 (current revision), as `smithGCorrelated` in core's direct light.
|
|
235
|
+
*/
|
|
236
|
+
export declare const directWgsl: (anisotropic: boolean, scatter?: boolean, rough?: boolean) => string;
|
|
237
|
+
/**
|
|
238
|
+
* Physical variant for an extended material (`ExtendedPlan`), cached per plan: only the extension maps the material uses
|
|
239
|
+
* are bound (shared textures once), the thin-film, anisotropic, diffuse-transmission and bump terms only when used, and
|
|
240
|
+
* a Frame with 21 slots of UV rows and six more factor rows (iri: factor, film IOR, thickness min, max; aniso: strength, cos, sin;
|
|
241
|
+
* its w: diffuse roughness; dtr: factor, colour; bump: factor, 1 for object space; scatter: multi-scatter colour, anisotropy; extinction: per unit
|
|
242
|
+
* length, thickness). Hook points and text-patch anchors are those of `physicalShader`.
|
|
243
|
+
*/
|
|
244
|
+
export declare function extendedShader(plan: ExtendedPlan): string;
|
|
245
|
+
/** `code` reading its view rows from `margoView` (group 0, binding 3); `code` itself when it reads none. Cached. */
|
|
246
|
+
export declare function viewShader(code: string): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** Vertex buffers of a 24-byte (core) or 80-byte (gltf/pbr) caster, plus instance matrices when `instanced`. */
|
|
2
|
+
export function casterBuffers(stride: number, displaced?: boolean, instanced?: boolean): GPUVertexBufferLayout[];
|
|
3
|
+
/** How a caster cuts its surface out like its colour pass, besides its alpha texture and cutoff. */
|
|
4
|
+
export interface CasterCutout {
|
|
5
|
+
/** UV transform of `alphaTexture` (80-byte vertices): 8 finite floats, rows (a, b, offset, unused) for u and then v. */
|
|
6
|
+
alphaTransform?: Float32Array;
|
|
7
|
+
/** Opacity map of the cut-out (materials `alphaMap`, 80-byte vertices): its green channel multiplies the alpha tested. */
|
|
8
|
+
opacity?: { readonly buffer: GPUBuffer; readonly view: GPUTextureView; readonly sampler: GPUSampler };
|
|
9
|
+
/**
|
|
10
|
+
* Moving UVs of the cut-out (VRMC_materials_mtoon 1.0 UV animation, 80-byte vertices): an 80-byte uniform (scroll x,
|
|
11
|
+
* scroll y, rotation, time; the base map's affine rows; the mask's affine rows), the mask view and its sampler. The
|
|
12
|
+
* alpha map is read at the animated UV in place of `alphaTransform`'s, as the colour pass reads it.
|
|
13
|
+
*/
|
|
14
|
+
animation?: { readonly buffer: GPUBuffer; readonly view: GPUTextureView; readonly sampler: GPUSampler };
|
|
15
|
+
/** False keeps vertex alpha out of the cut-out, as the colour pass does (materials `vertexColors: false`). Default true. */
|
|
16
|
+
vertexAlpha?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Cuts against hashed noise instead of `cutoff`, as materials `alphaHash()` does in its colour pass, so the shadow
|
|
19
|
+
* keeps a share of texels equal to the opacity: the caster shader edit (shared/alpha-hash.js `hashedDepth`) that a
|
|
20
|
+
* materials record hands over as `castHashed`, so only an app that imports `alphaHash` carries its WGSL. Only a
|
|
21
|
+
* primitive that cuts (`cutoff` above 0) uses it. Default none.
|
|
22
|
+
*/
|
|
23
|
+
hashed?: (code: string) => string;
|
|
24
|
+
/** Vertex displacement along the normal (materials `displacementMap`, 80-byte vertices). */
|
|
25
|
+
displacement?: CasterDisplacement;
|
|
26
|
+
/** Planes that clip the shadow (materials `clippingPlanes` with `clipShadows`, 80-byte vertices). */
|
|
27
|
+
clip?: GPUBufferBinding;
|
|
28
|
+
/** Planes that clip the surface, whatever `clipShadows` says (80-byte vertices). */
|
|
29
|
+
surfaceClip?: GPUBufferBinding;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What moves a caster's vertices: a displacement map's uniform, view and sampler, or a shader patch of its own (a
|
|
33
|
+
* NodeMaterial's graph), with a `key` for its pipeline and its bind group.
|
|
34
|
+
*/
|
|
35
|
+
export type CasterDisplacement =
|
|
36
|
+
| {
|
|
37
|
+
readonly buffer: GPUBuffer;
|
|
38
|
+
readonly view: GPUTextureView;
|
|
39
|
+
readonly sampler: GPUSampler;
|
|
40
|
+
readonly key?: undefined;
|
|
41
|
+
readonly depth?: undefined;
|
|
42
|
+
readonly velocity?: undefined;
|
|
43
|
+
readonly entries?: undefined;
|
|
44
|
+
readonly layout?: undefined;
|
|
45
|
+
readonly cuts?: undefined;
|
|
46
|
+
readonly move?: undefined;
|
|
47
|
+
readonly program?: undefined;
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
readonly key: string;
|
|
51
|
+
depth(code: string, group: number): string;
|
|
52
|
+
/** TAA's object velocity shader, moved and cut as `depth` does it. Absent on a patch that does not support it. */
|
|
53
|
+
velocity?(code: string, group: number): string;
|
|
54
|
+
entries(): GPUBindGroupEntry[];
|
|
55
|
+
/** The group's layout, for passes that build their pipeline layouts by hand. */
|
|
56
|
+
layout(): GPUBindGroupLayout;
|
|
57
|
+
/** The patch discards fragments, so a pass that skips the fragment stage of opaque casters needs it here. */
|
|
58
|
+
readonly cuts: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The WGSL lines of the patch's move of `margoPosition` alone (empty: no move), and its program: TAA runs a move
|
|
61
|
+
* that reads the uniform block `ndu` again on last frame's bytes of it, bound at `program.next`.
|
|
62
|
+
*/
|
|
63
|
+
readonly move?: readonly string[];
|
|
64
|
+
readonly program?: { readonly next: number; readonly buffers: WeakMap<GPUDevice, { bytes: Uint8Array }> };
|
|
65
|
+
};
|
|
66
|
+
/** A depth-only caster pipeline (less-equal depth into depth32float, line lists for `lines`). */
|
|
67
|
+
export function casterPipeline(
|
|
68
|
+
device: GPUDevice,
|
|
69
|
+
module: GPUShaderModule,
|
|
70
|
+
stride: number,
|
|
71
|
+
displaced: boolean,
|
|
72
|
+
instanced: boolean,
|
|
73
|
+
lines: boolean | undefined,
|
|
74
|
+
): GPURenderPipeline;
|
|
75
|
+
/** The per-primitive draw records of `node` in `draws`, created empty on first use. */
|
|
76
|
+
export function nodeRecords<N, K, R>(draws: Map<N, Map<K, R>>, node: N): Map<K, R>;
|
|
77
|
+
/** The runtime object of a caster source; throws MargoError 'disposed' or 'attached'. */
|
|
78
|
+
export function casterRuntime<S extends object, R>(source: S, engine: unknown, noun: string): R;
|
|
79
|
+
/**
|
|
80
|
+
* The bind group of a displaced caster: its feature uniform, map and sampler; else undefined. Also undefined when the
|
|
81
|
+
* displacement binds nothing and `layout` is an automatic layout's group (`explicit` false, the default), which a
|
|
82
|
+
* default pipeline layout does not hold.
|
|
83
|
+
*/
|
|
84
|
+
export function displacementGroup(
|
|
85
|
+
device: GPUDevice,
|
|
86
|
+
layout: () => GPUBindGroupLayout,
|
|
87
|
+
displacement: CasterDisplacement | undefined,
|
|
88
|
+
explicit?: boolean,
|
|
89
|
+
): GPUBindGroup | undefined;
|
|
90
|
+
/** WGSL of a moving cut-out (MToon UV animation) at bindings `first` to `first` + 2 (default 7), and `margoAnimatedUV`. */
|
|
91
|
+
export function animationCode(group: number, first?: number): string;
|
|
92
|
+
/** A caster depth shader whose cut-out reads its alpha map at the animated UV, bound at 7-9 of `group`. */
|
|
93
|
+
export function animatedDepth(code: string, group: number, first?: number): string;
|
|
94
|
+
/** The bind group entries of a caster's UV `animation`, from binding `first` (default 7). */
|
|
95
|
+
export function animationEntries(
|
|
96
|
+
animation: { readonly buffer: GPUBuffer; readonly view: GPUTextureView; readonly sampler: GPUSampler },
|
|
97
|
+
first?: number,
|
|
98
|
+
): GPUBindGroupEntry[];
|
|
99
|
+
/** WGSL of an opacity map at bindings `first` to `first` + 2 (default 4) of `group`, and `margoOpacityAt` of both UV sets. */
|
|
100
|
+
export function opacityCode(group: number, first?: number): string;
|
|
101
|
+
/** A caster depth shader whose cut-out also multiplies by an opacity map's green channel, bound at 4-6 of `group`. */
|
|
102
|
+
export function opacityDepth(code: string, group: number): string;
|
|
103
|
+
/** The bind group entries of a caster's `opacity`, from binding `first` (default 4). */
|
|
104
|
+
export function opacityEntries(
|
|
105
|
+
opacity: {
|
|
106
|
+
buffer: GPUBuffer;
|
|
107
|
+
view: GPUTextureView;
|
|
108
|
+
sampler: GPUSampler;
|
|
109
|
+
},
|
|
110
|
+
first?: number,
|
|
111
|
+
): GPUBindGroupEntry[];
|
|
112
|
+
/** A caster shader that leaves vertex alpha out of its cut-out (a primitive with `vertexAlpha: false`). */
|
|
113
|
+
export function solidVertexDepth(code: string): string;
|
|
114
|
+
/** A caster shader that discards what uniform `name`'s planes cut away, bound at `binding` of `group` (default 0); its vertex stage writes `o.clip=<camera>*...` (default `f.camera`). */
|
|
115
|
+
export function clippedDepth(
|
|
116
|
+
code: string,
|
|
117
|
+
binding: number,
|
|
118
|
+
name: string,
|
|
119
|
+
hardware?: boolean,
|
|
120
|
+
group?: number,
|
|
121
|
+
camera?: string,
|
|
122
|
+
): string;
|
|
123
|
+
/** A cleared depth-only pass descriptor; set `depthStencilAttachment.view` before each use. */
|
|
124
|
+
export function depthPassDescriptor(): GPURenderPassDescriptor & {
|
|
125
|
+
depthStencilAttachment: GPURenderPassDepthStencilAttachment;
|
|
126
|
+
};
|
|
127
|
+
/** Writes one caster's uniform (view, node matrix, alpha, cutoff at least `floor`, uv set, alpha transform), uploads it and draws. */
|
|
128
|
+
export function drawCaster(
|
|
129
|
+
pass: GPURenderPassEncoder,
|
|
130
|
+
device: GPUDevice,
|
|
131
|
+
pipeline: GPURenderPipeline,
|
|
132
|
+
group: GPUBindGroup,
|
|
133
|
+
uniform: GPUBuffer,
|
|
134
|
+
values: Float32Array<ArrayBuffer>,
|
|
135
|
+
view: ArrayLike<number>,
|
|
136
|
+
p: {
|
|
137
|
+
node: { matrix: ArrayLike<number> };
|
|
138
|
+
alpha?: number;
|
|
139
|
+
cutoff?: number;
|
|
140
|
+
texCoord?: number;
|
|
141
|
+
vertex: GPUBuffer;
|
|
142
|
+
/** Byte offset of the caster's vertices in `vertex`. Default 0. */
|
|
143
|
+
vertexOffset?: number;
|
|
144
|
+
index: GPUBuffer;
|
|
145
|
+
count: number;
|
|
146
|
+
},
|
|
147
|
+
transform: ArrayLike<number> | undefined | null,
|
|
148
|
+
displaced: GPUBindGroup | undefined,
|
|
149
|
+
instances: { upload(device: GPUDevice): GPUBuffer; count: number } | undefined | null,
|
|
150
|
+
/** Lowest cutoff written: the larger of this and `p.cutoff`. Default 0. */
|
|
151
|
+
floor?: number,
|
|
152
|
+
): void;
|
|
153
|
+
/** Whether a caster's cached draw `record` no longer fits primitive `p` drawn with `pipeline` and `displacement`. */
|
|
154
|
+
export function staleCaster<R extends object>(
|
|
155
|
+
record: R | undefined,
|
|
156
|
+
p: { vertex: GPUBuffer; alphaTexture?: unknown; alphaSampler?: unknown; opacity?: unknown; animation?: unknown },
|
|
157
|
+
pipeline: GPURenderPipeline,
|
|
158
|
+
displacement: unknown,
|
|
159
|
+
): record is undefined;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/** Structural glTF 2.0 data consumed by the optional loaders. Runtime validation stays at each use site. */
|
|
2
|
+
export interface GLTFProperty<E extends Record<string, unknown> = GLTFExtensions> {
|
|
3
|
+
name?: string;
|
|
4
|
+
extras?: unknown;
|
|
5
|
+
extensions?: E;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** One entry of EXT_lights_image_based `lights`. */
|
|
10
|
+
export interface GLTFImageBasedLight extends GLTFProperty {
|
|
11
|
+
rotation?: number[];
|
|
12
|
+
intensity?: number;
|
|
13
|
+
irradianceCoefficients: number[][];
|
|
14
|
+
specularImages: number[][];
|
|
15
|
+
specularImageSize: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Known extension payloads retain their schema; application-specific extensions remain unknown. */
|
|
19
|
+
export interface GLTFExtensions {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
KHR_draco_mesh_compression?: { bufferView: number; attributes: Record<string, number> };
|
|
22
|
+
EXT_meshopt_compression?: GLTFMeshopt;
|
|
23
|
+
KHR_meshopt_compression?: GLTFMeshopt;
|
|
24
|
+
KHR_texture_basisu?: { source: number };
|
|
25
|
+
MSFT_texture_dds?: { source: number };
|
|
26
|
+
EXT_texture_webp?: { source: number };
|
|
27
|
+
EXT_texture_avif?: { source: number };
|
|
28
|
+
KHR_texture_transform?: GLTFTextureTransform;
|
|
29
|
+
EXT_mesh_gpu_instancing?: GLTFInstancing;
|
|
30
|
+
KHR_lights_punctual?: { light?: number; lights?: GLTFLightDefinition[] };
|
|
31
|
+
// On the document: `lights`. On a node: `light`, `multiplier`, `color`.
|
|
32
|
+
EXT_lights_ies?: {
|
|
33
|
+
lights?: { name?: string; uri?: string; bufferView?: number; mimeType?: string }[];
|
|
34
|
+
light?: number;
|
|
35
|
+
multiplier?: number;
|
|
36
|
+
color?: number[];
|
|
37
|
+
};
|
|
38
|
+
// On the document: `lights`. On a scene: `light`.
|
|
39
|
+
EXT_lights_image_based?: { lights?: GLTFImageBasedLight[]; light?: number };
|
|
40
|
+
KHR_node_visibility?: { visible?: boolean };
|
|
41
|
+
KHR_materials_variants?: { variants?: { name: string }[]; mappings?: { material: number; variants: number[] }[] };
|
|
42
|
+
KHR_materials_unlit?: object;
|
|
43
|
+
KHR_materials_emissive_strength?: { emissiveStrength?: number };
|
|
44
|
+
KHR_materials_ior?: { ior?: number };
|
|
45
|
+
KHR_materials_dispersion?: { dispersion?: number };
|
|
46
|
+
KHR_materials_clearcoat?: {
|
|
47
|
+
clearcoatFactor?: number;
|
|
48
|
+
clearcoatRoughnessFactor?: number;
|
|
49
|
+
clearcoatTexture?: GLTFTextureInfo;
|
|
50
|
+
clearcoatRoughnessTexture?: GLTFTextureInfo;
|
|
51
|
+
clearcoatNormalTexture?: GLTFTextureInfo;
|
|
52
|
+
};
|
|
53
|
+
KHR_materials_transmission?: { transmissionFactor?: number; transmissionTexture?: GLTFTextureInfo };
|
|
54
|
+
KHR_materials_volume?: {
|
|
55
|
+
thicknessFactor?: number;
|
|
56
|
+
thicknessTexture?: GLTFTextureInfo;
|
|
57
|
+
attenuationDistance?: number;
|
|
58
|
+
attenuationColor?: number[];
|
|
59
|
+
};
|
|
60
|
+
KHR_materials_sheen?: {
|
|
61
|
+
sheenColorFactor?: number[];
|
|
62
|
+
sheenRoughnessFactor?: number;
|
|
63
|
+
sheenColorTexture?: GLTFTextureInfo;
|
|
64
|
+
sheenRoughnessTexture?: GLTFTextureInfo;
|
|
65
|
+
};
|
|
66
|
+
KHR_materials_specular?: {
|
|
67
|
+
specularFactor?: number;
|
|
68
|
+
specularColorFactor?: number[];
|
|
69
|
+
specularTexture?: GLTFTextureInfo;
|
|
70
|
+
specularColorTexture?: GLTFTextureInfo;
|
|
71
|
+
};
|
|
72
|
+
KHR_materials_iridescence?: {
|
|
73
|
+
iridescenceFactor?: number;
|
|
74
|
+
iridescenceIor?: number;
|
|
75
|
+
iridescenceThicknessMinimum?: number;
|
|
76
|
+
iridescenceThicknessMaximum?: number;
|
|
77
|
+
iridescenceTexture?: GLTFTextureInfo;
|
|
78
|
+
iridescenceThicknessTexture?: GLTFTextureInfo;
|
|
79
|
+
};
|
|
80
|
+
KHR_materials_anisotropy?: {
|
|
81
|
+
anisotropyStrength?: number;
|
|
82
|
+
anisotropyRotation?: number;
|
|
83
|
+
anisotropyTexture?: GLTFTextureInfo;
|
|
84
|
+
};
|
|
85
|
+
KHR_materials_diffuse_roughness?: {
|
|
86
|
+
diffuseRoughnessFactor?: number;
|
|
87
|
+
diffuseRoughnessTexture?: GLTFTextureInfo;
|
|
88
|
+
};
|
|
89
|
+
KHR_materials_diffuse_transmission?: {
|
|
90
|
+
diffuseTransmissionFactor?: number;
|
|
91
|
+
diffuseTransmissionColorFactor?: number[];
|
|
92
|
+
diffuseTransmissionTexture?: GLTFTextureInfo;
|
|
93
|
+
diffuseTransmissionColorTexture?: GLTFTextureInfo;
|
|
94
|
+
};
|
|
95
|
+
KHR_materials_volume_scatter?: {
|
|
96
|
+
multiscatterColorFactor?: number[];
|
|
97
|
+
multiscatterColorTexture?: GLTFTextureInfo;
|
|
98
|
+
scatterAnisotropy?: number;
|
|
99
|
+
};
|
|
100
|
+
EXT_materials_bump?: {
|
|
101
|
+
bumpFactor?: number;
|
|
102
|
+
bumpTexture?: GLTFTextureInfo;
|
|
103
|
+
heightSpace?: 'world' | 'object';
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface GLTFMeshopt {
|
|
107
|
+
fallback?: boolean;
|
|
108
|
+
buffer: number;
|
|
109
|
+
byteOffset?: number;
|
|
110
|
+
byteLength: number;
|
|
111
|
+
byteStride: number;
|
|
112
|
+
count: number;
|
|
113
|
+
mode: string;
|
|
114
|
+
filter?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface GLTFInstancing {
|
|
117
|
+
attributes: Record<string, number>;
|
|
118
|
+
}
|
|
119
|
+
export interface GLTFTextureTransform {
|
|
120
|
+
offset?: readonly [number, number];
|
|
121
|
+
rotation?: number;
|
|
122
|
+
scale?: readonly [number, number];
|
|
123
|
+
texCoord?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface GLTFTextureInfo extends GLTFProperty {
|
|
126
|
+
index: number;
|
|
127
|
+
texCoord?: number;
|
|
128
|
+
scale?: number;
|
|
129
|
+
strength?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface GLTFBufferExtensions {
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
EXT_meshopt_compression?: { fallback?: boolean };
|
|
134
|
+
}
|
|
135
|
+
export interface GLTFBuffer extends GLTFProperty<GLTFBufferExtensions> {
|
|
136
|
+
byteLength: number;
|
|
137
|
+
uri?: string;
|
|
138
|
+
}
|
|
139
|
+
export interface GLTFBufferView extends GLTFProperty {
|
|
140
|
+
buffer: number;
|
|
141
|
+
byteLength: number;
|
|
142
|
+
byteOffset?: number;
|
|
143
|
+
byteStride?: number;
|
|
144
|
+
target?: number;
|
|
145
|
+
}
|
|
146
|
+
export interface GLTFAccessor extends GLTFProperty {
|
|
147
|
+
bufferView?: number;
|
|
148
|
+
byteOffset?: number;
|
|
149
|
+
componentType: number;
|
|
150
|
+
count: number;
|
|
151
|
+
type: string;
|
|
152
|
+
normalized?: boolean;
|
|
153
|
+
min?: number[];
|
|
154
|
+
max?: number[];
|
|
155
|
+
sparse?: {
|
|
156
|
+
count: number;
|
|
157
|
+
indices: { bufferView: number; byteOffset?: number; componentType: number };
|
|
158
|
+
values: { bufferView: number; byteOffset?: number };
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface GLTFPrimitive extends GLTFProperty {
|
|
162
|
+
/** Absent for engine-owned prepared geometry whose vertices are supplied separately. */
|
|
163
|
+
attributes?: Record<string, number>;
|
|
164
|
+
indices?: number;
|
|
165
|
+
material?: number;
|
|
166
|
+
mode?: number;
|
|
167
|
+
targets?: Record<string, number>[];
|
|
168
|
+
}
|
|
169
|
+
export interface GLTFMesh extends GLTFProperty {
|
|
170
|
+
primitives: GLTFPrimitive[];
|
|
171
|
+
weights?: number[];
|
|
172
|
+
}
|
|
173
|
+
export interface GLTFNode extends GLTFProperty {
|
|
174
|
+
mesh?: number;
|
|
175
|
+
skin?: number;
|
|
176
|
+
camera?: number;
|
|
177
|
+
children?: number[];
|
|
178
|
+
matrix?: number[];
|
|
179
|
+
translation?: number[];
|
|
180
|
+
rotation?: number[];
|
|
181
|
+
scale?: number[];
|
|
182
|
+
weights?: number[];
|
|
183
|
+
}
|
|
184
|
+
export interface GLTFMaterial extends GLTFProperty {
|
|
185
|
+
pbrMetallicRoughness?: {
|
|
186
|
+
baseColorFactor?: number[];
|
|
187
|
+
metallicFactor?: number;
|
|
188
|
+
roughnessFactor?: number;
|
|
189
|
+
baseColorTexture?: GLTFTextureInfo;
|
|
190
|
+
metallicRoughnessTexture?: GLTFTextureInfo;
|
|
191
|
+
};
|
|
192
|
+
normalTexture?: GLTFTextureInfo;
|
|
193
|
+
occlusionTexture?: GLTFTextureInfo;
|
|
194
|
+
emissiveTexture?: GLTFTextureInfo;
|
|
195
|
+
emissiveFactor?: number[];
|
|
196
|
+
alphaMode?: string;
|
|
197
|
+
alphaCutoff?: number;
|
|
198
|
+
doubleSided?: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface GLTFTexture extends GLTFProperty {
|
|
201
|
+
source?: number;
|
|
202
|
+
sampler?: number;
|
|
203
|
+
}
|
|
204
|
+
export interface GLTFImageDefinition extends GLTFProperty {
|
|
205
|
+
uri?: string;
|
|
206
|
+
mimeType?: string;
|
|
207
|
+
bufferView?: number;
|
|
208
|
+
}
|
|
209
|
+
export interface GLTFSampler extends GLTFProperty {
|
|
210
|
+
wrapS?: number;
|
|
211
|
+
wrapT?: number;
|
|
212
|
+
magFilter?: number;
|
|
213
|
+
minFilter?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface GLTFSkin extends GLTFProperty {
|
|
216
|
+
joints: number[];
|
|
217
|
+
inverseBindMatrices?: number;
|
|
218
|
+
skeleton?: number;
|
|
219
|
+
}
|
|
220
|
+
export interface GLTFAnimation extends GLTFProperty {
|
|
221
|
+
samplers: { input: number; output: number; interpolation?: string }[];
|
|
222
|
+
channels: { sampler: number; target: { node?: number; path: string; extensions?: Record<string, unknown> } }[];
|
|
223
|
+
}
|
|
224
|
+
export interface GLTFLightDefinition extends GLTFProperty {
|
|
225
|
+
type: 'directional' | 'point' | 'spot';
|
|
226
|
+
color?: number[];
|
|
227
|
+
intensity?: number;
|
|
228
|
+
range?: number;
|
|
229
|
+
spot?: { innerConeAngle?: number; outerConeAngle?: number };
|
|
230
|
+
}
|
|
231
|
+
export interface GLTFCameraDefinition extends GLTFProperty {
|
|
232
|
+
type: 'perspective' | 'orthographic';
|
|
233
|
+
perspective?: { yfov: number; znear: number; zfar?: number; aspectRatio?: number };
|
|
234
|
+
orthographic?: { xmag: number; ymag: number; znear: number; zfar: number };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A glTF 2.0 JSON document as the loaders read it: scenes, nodes, meshes, materials, animations and the other top-level arrays.
|
|
238
|
+
*/
|
|
239
|
+
export interface GLTFDocument extends GLTFProperty {
|
|
240
|
+
asset?: { version: string; generator?: string; [key: string]: unknown };
|
|
241
|
+
buffers?: GLTFBuffer[];
|
|
242
|
+
bufferViews?: GLTFBufferView[];
|
|
243
|
+
accessors?: GLTFAccessor[];
|
|
244
|
+
meshes?: GLTFMesh[];
|
|
245
|
+
nodes?: GLTFNode[];
|
|
246
|
+
scenes?: (GLTFProperty & { nodes?: number[] })[];
|
|
247
|
+
scene?: number;
|
|
248
|
+
materials?: GLTFMaterial[];
|
|
249
|
+
textures?: GLTFTexture[];
|
|
250
|
+
images?: GLTFImageDefinition[];
|
|
251
|
+
samplers?: GLTFSampler[];
|
|
252
|
+
skins?: GLTFSkin[];
|
|
253
|
+
animations?: GLTFAnimation[];
|
|
254
|
+
cameras?: GLTFCameraDefinition[];
|
|
255
|
+
extensionsUsed?: string[];
|
|
256
|
+
extensionsRequired?: string[];
|
|
257
|
+
}
|