threejs-debug-compose 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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/assets/readme-compose-banner.png +0 -0
  4. package/assets/viewport-compose-quad.png +0 -0
  5. package/dist/custom-debug-view.js +13 -0
  6. package/dist/debug-render-graph-plan.js +38 -0
  7. package/dist/debug-render-plan.js +86 -0
  8. package/dist/debug-view-definitions.js +91 -0
  9. package/dist/debug-view-layout.js +65 -0
  10. package/dist/debug-view-selection.js +33 -0
  11. package/dist/debug-viewport-labels.js +28 -0
  12. package/dist/debug-viewport-plan.js +51 -0
  13. package/dist/debug-viewport-presenter.js +33 -0
  14. package/dist/debug-views-post.js +329 -0
  15. package/dist/debug-views-tsl/ao-fallbacks.js +103 -0
  16. package/dist/debug-views-tsl/compositor.js +51 -0
  17. package/dist/debug-views-tsl/default-debug-nodes.js +61 -0
  18. package/dist/debug-views-tsl/uniforms.js +19 -0
  19. package/dist/debug-views-tsl/visualize.js +21 -0
  20. package/dist/index.js +11 -0
  21. package/dist/react.js +3 -0
  22. package/dist/shader-cost/cost-override.js +67 -0
  23. package/dist/shader-cost/material-cost.js +302 -0
  24. package/dist/types/custom-debug-view.d.ts +17 -0
  25. package/dist/types/debug-render-graph-plan.d.ts +17 -0
  26. package/dist/types/debug-render-plan.d.ts +26 -0
  27. package/dist/types/debug-view-definitions.d.ts +60 -0
  28. package/dist/types/debug-view-layout.d.ts +21 -0
  29. package/dist/types/debug-view-selection.d.ts +5 -0
  30. package/dist/types/debug-viewport-labels.d.ts +8 -0
  31. package/dist/types/debug-viewport-plan.d.ts +29 -0
  32. package/dist/types/debug-viewport-presenter.d.ts +28 -0
  33. package/dist/types/debug-views-post.d.ts +19 -0
  34. package/dist/types/debug-views-tsl/ao-fallbacks.d.ts +6 -0
  35. package/dist/types/debug-views-tsl/compositor.d.ts +20 -0
  36. package/dist/types/debug-views-tsl/default-debug-nodes.d.ts +35 -0
  37. package/dist/types/debug-views-tsl/node-types.d.ts +6 -0
  38. package/dist/types/debug-views-tsl/uniforms.d.ts +12 -0
  39. package/dist/types/debug-views-tsl/visualize.d.ts +5 -0
  40. package/dist/types/index.d.ts +11 -0
  41. package/dist/types/react.d.ts +2 -0
  42. package/dist/types/shader-cost/cost-override.d.ts +20 -0
  43. package/dist/types/shader-cost/material-cost.d.ts +15 -0
  44. package/dist/types/use-debug-views-controls.d.ts +16 -0
  45. package/dist/use-debug-views-controls.js +77 -0
  46. package/package.json +101 -0
@@ -0,0 +1,302 @@
1
+ import { Material as e, MeshBasicMaterial as t, MeshLambertMaterial as n, MeshMatcapMaterial as r, MeshPhongMaterial as i, MeshPhysicalMaterial as a, MeshStandardMaterial as o, MeshToonMaterial as s, ShaderMaterial as c } from "three";
2
+ //#region components/debug-views/shader-cost/material-cost.ts
3
+ var l = 12, u = [
4
+ "map",
5
+ "normalMap",
6
+ "roughnessMap",
7
+ "metalnessMap",
8
+ "aoMap",
9
+ "emissiveMap",
10
+ "alphaMap",
11
+ "envMap",
12
+ "clearcoatMap",
13
+ "clearcoatNormalMap",
14
+ "clearcoatRoughnessMap",
15
+ "iridescenceMap",
16
+ "sheenColorMap",
17
+ "sheenRoughnessMap",
18
+ "transmissionMap"
19
+ ], d = [
20
+ "alphaTest",
21
+ "clearcoat",
22
+ "iridescence",
23
+ "sheen",
24
+ "transmission"
25
+ ], f = [
26
+ {
27
+ name: "texture-sample",
28
+ pattern: /\btexture(?:2D|Cube)?\s*\(/g
29
+ },
30
+ {
31
+ name: "branch",
32
+ pattern: /\b(?:if|switch)\b/g
33
+ },
34
+ {
35
+ name: "loop",
36
+ pattern: /\b(?:for|while|do)\b/g
37
+ },
38
+ {
39
+ name: "derivative",
40
+ pattern: /\b(?:dFdx|dFdy|fwidth)\s*\(/g
41
+ }
42
+ ], p = new Set(y(new e()));
43
+ function m() {
44
+ let e = /* @__PURE__ */ new Map();
45
+ return {
46
+ get(t) {
47
+ let n = h(t), r = e.get(t.uuid);
48
+ if (r?.signature === n) return r;
49
+ let i = g(t, n);
50
+ return e.set(t.uuid, i), i;
51
+ },
52
+ clear() {
53
+ e.clear();
54
+ },
55
+ get size() {
56
+ return e.size;
57
+ }
58
+ };
59
+ }
60
+ function h(e) {
61
+ return b(e);
62
+ }
63
+ function g(e, t = h(e)) {
64
+ let n = _(y(e));
65
+ return {
66
+ cost: v(n.length),
67
+ signature: t,
68
+ signals: n
69
+ };
70
+ }
71
+ function _(e) {
72
+ return e.filter((e) => !p.has(e));
73
+ }
74
+ function v(e) {
75
+ return Math.max(0, Math.min(1, e / l));
76
+ }
77
+ function y(e) {
78
+ let t = [];
79
+ return x(t, e), S(t, e), C(t, e), w(t, e), T(t, e), E(t, e), t;
80
+ }
81
+ function b(e) {
82
+ let t = [];
83
+ return x(t, e), S(t, e), C(t, e), w(t, e), D(t, e), t.join("|");
84
+ }
85
+ function x(e, l) {
86
+ if (l instanceof t) {
87
+ e.push("type:basic-unlit");
88
+ return;
89
+ }
90
+ if (l instanceof a) {
91
+ e.push("type:physical-lit", "lighting:pbr", "brdf:physical");
92
+ return;
93
+ }
94
+ if (l instanceof o) {
95
+ e.push("type:standard-lit", "lighting:pbr");
96
+ return;
97
+ }
98
+ if (l instanceof i) {
99
+ e.push("type:phong-lit", "lighting:phong", "specular:phong");
100
+ return;
101
+ }
102
+ if (l instanceof s) {
103
+ e.push("type:toon-lit", "lighting:toon");
104
+ return;
105
+ }
106
+ if (l instanceof n) {
107
+ e.push("type:lambert-lit", "lighting:lambert");
108
+ return;
109
+ }
110
+ if (l instanceof r) {
111
+ e.push("type:matcap", "lighting:matcap");
112
+ return;
113
+ }
114
+ if (l instanceof c) {
115
+ e.push("type:custom-shader");
116
+ return;
117
+ }
118
+ e.push(`type:${l.type}`);
119
+ }
120
+ function S(e, t) {
121
+ e.push(`side:${t.side}`, `blending:${t.blending}`), t.transparent && e.push("transparent:true"), J(t, "clippingPlanes") > 0 && e.push(`clippingPlanes:${J(t, "clippingPlanes")}`);
122
+ }
123
+ function C(e, t) {
124
+ for (let n of u) {
125
+ let r = K(t, n);
126
+ r && e.push(U(n, r));
127
+ }
128
+ }
129
+ function w(e, t) {
130
+ for (let n of d) {
131
+ let r = q(t, n);
132
+ r > 0 && e.push(`${n}:${r}`);
133
+ }
134
+ }
135
+ function T(e, t) {
136
+ if (t instanceof c) for (let [n, r] of R(t)) e.push(`define:${n}:${String(r)}`);
137
+ }
138
+ function E(e, t) {
139
+ if (!(t instanceof c)) return;
140
+ let n = z(t);
141
+ O(e, "fragment", j(t.fragmentShader, n)), O(e, "vertex", j(t.vertexShader, n));
142
+ }
143
+ function D(e, t) {
144
+ t instanceof c && (T(e, t), e.push(`fragmentShader:${H(t.fragmentShader)}`), e.push(`vertexShader:${H(t.vertexShader)}`));
145
+ }
146
+ function O(e, t, n) {
147
+ k(e, `${t}:source-kb`, Math.ceil(n.length / 1024));
148
+ for (let { name: r, pattern: i } of f) k(e, `${t}:${r}`, A(n, i));
149
+ }
150
+ function k(e, t, n) {
151
+ if (!(n <= 0)) {
152
+ if (n === 1) {
153
+ e.push(t);
154
+ return;
155
+ }
156
+ for (let r = 1; r <= n; r += 1) e.push(`${t}:${r}`);
157
+ }
158
+ }
159
+ function A(e, t) {
160
+ t.lastIndex = 0;
161
+ let n = 0;
162
+ for (; t.exec(e);) n += 1;
163
+ return t.lastIndex = 0, n;
164
+ }
165
+ function j(e, t) {
166
+ let n = [], r = [];
167
+ for (let i of e.split(/\r?\n/)) {
168
+ let e = M(i, t);
169
+ if (e) {
170
+ N(r, e);
171
+ continue;
172
+ }
173
+ r.every((e) => e.active) && n.push(i);
174
+ }
175
+ return n.join("\n");
176
+ }
177
+ function M(e, t) {
178
+ let n = e.trim();
179
+ return n.startsWith("#ifdef ") ? {
180
+ type: "open",
181
+ active: B(t, n.slice(7).trim())
182
+ } : n.startsWith("#ifndef ") ? {
183
+ type: "open",
184
+ active: !B(t, n.slice(8).trim())
185
+ } : n.startsWith("#if ") ? {
186
+ type: "open",
187
+ active: P(n.slice(4).trim(), t)
188
+ } : n.startsWith("#elif ") ? {
189
+ type: "elif",
190
+ active: P(n.slice(6).trim(), t)
191
+ } : n === "#else" ? { type: "else" } : n === "#endif" ? { type: "close" } : null;
192
+ }
193
+ function N(e, t) {
194
+ if (t.type === "open") {
195
+ let n = e.every((e) => e.active);
196
+ e.push({
197
+ parentActive: n,
198
+ conditionActive: t.active,
199
+ active: n && t.active,
200
+ branchMatched: t.active
201
+ });
202
+ return;
203
+ }
204
+ if (t.type === "elif") {
205
+ let n = e[e.length - 1];
206
+ n && (n.conditionActive = !n.branchMatched && t.active, n.active = n.parentActive && n.conditionActive, n.branchMatched ||= t.active);
207
+ return;
208
+ }
209
+ if (t.type === "else") {
210
+ let t = e[e.length - 1];
211
+ t && (t.conditionActive = !t.branchMatched, t.active = t.parentActive && t.conditionActive, t.branchMatched = !0);
212
+ return;
213
+ }
214
+ e.pop();
215
+ }
216
+ function P(e, t) {
217
+ let n = F(e.trim());
218
+ if (n.includes("||")) return n.split("||").some((e) => P(e, t));
219
+ if (n.includes("&&")) return n.split("&&").every((e) => P(e, t));
220
+ if (n.startsWith("!")) return !P(n.slice(1), t);
221
+ if (n === "1") return !0;
222
+ if (n === "0") return !1;
223
+ let r = n.match(/^defined\((\w+)\)$/);
224
+ if (r) return B(t, r[1] ?? "");
225
+ let i = n.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([.\w-]+)$/);
226
+ return i ? I(t[i[1] ?? ""], i[2] ?? "", i[3] ?? "") : B(t, n);
227
+ }
228
+ function F(e) {
229
+ return !e.startsWith("(") || !e.endsWith(")") ? e : e.slice(1, -1).trim();
230
+ }
231
+ function I(e, t, n) {
232
+ let r = L(e), i = L(n);
233
+ switch (t) {
234
+ case "==": return r === i;
235
+ case "!=": return r !== i;
236
+ case ">": return Number(r) > Number(i);
237
+ case ">=": return Number(r) >= Number(i);
238
+ case "<": return Number(r) < Number(i);
239
+ case "<=": return Number(r) <= Number(i);
240
+ default: return !1;
241
+ }
242
+ }
243
+ function L(e) {
244
+ return e === !0 ? "1" : e === !1 || e == null ? "0" : String(e);
245
+ }
246
+ function R(e) {
247
+ return Object.entries(z(e)).filter(([, e]) => V(e));
248
+ }
249
+ function z(e) {
250
+ return X(e.defines) ? e.defines : {};
251
+ }
252
+ function B(e, t) {
253
+ return V(e[t]);
254
+ }
255
+ function V(e) {
256
+ return e != null && e !== !1 && e !== 0 && e !== "0";
257
+ }
258
+ function H(e) {
259
+ let t = 5381;
260
+ for (let n = 0; n < e.length; n += 1) t = t * 33 ^ e.charCodeAt(n);
261
+ return (t >>> 0).toString(36);
262
+ }
263
+ function U(e, t) {
264
+ return [
265
+ e,
266
+ "texture",
267
+ t.uuid,
268
+ t.version,
269
+ t.mapping,
270
+ t.magFilter,
271
+ t.minFilter,
272
+ t.wrapS,
273
+ t.wrapT,
274
+ W(t)
275
+ ].join(":");
276
+ }
277
+ function W(e) {
278
+ return e.wrapR ?? "none";
279
+ }
280
+ function G(e, t) {
281
+ return e[t];
282
+ }
283
+ function K(e, t) {
284
+ let n = G(e, t);
285
+ return Y(n) ? n : null;
286
+ }
287
+ function q(e, t) {
288
+ let n = G(e, t);
289
+ return typeof n == "number" ? n : 0;
290
+ }
291
+ function J(e, t) {
292
+ let n = G(e, t);
293
+ return Array.isArray(n) ? n.length : 0;
294
+ }
295
+ function Y(e) {
296
+ return !!(e && typeof e == "object" && "isTexture" in e && e.isTexture);
297
+ }
298
+ function X(e) {
299
+ return !!(e && typeof e == "object" && !Array.isArray(e));
300
+ }
301
+ //#endregion
302
+ export { m as createMaterialCostCache };
@@ -0,0 +1,17 @@
1
+ import type { DebugNode } from "./debug-views-tsl/node-types";
2
+ import type { DebugView, ViewMode } from "./debug-views-tsl/compositor";
3
+ export interface CustomDebugNodeViewOptions {
4
+ /**
5
+ * Stable identity for render-graph deduping.
6
+ *
7
+ * Reuse the same id only when two views are expected to render the same node
8
+ * with the same visualization settings.
9
+ */
10
+ id: string;
11
+ label: string;
12
+ node: DebugNode;
13
+ mode?: ViewMode;
14
+ scale?: number;
15
+ bias?: number;
16
+ }
17
+ export declare function createCustomDebugView({ id, label, node, mode, scale, bias, }: CustomDebugNodeViewOptions): DebugView;
@@ -0,0 +1,17 @@
1
+ import type { Camera } from "three";
2
+ import type { DebugView } from "./debug-views-tsl/compositor";
3
+ import type { DebugViewportCell, DebugViewportPlan, DebugViewportResolutionScale } from "./debug-viewport-plan";
4
+ export interface DebugViewportRenderPassPlan {
5
+ key: string;
6
+ view: DebugView;
7
+ camera?: Camera;
8
+ resolutionScale: DebugViewportResolutionScale;
9
+ }
10
+ export interface DebugViewportRenderGraphCell extends DebugViewportCell {
11
+ passIndex: number;
12
+ }
13
+ export interface DebugViewportRenderGraphPlan {
14
+ passes: DebugViewportRenderPassPlan[];
15
+ cells: DebugViewportRenderGraphCell[];
16
+ }
17
+ export declare function createDebugViewportRenderGraphPlan(plan: DebugViewportPlan): DebugViewportRenderGraphPlan;
@@ -0,0 +1,26 @@
1
+ import { type Texture, type TextureDataType } from "three";
2
+ import type { DebugView } from "./debug-views-tsl/compositor";
3
+ import type { MaterialDetailOutputs, SceneDebugOutputs } from "./debug-views-tsl/default-debug-nodes";
4
+ import type { DebugViewLayout, ResolvedDebugViewLayout } from "./debug-view-layout";
5
+ export interface DebugTextureTypeOverride {
6
+ name: string;
7
+ type: TextureDataType;
8
+ }
9
+ export interface TextureTypedDebugPass {
10
+ getTexture(name: string): Texture;
11
+ }
12
+ export interface DebugRenderPlan {
13
+ views: DebugView[];
14
+ sceneOutputs: SceneDebugOutputs;
15
+ materialDetailOutputs: MaterialDetailOutputs;
16
+ usesMaterialDetailPass: boolean;
17
+ usesWireframePass: boolean;
18
+ usesLightingOnlyPass: boolean;
19
+ usesReflectionOnlyPass: boolean;
20
+ usesShaderCostPass: boolean;
21
+ usesAoFallback: boolean;
22
+ sceneTextureTypes: DebugTextureTypeOverride[];
23
+ materialDetailTextureTypes: DebugTextureTypeOverride[];
24
+ }
25
+ export declare function createDebugRenderPlan(views: readonly DebugView[], activeView: number, layout: DebugViewLayout | ResolvedDebugViewLayout): DebugRenderPlan;
26
+ export declare function applyDebugTextureTypes(passNode: TextureTypedDebugPass, overrides: readonly DebugTextureTypeOverride[]): void;
@@ -0,0 +1,60 @@
1
+ import type { DebugView } from "./debug-views-tsl/compositor";
2
+ export declare const MATERIAL_DEBUG_VIEW_SOURCES: readonly ["albedo", "materialNormal", "normalMap", "emissive", "roughness", "ao", "metallic", "opacity", "wireframe", "lightingOnly", "reflectionOnly", "shaderCost"];
3
+ export declare const DEFAULT_DEBUG_VIEWS: readonly [{
4
+ readonly label: "Beauty";
5
+ readonly source: "beauty";
6
+ readonly mode: "passthrough";
7
+ }, {
8
+ readonly label: "Normal";
9
+ readonly source: "normal";
10
+ readonly mode: "passthrough";
11
+ }, {
12
+ readonly label: "Depth";
13
+ readonly source: "depth";
14
+ readonly mode: "depth";
15
+ }, {
16
+ readonly label: "Base Color / Albedo";
17
+ readonly source: "albedo";
18
+ readonly mode: "passthrough";
19
+ }, {
20
+ readonly label: "Material Normal / Normal Map";
21
+ readonly source: "materialNormal";
22
+ readonly mode: "passthrough";
23
+ }, {
24
+ readonly label: "Emissive";
25
+ readonly source: "emissive";
26
+ readonly mode: "passthrough";
27
+ }, {
28
+ readonly label: "Roughness";
29
+ readonly source: "roughness";
30
+ readonly mode: "passthrough";
31
+ }, {
32
+ readonly label: "AO";
33
+ readonly source: "ao";
34
+ readonly mode: "passthrough";
35
+ }, {
36
+ readonly label: "Metallic";
37
+ readonly source: "metallic";
38
+ readonly mode: "passthrough";
39
+ }, {
40
+ readonly label: "Opacity";
41
+ readonly source: "opacity";
42
+ readonly mode: "passthrough";
43
+ }, {
44
+ readonly label: "Wireframe";
45
+ readonly source: "wireframe";
46
+ readonly mode: "passthrough";
47
+ }, {
48
+ readonly label: "Lighting Only";
49
+ readonly source: "lightingOnly";
50
+ readonly mode: "passthrough";
51
+ }, {
52
+ readonly label: "Reflection Only";
53
+ readonly source: "reflectionOnly";
54
+ readonly mode: "passthrough";
55
+ }, {
56
+ readonly label: "Estimated Shader Complexity";
57
+ readonly source: "shaderCost";
58
+ readonly mode: "heatmap";
59
+ }];
60
+ export declare function getDebugViewLabels(views?: readonly DebugView[]): string[];
@@ -0,0 +1,21 @@
1
+ export type LayoutMode = "single" | "overlay" | "split-h" | "split-v" | "quad" | "row" | "column" | "grid";
2
+ export interface DebugViewLayoutOptions {
3
+ slots?: number;
4
+ columns?: number;
5
+ rows?: number;
6
+ }
7
+ export interface DebugViewLayoutConfig extends DebugViewLayoutOptions {
8
+ mode: LayoutMode;
9
+ }
10
+ export type DebugViewLayout = LayoutMode | DebugViewLayoutConfig;
11
+ export type LayoutPresentation = "single" | "overlay" | "grid";
12
+ export interface ResolvedDebugViewLayout {
13
+ mode: LayoutMode;
14
+ presentation: LayoutPresentation;
15
+ columns: number;
16
+ rows: number;
17
+ slots: number;
18
+ }
19
+ export declare const LAYOUT_INDEX: Record<LayoutMode, number>;
20
+ export declare function resolveDebugViewLayout(layout?: DebugViewLayout, options?: DebugViewLayoutOptions): ResolvedDebugViewLayout;
21
+ export declare function isResolvedDebugViewLayout(layout: DebugViewLayout | ResolvedDebugViewLayout): layout is ResolvedDebugViewLayout;
@@ -0,0 +1,5 @@
1
+ import type { DebugView, DebugViewSource, ViewMode } from "./debug-views-tsl/compositor";
2
+ import { type DebugViewLayout, type ResolvedDebugViewLayout } from "./debug-view-layout";
3
+ export declare function getDefaultDebugViewSource(view: DebugView): DebugViewSource;
4
+ export declare function getResolvedDebugViewMode(view: DebugView): ViewMode;
5
+ export declare function selectPipelineViews(views: readonly DebugView[], activeView: number, layout: DebugViewLayout | ResolvedDebugViewLayout): DebugView[];
@@ -0,0 +1,8 @@
1
+ import type { DebugView } from "./debug-views-tsl/compositor";
2
+ import type { ResolvedDebugViewLayout } from "./debug-view-layout";
3
+ import type { DebugViewportPlan } from "./debug-viewport-plan";
4
+ export type DebugViewportLabel = string | undefined;
5
+ export type DebugViewportLabelFormatter = (view: DebugView, viewportIndex: number) => DebugViewportLabel;
6
+ export type DebugViewportLabels = readonly DebugViewportLabel[] | DebugViewportLabelFormatter;
7
+ export declare function createDebugViewportLabels(views: readonly DebugView[], layout: ResolvedDebugViewLayout, labels?: DebugViewportLabels): string[];
8
+ export declare function createDebugViewportPlanLabels(plan: DebugViewportPlan, labels?: DebugViewportLabels): string[];
@@ -0,0 +1,29 @@
1
+ import type { Camera } from "three";
2
+ import type { DebugView, DebugViewSource } from "./debug-views-tsl/compositor";
3
+ import { type DebugViewLayout, type ResolvedDebugViewLayout } from "./debug-view-layout";
4
+ export type DebugViewsMode = "compose" | "viewport";
5
+ export type DebugViewportResolutionScale = 1 | 0.5 | 0.25;
6
+ export interface DebugViewportView {
7
+ view: number | DebugViewSource | DebugView;
8
+ label?: string;
9
+ camera?: Camera;
10
+ resolutionScale?: number;
11
+ }
12
+ export interface DebugViewportCell {
13
+ index: number;
14
+ view: DebugView;
15
+ camera?: Camera;
16
+ resolutionScale: DebugViewportResolutionScale;
17
+ }
18
+ export interface DebugViewportPlan {
19
+ layout: ResolvedDebugViewLayout;
20
+ views: DebugView[];
21
+ cells: DebugViewportCell[];
22
+ }
23
+ export interface DebugViewportPlanOptions {
24
+ views: readonly DebugView[];
25
+ viewportViews?: readonly DebugViewportView[];
26
+ activeView?: number;
27
+ layout?: DebugViewLayout | ResolvedDebugViewLayout;
28
+ }
29
+ export declare function createDebugViewportPlan({ views, viewportViews, activeView, layout, }: DebugViewportPlanOptions): DebugViewportPlan;
@@ -0,0 +1,28 @@
1
+ import type { DebugViewportPlan } from "./debug-viewport-plan";
2
+ export interface DebugViewportNormalizedRect {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export interface DebugViewportCssCell {
9
+ column: number;
10
+ row: number;
11
+ }
12
+ export interface DebugViewportRect {
13
+ index: number;
14
+ css: DebugViewportCssCell;
15
+ scissor: DebugViewportNormalizedRect;
16
+ }
17
+ export declare function createDebugViewportRects(plan: DebugViewportPlan): DebugViewportRect[];
18
+ export interface DebugViewportDrawingBufferSize {
19
+ width: number;
20
+ height: number;
21
+ }
22
+ export interface DebugViewportPixelRect {
23
+ x: number;
24
+ y: number;
25
+ width: number;
26
+ height: number;
27
+ }
28
+ export declare function toDebugViewportPixels(rect: DebugViewportNormalizedRect, drawingBufferSize: DebugViewportDrawingBufferSize): DebugViewportPixelRect;
@@ -0,0 +1,19 @@
1
+ import { type DebugView } from "./debug-views-tsl/compositor";
2
+ import { type DebugViewLayout } from "./debug-view-layout";
3
+ import { type DebugViewportLabels } from "./debug-viewport-labels";
4
+ import { type DebugViewportView, type DebugViewsMode } from "./debug-viewport-plan";
5
+ export interface DebugViewsProps {
6
+ views: DebugView[];
7
+ mode?: DebugViewsMode;
8
+ viewportViews?: DebugViewportView[];
9
+ activeView?: number;
10
+ layout?: DebugViewLayout;
11
+ slots?: number;
12
+ columns?: number;
13
+ rows?: number;
14
+ showLabels?: boolean;
15
+ viewportLabels?: DebugViewportLabels;
16
+ overlayOpacity?: number;
17
+ enabled?: boolean;
18
+ }
19
+ export declare function DebugViews({ views, mode, viewportViews, activeView, layout, slots, columns, rows, showLabels, viewportLabels, overlayOpacity, enabled, }: DebugViewsProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import { type Scene } from "three";
2
+ export declare function createAoFallbacks(scene: Scene): {
3
+ apply: () => void;
4
+ refresh: () => void;
5
+ restore: () => void;
6
+ };
@@ -0,0 +1,20 @@
1
+ import type { DebugNode, Vec4Node } from "./node-types";
2
+ import type { DebugViewUniforms } from "./uniforms";
3
+ import { type DebugViewLayout, type ResolvedDebugViewLayout } from "../debug-view-layout";
4
+ export type ViewMode = "passthrough" | "normal" | "depth" | "heatmap";
5
+ export type DebugViewSource = "beauty" | "normal" | "materialNormal" | "normalMap" | "depth" | "albedo" | "baseColor" | "roughness" | "metalness" | "metallic" | "opacity" | "transparency" | "ao" | "emissive" | "wireframe" | "lightingOnly" | "reflectionOnly" | "shaderCost";
6
+ export interface DebugView {
7
+ id?: string;
8
+ label: string;
9
+ node?: DebugNode;
10
+ mode?: ViewMode;
11
+ source?: DebugViewSource;
12
+ scale?: number;
13
+ bias?: number;
14
+ }
15
+ export interface ViewCompositorConfig {
16
+ views: DebugView[];
17
+ uniforms: DebugViewUniforms;
18
+ layout?: DebugViewLayout | ResolvedDebugViewLayout;
19
+ }
20
+ export declare function createViewCompositor(config: ViewCompositorConfig): Vec4Node;
@@ -0,0 +1,35 @@
1
+ import { mrt } from "three/tsl";
2
+ import type { DebugNode, FloatNode } from "./node-types";
3
+ interface DebugPass {
4
+ getTextureNode(name?: string): DebugNode;
5
+ getViewZNode(name?: string): FloatNode;
6
+ }
7
+ interface ConfigurableDebugPass extends DebugPass {
8
+ setMRT(mrtNode: ReturnType<typeof mrt>): unknown;
9
+ }
10
+ export interface MaterialDebugChannels {
11
+ roughness?: boolean;
12
+ metalness?: boolean;
13
+ ao?: boolean;
14
+ opacity?: boolean;
15
+ }
16
+ export interface SceneDebugOutputs {
17
+ normal?: boolean;
18
+ albedo?: boolean;
19
+ material?: MaterialDebugChannels;
20
+ }
21
+ export interface MaterialDetailOutputs {
22
+ materialNormal?: boolean;
23
+ emissive?: boolean;
24
+ }
25
+ interface DefaultDebugNodeResolverOptions {
26
+ materialDetailPass?: DebugPass;
27
+ wireframePass?: DebugPass;
28
+ lightingOnlyPass?: DebugPass;
29
+ reflectionOnlyPass?: DebugPass;
30
+ shaderCostPass?: DebugPass;
31
+ }
32
+ export declare function configureSceneDebugPass(scenePass: ConfigurableDebugPass, outputs: SceneDebugOutputs): void;
33
+ export declare function configureMaterialDetailPass(materialDetailPass: ConfigurableDebugPass, outputs: MaterialDetailOutputs): void;
34
+ export declare function createDefaultDebugNodeResolver(scenePass: DebugPass, options?: DefaultDebugNodeResolverOptions): (source: string) => DebugNode;
35
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { Node } from "three/webgpu";
2
+ export type DebugNode = Node;
3
+ export type FloatNode = Node<"float">;
4
+ export type Vec2Node = Node<"vec2">;
5
+ export type Vec3Node = Node<"vec3">;
6
+ export type Vec4Node = Node<"vec4">;
@@ -0,0 +1,12 @@
1
+ import { type DebugViewLayout } from "../debug-view-layout";
2
+ export type { DebugViewLayout, LayoutMode } from "../debug-view-layout";
3
+ export declare function createDebugViewUniforms(): {
4
+ activeView: import("three/webgpu").UniformNode<"float", number>;
5
+ layout: import("three/webgpu").UniformNode<"float", number>;
6
+ viewCount: import("three/webgpu").UniformNode<"float", number>;
7
+ gridColumns: import("three/webgpu").UniformNode<"float", number>;
8
+ gridRows: import("three/webgpu").UniformNode<"float", number>;
9
+ overlayOpacity: import("three/webgpu").UniformNode<"float", number>;
10
+ };
11
+ export type DebugViewUniforms = ReturnType<typeof createDebugViewUniforms>;
12
+ export declare function updateDebugViewUniforms(uniforms: DebugViewUniforms, activeView: number, layout?: DebugViewLayout, viewCount?: number, overlayOpacity?: number): void;
@@ -0,0 +1,5 @@
1
+ import type { FloatNode, Vec3Node, Vec4Node } from "./node-types";
2
+ export declare function visualizeNormal(normalNode: Vec3Node | Vec4Node): Vec4Node;
3
+ export declare function visualizeGrayscale(floatNode: FloatNode, scale?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>, bias?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>): Vec4Node;
4
+ export declare function visualizeDepth(viewDepthNode: FloatNode, scale?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>, bias?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>): Vec4Node;
5
+ export declare function visualizeHeatmap(costNode: FloatNode, scale?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>, bias?: import("three/webgpu").VarNode<"float", import("three/webgpu").ConstNode<"float", number>>): Vec4Node;
@@ -0,0 +1,11 @@
1
+ export { DEFAULT_DEBUG_VIEWS, MATERIAL_DEBUG_VIEW_SOURCES, getDebugViewLabels, } from "./debug-view-definitions";
2
+ export { createCustomDebugView, type CustomDebugNodeViewOptions, } from "./custom-debug-view";
3
+ export { isResolvedDebugViewLayout, LAYOUT_INDEX, resolveDebugViewLayout, type DebugViewLayout, type DebugViewLayoutConfig, type DebugViewLayoutOptions, type LayoutMode, type LayoutPresentation, type ResolvedDebugViewLayout, } from "./debug-view-layout";
4
+ export { createDebugViewportPlan, type DebugViewportCell, type DebugViewportPlan, type DebugViewportPlanOptions, type DebugViewportResolutionScale, type DebugViewportView, type DebugViewsMode, } from "./debug-viewport-plan";
5
+ export { createDebugViewportRenderGraphPlan, type DebugViewportRenderGraphCell, type DebugViewportRenderGraphPlan, type DebugViewportRenderPassPlan, } from "./debug-render-graph-plan";
6
+ export { createDebugViewportRects, type DebugViewportCssCell, type DebugViewportNormalizedRect, type DebugViewportRect, } from "./debug-viewport-presenter";
7
+ export { createDebugViewportLabels, createDebugViewportPlanLabels, type DebugViewportLabel, type DebugViewportLabelFormatter, type DebugViewportLabels, } from "./debug-viewport-labels";
8
+ export { createViewCompositor, type DebugView, type DebugViewSource, type ViewCompositorConfig, type ViewMode, } from "./debug-views-tsl/compositor";
9
+ export { createDebugViewUniforms, updateDebugViewUniforms, type DebugViewUniforms, } from "./debug-views-tsl/uniforms";
10
+ export { visualizeDepth, visualizeGrayscale, visualizeHeatmap, visualizeNormal, } from "./debug-views-tsl/visualize";
11
+ export type { DebugNode, FloatNode, Vec2Node, Vec3Node, Vec4Node, } from "./debug-views-tsl/node-types";
@@ -0,0 +1,2 @@
1
+ export { DebugViews, type DebugViewsProps } from "./debug-views-post";
2
+ export { useDebugViewsControls } from "./use-debug-views-controls";
@@ -0,0 +1,20 @@
1
+ import { MeshBasicMaterial, Object3D, type Scene } from "three";
2
+ import { type MaterialCostCache } from "./material-cost";
3
+ export declare const DEFAULT_SHADER_COST_BUCKET_COUNT = 16;
4
+ export interface ShaderCostOverrideOptions {
5
+ bucketCount?: number;
6
+ cache?: MaterialCostCache;
7
+ }
8
+ export interface ShaderCostOverride {
9
+ apply(scene: Scene | Object3D): ShaderCostRestore;
10
+ dispose(): void;
11
+ readonly bucketCount: number;
12
+ readonly materials: readonly MeshBasicMaterial[];
13
+ }
14
+ export interface ShaderCostRestore {
15
+ restore(): void;
16
+ readonly replacements: number;
17
+ }
18
+ export declare function createShaderCostOverride(options?: ShaderCostOverrideOptions): ShaderCostOverride;
19
+ export declare function createShaderCostBucketMaterials(bucketCount?: number): MeshBasicMaterial[];
20
+ export declare function getShaderCostBucketIndex(cost: number, bucketCount?: number): number;