@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/dist/esm/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
/** Middle segment shared by every custom element tag name in this package (e.g. `pacem-3d`, `pacem-3d-mesh`). */
|
|
6
7
|
export const TAG_MIDDLE_NAME = "3d";
|
|
8
|
+
/** Conversion factor from degrees to radians. */
|
|
7
9
|
export const DEG2RAD = Math.PI / 180;
|
package/dist/esm/converters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -7,10 +7,12 @@ import { Utils } from '@pacem/pacem-core';
|
|
|
7
7
|
import { parseAsNumericalArray } from '@pacem/pacem-foundation';
|
|
8
8
|
import { Geometry } from '@pacem/pacem-numerical';
|
|
9
9
|
//namespace Pacem.Drawing3D {
|
|
10
|
+
/** Converts a `"x y z"` attribute string to/from a {@link Vector3D}. */
|
|
10
11
|
export const Point3DConverter = {
|
|
11
12
|
convert: (attr) => Geometry.LinearAlgebra.Vector3D.parse(attr),
|
|
12
13
|
convertBack: (prop) => `${prop.x || 0} ${prop.y || 0} ${prop.z || 0}`
|
|
13
14
|
};
|
|
15
|
+
/** 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`. */
|
|
14
16
|
export const Point3DOrNumberConverter = {
|
|
15
17
|
convert: (attr) => {
|
|
16
18
|
const arr = parseAsNumericalArray(attr);
|
|
@@ -29,10 +31,12 @@ export const Point3DOrNumberConverter = {
|
|
|
29
31
|
},
|
|
30
32
|
convertBack: (prop) => `${prop.x || 0} ${prop.y || 0} ${prop.z || 0}`
|
|
31
33
|
};
|
|
34
|
+
/** Converts a `"x y z w"` attribute string to/from a {@link Quaternion}. Used e.g. for `rotate`. */
|
|
32
35
|
export const QuaternionConverter = {
|
|
33
36
|
convert: (attr) => Geometry.LinearAlgebra.Quaternion.parse(attr),
|
|
34
37
|
convertBack: (prop) => `${prop.x || 0} ${prop.y || 0} ${prop.z || 0} ${prop.w || 0}`
|
|
35
38
|
};
|
|
39
|
+
/** Converts an attribute string to/from either a `boolean` (`"true"`/`"false"`) or a `number`. */
|
|
36
40
|
export const BooleanOrNumberConverter = {
|
|
37
41
|
convert: (attr) => {
|
|
38
42
|
if (attr === 'true')
|
package/dist/esm/decorators.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Utils } from '@pacem/pacem-core';
|
|
7
7
|
//namespace Pacem.Drawing3D {
|
|
8
|
+
/**
|
|
9
|
+
* Property decorator factory that turns the decorated field into an accessor backed by a private field, invoking
|
|
10
|
+
* `callback` with the property name and old/new values whenever it is set to a different value. Used by
|
|
11
|
+
* {@link NodeGeometry}/{@link LineGeometry}/{@link MeshGeometry} to flag themselves as dirty ({@link StalePropertyFlag.Geometry})
|
|
12
|
+
* whenever their vertex data changes.
|
|
13
|
+
* @param callback Invoked (with `this` bound to the decorated instance) on every effective change of the property.
|
|
14
|
+
*/
|
|
8
15
|
export function NotifyChange(callback) {
|
|
9
16
|
return (target, prop, descriptor) => {
|
|
10
17
|
const backingField = `_${prop}_${Utils.uniqueCode()}_backingField`;
|
package/dist/esm/detector.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
//namespace Pacem.Components.Drawing3D {
|
|
7
7
|
/** @deprecated*/
|
|
8
8
|
export class Pacem3DDetector {
|
|
9
|
+
/** Probes the browser for WebGL support by attempting to create a rendering context, populating {@link info} and {@link supported}. */
|
|
9
10
|
constructor() {
|
|
10
11
|
this._detected = {
|
|
11
12
|
supported: false, info: {}
|
|
@@ -69,9 +70,11 @@ export class Pacem3DDetector {
|
|
|
69
70
|
addLine('misc', 'Supported Extensions', ctx.getSupportedExtensions() || []);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
/** @readonly Gets the detected WebGL capabilities/limits, grouped by section (`main`, `bits`, `shader`, `tex`, `misc`). */
|
|
72
74
|
get info() {
|
|
73
75
|
return this._detected.info;
|
|
74
76
|
}
|
|
77
|
+
/** @readonly Gets whether a WebGL rendering context could be created on this browser/device. */
|
|
75
78
|
get supported() {
|
|
76
79
|
return this._detected.supported;
|
|
77
80
|
}
|
package/dist/esm/geometry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -12,10 +12,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
import { Utils } from '@pacem/pacem-core';
|
|
13
13
|
import { StalePropertyFlag } from './types';
|
|
14
14
|
import { NotifyChange } from './decorators';
|
|
15
|
+
/**
|
|
16
|
+
* Abstract base for the concrete geometry classes ({@link LineGeometry}, {@link MeshGeometry}) that back a
|
|
17
|
+
* {@link Pacem3DMeshElement}'s `geometry` property, providing shared bounding-volume computation helpers.
|
|
18
|
+
*/
|
|
15
19
|
export class NodeGeometry {
|
|
16
20
|
constructor(positions = []) {
|
|
17
21
|
this.positions = positions;
|
|
18
22
|
}
|
|
23
|
+
/** Computes the centroid (average) of the given positions. */
|
|
19
24
|
static barycenter(positions) {
|
|
20
25
|
var bary = { x: 0, y: 0, z: 0 };
|
|
21
26
|
if (!Utils.isNullOrEmpty(positions)) {
|
|
@@ -33,6 +38,7 @@ export class NodeGeometry {
|
|
|
33
38
|
}
|
|
34
39
|
return bary;
|
|
35
40
|
}
|
|
41
|
+
/** Computes the axis-aligned {@link Box3D} enclosing the given positions. */
|
|
36
42
|
static boundingBox(positions) {
|
|
37
43
|
const output = {
|
|
38
44
|
minX: +Infinity, minY: +Infinity, minZ: +Infinity,
|
|
@@ -51,6 +57,7 @@ export class NodeGeometry {
|
|
|
51
57
|
}
|
|
52
58
|
return output;
|
|
53
59
|
}
|
|
60
|
+
/** Marks the geometry as stale, flagging it with {@link StalePropertyFlag.Geometry} for the next render. */
|
|
54
61
|
setAsDirty() {
|
|
55
62
|
setSelfAsDirty.call(this);
|
|
56
63
|
}
|
|
@@ -59,27 +66,32 @@ function setSelfAsDirty() {
|
|
|
59
66
|
const me = this;
|
|
60
67
|
me.flags = [/* no further specifications, other than 'geometry' */ StalePropertyFlag.Geometry];
|
|
61
68
|
}
|
|
69
|
+
/** A {@link NodeGeometry} rendered as a polyline through its {@link positions} (no faces/triangles). */
|
|
62
70
|
export class LineGeometry extends NodeGeometry {
|
|
63
71
|
}
|
|
64
72
|
__decorate([
|
|
65
73
|
NotifyChange(setSelfAsDirty)
|
|
66
74
|
], LineGeometry.prototype, "positions", void 0);
|
|
75
|
+
/** A {@link MeshGeometry} implementation with lazily-computed {@link barycenter}/{@link boundingBox} and settable {@link boundingSphere}, used as the `geometry` of a {@link Pacem3DMeshElement}. */
|
|
67
76
|
export class MeshGeometry extends NodeGeometry {
|
|
68
77
|
#boundingBox;
|
|
69
78
|
#boundingSphere;
|
|
70
79
|
#barycenter;
|
|
80
|
+
/** Gets or sets the centroid of {@link positions}; computed on first access if not explicitly set. */
|
|
71
81
|
get barycenter() {
|
|
72
82
|
return this.#barycenter ??= NodeGeometry.barycenter(this.positions);
|
|
73
83
|
}
|
|
74
84
|
set barycenter(point) {
|
|
75
85
|
this.#barycenter = point;
|
|
76
86
|
}
|
|
87
|
+
/** Gets or sets the axis-aligned bounding box; computed from {@link positions} on first access if not explicitly set. */
|
|
77
88
|
get boundingBox() {
|
|
78
89
|
return this.#boundingBox ??= NodeGeometry.boundingBox(this.positions);
|
|
79
90
|
}
|
|
80
91
|
set boundingBox(bbox) {
|
|
81
92
|
this.#boundingBox = bbox;
|
|
82
93
|
}
|
|
94
|
+
/** Gets or sets the bounding sphere. */
|
|
83
95
|
get boundingSphere() {
|
|
84
96
|
return this.#boundingSphere;
|
|
85
97
|
}
|
package/dist/esm/index-iife.js
CHANGED
package/dist/esm/index-root.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/stage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -13,6 +13,12 @@ import { CustomElement, P, PCSS, Defaults, ViewChild, Watch, PropertyConverters,
|
|
|
13
13
|
import { RenderableEvent, DragEvent, RenderableElement } from './types';
|
|
14
14
|
import { TAG_MIDDLE_NAME } from './constants';
|
|
15
15
|
//namespace Pacem.Components.Drawing3D {
|
|
16
|
+
/**
|
|
17
|
+
* `<pacem-3d>`: the root 3d stage element. Hosts the {@link RenderableElement} scene graph (groups, meshes, lights,
|
|
18
|
+
* cameras) declared as children or provided via {@link datasource}, delegates all actual scene-building/rendering/
|
|
19
|
+
* hit-testing to the pluggable {@link adapter} ({@link Pacem3DAdapterElement}), and dispatches pointer interaction
|
|
20
|
+
* events ({@link RenderableEvent}/{@link DragEvent}) for the items under the cursor.
|
|
21
|
+
*/
|
|
16
22
|
let Pacem3DElement = class Pacem3DElement extends Components.PacemItemsContainerElement {
|
|
17
23
|
constructor() {
|
|
18
24
|
super(...arguments);
|
|
@@ -77,9 +83,11 @@ let Pacem3DElement = class Pacem3DElement extends Components.PacemItemsContainer
|
|
|
77
83
|
validate(item) {
|
|
78
84
|
return item instanceof RenderableElement;
|
|
79
85
|
}
|
|
86
|
+
/** @readonly Gets the DOM element the scene is mounted into. */
|
|
80
87
|
get stage() {
|
|
81
88
|
return this._container;
|
|
82
89
|
}
|
|
90
|
+
/** @readonly Gets the technology-dependent native scene instance, as reported by the active {@link adapter}. */
|
|
83
91
|
get scene() {
|
|
84
92
|
return this.adapter && this.adapter.getScene(this);
|
|
85
93
|
}
|
|
@@ -224,9 +232,11 @@ let Pacem3DElement = class Pacem3DElement extends Components.PacemItemsContainer
|
|
|
224
232
|
super.disconnectedCallback();
|
|
225
233
|
}
|
|
226
234
|
#size;
|
|
235
|
+
/** @readonly Gets the current viewport size, as last reported by the internal resize observer. */
|
|
227
236
|
get size() {
|
|
228
237
|
return this.#size;
|
|
229
238
|
}
|
|
239
|
+
/** Renders the whole scene through the active {@link adapter}, or just updates the given `item` if provided. */
|
|
230
240
|
render(item, deepUpdate, now = performance.now()) {
|
|
231
241
|
if (!Utils.isNull(item)) {
|
|
232
242
|
const adapter = this.adapter;
|
package/dist/esm/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-3d v1.0.0-
|
|
2
|
+
* @pacem/pacem-3d v1.0.0-dirac (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -14,38 +14,49 @@ import { Geometry } from '@pacem/pacem-numerical';
|
|
|
14
14
|
import { Point3DConverter, Point3DOrNumberConverter, QuaternionConverter } from './converters';
|
|
15
15
|
import { Pacem3DElement } from './stage';
|
|
16
16
|
import { TAG_MIDDLE_NAME } from './constants';
|
|
17
|
+
/** Type guard checking whether `object` implements the {@link Stage} contract. */
|
|
17
18
|
export function isStage(object) {
|
|
18
19
|
return !Utils.isNull(object) && 'render' in object && typeof object['render'] === 'function';
|
|
19
20
|
}
|
|
21
|
+
/** Type guard checking whether `object` implements the {@link Renderable} contract (i.e. it is attached to a valid {@link Stage}). */
|
|
20
22
|
export function isRenderable(object) {
|
|
21
23
|
return isStage(object?.stage);
|
|
22
24
|
}
|
|
25
|
+
/** Type guard checking whether `object` implements the {@link Ui3DObject} contract (i.e. it exposes a {@link Ui3DObject.transformMatrix}). */
|
|
23
26
|
export function isUi3DObject(object) {
|
|
24
27
|
return 'transformMatrix' in object && isRenderable(object);
|
|
25
28
|
}
|
|
29
|
+
/** Type guard checking whether `object` implements the {@link Camera} contract. */
|
|
26
30
|
export function isCamera(object) {
|
|
27
31
|
return 'type' in object && 'up' in object && 'lookAt' in object && isRenderable(object);
|
|
28
32
|
}
|
|
33
|
+
/** Type guard checking whether `object` is a {@link PerspectiveCamera}. */
|
|
29
34
|
export function isPerspectiveCamera(object) {
|
|
30
35
|
return isCamera(object) && 'type' in object && object.type === 'perspective';
|
|
31
36
|
}
|
|
37
|
+
/** Type guard checking whether `object` is an {@link OrthographicCamera}. */
|
|
32
38
|
export function isOrthographicCamera(object) {
|
|
33
39
|
return isCamera(object) && 'type' in object && object.type === 'orthographic';
|
|
34
40
|
}
|
|
41
|
+
/** Type guard checking whether `object` implements the {@link Light} contract. */
|
|
35
42
|
export function isLight(object) {
|
|
36
43
|
return 'type' in object && (object.type === 'ambient' || object.type === 'omni' || object.type === 'direction' || object.type == 'spot') && isRenderable(object);
|
|
37
44
|
}
|
|
45
|
+
/** Type guard checking whether `object` implements the {@link Mesh} contract. */
|
|
38
46
|
export function isMesh(object) {
|
|
39
47
|
return 'geometry' in object && isUi3DObject(object);
|
|
40
48
|
}
|
|
49
|
+
/** Type guard checking whether `object` implements the {@link NodeGeometry} contract. */
|
|
41
50
|
export function isGeometry(object) {
|
|
42
51
|
return 'positions' in object && Utils.isArray(object.positions);
|
|
43
52
|
}
|
|
53
|
+
/** Type guard checking whether `object` implements the {@link MeshGeometry} contract (a {@link NodeGeometry} with triangle indices/normals/UVs). */
|
|
44
54
|
export function isMeshGeometry(object) {
|
|
45
55
|
return ('triangleIndices' in object && Utils.isArray(object.triangleIndices)
|
|
46
56
|
|| 'normals' in object && Utils.isArray(object.normals)
|
|
47
57
|
|| 'textureCoordinates' in object && Utils.isArray(object.textureCoordinates)) && isGeometry(object);
|
|
48
58
|
}
|
|
59
|
+
/** Type guard checking whether `object` implements the {@link Group} contract. */
|
|
49
60
|
export function isGroup(object) {
|
|
50
61
|
return 'childRenderables' in object && Utils.isArray(object['childRenderables']) && isUi3DObject(object);
|
|
51
62
|
}
|
|
@@ -81,6 +92,7 @@ export function computePlaneNormal(a, b, c) {
|
|
|
81
92
|
const orthogonal = Geometry.LinearAlgebra.Vector3D.cross(vAB, vAC);
|
|
82
93
|
return Geometry.LinearAlgebra.Vector3D.unit(orthogonal);
|
|
83
94
|
}
|
|
95
|
+
/** 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. */
|
|
84
96
|
export class UI3DEvent extends CustomUIEvent {
|
|
85
97
|
constructor(type, eventInit, originalEvent, point) {
|
|
86
98
|
super(type, eventInit, originalEvent);
|
|
@@ -92,24 +104,36 @@ export class UI3DEvent extends CustomUIEvent {
|
|
|
92
104
|
return this.#point;
|
|
93
105
|
}
|
|
94
106
|
}
|
|
107
|
+
/** Event dispatched while a {@link Renderable} item is being dragged (`itemdragstart`/`itemdrag`/`itemdragend`-like events), carrying a {@link DragEventArgs} payload. */
|
|
95
108
|
export class DragEvent extends UI3DEvent {
|
|
96
109
|
}
|
|
110
|
+
/** Event dispatched for pointer interactions (click/over/out/down/up) with a {@link Renderable} item, carrying the item itself as its `detail`. */
|
|
97
111
|
export class RenderableEvent extends UI3DEvent {
|
|
98
112
|
constructor(type, args, originalEvent, p) {
|
|
99
113
|
super(type, { detail: args, bubbles: true, cancelable: true }, originalEvent, p);
|
|
100
114
|
}
|
|
101
115
|
}
|
|
116
|
+
/** 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. */
|
|
102
117
|
export var StalePropertyFlag;
|
|
103
118
|
(function (StalePropertyFlag) {
|
|
119
|
+
/** The object's {@link Renderable.position} changed. */
|
|
104
120
|
StalePropertyFlag["Position"] = "position";
|
|
121
|
+
/** The object's {@link Ui3DObject.transformMatrix} (rotate/scale/offset) changed. */
|
|
105
122
|
StalePropertyFlag["Transform"] = "transform";
|
|
123
|
+
/** The mesh/line {@link NodeGeometry} changed. */
|
|
106
124
|
StalePropertyFlag["Geometry"] = "geometry";
|
|
125
|
+
/** The group's child collection changed. */
|
|
107
126
|
StalePropertyFlag["Children"] = "children";
|
|
127
|
+
/** The mesh's {@link Material}/{@link Mesh.backMaterial} changed. */
|
|
108
128
|
StalePropertyFlag["Material"] = "material";
|
|
129
|
+
/** A {@link Light}-specific property (color, intensity, target, ...) changed. */
|
|
109
130
|
StalePropertyFlag["Light"] = "light";
|
|
131
|
+
/** A {@link Camera}-specific property (near, far, fov, frustum, ...) changed. */
|
|
110
132
|
StalePropertyFlag["Camera"] = "camera";
|
|
133
|
+
/** The object's {@link Renderable.hide} visibility changed. */
|
|
111
134
|
StalePropertyFlag["Visibility"] = "visibility";
|
|
112
135
|
})(StalePropertyFlag || (StalePropertyFlag = {}));
|
|
136
|
+
/** Type guard checking whether `object` implements the {@link Interaction} contract. */
|
|
113
137
|
export function isInteraction(object) {
|
|
114
138
|
return typeof object === 'object' && 'time' in object && typeof object['time'] === 'number';
|
|
115
139
|
}
|
|
@@ -124,12 +148,20 @@ const Constants = {
|
|
|
124
148
|
GROUP_SELECTOR: P + '-' + TAG_MIDDLE_NAME + '-group',
|
|
125
149
|
DEFAULT_COORDS: { x: 0, y: 0, z: 0 }
|
|
126
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Abstract base of every scene-graph custom element usable inside a {@link Pacem3DElement} stage (groups, meshes,
|
|
153
|
+
* native objects, lights, cameras). Implements {@link Renderable}, wires the element into the ancestor stage/parent
|
|
154
|
+
* chain, and tracks which aspects of the object are stale (via {@link StalePropertyFlag}) so the active
|
|
155
|
+
* {@link Pacem3DAdapterElement} can update only what changed on the next render.
|
|
156
|
+
*/
|
|
127
157
|
export class RenderableElement extends Components.PacemCrossItemsContainerElement {
|
|
128
158
|
constructor() {
|
|
129
159
|
super(...arguments);
|
|
160
|
+
/** Gets or sets the element's position, in 3d world (or parent-local) space. */
|
|
130
161
|
this.position = Constants.DEFAULT_COORDS;
|
|
131
162
|
this.#staleFlags = [];
|
|
132
163
|
}
|
|
164
|
+
/** When implemented in a derived class (e.g. {@link Pacem3DGroupElement}), determines whether `_` may be nested under this element. Denies any child by default. */
|
|
133
165
|
validate(_) {
|
|
134
166
|
// by default no children allowed (Group will except)
|
|
135
167
|
return false;
|
|
@@ -138,9 +170,11 @@ export class RenderableElement extends Components.PacemCrossItemsContainerElemen
|
|
|
138
170
|
// override
|
|
139
171
|
return this.parent || this.stage;
|
|
140
172
|
}
|
|
173
|
+
/** @readonly Gets the ancestor {@link Pacem3DElement} stage this element belongs to. */
|
|
141
174
|
get stage() {
|
|
142
175
|
return this['_scene'] = this['_scene'] || CustomElementUtils.findAncestorOfType(this, Pacem3DElement);
|
|
143
176
|
}
|
|
177
|
+
/** @readonly Gets the closest ancestor {@link RenderableElement} (e.g. the containing group), if any. */
|
|
144
178
|
get parent() {
|
|
145
179
|
return this['_drawableParent'] = this['_drawableParent'] || CustomElementUtils.findAncestor(this, i => i instanceof RenderableElement);
|
|
146
180
|
}
|
|
@@ -164,6 +198,7 @@ export class RenderableElement extends Components.PacemCrossItemsContainerElemen
|
|
|
164
198
|
}
|
|
165
199
|
}
|
|
166
200
|
#staleFlags;
|
|
201
|
+
/** @readonly Gets the list of {@link StalePropertyFlag}s accumulated since the element was last rendered/updated by the adapter. */
|
|
167
202
|
get flags() {
|
|
168
203
|
return this.#staleFlags;
|
|
169
204
|
}
|
|
@@ -187,6 +222,11 @@ __decorate([
|
|
|
187
222
|
__decorate([
|
|
188
223
|
Watch({ emit: false, converter: PropertyConverters.Boolean })
|
|
189
224
|
], RenderableElement.prototype, "inert", void 0);
|
|
225
|
+
/**
|
|
226
|
+
* Abstract base of every {@link RenderableElement} that also carries an affine 3d transform (rotate/scale/offset,
|
|
227
|
+
* combined into {@link transformMatrix}). Extended by {@link Pacem3DGroupElement}, {@link Pacem3DMeshElement} and
|
|
228
|
+
* {@link Pacem3DObjectElement}.
|
|
229
|
+
*/
|
|
190
230
|
export class Ui3DElement extends RenderableElement {
|
|
191
231
|
// #endregion
|
|
192
232
|
propertyChangedCallback(name, old, val, first) {
|
|
@@ -258,12 +298,14 @@ __decorate([
|
|
|
258
298
|
__decorate([
|
|
259
299
|
Watch({ emit: false, converter: PropertyConverters.Number })
|
|
260
300
|
], Ui3DElement.prototype, "translateZ", void 0);
|
|
301
|
+
/** `<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. */
|
|
261
302
|
let Pacem3DGroupElement = class Pacem3DGroupElement extends Ui3DElement {
|
|
262
303
|
validate(child) {
|
|
263
304
|
// overrides default denial
|
|
264
305
|
return child instanceof RenderableElement;
|
|
265
306
|
}
|
|
266
307
|
#children = [];
|
|
308
|
+
/** @readonly Gets the renderable children currently belonging to the group. */
|
|
267
309
|
get childRenderables() {
|
|
268
310
|
return this.#children;
|
|
269
311
|
}
|
|
@@ -285,6 +327,7 @@ Pacem3DGroupElement = __decorate([
|
|
|
285
327
|
CustomElement({ tagName: Constants.GROUP_SELECTOR })
|
|
286
328
|
], Pacem3DGroupElement);
|
|
287
329
|
export { Pacem3DGroupElement };
|
|
330
|
+
/** `<pacem-3d-mesh>`: a {@link Ui3DElement} that renders a {@link NodeGeometry} (mesh or line) with a front/back {@link Material}. */
|
|
288
331
|
let Pacem3DMeshElement = class Pacem3DMeshElement extends Ui3DElement {
|
|
289
332
|
propertyChangedCallback(name, old, val, first) {
|
|
290
333
|
super.propertyChangedCallback(name, old, val, first);
|
|
@@ -312,6 +355,7 @@ Pacem3DMeshElement = __decorate([
|
|
|
312
355
|
CustomElement({ tagName: Constants.MESH_SELECTOR })
|
|
313
356
|
], Pacem3DMeshElement);
|
|
314
357
|
export { Pacem3DMeshElement };
|
|
358
|
+
/** `<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. */
|
|
315
359
|
let Pacem3DObjectElement = class Pacem3DObjectElement extends Ui3DElement {
|
|
316
360
|
propertyChangedCallback(name, old, val, first) {
|
|
317
361
|
super.propertyChangedCallback(name, old, val, first);
|
|
@@ -330,12 +374,17 @@ Pacem3DObjectElement = __decorate([
|
|
|
330
374
|
CustomElement({ tagName: Constants.OBJECT_SELECTOR })
|
|
331
375
|
], Pacem3DObjectElement);
|
|
332
376
|
export { Pacem3DObjectElement };
|
|
377
|
+
/** `<pacem-3d-light>`: a {@link RenderableElement} light source (point/omni, spot or directional) illuminating the scene. */
|
|
333
378
|
let Pacem3DLightElement = class Pacem3DLightElement extends RenderableElement {
|
|
334
379
|
constructor() {
|
|
335
380
|
super(...arguments);
|
|
381
|
+
/** Gets or sets the light intensity/brightness. */
|
|
336
382
|
this.intensity = .85;
|
|
383
|
+
/** Gets or sets the point the light is aimed at (spotlight-specific). */
|
|
337
384
|
this.target = Constants.DEFAULT_COORDS;
|
|
385
|
+
/** Gets or sets the light color. */
|
|
338
386
|
this.color = '#fff';
|
|
387
|
+
/** Gets or sets the kind of light source. */
|
|
339
388
|
this.type = 'omni';
|
|
340
389
|
}
|
|
341
390
|
propertyChangedCallback(name, old, val, first) {
|
|
@@ -366,12 +415,21 @@ Pacem3DLightElement = __decorate([
|
|
|
366
415
|
CustomElement({ tagName: Constants.LIGHT_SELECTOR })
|
|
367
416
|
], Pacem3DLightElement);
|
|
368
417
|
export { Pacem3DLightElement };
|
|
418
|
+
/**
|
|
419
|
+
* Abstract base of the camera custom elements ({@link Pacem3DPerspectiveCameraElement}, {@link Pacem3DOrthographicCameraElement})
|
|
420
|
+
* that can be added to a {@link Pacem3DElement} stage. Implements {@link Camera}, tracking the eye-to-target
|
|
421
|
+
* {@link boundingSphere} used e.g. by {@link Pacem3DAdapterElement.zoomFit}.
|
|
422
|
+
*/
|
|
369
423
|
export class Pacem3DCameraElement extends RenderableElement {
|
|
370
424
|
constructor() {
|
|
371
425
|
super(...arguments);
|
|
426
|
+
/** Gets or sets the near clipping plane distance. */
|
|
372
427
|
this.near = 0.1;
|
|
428
|
+
/** Gets or sets the far clipping plane distance. */
|
|
373
429
|
this.far = 1000.0;
|
|
430
|
+
/** Gets or sets the up vector, in world coordinates. */
|
|
374
431
|
this.up = Geometry.LinearAlgebra.Vector3D.j();
|
|
432
|
+
/** Gets or sets the target the camera looks at, in world coordinates. */
|
|
375
433
|
this.lookAt = Constants.DEFAULT_COORDS;
|
|
376
434
|
}
|
|
377
435
|
#sphere;
|
|
@@ -383,6 +441,7 @@ export class Pacem3DCameraElement extends RenderableElement {
|
|
|
383
441
|
const currentValue = this.#sphere = { center, radius };
|
|
384
442
|
this.dispatchEvent(new PropertyChangeEvent({ currentValue, propertyName: 'boundingSphere', oldValue }));
|
|
385
443
|
}
|
|
444
|
+
/** @readonly Gets the sphere centered on {@link lookAt} with radius equal to the eye-to-target distance. */
|
|
386
445
|
get boundingSphere() {
|
|
387
446
|
return this.#sphere;
|
|
388
447
|
}
|
|
@@ -412,15 +471,20 @@ __decorate([
|
|
|
412
471
|
__decorate([
|
|
413
472
|
Watch({ emit: false, converter: Point3DConverter })
|
|
414
473
|
], Pacem3DCameraElement.prototype, "lookAt", void 0);
|
|
474
|
+
/** `<pacem-3d-perspective-camera>`: a {@link Pacem3DCameraElement} that projects the scene through a perspective frustum (vanishing point), defined by {@link fov} and {@link aspect}. */
|
|
415
475
|
let Pacem3DPerspectiveCameraElement = class Pacem3DPerspectiveCameraElement extends Pacem3DCameraElement {
|
|
416
476
|
constructor() {
|
|
417
477
|
super(...arguments);
|
|
478
|
+
/** Gets or sets the vertical field of view, in degrees. */
|
|
418
479
|
this.fov = 45;
|
|
480
|
+
/** Gets or sets the viewport width/height ratio. */
|
|
419
481
|
this.aspect = 1;
|
|
420
482
|
}
|
|
483
|
+
/** @readonly Gets the camera discriminator: always `"perspective"`. */
|
|
421
484
|
get type() {
|
|
422
485
|
return "perspective";
|
|
423
486
|
}
|
|
487
|
+
/** @readonly Gets the viewport width/height ratio (alias of {@link aspect}). */
|
|
424
488
|
get aspectRatio() {
|
|
425
489
|
return this.aspect;
|
|
426
490
|
}
|
|
@@ -444,14 +508,20 @@ Pacem3DPerspectiveCameraElement = __decorate([
|
|
|
444
508
|
CustomElement({ tagName: Constants.PERSPECTIVE_CAMERA_SELECTOR })
|
|
445
509
|
], Pacem3DPerspectiveCameraElement);
|
|
446
510
|
export { Pacem3DPerspectiveCameraElement };
|
|
511
|
+
/** `<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. */
|
|
447
512
|
let Pacem3DOrthographicCameraElement = class Pacem3DOrthographicCameraElement extends Pacem3DCameraElement {
|
|
448
513
|
constructor() {
|
|
449
514
|
super(...arguments);
|
|
515
|
+
/** Gets or sets the top frustum coordinate (e.g. 1). */
|
|
450
516
|
this.top = 1;
|
|
517
|
+
/** Gets or sets the left frustum coordinate (e.g. -1). */
|
|
451
518
|
this.left = -1;
|
|
519
|
+
/** Gets or sets the bottom frustum coordinate (e.g. -1). */
|
|
452
520
|
this.bottom = -1;
|
|
521
|
+
/** Gets or sets the right frustum coordinate (e.g. 1). */
|
|
453
522
|
this.right = 1;
|
|
454
523
|
}
|
|
524
|
+
/** @readonly Gets the camera discriminator: always `"orthographic"`. */
|
|
455
525
|
get type() {
|
|
456
526
|
return "orthographic";
|
|
457
527
|
}
|
|
@@ -483,5 +553,11 @@ Pacem3DOrthographicCameraElement = __decorate([
|
|
|
483
553
|
CustomElement({ tagName: Constants.ORTHO_CAMERA_SELECTOR })
|
|
484
554
|
], Pacem3DOrthographicCameraElement);
|
|
485
555
|
export { Pacem3DOrthographicCameraElement };
|
|
556
|
+
/**
|
|
557
|
+
* Pluggable rendering-backend contract assignable to a {@link Pacem3DElement}'s `adapter` property. Concrete adapters
|
|
558
|
+
* ({@link Pacem3DThreeAdapterElement} for Three.js/WebGL, {@link Pacem3DWebgpuAdapterElement} for WebGPU) are
|
|
559
|
+
* responsible for initializing/disposing the underlying native scene and DOM surface, sizing it, translating the
|
|
560
|
+
* {@link RenderableElement} scene graph into native objects, hit-testing (raycasting) and producing snapshot images.
|
|
561
|
+
*/
|
|
486
562
|
export class Pacem3DAdapterElement extends PacemEventTarget {
|
|
487
563
|
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"dist/browser/*.*",
|
|
5
5
|
"dist/bundle/*.*",
|
|
6
6
|
"dist/esm/*.*",
|
|
7
|
+
"dist/docs/*.*",
|
|
7
8
|
"typings/*.*",
|
|
8
9
|
"README.md",
|
|
9
10
|
"LICENSE",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"types": "./typings/index.d.ts"
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
|
-
"version": "1.0.0-
|
|
29
|
+
"version": "1.0.0-dirac",
|
|
29
30
|
"author": {
|
|
30
31
|
"name": "Pacem",
|
|
31
32
|
"url": "https://pacem.it"
|