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.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/assets/readme-compose-banner.png +0 -0
- package/assets/viewport-compose-quad.png +0 -0
- package/dist/custom-debug-view.js +13 -0
- package/dist/debug-render-graph-plan.js +38 -0
- package/dist/debug-render-plan.js +86 -0
- package/dist/debug-view-definitions.js +91 -0
- package/dist/debug-view-layout.js +65 -0
- package/dist/debug-view-selection.js +33 -0
- package/dist/debug-viewport-labels.js +28 -0
- package/dist/debug-viewport-plan.js +51 -0
- package/dist/debug-viewport-presenter.js +33 -0
- package/dist/debug-views-post.js +329 -0
- package/dist/debug-views-tsl/ao-fallbacks.js +103 -0
- package/dist/debug-views-tsl/compositor.js +51 -0
- package/dist/debug-views-tsl/default-debug-nodes.js +61 -0
- package/dist/debug-views-tsl/uniforms.js +19 -0
- package/dist/debug-views-tsl/visualize.js +21 -0
- package/dist/index.js +11 -0
- package/dist/react.js +3 -0
- package/dist/shader-cost/cost-override.js +67 -0
- package/dist/shader-cost/material-cost.js +302 -0
- package/dist/types/custom-debug-view.d.ts +17 -0
- package/dist/types/debug-render-graph-plan.d.ts +17 -0
- package/dist/types/debug-render-plan.d.ts +26 -0
- package/dist/types/debug-view-definitions.d.ts +60 -0
- package/dist/types/debug-view-layout.d.ts +21 -0
- package/dist/types/debug-view-selection.d.ts +5 -0
- package/dist/types/debug-viewport-labels.d.ts +8 -0
- package/dist/types/debug-viewport-plan.d.ts +29 -0
- package/dist/types/debug-viewport-presenter.d.ts +28 -0
- package/dist/types/debug-views-post.d.ts +19 -0
- package/dist/types/debug-views-tsl/ao-fallbacks.d.ts +6 -0
- package/dist/types/debug-views-tsl/compositor.d.ts +20 -0
- package/dist/types/debug-views-tsl/default-debug-nodes.d.ts +35 -0
- package/dist/types/debug-views-tsl/node-types.d.ts +6 -0
- package/dist/types/debug-views-tsl/uniforms.d.ts +12 -0
- package/dist/types/debug-views-tsl/visualize.d.ts +5 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/react.d.ts +2 -0
- package/dist/types/shader-cost/cost-override.d.ts +20 -0
- package/dist/types/shader-cost/material-cost.d.ts +15 -0
- package/dist/types/use-debug-views-controls.d.ts +16 -0
- package/dist/use-debug-views-controls.js +77 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antonio Bonet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# threejs-debug-compose
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/threejs-debug-compose)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://bundlephobia.com/package/threejs-debug-compose)
|
|
6
|
+
|
|
7
|
+
Composable TSL debug views for a Three.js WebGPU render pipeline.
|
|
8
|
+
|
|
9
|
+
The demo renders the scene into compact WebGPU MRT passes, exposes Beauty/Normal/Depth plus packed material buffers, and composites them through a fullscreen `RenderPipeline`.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { DebugViews } from "./components/debug-views"
|
|
17
|
+
|
|
18
|
+
<DebugViews
|
|
19
|
+
views={[
|
|
20
|
+
{ label: "Beauty", source: "beauty", mode: "passthrough" },
|
|
21
|
+
{ label: "Normal", source: "normal", mode: "passthrough" },
|
|
22
|
+
{ label: "Depth", source: "depth", mode: "depth" },
|
|
23
|
+
{ label: "Base Color / Albedo", source: "albedo", mode: "passthrough" },
|
|
24
|
+
]}
|
|
25
|
+
layout="single"
|
|
26
|
+
activeView={0}
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Built-in Views
|
|
31
|
+
|
|
32
|
+
| Mode | Source | Output |
|
|
33
|
+
|------|--------|--------|
|
|
34
|
+
| `passthrough` | scene color output | beauty pass |
|
|
35
|
+
| `passthrough` | 8-bit encoded `normalView` MRT output | RGB normal visualization |
|
|
36
|
+
| `passthrough` | 8-bit encoded material detail MRT | material normal / normal-map visualization |
|
|
37
|
+
| `depth` | pass depth texture converted to view-space distance | inverted grayscale |
|
|
38
|
+
| `passthrough` | packed material MRT | base color/albedo, roughness, AO, metallic, opacity |
|
|
39
|
+
| `passthrough` | material detail MRT | emissive color |
|
|
40
|
+
| `passthrough` | wireframe override pass | white wireframe |
|
|
41
|
+
| `passthrough` | neutral material override pass | lighting-only visualization |
|
|
42
|
+
| `passthrough` | reflective neutral material override pass | reflection-only visualization |
|
|
43
|
+
| `heatmap` | bucketed shader-complexity override pass | estimated shader complexity heatmap |
|
|
44
|
+
|
|
45
|
+
The material data is packed into one RGBA target:
|
|
46
|
+
|
|
47
|
+
- `R`: roughness
|
|
48
|
+
- `G`: metallic
|
|
49
|
+
- `B`: AO
|
|
50
|
+
- `A`: opacity
|
|
51
|
+
|
|
52
|
+
This keeps the composer under the common WebGPU `maxColorAttachmentBytesPerSample` limit instead of allocating one render target per scalar debug view.
|
|
53
|
+
|
|
54
|
+
Emissive and material-normal/normal-map views use a second small MRT pass. That keeps the main pass below the attachment byte budget while preserving both geometry normals and material-perturbed normals. Lighting-only, reflection-only, estimated shader-complexity, and wireframe use demand-driven override passes, so they add GPU work only when selected by the active layout or viewport plan. `shaderCost` is an estimated complexity view, not a native GPU instruction counter: inferred program/material signals choose a bounded grayscale bucket material, then TSL maps that scalar to a heat color.
|
|
55
|
+
|
|
56
|
+
## Render Modes
|
|
57
|
+
|
|
58
|
+
`DebugViews` supports two public modes:
|
|
59
|
+
|
|
60
|
+
- `compose` - default/current path. One TSL fullscreen compositor presents single, overlay, split, row, column, and grid layouts.
|
|
61
|
+
- `viewport` - explicit viewport-assignment path. `viewportViews` defines the panes to present; the internal render-graph plan dedupes repeated pass construction and presents cells with renderer viewport/scissor bounds.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<DebugViews
|
|
65
|
+
mode="viewport"
|
|
66
|
+
views={views}
|
|
67
|
+
viewportViews={[
|
|
68
|
+
{ view: "beauty", label: "Beauty" },
|
|
69
|
+
{ view: "lightingOnly", label: "Lighting" },
|
|
70
|
+
{ view: "normal", label: "Normals", resolutionScale: 0.5 },
|
|
71
|
+
{ view: "roughness", label: "Roughness", resolutionScale: 0.5 },
|
|
72
|
+
]}
|
|
73
|
+
layout="row"
|
|
74
|
+
slots={4}
|
|
75
|
+
showLabels
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Use `compose` for cheap compositing and overlays. Use `viewport` when callers need stable pane assignments, labels, per-pane resolution policy, or scissor-based presentation. `resolutionScale` is quantized to `1`, `0.5`, or `0.25` so render targets can be pooled predictably instead of producing one-off VRAM allocations.
|
|
80
|
+
|
|
81
|
+
## Layouts
|
|
82
|
+
|
|
83
|
+
- `single` - one view at a time (switch with `activeView`)
|
|
84
|
+
- `split-h` - left/right split by view index
|
|
85
|
+
- `split-v` - top/bottom split by view index
|
|
86
|
+
- `quad` - 2x2 grid; empty cells repeat the beauty view
|
|
87
|
+
- `row` - N views side by side with `slots`
|
|
88
|
+
- `column` - N stacked views with `slots`
|
|
89
|
+
- `grid` - explicit `columns` x `rows` topology
|
|
90
|
+
- `overlay` - alpha blend views over the beauty pass
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
<DebugViews views={views} layout="row" slots={4} />
|
|
94
|
+
<DebugViews views={views} layout="row" slots={3} />
|
|
95
|
+
<DebugViews views={views} layout="grid" columns={4} rows={1} />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The render plan still selects only the visible slot budget, so a four-wide row does not force every registered debug source to allocate.
|
|
99
|
+
|
|
100
|
+
## Viewport Labels
|
|
101
|
+
|
|
102
|
+
Enable labels to identify each viewport in split, row, column, or grid layouts:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<DebugViews
|
|
106
|
+
views={views}
|
|
107
|
+
layout="row"
|
|
108
|
+
slots={4}
|
|
109
|
+
showLabels
|
|
110
|
+
viewportLabels={["Beauty", "Normals", "Depth", "Albedo"]}
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Custom TSL Nodes
|
|
115
|
+
|
|
116
|
+
You can provide a custom node per view. If omitted, the component resolves a built-in source node from the scene pass.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { float, vec4 } from "three/tsl"
|
|
120
|
+
|
|
121
|
+
{ label: "Constant", node: float(0.5), mode: "depth", scale: 1 }
|
|
122
|
+
{ label: "Custom Color", node: vec4(1, 0, 0, 1), mode: "passthrough" }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Leva Controls
|
|
126
|
+
|
|
127
|
+
Interactive GUI for switching views at runtime:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { useDebugViewsControls } from "./components/debug-views"
|
|
131
|
+
|
|
132
|
+
const controls = useDebugViewsControls({
|
|
133
|
+
viewLabels: ["Beauty", "Normal", "Depth", "Base Color / Albedo"],
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Verification
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pnpm typecheck
|
|
141
|
+
pnpm test
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### Stable Custom Debug Views
|
|
146
|
+
|
|
147
|
+
For custom shader/debug nodes that may be recreated between React renders, prefer `createCustomDebugView` with a stable `id`:
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import { float, vec4 } from "three/tsl"
|
|
151
|
+
import { createCustomDebugView, DEFAULT_DEBUG_VIEWS, DebugViews } from "./components/debug-views"
|
|
152
|
+
|
|
153
|
+
const fresnelView = createCustomDebugView({
|
|
154
|
+
id: "shader:fresnel",
|
|
155
|
+
label: "Fresnel",
|
|
156
|
+
node: vec4(float(1), float(0), float(0), float(1)),
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
<DebugViews views={[...DEFAULT_DEBUG_VIEWS, fresnelView]} />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The viewport render graph uses the stable `id` to dedupe equivalent custom node views. If the custom debug output needs its own render target, material override, or disposal lifecycle, model it as a dedicated pass provider instead of forcing it into a compositor-only node.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region components/debug-views/custom-debug-view.ts
|
|
2
|
+
function e({ id: e, label: t, node: n, mode: r = "passthrough", scale: i, bias: a }) {
|
|
3
|
+
return {
|
|
4
|
+
id: e,
|
|
5
|
+
label: t,
|
|
6
|
+
node: n,
|
|
7
|
+
mode: r,
|
|
8
|
+
scale: i,
|
|
9
|
+
bias: a
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as createCustomDebugView };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getDefaultDebugViewSource as e, getResolvedDebugViewMode as t } from "./debug-view-selection.js";
|
|
2
|
+
//#region components/debug-views/debug-render-graph-plan.ts
|
|
3
|
+
function n(e) {
|
|
4
|
+
let t = [], n = /* @__PURE__ */ new Map();
|
|
5
|
+
return {
|
|
6
|
+
passes: t,
|
|
7
|
+
cells: e.cells.map((e) => {
|
|
8
|
+
let r = a(e), i = n.get(r);
|
|
9
|
+
return i === void 0 && (i = t.length, n.set(r, i), t.push({
|
|
10
|
+
key: r,
|
|
11
|
+
view: e.view,
|
|
12
|
+
camera: e.camera,
|
|
13
|
+
resolutionScale: e.resolutionScale
|
|
14
|
+
})), {
|
|
15
|
+
...e,
|
|
16
|
+
passIndex: i
|
|
17
|
+
};
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var r = /* @__PURE__ */ new WeakMap(), i = 0;
|
|
22
|
+
function a(n) {
|
|
23
|
+
return [
|
|
24
|
+
e(n.view),
|
|
25
|
+
t(n.view),
|
|
26
|
+
n.view.id ? `id:${n.view.id}` : n.view.node ? `node:${o(n.view.node)}` : "default",
|
|
27
|
+
n.camera ? `camera:${n.camera.uuid}` : "camera:default",
|
|
28
|
+
n.resolutionScale,
|
|
29
|
+
n.view.scale ?? "scale:default",
|
|
30
|
+
n.view.bias ?? "bias:default"
|
|
31
|
+
].join("|");
|
|
32
|
+
}
|
|
33
|
+
function o(e) {
|
|
34
|
+
let t = r.get(e);
|
|
35
|
+
return t === void 0 && (t = i, i += 1, r.set(e, t)), t;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { n as createDebugViewportRenderGraphPlan };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { getDefaultDebugViewSource as e, selectPipelineViews as t } from "./debug-view-selection.js";
|
|
2
|
+
import { UnsignedByteType as n } from "three";
|
|
3
|
+
//#region components/debug-views/debug-render-plan.ts
|
|
4
|
+
function r(e, n, r) {
|
|
5
|
+
let i = t(e, n, r), l = a(i), d = o(i);
|
|
6
|
+
return {
|
|
7
|
+
views: i,
|
|
8
|
+
sceneOutputs: l,
|
|
9
|
+
materialDetailOutputs: d,
|
|
10
|
+
usesMaterialDetailPass: f(d),
|
|
11
|
+
usesWireframePass: u(i, "wireframe"),
|
|
12
|
+
usesLightingOnlyPass: u(i, "lightingOnly"),
|
|
13
|
+
usesReflectionOnlyPass: u(i, "reflectionOnly"),
|
|
14
|
+
usesShaderCostPass: u(i, "shaderCost"),
|
|
15
|
+
usesAoFallback: u(i, "ao"),
|
|
16
|
+
sceneTextureTypes: s(l),
|
|
17
|
+
materialDetailTextureTypes: c(d)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function i(e, t) {
|
|
21
|
+
for (let n of t) e.getTexture(n.name).type = n.type;
|
|
22
|
+
}
|
|
23
|
+
function a(t) {
|
|
24
|
+
let n = {}, r = {};
|
|
25
|
+
for (let i of t) if (!i.node) switch (e(i)) {
|
|
26
|
+
case "normal":
|
|
27
|
+
n.normal = !0;
|
|
28
|
+
break;
|
|
29
|
+
case "albedo":
|
|
30
|
+
case "baseColor":
|
|
31
|
+
n.albedo = !0;
|
|
32
|
+
break;
|
|
33
|
+
case "roughness":
|
|
34
|
+
r.roughness = !0;
|
|
35
|
+
break;
|
|
36
|
+
case "metalness":
|
|
37
|
+
case "metallic":
|
|
38
|
+
r.metalness = !0;
|
|
39
|
+
break;
|
|
40
|
+
case "ao":
|
|
41
|
+
r.ao = !0;
|
|
42
|
+
break;
|
|
43
|
+
case "opacity":
|
|
44
|
+
case "transparency":
|
|
45
|
+
r.opacity = !0;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
return d(r) && (n.material = r), n;
|
|
49
|
+
}
|
|
50
|
+
function o(t) {
|
|
51
|
+
let n = {};
|
|
52
|
+
for (let r of t) if (!r.node) switch (e(r)) {
|
|
53
|
+
case "materialNormal":
|
|
54
|
+
case "normalMap":
|
|
55
|
+
n.materialNormal = !0;
|
|
56
|
+
break;
|
|
57
|
+
case "emissive":
|
|
58
|
+
n.emissive = !0;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
return n;
|
|
62
|
+
}
|
|
63
|
+
function s(e) {
|
|
64
|
+
let t = [];
|
|
65
|
+
return e.normal && t.push(l("normal")), e.albedo && t.push(l("albedo")), e.material && t.push(l("material")), t;
|
|
66
|
+
}
|
|
67
|
+
function c(e) {
|
|
68
|
+
return e.materialNormal ? [l("materialNormal")] : [];
|
|
69
|
+
}
|
|
70
|
+
function l(e) {
|
|
71
|
+
return {
|
|
72
|
+
name: e,
|
|
73
|
+
type: n
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function u(t, n) {
|
|
77
|
+
return t.some((t) => !t.node && e(t) === n);
|
|
78
|
+
}
|
|
79
|
+
function d(e) {
|
|
80
|
+
return !!(e.roughness || e.metalness || e.ao || e.opacity);
|
|
81
|
+
}
|
|
82
|
+
function f(e) {
|
|
83
|
+
return !!(e.materialNormal || e.emissive);
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { i as applyDebugTextureTypes, r as createDebugRenderPlan };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region components/debug-views/debug-view-definitions.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"albedo",
|
|
4
|
+
"materialNormal",
|
|
5
|
+
"normalMap",
|
|
6
|
+
"emissive",
|
|
7
|
+
"roughness",
|
|
8
|
+
"ao",
|
|
9
|
+
"metallic",
|
|
10
|
+
"opacity",
|
|
11
|
+
"wireframe",
|
|
12
|
+
"lightingOnly",
|
|
13
|
+
"reflectionOnly",
|
|
14
|
+
"shaderCost"
|
|
15
|
+
], t = [
|
|
16
|
+
{
|
|
17
|
+
label: "Beauty",
|
|
18
|
+
source: "beauty",
|
|
19
|
+
mode: "passthrough"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "Normal",
|
|
23
|
+
source: "normal",
|
|
24
|
+
mode: "passthrough"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Depth",
|
|
28
|
+
source: "depth",
|
|
29
|
+
mode: "depth"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "Base Color / Albedo",
|
|
33
|
+
source: "albedo",
|
|
34
|
+
mode: "passthrough"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "Material Normal / Normal Map",
|
|
38
|
+
source: "materialNormal",
|
|
39
|
+
mode: "passthrough"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: "Emissive",
|
|
43
|
+
source: "emissive",
|
|
44
|
+
mode: "passthrough"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Roughness",
|
|
48
|
+
source: "roughness",
|
|
49
|
+
mode: "passthrough"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "AO",
|
|
53
|
+
source: "ao",
|
|
54
|
+
mode: "passthrough"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "Metallic",
|
|
58
|
+
source: "metallic",
|
|
59
|
+
mode: "passthrough"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: "Opacity",
|
|
63
|
+
source: "opacity",
|
|
64
|
+
mode: "passthrough"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: "Wireframe",
|
|
68
|
+
source: "wireframe",
|
|
69
|
+
mode: "passthrough"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "Lighting Only",
|
|
73
|
+
source: "lightingOnly",
|
|
74
|
+
mode: "passthrough"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
label: "Reflection Only",
|
|
78
|
+
source: "reflectionOnly",
|
|
79
|
+
mode: "passthrough"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: "Estimated Shader Complexity",
|
|
83
|
+
source: "shaderCost",
|
|
84
|
+
mode: "heatmap"
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
function n(e = t) {
|
|
88
|
+
return e.map((e) => e.label);
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { t as DEFAULT_DEBUG_VIEWS, e as MATERIAL_DEBUG_VIEW_SOURCES, n as getDebugViewLabels };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region components/debug-views/debug-view-layout.ts
|
|
2
|
+
var e = {
|
|
3
|
+
single: 0,
|
|
4
|
+
overlay: 1,
|
|
5
|
+
"split-h": 2,
|
|
6
|
+
"split-v": 3,
|
|
7
|
+
quad: 4,
|
|
8
|
+
row: 5,
|
|
9
|
+
column: 6,
|
|
10
|
+
grid: 7
|
|
11
|
+
}, t = 4;
|
|
12
|
+
function n(e = "single", n = {}) {
|
|
13
|
+
let r = i(e, n);
|
|
14
|
+
switch (r.mode) {
|
|
15
|
+
case "single": return o(r.mode, "single", 1, 1);
|
|
16
|
+
case "overlay": return o(r.mode, "overlay", 1, 1, 2);
|
|
17
|
+
case "split-h": return o(r.mode, "grid", 2, 1);
|
|
18
|
+
case "split-v": return o(r.mode, "grid", 1, 2);
|
|
19
|
+
case "quad": return o(r.mode, "grid", 2, 2);
|
|
20
|
+
case "row": {
|
|
21
|
+
let e = s(r.slots, t);
|
|
22
|
+
return o(r.mode, "grid", e, 1, e);
|
|
23
|
+
}
|
|
24
|
+
case "column": {
|
|
25
|
+
let e = s(r.slots, t);
|
|
26
|
+
return o(r.mode, "grid", 1, e, e);
|
|
27
|
+
}
|
|
28
|
+
case "grid": {
|
|
29
|
+
let e = s(r.columns, 2), t = s(r.rows, 2);
|
|
30
|
+
return o(r.mode, "grid", e, t, r.slots);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function r(e) {
|
|
35
|
+
return typeof e == "object" && "presentation" in e;
|
|
36
|
+
}
|
|
37
|
+
function i(e, t) {
|
|
38
|
+
let n = a(t);
|
|
39
|
+
return typeof e == "string" ? {
|
|
40
|
+
mode: e,
|
|
41
|
+
...n
|
|
42
|
+
} : {
|
|
43
|
+
...e,
|
|
44
|
+
...n
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function a(e) {
|
|
48
|
+
let t = {};
|
|
49
|
+
return e.slots !== void 0 && (t.slots = e.slots), e.columns !== void 0 && (t.columns = e.columns), e.rows !== void 0 && (t.rows = e.rows), t;
|
|
50
|
+
}
|
|
51
|
+
function o(e, t, n, r, i = n * r) {
|
|
52
|
+
let a = n * r;
|
|
53
|
+
return {
|
|
54
|
+
mode: e,
|
|
55
|
+
presentation: t,
|
|
56
|
+
columns: n,
|
|
57
|
+
rows: r,
|
|
58
|
+
slots: Math.min(s(i, a), a)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function s(e, t) {
|
|
62
|
+
return e === void 0 || !Number.isFinite(e) ? t : Math.max(1, Math.floor(e));
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { e as LAYOUT_INDEX, r as isResolvedDebugViewLayout, n as resolveDebugViewLayout };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isResolvedDebugViewLayout as e, resolveDebugViewLayout as t } from "./debug-view-layout.js";
|
|
2
|
+
//#region components/debug-views/debug-view-selection.ts
|
|
3
|
+
function n(e) {
|
|
4
|
+
return e.source ? e.source : e.mode === "normal" ? "normal" : e.mode === "depth" ? "depth" : "beauty";
|
|
5
|
+
}
|
|
6
|
+
function r(e) {
|
|
7
|
+
let t = e.mode ?? "passthrough";
|
|
8
|
+
if (e.node) return t;
|
|
9
|
+
switch (n(e)) {
|
|
10
|
+
case "normal":
|
|
11
|
+
case "materialNormal":
|
|
12
|
+
case "normalMap": return "passthrough";
|
|
13
|
+
default: return t;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function i(n, r, i) {
|
|
17
|
+
if (n.length === 0) return [];
|
|
18
|
+
let s = e(i) ? i : t(i), c = n[o(r, n.length)];
|
|
19
|
+
switch (s.presentation) {
|
|
20
|
+
case "single": return [c];
|
|
21
|
+
case "overlay": return a(n, c);
|
|
22
|
+
case "grid": return n.slice(0, s.slots);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function a(e, t) {
|
|
26
|
+
let r = e.find((e) => n(e) === "beauty") ?? e[0];
|
|
27
|
+
return r === t ? [r] : [r, t];
|
|
28
|
+
}
|
|
29
|
+
function o(e, t) {
|
|
30
|
+
return Math.max(0, Math.min(e, t - 1));
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { n as getDefaultDebugViewSource, r as getResolvedDebugViewMode, i as selectPipelineViews };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region components/debug-views/debug-viewport-labels.ts
|
|
2
|
+
function e(e, t, i) {
|
|
3
|
+
if (e.length === 0) return [];
|
|
4
|
+
if (t.presentation === "overlay") return [n(e, i)];
|
|
5
|
+
if (t.presentation === "single") return [r(e[0], 0, i)];
|
|
6
|
+
let a = [];
|
|
7
|
+
for (let n = 0; n < t.slots; n++) {
|
|
8
|
+
let t = e[n] ?? e[0];
|
|
9
|
+
a.push(r(t, n, i));
|
|
10
|
+
}
|
|
11
|
+
return a;
|
|
12
|
+
}
|
|
13
|
+
function t(e, t) {
|
|
14
|
+
return e.cells.map((e) => r(e.view, e.index, t));
|
|
15
|
+
}
|
|
16
|
+
function n(e, t) {
|
|
17
|
+
let n = i(e[0], 0, t);
|
|
18
|
+
return n === void 0 ? e.map((e) => e.label).join(" + ") : n;
|
|
19
|
+
}
|
|
20
|
+
function r(e, t, n) {
|
|
21
|
+
return i(e, t, n) ?? e.label;
|
|
22
|
+
}
|
|
23
|
+
function i(e, t, n) {
|
|
24
|
+
let r = typeof n == "function" ? n(e, t) : n?.[t];
|
|
25
|
+
if (r !== void 0) return r;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { e as createDebugViewportLabels, t as createDebugViewportPlanLabels };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { resolveDebugViewLayout as e } from "./debug-view-layout.js";
|
|
2
|
+
import { getDefaultDebugViewSource as t, selectPipelineViews as n } from "./debug-view-selection.js";
|
|
3
|
+
//#region components/debug-views/debug-viewport-plan.ts
|
|
4
|
+
function r({ views: t, viewportViews: r, activeView: o = 0, layout: s = "single" }) {
|
|
5
|
+
let l = i(s) ? s : e(s), u = (r?.length ? r.slice(0, l.slots).map((e) => a(t, e)) : n(t, o, l).slice(0, l.slots).map((e) => ({
|
|
6
|
+
view: e,
|
|
7
|
+
resolutionScale: 1
|
|
8
|
+
}))).map((e, t) => ({
|
|
9
|
+
index: t,
|
|
10
|
+
view: e.view,
|
|
11
|
+
camera: e.camera,
|
|
12
|
+
resolutionScale: c(e.resolutionScale)
|
|
13
|
+
}));
|
|
14
|
+
return {
|
|
15
|
+
layout: l,
|
|
16
|
+
views: u.map((e) => e.view),
|
|
17
|
+
cells: u
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function i(e) {
|
|
21
|
+
return typeof e == "object" && "presentation" in e;
|
|
22
|
+
}
|
|
23
|
+
function a(e, t) {
|
|
24
|
+
let n = o(e, t.view);
|
|
25
|
+
return {
|
|
26
|
+
view: t.label ? {
|
|
27
|
+
...n,
|
|
28
|
+
label: t.label
|
|
29
|
+
} : n,
|
|
30
|
+
camera: t.camera,
|
|
31
|
+
resolutionScale: c(t.resolutionScale)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function o(e, n) {
|
|
35
|
+
return typeof n == "number" ? e[l(n, e.length)] ?? s("beauty") : typeof n == "string" ? e.find((e) => t(e) === n) ?? s(n) : n;
|
|
36
|
+
}
|
|
37
|
+
function s(e) {
|
|
38
|
+
return {
|
|
39
|
+
label: e,
|
|
40
|
+
source: e,
|
|
41
|
+
mode: "passthrough"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function c(e) {
|
|
45
|
+
return e === void 0 || !Number.isFinite(e) || e >= .75 ? 1 : e >= .375 ? .5 : .25;
|
|
46
|
+
}
|
|
47
|
+
function l(e, t) {
|
|
48
|
+
return t <= 0 ? 0 : Math.max(0, Math.min(e, t - 1));
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { r as createDebugViewportPlan };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region components/debug-views/debug-viewport-presenter.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let { columns: t, rows: r } = e.layout, i = 1 / t, a = 1 / r;
|
|
4
|
+
return e.cells.map((e) => {
|
|
5
|
+
let r = e.index % t, o = Math.floor(e.index / t);
|
|
6
|
+
return {
|
|
7
|
+
index: e.index,
|
|
8
|
+
css: {
|
|
9
|
+
column: r + 1,
|
|
10
|
+
row: o + 1
|
|
11
|
+
},
|
|
12
|
+
scissor: {
|
|
13
|
+
x: n(r * i),
|
|
14
|
+
y: n(1 - (o + 1) * a),
|
|
15
|
+
width: n(i),
|
|
16
|
+
height: n(a)
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function t(e, t) {
|
|
22
|
+
return {
|
|
23
|
+
x: Math.round(e.x * t.width),
|
|
24
|
+
y: Math.round(e.y * t.height),
|
|
25
|
+
width: Math.round(e.width * t.width),
|
|
26
|
+
height: Math.round(e.height * t.height)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function n(e) {
|
|
30
|
+
return Math.round(e * 1e6) / 1e6;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { e as createDebugViewportRects, t as toDebugViewportPixels };
|