@pacem/pacem-3d 1.0.0-bessel → 1.0.0-dirac
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/dist/browser/pacem-3d.js +646 -2
- package/dist/browser/pacem-3d.js.map +1 -1
- package/dist/browser/pacem-3d.min.js +1 -1
- package/dist/bundle/pacem-3d.min.mjs +1 -1
- package/dist/bundle/pacem-3d.mjs +180 -1
- package/dist/bundle/pacem-3d.mjs.map +2 -2
- package/dist/docs/pacem-3d.json +29096 -0
- package/dist/esm/constants.js +3 -1
- package/dist/esm/converters.js +5 -1
- package/dist/esm/decorators.js +8 -1
- package/dist/esm/detector.js +4 -1
- package/dist/esm/geometry.js +13 -1
- package/dist/esm/index-components-drawing3d.js +1 -1
- package/dist/esm/index-components.js +1 -1
- package/dist/esm/index-drawing3d.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index-root.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/stage.js +11 -1
- package/dist/esm/types.js +77 -1
- package/package.json +2 -1
- package/typings/index.d.ts +411 -0
package/typings/index.d.ts
CHANGED
|
@@ -11,27 +11,46 @@ import { Rect } from '@pacem/pacem-foundation';
|
|
|
11
11
|
import { Rgba } from '@pacem/pacem-foundation';
|
|
12
12
|
import { Size } from '@pacem/pacem-foundation';
|
|
13
13
|
|
|
14
|
+
/** Shared helpers used by the concrete `pacem-3d` rendering-backend adapters (Three.js, WebGPU): type guards, buffer flattening, camera lookup and pointer-to-clip-space conversion. */
|
|
14
15
|
declare class AdapterUtils {
|
|
16
|
+
/** Returns whether the given object is a {@link MeshGeometry} (has `positions` and `triangleIndices` arrays). */
|
|
15
17
|
static isMeshGeometry(obj: any): obj is MeshGeometry;
|
|
18
|
+
/** Returns whether the given object is a {@link Vector3D} (has numeric `x`/`y`/`z`). */
|
|
16
19
|
static isVector3D(obj: any): obj is Vector3D;
|
|
20
|
+
/** Returns whether the given object is an {@link Rgba} color (has numeric `r`/`g`/`b`). */
|
|
17
21
|
static isRgba(obj: any): obj is Rgba;
|
|
22
|
+
/**
|
|
23
|
+
* Flattens an array of 3D vectors, UV coordinates, or RGBA colors into a single flat number array (interleaved components), ready for a GPU buffer.
|
|
24
|
+
* @param array Array of {@link Vector3D}, {@link UVMap} entries, or {@link Rgba} values to flatten
|
|
25
|
+
*/
|
|
18
26
|
static flattenVectorArray(array: Vector3D[] | UVMap | Rgba[]): number[];
|
|
27
|
+
/**
|
|
28
|
+
* Returns the first non-hidden {@link Camera} among the given renderables, if any.
|
|
29
|
+
* @param items Renderable items to search
|
|
30
|
+
*/
|
|
19
31
|
static findCamera(items: Renderable[]): Camera;
|
|
32
|
+
/** Converts a viewport-relative point into WebGL/WebGPU clip space (-1..1 on both axes). */
|
|
20
33
|
clipPixel(viewportPoint: Point): Point;
|
|
34
|
+
/** Converts a pointer event's page coordinates into clip space, relative to the given canvas. */
|
|
21
35
|
clipPixel(evt: PointerEventLike, canvas: HTMLCanvasElement): Point;
|
|
36
|
+
/** Converts a pointer event's page coordinates into clip space, relative to the given viewport rectangle. */
|
|
22
37
|
clipPixel(evt: PointerEventLike, viewport: Rect): Point;
|
|
23
38
|
}
|
|
24
39
|
|
|
40
|
+
/** A {@link Material} using the unlit ("basic") shading model: rendered at flat {@link Material.color}, unaffected by scene lighting. */
|
|
25
41
|
declare interface BasicMaterial extends Material {
|
|
26
42
|
readonly shader: KnownShader.Basic;
|
|
27
43
|
}
|
|
28
44
|
|
|
45
|
+
/** `<pacem-3d-material-basic>`: produces a {@link BasicMaterial} (unlit shading model): rendered at flat color, unaffected by scene lighting. */
|
|
29
46
|
declare class BasicMaterialElement extends MaterialElement {
|
|
30
47
|
constructor();
|
|
31
48
|
}
|
|
32
49
|
|
|
50
|
+
/** Converts an attribute string to/from either a `boolean` (`"true"`/`"false"`) or a `number`. */
|
|
33
51
|
declare const BooleanOrNumberConverter: PropertyConverter;
|
|
34
52
|
|
|
53
|
+
/** Axis-aligned bounding box in 3d world space. */
|
|
35
54
|
declare interface Box3D {
|
|
36
55
|
minX: number;
|
|
37
56
|
minY: number;
|
|
@@ -41,12 +60,15 @@ declare interface Box3D {
|
|
|
41
60
|
maxZ: number;
|
|
42
61
|
}
|
|
43
62
|
|
|
63
|
+
/** A {@link Renderable} viewpoint used to render the scene: perspective ({@link PerspectiveCamera}) or orthographic ({@link OrthographicCamera}). */
|
|
44
64
|
declare interface Camera extends Renderable {
|
|
45
65
|
/** Target in world coordinates. */
|
|
46
66
|
lookAt: Vector3D;
|
|
47
67
|
/** Up vector in world coordinates. */
|
|
48
68
|
up: Vector3D;
|
|
69
|
+
/** Near clipping plane distance. */
|
|
49
70
|
near: number;
|
|
71
|
+
/** Far clipping plane distance. */
|
|
50
72
|
far: number;
|
|
51
73
|
}
|
|
52
74
|
|
|
@@ -70,6 +92,7 @@ declare function computePlaneNormal(a: Vector3D, b: Vector3D, c: Vector3D): Vect
|
|
|
70
92
|
*/
|
|
71
93
|
declare function computeSharpVertexNormals(geometry: MeshGeometry): void;
|
|
72
94
|
|
|
95
|
+
/** A {@link Material} whose shading model accounts for diffuse (matte) reflection of scene lighting. */
|
|
73
96
|
declare interface DiffuseMaterial extends Material {
|
|
74
97
|
/** Diffuse color, albedo. */
|
|
75
98
|
emissiveColor?: string;
|
|
@@ -79,11 +102,15 @@ declare interface DiffuseMaterial extends Material {
|
|
|
79
102
|
refractionRatio?: number;
|
|
80
103
|
}
|
|
81
104
|
|
|
105
|
+
/** Event dispatched while a {@link Renderable} item is being dragged (`itemdragstart`/`itemdrag`/`itemdragend`-like events), carrying a {@link DragEventArgs} payload. */
|
|
82
106
|
declare class DragEvent_2 extends UI3DEvent<DragEventArgs> {
|
|
83
107
|
}
|
|
84
108
|
|
|
109
|
+
/** Payload carried by a {@link DragEvent}: the dragged {@link Renderable} item and its drag offset. */
|
|
85
110
|
declare interface DragEventArgs {
|
|
111
|
+
/** Gets the drag displacement. */
|
|
86
112
|
readonly offset: Point;
|
|
113
|
+
/** Gets the item being dragged. */
|
|
87
114
|
readonly item: Renderable;
|
|
88
115
|
}
|
|
89
116
|
|
|
@@ -260,58 +287,84 @@ export declare namespace Drawing3D_2 {
|
|
|
260
287
|
}
|
|
261
288
|
}
|
|
262
289
|
|
|
290
|
+
/** User-supplied callback (see {@link WGSLModifierDelegates.fragment}) that returns extra WGSL statements to splice into the fragment stage. */
|
|
263
291
|
declare type FragmentModifierDelegate = (...args: FragmentModifierDelegateArgs) => string;
|
|
264
292
|
|
|
293
|
+
/** Tuple of WGSL identifiers passed to a {@link FragmentModifierDelegate}: world position, instance index, time, cursor and viewport-size references, so custom snippets can reference them. */
|
|
265
294
|
declare type FragmentModifierDelegateArgs = [worldPositionRef: string, instanceIndexRef: string, timeRef: string, cursorRef: string, sizeRef: string];
|
|
266
295
|
|
|
296
|
+
/** A {@link Ui3DObject} that contains other {@link Renderable}s, as produced by {@link Pacem3DGroupElement}. */
|
|
267
297
|
declare interface Group extends Ui3DObject {
|
|
298
|
+
/** Gets the renderable children currently belonging to the group. */
|
|
268
299
|
childRenderables: Renderable[];
|
|
269
300
|
}
|
|
270
301
|
|
|
302
|
+
/** Snapshot of the current pointer/viewport interaction state, as consumed by a WebGPU render pass for hit-testing/uniforms. */
|
|
271
303
|
declare interface Interaction {
|
|
304
|
+
/** Timestamp (as returned by `performance.now()`) of the current frame. */
|
|
272
305
|
time: number;
|
|
273
306
|
cursor: Point;
|
|
274
307
|
resolution: Size;
|
|
275
308
|
}
|
|
276
309
|
|
|
310
|
+
/** Type guard checking whether `obj` implements the {@link BasicMaterial} contract. */
|
|
277
311
|
declare function isBasicMaterial(obj: any): obj is BasicMaterial;
|
|
278
312
|
|
|
313
|
+
/** Type guard checking whether `object` implements the {@link Camera} contract. */
|
|
279
314
|
declare function isCamera(object: any): object is Camera;
|
|
280
315
|
|
|
316
|
+
/** Type guard checking whether `object` implements the {@link NodeGeometry} contract. */
|
|
281
317
|
declare function isGeometry(object: any): object is NodeGeometry;
|
|
282
318
|
|
|
319
|
+
/** Type guard checking whether `object` implements the {@link Group} contract. */
|
|
283
320
|
declare function isGroup(object: any): object is Group;
|
|
284
321
|
|
|
322
|
+
/** Type guard checking whether `object` implements the {@link Interaction} contract. */
|
|
285
323
|
declare function isInteraction(object: any): object is Interaction;
|
|
286
324
|
|
|
325
|
+
/** Type guard checking whether `obj` implements the {@link LambertMaterial} contract. */
|
|
287
326
|
declare function isLambertMaterial(obj: any): obj is LambertMaterial;
|
|
288
327
|
|
|
328
|
+
/** Type guard checking whether `object` implements the {@link Light} contract. */
|
|
289
329
|
declare function isLight(object: any): object is Light;
|
|
290
330
|
|
|
331
|
+
/** Type guard checking whether `obj` implements the {@link LineMaterial} contract. */
|
|
291
332
|
declare function isLineMaterial(obj: any): obj is LineMaterial;
|
|
292
333
|
|
|
334
|
+
/** Type guard checking whether `obj` implements the {@link Material} contract. */
|
|
293
335
|
declare function isMaterial(obj: any): obj is Material;
|
|
294
336
|
|
|
337
|
+
/** Type guard checking whether `object` implements the {@link Mesh} contract. */
|
|
295
338
|
declare function isMesh(object: any): object is Mesh;
|
|
296
339
|
|
|
340
|
+
/** Type guard checking whether `object` implements the {@link MeshGeometry} contract (a {@link NodeGeometry} with triangle indices/normals/UVs). */
|
|
297
341
|
declare function isMeshGeometry(object: any): object is MeshGeometry;
|
|
298
342
|
|
|
343
|
+
/** Type guard checking whether `object` is an {@link OrthographicCamera}. */
|
|
299
344
|
declare function isOrthographicCamera(object: any): object is OrthographicCamera;
|
|
300
345
|
|
|
346
|
+
/** Type guard checking whether `object` is a {@link PerspectiveCamera}. */
|
|
301
347
|
declare function isPerspectiveCamera(object: any): object is PerspectiveCamera;
|
|
302
348
|
|
|
349
|
+
/** Type guard checking whether `obj` implements the {@link PhongMaterial} contract. */
|
|
303
350
|
declare function isPhongMaterial(obj: any): obj is PhongMaterial;
|
|
304
351
|
|
|
352
|
+
/** Type guard checking whether `object` implements the {@link Renderable} contract (i.e. it is attached to a valid {@link Stage}). */
|
|
305
353
|
declare function isRenderable(object: any): object is Renderable;
|
|
306
354
|
|
|
355
|
+
/** Type guard checking whether `obj` implements the {@link ShaderMaterial} contract. */
|
|
307
356
|
declare function isShaderMaterial(obj: any): obj is ShaderMaterial;
|
|
308
357
|
|
|
358
|
+
/** Type guard checking whether `object` implements the {@link Stage} contract. */
|
|
309
359
|
declare function isStage(object: any): object is Stage;
|
|
310
360
|
|
|
361
|
+
/** Type guard checking whether `obj` implements the {@link StandardMaterial} contract. */
|
|
311
362
|
declare function isStandardMaterial(obj: any): obj is StandardMaterial;
|
|
312
363
|
|
|
364
|
+
/** Type guard checking whether `object` implements the {@link Ui3DObject} contract (i.e. it exposes a {@link Ui3DObject.transformMatrix}). */
|
|
313
365
|
declare function isUi3DObject(object: any): object is Ui3DObject;
|
|
314
366
|
|
|
367
|
+
/** Identifies the shading model (and, correspondingly, the concrete `Material` shape) applied to a mesh's faces. */
|
|
315
368
|
declare enum KnownShader {
|
|
316
369
|
Basic = "basic",
|
|
317
370
|
Lambert = "lambert",
|
|
@@ -321,128 +374,216 @@ declare enum KnownShader {
|
|
|
321
374
|
Custom = "custom"
|
|
322
375
|
}
|
|
323
376
|
|
|
377
|
+
/** A {@link DiffuseMaterial} using the Lambertian shading model: matte, non-specular reflection with no glossy highlights. */
|
|
324
378
|
declare interface LambertMaterial extends DiffuseMaterial {
|
|
325
379
|
readonly shader: KnownShader.Lambert;
|
|
326
380
|
}
|
|
327
381
|
|
|
382
|
+
/** `<pacem-3d-material-lambert>`: produces a {@link LambertMaterial} (Lambertian shading model): matte, non-specular reflection of scene lighting, with no glossy highlights. */
|
|
328
383
|
declare class LambertMaterialElement extends MaterialElement {
|
|
329
384
|
constructor();
|
|
385
|
+
/** Builds the {@link LambertMaterial}, adding `emissiveColor`, `reflectivity` and `refractionRatio` to the base {@link Material}. */
|
|
330
386
|
protected createMaterial(): Promise<LambertMaterial>;
|
|
331
387
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
388
|
+
/** Gets or sets the diffuse color (albedo). */
|
|
332
389
|
emissiveColor: string;
|
|
390
|
+
/** Gets or sets the percentage of reflected light. */
|
|
333
391
|
reflectivity: number;
|
|
392
|
+
/** Gets or sets the index of refraction. */
|
|
334
393
|
refractionRatio: number;
|
|
335
394
|
}
|
|
336
395
|
|
|
396
|
+
/** A {@link Renderable} light source (spot, directional, point/omni or ambient), as produced by {@link Pacem3DLightElement}. */
|
|
337
397
|
declare interface Light extends Renderable {
|
|
398
|
+
/** Gets or sets the light intensity/brightness. */
|
|
338
399
|
intensity: number;
|
|
400
|
+
/** Gets or sets the point the light is aimed at (spotlight-specific). */
|
|
339
401
|
target?: Vector3D;
|
|
402
|
+
/** Gets or sets the light color. */
|
|
340
403
|
color: string;
|
|
404
|
+
/** Gets or sets the kind of light source. */
|
|
341
405
|
type: 'spot' | 'direction' | 'omni' | 'ambient';
|
|
406
|
+
/** Distance at which the spotlight intensity starts to fall off (spotlight-specific). */
|
|
342
407
|
attenuationStart?: number;
|
|
408
|
+
/** Distance beyond which the spotlight has no effect (spotlight-specific). */
|
|
343
409
|
attenuationEnd?: number;
|
|
410
|
+
/** Cone angle, in degrees (spotlight-specific). */
|
|
344
411
|
angle?: number;
|
|
345
412
|
}
|
|
346
413
|
|
|
414
|
+
/** A {@link NodeGeometry} rendered as a polyline through its {@link positions} (no faces/triangles). */
|
|
347
415
|
declare class LineGeometry extends NodeGeometry {
|
|
416
|
+
/** Gets or sets the vertex positions, in local space; reassigning this array flags the geometry as dirty. */
|
|
348
417
|
positions: Vector3D_2[];
|
|
349
418
|
}
|
|
350
419
|
|
|
420
|
+
/** A {@link Material} for rendering {@link PacemLineElement} polylines: stroke width, joins, caps and dash pattern. */
|
|
351
421
|
declare interface LineMaterial extends Material {
|
|
352
422
|
readonly shader: KnownShader.Line;
|
|
423
|
+
/** Gets or sets the stroke width, in local units. */
|
|
353
424
|
lineWidth: number;
|
|
425
|
+
/** Gets or sets how consecutive line segments are joined. */
|
|
354
426
|
lineJoin?: CanvasLineJoin;
|
|
427
|
+
/** Gets or sets how the line's endpoints are capped. */
|
|
355
428
|
lineCap?: CanvasLineCap;
|
|
429
|
+
/** Gets or sets the alternating dash/gap lengths, or `undefined`/empty for a solid line. */
|
|
356
430
|
dashArray?: number[];
|
|
357
431
|
}
|
|
358
432
|
|
|
433
|
+
/** `<pacem-3d-material-line>`: produces a {@link LineMaterial} for rendering {@link PacemLineElement} polylines (stroke width, joins, caps, dash pattern). */
|
|
359
434
|
declare class LineMaterialElement extends MaterialElement {
|
|
360
435
|
constructor();
|
|
436
|
+
/** Gets or sets the stroke width, in local units. */
|
|
361
437
|
lineWidth: number;
|
|
438
|
+
/** Gets or sets how consecutive line segments are joined. */
|
|
362
439
|
lineJoin?: CanvasLineJoin;
|
|
440
|
+
/** Gets or sets how the line's endpoints are capped. */
|
|
363
441
|
lineCap?: CanvasLineCap;
|
|
442
|
+
/** Gets or sets the alternating dash/gap lengths (comma-separated as an attribute), or unset for a solid line. */
|
|
364
443
|
dashArray?: number[];
|
|
365
444
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
445
|
+
/** Builds the {@link LineMaterial}, adding `lineWidth`, `lineJoin`, `lineCap` and `dashArray` to the base {@link Material}. */
|
|
366
446
|
protected createMaterial(): Promise<LineMaterial>;
|
|
367
447
|
}
|
|
368
448
|
|
|
449
|
+
/** Plain-data contract shared by every shading model, produced by a {@link MaterialElement} and consumed by the rendering adapter. */
|
|
369
450
|
declare interface Material {
|
|
451
|
+
/** Opacity, from `0` (fully transparent) to `1` (fully opaque). */
|
|
370
452
|
opacity?: number;
|
|
453
|
+
/** Renders the faces as a wireframe (edges only) instead of solid, shaded surfaces. */
|
|
371
454
|
wireframe?: boolean;
|
|
372
455
|
/** Object color. */
|
|
373
456
|
color?: string | Rgba;
|
|
457
|
+
/** Whether the object is rendered at all. */
|
|
374
458
|
visible?: boolean;
|
|
375
459
|
/** Texture map. */
|
|
376
460
|
map?: string;
|
|
461
|
+
/** The decoded bitmap of {@link map}, loaded asynchronously. */
|
|
377
462
|
texture?: ImageBitmap;
|
|
378
463
|
/** Renders each face as flat. */
|
|
379
464
|
flatShading?: boolean;
|
|
465
|
+
/** Identifies the shading model this material implements. */
|
|
380
466
|
readonly shader: KnownShader;
|
|
467
|
+
/** Gets the list of {@link StalePropertyFlag}s accumulated since the material was last consumed by the adapter/renderer. */
|
|
381
468
|
flags: StalePropertyFlag[];
|
|
382
469
|
}
|
|
383
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Abstract base of the declarative material custom elements — {@link BasicMaterialElement}, {@link LambertMaterialElement},
|
|
473
|
+
* {@link LineMaterialElement}, {@link PhongMaterialElement} and {@link StandardMaterialElement} — that assemble a
|
|
474
|
+
* {@link Material} (with its `shader`-specific extra properties) out of shared and shader-specific watched attributes,
|
|
475
|
+
* ready to be assigned to a `Pacem3DMeshElement`'s `material`/`backMaterial` property.
|
|
476
|
+
*/
|
|
384
477
|
declare abstract class MaterialElement extends PacemEventTarget {
|
|
385
478
|
#private;
|
|
479
|
+
/** @param shader The {@link KnownShader} this element's {@link createMaterial} produces. */
|
|
386
480
|
constructor(shader: KnownShader);
|
|
481
|
+
/** Gets the shading model this element produces materials for. */
|
|
387
482
|
get shader(): KnownShader;
|
|
388
483
|
private _loadMap;
|
|
484
|
+
/** Gets or sets the computed {@link Material}, recomputed by {@link updateMaterial} whenever a shading attribute changes. */
|
|
389
485
|
material: Material;
|
|
486
|
+
/** Gets or sets the opacity, from `0` (fully transparent) to `1` (fully opaque). */
|
|
390
487
|
opacity: number;
|
|
488
|
+
/** Gets or sets whether faces render as a wireframe (edges only) instead of solid, shaded surfaces. */
|
|
391
489
|
wireframe: boolean;
|
|
490
|
+
/** Gets or sets the object color (defaults to the `--pacem-color-primary` CSS custom property when unset). */
|
|
392
491
|
color: string;
|
|
492
|
+
/** Gets or sets whether the object is hidden (not rendered). */
|
|
393
493
|
hide: boolean;
|
|
494
|
+
/** Gets or sets the URL of the texture map to load into {@link Material.texture}. */
|
|
394
495
|
map?: string;
|
|
395
496
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
396
497
|
viewActivatedCallback(): void;
|
|
498
|
+
/** Recomputes {@link material} via {@link createMaterial}, flagging it as {@link StalePropertyFlag.Material}. */
|
|
397
499
|
protected updateMaterial(): void;
|
|
500
|
+
/** Builds the base {@link Material} out of the shared watched attributes (`opacity`, `wireframe`, `color`, `hide`, `map`); overridden by subclasses to add their shader-specific properties. */
|
|
398
501
|
protected createMaterial(): Promise<Material>;
|
|
399
502
|
}
|
|
400
503
|
|
|
504
|
+
/** A 4x4 3d transform matrix (rotation, scale, translation). */
|
|
401
505
|
declare type Matrix3D = Geometry.LinearAlgebra.Matrix3D;
|
|
402
506
|
|
|
507
|
+
/** A {@link Ui3DObject} with a {@link NodeGeometry} (vertex data) and up to two {@link Material}s (front/back face), as produced by {@link Pacem3DMeshElement}. */
|
|
403
508
|
declare interface Mesh extends Ui3DObject {
|
|
509
|
+
/** Gets or sets the vertex/index data defining the mesh's shape. */
|
|
404
510
|
geometry: NodeGeometry;
|
|
511
|
+
/** Gets or sets the material applied to front-facing faces. */
|
|
405
512
|
material?: Material;
|
|
513
|
+
/** Gets or sets the material applied to back-facing faces (defaults to {@link material} when unset). */
|
|
406
514
|
backMaterial?: Material;
|
|
407
515
|
}
|
|
408
516
|
|
|
517
|
+
/** A {@link NodeGeometry} for triangulated surfaces: adds triangle vertex indices, per-vertex UV texture coordinates and normals. */
|
|
409
518
|
declare interface MeshGeometry extends NodeGeometry {
|
|
519
|
+
/** Gets or sets the vertex indices forming the mesh's triangles (each consecutive triplet is one face). */
|
|
410
520
|
triangleIndices: number[];
|
|
521
|
+
/** Gets or sets the per-vertex texture (u, v) coordinates. */
|
|
411
522
|
textureCoordinates: UVMap;
|
|
523
|
+
/** Gets or sets the per-vertex normals, used for lighting. */
|
|
412
524
|
normals: Vector3D_2[];
|
|
413
525
|
}
|
|
414
526
|
|
|
527
|
+
/** A {@link MeshGeometry} implementation with lazily-computed {@link barycenter}/{@link boundingBox} and settable {@link boundingSphere}, used as the `geometry` of a {@link Pacem3DMeshElement}. */
|
|
415
528
|
declare class MeshGeometry extends NodeGeometry {
|
|
416
529
|
#private;
|
|
530
|
+
/** Gets or sets the centroid of {@link positions}; computed on first access if not explicitly set. */
|
|
417
531
|
get barycenter(): Vector3D_2;
|
|
418
532
|
set barycenter(point: Vector3D_2);
|
|
533
|
+
/** Gets or sets the axis-aligned bounding box; computed from {@link positions} on first access if not explicitly set. */
|
|
419
534
|
get boundingBox(): Box3D;
|
|
420
535
|
set boundingBox(bbox: Box3D);
|
|
536
|
+
/** Gets or sets the bounding sphere. */
|
|
421
537
|
get boundingSphere(): Sphere3D;
|
|
422
538
|
set boundingSphere(sphere: Sphere3D);
|
|
423
539
|
constructor(positions: Vector3D_2[], triangleIndices: number[], textureCoordinates?: UVMap, normals?: Vector3D_2[]);
|
|
540
|
+
/** Gets or sets the vertex positions, in local space; reassigning this array flags the geometry as dirty. */
|
|
424
541
|
positions: Vector3D_2[];
|
|
542
|
+
/** Gets or sets the vertex indices forming the mesh's triangles; reassigning this array flags the geometry as dirty. */
|
|
425
543
|
triangleIndices: number[];
|
|
544
|
+
/** Gets or sets the per-vertex texture (u, v) coordinates; reassigning this array flags the geometry as dirty. */
|
|
426
545
|
textureCoordinates: UVMap;
|
|
546
|
+
/** Gets or sets the per-vertex normals; reassigning this array flags the geometry as dirty. */
|
|
427
547
|
normals: Vector3D_2[];
|
|
428
548
|
}
|
|
429
549
|
|
|
550
|
+
/** Vertex data contract shared by all geometry kinds ({@link LineGeometry}, {@link MeshGeometry}): a set of positions plus their derived bounding volumes. */
|
|
430
551
|
declare interface NodeGeometry {
|
|
552
|
+
/** Gets or sets the vertex positions, in local space. */
|
|
431
553
|
positions: Vector3D_2[];
|
|
554
|
+
/** Gets or sets the axis-aligned bounding box, computed from {@link positions} when unset. */
|
|
432
555
|
boundingBox?: Box3D;
|
|
556
|
+
/** Gets or sets the centroid of {@link positions}, computed on demand when unset. */
|
|
433
557
|
barycenter?: Vector3D_2;
|
|
558
|
+
/** Gets or sets the bounding sphere. */
|
|
434
559
|
boundingSphere?: Sphere3D;
|
|
560
|
+
/** Gets the list of {@link StalePropertyFlag}s accumulated since the geometry was last consumed by the adapter/renderer. */
|
|
435
561
|
flags: StalePropertyFlag[];
|
|
562
|
+
/** Gets or sets an identity key, used by adapters/renderers to track the geometry across updates. */
|
|
436
563
|
key?: string;
|
|
437
564
|
}
|
|
438
565
|
|
|
566
|
+
/**
|
|
567
|
+
* Abstract base for the concrete geometry classes ({@link LineGeometry}, {@link MeshGeometry}) that back a
|
|
568
|
+
* {@link Pacem3DMeshElement}'s `geometry` property, providing shared bounding-volume computation helpers.
|
|
569
|
+
*/
|
|
439
570
|
declare abstract class NodeGeometry {
|
|
440
571
|
constructor(positions?: Vector3D_2[]);
|
|
572
|
+
/** Computes the centroid (average) of the given positions. */
|
|
441
573
|
static barycenter(positions: Vector3D_2[]): Vector3D_2;
|
|
574
|
+
/** Computes the axis-aligned {@link Box3D} enclosing the given positions. */
|
|
442
575
|
static boundingBox(positions: Vector3D_2[]): Box3D;
|
|
576
|
+
/** Marks the geometry as stale, flagging it with {@link StalePropertyFlag.Geometry} for the next render. */
|
|
443
577
|
protected setAsDirty(): void;
|
|
444
578
|
}
|
|
445
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Property decorator factory that turns the decorated field into an accessor backed by a private field, invoking
|
|
582
|
+
* `callback` with the property name and old/new values whenever it is set to a different value. Used by
|
|
583
|
+
* {@link NodeGeometry}/{@link LineGeometry}/{@link MeshGeometry} to flag themselves as dirty ({@link StalePropertyFlag.Geometry})
|
|
584
|
+
* whenever their vertex data changes.
|
|
585
|
+
* @param callback Invoked (with `this` bound to the decorated instance) on every effective change of the property.
|
|
586
|
+
*/
|
|
446
587
|
declare function NotifyChange(callback: (property?: string, old?: any, val?: any) => void): (target: any, prop: string, descriptor?: PropertyDescriptor) => void;
|
|
447
588
|
|
|
448
589
|
declare class OrbitCameraBehavior {
|
|
@@ -499,6 +640,7 @@ declare type OrbitCameraControl = {
|
|
|
499
640
|
modifiers?: EventKeyModifier[];
|
|
500
641
|
};
|
|
501
642
|
|
|
643
|
+
/** A {@link Camera} that projects the scene with a fixed, non-diminishing frustum (parallel projection), as produced by {@link Pacem3DOrthographicCameraElement}. */
|
|
502
644
|
declare interface OrthographicCamera extends Camera {
|
|
503
645
|
type: "orthographic";
|
|
504
646
|
/** Top frustum coordinate (e.g. 1). */
|
|
@@ -511,6 +653,12 @@ declare interface OrthographicCamera extends Camera {
|
|
|
511
653
|
right: number;
|
|
512
654
|
}
|
|
513
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Pluggable rendering-backend contract assignable to a {@link Pacem3DElement}'s `adapter` property. Concrete adapters
|
|
658
|
+
* ({@link Pacem3DThreeAdapterElement} for Three.js/WebGL, {@link Pacem3DWebgpuAdapterElement} for WebGPU) are
|
|
659
|
+
* responsible for initializing/disposing the underlying native scene and DOM surface, sizing it, translating the
|
|
660
|
+
* {@link RenderableElement} scene graph into native objects, hit-testing (raycasting) and producing snapshot images.
|
|
661
|
+
*/
|
|
514
662
|
declare abstract class Pacem3DAdapterElement extends PacemEventTarget {
|
|
515
663
|
/**
|
|
516
664
|
* When implemented in a derived class, resizes the stage.
|
|
@@ -555,6 +703,10 @@ declare abstract class Pacem3DAdapterElement extends PacemEventTarget {
|
|
|
555
703
|
* @param items
|
|
556
704
|
*/
|
|
557
705
|
abstract zoomFit(scene: Pacem3DElement, ...items: Ui3DObject[]): Promise<void>;
|
|
706
|
+
/**
|
|
707
|
+
* When implemented in a derived class, projects a 3d world-space point onto the 2d viewport (screen) coordinates.
|
|
708
|
+
* @param point3D Point in 3d world space.
|
|
709
|
+
*/
|
|
558
710
|
abstract project(scene: Pacem3DElement, point3D: Vector3D): Point;
|
|
559
711
|
/** Gets the native scene instance */
|
|
560
712
|
abstract getScene(scene: Pacem3DElement): any;
|
|
@@ -565,13 +717,23 @@ declare abstract class Pacem3DAdapterElement extends PacemEventTarget {
|
|
|
565
717
|
abstract dispose(scene: Pacem3DElement): void;
|
|
566
718
|
}
|
|
567
719
|
|
|
720
|
+
/**
|
|
721
|
+
* Abstract base of the camera custom elements ({@link Pacem3DPerspectiveCameraElement}, {@link Pacem3DOrthographicCameraElement})
|
|
722
|
+
* that can be added to a {@link Pacem3DElement} stage. Implements {@link Camera}, tracking the eye-to-target
|
|
723
|
+
* {@link boundingSphere} used e.g. by {@link Pacem3DAdapterElement.zoomFit}.
|
|
724
|
+
*/
|
|
568
725
|
declare abstract class Pacem3DCameraElement extends RenderableElement implements Camera {
|
|
569
726
|
#private;
|
|
727
|
+
/** Gets or sets the near clipping plane distance. */
|
|
570
728
|
near: number;
|
|
729
|
+
/** Gets or sets the far clipping plane distance. */
|
|
571
730
|
far: number;
|
|
731
|
+
/** Gets or sets the up vector, in world coordinates. */
|
|
572
732
|
up: Vector3D;
|
|
733
|
+
/** Gets or sets the target the camera looks at, in world coordinates. */
|
|
573
734
|
lookAt: Vector3D;
|
|
574
735
|
private _resetBoundingSphere;
|
|
736
|
+
/** @readonly Gets the sphere centered on {@link lookAt} with radius equal to the eye-to-target distance. */
|
|
575
737
|
get boundingSphere(): Sphere3D;
|
|
576
738
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
577
739
|
}
|
|
@@ -579,7 +741,9 @@ declare abstract class Pacem3DCameraElement extends RenderableElement implements
|
|
|
579
741
|
/** @deprecated*/
|
|
580
742
|
declare class Pacem3DDetector {
|
|
581
743
|
private _detected;
|
|
744
|
+
/** Probes the browser for WebGL support by attempting to create a rendering context, populating {@link info} and {@link supported}. */
|
|
582
745
|
constructor();
|
|
746
|
+
/** @readonly Gets the detected WebGL capabilities/limits, grouped by section (`main`, `bits`, `shader`, `tex`, `misc`). */
|
|
583
747
|
get info(): {
|
|
584
748
|
main?: any;
|
|
585
749
|
bits?: any;
|
|
@@ -587,22 +751,36 @@ declare class Pacem3DDetector {
|
|
|
587
751
|
tex?: any;
|
|
588
752
|
misc?: any;
|
|
589
753
|
};
|
|
754
|
+
/** @readonly Gets whether a WebGL rendering context could be created on this browser/device. */
|
|
590
755
|
get supported(): boolean;
|
|
591
756
|
}
|
|
592
757
|
|
|
758
|
+
/**
|
|
759
|
+
* `<pacem-3d>`: the root 3d stage element. Hosts the {@link RenderableElement} scene graph (groups, meshes, lights,
|
|
760
|
+
* cameras) declared as children or provided via {@link datasource}, delegates all actual scene-building/rendering/
|
|
761
|
+
* hit-testing to the pluggable {@link adapter} ({@link Pacem3DAdapterElement}), and dispatches pointer interaction
|
|
762
|
+
* events ({@link RenderableEvent}/{@link DragEvent}) for the items under the cursor.
|
|
763
|
+
*/
|
|
593
764
|
declare class Pacem3DElement extends Components_2.PacemItemsContainerElement<RenderableElement> implements Stage {
|
|
594
765
|
#private;
|
|
595
766
|
validate(item: RenderableElement): boolean;
|
|
596
767
|
private _container;
|
|
597
768
|
private _resizer;
|
|
769
|
+
/** Gets or sets whether the stage listens for pointer interactions (hover/click/drag) and dispatches the corresponding events. */
|
|
598
770
|
interactive: boolean;
|
|
771
|
+
/** Gets or sets whether the stage background should be transparent. */
|
|
599
772
|
transparent: boolean;
|
|
773
|
+
/** Gets or sets the stage background color (ignored when {@link transparent} is set). */
|
|
600
774
|
background: string;
|
|
775
|
+
/** Gets or sets the {@link Pacem3DAdapterElement} rendering backend (e.g. a {@link Pacem3DThreeAdapterElement} or {@link Pacem3DWebgpuAdapterElement}) used to actually build/render the scene. */
|
|
601
776
|
adapter: Pacem3DAdapterElement;
|
|
777
|
+
/** Gets or sets the renderable items, as an alternative/complement to declaring them in markup. */
|
|
602
778
|
datasource: Renderable[];
|
|
603
779
|
/** @deprecated */
|
|
604
780
|
orbit: boolean;
|
|
781
|
+
/** @readonly Gets the DOM element the scene is mounted into. */
|
|
605
782
|
get stage(): HTMLElement;
|
|
783
|
+
/** @readonly Gets the technology-dependent native scene instance, as reported by the active {@link adapter}. */
|
|
606
784
|
get scene(): any;
|
|
607
785
|
register(item: RenderableElement): boolean;
|
|
608
786
|
unregister(item: RenderableElement): boolean;
|
|
@@ -620,64 +798,106 @@ declare class Pacem3DElement extends Components_2.PacemItemsContainerElement<Ren
|
|
|
620
798
|
private _hitTestCallback;
|
|
621
799
|
private _moveHandler;
|
|
622
800
|
disconnectedCallback(): void;
|
|
801
|
+
/** @readonly Gets the current viewport size, as last reported by the internal resize observer. */
|
|
623
802
|
get size(): Size;
|
|
624
803
|
private _resizeHandler;
|
|
804
|
+
/** Renders the whole scene through the active {@link adapter}, or just updates the given `item` if provided. */
|
|
625
805
|
render(item?: Renderable, deepUpdate?: boolean, now?: number): void;
|
|
626
806
|
private _doRender;
|
|
627
807
|
}
|
|
628
808
|
|
|
809
|
+
/** `<pacem-3d-group>`: a {@link Ui3DElement} container that groups child {@link RenderableElement}s (declarative or from {@link datasource}) so its own transform applies to all of them. */
|
|
629
810
|
declare class Pacem3DGroupElement extends Ui3DElement implements Group {
|
|
630
811
|
#private;
|
|
631
812
|
validate(child: RenderableElement): boolean;
|
|
813
|
+
/** Gets or sets the renderable children, as an alternative to declaring them in markup. */
|
|
632
814
|
datasource: Renderable[];
|
|
815
|
+
/** @readonly Gets the renderable children currently belonging to the group. */
|
|
633
816
|
get childRenderables(): Renderable[];
|
|
634
817
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
635
818
|
}
|
|
636
819
|
|
|
820
|
+
/** `<pacem-3d-light>`: a {@link RenderableElement} light source (point/omni, spot or directional) illuminating the scene. */
|
|
637
821
|
declare class Pacem3DLightElement extends RenderableElement implements Light {
|
|
822
|
+
/** Gets or sets the light intensity/brightness. */
|
|
638
823
|
intensity: number;
|
|
824
|
+
/** Gets or sets the point the light is aimed at (spotlight-specific). */
|
|
639
825
|
target: Vector3D;
|
|
826
|
+
/** Gets or sets the light color. */
|
|
640
827
|
color: string;
|
|
828
|
+
/** Gets or sets the kind of light source. */
|
|
641
829
|
type: 'spot' | 'direction' | 'omni';
|
|
642
830
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
643
831
|
}
|
|
644
832
|
|
|
833
|
+
/** `<pacem-3d-mesh>`: a {@link Ui3DElement} that renders a {@link NodeGeometry} (mesh or line) with a front/back {@link Material}. */
|
|
645
834
|
declare class Pacem3DMeshElement extends Ui3DElement implements Mesh {
|
|
835
|
+
/** Gets or sets the vertex/index data defining the mesh's shape. */
|
|
646
836
|
geometry: NodeGeometry;
|
|
837
|
+
/** Gets or sets the material applied to front-facing faces. */
|
|
647
838
|
material: Material;
|
|
839
|
+
/** Gets or sets the material applied to back-facing faces (defaults to {@link material} when unset). */
|
|
648
840
|
backMaterial: Material;
|
|
649
841
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
650
842
|
}
|
|
651
843
|
|
|
844
|
+
/** `<pacem-3d-object>`: a {@link Ui3DElement} that loads/embeds a pre-built 3d asset (`obj`, `fbx`, or a native scene-graph object) instead of an explicit {@link Pacem3DMeshElement} geometry. */
|
|
652
845
|
declare class Pacem3DObjectElement extends Ui3DElement {
|
|
846
|
+
/** Gets or sets the raw asset content (format depends on {@link type}) to parse/load. */
|
|
653
847
|
content: any;
|
|
848
|
+
/** Gets or sets the format of {@link content} (e.g. `"obj"`, `"fbx"`, or `"native"` for an adapter-specific object). */
|
|
654
849
|
type: string | "obj" | "fbx" | "native";
|
|
655
850
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
656
851
|
}
|
|
657
852
|
|
|
853
|
+
/** `<pacem-3d-orthographic-camera>`: a {@link Pacem3DCameraElement} that projects the scene through a fixed, non-diminishing (parallel) frustum, defined by the {@link top}/{@link left}/{@link bottom}/{@link right} coordinates. */
|
|
658
854
|
declare class Pacem3DOrthographicCameraElement extends Pacem3DCameraElement implements OrthographicCamera {
|
|
855
|
+
/** Gets or sets the top frustum coordinate (e.g. 1). */
|
|
659
856
|
top: number;
|
|
857
|
+
/** Gets or sets the left frustum coordinate (e.g. -1). */
|
|
660
858
|
left: number;
|
|
859
|
+
/** Gets or sets the bottom frustum coordinate (e.g. -1). */
|
|
661
860
|
bottom: number;
|
|
861
|
+
/** Gets or sets the right frustum coordinate (e.g. 1). */
|
|
662
862
|
right: number;
|
|
863
|
+
/** @readonly Gets the camera discriminator: always `"orthographic"`. */
|
|
663
864
|
get type(): "orthographic";
|
|
664
865
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
665
866
|
}
|
|
666
867
|
|
|
868
|
+
/** `<pacem-3d-perspective-camera>`: a {@link Pacem3DCameraElement} that projects the scene through a perspective frustum (vanishing point), defined by {@link fov} and {@link aspect}. */
|
|
667
869
|
declare class Pacem3DPerspectiveCameraElement extends Pacem3DCameraElement implements PerspectiveCamera {
|
|
870
|
+
/** Gets or sets the vertical field of view, in degrees. */
|
|
668
871
|
fov: number;
|
|
872
|
+
/** Gets or sets the viewport width/height ratio. */
|
|
669
873
|
aspect: number;
|
|
874
|
+
/** @readonly Gets the camera discriminator: always `"perspective"`. */
|
|
670
875
|
get type(): "perspective";
|
|
876
|
+
/** @readonly Gets the viewport width/height ratio (alias of {@link aspect}). */
|
|
671
877
|
get aspectRatio(): number;
|
|
672
878
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
673
879
|
}
|
|
674
880
|
|
|
881
|
+
/**
|
|
882
|
+
* Abstract base of the declarative geometric-primitive custom elements — {@link PacemBoxElement}, {@link PacemConeElement},
|
|
883
|
+
* {@link PacemCylinderElement}, {@link PacemLineElement}, {@link PacemPlaneElement}, {@link PacemSphereElement},
|
|
884
|
+
* {@link PacemTorusElement} and the {@link PolyhedronElement} family — that compute a {@link NodeGeometry} out of their
|
|
885
|
+
* own shape parameters, ready to be assigned to a `Pacem3DMeshElement`'s `geometry` property.
|
|
886
|
+
*/
|
|
675
887
|
declare abstract class Pacem3DPrimitiveElement extends PacemEventTarget {
|
|
888
|
+
/** Gets or sets the computed vertex/index data describing the primitive's shape. */
|
|
676
889
|
geometry: NodeGeometry;
|
|
677
890
|
viewActivatedCallback(): void;
|
|
891
|
+
/** Computes the geometry to fall back to when {@link geometry} hasn't been explicitly set. */
|
|
678
892
|
protected abstract createDefaultGeometry(): NodeGeometry;
|
|
679
893
|
}
|
|
680
894
|
|
|
895
|
+
/**
|
|
896
|
+
* `<pacem-3d-three-adapter>`: {@link Pacem3DAdapterElement} rendering backend built on top of the
|
|
897
|
+
* {@link https://threejs.org/ | Three.js}/WebGL library (lazily loaded from a CDN on first use). Translates the
|
|
898
|
+
* {@link RenderableElement} scene graph into `THREE.Object3D`s, renders them with a `THREE.WebGLRenderer` and
|
|
899
|
+
* supports mouse-driven orbit controls via {@link orbit}.
|
|
900
|
+
*/
|
|
681
901
|
declare class Pacem3DThreeAdapterElement extends Pacem3DAdapterElement {
|
|
682
902
|
private _assertMonoStage;
|
|
683
903
|
dispose(scene: Pacem3DElement): void;
|
|
@@ -692,6 +912,7 @@ declare class Pacem3DThreeAdapterElement extends Pacem3DAdapterElement {
|
|
|
692
912
|
private _orbitCtrls;
|
|
693
913
|
private _objects;
|
|
694
914
|
private _dict;
|
|
915
|
+
/** Gets or sets whether mouse-driven orbit controls (`THREE.OrbitControls`) are attached to the active camera. */
|
|
695
916
|
orbit: boolean;
|
|
696
917
|
getScene(scene: Pacem3DElement): any;
|
|
697
918
|
raycast(scene: Pacem3DElement, point: Point, size: Size, callback: (result: RaycastResult) => void): void;
|
|
@@ -711,14 +932,25 @@ declare class Pacem3DThreeAdapterElement extends Pacem3DAdapterElement {
|
|
|
711
932
|
render(): void;
|
|
712
933
|
}
|
|
713
934
|
|
|
935
|
+
/**
|
|
936
|
+
* `<pacem-3d-webgpu-adapter>`: {@link Pacem3DAdapterElement} rendering backend built directly on the browser's
|
|
937
|
+
* WebGPU API. Manages one {@link Renderer} per stage it is assigned to, hosts child {@link Pacem3DWgslScriptElement}
|
|
938
|
+
* shader customizations (via {@link modifiers}), and falls back gracefully (see {@link supported}/{@link active})
|
|
939
|
+
* when WebGPU isn't available.
|
|
940
|
+
*/
|
|
714
941
|
declare class Pacem3DWebgpuAdapterElement extends Pacem3DAdapterElement implements ItemsContainer<Pacem3DWgslScriptElement> {
|
|
715
942
|
#private;
|
|
716
943
|
invalidateSize(stage: Pacem3DElement, size?: Size): void;
|
|
944
|
+
/** @readonly Gets the child {@link Pacem3DWgslScriptElement} shader-customization items currently registered. */
|
|
717
945
|
get items(): Pacem3DWgslScriptElement[];
|
|
946
|
+
/** Registers a child {@link Pacem3DWgslScriptElement}, re-parsing the WGSL {@link modifiers} it contributes. */
|
|
718
947
|
register(item: Pacem3DWgslScriptElement): boolean;
|
|
948
|
+
/** Unregisters a previously-registered {@link Pacem3DWgslScriptElement}, re-parsing the WGSL {@link modifiers} accordingly. */
|
|
719
949
|
unregister(item: Pacem3DWgslScriptElement): boolean;
|
|
720
950
|
private _scriptVersionChangeHandler;
|
|
951
|
+
/** @readonly Gets whether WebGPU is supported by the current browser/device. */
|
|
721
952
|
get supported(): boolean;
|
|
953
|
+
/** @readonly Gets whether the adapter is currently able to render (false once a {@link WebGPUIssue} disables it). */
|
|
722
954
|
get active(): boolean;
|
|
723
955
|
private _webGPUNotSupported;
|
|
724
956
|
initialize(scene: Pacem3DElement): Promise<HTMLCanvasElement | null>;
|
|
@@ -727,7 +959,9 @@ declare class Pacem3DWebgpuAdapterElement extends Pacem3DAdapterElement implemen
|
|
|
727
959
|
disconnectedCallback(): void;
|
|
728
960
|
dispose(scene: Pacem3DElement): void;
|
|
729
961
|
private _reinitialize;
|
|
962
|
+
/** Gets or sets the WGSL snippets (vertex input/output, fragment) spliced into the render pipeline shaders, normally derived from the child {@link Pacem3DWgslScriptElement} items. Reassigning it reinitializes the renderer(s). */
|
|
730
963
|
modifiers: WGSLModifierDelegates;
|
|
964
|
+
/** Gets or sets whether WebGPU API validation is enabled (useful for debugging, at a performance cost). Reassigning it reinitializes the renderer(s). */
|
|
731
965
|
enableValidation: boolean;
|
|
732
966
|
private _ensureRenderer;
|
|
733
967
|
private _updatePipeline;
|
|
@@ -748,11 +982,15 @@ declare class Pacem3DWebgpuAdapterElement extends Pacem3DAdapterElement implemen
|
|
|
748
982
|
getScene(stage: Pacem3DElement): any;
|
|
749
983
|
}
|
|
750
984
|
|
|
985
|
+
/** `<pacem-3d-wgsl-script>`: declares a WGSL snippet (vertex input/output or fragment stage) that a parent {@link Pacem3DWebgpuAdapterElement} splices into its render pipeline shaders, tracked via a content {@link version} hash. */
|
|
751
986
|
declare class Pacem3DWgslScriptElement extends Components_2.PacemItemElement {
|
|
752
987
|
#private;
|
|
753
988
|
protected findContainer(): ItemsContainer<Pacem3DWgslScriptElement>;
|
|
989
|
+
/** @readonly Gets a hash of the current {@link wgsl} content, changing whenever it does. */
|
|
754
990
|
get version(): string;
|
|
991
|
+
/** Gets or sets which pipeline stage this WGSL snippet modifies (e.g. `"vertex-input"`, `"vertex-output"`, `"fragment"`). */
|
|
755
992
|
type: WGSLModifierScriptType;
|
|
993
|
+
/** Gets or sets the WGSL source code, normally mirrored from the element's text content. */
|
|
756
994
|
wgsl: string;
|
|
757
995
|
viewActivatedCallback(): void;
|
|
758
996
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
@@ -760,76 +998,126 @@ declare class Pacem3DWgslScriptElement extends Components_2.PacemItemElement {
|
|
|
760
998
|
disconnectedCallback(): void;
|
|
761
999
|
}
|
|
762
1000
|
|
|
1001
|
+
/** `<pacem-3d-primitive-box>`: computes the {@link MeshGeometry} of a rectangular cuboid (box). */
|
|
763
1002
|
declare class PacemBoxElement extends Pacem3DPrimitiveElement {
|
|
1003
|
+
/** Gets or sets the size along the x axis. */
|
|
764
1004
|
width: number;
|
|
1005
|
+
/** Gets or sets the size along the y axis. */
|
|
765
1006
|
height: number;
|
|
1007
|
+
/** Gets or sets the size along the z axis. */
|
|
766
1008
|
depth: number;
|
|
1009
|
+
/** Gets or sets the number of subdivisions along the width (x axis). */
|
|
767
1010
|
widthSegments: number;
|
|
1011
|
+
/** Gets or sets the number of subdivisions along the height (y axis). */
|
|
768
1012
|
heightSegments: number;
|
|
1013
|
+
/** Gets or sets the number of subdivisions along the depth (z axis). */
|
|
769
1014
|
depthSegments: number;
|
|
1015
|
+
/** Builds the {@link MeshGeometry} of a box with the given size and per-axis segment subdivisions (all default to `1`). */
|
|
770
1016
|
static createMeshGeometry(width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number): MeshGeometry;
|
|
1017
|
+
/** Computes the box geometry from the default (unset) shape parameters. */
|
|
771
1018
|
protected createDefaultGeometry(): MeshGeometry;
|
|
772
1019
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
773
1020
|
}
|
|
774
1021
|
|
|
1022
|
+
/** `<pacem-3d-primitive-cone>`: computes the {@link MeshGeometry} of a cone (a circular base tapering to an apex point). */
|
|
775
1023
|
declare class PacemConeElement extends Pacem3DPrimitiveElement {
|
|
1024
|
+
/** Gets or sets the radius of the circular base. */
|
|
776
1025
|
radius: number;
|
|
1026
|
+
/** Gets or sets the distance from the base to the apex. */
|
|
777
1027
|
height: number;
|
|
1028
|
+
/** Gets or sets the number of straight sides (radial segments) approximating the circular base. */
|
|
778
1029
|
sides: number;
|
|
1030
|
+
/** Gets or sets the number of subdivisions along the lateral surface, from base to apex. */
|
|
779
1031
|
heightSegments: number;
|
|
1032
|
+
/** Gets or sets the number of concentric ring subdivisions of the base cap. */
|
|
780
1033
|
capSegments: number;
|
|
1034
|
+
/** Builds the {@link MeshGeometry} of a cone with the given base radius, height, side count, lateral-surface segments and base-cap segments. */
|
|
781
1035
|
static createMeshGeometry(radius?: number, height?: number, sides?: number, heightSegments?: number, capSegments?: number): MeshGeometry;
|
|
1036
|
+
/** Computes the cone geometry from the default (unset) shape parameters. */
|
|
782
1037
|
protected createDefaultGeometry(): MeshGeometry;
|
|
783
1038
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
784
1039
|
}
|
|
785
1040
|
|
|
1041
|
+
/** `<pacem-3d-primitive-cylinder>`: computes the {@link MeshGeometry} of a cylinder (two parallel circular caps joined by a straight lateral surface). */
|
|
786
1042
|
declare class PacemCylinderElement extends Pacem3DPrimitiveElement {
|
|
1043
|
+
/** Gets or sets the radius of the top and bottom circular caps. */
|
|
787
1044
|
radius: number;
|
|
1045
|
+
/** Gets or sets the distance between the top and bottom caps. */
|
|
788
1046
|
height: number;
|
|
1047
|
+
/** Gets or sets the number of straight sides (radial segments) approximating the circular caps. */
|
|
789
1048
|
sides: number;
|
|
1049
|
+
/** Gets or sets the number of subdivisions along the lateral surface, from bottom to top. */
|
|
790
1050
|
heightSegments: number;
|
|
1051
|
+
/** Gets or sets the number of concentric ring subdivisions of each cap. */
|
|
791
1052
|
capSegments: number;
|
|
1053
|
+
/** Builds the {@link MeshGeometry} of a cylinder with the given radius, height, side count, lateral-surface segments and cap segments. */
|
|
792
1054
|
static createMeshGeometry(radius?: number, height?: number, sides?: number, heightSegments?: number, capSegments?: number): MeshGeometry;
|
|
1055
|
+
/** Computes the cylinder geometry from the default (unset) shape parameters. */
|
|
793
1056
|
protected createDefaultGeometry(): MeshGeometry;
|
|
794
1057
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
795
1058
|
}
|
|
796
1059
|
|
|
1060
|
+
/** `<pacem-3d-primitive-dodecahedron>`: computes the {@link MeshGeometry} of a regular dodecahedron (a Platonic solid with 12 pentagonal faces). */
|
|
797
1061
|
declare class PacemDodecahedronElement extends PolyhedronElement {
|
|
1062
|
+
/** Builds the {@link MeshGeometry} of a dodecahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
798
1063
|
static createMeshGeometry(radius?: number): MeshGeometry;
|
|
799
1064
|
protected createMeshGeometry(radius?: number): MeshGeometry;
|
|
800
1065
|
}
|
|
801
1066
|
|
|
1067
|
+
/** `<pacem-3d-primitive-hexahedron>`: computes the {@link MeshGeometry} of a regular hexahedron (a Platonic solid with 6 square faces, i.e. a cube). */
|
|
802
1068
|
declare class PacemHexahedronElement extends PolyhedronElement {
|
|
1069
|
+
/** Builds the {@link MeshGeometry} of a cube inscribed in a sphere of the given radius (defaults to `1`), as an equal-sided {@link PacemBoxElement}. */
|
|
803
1070
|
static createMeshGeometry(radius?: number): MeshGeometry;
|
|
804
1071
|
protected createMeshGeometry(radius?: number): MeshGeometry;
|
|
805
1072
|
}
|
|
806
1073
|
|
|
1074
|
+
/** `<pacem-3d-primitive-icosahedron>`: computes the {@link MeshGeometry} of a regular icosahedron (a Platonic solid with 20 triangular faces). */
|
|
807
1075
|
declare class PacemIcosahedronElement extends PolyhedronElement {
|
|
1076
|
+
/** Builds the {@link MeshGeometry} of an icosahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
808
1077
|
static createMeshGeometry(radius?: number): MeshGeometry;
|
|
809
1078
|
protected createMeshGeometry(radius?: number): MeshGeometry;
|
|
810
1079
|
}
|
|
811
1080
|
|
|
1081
|
+
/** `<pacem-3d-primitive-line>`: computes the {@link LineGeometry} of a polyline connecting a sequence of points. */
|
|
812
1082
|
declare class PacemLineElement extends Pacem3DPrimitiveElement {
|
|
1083
|
+
/** Gets or sets the ordered vertices of the polyline, in local space. */
|
|
813
1084
|
positions: Vector3D[];
|
|
1085
|
+
/** Builds the {@link LineGeometry} out of the given vertices (a single segment from `(0,0,0)` to `(0,1,0)` when omitted). */
|
|
814
1086
|
static createLineGeometry(positions?: Vector3D[]): LineGeometry;
|
|
1087
|
+
/** Computes the line geometry from the default (unset) vertex positions. */
|
|
815
1088
|
protected createDefaultGeometry(): LineGeometry;
|
|
816
1089
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
817
1090
|
}
|
|
818
1091
|
|
|
1092
|
+
/** `<pacem-3d-primitive-octahedron>`: computes the {@link MeshGeometry} of a regular octahedron (a Platonic solid with 8 triangular faces). */
|
|
819
1093
|
declare class PacemOctahedronElement extends PolyhedronElement {
|
|
1094
|
+
/** Builds the {@link MeshGeometry} of an octahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
820
1095
|
static createMeshGeometry(radius?: number): MeshGeometry;
|
|
821
1096
|
protected createMeshGeometry(radius?: number): MeshGeometry;
|
|
822
1097
|
}
|
|
823
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* `<pacem-3d-orbit-camera>`: a behavior element that, applied to a {@link Pacem3DCameraElement}, attaches pointer/wheel
|
|
1101
|
+
* driven orbit (rotate/pan/zoom around a target) interaction by instantiating and configuring an
|
|
1102
|
+
* {@link OrbitCameraBehavior} for each decorated element.
|
|
1103
|
+
*/
|
|
824
1104
|
declare class PacemOrbitCameraBehaviorElement extends Behaviors.PacemBehavior {
|
|
825
1105
|
#private;
|
|
1106
|
+
/** Gets or sets the maximum azimuth (horizontal orbit) angle, in degrees. */
|
|
826
1107
|
maxAzimuth: number;
|
|
1108
|
+
/** Gets or sets the maximum polar (vertical orbit) angle, in degrees. */
|
|
827
1109
|
maxPolar: number;
|
|
1110
|
+
/** Gets or sets the minimum azimuth (horizontal orbit) angle, in degrees. */
|
|
828
1111
|
minAzimuth: number;
|
|
1112
|
+
/** Gets or sets the minimum polar (vertical orbit) angle, in degrees. */
|
|
829
1113
|
minPolar: number;
|
|
1114
|
+
/** Gets or sets the pointer button/modifier configuration enabling zoom (mouse wheel). */
|
|
830
1115
|
zoomControl: OrbitCameraControl;
|
|
1116
|
+
/** Gets or sets the pointer button/modifier configuration enabling rotation. */
|
|
831
1117
|
rotationControl: OrbitCameraControl;
|
|
1118
|
+
/** Gets or sets the pointer button/modifier configuration enabling panning. */
|
|
832
1119
|
panControl: OrbitCameraControl;
|
|
1120
|
+
/** Gets or sets whether (and how strongly) orbit movements ease out with inertia instead of stopping immediately; `true` uses the default friction factor, a `number` sets a custom one, `false` disables inertia. */
|
|
833
1121
|
inertia: boolean | number;
|
|
834
1122
|
private _readyHandler;
|
|
835
1123
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
@@ -840,124 +1128,195 @@ declare class PacemOrbitCameraBehaviorElement extends Behaviors.PacemBehavior {
|
|
|
840
1128
|
protected undecorate(element: Element): void;
|
|
841
1129
|
}
|
|
842
1130
|
|
|
1131
|
+
/** `<pacem-3d-primitive-plane>`: computes the {@link MeshGeometry} of a flat rectangular surface lying on the xz plane. */
|
|
843
1132
|
declare class PacemPlaneElement extends Pacem3DPrimitiveElement {
|
|
1133
|
+
/** Gets or sets the size along the x axis. */
|
|
844
1134
|
width: number;
|
|
1135
|
+
/** Gets or sets the size along the z axis. */
|
|
845
1136
|
length: number;
|
|
1137
|
+
/** Gets or sets the number of subdivisions along the width (x axis). */
|
|
846
1138
|
widthSegments: number;
|
|
1139
|
+
/** Gets or sets the number of subdivisions along the length (z axis). */
|
|
847
1140
|
lengthSegments: number;
|
|
1141
|
+
/** Builds the {@link MeshGeometry} of a flat rectangle with the given width, length and per-axis segment subdivisions (defaulting to `1`x`1`, 4 segments each way). */
|
|
848
1142
|
static createMeshGeometry(width?: number, length?: number, widthSegments?: number, lengthSegments?: number): MeshGeometry;
|
|
1143
|
+
/** Computes the plane geometry from the default (unset) shape parameters. */
|
|
849
1144
|
protected createDefaultGeometry(): MeshGeometry;
|
|
850
1145
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
851
1146
|
}
|
|
852
1147
|
|
|
1148
|
+
/** `<pacem-3d-primitive-sphere>`: computes the {@link MeshGeometry} of a UV sphere. */
|
|
853
1149
|
declare class PacemSphereElement extends Pacem3DPrimitiveElement {
|
|
1150
|
+
/** Gets or sets the radius. */
|
|
854
1151
|
radius: number;
|
|
1152
|
+
/** Gets or sets the tessellation: the number of longitude divisions (and, derived from it, the latitude bands) around the sphere. */
|
|
855
1153
|
segments: number;
|
|
1154
|
+
/** Builds the {@link MeshGeometry} of a sphere with the given radius (defaults to `1`) and tessellation (defaults to `8`). */
|
|
856
1155
|
static createMeshGeometry(radius?: number, segs?: number): MeshGeometry;
|
|
1156
|
+
/** Computes the sphere geometry from the default (unset) shape parameters. */
|
|
857
1157
|
protected createDefaultGeometry(): MeshGeometry;
|
|
858
1158
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
859
1159
|
}
|
|
860
1160
|
|
|
1161
|
+
/** `<pacem-3d-primitive-tetrahedron>`: computes the {@link MeshGeometry} of a regular tetrahedron (a Platonic solid with 4 triangular faces). */
|
|
861
1162
|
declare class PacemTetrahedronElement extends PolyhedronElement {
|
|
1163
|
+
/** Builds the {@link MeshGeometry} of a tetrahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
862
1164
|
static createMeshGeometry(radius?: number): MeshGeometry;
|
|
863
1165
|
protected createMeshGeometry(radius?: number): MeshGeometry;
|
|
864
1166
|
}
|
|
865
1167
|
|
|
1168
|
+
/** `<pacem-3d-primitive-torus>`: computes the {@link MeshGeometry} of a torus (donut shape): a tube revolved around a central axis. */
|
|
866
1169
|
declare class PacemTorusElement extends Pacem3DPrimitiveElement {
|
|
1170
|
+
/** Gets or sets the outer radius: the distance from the torus' center to the center of the tube. */
|
|
867
1171
|
radius: number;
|
|
1172
|
+
/** Gets or sets the inner (tube) radius: the thickness of the revolved tube. */
|
|
868
1173
|
innerRadius: number;
|
|
1174
|
+
/** Gets or sets the number of radial segments around the main ring. */
|
|
869
1175
|
segments: number;
|
|
1176
|
+
/** Gets or sets the number of segments around the tube's circular cross-section. */
|
|
870
1177
|
sides: number;
|
|
1178
|
+
/** Builds the {@link MeshGeometry} of a torus with the given outer/inner radii and ring/tube segment counts. */
|
|
871
1179
|
static createMeshGeometry(radius?: number, innerRadius?: number, segments?: number, sides?: number): MeshGeometry;
|
|
1180
|
+
/** Computes the torus geometry from the default (unset) shape parameters. */
|
|
872
1181
|
protected createDefaultGeometry(): MeshGeometry;
|
|
873
1182
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
874
1183
|
}
|
|
875
1184
|
|
|
1185
|
+
/** A {@link Camera} that projects the scene with a perspective frustum (vanishing point), as produced by {@link Pacem3DPerspectiveCameraElement}. */
|
|
876
1186
|
declare interface PerspectiveCamera extends Camera {
|
|
877
1187
|
type: "perspective";
|
|
878
1188
|
/** Vertical field of view in degrees. */
|
|
879
1189
|
fov: number;
|
|
1190
|
+
/** Viewport width/height ratio. */
|
|
880
1191
|
aspectRatio: number;
|
|
881
1192
|
}
|
|
882
1193
|
|
|
1194
|
+
/** A {@link SpecularMaterial} using the Phong shading model: diffuse reflection plus a specular highlight of adjustable {@link SpecularMaterial.shininess}. */
|
|
883
1195
|
declare interface PhongMaterial extends SpecularMaterial {
|
|
884
1196
|
readonly shader: KnownShader.Phong;
|
|
885
1197
|
}
|
|
886
1198
|
|
|
1199
|
+
/** `<pacem-3d-material-phong>`: produces a {@link PhongMaterial} (Phong shading model): diffuse reflection plus a specular highlight of adjustable shininess. */
|
|
887
1200
|
declare class PhongMaterialElement extends MaterialElement {
|
|
888
1201
|
constructor();
|
|
1202
|
+
/** Builds the {@link PhongMaterial}, adding the diffuse (`emissiveColor`, `reflectivity`, `refractionRatio`) and specular (`specularColor`, `shininess`, `flatShading`) properties to the base {@link Material}. */
|
|
889
1203
|
protected createMaterial(): Promise<PhongMaterial>;
|
|
890
1204
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
1205
|
+
/** Gets or sets the diffuse color (albedo). */
|
|
891
1206
|
emissiveColor: string;
|
|
1207
|
+
/** Gets or sets the percentage of reflected light. */
|
|
892
1208
|
reflectivity: number;
|
|
1209
|
+
/** Gets or sets the index of refraction. */
|
|
893
1210
|
refractionRatio: number;
|
|
1211
|
+
/** Gets or sets the specular color, defining the color of reflections/highlights. */
|
|
894
1212
|
specularColor: string;
|
|
1213
|
+
/** Gets or sets the specular exponent (glossiness): higher values produce smaller, sharper highlights. */
|
|
895
1214
|
shininess: number;
|
|
1215
|
+
/** Gets or sets whether each face is rendered as flat (faceted) rather than smoothly interpolated. */
|
|
896
1216
|
flatShading: boolean;
|
|
897
1217
|
}
|
|
898
1218
|
|
|
1219
|
+
/** Converts a `"x y z"` attribute string to/from a {@link Vector3D}. */
|
|
899
1220
|
declare const Point3DConverter: PropertyConverter;
|
|
900
1221
|
|
|
1222
|
+
/** Converts a `"x y z"` (3 components) or `"n"` (single uniform component, broadcast to all 3 axes) attribute string to/from a {@link Vector3D}. Used e.g. for `scale`/`offset`. */
|
|
901
1223
|
declare const Point3DOrNumberConverter: PropertyConverter;
|
|
902
1224
|
|
|
903
1225
|
declare type PointerEventLike = MouseEvent | PointerEvent | TouchEvent;
|
|
904
1226
|
|
|
1227
|
+
/**
|
|
1228
|
+
* Abstract base of the regular-polyhedron (Platonic solid) primitive custom elements — {@link PacemTetrahedronElement},
|
|
1229
|
+
* {@link PacemOctahedronElement}, {@link PacemHexahedronElement}, {@link PacemIcosahedronElement} and
|
|
1230
|
+
* {@link PacemDodecahedronElement} — each computing the {@link MeshGeometry} of a solid inscribed in a sphere of the
|
|
1231
|
+
* given {@link radius}.
|
|
1232
|
+
*/
|
|
905
1233
|
declare abstract class PolyhedronElement extends Pacem3DPrimitiveElement {
|
|
1234
|
+
/** Gets or sets the radius of the sphere the polyhedron's vertices lie on. */
|
|
906
1235
|
radius: number;
|
|
907
1236
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
908
1237
|
private _assignMeshGeometry;
|
|
1238
|
+
/** Computes the polyhedron geometry using a radius of `1` when {@link radius} hasn't been explicitly set. */
|
|
909
1239
|
protected createDefaultGeometry(): MeshGeometry;
|
|
1240
|
+
/** Computes the {@link MeshGeometry} of the polyhedron with the given radius. */
|
|
910
1241
|
protected abstract createMeshGeometry(radius: number): MeshGeometry;
|
|
911
1242
|
}
|
|
912
1243
|
|
|
1244
|
+
/** A rotation expressed as a unit quaternion. */
|
|
913
1245
|
declare type Quaternion = Geometry.LinearAlgebra.Quaternion;
|
|
914
1246
|
|
|
1247
|
+
/** Converts a `"x y z w"` attribute string to/from a {@link Quaternion}. Used e.g. for `rotate`. */
|
|
915
1248
|
declare const QuaternionConverter: PropertyConverter;
|
|
916
1249
|
|
|
1250
|
+
/** Result of a {@link Pacem3DAdapterElement.raycast} hit-test: the hit {@link Renderable} object and the world-space point of intersection. */
|
|
917
1251
|
declare type RaycastResult = {
|
|
918
1252
|
object: Renderable;
|
|
919
1253
|
point: Vector3D;
|
|
920
1254
|
};
|
|
921
1255
|
|
|
1256
|
+
/** Base contract of any object that can be part of the scene graph and rendered on a {@link Stage}. */
|
|
922
1257
|
declare interface Renderable {
|
|
1258
|
+
/** Gets or sets the {@link Stage} this renderable is attached to. */
|
|
923
1259
|
stage?: Stage;
|
|
1260
|
+
/** Gets or sets the object's position in 3d world (or parent-local) space. */
|
|
924
1261
|
position: Vector3D;
|
|
925
1262
|
/** Gets or sets whether the drawable is hit-testable. */
|
|
926
1263
|
inert?: boolean;
|
|
1264
|
+
/** Gets or sets whether the object is hidden (excluded from rendering, but still part of the scene graph). */
|
|
927
1265
|
hide?: boolean;
|
|
1266
|
+
/** Gets or sets an arbitrary user payload attached to the object. */
|
|
928
1267
|
tag?: any;
|
|
1268
|
+
/** Gets the list of {@link StalePropertyFlag}s accumulated since the object was last rendered/updated by the adapter. */
|
|
929
1269
|
flags: StalePropertyFlag[];
|
|
1270
|
+
/** Gets or sets an identity key, used by adapters/renderers to track the object across updates. */
|
|
930
1271
|
key?: string;
|
|
931
1272
|
/** @deprecated will be likely removed sooner or later to be handled outside the stage/adapter. */
|
|
932
1273
|
draggable?: boolean;
|
|
933
1274
|
}
|
|
934
1275
|
|
|
1276
|
+
/**
|
|
1277
|
+
* Abstract base of every scene-graph custom element usable inside a {@link Pacem3DElement} stage (groups, meshes,
|
|
1278
|
+
* native objects, lights, cameras). Implements {@link Renderable}, wires the element into the ancestor stage/parent
|
|
1279
|
+
* chain, and tracks which aspects of the object are stale (via {@link StalePropertyFlag}) so the active
|
|
1280
|
+
* {@link Pacem3DAdapterElement} can update only what changed on the next render.
|
|
1281
|
+
*/
|
|
935
1282
|
declare abstract class RenderableElement extends Components_2.PacemCrossItemsContainerElement<RenderableElement> implements Renderable {
|
|
936
1283
|
#private;
|
|
1284
|
+
/** When implemented in a derived class (e.g. {@link Pacem3DGroupElement}), determines whether `_` may be nested under this element. Denies any child by default. */
|
|
937
1285
|
validate(_: RenderableElement): boolean;
|
|
938
1286
|
protected findContainer(): Pacem3DElement | RenderableElement;
|
|
1287
|
+
/** @readonly Gets the ancestor {@link Pacem3DElement} stage this element belongs to. */
|
|
939
1288
|
get stage(): Pacem3DElement;
|
|
1289
|
+
/** @readonly Gets the closest ancestor {@link RenderableElement} (e.g. the containing group), if any. */
|
|
940
1290
|
get parent(): RenderableElement;
|
|
1291
|
+
/** Gets or sets the element's position, in 3d world (or parent-local) space. */
|
|
941
1292
|
position: Vector3D;
|
|
1293
|
+
/** Gets or sets an arbitrary user payload attached to the element. */
|
|
942
1294
|
tag: string;
|
|
1295
|
+
/** Gets or sets whether the element is excluded from hit-testing/raycasting. */
|
|
943
1296
|
inert: boolean;
|
|
944
1297
|
disconnectedCallback(): void;
|
|
945
1298
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
1299
|
+
/** @readonly Gets the list of {@link StalePropertyFlag}s accumulated since the element was last rendered/updated by the adapter. */
|
|
946
1300
|
get flags(): StalePropertyFlag[];
|
|
947
1301
|
/** Calls for a redraw of the current element in the next rendering process. */
|
|
948
1302
|
protected setAsDirty(...flags: StalePropertyFlag[]): void;
|
|
949
1303
|
}
|
|
950
1304
|
|
|
1305
|
+
/** Event dispatched for pointer interactions (click/over/out/down/up) with a {@link Renderable} item, carrying the item itself as its `detail`. */
|
|
951
1306
|
declare class RenderableEvent extends UI3DEvent<Renderable> {
|
|
952
1307
|
constructor(type: string, args: Renderable, originalEvent: MouseEvent | TouchEvent | KeyboardEvent, p: Vector3D);
|
|
953
1308
|
}
|
|
954
1309
|
|
|
1310
|
+
/** A {@link Material} rendered by a user-supplied GLSL vertex/fragment shader pair, bypassing the built-in shading models. */
|
|
955
1311
|
declare interface ShaderMaterial extends Material {
|
|
956
1312
|
readonly shader: KnownShader.Custom;
|
|
1313
|
+
/** Gets or sets the GLSL source of the vertex shader. */
|
|
957
1314
|
vertexShader?: string;
|
|
1315
|
+
/** Gets or sets the GLSL source of the fragment shader. */
|
|
958
1316
|
fragmentShader?: string;
|
|
959
1317
|
}
|
|
960
1318
|
|
|
1319
|
+
/** A {@link DiffuseMaterial} that additionally models specular (glossy) highlights. */
|
|
961
1320
|
declare interface SpecularMaterial extends DiffuseMaterial {
|
|
962
1321
|
/** Specular color, defines the color of reflections. */
|
|
963
1322
|
specularColor?: string;
|
|
@@ -965,53 +1324,88 @@ declare interface SpecularMaterial extends DiffuseMaterial {
|
|
|
965
1324
|
shininess?: number;
|
|
966
1325
|
}
|
|
967
1326
|
|
|
1327
|
+
/** Bounding sphere in 3d world space. */
|
|
968
1328
|
declare interface Sphere3D {
|
|
969
1329
|
center: Vector3D;
|
|
970
1330
|
radius: number;
|
|
971
1331
|
}
|
|
972
1332
|
|
|
1333
|
+
/** Contract of the `<pacem-3d>` stage (see {@link Pacem3DElement}) as seen by adapters and renderables: the DOM/native surface, its size, and the entry point to trigger a (partial) render. */
|
|
973
1334
|
declare interface Stage extends EventTarget {
|
|
1335
|
+
/** Renders the whole scene, or just the given item if provided. */
|
|
974
1336
|
render(item?: Renderable): any;
|
|
1337
|
+
/** Gets the DOM element the scene is mounted into. */
|
|
975
1338
|
readonly stage: HTMLElement;
|
|
1339
|
+
/** Gets the technology-dependent native scene instance (e.g. a `THREE.Scene`), as returned by the active {@link Pacem3DAdapterElement}. */
|
|
976
1340
|
readonly scene: any;
|
|
1341
|
+
/** Gets the current viewport size. */
|
|
977
1342
|
readonly size: Size;
|
|
1343
|
+
/** Gets or sets whether the stage background should be transparent. */
|
|
978
1344
|
transparent?: boolean;
|
|
1345
|
+
/** Gets or sets the stage background color. */
|
|
979
1346
|
background?: string | Rgba;
|
|
980
1347
|
}
|
|
981
1348
|
|
|
1349
|
+
/** Identifies which aspect of a {@link Renderable} changed since the last render, so the adapter can update only the stale part of the underlying native object. */
|
|
982
1350
|
declare enum StalePropertyFlag {
|
|
1351
|
+
/** The object's {@link Renderable.position} changed. */
|
|
983
1352
|
Position = "position",
|
|
1353
|
+
/** The object's {@link Ui3DObject.transformMatrix} (rotate/scale/offset) changed. */
|
|
984
1354
|
Transform = "transform",
|
|
1355
|
+
/** The mesh/line {@link NodeGeometry} changed. */
|
|
985
1356
|
Geometry = "geometry",
|
|
1357
|
+
/** The group's child collection changed. */
|
|
986
1358
|
Children = "children",
|
|
1359
|
+
/** The mesh's {@link Material}/{@link Mesh.backMaterial} changed. */
|
|
987
1360
|
Material = "material",
|
|
1361
|
+
/** A {@link Light}-specific property (color, intensity, target, ...) changed. */
|
|
988
1362
|
Light = "light",
|
|
1363
|
+
/** A {@link Camera}-specific property (near, far, fov, frustum, ...) changed. */
|
|
989
1364
|
Camera = "camera",
|
|
1365
|
+
/** The object's {@link Renderable.hide} visibility changed. */
|
|
990
1366
|
Visibility = "visibility"
|
|
991
1367
|
}
|
|
992
1368
|
|
|
1369
|
+
/** A {@link DiffuseMaterial} using a physically-based (metalness/roughness) shading model. */
|
|
993
1370
|
declare interface StandardMaterial extends DiffuseMaterial {
|
|
994
1371
|
readonly shader: KnownShader.Phong;
|
|
1372
|
+
/** Surface roughness, from `0` (mirror-smooth) to `1` (fully matte), controlling how spread-out specular highlights are. */
|
|
995
1373
|
roughness?: number;
|
|
1374
|
+
/** How metallic the surface is, from `0` (dielectric) to `1` (fully metallic), controlling how much of {@link DiffuseMaterial.emissiveColor} tints reflections. */
|
|
996
1375
|
metalness?: number;
|
|
997
1376
|
/** Percentage of reflected light at grazing angles. */
|
|
998
1377
|
fresnel?: number;
|
|
999
1378
|
}
|
|
1000
1379
|
|
|
1380
|
+
/** `<pacem-3d-material-standard>`: produces a {@link StandardMaterial} using a physically-based (metalness/roughness) shading model. */
|
|
1001
1381
|
declare class StandardMaterialElement extends MaterialElement {
|
|
1002
1382
|
constructor();
|
|
1383
|
+
/** Builds the {@link StandardMaterial}, adding `emissiveColor`, `refractionRatio`, `metalness`, `roughness` and `flatShading` to the base {@link Material}. */
|
|
1003
1384
|
protected createMaterial(): Promise<PhongMaterial>;
|
|
1004
1385
|
propertyChangedCallback(name: string, old: any, val: any, first?: boolean): void;
|
|
1386
|
+
/** Gets or sets the diffuse color (albedo). */
|
|
1005
1387
|
emissiveColor: string;
|
|
1388
|
+
/** Gets or sets the index of refraction. */
|
|
1006
1389
|
refractionRatio: number;
|
|
1390
|
+
/** Gets or sets the surface roughness, from `0` (mirror-smooth) to `1` (fully matte). */
|
|
1007
1391
|
roughness: number;
|
|
1392
|
+
/** Gets or sets how metallic the surface is, from `0` (dielectric) to `1` (fully metallic). */
|
|
1008
1393
|
metalness: number;
|
|
1394
|
+
/** Gets or sets whether each face is rendered as flat (faceted) rather than smoothly interpolated. */
|
|
1009
1395
|
flatShading: boolean;
|
|
1010
1396
|
}
|
|
1011
1397
|
|
|
1398
|
+
/**
|
|
1399
|
+
* Abstract base of every {@link RenderableElement} that also carries an affine 3d transform (rotate/scale/offset,
|
|
1400
|
+
* combined into {@link transformMatrix}). Extended by {@link Pacem3DGroupElement}, {@link Pacem3DMeshElement} and
|
|
1401
|
+
* {@link Pacem3DObjectElement}.
|
|
1402
|
+
*/
|
|
1012
1403
|
declare abstract class Ui3DElement extends RenderableElement implements Ui3DObject {
|
|
1404
|
+
/** Gets or sets the element's rotation, as a quaternion. */
|
|
1013
1405
|
rotate: Geometry.LinearAlgebra.Quaternion;
|
|
1406
|
+
/** Gets or sets the element's scale, per axis (or a single number for uniform scaling). */
|
|
1014
1407
|
scale: Geometry.LinearAlgebra.Point3D;
|
|
1408
|
+
/** Gets or sets the element's translation offset, applied on top of {@link RenderableElement.position}. */
|
|
1015
1409
|
offset: Geometry.LinearAlgebra.Point3D;
|
|
1016
1410
|
/** Gets the local transform 3D matrix (4x4). */
|
|
1017
1411
|
transformMatrix: Geometry.LinearAlgebra.Matrix3D;
|
|
@@ -1031,6 +1425,7 @@ declare abstract class Ui3DElement extends RenderableElement implements Ui3DObje
|
|
|
1031
1425
|
private _computeTransformMatrix;
|
|
1032
1426
|
}
|
|
1033
1427
|
|
|
1428
|
+
/** Base class for the custom UI events dispatched by 3d elements/the stage, carrying the source pointer's projected {@link point} in 3d world space alongside the original DOM event. */
|
|
1034
1429
|
declare abstract class UI3DEvent<T> extends CustomUIEvent<T> {
|
|
1035
1430
|
#private;
|
|
1036
1431
|
constructor(type: string, eventInit: CustomEventInit<T>, originalEvent: MouseEvent | TouchEvent | KeyboardEvent, point: Vector3D);
|
|
@@ -1038,10 +1433,15 @@ declare abstract class UI3DEvent<T> extends CustomUIEvent<T> {
|
|
|
1038
1433
|
get point(): Vector3D;
|
|
1039
1434
|
}
|
|
1040
1435
|
|
|
1436
|
+
/** A {@link Renderable} that also has an affine 3d transform (rotation, scale, translation) and a bounding volume. */
|
|
1041
1437
|
declare interface Ui3DObject extends Renderable {
|
|
1438
|
+
/** Gets or sets the object's rotation. */
|
|
1042
1439
|
rotate?: Quaternion;
|
|
1440
|
+
/** Gets or sets the object's scale, per axis. */
|
|
1043
1441
|
scale?: Vector3D;
|
|
1442
|
+
/** Gets or sets the object's translation offset, applied on top of {@link Renderable.position}. */
|
|
1044
1443
|
offset?: Vector3D;
|
|
1444
|
+
/** Gets or sets the composed local transform (scale, rotation, offset) matrix. */
|
|
1045
1445
|
transformMatrix: Matrix3D;
|
|
1046
1446
|
/** Gets the plain (untransformed via {@link transformMatrix}) bounding sphere. */
|
|
1047
1447
|
readonly boundingSphere?: Sphere3D;
|
|
@@ -1049,20 +1449,30 @@ declare interface Ui3DObject extends Renderable {
|
|
|
1049
1449
|
readonly boundingBox?: Box3D;
|
|
1050
1450
|
}
|
|
1051
1451
|
|
|
1452
|
+
/** Per-vertex texture (u, v) coordinates, one {@link Point} per vertex. */
|
|
1052
1453
|
declare type UVMap = Point[];
|
|
1053
1454
|
|
|
1455
|
+
/** A point/displacement in 3d world space, as `{x, y, z}`. */
|
|
1054
1456
|
declare type Vector3D = Geometry.LinearAlgebra.Vector3D;
|
|
1055
1457
|
|
|
1056
1458
|
declare type Vector3D_2 = Geometry.LinearAlgebra.Vector3D;
|
|
1057
1459
|
|
|
1460
|
+
/** User-supplied callback (see {@link WGSLModifierDelegates.vertexInput}) that returns extra WGSL statements to splice into the vertex-input stage. */
|
|
1058
1461
|
declare type VertexInputModifierDelegate = (...args: VertexInputModifierDelegateArgs) => string;
|
|
1059
1462
|
|
|
1463
|
+
/** Tuple of WGSL identifiers passed to a {@link VertexInputModifierDelegate}: the name of the `VertexInput`-struct variable and of the interaction-data uniform, so custom snippets can reference them. */
|
|
1060
1464
|
declare type VertexInputModifierDelegateArgs = [vertexInputRef: string, interactionDataRef: string];
|
|
1061
1465
|
|
|
1466
|
+
/** User-supplied callback (see {@link WGSLModifierDelegates.vertexOutput}) that returns extra WGSL statements to splice into the vertex-output stage. */
|
|
1062
1467
|
declare type VertexOutputModifierDelegate = (...args: VertexOutputModifierDelegateArgs) => string;
|
|
1063
1468
|
|
|
1469
|
+
/** Tuple of WGSL identifiers passed to a {@link VertexOutputModifierDelegate}: the name of the `VertexOutput`-struct variable and of the interaction-data uniform, so custom snippets can reference them. */
|
|
1064
1470
|
declare type VertexOutputModifierDelegateArgs = [vertexOutputRef: string, interactionDataRef: string];
|
|
1065
1471
|
|
|
1472
|
+
/**
|
|
1473
|
+
* User-authored WGSL customizations spliced into the generated shaders (see {@link Pacem3DWebgpuAdapterElement.modifiers}), either as raw
|
|
1474
|
+
* WGSL source strings or as delegate callbacks. `version` is a content hash used to invalidate cached pipelines when the customization changes.
|
|
1475
|
+
*/
|
|
1066
1476
|
declare type WGSLModifierDelegates = {
|
|
1067
1477
|
vertexInput?: string | VertexInputModifierDelegate;
|
|
1068
1478
|
vertexOutput?: string | VertexOutputModifierDelegate;
|
|
@@ -1070,6 +1480,7 @@ declare type WGSLModifierDelegates = {
|
|
|
1070
1480
|
version?: string;
|
|
1071
1481
|
};
|
|
1072
1482
|
|
|
1483
|
+
/** Which pipeline stage a {@link Pacem3DWgslScriptElement}/{@link WGSLModifierDelegates} snippet customizes. */
|
|
1073
1484
|
declare type WGSLModifierScriptType = 'vertex-input' | 'vertex-output' | 'fragment';
|
|
1074
1485
|
|
|
1075
1486
|
|