@playcanvas/inspector 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 +19 -0
- package/README.md +110 -0
- package/package.json +62 -0
- package/src/asset-usage.js +108 -0
- package/src/asset-view.js +370 -0
- package/src/camera-view.js +128 -0
- package/src/debug.js +31 -0
- package/src/describe.js +302 -0
- package/src/entity-inspector-script.js +130 -0
- package/src/frame-graph-view.js +767 -0
- package/src/hierarchy-view.js +475 -0
- package/src/index.js +4 -0
- package/src/input/fly-controller.js +116 -0
- package/src/input/input.js +299 -0
- package/src/input/math.js +8 -0
- package/src/input/orbit-controller.js +158 -0
- package/src/input/pose.js +207 -0
- package/src/inspector.js +3293 -0
- package/src/instance-survey.js +50 -0
- package/src/list-view.js +410 -0
- package/src/material-view.js +197 -0
- package/src/memory-view.js +344 -0
- package/src/mesh-view.js +235 -0
- package/src/model.js +170 -0
- package/src/node-model.js +404 -0
- package/src/physics-debug.js +527 -0
- package/src/physics-view.js +314 -0
- package/src/picker/picker.js +545 -0
- package/src/picker/render-pass-picker.js +206 -0
- package/src/property-view.js +628 -0
- package/src/render-target-view.js +288 -0
- package/src/renderers/texture-renderer-shaders.js +139 -0
- package/src/renderers/texture-renderer.js +430 -0
- package/src/renderers/wire-renderer.js +954 -0
- package/src/script-view.js +288 -0
- package/src/shader-view.js +287 -0
- package/src/styles.js +918 -0
- package/src/texture-view.js +186 -0
- package/src/tooltip.js +72 -0
- package/src/viewport-tools.js +695 -0
- package/types/asset-usage.d.ts +23 -0
- package/types/asset-view.d.ts +94 -0
- package/types/camera-view.d.ts +45 -0
- package/types/debug.d.ts +14 -0
- package/types/describe.d.ts +43 -0
- package/types/entity-inspector-script.d.ts +87 -0
- package/types/frame-graph-view.d.ts +155 -0
- package/types/hierarchy-view.d.ts +172 -0
- package/types/index.d.ts +3 -0
- package/types/input/fly-controller.d.ts +42 -0
- package/types/input/input.d.ts +192 -0
- package/types/input/math.d.ts +1 -0
- package/types/input/orbit-controller.d.ts +63 -0
- package/types/input/pose.d.ts +126 -0
- package/types/inspector.d.ts +1304 -0
- package/types/instance-survey.d.ts +35 -0
- package/types/list-view.d.ts +151 -0
- package/types/material-view.d.ts +63 -0
- package/types/memory-view.d.ts +95 -0
- package/types/mesh-view.d.ts +89 -0
- package/types/model.d.ts +104 -0
- package/types/node-model.d.ts +54 -0
- package/types/physics-debug.d.ts +254 -0
- package/types/physics-view.d.ts +81 -0
- package/types/picker/picker.d.ts +255 -0
- package/types/picker/render-pass-picker.d.ts +47 -0
- package/types/property-view.d.ts +189 -0
- package/types/render-target-view.d.ts +98 -0
- package/types/renderers/texture-renderer-shaders.d.ts +9 -0
- package/types/renderers/texture-renderer.d.ts +231 -0
- package/types/renderers/wire-renderer.d.ts +347 -0
- package/types/script-view.d.ts +56 -0
- package/types/shader-view.d.ts +46 -0
- package/types/styles.d.ts +22 -0
- package/types/texture-view.d.ts +30 -0
- package/types/tooltip.d.ts +17 -0
- package/types/viewport-tools.d.ts +237 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
export type RowElements = object;
|
|
2
|
+
export type SectionElements = object;
|
|
3
|
+
/**
|
|
4
|
+
* A read-only property panel for any subject a model builder can describe: a node, a render pass,
|
|
5
|
+
* a render target. Sections and rows are keyed and reconciled in place, so refreshing at a high
|
|
6
|
+
* rate only touches the text that actually changed and never resets the scroll position, the
|
|
7
|
+
* collapsed sections or the rows opened in place.
|
|
8
|
+
*
|
|
9
|
+
* A value carrying `expand` opens under its own row, to any depth, and one carrying `code` opens
|
|
10
|
+
* as a numbered block of text. Both are built on every refresh, so they follow the live object.
|
|
11
|
+
*
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export class PropertyView {
|
|
15
|
+
/**
|
|
16
|
+
* @param {HTMLElement} container - The element to render into.
|
|
17
|
+
* @param {(target: *) => void} onSelect - The value link callback.
|
|
18
|
+
*/
|
|
19
|
+
constructor(container: HTMLElement, onSelect: (target: any) => void);
|
|
20
|
+
/**
|
|
21
|
+
* The element the panel is rendered into.
|
|
22
|
+
*
|
|
23
|
+
* @type {HTMLElement}
|
|
24
|
+
*/
|
|
25
|
+
container: HTMLElement;
|
|
26
|
+
/**
|
|
27
|
+
* Called with the target of a value link when it is clicked.
|
|
28
|
+
*
|
|
29
|
+
* @type {(target: *) => void}
|
|
30
|
+
*/
|
|
31
|
+
onSelect: (target: any) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the pointer enters a link, with the link element and a function reading the
|
|
34
|
+
* link's current target, and with nulls when it leaves. The target is read through the
|
|
35
|
+
* function because a refresh can point the same element at a new target while it is hovered.
|
|
36
|
+
*
|
|
37
|
+
* @type {((el: HTMLElement|null, target: (() => *)|null) => void)|undefined}
|
|
38
|
+
*/
|
|
39
|
+
onHover: ((el: HTMLElement | null, target: (() => any) | null) => void) | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* @type {*}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private _subject;
|
|
45
|
+
/**
|
|
46
|
+
* @type {*}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private _key;
|
|
50
|
+
/**
|
|
51
|
+
* @type {((subject: *) => PropertySection[])|null}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
private _buildModel;
|
|
55
|
+
/**
|
|
56
|
+
* @type {Map<string, SectionElements>}
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
private _sections;
|
|
60
|
+
/**
|
|
61
|
+
* @type {Set<string>}
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
private _collapsed;
|
|
65
|
+
/**
|
|
66
|
+
* Keys of the rows opened in place, as section key and row key.
|
|
67
|
+
*
|
|
68
|
+
* @type {Set<string>}
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private _expanded;
|
|
72
|
+
/**
|
|
73
|
+
* How deep a chain of expanded rows may go, in case a model ever builds a cycle.
|
|
74
|
+
*
|
|
75
|
+
* @type {number}
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private _maxDepth;
|
|
79
|
+
/**
|
|
80
|
+
* How far each subject was scrolled when it was last shown, so following a link to another tab
|
|
81
|
+
* and coming back lands where it left off. Object keys are held weakly, so remembering where a
|
|
82
|
+
* texture or an entity was read does not keep it alive.
|
|
83
|
+
*
|
|
84
|
+
* @type {WeakMap<object, number>}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
private _scrollByObject;
|
|
88
|
+
/**
|
|
89
|
+
* The same, for subjects identified by a key rather than by the object itself, such as the
|
|
90
|
+
* render passes of a frame, which are recreated every frame.
|
|
91
|
+
*
|
|
92
|
+
* @type {Map<*, number>}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
private _scrollByKey;
|
|
96
|
+
/**
|
|
97
|
+
* @type {HTMLElement|null}
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private _emptyEl;
|
|
101
|
+
/**
|
|
102
|
+
* The subject being shown.
|
|
103
|
+
*
|
|
104
|
+
* @type {*}
|
|
105
|
+
*/
|
|
106
|
+
get subject(): any;
|
|
107
|
+
/**
|
|
108
|
+
* Shows a subject. The DOM is rebuilt only when the key changes, so a subject that is
|
|
109
|
+
* recreated every frame under a stable key keeps its scroll position.
|
|
110
|
+
*
|
|
111
|
+
* @param {*} subject - The subject, or null to show nothing.
|
|
112
|
+
* @param {(subject: *) => PropertySection[]} [buildModel] - Turns the subject into sections.
|
|
113
|
+
* @param {*} [key] - Identifies the subject across refreshes. Defaults to the subject itself.
|
|
114
|
+
*/
|
|
115
|
+
setSubject(subject: any, buildModel?: (subject: any) => PropertySection[], key?: any): void;
|
|
116
|
+
/**
|
|
117
|
+
* @param {*} key - The subject key to remember the current position of, if any.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
private _saveScroll;
|
|
121
|
+
/**
|
|
122
|
+
* @param {*} key - The subject key.
|
|
123
|
+
* @returns {number} How far it was scrolled when last shown, or the top.
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
private _loadScroll;
|
|
127
|
+
/**
|
|
128
|
+
* Re-reads every shown property and updates the text that changed.
|
|
129
|
+
*/
|
|
130
|
+
refresh(): void;
|
|
131
|
+
/**
|
|
132
|
+
* @param {PropertySection[]} model - The sections to show, in order.
|
|
133
|
+
* @private
|
|
134
|
+
*/
|
|
135
|
+
private _renderSections;
|
|
136
|
+
/**
|
|
137
|
+
* @param {SectionElements} section - The section.
|
|
138
|
+
* @param {PropertyRow[]} rows - The rows to show, in order.
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
private _renderRows;
|
|
142
|
+
/**
|
|
143
|
+
* The rows to show for a list of model rows: each row, followed by the rows of whatever it
|
|
144
|
+
* expands into while it is open. Keys are prefixed by their parent so that a label repeated at
|
|
145
|
+
* two depths, such as the material of two mesh instances, stays distinct.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} sectionKey - The key of the section being rendered.
|
|
148
|
+
* @param {PropertyRow[]} rows - The rows to flatten.
|
|
149
|
+
* @param {number} depth - The depth the rows sit at.
|
|
150
|
+
* @param {string} prefix - The key of the row they expand from.
|
|
151
|
+
* @returns {PropertyRow[]} The flattened rows.
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
private _flatten;
|
|
155
|
+
/**
|
|
156
|
+
* Keeps the buttons of a row in step with its value. The buttons are rebuilt only when their text
|
|
157
|
+
* or state changes, and always run the actions of the latest refresh, whose closures hold the
|
|
158
|
+
* current state.
|
|
159
|
+
*
|
|
160
|
+
* @param {RowElements} elements - The row.
|
|
161
|
+
* @param {Described['actions']|null} actions - The actions, or null for a row without any.
|
|
162
|
+
* @private
|
|
163
|
+
*/
|
|
164
|
+
private _renderActions;
|
|
165
|
+
/**
|
|
166
|
+
* Keeps the copy button and the expanded code block of a row in step with its value.
|
|
167
|
+
*
|
|
168
|
+
* @param {SectionElements} section - The section the row belongs to.
|
|
169
|
+
* @param {RowElements} elements - The row.
|
|
170
|
+
* @param {string|null} code - The code, or null for a row without any.
|
|
171
|
+
* @param {boolean} expanded - Whether the block is shown.
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
private _renderCode;
|
|
175
|
+
/**
|
|
176
|
+
* @param {PropertySection} section - The section.
|
|
177
|
+
* @returns {SectionElements} The new section elements.
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
private _createSection;
|
|
181
|
+
/**
|
|
182
|
+
* @param {SectionElements} section - The section the row belongs to.
|
|
183
|
+
* @param {PropertyRow} row - The row.
|
|
184
|
+
* @returns {RowElements} The new row elements.
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
private _createRow;
|
|
188
|
+
}
|
|
189
|
+
import type { PropertySection } from './model.js';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A texture of a render target that the preview can sample.
|
|
3
|
+
*/
|
|
4
|
+
export type PreviewAttachment = {
|
|
5
|
+
/**
|
|
6
|
+
* - 'color0', 'color1' and so on, or 'depth'.
|
|
7
|
+
*/
|
|
8
|
+
key: string;
|
|
9
|
+
/**
|
|
10
|
+
* - The label shown in the attachment selector.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* - The texture to sample.
|
|
15
|
+
*/
|
|
16
|
+
texture: FILTER_NEAREST;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Everything the property view shows for a render target: its setup, the passes that rendered
|
|
20
|
+
* into it this frame (linked), its attachments, and every other public property.
|
|
21
|
+
*
|
|
22
|
+
* @param {RenderTarget} rt - The render target.
|
|
23
|
+
* @param {{ device: GraphicsDevice, frame: FrameSnapshot|null }} ctx - The device and the captured frame.
|
|
24
|
+
* @returns {PropertySection[]} The sections.
|
|
25
|
+
*/
|
|
26
|
+
export function buildRenderTargetModel(rt: FILTER_NEAREST, ctx: {
|
|
27
|
+
device: FILTER_NEAREST;
|
|
28
|
+
frame: FrameSnapshot | null;
|
|
29
|
+
}): PropertySection[];
|
|
30
|
+
/**
|
|
31
|
+
* The r, g, b and a channels an uncompressed color format stores, read from its name: R8 stores
|
|
32
|
+
* 'r', RG16F 'rg', SRGB8 'rgb', BGRA8 and RGB10A2 'rgba'. Sampling a channel the format lacks
|
|
33
|
+
* returns a constant (0, or 1 for alpha), so a preview of it shows nothing. Empty when the name
|
|
34
|
+
* carries no channel letters: depth, the packed 111110F and compressed formats.
|
|
35
|
+
*
|
|
36
|
+
* @param {number} format - A PIXELFORMAT_* constant.
|
|
37
|
+
* @returns {string} The stored channels as lower-case letters from 'rgba', or ''.
|
|
38
|
+
*/
|
|
39
|
+
export function formatChannels(format: number): string;
|
|
40
|
+
/**
|
|
41
|
+
* @param {number} format - A PIXELFORMAT_* constant.
|
|
42
|
+
* @returns {boolean} Whether it is one of the depth formats, which preview as raw grayscale.
|
|
43
|
+
*/
|
|
44
|
+
export function isDepthFormat(format: number): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A texture of a render target that the preview can sample.
|
|
47
|
+
*
|
|
48
|
+
* @typedef {object} PreviewAttachment
|
|
49
|
+
* @property {string} key - 'color0', 'color1' and so on, or 'depth'.
|
|
50
|
+
* @property {string} label - The label shown in the attachment selector.
|
|
51
|
+
* @property {Texture} texture - The texture to sample.
|
|
52
|
+
* @ignore
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* The textures of a render target a preview can sample: each color attachment, using the resolve
|
|
56
|
+
* texture of the first when the target keeps explicit multisampled color buffers, and the depth
|
|
57
|
+
* buffer when it is a texture. The backbuffer has none: it is the screen itself.
|
|
58
|
+
*
|
|
59
|
+
* @param {RenderTarget} rt - The render target.
|
|
60
|
+
* @param {GraphicsDevice} device - The device.
|
|
61
|
+
* @returns {PreviewAttachment[]} The attachments, in selector order.
|
|
62
|
+
*/
|
|
63
|
+
export function previewAttachments(rt: FILTER_NEAREST, device: FILTER_NEAREST): PreviewAttachment[];
|
|
64
|
+
/**
|
|
65
|
+
* Mirrors the checks TextureRenderer applies before drawing, so the panel can say why a texture
|
|
66
|
+
* cannot be shown instead of letting the renderer warn once and draw nothing.
|
|
67
|
+
*
|
|
68
|
+
* @param {Texture|null} texture - The texture.
|
|
69
|
+
* @param {GraphicsDevice} device - The device.
|
|
70
|
+
* @returns {{ ok: boolean, reason: string }} Whether it can be previewed, and if not, why.
|
|
71
|
+
*/
|
|
72
|
+
export function previewSupport(texture: FILTER_NEAREST | null, device: FILTER_NEAREST): {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
reason: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* One row per render target on the device, dimmed when no pass of the captured frame used it.
|
|
78
|
+
*
|
|
79
|
+
* @param {GraphicsDevice} device - The device.
|
|
80
|
+
* @param {FrameSnapshot|null} frame - The captured frame, for usage counts.
|
|
81
|
+
* @returns {ListRow[]} The rows.
|
|
82
|
+
*/
|
|
83
|
+
export function renderTargetRows(device: FILTER_NEAREST, frame: FrameSnapshot | null): ListRow[];
|
|
84
|
+
/**
|
|
85
|
+
* Whether a texture holds its rows bottom-up, as a render target with the bottom origin stores
|
|
86
|
+
* them, or with the native origin on WebGL2. The texture renderer shows row 0 at the top, so such
|
|
87
|
+
* a preview needs flipping to appear upright.
|
|
88
|
+
*
|
|
89
|
+
* @param {Texture} texture - The texture.
|
|
90
|
+
* @param {GraphicsDevice} device - The device.
|
|
91
|
+
* @param {RenderTarget|null} [rt] - The render target it is attached to. Looked up on the device
|
|
92
|
+
* when not given.
|
|
93
|
+
* @returns {boolean} Whether it is stored bottom-up.
|
|
94
|
+
*/
|
|
95
|
+
export function storedBottomUp(texture: FILTER_NEAREST, device: FILTER_NEAREST, rt?: FILTER_NEAREST | null): boolean;
|
|
96
|
+
import type { FrameSnapshot } from './frame-graph-view.js';
|
|
97
|
+
import type { PropertySection } from './model.js';
|
|
98
|
+
import type { ListRow } from './list-view.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds shaders for one debug texture sampling mode.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} mode - Filtered color, unfilterable color, raw depth, or scene depth.
|
|
5
|
+
* @param {string} encoding - The source texture's encoding.
|
|
6
|
+
* @returns {ShaderDesc} Shader description.
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
export function createTextureShaderDesc(mode: string, encoding: string): ChunkUtils;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
export type TextureSlot = {
|
|
2
|
+
/**
|
|
3
|
+
* - The persistent screen-space quad.
|
|
4
|
+
*/
|
|
5
|
+
meshInstance: MeshInstance;
|
|
6
|
+
/**
|
|
7
|
+
* - Material owned by this slot.
|
|
8
|
+
*/
|
|
9
|
+
material: ShaderMaterial;
|
|
10
|
+
/**
|
|
11
|
+
* - The last sampling mode.
|
|
12
|
+
*/
|
|
13
|
+
mode: string;
|
|
14
|
+
/**
|
|
15
|
+
* - The last source encoding.
|
|
16
|
+
*/
|
|
17
|
+
encoding: string;
|
|
18
|
+
/**
|
|
19
|
+
* - Channels selected for this preview.
|
|
20
|
+
*/
|
|
21
|
+
channelIndices: Int32Array;
|
|
22
|
+
/**
|
|
23
|
+
* - The texture shown this frame, or null.
|
|
24
|
+
*/
|
|
25
|
+
texture: BLEND_NORMAL | null;
|
|
26
|
+
};
|
|
27
|
+
export type TexturePool = {
|
|
28
|
+
/**
|
|
29
|
+
* - Slots in submission order.
|
|
30
|
+
*/
|
|
31
|
+
slots: TextureSlot[];
|
|
32
|
+
/**
|
|
33
|
+
* - Registered instances, used for cleanup.
|
|
34
|
+
*/
|
|
35
|
+
meshInstances: MeshInstance[];
|
|
36
|
+
/**
|
|
37
|
+
* - Number of submissions this frame.
|
|
38
|
+
*/
|
|
39
|
+
used: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Displays textures for a single frame, for debugging. Call {@link draw} or {@link sceneDepth}
|
|
43
|
+
* during update or prerender on every frame the preview should be visible. Positions specify
|
|
44
|
+
* the top-left corner in normalized camera-viewport coordinates: (0, 0) is top-left and (1, 1)
|
|
45
|
+
* is bottom-right. Width and height are fractions of the viewport; a rectangle of (0, 0, 1, 1)
|
|
46
|
+
* fills it. Signed sizes can flip a preview, and rectangles can extend outside the viewport.
|
|
47
|
+
*
|
|
48
|
+
* Supports 2D color textures in normalized, floating-point and device-supported compressed
|
|
49
|
+
* formats. Linear and sRGB color, and RGBM, RGBE and RGBP encoded HDR color, are detected
|
|
50
|
+
* automatically with the default {@link channels} selection, and single-channel formats such as
|
|
51
|
+
* {@link PIXELFORMAT_R8} display their channel as grayscale. Other selections display stored
|
|
52
|
+
* channel values, including alpha, as opaque previews.
|
|
53
|
+
*
|
|
54
|
+
* Depth textures using {@link PIXELFORMAT_DEPTH}, {@link PIXELFORMAT_DEPTH16} or
|
|
55
|
+
* {@link PIXELFORMAT_DEPTHSTENCIL} are displayed as raw grayscale values. Use {@link sceneDepth}
|
|
56
|
+
* to display the rendering camera's scene depth, linearized and normalized by its far clip
|
|
57
|
+
* distance. The camera must have scene depth capture enabled.
|
|
58
|
+
*
|
|
59
|
+
* Cube, volume, array, integer and multisampled textures are not supported. On WebGL2, raw depth
|
|
60
|
+
* textures must have comparison sampling disabled, and both raw depth and non-filterable float
|
|
61
|
+
* textures require nearest minification and magnification filters. WebGPU supports these textures
|
|
62
|
+
* regardless of their filtering and comparison sampler settings.
|
|
63
|
+
*
|
|
64
|
+
* Resources are released automatically when the application is destroyed, or earlier by calling
|
|
65
|
+
* {@link destroy}. Supplied textures are never destroyed by this helper.
|
|
66
|
+
*
|
|
67
|
+
* Previews produce fully opaque pixels but are drawn as alpha-blended instances, so they render in
|
|
68
|
+
* layers that only draw their transparent sub-layer, such as the default UI layer, which is also
|
|
69
|
+
* where they escape a camera frame's post-processing. They do not write or test depth and do not
|
|
70
|
+
* cast shadows. Ordering against other transparent geometry follows the destination layer's
|
|
71
|
+
* transparent sort mode.
|
|
72
|
+
*
|
|
73
|
+
* Every camera rendering the destination layer draws the previews, including cameras rendering
|
|
74
|
+
* into a texture. Set {@link camera} to limit them to a single camera, typically the one rendering
|
|
75
|
+
* to the screen. A render pass whose target has the previewed texture among its attachments never
|
|
76
|
+
* draws that preview: sampling a texture while rendering into it is undefined on WebGL and an
|
|
77
|
+
* error on WebGPU. Both rules are applied as each layer is rendered, against the target the pass
|
|
78
|
+
* really renders into, so they hold for camera frames and custom render passes and do not depend
|
|
79
|
+
* on frustum culling.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const textures = new TextureRenderer(app);
|
|
83
|
+
* app.on('update', () => {
|
|
84
|
+
* textures.draw(texture, 0.7, 0.7, 0.25, 0.25);
|
|
85
|
+
* });
|
|
86
|
+
* @example
|
|
87
|
+
* // camera is an entity with a camera component.
|
|
88
|
+
* camera.camera.requestSceneDepthMap(true);
|
|
89
|
+
* const textures = new TextureRenderer(app);
|
|
90
|
+
* app.on('update', () => {
|
|
91
|
+
* textures.sceneDepth(0.7, 0.7, 0.25, 0.25);
|
|
92
|
+
* });
|
|
93
|
+
* @category Graphics
|
|
94
|
+
*/
|
|
95
|
+
export class TextureRenderer {
|
|
96
|
+
/**
|
|
97
|
+
* Creates a debug texture renderer.
|
|
98
|
+
*
|
|
99
|
+
* @param {AppBase} app - The application to render into and bind resource lifetime to.
|
|
100
|
+
*/
|
|
101
|
+
constructor(app: BLEND_NORMAL);
|
|
102
|
+
/**
|
|
103
|
+
* The layer used by subsequent draw calls, or null to use the application's default debug
|
|
104
|
+
* drawing layer (normally Immediate). Defaults to null.
|
|
105
|
+
*
|
|
106
|
+
* @type {Layer|null}
|
|
107
|
+
*/
|
|
108
|
+
layer: BLEND_NORMAL | null;
|
|
109
|
+
/**
|
|
110
|
+
* The only camera that draws the previews, or null to let every camera rendering the
|
|
111
|
+
* destination layer draw them. Defaults to null.
|
|
112
|
+
*
|
|
113
|
+
* @type {CameraComponent|null}
|
|
114
|
+
*/
|
|
115
|
+
camera: BLEND_NORMAL | null;
|
|
116
|
+
/** @private */
|
|
117
|
+
private _channels;
|
|
118
|
+
/** @private */
|
|
119
|
+
private _channelIndices;
|
|
120
|
+
/**
|
|
121
|
+
* Channels displayed by subsequent {@link draw} calls. Must be exactly three characters from
|
|
122
|
+
* 'r', 'g', 'b' and 'a'. Defaults to 'rgb', which displays automatically decoded color, or the
|
|
123
|
+
* stored channel as grayscale for single-channel formats. Other selections display stored
|
|
124
|
+
* channel values without color decoding: for example, 'rrr' displays
|
|
125
|
+
* red as grayscale, 'aaa' displays alpha, and 'bgr' swaps red and blue. Values from 0 to 1 map
|
|
126
|
+
* directly from black to white. Output is always opaque. Ignored for depth textures and
|
|
127
|
+
* {@link sceneDepth}. Invalid values leave the previous selection unchanged.
|
|
128
|
+
*
|
|
129
|
+
* @type {string}
|
|
130
|
+
* @example
|
|
131
|
+
* textures.channels = 'aaa';
|
|
132
|
+
* textures.draw(texture, 0, 0, 0.25, 0.25);
|
|
133
|
+
*/
|
|
134
|
+
set channels(value: string);
|
|
135
|
+
get channels(): string;
|
|
136
|
+
/**
|
|
137
|
+
* @type {Map<Layer, TexturePool>}
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
private _pools;
|
|
141
|
+
/**
|
|
142
|
+
* @type {Map<string, ShaderDesc>}
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
private _shaderDescs;
|
|
146
|
+
/**
|
|
147
|
+
* @type {Mesh|null}
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
private _mesh;
|
|
151
|
+
/** @private */
|
|
152
|
+
private _app;
|
|
153
|
+
/**
|
|
154
|
+
* Displays a 2D color or depth texture for this frame. Color encoding and supported filtering
|
|
155
|
+
* are detected automatically when {@link channels} is 'rgb'. Other selections display stored
|
|
156
|
+
* channel values. Raw depth is shown as grayscale without
|
|
157
|
+
* projection-dependent linearization; use {@link sceneDepth} for camera depth. Texture row 0
|
|
158
|
+
* is displayed at the top. For rendered textures, use {@link RENDERTARGET_ORIGIN_TOP} on their
|
|
159
|
+
* render target for consistent orientation across backends.
|
|
160
|
+
*
|
|
161
|
+
* Cube, volume, array, integer and multisampled textures are not supported. On WebGL2,
|
|
162
|
+
* depth textures must have comparison sampling disabled. Raw depth and non-filterable float
|
|
163
|
+
* textures must use nearest minification and magnification filters on WebGL2. WebGPU samples
|
|
164
|
+
* these textures independently of their filtering and comparison sampler settings.
|
|
165
|
+
*
|
|
166
|
+
* @param {Texture} texture - The caller-owned texture to display.
|
|
167
|
+
* @param {number} x - Left edge as a fraction of the camera viewport width.
|
|
168
|
+
* @param {number} y - Top edge as a fraction of the camera viewport height.
|
|
169
|
+
* @param {number} width - Width as a fraction of the camera viewport width.
|
|
170
|
+
* @param {number} height - Height as a fraction of the camera viewport height.
|
|
171
|
+
*/
|
|
172
|
+
draw(texture: BLEND_NORMAL, x: number, y: number, width: number, height: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Displays the rendering camera's scene depth for this frame, linearized and normalized by
|
|
175
|
+
* its far clip distance. The camera must already supply a scene depth map, for example using
|
|
176
|
+
* {@link CameraComponent#requestSceneDepthMap}, and this layer must render after depth capture.
|
|
177
|
+
*
|
|
178
|
+
* @param {number} x - Left edge as a fraction of the camera viewport width.
|
|
179
|
+
* @param {number} y - Top edge as a fraction of the camera viewport height.
|
|
180
|
+
* @param {number} width - Width as a fraction of the camera viewport width.
|
|
181
|
+
* @param {number} height - Height as a fraction of the camera viewport height.
|
|
182
|
+
*/
|
|
183
|
+
sceneDepth(x: number, y: number, width: number, height: number): void;
|
|
184
|
+
/**
|
|
185
|
+
* @param {Texture|null} texture - Source texture, or null for scene depth.
|
|
186
|
+
* @param {string} mode - Sampling mode.
|
|
187
|
+
* @param {string} encoding - Source encoding.
|
|
188
|
+
* @param {number} x - Normalized left edge.
|
|
189
|
+
* @param {number} y - Normalized top edge.
|
|
190
|
+
* @param {number} width - Normalized width.
|
|
191
|
+
* @param {number} height - Normalized height.
|
|
192
|
+
* @param {Int32Array} channelIndices - The channels shown by a raw encoding.
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
private _draw;
|
|
196
|
+
/**
|
|
197
|
+
* Whether a pass draws a preview: only the selected camera if one is set, and never a pass
|
|
198
|
+
* rendering into the texture the preview samples.
|
|
199
|
+
*
|
|
200
|
+
* @param {TextureSlot} slot - The preview.
|
|
201
|
+
* @param {Camera} camera - The camera rendering the layer.
|
|
202
|
+
* @param {RenderTarget|null} renderTarget - The target the pass renders into.
|
|
203
|
+
* @returns {boolean} True to draw the preview in this pass.
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
private _isDrawnBy;
|
|
207
|
+
/**
|
|
208
|
+
* Applies camera and attachment restrictions after culling, using the actual pass target.
|
|
209
|
+
* The pass mask skips shader preparation and resource binding as well as the draw itself.
|
|
210
|
+
*
|
|
211
|
+
* @param {CameraComponent} cameraComponent - The camera rendering the layer.
|
|
212
|
+
* @param {Layer} layer - The layer about to be rendered.
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
private _onPreRenderLayer;
|
|
216
|
+
/**
|
|
217
|
+
* Keeps previews out of other passes until their destination layer explicitly enables them.
|
|
218
|
+
*
|
|
219
|
+
* @param {CameraComponent} cameraComponent - The camera that rendered the layer.
|
|
220
|
+
* @param {Layer} layer - The layer that was rendered.
|
|
221
|
+
* @private
|
|
222
|
+
*/
|
|
223
|
+
private _onPostRenderLayer;
|
|
224
|
+
/** @private */
|
|
225
|
+
private _endFrame;
|
|
226
|
+
/**
|
|
227
|
+
* Removes all previews and releases the renderer's resources. Does not destroy supplied
|
|
228
|
+
* textures. Safe to call repeatedly; subsequent draw calls are ignored.
|
|
229
|
+
*/
|
|
230
|
+
destroy(): void;
|
|
231
|
+
}
|