@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,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flies a camera with the mouse and WASD. An orthographic view shows no movement along its
|
|
3
|
+
* direction, so there forward and back zoom instead, and panning scales with the height of the view.
|
|
4
|
+
*/
|
|
5
|
+
export class CameraFly extends CameraDrive {
|
|
6
|
+
/** Units a second, changed with the wheel. */
|
|
7
|
+
speed: number;
|
|
8
|
+
/** @type {FlyController} */
|
|
9
|
+
_controller: FlyController;
|
|
10
|
+
/** @type {InputFrame<{ move: number[], rotate: number[] }>} */
|
|
11
|
+
_frame: InputFrame<{
|
|
12
|
+
move: number[];
|
|
13
|
+
rotate: number[];
|
|
14
|
+
}>;
|
|
15
|
+
/** @type {Pose} */
|
|
16
|
+
_pose: Pose;
|
|
17
|
+
/** @type {Set<string>} */
|
|
18
|
+
_keys: Set<string>;
|
|
19
|
+
_fast: boolean;
|
|
20
|
+
_looking: boolean;
|
|
21
|
+
_lastX: number;
|
|
22
|
+
_lastY: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Orbits a camera around a node: drag to orbit, right-drag or Shift-drag to pan, and the wheel to
|
|
26
|
+
* zoom. The camera turns to the node from where it is, keeping its distance unless that is inside
|
|
27
|
+
* the node's bounds. The orbit follows the node as it moves, around the center of its bounds when
|
|
28
|
+
* the orbit started, or its position when it has none. An orthographic view zooms by its height.
|
|
29
|
+
*/
|
|
30
|
+
export class CameraOrbit extends CameraDrive {
|
|
31
|
+
/**
|
|
32
|
+
* @param {AppBase} app - The app.
|
|
33
|
+
* @param {CameraComponent} camera - The camera to orbit.
|
|
34
|
+
* @param {GraphNode} target - The node to orbit around.
|
|
35
|
+
* @param {() => void} onEnd - Called when the orbit ends from the keyboard.
|
|
36
|
+
*/
|
|
37
|
+
constructor(app: BoundingBox, camera: BoundingBox, target: BoundingBox, onEnd: () => void);
|
|
38
|
+
/** @type {GraphNode} */
|
|
39
|
+
target: BoundingBox;
|
|
40
|
+
/** @type {OrbitController} */
|
|
41
|
+
_controller: OrbitController;
|
|
42
|
+
/** @type {InputFrame<{ move: number[], rotate: number[] }>} */
|
|
43
|
+
_frame: InputFrame<{
|
|
44
|
+
move: number[];
|
|
45
|
+
rotate: number[];
|
|
46
|
+
}>;
|
|
47
|
+
/** The pose drawn last, for a change of target to turn from. */
|
|
48
|
+
_pose: Pose;
|
|
49
|
+
/** The center of the target's bounds, relative to its position. */
|
|
50
|
+
_center: any;
|
|
51
|
+
/** Where the orbit was centered last frame, to follow the target by. */
|
|
52
|
+
_focus: any;
|
|
53
|
+
/** @type {'orbit'|'pan'|null} */
|
|
54
|
+
_drag: "orbit" | "pan" | null;
|
|
55
|
+
_lastX: number;
|
|
56
|
+
_lastY: number;
|
|
57
|
+
/**
|
|
58
|
+
* Turns the orbit to another node, from where the camera is now.
|
|
59
|
+
*
|
|
60
|
+
* @param {GraphNode} target - The node to orbit around.
|
|
61
|
+
*/
|
|
62
|
+
setTarget(target: BoundingBox): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Takes the pointer events on the canvas ahead of the app's own handlers, for a mode of the
|
|
66
|
+
* inspector that uses the pointer itself. The listeners sit in the capture phase on the window, so
|
|
67
|
+
* they run before any listener of the app, and stop the events there.
|
|
68
|
+
*/
|
|
69
|
+
export class CanvasCapture {
|
|
70
|
+
/**
|
|
71
|
+
* @param {HTMLCanvasElement} canvas - The canvas.
|
|
72
|
+
* @param {(e: Event) => void} onEvent - Called with every pointer event on the canvas.
|
|
73
|
+
*/
|
|
74
|
+
constructor(canvas: HTMLCanvasElement, onEvent: (e: Event) => void);
|
|
75
|
+
/** @type {HTMLCanvasElement} */
|
|
76
|
+
canvas: HTMLCanvasElement;
|
|
77
|
+
/** @type {(e: Event) => void} */
|
|
78
|
+
_listener: (e: Event) => void;
|
|
79
|
+
_dragging: boolean;
|
|
80
|
+
destroy(): void;
|
|
81
|
+
}
|
|
82
|
+
/** @import { Quat } from 'playcanvas' */
|
|
83
|
+
/** @import { AppBase } from 'playcanvas' */
|
|
84
|
+
/** @import { CameraComponent } from 'playcanvas' */
|
|
85
|
+
/** @import { GraphNode } from 'playcanvas' */
|
|
86
|
+
/** @import { MeshInstance } from 'playcanvas' */
|
|
87
|
+
/**
|
|
88
|
+
* The shader passes a camera can render with, as the editor offers them: the lit scene, and the
|
|
89
|
+
* debug views of the standard material's inputs.
|
|
90
|
+
*/
|
|
91
|
+
export const RENDER_MODES: any[][];
|
|
92
|
+
/**
|
|
93
|
+
* Picks the entity under the pointer, through the screen camera whose viewport holds it, the way
|
|
94
|
+
* the editor picks: an id buffer the size of the canvas is rendered for that camera, which draws
|
|
95
|
+
* into its own viewport of it, and read back under the pointer.
|
|
96
|
+
*/
|
|
97
|
+
export class ViewportPicker {
|
|
98
|
+
/**
|
|
99
|
+
* @param {AppBase} app - The app.
|
|
100
|
+
*/
|
|
101
|
+
constructor(app: BoundingBox);
|
|
102
|
+
/** @type {AppBase} */
|
|
103
|
+
app: BoundingBox;
|
|
104
|
+
/** @type {Picker|null} */
|
|
105
|
+
_picker: Picker | null;
|
|
106
|
+
/**
|
|
107
|
+
* The picks in flight, one after the other, as each reads back the id buffer the next renders.
|
|
108
|
+
*
|
|
109
|
+
* @type {Promise<*>}
|
|
110
|
+
*/
|
|
111
|
+
_queue: Promise<any>;
|
|
112
|
+
/**
|
|
113
|
+
* @param {number} clientX - The pointer, in client pixels.
|
|
114
|
+
* @param {number} clientY - The pointer, in client pixels.
|
|
115
|
+
* @returns {Promise<{ entity: Entity, instance: MeshInstance, camera: CameraComponent }|null>} What
|
|
116
|
+
* is under the pointer, or null for nothing. Picks run one after the other.
|
|
117
|
+
*/
|
|
118
|
+
pick(clientX: number, clientY: number): Promise<{
|
|
119
|
+
entity: Entity;
|
|
120
|
+
instance: BoundingBox;
|
|
121
|
+
camera: BoundingBox;
|
|
122
|
+
} | null>;
|
|
123
|
+
/**
|
|
124
|
+
* @param {number} clientX - The pointer, in client pixels.
|
|
125
|
+
* @param {number} clientY - The pointer, in client pixels.
|
|
126
|
+
* @returns {Promise<{ entity: Entity, instance: MeshInstance, camera: CameraComponent }|null>} What
|
|
127
|
+
* is under the pointer.
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
private _pickNow;
|
|
131
|
+
destroy(): void;
|
|
132
|
+
_destroyed: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Draws every mesh instance of the app in wireframe while on, keeping the render style each had to
|
|
136
|
+
* put back. Mesh instances the app adds while it is on take it on at the next apply.
|
|
137
|
+
*/
|
|
138
|
+
export class WireframeMode {
|
|
139
|
+
/** @type {Map<MeshInstance, number>} */
|
|
140
|
+
_styles: Map<BoundingBox, number>;
|
|
141
|
+
/**
|
|
142
|
+
* @param {AppBase} app - The app, whose mesh instances to draw in wireframe.
|
|
143
|
+
*/
|
|
144
|
+
apply(app: BoundingBox): void;
|
|
145
|
+
/** Puts back the render style of every mesh instance drawn in wireframe. */
|
|
146
|
+
restore(): void;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @param {CameraComponent} camera - A camera.
|
|
150
|
+
* @returns {boolean} Whether it draws to the screen, the ones a pointer can be over.
|
|
151
|
+
*/
|
|
152
|
+
export function isScreenCamera(camera: BoundingBox): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* The screen camera whose viewport holds a point of the canvas, the last one drawn when several
|
|
155
|
+
* overlap, which is the one on top.
|
|
156
|
+
*
|
|
157
|
+
* @param {AppBase} app - The app.
|
|
158
|
+
* @param {number} x - The point, as a fraction of the canvas width from its left edge.
|
|
159
|
+
* @param {number} y - The point, as a fraction of the canvas height from its top edge.
|
|
160
|
+
* @returns {CameraComponent|null} The camera, or null when no camera draws there.
|
|
161
|
+
*/
|
|
162
|
+
export function screenCameraAt(app: BoundingBox, x: number, y: number): BoundingBox | null;
|
|
163
|
+
/**
|
|
164
|
+
* Drives a camera the app keeps drawing with, from the inspector's own input. The app may move the
|
|
165
|
+
* camera itself, from a script or from code of its own, so the camera is not taken over: its
|
|
166
|
+
* transform is swapped for the driven one on the app's prerender event, after every update has run,
|
|
167
|
+
* and put back on postrender, so the frame is drawn from the driven pose while the app keeps seeing
|
|
168
|
+
* and moving its own. Its projection is held the same way, at the field of view or orthographic
|
|
169
|
+
* height it had when the drive started, as an app may animate those too. Ending the drive needs no
|
|
170
|
+
* restoring. The keyboard and the pointer on the canvas are taken ahead of the app while driving,
|
|
171
|
+
* and the drive runs on the wall clock, so a paused app can be looked around.
|
|
172
|
+
*
|
|
173
|
+
* @abstract
|
|
174
|
+
*/
|
|
175
|
+
declare class CameraDrive {
|
|
176
|
+
/**
|
|
177
|
+
* @param {AppBase} app - The app.
|
|
178
|
+
* @param {CameraComponent} camera - The camera to drive.
|
|
179
|
+
* @param {() => void} onEnd - Called when the drive ends from the keyboard.
|
|
180
|
+
*/
|
|
181
|
+
constructor(app: BoundingBox, camera: BoundingBox, onEnd: () => void);
|
|
182
|
+
/** @type {AppBase} */
|
|
183
|
+
app: BoundingBox;
|
|
184
|
+
/** @type {CameraComponent} */
|
|
185
|
+
camera: BoundingBox;
|
|
186
|
+
/** @type {{ position: Vec3, rotation: Quat, fov: number, orthoHeight: number }|null} */
|
|
187
|
+
_saved: {
|
|
188
|
+
position: Vec3;
|
|
189
|
+
rotation: BoundingBox;
|
|
190
|
+
fov: number;
|
|
191
|
+
orthoHeight: number;
|
|
192
|
+
} | null;
|
|
193
|
+
/** Whether the camera is orthographic, which zooms by its height rather than by moving. */
|
|
194
|
+
_ortho: boolean;
|
|
195
|
+
/** The field of view the driven view keeps. */
|
|
196
|
+
_fov: number;
|
|
197
|
+
/** The orthographic height the driven view keeps, changed by zooming. */
|
|
198
|
+
_orthoHeight: number;
|
|
199
|
+
_lastTime: number;
|
|
200
|
+
/** @type {CanvasCapture} */
|
|
201
|
+
_capture: CanvasCapture;
|
|
202
|
+
_onEnd: () => void;
|
|
203
|
+
_pointerListener: (e: any) => void;
|
|
204
|
+
_keyDownListener: (e: any) => void;
|
|
205
|
+
_keyUpListener: (e: any) => void;
|
|
206
|
+
_blurListener: () => void;
|
|
207
|
+
destroy(): void;
|
|
208
|
+
/**
|
|
209
|
+
* @param {Event} e - A pointer event on the canvas.
|
|
210
|
+
* @abstract
|
|
211
|
+
*/
|
|
212
|
+
_onPointer(e: Event): void;
|
|
213
|
+
/**
|
|
214
|
+
* @param {KeyboardEvent} e - A key pressed or released, other than Esc.
|
|
215
|
+
* @param {boolean} down - Whether it was pressed.
|
|
216
|
+
*/
|
|
217
|
+
_onKey(e: KeyboardEvent, down: boolean): void;
|
|
218
|
+
_onBlur(): void;
|
|
219
|
+
/**
|
|
220
|
+
* @param {number} dt - Seconds since the last frame.
|
|
221
|
+
* @returns {Pose} The pose to draw from this frame.
|
|
222
|
+
* @abstract
|
|
223
|
+
*/
|
|
224
|
+
_update(dt: number): Pose;
|
|
225
|
+
_onPrerender(): void;
|
|
226
|
+
_onPostrender(): void;
|
|
227
|
+
/**
|
|
228
|
+
* @returns {boolean} Whether the view zooms by its orthographic height rather than by moving.
|
|
229
|
+
*/
|
|
230
|
+
get zooms(): boolean;
|
|
231
|
+
}
|
|
232
|
+
import { FlyController } from './input/fly-controller.js';
|
|
233
|
+
import { InputFrame } from './input/input.js';
|
|
234
|
+
import { Pose } from './input/pose.js';
|
|
235
|
+
import { OrbitController } from './input/orbit-controller.js';
|
|
236
|
+
import { Picker } from './picker/picker.js';
|
|
237
|
+
export {};
|