@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,192 @@
|
|
|
1
|
+
/** @import { HandleEventCallback } from 'playcanvas' */
|
|
2
|
+
/**
|
|
3
|
+
* Represents an input delta: a fixed-length array of numbers that accumulates input between reads.
|
|
4
|
+
* Sources {@link append} raw values to it as events arrive, and {@link read} returns the total and
|
|
5
|
+
* resets it to zero, so each read yields the change since the previous one. An {@link InputFrame}
|
|
6
|
+
* groups named deltas together.
|
|
7
|
+
*
|
|
8
|
+
* @category Input
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export class InputDelta {
|
|
12
|
+
/**
|
|
13
|
+
* @param {number | number[]} arg - The size of the delta or an array of initial values.
|
|
14
|
+
*/
|
|
15
|
+
constructor(arg: number | number[]);
|
|
16
|
+
/**
|
|
17
|
+
* @type {number[]}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
private _value;
|
|
21
|
+
/**
|
|
22
|
+
* Adds another InputDelta instance to this one.
|
|
23
|
+
*
|
|
24
|
+
* @param {InputDelta} other - The other InputDelta instance to add.
|
|
25
|
+
* @returns {InputDelta} Self for chaining.
|
|
26
|
+
*/
|
|
27
|
+
add(other: InputDelta): InputDelta;
|
|
28
|
+
/**
|
|
29
|
+
* Appends offsets to the current delta values.
|
|
30
|
+
*
|
|
31
|
+
* @param {number[]} offsets - The offsets.
|
|
32
|
+
* @returns {InputDelta} Self for chaining.
|
|
33
|
+
*/
|
|
34
|
+
append(offsets: number[]): InputDelta;
|
|
35
|
+
/**
|
|
36
|
+
* Copies the values from another InputDelta instance to this one.
|
|
37
|
+
*
|
|
38
|
+
* @param {InputDelta} other - The other InputDelta instance to copy from.
|
|
39
|
+
* @returns {InputDelta} Self for chaining.
|
|
40
|
+
*/
|
|
41
|
+
copy(other: InputDelta): InputDelta;
|
|
42
|
+
/**
|
|
43
|
+
* The magnitude of the delta, calculated as the square root of the sum of squares
|
|
44
|
+
* of the values.
|
|
45
|
+
*
|
|
46
|
+
* @returns {number} - The magnitude of the delta.
|
|
47
|
+
*/
|
|
48
|
+
length(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the current value of the delta and resets it to zero.
|
|
51
|
+
*
|
|
52
|
+
* @returns {number[]} - The current value of the delta.
|
|
53
|
+
*/
|
|
54
|
+
read(): number[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Represents an input frame, which contains a map of input deltas. The keys and lengths are fixed
|
|
58
|
+
* by the object passed to the constructor, for example `{ move: [0, 0, 0], rotate: [0, 0, 0] }`,
|
|
59
|
+
* and {@link read} flushes every delta at once. A frame is the unit of exchange in this input
|
|
60
|
+
* system: {@link InputSource}s are frames that fill themselves from a device, and an application
|
|
61
|
+
* combines their values into a frame with the shape an {@link InputController} expects.
|
|
62
|
+
*
|
|
63
|
+
* @category Input
|
|
64
|
+
* @alpha
|
|
65
|
+
*
|
|
66
|
+
* @template {Record<string, number[]>} T - The shape of the input frame.
|
|
67
|
+
*/
|
|
68
|
+
export class InputFrame<T extends Record<string, number[]>> {
|
|
69
|
+
/**
|
|
70
|
+
* @param {T} data - The input frame data, where each key corresponds to an input delta.
|
|
71
|
+
*/
|
|
72
|
+
constructor(data: T);
|
|
73
|
+
/**
|
|
74
|
+
* @type {{ [K in keyof T]: InputDelta }}
|
|
75
|
+
*/
|
|
76
|
+
deltas: { [K in keyof T]: InputDelta; };
|
|
77
|
+
/**
|
|
78
|
+
* Returns the current frame state and resets the deltas to zero.
|
|
79
|
+
*
|
|
80
|
+
* @returns {{ [K in keyof T]: number[] }} - The flushed input frame with current deltas.
|
|
81
|
+
*/
|
|
82
|
+
read(): { [K in keyof T]: number[]; };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The base class for all input devices. An input source is an {@link InputFrame} that fills its own
|
|
86
|
+
* deltas from DOM events or device polling once {@link attach} is given an element, and stops on
|
|
87
|
+
* {@link detach}. Call {@link InputFrame#read} once per frame to take the accumulated deltas. The
|
|
88
|
+
* built-in sources are {@link KeyboardMouseSource}, {@link GamepadSource},
|
|
89
|
+
* {@link MultiTouchSource}, {@link SingleGestureSource} and {@link DualGestureSource}; subclass
|
|
90
|
+
* this to add another device.
|
|
91
|
+
*
|
|
92
|
+
* @category Input
|
|
93
|
+
* @alpha
|
|
94
|
+
*
|
|
95
|
+
* @template {Record<string, number[]>} T - The shape of the input source.
|
|
96
|
+
* @augments {InputFrame<T>}
|
|
97
|
+
*/
|
|
98
|
+
export class InputSource<T extends Record<string, number[]>> extends InputFrame<T> {
|
|
99
|
+
/**
|
|
100
|
+
* @type {HTMLElement | null}
|
|
101
|
+
* @protected
|
|
102
|
+
*/
|
|
103
|
+
protected _element: HTMLElement | null;
|
|
104
|
+
/**
|
|
105
|
+
* @type {EventHandler}
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
private _events;
|
|
109
|
+
/**
|
|
110
|
+
* Adds an event listener for the specified event.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} event - The event name to listen for.
|
|
113
|
+
* @param {HandleEventCallback} callback - The callback function to execute when the event is
|
|
114
|
+
* triggered.
|
|
115
|
+
*/
|
|
116
|
+
on(event: string, callback: EventHandler): void;
|
|
117
|
+
/**
|
|
118
|
+
* Removes an event listener for the specified event.
|
|
119
|
+
*
|
|
120
|
+
* @param {string} event - The event name to stop listening for.
|
|
121
|
+
* @param {HandleEventCallback} callback - The callback function to remove.
|
|
122
|
+
*/
|
|
123
|
+
off(event: string, callback: EventHandler): void;
|
|
124
|
+
/**
|
|
125
|
+
* Fires an event with the given name and arguments.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} event - The event name to fire.
|
|
128
|
+
* @param {...any} args - The arguments to pass to the event listeners.
|
|
129
|
+
*/
|
|
130
|
+
fire(event: string, ...args: any[]): void;
|
|
131
|
+
/**
|
|
132
|
+
* @param {HTMLElement} element - The element.
|
|
133
|
+
*/
|
|
134
|
+
attach(element: HTMLElement): void;
|
|
135
|
+
detach(): void;
|
|
136
|
+
destroy(): void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The base class for all input consumers, which are used to process input frames. A consumer
|
|
140
|
+
* implements {@link update}, receiving an {@link InputFrame} and the frame time, and does whatever
|
|
141
|
+
* that input means for it. {@link InputController} is the consumer that turns input into a
|
|
142
|
+
* {@link Pose}.
|
|
143
|
+
*
|
|
144
|
+
* @category Input
|
|
145
|
+
* @alpha
|
|
146
|
+
*/
|
|
147
|
+
export class InputConsumer {
|
|
148
|
+
/**
|
|
149
|
+
* @param {InputFrame} frame - The input frame.
|
|
150
|
+
* @param {number} dt - The delta time.
|
|
151
|
+
*/
|
|
152
|
+
update(frame: InputFrame<any>, dt: number): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The base class for all input controllers. A controller consumes an {@link InputFrame} carrying
|
|
156
|
+
* `move` and `rotate` deltas and produces a {@link Pose}: {@link attach} sets the pose it starts
|
|
157
|
+
* from, {@link update} applies a frame and returns the current pose, and {@link detach} releases
|
|
158
|
+
* it. The application applies the returned pose to an entity. {@link FlyController},
|
|
159
|
+
* {@link OrbitController} and {@link FocusController} implement three ways of doing this.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* controller.attach(pose.look(cameraPosition, target));
|
|
163
|
+
*
|
|
164
|
+
* // each frame, after filling the frame's move and rotate deltas from your sources
|
|
165
|
+
* const result = controller.update(frame, dt);
|
|
166
|
+
* camera.setPosition(result.position);
|
|
167
|
+
* camera.setEulerAngles(result.angles);
|
|
168
|
+
* @category Input
|
|
169
|
+
* @alpha
|
|
170
|
+
*/
|
|
171
|
+
export class InputController extends InputConsumer {
|
|
172
|
+
/**
|
|
173
|
+
* @type {Pose}
|
|
174
|
+
* @protected
|
|
175
|
+
*/
|
|
176
|
+
protected _pose: Pose;
|
|
177
|
+
/**
|
|
178
|
+
* @param {Pose} pose - The initial pose of the controller.
|
|
179
|
+
* @param {boolean} [smooth] - Whether to smooth the transition.
|
|
180
|
+
*/
|
|
181
|
+
attach(pose: Pose, smooth?: boolean): void;
|
|
182
|
+
detach(): void;
|
|
183
|
+
/**
|
|
184
|
+
* @param {InputFrame} frame - The input frame.
|
|
185
|
+
* @param {number} dt - The delta time.
|
|
186
|
+
* @returns {Pose} - The controller pose.
|
|
187
|
+
* @override
|
|
188
|
+
*/
|
|
189
|
+
override update(frame: InputFrame<any>, dt: number): Pose;
|
|
190
|
+
destroy(): void;
|
|
191
|
+
}
|
|
192
|
+
import { Pose } from './pose.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function damp(damping: number, dt: number): number;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The orbit controller. The pose orbits a focus point at a distance: `rotate` deltas turn the
|
|
3
|
+
* view around the focus within {@link yawRange} and {@link pitchRange}, the first two `move`
|
|
4
|
+
* components pan the focus point, and the third scales the distance within {@link zoomRange}.
|
|
5
|
+
* Motion is smoothed with {@link rotateDamping}, {@link moveDamping} and {@link zoomDamping}.
|
|
6
|
+
*
|
|
7
|
+
* @category Input
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export class OrbitController extends InputController {
|
|
11
|
+
/**
|
|
12
|
+
* @type {Pose}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
private _targetRootPose;
|
|
16
|
+
/**
|
|
17
|
+
* @type {Pose}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
private _rootPose;
|
|
21
|
+
/**
|
|
22
|
+
* @type {Pose}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private _targetChildPose;
|
|
26
|
+
/**
|
|
27
|
+
* @type {Pose}
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private _childPose;
|
|
31
|
+
/**
|
|
32
|
+
* The rotation damping. In the range 0 to 1, where a value of 0 means no damping and 1 means
|
|
33
|
+
* full damping. Default is 0.98.
|
|
34
|
+
*/
|
|
35
|
+
rotateDamping: number;
|
|
36
|
+
/**
|
|
37
|
+
* The movement damping. In the range 0 to 1, where a value of 0 means no damping and 1 means
|
|
38
|
+
* full damping. Default is 0.98.
|
|
39
|
+
*/
|
|
40
|
+
moveDamping: number;
|
|
41
|
+
/**
|
|
42
|
+
* The zoom damping. A higher value means more damping. A value of 0 means no damping.
|
|
43
|
+
*/
|
|
44
|
+
zoomDamping: number;
|
|
45
|
+
set pitchRange(range: any);
|
|
46
|
+
get pitchRange(): any;
|
|
47
|
+
set yawRange(range: any);
|
|
48
|
+
get yawRange(): any;
|
|
49
|
+
set zoomRange(range: any);
|
|
50
|
+
get zoomRange(): any;
|
|
51
|
+
/**
|
|
52
|
+
* @param {InputFrame<{ move: number[], rotate: number[] }>} frame - The input frame.
|
|
53
|
+
* @param {number} dt - The delta time.
|
|
54
|
+
* @returns {Pose} - The controller pose.
|
|
55
|
+
*/
|
|
56
|
+
update(frame: InputFrame<{
|
|
57
|
+
move: number[];
|
|
58
|
+
rotate: number[];
|
|
59
|
+
}>, dt: number): Pose;
|
|
60
|
+
}
|
|
61
|
+
import { InputController } from './input.js';
|
|
62
|
+
import type { InputFrame } from './input.js';
|
|
63
|
+
import { Pose } from './pose.js';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a pose in 3D space, including position and rotation. It is what an
|
|
3
|
+
* {@link InputController} produces: a {@link position}, Euler {@link angles} in degrees and, for
|
|
4
|
+
* controllers that orbit, the {@link distance} to the focus point. Optional ranges such as
|
|
5
|
+
* {@link pitchRange} and {@link yRange} clamp the result of {@link rotate} and {@link move}.
|
|
6
|
+
*
|
|
7
|
+
* @category Input
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export class Pose {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Pose instance.
|
|
13
|
+
*
|
|
14
|
+
* @param {Vec3} [position] - The position of the pose.
|
|
15
|
+
* @param {Vec3} [angles] - The angles of the pose in degrees.
|
|
16
|
+
* @param {number} [distance] - The focus distance from the position to the pose.
|
|
17
|
+
*/
|
|
18
|
+
constructor(position?: Vec3, angles?: Vec3, distance?: number);
|
|
19
|
+
/**
|
|
20
|
+
* The position of the pose.
|
|
21
|
+
*/
|
|
22
|
+
position: any;
|
|
23
|
+
/**
|
|
24
|
+
* The angles of the pose in degrees calculated from the forward vector.
|
|
25
|
+
*/
|
|
26
|
+
angles: any;
|
|
27
|
+
/**
|
|
28
|
+
* The focus distance from the position to the pose.
|
|
29
|
+
*/
|
|
30
|
+
distance: number;
|
|
31
|
+
/**
|
|
32
|
+
* The allowed range of pitch angles in degrees, stored as (min, max). Applied when the pose
|
|
33
|
+
* is rotated via {@link rotate}.
|
|
34
|
+
*/
|
|
35
|
+
pitchRange: any;
|
|
36
|
+
/**
|
|
37
|
+
* The allowed range of yaw angles in degrees, stored as (min, max). Applied when the pose is
|
|
38
|
+
* rotated via {@link rotate}.
|
|
39
|
+
*/
|
|
40
|
+
yawRange: any;
|
|
41
|
+
/**
|
|
42
|
+
* The allowed range of positions along the x axis, stored as (min, max). Applied when the
|
|
43
|
+
* pose is translated via {@link move}.
|
|
44
|
+
*/
|
|
45
|
+
xRange: any;
|
|
46
|
+
/**
|
|
47
|
+
* The allowed range of positions along the y axis, stored as (min, max). Applied when the
|
|
48
|
+
* pose is translated via {@link move}.
|
|
49
|
+
*/
|
|
50
|
+
yRange: any;
|
|
51
|
+
/**
|
|
52
|
+
* The allowed range of positions along the z axis, stored as (min, max). Applied when the
|
|
53
|
+
* pose is translated via {@link move}.
|
|
54
|
+
*/
|
|
55
|
+
zRange: any;
|
|
56
|
+
/**
|
|
57
|
+
* Copies the position and rotation from another pose.
|
|
58
|
+
*
|
|
59
|
+
* @param {Pose} other - The pose to copy from.
|
|
60
|
+
* @returns {Pose} The updated Pose instance.
|
|
61
|
+
*/
|
|
62
|
+
copy(other: Pose): Pose;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a clone of this pose.
|
|
65
|
+
*
|
|
66
|
+
* @returns {Pose} A new Pose instance with the same position, angles, and distance.
|
|
67
|
+
*/
|
|
68
|
+
clone(): Pose;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if this pose is approximately equal to another pose within a given epsilon.
|
|
71
|
+
*
|
|
72
|
+
* @param {Pose} other - The pose to compare with.
|
|
73
|
+
* @param {number} [epsilon] - The tolerance for comparison.
|
|
74
|
+
* @returns {boolean} True if the poses are approximately equal, false otherwise.
|
|
75
|
+
*/
|
|
76
|
+
equalsApprox(other: Pose, epsilon?: number): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Lerps between two poses based on the given alpha values.
|
|
79
|
+
*
|
|
80
|
+
* @param {Pose} lhs - The left-hand side pose.
|
|
81
|
+
* @param {Pose} rhs - The right-hand side pose.
|
|
82
|
+
* @param {number} alpha1 - The alpha value for position interpolation.
|
|
83
|
+
* @param {number} [alpha2] - The alpha value for angles interpolation.
|
|
84
|
+
* @param {number} [alpha3] - The alpha value for distance interpolation.
|
|
85
|
+
* @returns {Pose} The updated Pose instance.
|
|
86
|
+
*/
|
|
87
|
+
lerp(lhs: Pose, rhs: Pose, alpha1: number, alpha2?: number, alpha3?: number): Pose;
|
|
88
|
+
/**
|
|
89
|
+
* Moves the pose by the given vector.
|
|
90
|
+
*
|
|
91
|
+
* @param {Vec3} offset - The vector to move by.
|
|
92
|
+
* @returns {Pose} The updated Pose instance.
|
|
93
|
+
*/
|
|
94
|
+
move(offset: Vec3): Pose;
|
|
95
|
+
/**
|
|
96
|
+
* Rotates the pose by the given angles in degrees.
|
|
97
|
+
*
|
|
98
|
+
* @param {Vec3} euler - The angles to rotate by.
|
|
99
|
+
* @returns {Pose} The updated Pose instance.
|
|
100
|
+
*/
|
|
101
|
+
rotate(euler: Vec3): Pose;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the position and rotation of the pose.
|
|
104
|
+
*
|
|
105
|
+
* @param {Vec3} position - The new position.
|
|
106
|
+
* @param {Vec3} angles - The new angles in degrees.
|
|
107
|
+
* @param {number} distance - The new focus distance.
|
|
108
|
+
* @returns {Pose} The updated Pose instance.
|
|
109
|
+
*/
|
|
110
|
+
set(position: Vec3, angles: Vec3, distance: number): Pose;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the pose to look in the direction of the given vector.
|
|
113
|
+
*
|
|
114
|
+
* @param {Vec3} from - The point from which to look.
|
|
115
|
+
* @param {Vec3} to - The point to look at.
|
|
116
|
+
* @returns {Pose} The updated Pose instance.
|
|
117
|
+
*/
|
|
118
|
+
look(from: Vec3, to: Vec3): Pose;
|
|
119
|
+
/**
|
|
120
|
+
* Gets the focus point of the pose, which is the position plus the forward vector scaled by the distance.
|
|
121
|
+
*
|
|
122
|
+
* @param {Vec3} [out] - The output vector to store the focus point.
|
|
123
|
+
* @returns {Vec3} The focus point of the pose.
|
|
124
|
+
*/
|
|
125
|
+
getFocus(out?: Vec3): Vec3;
|
|
126
|
+
}
|