@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,206 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlendState, RenderPass, SHADER_DEPTH_PICK, SHADER_PICK, UniformBufferFormat, UniformFormat, UNIFORMTYPE_MAT4
|
|
3
|
+
} from 'playcanvas';
|
|
4
|
+
|
|
5
|
+
import { DebugGraphics } from '../debug.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import { CameraComponent } from 'playcanvas'
|
|
9
|
+
* @import { Scene } from 'playcanvas'
|
|
10
|
+
* @import { Layer } from 'playcanvas'
|
|
11
|
+
* @import { MeshInstance } from 'playcanvas'
|
|
12
|
+
* @import { GSplatComponent } from 'playcanvas'
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const tempMeshInstances = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A render pass implementing rendering of mesh instances into a pick buffer.
|
|
19
|
+
*
|
|
20
|
+
* @ignore
|
|
21
|
+
*/
|
|
22
|
+
class RenderPassPicker extends RenderPass {
|
|
23
|
+
/** @type {BlendState} */
|
|
24
|
+
blendState = BlendState.NOBLEND;
|
|
25
|
+
|
|
26
|
+
/** @type {CameraComponent} */
|
|
27
|
+
camera;
|
|
28
|
+
|
|
29
|
+
/** @type {Scene} */
|
|
30
|
+
scene;
|
|
31
|
+
|
|
32
|
+
/** @type {Layer[]} */
|
|
33
|
+
layers;
|
|
34
|
+
|
|
35
|
+
/** @type {Map<number, MeshInstance | GSplatComponent>} */
|
|
36
|
+
mapping;
|
|
37
|
+
|
|
38
|
+
/** @type {boolean} */
|
|
39
|
+
depth;
|
|
40
|
+
|
|
41
|
+
/** @type {number[]} */
|
|
42
|
+
_qualifiedLayerIndices = [];
|
|
43
|
+
|
|
44
|
+
/** @type {Map<number, MeshInstance|null>} */
|
|
45
|
+
_pickMeshInstances = new Map();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Minimal view uniform format used by the picker. The pick shaders only need the view
|
|
49
|
+
* projection (and the view matrix for depth picking); any other view uniform a shader happens
|
|
50
|
+
* to reference falls back to the per-mesh uniform buffer automatically. This avoids pulling in
|
|
51
|
+
* the full forward view format (and its lighting / shadow uniforms) which the picker does not
|
|
52
|
+
* need.
|
|
53
|
+
*
|
|
54
|
+
* @type {UniformBufferFormat|null}
|
|
55
|
+
*/
|
|
56
|
+
_viewUniformFormat = null;
|
|
57
|
+
|
|
58
|
+
constructor(device, renderer) {
|
|
59
|
+
super(device);
|
|
60
|
+
this.renderer = renderer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getViewUniformFormat() {
|
|
64
|
+
if (!this._viewUniformFormat) {
|
|
65
|
+
this._viewUniformFormat = new UniformBufferFormat(this.device, [
|
|
66
|
+
new UniformFormat('matrix_viewProjection', UNIFORMTYPE_MAT4),
|
|
67
|
+
new UniformFormat('matrix_view', UNIFORMTYPE_MAT4)
|
|
68
|
+
], { pack: true });
|
|
69
|
+
}
|
|
70
|
+
return this._viewUniformFormat;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {CameraComponent} camera - The camera component used for picking.
|
|
75
|
+
* @param {Scene} scene - The scene to pick from.
|
|
76
|
+
* @param {Layer[]} layers - The layers to pick from.
|
|
77
|
+
* @param {Map<number, MeshInstance | GSplatComponent>} mapping - Map to store ID to object mappings.
|
|
78
|
+
* @param {boolean} depth - Whether to render depth information.
|
|
79
|
+
*/
|
|
80
|
+
update(camera, scene, layers, mapping, depth) {
|
|
81
|
+
this.camera = camera;
|
|
82
|
+
this.scene = scene;
|
|
83
|
+
this.layers = layers;
|
|
84
|
+
this.mapping = mapping;
|
|
85
|
+
this.depth = depth;
|
|
86
|
+
|
|
87
|
+
if (scene.clusteredLightingEnabled) {
|
|
88
|
+
this.emptyWorldClusters = this.renderer.worldClustersAllocator.empty;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Filter qualifying layers and prepare gsplat pick mesh instances for the compute-based
|
|
93
|
+
// renderer. The execute() loop iterates the pre-built list instead of re-filtering.
|
|
94
|
+
before() {
|
|
95
|
+
this._qualifiedLayerIndices.length = 0;
|
|
96
|
+
this._pickMeshInstances.clear();
|
|
97
|
+
|
|
98
|
+
const { camera, scene, layers, renderer } = this;
|
|
99
|
+
const srcLayers = scene.layers.layerList;
|
|
100
|
+
|
|
101
|
+
const gsplatDirector = renderer.gsplatDirector;
|
|
102
|
+
const pickerWidth = this.renderTarget?.width ?? 1;
|
|
103
|
+
const pickerHeight = this.renderTarget?.height ?? 1;
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < srcLayers.length; i++) {
|
|
106
|
+
const srcLayer = srcLayers[i];
|
|
107
|
+
if (layers && layers.indexOf(srcLayer) < 0) continue;
|
|
108
|
+
if (!scene.layers.isSubLayerRenderedByCamera(i, camera.camera)) continue;
|
|
109
|
+
|
|
110
|
+
// store the index of the layers we need to render
|
|
111
|
+
this._qualifiedLayerIndices.push(i);
|
|
112
|
+
|
|
113
|
+
// request culling of this layer for the picking camera, so execute() can read the
|
|
114
|
+
// camera-visible instances instead of the whole layer
|
|
115
|
+
renderer.culler.requestMeshInstanceCull(camera.camera, srcLayer);
|
|
116
|
+
|
|
117
|
+
// kick off a compute tiled renderer for the gsplat manager on this layer, and store the mesh instance
|
|
118
|
+
// which copies the results to the pick buffer
|
|
119
|
+
if (gsplatDirector) {
|
|
120
|
+
const pickMI = gsplatDirector.prepareForPicking(camera.camera, pickerWidth, pickerHeight, srcLayer);
|
|
121
|
+
if (pickMI) {
|
|
122
|
+
this._pickMeshInstances.set(i, pickMI);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// perform the requested culls now (the picker renders standalone, outside the main
|
|
128
|
+
// cullComposition), so the culled instance lists are ready for execute()
|
|
129
|
+
renderer.culler.executeMeshInstanceCull();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
execute() {
|
|
133
|
+
const device = this.device;
|
|
134
|
+
|
|
135
|
+
const { renderer, camera, scene, mapping, renderTarget } = this;
|
|
136
|
+
const srcLayers = scene.layers.layerList;
|
|
137
|
+
const isTransparent = scene.layers.subLayerList;
|
|
138
|
+
|
|
139
|
+
for (const i of this._qualifiedLayerIndices) {
|
|
140
|
+
const srcLayer = srcLayers[i];
|
|
141
|
+
const transparent = isTransparent[i];
|
|
142
|
+
DebugGraphics.pushGpuMarker(device, `${srcLayer.name}(${transparent ? 'TRANSP' : 'OPAQUE'})`);
|
|
143
|
+
|
|
144
|
+
// if the layer clears the depth
|
|
145
|
+
if (srcLayer._clearDepthBuffer) {
|
|
146
|
+
renderer.clear(camera.camera, false, true, false);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// use the camera-visible instances for this layer (culling was requested in before()),
|
|
150
|
+
// taking the bucket that matches this sub-layer's transparency
|
|
151
|
+
const culledInstances = srcLayer.getCulledInstances(camera.camera);
|
|
152
|
+
const meshInstances = transparent ? culledInstances.transparent : culledInstances.opaque;
|
|
153
|
+
|
|
154
|
+
// only need mesh instances with a pick flag (the bucket already matches transparency)
|
|
155
|
+
for (let j = 0; j < meshInstances.length; j++) {
|
|
156
|
+
const meshInstance = meshInstances[j];
|
|
157
|
+
if (meshInstance.pick) {
|
|
158
|
+
tempMeshInstances.push(meshInstance);
|
|
159
|
+
|
|
160
|
+
// keep the index -> meshInstance index mapping
|
|
161
|
+
mapping.set(meshInstance.id, meshInstance);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Inject gsplat pick mesh instance for this layer (compute-based renderer only)
|
|
166
|
+
const pickMI = this._pickMeshInstances.get(i);
|
|
167
|
+
if (pickMI) {
|
|
168
|
+
tempMeshInstances.push(pickMI);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Process gsplat placements when ID is enabled
|
|
172
|
+
// The gsplat unified mesh instance is already handled above (added to layer.meshInstances)
|
|
173
|
+
// Here we just need to add the placement ID -> component mapping
|
|
174
|
+
if (scene.getGsplatParams()?.enableIds) {
|
|
175
|
+
const placements = srcLayer.gsplatPlacements;
|
|
176
|
+
for (let j = 0; j < placements.length; j++) {
|
|
177
|
+
const placement = placements[j];
|
|
178
|
+
const component = placement.node?.gsplat;
|
|
179
|
+
if (component) {
|
|
180
|
+
mapping.set(placement.id, component);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (tempMeshInstances.length > 0) {
|
|
186
|
+
|
|
187
|
+
// render the mesh instances through the standard forward layer path, using the
|
|
188
|
+
// picker's own minimal view uniform format; it sets up the camera and view uniforms,
|
|
189
|
+
// and the callback forces the picker blend state per mesh
|
|
190
|
+
const shaderPass = this.depth ? SHADER_DEPTH_PICK : SHADER_PICK;
|
|
191
|
+
renderer.renderForwardLayer(camera.camera, renderTarget, null, undefined, shaderPass, {
|
|
192
|
+
meshInstances: tempMeshInstances,
|
|
193
|
+
lightClusters: this.emptyWorldClusters,
|
|
194
|
+
viewUniformFormat: this.getViewUniformFormat(),
|
|
195
|
+
drawCallback: () => device.setBlendState(this.blendState)
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
tempMeshInstances.length = 0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
DebugGraphics.popGpuMarker(device);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { RenderPassPicker };
|