@margoengine/inspector 0.0.0-stage → 1.0.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.
Files changed (49) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +622 -2
  4. package/dist/animation.d.ts +53 -0
  5. package/dist/animation.js +234 -0
  6. package/dist/color-D6qetPCJ.js +10 -0
  7. package/dist/color.d.ts +4 -0
  8. package/dist/debug-geometry-D61TEkP9.js +61 -0
  9. package/dist/debug-geometry.d.ts +15 -0
  10. package/dist/edit-state-Dm3G17js.js +4 -0
  11. package/dist/edit-state.d.ts +3 -0
  12. package/dist/edit.d.ts +105 -0
  13. package/dist/edit.js +379 -0
  14. package/dist/errors-D8rc8kzg.js +7 -0
  15. package/dist/frame-panel.d.ts +16 -0
  16. package/dist/frame.d.ts +264 -0
  17. package/dist/frame.js +881 -0
  18. package/dist/gizmo.d.ts +49 -0
  19. package/dist/gizmo.js +131 -0
  20. package/dist/gl.d.ts +89 -0
  21. package/dist/gl.js +284 -0
  22. package/dist/history.d.ts +65 -0
  23. package/dist/history.js +66 -0
  24. package/dist/index.d.ts +122 -0
  25. package/dist/index.js +490 -0
  26. package/dist/mesh-debug.d.ts +115 -0
  27. package/dist/mesh-debug.js +501 -0
  28. package/dist/mesh-source-BSQA_1GQ.js +31 -0
  29. package/dist/packages.d.ts +98 -0
  30. package/dist/packages.js +337 -0
  31. package/dist/remote-relay.d.ts +25 -0
  32. package/dist/remote-relay.js +64 -0
  33. package/dist/remote.d.ts +175 -0
  34. package/dist/remote.js +349 -0
  35. package/dist/resources.d.ts +30 -0
  36. package/dist/resources.js +42 -0
  37. package/dist/shaders.d.ts +122 -0
  38. package/dist/shaders.js +285 -0
  39. package/dist/snapshot.d.ts +47 -0
  40. package/dist/snapshot.js +90 -0
  41. package/dist/textures.d.ts +127 -0
  42. package/dist/textures.js +380 -0
  43. package/dist/tools.d.ts +101 -0
  44. package/dist/tools.js +220 -0
  45. package/dist/tweak.d.ts +86 -0
  46. package/dist/tweak.js +291 -0
  47. package/dist/view-rect-CTC0iGjf.js +23 -0
  48. package/dist/visibility-7_j5J9Nv.js +7 -0
  49. package/package.json +147 -4
@@ -0,0 +1,380 @@
1
+ // @margo/core-built 1.0.0
2
+ import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
+
4
+ import { t as e } from "./errors-D8rc8kzg.js";
5
+ //#region src/textures.ts
6
+ var t = 0, n = /* @__PURE__ */ new WeakMap();
7
+ function r(e) {
8
+ let t = n.get(e);
9
+ if (!t) {
10
+ let r = t = /* @__PURE__ */ new Set();
11
+ n.set(e, r), e.lost.then(() => {
12
+ for (let t of [...r]) t.lostDevice(e);
13
+ });
14
+ }
15
+ return t;
16
+ }
17
+ var i = class n {
18
+ static start(e = {}) {
19
+ return new n(e);
20
+ }
21
+ constructor(e = {}) {
22
+ this.options = e, this.records = /* @__PURE__ */ new Map(), this.ids = /* @__PURE__ */ new WeakMap(), this.watched = /* @__PURE__ */ new WeakSet(), this.cleanup = [], this.listeners = /* @__PURE__ */ new Set(), this.next = 0, this.disposed = !1, this.lifetime = new AbortController(), this.abort = () => this.dispose(), e.signal?.throwIfAborted();
23
+ let t = e.gpu === void 0 ? globalThis.navigator?.gpu : e.gpu;
24
+ t && this.watchGPU(t), e.signal?.addEventListener("abort", this.abort, { once: !0 });
25
+ }
26
+ alive() {
27
+ if (this.disposed) throw e("disposed", "Texture capture is disposed; start a new capture");
28
+ }
29
+ wrap(e, t, n) {
30
+ let r = Object.getOwnPropertyDescriptor(e, t), i = e[t], a = n(i), o = new WeakRef(e);
31
+ Object.defineProperty(e, t, {
32
+ configurable: !0,
33
+ writable: !0,
34
+ value: a
35
+ }), this.cleanup.push(() => {
36
+ let e = o.deref();
37
+ e && e[t] === a && (r ? Object.defineProperty(e, t, r) : Reflect.deleteProperty(e, t));
38
+ });
39
+ }
40
+ watchGPU(e) {
41
+ if (this.alive(), this.watched.has(e)) return;
42
+ this.watched.add(e);
43
+ let t = this;
44
+ this.wrap(e, "requestAdapter", (e) => async function(...n) {
45
+ let r = await e.apply(this, n);
46
+ return r && !t.disposed && t.watchAdapter(r), r;
47
+ });
48
+ }
49
+ watchAdapter(e) {
50
+ if (this.alive(), this.watched.has(e)) return;
51
+ this.watched.add(e);
52
+ let t = this;
53
+ this.wrap(e, "requestDevice", (e) => async function(...n) {
54
+ let r = await e.apply(this, n);
55
+ return t.disposed || t.watchDevice(r), r;
56
+ });
57
+ }
58
+ watchDevice(e) {
59
+ if (this.alive(), this.watched.has(e)) return;
60
+ this.watched.add(e);
61
+ let n = this;
62
+ this.wrap(e, "createTexture", (e) => function(r) {
63
+ let i = !n.disposed && t === 0, a = i && n.options.inspectable !== !1 && !(r.usage & 32) ? r.usage | 4 : r.usage, o = e.call(this, a === r.usage ? r : {
64
+ ...r,
65
+ usage: a
66
+ });
67
+ return i && n.register(this, o), o;
68
+ }), this.wrap(e, "destroy", (e) => function() {
69
+ e.call(this), n.disposed || n.forgetDevice(this);
70
+ });
71
+ let i = r(e);
72
+ i.add(this), this.cleanup.push(() => i.delete(this));
73
+ }
74
+ lostDevice(e) {
75
+ this.disposed || this.forgetDevice(e);
76
+ }
77
+ forgetDevice(e) {
78
+ for (let [t, n] of this.records) n.device.deref() === e && this.records.delete(t);
79
+ this.changed();
80
+ }
81
+ register(e, t) {
82
+ this.alive();
83
+ let n = this.ids.get(t);
84
+ if (n !== void 0 && this.records.has(n)) return n;
85
+ let r = ++this.next, i = this;
86
+ return this.ids.set(t, r), this.records.set(r, {
87
+ texture: new WeakRef(t),
88
+ device: new WeakRef(e)
89
+ }), this.wrap(t, "destroy", (e) => function() {
90
+ e.call(this), i.disposed || (i.records.delete(r), i.changed());
91
+ }), this.changed(), r;
92
+ }
93
+ watchCanvas(e) {
94
+ if (this.alive(), this.watched.has(e)) return;
95
+ this.watched.add(e);
96
+ let t = this;
97
+ this.wrap(e, "getCurrentTexture", (e) => function() {
98
+ let n = e.call(this), r = this.getConfiguration();
99
+ return !t.disposed && r && t.register(r.device, n), n;
100
+ });
101
+ }
102
+ list() {
103
+ this.alive();
104
+ let e = [];
105
+ for (let [t, n] of this.records) {
106
+ let r = n.texture.deref();
107
+ !r || !n.device.deref() ? this.records.delete(t) : e.push({
108
+ id: t,
109
+ label: r.label,
110
+ width: r.width,
111
+ height: r.height,
112
+ depthOrArrayLayers: r.depthOrArrayLayers,
113
+ dimension: r.dimension,
114
+ format: r.format,
115
+ mipLevelCount: r.mipLevelCount,
116
+ sampleCount: r.sampleCount,
117
+ usage: r.usage
118
+ });
119
+ }
120
+ return e;
121
+ }
122
+ onChange(e) {
123
+ return this.alive(), this.listeners.add(e), () => void this.listeners.delete(e);
124
+ }
125
+ changed() {
126
+ for (let e of [...this.listeners]) e();
127
+ }
128
+ async preview(n, r = {}) {
129
+ this.alive(), r.signal?.throwIfAborted();
130
+ let i = r.signal ? AbortSignal.any([r.signal, this.lifetime.signal]) : this.lifetime.signal, a = this.records.get(n), o = a?.texture.deref(), s = a?.device.deref();
131
+ if (!o || !s) throw e("state", "Texture is no longer available; refresh the texture list");
132
+ let c = r.mip ?? 0, l = r.layer ?? 0, u = r.channel ?? "rgba", d = r.exposure ?? 1, f = r.range ?? [0, 1];
133
+ if (!Number.isInteger(c) || c < 0 || c >= o.mipLevelCount) throw RangeError("Mip is outside the texture; choose a listed mip level");
134
+ let p = Math.max(1, o.width >> c), m = o.dimension === "1d" ? 1 : Math.max(1, o.height >> c), h = o.dimension === "3d" ? Math.max(1, o.depthOrArrayLayers >> c) : o.depthOrArrayLayers;
135
+ if (!Number.isInteger(l) || l < 0 || l >= h) throw RangeError("Layer is outside the texture; choose a listed layer or slice");
136
+ if (![
137
+ "rgba",
138
+ "rgb",
139
+ "r",
140
+ "g",
141
+ "b",
142
+ "a"
143
+ ].includes(u) || !Number.isFinite(d) || d < 0 || f.length !== 2 || !f.every(Number.isFinite) || !(f[1] > f[0])) throw RangeError("Invalid display mapping; use a channel, nonnegative exposure and increasing finite range");
144
+ if (!(o.usage & 4)) throw e("unsupported", "Texture lacks TEXTURE_BINDING; start TextureCapture before creation with inspectable:true");
145
+ let g = r.aspect ?? (o.format.startsWith("depth") ? "depth-only" : o.format === "stencil8" ? "stencil-only" : "all");
146
+ if (![
147
+ "all",
148
+ "depth-only",
149
+ "stencil-only"
150
+ ].includes(g) || g === "stencil-only" && !o.format.includes("stencil") || g === "depth-only" && !o.format.startsWith("depth") || g === "all" && o.format.includes("stencil") && o.format.startsWith("depth")) throw RangeError("Invalid texture aspect; select an existing depth or stencil aspect");
151
+ let _ = o.format === "stencil8" || g === "stencil-only", v = o.format.startsWith("depth") && !_, y = /(?:u|s)int$/.test(o.format), b = /uint$/.test(o.format) || _ ? "u32" : y ? "i32" : "f32", x = o.dimension, S = o.sampleCount > 1, C = v ? `texture_depth_${S ? "multisampled_2d" : "2d"}` : `texture_${S ? "multisampled_2d" : x}<${b}>`, w = x === "1d" ? "i32(p.x)" : x === "3d" ? `vec3i(i32(p.x),i32(p.y),${l})` : "vec2i(p.xy)", T = v ? S ? "textureLoad(source,vec2i(p.xy),sample)" : "textureLoad(source,vec2i(p.xy),0)" : `textureLoad(source,${w},${S ? "sample" : "0"})`, E = v || _ ? `vec4f(vec3f(${v ? T : `f32(${T}.r)`}),1)` : `vec4f(${T})`, D = u === "rgba" ? "value" : u === "rgb" ? "vec4f(value.rgb,1)" : `vec4f(vec3f(value.${u}),1)`, O = `@group(0) @binding(0) var source:${C};
152
+ @group(0) @binding(1) var<uniform> mapping:vec4f;
153
+ @vertex fn vs(@builtin(vertex_index) i:u32)->@builtin(position) vec4f {let x=f32((i<<1u)&2u);let y=f32(i&2u);return vec4f(x*2-1,y*2-1,0,1);}
154
+ @fragment fn fs(@builtin(position) p:vec4f)->@location(0) vec4f {
155
+ var value=vec4f(0);${S ? `for(var sample=0;sample<${o.sampleCount};sample++){value+=${E};} value/=f32(${o.sampleCount});` : `value=${E};`}
156
+ value=clamp((value*vec4f(mapping.xxx,1)-vec4f(mapping.yyy,0))/vec4f(mapping.zzz,1),vec4f(0),vec4f(1));${o.format.endsWith("-srgb") ? "value=vec4f(select(1.055*pow(value.rgb,vec3f(1.0/2.4))-0.055,value.rgb*12.92,value.rgb<=vec3f(0.0031308)),value.a);" : ""}return ${D};}`, k = [], A = (e) => (k.push(e), e), j;
157
+ try {
158
+ t++;
159
+ let e;
160
+ try {
161
+ e = A(s.createTexture({
162
+ label: "Texture inspector preview",
163
+ size: [p, m],
164
+ format: "rgba8unorm",
165
+ usage: 17
166
+ }));
167
+ } finally {
168
+ t--;
169
+ }
170
+ let n = A(s.createBuffer({
171
+ size: 16,
172
+ usage: 72
173
+ }));
174
+ s.queue.writeBuffer(n, 0, new Float32Array([
175
+ d,
176
+ f[0],
177
+ f[1] - f[0],
178
+ 0
179
+ ]));
180
+ let r = s.createShaderModule({
181
+ label: "Texture inspector channels",
182
+ code: O
183
+ }), a = s.createBindGroupLayout({ entries: [{
184
+ binding: 0,
185
+ visibility: 2,
186
+ texture: {
187
+ sampleType: v ? "depth" : y || _ ? b === "u32" ? "uint" : "sint" : "unfilterable-float",
188
+ viewDimension: x,
189
+ multisampled: S
190
+ }
191
+ }, {
192
+ binding: 1,
193
+ visibility: 2,
194
+ buffer: { type: "uniform" }
195
+ }] }), u = await this.wait(s.createRenderPipelineAsync({
196
+ layout: s.createPipelineLayout({ bindGroupLayouts: [a] }),
197
+ vertex: {
198
+ module: r,
199
+ entryPoint: "vs"
200
+ },
201
+ fragment: {
202
+ module: r,
203
+ entryPoint: "fs",
204
+ targets: [{ format: "rgba8unorm" }]
205
+ },
206
+ primitive: { topology: "triangle-list" }
207
+ }), i);
208
+ this.alive(), i.throwIfAborted();
209
+ let h = o.createView({
210
+ dimension: x,
211
+ baseMipLevel: c,
212
+ mipLevelCount: 1,
213
+ ...x === "2d" ? {
214
+ baseArrayLayer: l,
215
+ arrayLayerCount: 1
216
+ } : {},
217
+ aspect: g
218
+ }), C = s.createBindGroup({
219
+ layout: a,
220
+ entries: [{
221
+ binding: 0,
222
+ resource: h
223
+ }, {
224
+ binding: 1,
225
+ resource: { buffer: n }
226
+ }]
227
+ }), w = Math.ceil(p * 4 / 256) * 256;
228
+ j = A(s.createBuffer({
229
+ size: w * m,
230
+ usage: 9
231
+ }));
232
+ let T = s.createCommandEncoder({ label: "Texture inspector preview" }), E = T.beginRenderPass({ colorAttachments: [{
233
+ view: e.createView(),
234
+ loadOp: "clear",
235
+ storeOp: "store",
236
+ clearValue: {
237
+ r: 0,
238
+ g: 0,
239
+ b: 0,
240
+ a: 0
241
+ }
242
+ }] });
243
+ E.setPipeline(u), E.setBindGroup(0, C), E.draw(3), E.end(), T.copyTextureToBuffer({ texture: e }, {
244
+ buffer: j,
245
+ bytesPerRow: w
246
+ }, [p, m]), s.queue.submit([T.finish()]);
247
+ let D = j.mapAsync(1);
248
+ await this.wait(D, i), this.alive(), i.throwIfAborted();
249
+ let k = new Uint8Array(j.getMappedRange()), M = new Uint8ClampedArray(p * m * 4);
250
+ for (let e = 0; e < m; e++) M.set(k.subarray(e * w, e * w + p * 4), e * p * 4);
251
+ return j.unmap(), {
252
+ width: p,
253
+ height: m,
254
+ data: M
255
+ };
256
+ } finally {
257
+ for (let e of k.reverse()) e.destroy();
258
+ }
259
+ }
260
+ async wait(e, t) {
261
+ if (!t) return e;
262
+ let n, r = new Promise((e, r) => {
263
+ n = () => r(t.reason), t.addEventListener("abort", n, { once: !0 }), t.aborted && n();
264
+ });
265
+ try {
266
+ return await Promise.race([e, r]);
267
+ } finally {
268
+ t.removeEventListener("abort", n);
269
+ }
270
+ }
271
+ dispose() {
272
+ if (!this.disposed) {
273
+ this.disposed = !0, this.lifetime.abort(e("disposed", "Texture capture is disposed; start a new capture")), this.options.signal?.removeEventListener("abort", this.abort);
274
+ for (let e of this.cleanup.reverse()) e();
275
+ this.cleanup.length = 0, this.records.clear(), this.listeners.clear();
276
+ }
277
+ }
278
+ [Symbol.dispose]() {
279
+ this.dispose();
280
+ }
281
+ }, a = class t {
282
+ static attach(e, n = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
283
+ return new t(e, n);
284
+ }
285
+ constructor(e, t = {}) {
286
+ this.capture = e, this.options = t, this.disposed = !1, this.request = 0, this.abort = () => this.dispose(), t.signal?.throwIfAborted();
287
+ let n = t.parent ?? document.body, r = n.ownerDocument;
288
+ this.element = r.createElement("fieldset");
289
+ let i = r.createElement("legend");
290
+ i.textContent = "Textures", this.element.append(i), this.list = r.createElement("select"), this.list.setAttribute("aria-label", "Texture"), this.element.append(this.list);
291
+ let a = (e) => {
292
+ let t = r.createElement("input");
293
+ return t.type = "number", t.min = "0", t.step = "1", t.value = "0", t.setAttribute("aria-label", e), this.element.append(t), t;
294
+ };
295
+ this.mip = a("Mip level"), this.layer = a("Layer or slice"), this.exposure = a("Texture exposure"), this.exposure.value = "1", this.exposure.step = "any", this.rangeMin = a("Texture range minimum"), this.rangeMin.removeAttribute("min"), this.rangeMin.step = "any", this.rangeMax = a("Texture range maximum"), this.rangeMax.removeAttribute("min"), this.rangeMax.value = "1", this.rangeMax.step = "any", this.aspect = r.createElement("select"), this.aspect.setAttribute("aria-label", "Texture aspect");
296
+ for (let e of [
297
+ "default",
298
+ "depth-only",
299
+ "stencil-only"
300
+ ]) {
301
+ let t = r.createElement("option");
302
+ t.value = t.textContent = e, this.aspect.append(t);
303
+ }
304
+ this.element.append(this.aspect), this.channel = r.createElement("select"), this.channel.setAttribute("aria-label", "Texture channel");
305
+ for (let e of [
306
+ "rgba",
307
+ "rgb",
308
+ "r",
309
+ "g",
310
+ "b",
311
+ "a"
312
+ ]) {
313
+ let t = r.createElement("option");
314
+ t.value = t.textContent = e, this.channel.append(t);
315
+ }
316
+ this.element.append(this.channel), this.metadata = r.createElement("pre"), this.element.append(this.metadata), this.canvas = r.createElement("canvas"), this.canvas.style.cssText = "max-width:100%;image-rendering:pixelated;background:repeating-conic-gradient(#ddd 0% 25%,#fff 0% 50%) 0/16px 16px", this.element.append(this.canvas), this.status = r.createElement("output"), this.status.setAttribute("role", "status"), this.element.append(this.status), this.list.addEventListener("change", () => {
317
+ this.mip.value = this.layer.value = "0", this.render();
318
+ });
319
+ for (let e of [
320
+ this.mip,
321
+ this.layer,
322
+ this.channel,
323
+ this.aspect,
324
+ this.exposure,
325
+ this.rangeMin,
326
+ this.rangeMax
327
+ ]) e.addEventListener("change", () => void this.render());
328
+ this.stop = e.onChange(() => this.refresh()), n.append(this.element), t.signal?.addEventListener("abort", this.abort, { once: !0 }), this.refresh();
329
+ }
330
+ refresh() {
331
+ if (this.disposed) return;
332
+ let e = this.capture.list(), t = this.list.value;
333
+ this.list.replaceChildren();
334
+ for (let t of e) {
335
+ let e = this.element.ownerDocument.createElement("option");
336
+ e.value = String(t.id), e.textContent = `${t.label || `Texture ${t.id}`} | ${t.width} x ${t.height} x ${t.depthOrArrayLayers} | ${t.format} | ${t.mipLevelCount} mips`, this.list.append(e);
337
+ }
338
+ e.some((e) => String(e.id) === t) && (this.list.value = t), this.render();
339
+ }
340
+ async select(t, n = {}) {
341
+ if (this.disposed) throw e("disposed", "Texture viewer is disposed; attach a new viewer");
342
+ if (!this.capture.list().some((e) => e.id === t)) throw e("state", "Texture is absent; refresh and select a listed texture");
343
+ this.list.value = String(t), this.mip.value = String(n.mip ?? 0), this.layer.value = String(n.layer ?? 0), this.channel.value = n.channel ?? "rgba", this.aspect.value = n.aspect ?? "default", this.exposure.value = String(n.exposure ?? 1), this.rangeMin.value = String(n.range?.[0] ?? 0), this.rangeMax.value = String(n.range?.[1] ?? 1), await this.render(n);
344
+ }
345
+ async render(e = {}) {
346
+ let t = ++this.request;
347
+ this.pending?.abort(), this.pending = new AbortController();
348
+ let n = this.capture.list().find((e) => String(e.id) === this.list.value);
349
+ if (!n) this.metadata.textContent = "No captured textures", this.canvas.width = this.canvas.height = 1;
350
+ else {
351
+ this.metadata.textContent = `${n.width} x ${n.height} x ${n.depthOrArrayLayers}\n${n.format} | ${n.dimension} | ${n.mipLevelCount} mips | ${n.sampleCount} samples`, this.mip.max = String(n.mipLevelCount - 1), this.layer.max = String((n.dimension === "3d" ? Math.max(1, n.depthOrArrayLayers >> Number(this.mip.value)) : n.depthOrArrayLayers) - 1);
352
+ try {
353
+ let r = await this.capture.preview(n.id, {
354
+ ...e,
355
+ mip: Number(this.mip.value),
356
+ layer: Number(this.layer.value),
357
+ channel: this.channel.value,
358
+ aspect: this.aspect.value === "default" ? void 0 : this.aspect.value,
359
+ exposure: Number(this.exposure.value),
360
+ range: [Number(this.rangeMin.value), Number(this.rangeMax.value)],
361
+ signal: e.signal ? AbortSignal.any([e.signal, this.pending.signal]) : this.pending.signal
362
+ });
363
+ if (this.disposed || t !== this.request) return;
364
+ this.canvas.width = r.width, this.canvas.height = r.height;
365
+ let i = this.canvas.getContext("2d"), a = i.createImageData(r.width, r.height);
366
+ a.data.set(r.data), i.putImageData(a, 0, 0), this.status.textContent = "";
367
+ } catch (e) {
368
+ !this.disposed && t === this.request && (this.status.textContent = e instanceof Error ? e.message : String(e));
369
+ }
370
+ }
371
+ }
372
+ dispose() {
373
+ this.disposed || (this.disposed = !0, this.request++, this.pending?.abort(), this.stop(), this.options.signal?.removeEventListener("abort", this.abort), this.element.remove());
374
+ }
375
+ [Symbol.dispose]() {
376
+ this.dispose();
377
+ }
378
+ };
379
+ //#endregion
380
+ export { i as TextureCapture, a as TextureViewer };
@@ -0,0 +1,101 @@
1
+ /// <reference lib="esnext.disposable" preserve="true" />
2
+ import type { EngineKernel } from '@margoengine/core';
3
+ import { type Camera, type EnginePlugin } from '@margoengine/core/extension';
4
+ // @ts-ignore optional peer: its types apply when it is installed
5
+ import type { PBRModel } from '@margoengine/gltf/pbr';
6
+ import type { CanvasRecording, CanvasRecordingOptions } from '@margoengine/video/record';
7
+ /** A named application camera. Its live pose and projection are copied while selected. */
8
+ export interface InspectorCamera {
9
+ id: string;
10
+ label: string;
11
+ camera: Camera;
12
+ }
13
+ /** Tools placement, application cameras and additional loaded models. */
14
+ export interface CameraToolsOptions {
15
+ /** Default document.body; null leaves the controls detached. */
16
+ parent?: HTMLElement | ShadowRoot | null;
17
+ cameras?: readonly InspectorCamera[];
18
+ /** Loaded models outside the engine plugin list. Default automatic discovery. */
19
+ models?: readonly PBRModel[];
20
+ signal?: AbortSignal;
21
+ }
22
+ /** Screenshot format and cancellation. */
23
+ export interface ToolsScreenshotOptions {
24
+ /** Default image/png. Unsupported browser encodings may return PNG. */
25
+ type?: 'image/png' | 'image/jpeg' | 'image/webp';
26
+ /** Lossy encoder quality, 0..1. Default browser choice. */
27
+ quality?: number;
28
+ /** Default 10000 ms, positive and finite. */
29
+ timeout?: number;
30
+ signal?: AbortSignal;
31
+ }
32
+ /** glTF output and scope. */
33
+ export interface ToolsExportOptions {
34
+ /** Default true for GLB; false returns embedded-buffer glTF JSON. */
35
+ binary?: boolean;
36
+ /** Default the engine scene; a loaded model preserves its PBR materials, skins and animations. */
37
+ model?: PBRModel;
38
+ signal?: AbortSignal;
39
+ }
40
+ /** Camera selection, canvas screenshots/recordings and lazy glTF export, usable beside any inspector panel. */
41
+ export declare class CameraTools implements EnginePlugin {
42
+ readonly engine: EngineKernel;
43
+ private readonly options;
44
+ readonly name: string;
45
+ readonly element: HTMLElement;
46
+ private readonly runtime;
47
+ private readonly home;
48
+ private readonly cameras;
49
+ private readonly modelIds;
50
+ private nextModel;
51
+ private active;
52
+ private updateCamera?;
53
+ private selection;
54
+ private signature;
55
+ private disposed;
56
+ private starting;
57
+ private recording?;
58
+ private readonly controller;
59
+ private readonly urls;
60
+ private readonly picker;
61
+ private readonly scope;
62
+ private readonly format;
63
+ private readonly output;
64
+ private readonly recordButton;
65
+ private readonly stopButton;
66
+ private readonly abort;
67
+ /** Attaches the panel; pass inspector.root as parent to put it in the existing inspector. */
68
+ static attach(engine: EngineKernel, options?: CameraToolsOptions): CameraTools;
69
+ constructor(engine: EngineKernel, options?: CameraToolsOptions);
70
+ setup(): void;
71
+ private signal;
72
+ private action;
73
+ private models;
74
+ private modelKey;
75
+ /** Lists registered application and live glTF cameras. The default entry restores the original engine camera. */
76
+ list(): readonly {
77
+ id: string;
78
+ label: string;
79
+ }[];
80
+ /** Adds or replaces a named application camera; ids beginning model: and default are reserved. */
81
+ addCamera(camera: InspectorCamera): this;
82
+ /** Removes an application camera. Removing the active camera restores the original view. */
83
+ removeCamera(id: string): void;
84
+ private restoreCamera;
85
+ /** Activates a camera. Loaded-camera projection code is imported only for a loaded glTF camera. */
86
+ select(id: string): Promise<void>;
87
+ onPreUpdate(): void;
88
+ /** Renders and serializes the canvas. DOM overlays are outside this image. */
89
+ screenshot(options?: ToolsScreenshotOptions): Promise<Blob>;
90
+ /** Starts browser recording; the video/record entry loads on this action only. */
91
+ startRecording(options?: CanvasRecordingOptions): Promise<CanvasRecording>;
92
+ /** Finishes recording after its final data event, returning the actual encoded file. */
93
+ stopRecording(): Promise<Blob>;
94
+ /** Exports the engine scene or a selected loaded model with the existing exporter package. */
95
+ exportGLTF(options?: ToolsExportOptions): Promise<Blob>;
96
+ private download;
97
+ /** Refreshes camera/model choices and recording button availability. */
98
+ refresh(): void;
99
+ dispose(): void;
100
+ [Symbol.dispose](): void;
101
+ }