@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/bundle/pacem-3d.mjs
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
|
*/
|
|
@@ -204,9 +204,11 @@ var Pacem3DElement = class Pacem3DElement2 extends Components.PacemItemsContaine
|
|
|
204
204
|
validate(item) {
|
|
205
205
|
return item instanceof RenderableElement;
|
|
206
206
|
}
|
|
207
|
+
/** @readonly Gets the DOM element the scene is mounted into. */
|
|
207
208
|
get stage() {
|
|
208
209
|
return this._container;
|
|
209
210
|
}
|
|
211
|
+
/** @readonly Gets the technology-dependent native scene instance, as reported by the active {@link adapter}. */
|
|
210
212
|
get scene() {
|
|
211
213
|
return this.adapter && this.adapter.getScene(this);
|
|
212
214
|
}
|
|
@@ -342,9 +344,11 @@ var Pacem3DElement = class Pacem3DElement2 extends Components.PacemItemsContaine
|
|
|
342
344
|
super.disconnectedCallback();
|
|
343
345
|
}
|
|
344
346
|
#size;
|
|
347
|
+
/** @readonly Gets the current viewport size, as last reported by the internal resize observer. */
|
|
345
348
|
get size() {
|
|
346
349
|
return this.#size;
|
|
347
350
|
}
|
|
351
|
+
/** Renders the whole scene through the active {@link adapter}, or just updates the given `item` if provided. */
|
|
348
352
|
render(item, deepUpdate, now = performance.now()) {
|
|
349
353
|
if (!Utils2.isNull(item)) {
|
|
350
354
|
const adapter = this.adapter;
|
|
@@ -510,15 +514,18 @@ var RenderableElement = class _RenderableElement extends Components2.PacemCrossI
|
|
|
510
514
|
this.position = Constants.DEFAULT_COORDS;
|
|
511
515
|
this.#staleFlags = [];
|
|
512
516
|
}
|
|
517
|
+
/** When implemented in a derived class (e.g. {@link Pacem3DGroupElement}), determines whether `_` may be nested under this element. Denies any child by default. */
|
|
513
518
|
validate(_) {
|
|
514
519
|
return false;
|
|
515
520
|
}
|
|
516
521
|
findContainer() {
|
|
517
522
|
return this.parent || this.stage;
|
|
518
523
|
}
|
|
524
|
+
/** @readonly Gets the ancestor {@link Pacem3DElement} stage this element belongs to. */
|
|
519
525
|
get stage() {
|
|
520
526
|
return this["_scene"] = this["_scene"] || CustomElementUtils.findAncestorOfType(this, Pacem3DElement);
|
|
521
527
|
}
|
|
528
|
+
/** @readonly Gets the closest ancestor {@link RenderableElement} (e.g. the containing group), if any. */
|
|
522
529
|
get parent() {
|
|
523
530
|
return this["_drawableParent"] = this["_drawableParent"] || CustomElementUtils.findAncestor(this, (i) => i instanceof _RenderableElement);
|
|
524
531
|
}
|
|
@@ -542,6 +549,7 @@ var RenderableElement = class _RenderableElement extends Components2.PacemCrossI
|
|
|
542
549
|
}
|
|
543
550
|
}
|
|
544
551
|
#staleFlags;
|
|
552
|
+
/** @readonly Gets the list of {@link StalePropertyFlag}s accumulated since the element was last rendered/updated by the adapter. */
|
|
545
553
|
get flags() {
|
|
546
554
|
return this.#staleFlags;
|
|
547
555
|
}
|
|
@@ -637,6 +645,7 @@ var Pacem3DGroupElement = class Pacem3DGroupElement2 extends Ui3DElement {
|
|
|
637
645
|
return child instanceof RenderableElement;
|
|
638
646
|
}
|
|
639
647
|
#children = [];
|
|
648
|
+
/** @readonly Gets the renderable children currently belonging to the group. */
|
|
640
649
|
get childRenderables() {
|
|
641
650
|
return this.#children;
|
|
642
651
|
}
|
|
@@ -751,6 +760,7 @@ var Pacem3DCameraElement = class extends RenderableElement {
|
|
|
751
760
|
const currentValue = this.#sphere = { center, radius };
|
|
752
761
|
this.dispatchEvent(new PropertyChangeEvent({ currentValue, propertyName: "boundingSphere", oldValue }));
|
|
753
762
|
}
|
|
763
|
+
/** @readonly Gets the sphere centered on {@link lookAt} with radius equal to the eye-to-target distance. */
|
|
754
764
|
get boundingSphere() {
|
|
755
765
|
return this.#sphere;
|
|
756
766
|
}
|
|
@@ -786,9 +796,11 @@ var Pacem3DPerspectiveCameraElement = class Pacem3DPerspectiveCameraElement2 ext
|
|
|
786
796
|
this.fov = 45;
|
|
787
797
|
this.aspect = 1;
|
|
788
798
|
}
|
|
799
|
+
/** @readonly Gets the camera discriminator: always `"perspective"`. */
|
|
789
800
|
get type() {
|
|
790
801
|
return "perspective";
|
|
791
802
|
}
|
|
803
|
+
/** @readonly Gets the viewport width/height ratio (alias of {@link aspect}). */
|
|
792
804
|
get aspectRatio() {
|
|
793
805
|
return this.aspect;
|
|
794
806
|
}
|
|
@@ -819,6 +831,7 @@ var Pacem3DOrthographicCameraElement = class Pacem3DOrthographicCameraElement2 e
|
|
|
819
831
|
this.bottom = -1;
|
|
820
832
|
this.right = 1;
|
|
821
833
|
}
|
|
834
|
+
/** @readonly Gets the camera discriminator: always `"orthographic"`. */
|
|
822
835
|
get type() {
|
|
823
836
|
return "orthographic";
|
|
824
837
|
}
|
|
@@ -854,6 +867,7 @@ var Pacem3DAdapterElement = class extends PacemEventTarget {
|
|
|
854
867
|
|
|
855
868
|
// packages/3d/dist/esm/detector.js
|
|
856
869
|
var Pacem3DDetector = class {
|
|
870
|
+
/** Probes the browser for WebGL support by attempting to create a rendering context, populating {@link info} and {@link supported}. */
|
|
857
871
|
constructor() {
|
|
858
872
|
this._detected = {
|
|
859
873
|
supported: false,
|
|
@@ -916,9 +930,11 @@ var Pacem3DDetector = class {
|
|
|
916
930
|
addLine("misc", "Supported Extensions", ctx.getSupportedExtensions() || []);
|
|
917
931
|
}
|
|
918
932
|
}
|
|
933
|
+
/** @readonly Gets the detected WebGL capabilities/limits, grouped by section (`main`, `bits`, `shader`, `tex`, `misc`). */
|
|
919
934
|
get info() {
|
|
920
935
|
return this._detected.info;
|
|
921
936
|
}
|
|
937
|
+
/** @readonly Gets whether a WebGL rendering context could be created on this browser/device. */
|
|
922
938
|
get supported() {
|
|
923
939
|
return this._detected.supported;
|
|
924
940
|
}
|
|
@@ -967,11 +983,13 @@ function isShaderMaterial(obj) {
|
|
|
967
983
|
return isMaterial(obj) && obj.shader === KnownShader.Custom;
|
|
968
984
|
}
|
|
969
985
|
var MaterialElement = class extends PacemEventTarget2 {
|
|
986
|
+
/** @param shader The {@link KnownShader} this element's {@link createMaterial} produces. */
|
|
970
987
|
constructor(shader) {
|
|
971
988
|
super();
|
|
972
989
|
this.#shader = shader;
|
|
973
990
|
}
|
|
974
991
|
#shader;
|
|
992
|
+
/** Gets the shading model this element produces materials for. */
|
|
975
993
|
get shader() {
|
|
976
994
|
return this.#shader;
|
|
977
995
|
}
|
|
@@ -1006,11 +1024,13 @@ var MaterialElement = class extends PacemEventTarget2 {
|
|
|
1006
1024
|
super.viewActivatedCallback();
|
|
1007
1025
|
this.updateMaterial();
|
|
1008
1026
|
}
|
|
1027
|
+
/** Recomputes {@link material} via {@link createMaterial}, flagging it as {@link StalePropertyFlag.Material}. */
|
|
1009
1028
|
updateMaterial() {
|
|
1010
1029
|
this.createMaterial().then((m) => {
|
|
1011
1030
|
this.material = Utils4.extend(m, { flags: [StalePropertyFlag.Material] });
|
|
1012
1031
|
});
|
|
1013
1032
|
}
|
|
1033
|
+
/** 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. */
|
|
1014
1034
|
async createMaterial() {
|
|
1015
1035
|
return {
|
|
1016
1036
|
opacity: this.opacity ?? 1,
|
|
@@ -1072,6 +1092,7 @@ var LambertMaterialElement = class LambertMaterialElement2 extends MaterialEleme
|
|
|
1072
1092
|
constructor() {
|
|
1073
1093
|
super(KnownShader.Lambert);
|
|
1074
1094
|
}
|
|
1095
|
+
/** Builds the {@link LambertMaterial}, adding `emissiveColor`, `reflectivity` and `refractionRatio` to the base {@link Material}. */
|
|
1075
1096
|
async createMaterial() {
|
|
1076
1097
|
return Utils5.extend({
|
|
1077
1098
|
emissiveColor: this.emissiveColor || "#000",
|
|
@@ -1130,6 +1151,7 @@ var LineMaterialElement = class LineMaterialElement2 extends MaterialElement {
|
|
|
1130
1151
|
}
|
|
1131
1152
|
}
|
|
1132
1153
|
}
|
|
1154
|
+
/** Builds the {@link LineMaterial}, adding `lineWidth`, `lineJoin`, `lineCap` and `dashArray` to the base {@link Material}. */
|
|
1133
1155
|
async createMaterial() {
|
|
1134
1156
|
return Utils6.extend({
|
|
1135
1157
|
lineWidth: this.lineWidth ?? 1,
|
|
@@ -1173,6 +1195,7 @@ var PhongMaterialElement = class PhongMaterialElement2 extends MaterialElement {
|
|
|
1173
1195
|
constructor() {
|
|
1174
1196
|
super(KnownShader.Phong);
|
|
1175
1197
|
}
|
|
1198
|
+
/** Builds the {@link PhongMaterial}, adding the diffuse (`emissiveColor`, `reflectivity`, `refractionRatio`) and specular (`specularColor`, `shininess`, `flatShading`) properties to the base {@link Material}. */
|
|
1176
1199
|
async createMaterial() {
|
|
1177
1200
|
return Utils7.extend({
|
|
1178
1201
|
emissiveColor: this.emissiveColor || "#000",
|
|
@@ -1233,6 +1256,7 @@ var StandardMaterialElement = class StandardMaterialElement2 extends MaterialEle
|
|
|
1233
1256
|
constructor() {
|
|
1234
1257
|
super(KnownShader.Standard);
|
|
1235
1258
|
}
|
|
1259
|
+
/** Builds the {@link StandardMaterial}, adding `emissiveColor`, `refractionRatio`, `metalness`, `roughness` and `flatShading` to the base {@link Material}. */
|
|
1236
1260
|
async createMaterial() {
|
|
1237
1261
|
return Utils8.extend({
|
|
1238
1262
|
emissiveColor: this.emissiveColor || "#000",
|
|
@@ -1341,6 +1365,7 @@ var NodeGeometry = class {
|
|
|
1341
1365
|
constructor(positions = []) {
|
|
1342
1366
|
this.positions = positions;
|
|
1343
1367
|
}
|
|
1368
|
+
/** Computes the centroid (average) of the given positions. */
|
|
1344
1369
|
static barycenter(positions) {
|
|
1345
1370
|
var bary = { x: 0, y: 0, z: 0 };
|
|
1346
1371
|
if (!Utils11.isNullOrEmpty(positions)) {
|
|
@@ -1358,6 +1383,7 @@ var NodeGeometry = class {
|
|
|
1358
1383
|
}
|
|
1359
1384
|
return bary;
|
|
1360
1385
|
}
|
|
1386
|
+
/** Computes the axis-aligned {@link Box3D} enclosing the given positions. */
|
|
1361
1387
|
static boundingBox(positions) {
|
|
1362
1388
|
const output = {
|
|
1363
1389
|
minX: Infinity,
|
|
@@ -1380,6 +1406,7 @@ var NodeGeometry = class {
|
|
|
1380
1406
|
}
|
|
1381
1407
|
return output;
|
|
1382
1408
|
}
|
|
1409
|
+
/** Marks the geometry as stale, flagging it with {@link StalePropertyFlag.Geometry} for the next render. */
|
|
1383
1410
|
setAsDirty() {
|
|
1384
1411
|
setSelfAsDirty.call(this);
|
|
1385
1412
|
}
|
|
@@ -1400,18 +1427,21 @@ var MeshGeometry = class extends NodeGeometry {
|
|
|
1400
1427
|
#boundingBox;
|
|
1401
1428
|
#boundingSphere;
|
|
1402
1429
|
#barycenter;
|
|
1430
|
+
/** Gets or sets the centroid of {@link positions}; computed on first access if not explicitly set. */
|
|
1403
1431
|
get barycenter() {
|
|
1404
1432
|
return this.#barycenter ??= NodeGeometry.barycenter(this.positions);
|
|
1405
1433
|
}
|
|
1406
1434
|
set barycenter(point) {
|
|
1407
1435
|
this.#barycenter = point;
|
|
1408
1436
|
}
|
|
1437
|
+
/** Gets or sets the axis-aligned bounding box; computed from {@link positions} on first access if not explicitly set. */
|
|
1409
1438
|
get boundingBox() {
|
|
1410
1439
|
return this.#boundingBox ??= NodeGeometry.boundingBox(this.positions);
|
|
1411
1440
|
}
|
|
1412
1441
|
set boundingBox(bbox) {
|
|
1413
1442
|
this.#boundingBox = bbox;
|
|
1414
1443
|
}
|
|
1444
|
+
/** Gets or sets the bounding sphere. */
|
|
1415
1445
|
get boundingSphere() {
|
|
1416
1446
|
return this.#boundingSphere;
|
|
1417
1447
|
}
|
|
@@ -1447,6 +1477,7 @@ var __decorate11 = function(decorators, target, key, desc) {
|
|
|
1447
1477
|
};
|
|
1448
1478
|
var PacemBoxElement_1;
|
|
1449
1479
|
var PacemBoxElement = PacemBoxElement_1 = class PacemBoxElement2 extends Pacem3DPrimitiveElement {
|
|
1480
|
+
/** Builds the {@link MeshGeometry} of a box with the given size and per-axis segment subdivisions (all default to `1`). */
|
|
1450
1481
|
static createMeshGeometry(width, height, depth, widthSegments, heightSegments, depthSegments) {
|
|
1451
1482
|
const w = width || 1, h = height || 1, d = depth || 1, sw = widthSegments || 1, sh = heightSegments || 1, sd = depthSegments || 1;
|
|
1452
1483
|
const positions = [];
|
|
@@ -1604,6 +1635,7 @@ var PacemBoxElement = PacemBoxElement_1 = class PacemBoxElement2 extends Pacem3D
|
|
|
1604
1635
|
geom.boundingSphere = { center, radius: Math.sqrt(Math.pow(w2, 2) + Math.pow(h2, 2) + Math.pow(d2, 2)) };
|
|
1605
1636
|
return geom;
|
|
1606
1637
|
}
|
|
1638
|
+
/** Computes the box geometry from the default (unset) shape parameters. */
|
|
1607
1639
|
createDefaultGeometry() {
|
|
1608
1640
|
return PacemBoxElement_1.createMeshGeometry();
|
|
1609
1641
|
}
|
|
@@ -1653,6 +1685,7 @@ var __decorate12 = function(decorators, target, key, desc) {
|
|
|
1653
1685
|
};
|
|
1654
1686
|
var PacemConeElement_1;
|
|
1655
1687
|
var PacemConeElement = PacemConeElement_1 = class PacemConeElement2 extends Pacem3DPrimitiveElement {
|
|
1688
|
+
/** Builds the {@link MeshGeometry} of a cone with the given base radius, height, side count, lateral-surface segments and base-cap segments. */
|
|
1656
1689
|
static createMeshGeometry(radius = 1, height = 1, sides = 18, heightSegments = 5, capSegments = 1) {
|
|
1657
1690
|
const r = radius;
|
|
1658
1691
|
const nodes = [], uv = [], indices = [];
|
|
@@ -1746,6 +1779,7 @@ var PacemConeElement = PacemConeElement_1 = class PacemConeElement2 extends Pace
|
|
|
1746
1779
|
computeSharpVertexNormals(geom);
|
|
1747
1780
|
return geom;
|
|
1748
1781
|
}
|
|
1782
|
+
/** Computes the cone geometry from the default (unset) shape parameters. */
|
|
1749
1783
|
createDefaultGeometry() {
|
|
1750
1784
|
return PacemConeElement_1.createMeshGeometry();
|
|
1751
1785
|
}
|
|
@@ -1791,6 +1825,7 @@ var __decorate13 = function(decorators, target, key, desc) {
|
|
|
1791
1825
|
};
|
|
1792
1826
|
var PacemCylinderElement_1;
|
|
1793
1827
|
var PacemCylinderElement = PacemCylinderElement_1 = class PacemCylinderElement2 extends Pacem3DPrimitiveElement {
|
|
1828
|
+
/** Builds the {@link MeshGeometry} of a cylinder with the given radius, height, side count, lateral-surface segments and cap segments. */
|
|
1794
1829
|
static createMeshGeometry(radius = 1, height = 1, sides = 18, heightSegments = 5, capSegments = 1) {
|
|
1795
1830
|
const r = radius;
|
|
1796
1831
|
const nodes = [], uv = [], indices = [];
|
|
@@ -1926,6 +1961,7 @@ var PacemCylinderElement = PacemCylinderElement_1 = class PacemCylinderElement2
|
|
|
1926
1961
|
computeSharpVertexNormals(geom);
|
|
1927
1962
|
return geom;
|
|
1928
1963
|
}
|
|
1964
|
+
/** Computes the cylinder geometry from the default (unset) shape parameters. */
|
|
1929
1965
|
createDefaultGeometry() {
|
|
1930
1966
|
return PacemCylinderElement_1.createMeshGeometry();
|
|
1931
1967
|
}
|
|
@@ -1972,9 +2008,11 @@ var __decorate14 = function(decorators, target, key, desc) {
|
|
|
1972
2008
|
var PacemLineElement_1;
|
|
1973
2009
|
var DEFAULT_LINE = [{ x: 0, y: 0, z: 0 }, { x: 0, y: 1, z: 0 }];
|
|
1974
2010
|
var PacemLineElement = PacemLineElement_1 = class PacemLineElement2 extends Pacem3DPrimitiveElement {
|
|
2011
|
+
/** Builds the {@link LineGeometry} out of the given vertices (a single segment from `(0,0,0)` to `(0,1,0)` when omitted). */
|
|
1975
2012
|
static createLineGeometry(positions) {
|
|
1976
2013
|
return new LineGeometry(positions || DEFAULT_LINE);
|
|
1977
2014
|
}
|
|
2015
|
+
/** Computes the line geometry from the default (unset) vertex positions. */
|
|
1978
2016
|
createDefaultGeometry() {
|
|
1979
2017
|
return PacemLineElement_1.createLineGeometry();
|
|
1980
2018
|
}
|
|
@@ -2005,6 +2043,7 @@ var __decorate15 = function(decorators, target, key, desc) {
|
|
|
2005
2043
|
};
|
|
2006
2044
|
var PacemPlaneElement_1;
|
|
2007
2045
|
var PacemPlaneElement = PacemPlaneElement_1 = class PacemPlaneElement2 extends Pacem3DPrimitiveElement {
|
|
2046
|
+
/** 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). */
|
|
2008
2047
|
static createMeshGeometry(width, length, widthSegments, lengthSegments) {
|
|
2009
2048
|
width ||= 1;
|
|
2010
2049
|
length ||= 1;
|
|
@@ -2047,6 +2086,7 @@ var PacemPlaneElement = PacemPlaneElement_1 = class PacemPlaneElement2 extends P
|
|
|
2047
2086
|
geom.key = `plane_${width}x${length}_w${widthSegments}_l${lengthSegments}`;
|
|
2048
2087
|
return geom;
|
|
2049
2088
|
}
|
|
2089
|
+
/** Computes the plane geometry from the default (unset) shape parameters. */
|
|
2050
2090
|
createDefaultGeometry() {
|
|
2051
2091
|
return PacemPlaneElement_1.createMeshGeometry();
|
|
2052
2092
|
}
|
|
@@ -2118,6 +2158,7 @@ var PolyhedronElement = class extends Pacem3DPrimitiveElement {
|
|
|
2118
2158
|
_assignMeshGeometry(radius) {
|
|
2119
2159
|
this.geometry = this.createMeshGeometry(radius > 0 ? radius : 1);
|
|
2120
2160
|
}
|
|
2161
|
+
/** Computes the polyhedron geometry using a radius of `1` when {@link radius} hasn't been explicitly set. */
|
|
2121
2162
|
createDefaultGeometry() {
|
|
2122
2163
|
return this.createMeshGeometry(1);
|
|
2123
2164
|
}
|
|
@@ -2126,6 +2167,7 @@ __decorate16([
|
|
|
2126
2167
|
Watch14({ emit: false, converter: PropertyConverters14.Number })
|
|
2127
2168
|
], PolyhedronElement.prototype, "radius", void 0);
|
|
2128
2169
|
var PacemTetrahedronElement = PacemTetrahedronElement_1 = class PacemTetrahedronElement2 extends PolyhedronElement {
|
|
2170
|
+
/** Builds the {@link MeshGeometry} of a tetrahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
2129
2171
|
static createMeshGeometry(radius) {
|
|
2130
2172
|
radius ||= 1;
|
|
2131
2173
|
const nodesCoordsString = "0 0.5774 -0.8165, 0 0.5774 0.8165, 0.8165 -0.5774 0, -0.8165 -0.5774 0";
|
|
@@ -2160,6 +2202,7 @@ PacemTetrahedronElement = PacemTetrahedronElement_1 = __decorate16([
|
|
|
2160
2202
|
CustomElement13({ tagName: P13 + "-" + TAG_MIDDLE_NAME + "-primitive-tetrahedron" })
|
|
2161
2203
|
], PacemTetrahedronElement);
|
|
2162
2204
|
var PacemOctahedronElement = PacemOctahedronElement_1 = class PacemOctahedronElement2 extends PolyhedronElement {
|
|
2205
|
+
/** Builds the {@link MeshGeometry} of an octahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
2163
2206
|
static createMeshGeometry(radius) {
|
|
2164
2207
|
radius ||= 1;
|
|
2165
2208
|
const nodesCoordsString = "0 0.7071 -0.7071, 0 0.7071 0.7071, 1 0 0, 0 -0.7071 -0.7071, -1 0 0, 0 -0.7071 0.7071";
|
|
@@ -2194,6 +2237,7 @@ PacemOctahedronElement = PacemOctahedronElement_1 = __decorate16([
|
|
|
2194
2237
|
CustomElement13({ tagName: P13 + "-" + TAG_MIDDLE_NAME + "-primitive-octahedron" })
|
|
2195
2238
|
], PacemOctahedronElement);
|
|
2196
2239
|
var PacemHexahedronElement = PacemHexahedronElement_1 = class PacemHexahedronElement2 extends PolyhedronElement {
|
|
2240
|
+
/** Builds the {@link MeshGeometry} of a cube inscribed in a sphere of the given radius (defaults to `1`), as an equal-sided {@link PacemBoxElement}. */
|
|
2197
2241
|
static createMeshGeometry(radius) {
|
|
2198
2242
|
radius ||= 1;
|
|
2199
2243
|
const inv_sqrt3 = 1 / Math.sqrt(3);
|
|
@@ -2210,6 +2254,7 @@ PacemHexahedronElement = PacemHexahedronElement_1 = __decorate16([
|
|
|
2210
2254
|
CustomElement13({ tagName: P13 + "-" + TAG_MIDDLE_NAME + "-primitive-hexahedron" })
|
|
2211
2255
|
], PacemHexahedronElement);
|
|
2212
2256
|
var PacemIcosahedronElement = PacemIcosahedronElement_1 = class PacemIcosahedronElement2 extends PolyhedronElement {
|
|
2257
|
+
/** Builds the {@link MeshGeometry} of an icosahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
2213
2258
|
static createMeshGeometry(radius) {
|
|
2214
2259
|
radius ||= 1;
|
|
2215
2260
|
const nodesCoordsString = "0 0.850651 -0.525731, 0 0.850651 0.525731, 0.850651 0.525731 0, 0.525731 0 -0.850651, -0.525731 0 -0.850651, -0.850651 0.525731 0, -0.525731 0 0.850651, 0.525731 0 0.850651, 0.850651 -0.525731 0, 0 -0.850651 0.525731, 0 -0.850651 -0.525731, -0.850651 -0.525731 0";
|
|
@@ -2366,6 +2411,7 @@ PacemIcosahedronElement = PacemIcosahedronElement_1 = __decorate16([
|
|
|
2366
2411
|
CustomElement13({ tagName: P13 + "-" + TAG_MIDDLE_NAME + "-primitive-icosahedron" })
|
|
2367
2412
|
], PacemIcosahedronElement);
|
|
2368
2413
|
var PacemDodecahedronElement = PacemDodecahedronElement_1 = class PacemDodecahedronElement2 extends PolyhedronElement {
|
|
2414
|
+
/** Builds the {@link MeshGeometry} of a dodecahedron inscribed in a sphere of the given radius (defaults to `1`). */
|
|
2369
2415
|
static createMeshGeometry(radius) {
|
|
2370
2416
|
radius ||= 1;
|
|
2371
2417
|
const n1 = Point3D.from(0.356822 * radius, 0.934172 * radius, 0 * radius);
|
|
@@ -2691,6 +2737,7 @@ var __decorate17 = function(decorators, target, key, desc) {
|
|
|
2691
2737
|
};
|
|
2692
2738
|
var PacemSphereElement_1;
|
|
2693
2739
|
var PacemSphereElement = PacemSphereElement_1 = class PacemSphereElement2 extends Pacem3DPrimitiveElement {
|
|
2740
|
+
/** Builds the {@link MeshGeometry} of a sphere with the given radius (defaults to `1`) and tessellation (defaults to `8`). */
|
|
2694
2741
|
static createMeshGeometry(radius = 1, segs = 8) {
|
|
2695
2742
|
const nodes = [];
|
|
2696
2743
|
const uv = [];
|
|
@@ -2759,6 +2806,7 @@ var PacemSphereElement = PacemSphereElement_1 = class PacemSphereElement2 extend
|
|
|
2759
2806
|
computeSharpVertexNormals(geom);
|
|
2760
2807
|
return geom;
|
|
2761
2808
|
}
|
|
2809
|
+
/** Computes the sphere geometry from the default (unset) shape parameters. */
|
|
2762
2810
|
createDefaultGeometry() {
|
|
2763
2811
|
return PacemSphereElement_1.createMeshGeometry();
|
|
2764
2812
|
}
|
|
@@ -2792,6 +2840,7 @@ var __decorate18 = function(decorators, target, key, desc) {
|
|
|
2792
2840
|
};
|
|
2793
2841
|
var PacemTorusElement_1;
|
|
2794
2842
|
var PacemTorusElement = PacemTorusElement_1 = class PacemTorusElement2 extends Pacem3DPrimitiveElement {
|
|
2843
|
+
/** Builds the {@link MeshGeometry} of a torus with the given outer/inner radii and ring/tube segment counts. */
|
|
2795
2844
|
static createMeshGeometry(radius = 1, innerRadius = 0.25, segments = 24, sides = 12) {
|
|
2796
2845
|
const nodes = [];
|
|
2797
2846
|
const uv = [];
|
|
@@ -2836,6 +2885,7 @@ var PacemTorusElement = PacemTorusElement_1 = class PacemTorusElement2 extends P
|
|
|
2836
2885
|
computeSharpVertexNormals(geom);
|
|
2837
2886
|
return geom;
|
|
2838
2887
|
}
|
|
2888
|
+
/** Computes the torus geometry from the default (unset) shape parameters. */
|
|
2839
2889
|
createDefaultGeometry() {
|
|
2840
2890
|
return PacemTorusElement_1.createMeshGeometry();
|
|
2841
2891
|
}
|
|
@@ -2886,15 +2936,22 @@ function _clipPoint(evt, rect) {
|
|
|
2886
2936
|
return { x: clipX, y: clipY };
|
|
2887
2937
|
}
|
|
2888
2938
|
var AdapterUtils = class _AdapterUtils {
|
|
2939
|
+
/** Returns whether the given object is a {@link MeshGeometry} (has `positions` and `triangleIndices` arrays). */
|
|
2889
2940
|
static isMeshGeometry(obj) {
|
|
2890
2941
|
return "positions" in obj && Utils12.isArray(obj.positions) && "triangleIndices" in obj && Utils12.isArray(obj.triangleIndices);
|
|
2891
2942
|
}
|
|
2943
|
+
/** Returns whether the given object is a {@link Vector3D} (has numeric `x`/`y`/`z`). */
|
|
2892
2944
|
static isVector3D(obj) {
|
|
2893
2945
|
return "x" in obj && typeof obj.x === "number" && "y" in obj && typeof obj.y === "number" && "z" in obj && typeof obj.z === "number";
|
|
2894
2946
|
}
|
|
2947
|
+
/** Returns whether the given object is an {@link Rgba} color (has numeric `r`/`g`/`b`). */
|
|
2895
2948
|
static isRgba(obj) {
|
|
2896
2949
|
return "r" in obj && typeof obj.r === "number" && "g" in obj && typeof obj.g === "number" && "b" in obj && typeof obj.b === "number";
|
|
2897
2950
|
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Flattens an array of 3D vectors, UV coordinates, or RGBA colors into a single flat number array (interleaved components), ready for a GPU buffer.
|
|
2953
|
+
* @param array Array of {@link Vector3D}, {@link UVMap} entries, or {@link Rgba} values to flatten
|
|
2954
|
+
*/
|
|
2898
2955
|
static flattenVectorArray(array) {
|
|
2899
2956
|
const retval = [];
|
|
2900
2957
|
for (let v of array) {
|
|
@@ -2908,6 +2965,10 @@ var AdapterUtils = class _AdapterUtils {
|
|
|
2908
2965
|
}
|
|
2909
2966
|
return retval;
|
|
2910
2967
|
}
|
|
2968
|
+
/**
|
|
2969
|
+
* Returns the first non-hidden {@link Camera} among the given renderables, if any.
|
|
2970
|
+
* @param items Renderable items to search
|
|
2971
|
+
*/
|
|
2911
2972
|
static findCamera(items) {
|
|
2912
2973
|
return (items || []).find((r) => isCamera(r) && !r.hide);
|
|
2913
2974
|
}
|
|
@@ -3611,6 +3672,12 @@ var WGSLBindingType;
|
|
|
3611
3672
|
|
|
3612
3673
|
// packages/3d/dist/esm/adapters/webgpu/buffers.js
|
|
3613
3674
|
var Buffers = class {
|
|
3675
|
+
/**
|
|
3676
|
+
* Creates a {@link GPUBuffer} usable as a vertex buffer (`VERTEX | COPY_DST`), writing `data` into it immediately.
|
|
3677
|
+
* @param device The {@link GPUDevice} to allocate the buffer on.
|
|
3678
|
+
* @param data Vertex attribute data (e.g. flattened positions/normals/uv coordinates).
|
|
3679
|
+
* @param label Optional debug label.
|
|
3680
|
+
*/
|
|
3614
3681
|
static create(device, data, label = "") {
|
|
3615
3682
|
const buffer = device.createBuffer({
|
|
3616
3683
|
size: data.byteLength,
|
|
@@ -3636,6 +3703,12 @@ var Buffers = class {
|
|
|
3636
3703
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
3637
3704
|
});
|
|
3638
3705
|
}
|
|
3706
|
+
/**
|
|
3707
|
+
* Creates a {@link GPUBuffer} usable as an index buffer (`INDEX | COPY_DST`), writing `data` into it immediately.
|
|
3708
|
+
* @param device The {@link GPUDevice} to allocate the buffer on.
|
|
3709
|
+
* @param data 16-bit vertex indices.
|
|
3710
|
+
* @param label Optional debug label.
|
|
3711
|
+
*/
|
|
3639
3712
|
static createIndexed(device, data, label = "") {
|
|
3640
3713
|
const buffer = device.createBuffer({
|
|
3641
3714
|
size: data.byteLength,
|
|
@@ -3793,6 +3866,12 @@ fn getVertexColor(index: u32) -> vec4f {
|
|
|
3793
3866
|
|
|
3794
3867
|
// packages/3d/dist/esm/adapters/webgpu/materials.js
|
|
3795
3868
|
var Materials = class {
|
|
3869
|
+
/**
|
|
3870
|
+
* Wraps `material` in the {@link Material} implementation matching its `shader`.
|
|
3871
|
+
* @param material The scene material to wrap.
|
|
3872
|
+
* @returns A {@link BasicMaterial} or {@link LineMaterial}, depending on `material.shader`.
|
|
3873
|
+
* @throws {TypeError} If `material.shader` isn't one of the supported {@link KnownShader} values.
|
|
3874
|
+
*/
|
|
3796
3875
|
static create(material) {
|
|
3797
3876
|
if (isBasicMaterial(material)) {
|
|
3798
3877
|
return new BasicMaterial(material);
|
|
@@ -3846,6 +3925,10 @@ var BasicMaterial = class extends MaterialBase {
|
|
|
3846
3925
|
throw new TypeError("Basic material expected.");
|
|
3847
3926
|
}
|
|
3848
3927
|
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Allocates the (uninitialized) {@link GPUTexture} for the material's `texture`, if any.
|
|
3930
|
+
* @param key Must be `'texture'`; any other {@link MaterialKey} (or a material without a `texture`) yields `null`.
|
|
3931
|
+
*/
|
|
3849
3932
|
texture({ device }, key = "texture") {
|
|
3850
3933
|
const material = this.material;
|
|
3851
3934
|
if (key === "texture" && !Utils16.isNull(material.texture)) {
|
|
@@ -3873,6 +3956,12 @@ var LineMaterial = class extends MaterialBase {
|
|
|
3873
3956
|
throw new TypeError("Line material expected.");
|
|
3874
3957
|
}
|
|
3875
3958
|
}
|
|
3959
|
+
/**
|
|
3960
|
+
* Returns the `'line'` uniform buffer (canvas width/height and half line-width) for `key === 'line'`; otherwise
|
|
3961
|
+
* defers to the inherited diffuse-color buffer.
|
|
3962
|
+
* @param ctx WebGPU context supplying the device and canvas.
|
|
3963
|
+
* @param key Which buffer to build; only `'line'` is handled specially.
|
|
3964
|
+
*/
|
|
3876
3965
|
buffer(ctx, key) {
|
|
3877
3966
|
switch (key) {
|
|
3878
3967
|
case "line":
|
|
@@ -3884,6 +3973,7 @@ var LineMaterial = class extends MaterialBase {
|
|
|
3884
3973
|
return super.buffer(ctx);
|
|
3885
3974
|
}
|
|
3886
3975
|
}
|
|
3976
|
+
/** Lines have no texture support; always returns `null`. */
|
|
3887
3977
|
texture(_) {
|
|
3888
3978
|
return null;
|
|
3889
3979
|
}
|
|
@@ -4412,9 +4502,15 @@ var OrthographicCamera = class _OrthographicCamera {
|
|
|
4412
4502
|
constructor(_camera) {
|
|
4413
4503
|
this._camera = _camera;
|
|
4414
4504
|
}
|
|
4505
|
+
/** Computes the view matrix for `camera`; see {@link view} for a bound instance-method equivalent. */
|
|
4415
4506
|
static view(camera) {
|
|
4416
4507
|
return view(camera.position, camera.lookAt, camera.up);
|
|
4417
4508
|
}
|
|
4509
|
+
/**
|
|
4510
|
+
* Computes the orthographic projection matrix for `camera`.
|
|
4511
|
+
* @param camera Source orthographic camera.
|
|
4512
|
+
* @param size Viewport size, used to correct the projected frustum for aspect ratio; defaults to a 1:1 viewport.
|
|
4513
|
+
*/
|
|
4418
4514
|
static projection(camera, size = DEFAULT_SIZE) {
|
|
4419
4515
|
const eye = camera.position, target = camera.lookAt;
|
|
4420
4516
|
const z = Vector3D.subtract(target, eye);
|
|
@@ -4428,9 +4524,11 @@ var OrthographicCamera = class _OrthographicCamera {
|
|
|
4428
4524
|
const right = camera.right * w, left = camera.left * w;
|
|
4429
4525
|
return orthographic(left, right, top, bottom, camera.near, camera.far);
|
|
4430
4526
|
}
|
|
4527
|
+
/** Computes the view matrix for the wrapped camera. See {@link Camera.view}. */
|
|
4431
4528
|
view() {
|
|
4432
4529
|
return _OrthographicCamera.view(this._camera);
|
|
4433
4530
|
}
|
|
4531
|
+
/** Computes the orthographic projection matrix for the wrapped camera. See {@link Camera.projection}. */
|
|
4434
4532
|
projection(size) {
|
|
4435
4533
|
return _OrthographicCamera.projection(this._camera, size);
|
|
4436
4534
|
}
|
|
@@ -4439,16 +4537,25 @@ var PerspectiveCamera = class _PerspectiveCamera {
|
|
|
4439
4537
|
constructor(_camera) {
|
|
4440
4538
|
this._camera = _camera;
|
|
4441
4539
|
}
|
|
4540
|
+
/** Computes the view matrix for `camera`; see {@link view} for a bound instance-method equivalent. */
|
|
4442
4541
|
static view(camera) {
|
|
4443
4542
|
return view(camera.position, camera.lookAt, camera.up);
|
|
4444
4543
|
}
|
|
4544
|
+
/**
|
|
4545
|
+
* Computes the perspective projection matrix for `camera`, combining its `aspectRatio` with `size`'s
|
|
4546
|
+
* (`size.width / size.height`) to correct for non-square viewports.
|
|
4547
|
+
* @param camera Source perspective camera.
|
|
4548
|
+
* @param size Viewport size, used to correct for aspect ratio; defaults to a 1:1 viewport.
|
|
4549
|
+
*/
|
|
4445
4550
|
static projection(camera, size = DEFAULT_SIZE) {
|
|
4446
4551
|
const aspectRatio = size.width / size.height / camera.aspectRatio;
|
|
4447
4552
|
return perspective(camera.fov, aspectRatio, camera.near, camera.far);
|
|
4448
4553
|
}
|
|
4554
|
+
/** Computes the view matrix for the wrapped camera. See {@link Camera.view}. */
|
|
4449
4555
|
view() {
|
|
4450
4556
|
return _PerspectiveCamera.view(this._camera);
|
|
4451
4557
|
}
|
|
4558
|
+
/** Computes the perspective projection matrix for the wrapped camera. See {@link Camera.projection}. */
|
|
4452
4559
|
projection(size) {
|
|
4453
4560
|
return _PerspectiveCamera.projection(this._camera, size);
|
|
4454
4561
|
}
|
|
@@ -4497,6 +4604,13 @@ var RenderLooper = class {
|
|
|
4497
4604
|
get items() {
|
|
4498
4605
|
return this._set;
|
|
4499
4606
|
}
|
|
4607
|
+
/**
|
|
4608
|
+
* Invokes `render(mesh, camera, lights)` for every non-disposed mesh buffer in the set, skipping meshes for
|
|
4609
|
+
* which `render` returns `false` (e.g. hidden items). After each successful call, clears the
|
|
4610
|
+
* {@link StalePropertyFlag}s on the mesh buffer and, the first time each occurs, on the shared camera/light
|
|
4611
|
+
* buffers; group buffers are always sealed at the end regardless of whether any mesh rendered.
|
|
4612
|
+
* @param render Callback invoked once per mesh with its buffer, the (single) camera buffer and all light buffers; return `false` to skip that mesh (its flags are left untouched).
|
|
4613
|
+
*/
|
|
4500
4614
|
loop(render) {
|
|
4501
4615
|
const { meshes, cameras, groups, lights } = this._set;
|
|
4502
4616
|
const camera = cameras[0];
|
|
@@ -4525,6 +4639,11 @@ var RenderLooper = class {
|
|
|
4525
4639
|
}
|
|
4526
4640
|
};
|
|
4527
4641
|
var ManagedBuffers = class {
|
|
4642
|
+
/**
|
|
4643
|
+
* Wraps `item` in the {@link ManagedBuffer} implementation matching its runtime type.
|
|
4644
|
+
* @param item A geometry ({@link NodeGeometry}/{@link MeshGeometry}), material ({@link Material3D}) or {@link Interaction} instance.
|
|
4645
|
+
* @throws {Error} If `item`'s type isn't recognized.
|
|
4646
|
+
*/
|
|
4528
4647
|
static create(item) {
|
|
4529
4648
|
if (isGeometry(item)) {
|
|
4530
4649
|
item.key ??= "geometry_" + Utils23.uniqueCode();
|
|
@@ -4540,9 +4659,22 @@ var ManagedBuffers = class {
|
|
|
4540
4659
|
}
|
|
4541
4660
|
};
|
|
4542
4661
|
var RenderableBuffers = class _RenderableBuffers {
|
|
4662
|
+
/**
|
|
4663
|
+
* Wraps `item` in the {@link RenderableBuffer} implementation matching its kind (group/mesh/camera/light),
|
|
4664
|
+
* recursively wrapping a group's children.
|
|
4665
|
+
* @param item The scene renderable to wrap.
|
|
4666
|
+
* @param args Extra constructor arguments forwarded to mesh buffers (the shared geometry/material {@link ManagedBuffer} caches; see `renderer.ts`).
|
|
4667
|
+
* @throws {Error} If `item`'s type isn't recognized.
|
|
4668
|
+
*/
|
|
4543
4669
|
static create(item, ...args) {
|
|
4544
4670
|
return createRenderableBuffer(item, null, ...args);
|
|
4545
4671
|
}
|
|
4672
|
+
/**
|
|
4673
|
+
* Clears the {@link StalePropertyFlag}s on `buffer`'s underlying item, marking it as up to date until the next
|
|
4674
|
+
* scene-graph mutation flags it again.
|
|
4675
|
+
* @param buffer The buffer whose item's flags should be cleared.
|
|
4676
|
+
* @param includeParent Whether to also clear the parent group buffer's flags, recursively up the hierarchy.
|
|
4677
|
+
*/
|
|
4546
4678
|
static clearFlags(buffer, includeParent = false) {
|
|
4547
4679
|
buffer.item.flags.splice(0);
|
|
4548
4680
|
if (includeParent) {
|
|
@@ -4552,6 +4684,11 @@ var RenderableBuffers = class _RenderableBuffers {
|
|
|
4552
4684
|
}
|
|
4553
4685
|
}
|
|
4554
4686
|
}
|
|
4687
|
+
/**
|
|
4688
|
+
* Returns the union of `buffer`'s own {@link StalePropertyFlag}s with those of all its ancestor group buffers —
|
|
4689
|
+
* the effective set of "what changed" a re-render of this item needs to account for.
|
|
4690
|
+
* @param buffer The buffer to compute the effective flag set for.
|
|
4691
|
+
*/
|
|
4555
4692
|
static allFlags(buffer) {
|
|
4556
4693
|
const bufferBase = buffer;
|
|
4557
4694
|
const parentBufferBase = bufferBase.parent;
|
|
@@ -5258,6 +5395,7 @@ var RenderPipelines = class _RenderPipelines {
|
|
|
5258
5395
|
static {
|
|
5259
5396
|
this._memoizer = /* @__PURE__ */ new WeakMap();
|
|
5260
5397
|
}
|
|
5398
|
+
/** Clears the {@link RenderPipeline} cache associated with the given {@link Context} (e.g. on device loss/adapter teardown). Does not explicitly destroy the underlying GPU objects — they're released with the {@link GPUDevice}. */
|
|
5261
5399
|
static dispose(ctx) {
|
|
5262
5400
|
const memoizer = this._memoizer;
|
|
5263
5401
|
const cache = memoizer.get(ctx);
|
|
@@ -5266,6 +5404,12 @@ var RenderPipelines = class _RenderPipelines {
|
|
|
5266
5404
|
memoizer.delete(ctx);
|
|
5267
5405
|
}
|
|
5268
5406
|
}
|
|
5407
|
+
/**
|
|
5408
|
+
* Builds (or reuses, via {@link create}'s cache) the render pipeline for `items` and wraps it as a color-picking-only
|
|
5409
|
+
* {@link RenderPipeline}, whose `frame` delegate draws object ids into an `r32uint` target instead of the normal color target.
|
|
5410
|
+
* Returns `null` if the resolved pipeline isn't a mesh or line pipeline (i.e. doesn't support raycasting).
|
|
5411
|
+
* @param items The mesh/line, camera and lights to raycast, in the same shape expected by {@link create}.
|
|
5412
|
+
*/
|
|
5269
5413
|
static createColorPicking(ctx, items) {
|
|
5270
5414
|
const renderPipeline = _RenderPipelines.create(ctx, items);
|
|
5271
5415
|
if (renderPipeline instanceof MeshRenderPipelineClass || renderPipeline instanceof LineRenderPipelineClass) {
|
|
@@ -5275,6 +5419,20 @@ var RenderPipelines = class _RenderPipelines {
|
|
|
5275
5419
|
}
|
|
5276
5420
|
return null;
|
|
5277
5421
|
}
|
|
5422
|
+
/**
|
|
5423
|
+
* Builds (or returns the memoized) {@link RenderPipeline} for the given renderables: the first buffer must wrap a
|
|
5424
|
+
* {@link Mesh} (with either a {@link MeshGeometry} or a {@link LineMaterial}), followed by its {@link Camera} buffer
|
|
5425
|
+
* and zero or more {@link Light} buffers. Generates the mesh/line's WGSL vertex and fragment shaders (via
|
|
5426
|
+
* {@link MeshWGSLBuilder}/{@link LineWGSLBuilder}), compiles them into {@link GPUShaderModule}s, creates the
|
|
5427
|
+
* {@link GPUBindGroupLayout}s/{@link GPUPipelineLayout} and the resulting {@link GPURenderPipeline} (plus a matching
|
|
5428
|
+
* color-picking pipeline). The pipeline is cached per {@link Context} keyed by shader "recipe" + WGSL modifiers version,
|
|
5429
|
+
* so repeated calls with an equivalent recipe skip rebuilding.
|
|
5430
|
+
* @param ctx WebGPU context (device/canvas/format) to build the pipeline against.
|
|
5431
|
+
* @param items `[mesh, camera, ...lights]` renderable buffers.
|
|
5432
|
+
* @param pipelineOptions Optional overrides for primitive topology, multisampling, vertex packing and WGSL modifiers.
|
|
5433
|
+
* @returns The built (or cached) {@link RenderPipeline}.
|
|
5434
|
+
* @throws {Error} If no mesh is provided, the mesh's geometry/material combination isn't supported, or the first argument isn't a mesh.
|
|
5435
|
+
*/
|
|
5278
5436
|
static create(ctx, [mesh, camera, ...lights], pipelineOptions) {
|
|
5279
5437
|
const memoizer = _RenderPipelines._memoizer;
|
|
5280
5438
|
let cache = memoizer.get(ctx);
|
|
@@ -6370,6 +6528,7 @@ var Raycasters = class {
|
|
|
6370
6528
|
static {
|
|
6371
6529
|
this._memoizer = /* @__PURE__ */ new WeakMap();
|
|
6372
6530
|
}
|
|
6531
|
+
/** Destroys and clears all {@link Raycaster}s memoized for `ctx` (e.g. on device loss/adapter teardown). */
|
|
6373
6532
|
static dispose(ctx) {
|
|
6374
6533
|
const memoizer = this._memoizer;
|
|
6375
6534
|
if (memoizer.has(ctx)) {
|
|
@@ -6552,6 +6711,12 @@ var WebGPUIssueCause;
|
|
|
6552
6711
|
WebGPUIssueCause2[WebGPUIssueCause2["Disabled"] = 1] = "Disabled";
|
|
6553
6712
|
})(WebGPUIssueCause || (WebGPUIssueCause = {}));
|
|
6554
6713
|
var Renderers = class {
|
|
6714
|
+
/**
|
|
6715
|
+
* Creates and asynchronously initializes a WebGPU {@link Renderer} for `stage`'s canvas.
|
|
6716
|
+
* @param stage The owning `<pacem-3d>` element whose wrapper hosts the render canvas.
|
|
6717
|
+
* @param config Whether to enable per-frame WebGPU validation error scopes (a perf hog — debug builds only) and optional WGSL shader modifiers.
|
|
6718
|
+
* @returns A promise resolving to the ready {@link Renderer}, or rejecting with a {@link WebGPUIssue} if WebGPU isn't supported or no adapter/device could be obtained.
|
|
6719
|
+
*/
|
|
6555
6720
|
static create(stage, config) {
|
|
6556
6721
|
return new Promise((resolve, reject) => {
|
|
6557
6722
|
if (!navigator.gpu) {
|
|
@@ -6967,6 +7132,7 @@ var Pacem3DWgslScriptElement = class Pacem3DWgslScriptElement2 extends Component
|
|
|
6967
7132
|
return CustomElementUtils3.findAncestor(this, (n) => n instanceof Pacem3DWebgpuAdapterElement);
|
|
6968
7133
|
}
|
|
6969
7134
|
#version = "";
|
|
7135
|
+
/** @readonly Gets a hash of the current {@link wgsl} content, changing whenever it does. */
|
|
6970
7136
|
get version() {
|
|
6971
7137
|
return this.#version;
|
|
6972
7138
|
}
|
|
@@ -7030,9 +7196,11 @@ var Pacem3DWebgpuAdapterElement = class Pacem3DWebgpuAdapterElement2 extends Pac
|
|
|
7030
7196
|
renderer?.resize(size);
|
|
7031
7197
|
}
|
|
7032
7198
|
#items;
|
|
7199
|
+
/** @readonly Gets the child {@link Pacem3DWgslScriptElement} shader-customization items currently registered. */
|
|
7033
7200
|
get items() {
|
|
7034
7201
|
return this.#items;
|
|
7035
7202
|
}
|
|
7203
|
+
/** Registers a child {@link Pacem3DWgslScriptElement}, re-parsing the WGSL {@link modifiers} it contributes. */
|
|
7036
7204
|
register(item) {
|
|
7037
7205
|
const items = this.#items;
|
|
7038
7206
|
if (item instanceof Pacem3DWgslScriptElement && !items.includes(item)) {
|
|
@@ -7043,6 +7211,7 @@ var Pacem3DWebgpuAdapterElement = class Pacem3DWebgpuAdapterElement2 extends Pac
|
|
|
7043
7211
|
}
|
|
7044
7212
|
return false;
|
|
7045
7213
|
}
|
|
7214
|
+
/** Unregisters a previously-registered {@link Pacem3DWgslScriptElement}, re-parsing the WGSL {@link modifiers} accordingly. */
|
|
7046
7215
|
unregister(item) {
|
|
7047
7216
|
const items = this.#items;
|
|
7048
7217
|
const ndx = items.indexOf(item);
|
|
@@ -7058,9 +7227,11 @@ var Pacem3DWebgpuAdapterElement = class Pacem3DWebgpuAdapterElement2 extends Pac
|
|
|
7058
7227
|
#renderers;
|
|
7059
7228
|
#supported;
|
|
7060
7229
|
#active;
|
|
7230
|
+
/** @readonly Gets whether WebGPU is supported by the current browser/device. */
|
|
7061
7231
|
get supported() {
|
|
7062
7232
|
return this.#supported;
|
|
7063
7233
|
}
|
|
7234
|
+
/** @readonly Gets whether the adapter is currently able to render (false once a {@link WebGPUIssue} disables it). */
|
|
7064
7235
|
get active() {
|
|
7065
7236
|
return this.#active;
|
|
7066
7237
|
}
|
|
@@ -7660,6 +7831,10 @@ var __decorate22 = function(decorators, target, key, desc) {
|
|
|
7660
7831
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7661
7832
|
};
|
|
7662
7833
|
var OBJParser = class {
|
|
7834
|
+
/**
|
|
7835
|
+
* Parses `v` (vertex), `vt` (texture coordinate), `vn` (normal) and `f` (face) records out of `content`,
|
|
7836
|
+
* triangulating any face with more than 3 vertices (fan triangulation).
|
|
7837
|
+
*/
|
|
7663
7838
|
static parse(content) {
|
|
7664
7839
|
const vertices = [];
|
|
7665
7840
|
const vParser = /^v((\s+-?[\d\.]+){3})/gm;
|
|
@@ -7723,6 +7898,10 @@ var OBJParser = class {
|
|
|
7723
7898
|
}
|
|
7724
7899
|
};
|
|
7725
7900
|
var Parser3D = class {
|
|
7901
|
+
/**
|
|
7902
|
+
* Parses `content` according to `type` into a {@link NodeGeometry} (currently only the `'obj'` Wavefront format,
|
|
7903
|
+
* via {@link OBJParser}) or a {@link Material}. Throws for any other/unsupported `type` (e.g. `'mtl'`, not yet implemented).
|
|
7904
|
+
*/
|
|
7726
7905
|
static parseGeometry(content, type) {
|
|
7727
7906
|
switch (type.toLowerCase()) {
|
|
7728
7907
|
case "obj":
|