@luma.gl/engine 10.0.0-alpha.3 → 10.0.0-alpha.4
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/dist.dev.js +695 -1317
- package/dist/dist.min.js +31 -31
- package/dist/geometry/edge-geometry.d.ts +3 -2
- package/dist/geometry/edge-geometry.d.ts.map +1 -1
- package/dist/geometry/edge-geometry.js.map +1 -1
- package/dist/geometry/geometry-primitives.d.ts +54 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -0
- package/dist/geometry/geometry-primitives.js +153 -0
- package/dist/geometry/geometry-primitives.js.map +1 -0
- package/dist/geometry/geometry-utils.d.ts +7 -15
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +9 -55
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +9 -69
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +27 -93
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +4 -2
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +3 -3
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +241 -1301
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/models/clip-space.d.ts +4 -1
- package/dist/models/clip-space.d.ts.map +1 -1
- package/dist/models/clip-space.js +16 -13
- package/dist/models/clip-space.js.map +1 -1
- package/dist/models/directional-light-model.js +1 -1
- package/dist/models/directional-light-model.js.map +1 -1
- package/dist/models/point-light-model.js +1 -1
- package/dist/models/point-light-model.js.map +1 -1
- package/dist/models/spot-light-model.js +1 -1
- package/dist/models/spot-light-model.js.map +1 -1
- package/package.json +7 -6
- package/src/geometry/edge-geometry.ts +7 -3
- package/src/geometry/geometry-primitives.ts +215 -0
- package/src/geometry/geometry-utils.ts +16 -71
- package/src/geometry/geometry.ts +36 -163
- package/src/geometry/gpu-geometry.ts +9 -4
- package/src/index.ts +14 -14
- package/src/model/model.ts +1 -1
- package/src/models/clip-space.ts +21 -14
- package/src/models/directional-light-model.ts +1 -1
- package/src/models/point-light-model.ts +1 -1
- package/src/models/spot-light-model.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts +0 -12
- package/dist/geometries/cone-geometry.d.ts.map +0 -1
- package/dist/geometries/cone-geometry.js +0 -19
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.d.ts +0 -14
- package/dist/geometries/cube-geometry.d.ts.map +0 -1
- package/dist/geometries/cube-geometry.js +0 -222
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.d.ts +0 -11
- package/dist/geometries/cylinder-geometry.d.ts.map +0 -1
- package/dist/geometries/cylinder-geometry.js +0 -17
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +0 -11
- package/dist/geometries/ico-sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js +0 -158
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.d.ts +0 -20
- package/dist/geometries/plane-geometry.d.ts.map +0 -1
- package/dist/geometries/plane-geometry.js +0 -106
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.d.ts +0 -12
- package/dist/geometries/sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/sphere-geometry.js +0 -88
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +0 -23
- package/dist/geometries/truncated-cone-geometry.d.ts.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js +0 -112
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/src/geometries/cone-geometry.ts +0 -31
- package/src/geometries/cube-geometry.ts +0 -258
- package/src/geometries/cylinder-geometry.ts +0 -28
- package/src/geometries/ico-sphere-geometry.ts +0 -193
- package/src/geometries/plane-geometry.ts +0 -142
- package/src/geometries/sphere-geometry.ts +0 -113
- package/src/geometries/truncated-cone-geometry.ts +0 -145
package/dist/dist.dev.js
CHANGED
|
@@ -72,16 +72,16 @@ var __exports__ = (() => {
|
|
|
72
72
|
BufferTransform: () => BufferTransform,
|
|
73
73
|
ClipSpace: () => ClipSpace,
|
|
74
74
|
Computation: () => Computation,
|
|
75
|
-
ConeGeometry: () =>
|
|
76
|
-
CubeGeometry: () =>
|
|
77
|
-
CylinderGeometry: () =>
|
|
75
|
+
ConeGeometry: () => ConeGeometry2,
|
|
76
|
+
CubeGeometry: () => CubeGeometry2,
|
|
77
|
+
CylinderGeometry: () => CylinderGeometry2,
|
|
78
78
|
DirectionalLightModel: () => DirectionalLightModel,
|
|
79
79
|
DynamicBuffer: () => DynamicBuffer,
|
|
80
80
|
DynamicTexture: () => DynamicTexture,
|
|
81
81
|
GPUGeometry: () => GPUGeometry,
|
|
82
|
-
Geometry: () =>
|
|
82
|
+
Geometry: () => Geometry2,
|
|
83
83
|
GroupNode: () => GroupNode,
|
|
84
|
-
IcoSphereGeometry: () =>
|
|
84
|
+
IcoSphereGeometry: () => IcoSphereGeometry2,
|
|
85
85
|
Kernel: () => Kernel,
|
|
86
86
|
KeyFrames: () => KeyFrames,
|
|
87
87
|
LegacyPickingManager: () => LegacyPickingManager,
|
|
@@ -91,20 +91,20 @@ var __exports__ = (() => {
|
|
|
91
91
|
ModelNode: () => ModelNode,
|
|
92
92
|
OrbitControls: () => OrbitControls,
|
|
93
93
|
PickingManager: () => PickingManager,
|
|
94
|
-
PlaneGeometry: () =>
|
|
94
|
+
PlaneGeometry: () => PlaneGeometry2,
|
|
95
95
|
PointLightModel: () => PointLightModel,
|
|
96
96
|
RenderKernel: () => RenderKernel,
|
|
97
97
|
ScenegraphNode: () => ScenegraphNode,
|
|
98
98
|
ShaderInputs: () => ShaderInputs,
|
|
99
99
|
ShaderPassRenderer: () => ShaderPassRenderer,
|
|
100
|
-
SphereGeometry: () =>
|
|
100
|
+
SphereGeometry: () => SphereGeometry2,
|
|
101
101
|
SpotLightModel: () => SpotLightModel,
|
|
102
102
|
Swap: () => Swap,
|
|
103
103
|
SwapBuffers: () => SwapBuffers,
|
|
104
104
|
SwapFramebuffers: () => SwapFramebuffers,
|
|
105
105
|
TextureTransform: () => TextureTransform,
|
|
106
106
|
Timeline: () => Timeline,
|
|
107
|
-
TruncatedConeGeometry: () =>
|
|
107
|
+
TruncatedConeGeometry: () => TruncatedConeGeometry2,
|
|
108
108
|
VideoTexture: () => VideoTexture,
|
|
109
109
|
_resolveLoadFileUrl: () => _resolveLoadFileUrl,
|
|
110
110
|
applyMorphTargets: () => applyMorphTargets,
|
|
@@ -616,105 +616,489 @@ var __exports__ = (() => {
|
|
|
616
616
|
}
|
|
617
617
|
};
|
|
618
618
|
|
|
619
|
-
//
|
|
620
|
-
var
|
|
621
|
-
|
|
622
|
-
// src/utils/uid.ts
|
|
623
|
-
var uidCounters = {};
|
|
624
|
-
function uid(id = "id") {
|
|
625
|
-
uidCounters[id] = uidCounters[id] || 1;
|
|
626
|
-
const count = uidCounters[id]++;
|
|
627
|
-
return `${id}-${count}`;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// src/geometry/geometry.ts
|
|
619
|
+
// ../../node_modules/@math.gl/geometry/dist/lib/geometry.js
|
|
620
|
+
var geometryId = 0;
|
|
631
621
|
var Geometry = class {
|
|
632
|
-
/** Application-provided or generated identifier. */
|
|
633
|
-
id;
|
|
634
|
-
/** Determines how vertices are assembled into primitives. */
|
|
635
|
-
topology;
|
|
636
|
-
/** Resolved draw vertex count. */
|
|
637
|
-
vertexCount;
|
|
638
|
-
/** Optional index attribute. */
|
|
639
|
-
indices;
|
|
640
|
-
/** CPU attributes, keyed by caller-provided source attribute name. */
|
|
641
|
-
attributes;
|
|
642
|
-
/** Buffer layout matching the geometry attributes. Always populated. */
|
|
643
|
-
bufferLayout;
|
|
644
|
-
/** Application-owned metadata. */
|
|
645
|
-
userData = {};
|
|
646
|
-
/** Creates a CPU geometry and wraps raw typed arrays into attribute records. */
|
|
647
622
|
constructor(props) {
|
|
648
|
-
|
|
649
|
-
this.id = props.id ||
|
|
623
|
+
this.userData = {};
|
|
624
|
+
this.id = props.id || `geometry-${++geometryId}`;
|
|
650
625
|
this.topology = props.topology;
|
|
651
|
-
if (indices) {
|
|
652
|
-
this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
|
|
653
|
-
}
|
|
654
626
|
this.attributes = {};
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if (attributeName === "indices") {
|
|
666
|
-
if (this.indices) {
|
|
667
|
-
throw new Error("Multiple indices detected");
|
|
668
|
-
}
|
|
669
|
-
this.indices = attribute;
|
|
627
|
+
let indices = props.indices ? normalizeAttribute(props.indices) : void 0;
|
|
628
|
+
for (const [name, input] of Object.entries(props.attributes || {})) {
|
|
629
|
+
const attribute = normalizeAttribute(input);
|
|
630
|
+
if (name === "POSITION" || name === "positions") {
|
|
631
|
+
attribute.size || (attribute.size = 3);
|
|
632
|
+
}
|
|
633
|
+
if (name === "indices") {
|
|
634
|
+
if (indices)
|
|
635
|
+
throw new Error("Geometry has multiple index attributes");
|
|
636
|
+
indices = attribute;
|
|
670
637
|
} else {
|
|
671
|
-
|
|
672
|
-
const storedAttributeName = Object.keys(this.attributes).find(
|
|
673
|
-
(name) => getGeometryShaderAttributeName(name) === shaderAttributeName
|
|
674
|
-
);
|
|
675
|
-
if (storedAttributeName) {
|
|
676
|
-
delete this.attributes[storedAttributeName];
|
|
677
|
-
}
|
|
678
|
-
this.attributes[attributeName] = attribute;
|
|
638
|
+
this.attributes[name] = attribute;
|
|
679
639
|
}
|
|
680
640
|
}
|
|
681
|
-
if (
|
|
682
|
-
|
|
683
|
-
|
|
641
|
+
if (indices) {
|
|
642
|
+
if (!(indices.value instanceof Uint16Array || indices.value instanceof Uint32Array)) {
|
|
643
|
+
throw new Error("Geometry indices must be a Uint16Array or Uint32Array");
|
|
644
|
+
}
|
|
645
|
+
indices.size = 1;
|
|
646
|
+
this.indices = indices;
|
|
647
|
+
validateIndices(indices, this.attributes);
|
|
648
|
+
}
|
|
649
|
+
this.vertexCount = props.vertexCount ?? calculateVertexCount(this.attributes, this.indices);
|
|
650
|
+
if (!Number.isInteger(this.vertexCount) || this.vertexCount < 0) {
|
|
651
|
+
throw new Error("Geometry vertexCount must be a non-negative integer");
|
|
684
652
|
}
|
|
685
|
-
this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
|
|
686
|
-
this.bufferLayout = props.bufferLayout || getBufferLayoutFromGeometryAttributes(this.attributes);
|
|
687
653
|
}
|
|
688
|
-
/** Returns the resolved draw vertex count. */
|
|
689
654
|
getVertexCount() {
|
|
690
655
|
return this.vertexCount;
|
|
691
656
|
}
|
|
692
|
-
/** Returns all attributes, including `indices` when index data is present. */
|
|
693
657
|
getAttributes() {
|
|
694
658
|
return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
|
|
695
659
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
660
|
+
};
|
|
661
|
+
function normalizeAttribute(input) {
|
|
662
|
+
const attribute = isTypedArray(input) ? { value: input } : { ...input };
|
|
663
|
+
if (!isTypedArray(attribute.value)) {
|
|
664
|
+
throw new Error("Geometry attributes must contain a typed-array value");
|
|
699
665
|
}
|
|
700
|
-
|
|
701
|
-
|
|
666
|
+
if (attribute.size !== void 0 && (!Number.isInteger(attribute.size) || attribute.size < 1)) {
|
|
667
|
+
throw new Error("Geometry attribute size must be a positive integer");
|
|
702
668
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
669
|
+
if (attribute.size && attribute.value.length % attribute.size !== 0) {
|
|
670
|
+
throw new Error("Geometry attribute length must be divisible by its size");
|
|
671
|
+
}
|
|
672
|
+
return attribute;
|
|
673
|
+
}
|
|
674
|
+
function isTypedArray(value) {
|
|
675
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
676
|
+
}
|
|
677
|
+
function validateIndices(indices, attributes) {
|
|
678
|
+
let maximumIndex = -1;
|
|
679
|
+
for (const index of indices.value)
|
|
680
|
+
maximumIndex = Math.max(maximumIndex, Number(index));
|
|
681
|
+
for (const [name, attribute] of Object.entries(attributes)) {
|
|
682
|
+
if (!attribute.constant && attribute.size) {
|
|
683
|
+
const attributeVertexCount = attribute.value.length / attribute.size;
|
|
684
|
+
if (maximumIndex >= attributeVertexCount) {
|
|
685
|
+
throw new Error(`Geometry index ${maximumIndex} exceeds ${name} vertex count ${attributeVertexCount}`);
|
|
686
|
+
}
|
|
706
687
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function calculateVertexCount(attributes, indices) {
|
|
691
|
+
if (indices)
|
|
692
|
+
return indices.value.length;
|
|
693
|
+
let count = Infinity;
|
|
694
|
+
for (const attribute of Object.values(attributes)) {
|
|
695
|
+
if (!attribute.constant && attribute.size) {
|
|
696
|
+
count = Math.min(count, attribute.value.length / attribute.size);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (!Number.isFinite(count))
|
|
700
|
+
throw new Error("Geometry has no countable attributes");
|
|
701
|
+
return count;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// ../../node_modules/@math.gl/geometry/dist/lib/geometry-utils.js
|
|
705
|
+
function unpackIndexedGeometry(geometry) {
|
|
706
|
+
if (!geometry.indices)
|
|
707
|
+
return geometry;
|
|
708
|
+
const indices = geometry.indices.value;
|
|
709
|
+
const attributes = {};
|
|
710
|
+
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
711
|
+
if (!attribute)
|
|
712
|
+
continue;
|
|
713
|
+
if (attribute.constant || !attribute.size) {
|
|
714
|
+
attributes[name] = attribute;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
const ArrayType = attribute.value.constructor;
|
|
718
|
+
const value = new ArrayType(indices.length * attribute.size);
|
|
719
|
+
for (let i = 0; i < indices.length; i++) {
|
|
720
|
+
for (let component = 0; component < attribute.size; component++) {
|
|
721
|
+
value[i * attribute.size + component] = attribute.value[Number(indices[i]) * attribute.size + component];
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
attributes[name] = { ...attribute, value };
|
|
725
|
+
}
|
|
726
|
+
return { attributes };
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/geometry-helpers.js
|
|
730
|
+
function assertPositive(value, name) {
|
|
731
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
732
|
+
throw new Error(`${name} must be greater than zero`);
|
|
733
|
+
}
|
|
734
|
+
function assertNonNegative(value, name) {
|
|
735
|
+
if (!Number.isFinite(value) || value < 0)
|
|
736
|
+
throw new Error(`${name} must be non-negative`);
|
|
737
|
+
}
|
|
738
|
+
function assertSegments(value, name, minimum = 1) {
|
|
739
|
+
if (!Number.isInteger(value) || value < minimum)
|
|
740
|
+
throw new Error(`${name} must be an integer >= ${minimum}`);
|
|
741
|
+
}
|
|
742
|
+
function makeIndices(vertexCount, values) {
|
|
743
|
+
return vertexCount > 65535 ? new Uint32Array(values) : new Uint16Array(values);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/box-geometry.js
|
|
747
|
+
var BoxGeometry = class extends Geometry {
|
|
748
|
+
constructor(props = {}) {
|
|
749
|
+
const size = props.size || [1, 1, 1];
|
|
750
|
+
assertPositive(size[0], "size[0]");
|
|
751
|
+
assertPositive(size[1], "size[1]");
|
|
752
|
+
assertPositive(size[2], "size[2]");
|
|
753
|
+
const half = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
754
|
+
const positions = [];
|
|
755
|
+
const normals = [];
|
|
756
|
+
const texCoords = [];
|
|
757
|
+
const indices = [];
|
|
758
|
+
const faces = [
|
|
759
|
+
{ n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
760
|
+
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
761
|
+
{ n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
|
|
762
|
+
{ n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
|
|
763
|
+
{ n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
|
|
764
|
+
{ n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
|
|
765
|
+
];
|
|
766
|
+
for (const face of faces) {
|
|
767
|
+
const base = positions.length / 3;
|
|
768
|
+
for (const [s, t, u, v] of [
|
|
769
|
+
[-1, -1, 0, 0],
|
|
770
|
+
[1, -1, 1, 0],
|
|
771
|
+
[1, 1, 1, 1],
|
|
772
|
+
[-1, 1, 0, 1]
|
|
773
|
+
]) {
|
|
774
|
+
positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
|
|
775
|
+
normals.push(...face.n);
|
|
776
|
+
texCoords.push(u, v);
|
|
777
|
+
}
|
|
778
|
+
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
|
779
|
+
}
|
|
780
|
+
super({
|
|
781
|
+
id: props.id,
|
|
782
|
+
topology: "triangle-list",
|
|
783
|
+
indices: makeIndices(24, indices),
|
|
784
|
+
attributes: {
|
|
785
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
786
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
787
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
788
|
+
...props.attributes
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
var CubeGeometry = class extends BoxGeometry {
|
|
794
|
+
constructor(props = {}) {
|
|
795
|
+
const size = props.size ?? 1;
|
|
796
|
+
super({ ...props, size: [size, size, size] });
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/surface-of-revolution.js
|
|
801
|
+
function makeSurfaceOfRevolution(rings, nradial) {
|
|
802
|
+
const positions = [];
|
|
803
|
+
const normals = [];
|
|
804
|
+
const texCoords = [];
|
|
805
|
+
const indices = [];
|
|
806
|
+
const stride = nradial + 1;
|
|
807
|
+
for (let ringIndex = 0; ringIndex < rings.length; ringIndex++) {
|
|
808
|
+
const ring = rings[ringIndex];
|
|
809
|
+
for (let radial = 0; radial <= nradial; radial++) {
|
|
810
|
+
const u = radial / nradial;
|
|
811
|
+
const angle2 = u * Math.PI * 2;
|
|
812
|
+
const sin = Math.sin(angle2);
|
|
813
|
+
const cos = Math.cos(angle2);
|
|
814
|
+
positions.push(sin * ring.radius, ring.y, cos * ring.radius);
|
|
815
|
+
normals.push(sin * ring.normalRadius, ring.normalY, cos * ring.normalRadius);
|
|
816
|
+
texCoords.push(u, ringIndex / (rings.length - 1));
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
for (let ring = 0; ring < rings.length - 1; ring++) {
|
|
820
|
+
for (let radial = 0; radial < nradial; radial++) {
|
|
821
|
+
const a = ring * stride + radial;
|
|
822
|
+
const b = a + 1;
|
|
823
|
+
const c = a + stride;
|
|
824
|
+
const d = c + 1;
|
|
825
|
+
indices.push(a, b, d, a, d, c);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
...{ positions, normals, texCoords, indices },
|
|
830
|
+
indexArray: makeIndices(positions.length / 3, indices)
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/truncated-cone-geometry.js
|
|
835
|
+
var TruncatedConeGeometry = class extends Geometry {
|
|
836
|
+
constructor(props = {}) {
|
|
837
|
+
const { topRadius = 0, bottomRadius = 0, topCap = false, bottomCap = false, height = 1, nradial = 10, nvertical = 1, verticalAxis = "y" } = props;
|
|
838
|
+
assertNonNegative(topRadius, "topRadius");
|
|
839
|
+
assertNonNegative(bottomRadius, "bottomRadius");
|
|
840
|
+
if (topRadius === 0 && bottomRadius === 0)
|
|
841
|
+
throw new Error("At least one radius must be greater than zero");
|
|
842
|
+
assertPositive(height, "height");
|
|
843
|
+
assertSegments(nradial, "nradial", 3);
|
|
844
|
+
assertSegments(nvertical, "nvertical");
|
|
845
|
+
const positions = [];
|
|
846
|
+
const normals = [];
|
|
847
|
+
const texCoords = [];
|
|
848
|
+
const indices = [];
|
|
849
|
+
const stride = nradial + 1;
|
|
850
|
+
const slope = (bottomRadius - topRadius) / height;
|
|
851
|
+
const normalScale = 1 / Math.hypot(1, slope);
|
|
852
|
+
const addRing = (radius, y, normalRadius, normalY, v) => {
|
|
853
|
+
const ring = positions.length / 3 / stride;
|
|
854
|
+
for (let radial = 0; radial <= nradial; radial++) {
|
|
855
|
+
const u = radial / nradial;
|
|
856
|
+
const angle2 = u * Math.PI * 2;
|
|
857
|
+
const sin = Math.sin(angle2);
|
|
858
|
+
const cos = Math.cos(angle2);
|
|
859
|
+
const point = orient([sin * radius, y, cos * radius], verticalAxis);
|
|
860
|
+
const normal = orient([sin * normalRadius, normalY, cos * normalRadius], verticalAxis);
|
|
861
|
+
positions.push(...point);
|
|
862
|
+
normals.push(...normal);
|
|
863
|
+
texCoords.push(u, v);
|
|
864
|
+
}
|
|
865
|
+
return ring;
|
|
866
|
+
};
|
|
867
|
+
const connect = (lower, upper) => {
|
|
868
|
+
for (let radial = 0; radial < nradial; radial++) {
|
|
869
|
+
const a = lower * stride + radial;
|
|
870
|
+
const b = a + 1;
|
|
871
|
+
const c = upper * stride + radial;
|
|
872
|
+
const d = c + 1;
|
|
873
|
+
indices.push(a, b, d, a, d, c);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
let previous;
|
|
877
|
+
if (bottomCap) {
|
|
878
|
+
const center = addRing(0, -height / 2, 0, -1, 0);
|
|
879
|
+
const edge = addRing(bottomRadius, -height / 2, 0, -1, 1);
|
|
880
|
+
connect(center, edge);
|
|
881
|
+
previous = addRing(bottomRadius, -height / 2, normalScale, slope * normalScale, 0);
|
|
882
|
+
}
|
|
883
|
+
for (let vertical = 0; vertical <= nvertical; vertical++) {
|
|
884
|
+
const v = vertical / nvertical;
|
|
885
|
+
const radius = bottomRadius + (topRadius - bottomRadius) * v;
|
|
886
|
+
const ring = addRing(radius, (v - 0.5) * height, normalScale, slope * normalScale, v);
|
|
887
|
+
if (previous !== void 0 && !(bottomCap && vertical === 0))
|
|
888
|
+
connect(previous, ring);
|
|
889
|
+
previous = ring;
|
|
890
|
+
}
|
|
891
|
+
if (topCap && previous !== void 0) {
|
|
892
|
+
const edge = addRing(topRadius, height / 2, 0, 1, 1);
|
|
893
|
+
const center = addRing(0, height / 2, 0, 1, 0);
|
|
894
|
+
connect(edge, center);
|
|
895
|
+
}
|
|
896
|
+
const vertexCount = positions.length / 3;
|
|
897
|
+
super({
|
|
898
|
+
id: props.id,
|
|
899
|
+
topology: "triangle-list",
|
|
900
|
+
indices: makeIndices(vertexCount, indices),
|
|
901
|
+
attributes: {
|
|
902
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
903
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
904
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
905
|
+
...props.attributes
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
function orient(vector, axis) {
|
|
911
|
+
switch (axis) {
|
|
912
|
+
case "x":
|
|
913
|
+
return [vector[1], vector[2], vector[0]];
|
|
914
|
+
case "z":
|
|
915
|
+
return [vector[2], vector[0], vector[1]];
|
|
916
|
+
default:
|
|
917
|
+
return [vector[0], vector[1], vector[2]];
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/plane-geometry.js
|
|
922
|
+
var PlaneGeometry = class extends Geometry {
|
|
923
|
+
constructor(props) {
|
|
924
|
+
const { sizeX, sizeZ, nx = 1, nz = 1 } = props;
|
|
925
|
+
assertPositive(sizeX, "sizeX");
|
|
926
|
+
assertPositive(sizeZ, "sizeZ");
|
|
927
|
+
assertSegments(nx, "nx");
|
|
928
|
+
assertSegments(nz, "nz");
|
|
929
|
+
const positions = [];
|
|
930
|
+
const normals = [];
|
|
931
|
+
const texCoords = [];
|
|
932
|
+
const indexValues = [];
|
|
933
|
+
for (let z = 0; z <= nz; z++) {
|
|
934
|
+
const v = z / nz;
|
|
935
|
+
for (let x = 0; x <= nx; x++) {
|
|
936
|
+
const u = x / nx;
|
|
937
|
+
positions.push((u - 0.5) * sizeX, 0, (0.5 - v) * sizeZ);
|
|
938
|
+
normals.push(0, 1, 0);
|
|
939
|
+
texCoords.push(u, v);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
const stride = nx + 1;
|
|
943
|
+
for (let z = 0; z < nz; z++) {
|
|
944
|
+
for (let x = 0; x < nx; x++) {
|
|
945
|
+
const a = z * stride + x;
|
|
946
|
+
const b = a + 1;
|
|
947
|
+
const c = a + stride;
|
|
948
|
+
const d = c + 1;
|
|
949
|
+
indexValues.push(a, b, d, a, d, c);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
const vertexCount = positions.length / 3;
|
|
953
|
+
super({
|
|
954
|
+
id: props.id,
|
|
955
|
+
topology: "triangle-list",
|
|
956
|
+
indices: makeIndices(vertexCount, indexValues),
|
|
957
|
+
attributes: {
|
|
958
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
959
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
960
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
961
|
+
...props.attributes
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/sphere-geometry.js
|
|
968
|
+
var SphereGeometry = class extends Geometry {
|
|
969
|
+
constructor(props = {}) {
|
|
970
|
+
const { radius = 0.5, nlat = 10, nlong = 10 } = props;
|
|
971
|
+
assertPositive(radius, "radius");
|
|
972
|
+
assertSegments(nlat, "nlat", 2);
|
|
973
|
+
assertSegments(nlong, "nlong", 3);
|
|
974
|
+
const rings = [];
|
|
975
|
+
for (let latitude = 0; latitude <= nlat; latitude++) {
|
|
976
|
+
const angle2 = -Math.PI / 2 + latitude / nlat * Math.PI;
|
|
977
|
+
const normalRadius = Math.cos(angle2);
|
|
978
|
+
const normalY = Math.sin(angle2);
|
|
979
|
+
rings.push({ radius: radius * normalRadius, y: radius * normalY, normalRadius, normalY });
|
|
980
|
+
}
|
|
981
|
+
const mesh = makeSurfaceOfRevolution(rings, nlong);
|
|
982
|
+
super({
|
|
983
|
+
id: props.id,
|
|
984
|
+
topology: "triangle-list",
|
|
985
|
+
indices: mesh.indexArray,
|
|
986
|
+
attributes: {
|
|
987
|
+
POSITION: { size: 3, value: new Float32Array(mesh.positions) },
|
|
988
|
+
NORMAL: { size: 3, value: new Float32Array(mesh.normals) },
|
|
989
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(mesh.texCoords) },
|
|
990
|
+
...props.attributes
|
|
711
991
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
// ../../node_modules/@math.gl/geometry/dist/geometries/ico-sphere-geometry.js
|
|
997
|
+
var IcoSphereGeometry = class extends Geometry {
|
|
998
|
+
constructor(props = {}) {
|
|
999
|
+
const { radius = 0.5, iterations = 0 } = props;
|
|
1000
|
+
assertPositive(radius, "radius");
|
|
1001
|
+
assertSegments(iterations, "iterations", 0);
|
|
1002
|
+
if (iterations > 8)
|
|
1003
|
+
throw new Error("iterations must be <= 8");
|
|
1004
|
+
const t = (1 + Math.sqrt(5)) / 2;
|
|
1005
|
+
const vertices = [
|
|
1006
|
+
[-1, t, 0],
|
|
1007
|
+
[1, t, 0],
|
|
1008
|
+
[-1, -t, 0],
|
|
1009
|
+
[1, -t, 0],
|
|
1010
|
+
[0, -1, t],
|
|
1011
|
+
[0, 1, t],
|
|
1012
|
+
[0, -1, -t],
|
|
1013
|
+
[0, 1, -t],
|
|
1014
|
+
[t, 0, -1],
|
|
1015
|
+
[t, 0, 1],
|
|
1016
|
+
[-t, 0, -1],
|
|
1017
|
+
[-t, 0, 1]
|
|
1018
|
+
].map(normalize);
|
|
1019
|
+
let faces = [
|
|
1020
|
+
[0, 11, 5],
|
|
1021
|
+
[0, 5, 1],
|
|
1022
|
+
[0, 1, 7],
|
|
1023
|
+
[0, 7, 10],
|
|
1024
|
+
[0, 10, 11],
|
|
1025
|
+
[1, 5, 9],
|
|
1026
|
+
[5, 11, 4],
|
|
1027
|
+
[11, 10, 2],
|
|
1028
|
+
[10, 7, 6],
|
|
1029
|
+
[7, 1, 8],
|
|
1030
|
+
[3, 9, 4],
|
|
1031
|
+
[3, 4, 2],
|
|
1032
|
+
[3, 2, 6],
|
|
1033
|
+
[3, 6, 8],
|
|
1034
|
+
[3, 8, 9],
|
|
1035
|
+
[4, 9, 5],
|
|
1036
|
+
[2, 4, 11],
|
|
1037
|
+
[6, 2, 10],
|
|
1038
|
+
[8, 6, 7],
|
|
1039
|
+
[9, 8, 1]
|
|
1040
|
+
].map((face) => face.map((index) => vertices[index]));
|
|
1041
|
+
for (let iteration = 0; iteration < iterations; iteration++) {
|
|
1042
|
+
const subdivided = [];
|
|
1043
|
+
for (const [a, b, c] of faces) {
|
|
1044
|
+
const ab = normalize([a[0] + b[0], a[1] + b[1], a[2] + b[2]]);
|
|
1045
|
+
const bc = normalize([b[0] + c[0], b[1] + c[1], b[2] + c[2]]);
|
|
1046
|
+
const ca = normalize([c[0] + a[0], c[1] + a[1], c[2] + a[2]]);
|
|
1047
|
+
subdivided.push([a, ab, ca], [b, bc, ab], [c, ca, bc], [ab, bc, ca]);
|
|
1048
|
+
}
|
|
1049
|
+
faces = subdivided;
|
|
1050
|
+
}
|
|
1051
|
+
const positions = [];
|
|
1052
|
+
const normals = [];
|
|
1053
|
+
const texCoords = [];
|
|
1054
|
+
for (const face of faces) {
|
|
1055
|
+
for (const normal of face) {
|
|
1056
|
+
positions.push(normal[0] * radius, normal[1] * radius, normal[2] * radius);
|
|
1057
|
+
normals.push(...normal);
|
|
1058
|
+
texCoords.push(0.5 + Math.atan2(normal[0], normal[2]) / (2 * Math.PI), 0.5 - Math.asin(normal[1]) / Math.PI);
|
|
715
1059
|
}
|
|
716
1060
|
}
|
|
717
|
-
|
|
1061
|
+
super({
|
|
1062
|
+
id: props.id,
|
|
1063
|
+
topology: "triangle-list",
|
|
1064
|
+
attributes: {
|
|
1065
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
1066
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
1067
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
1068
|
+
...props.attributes
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
function normalize(vector) {
|
|
1074
|
+
const length = Math.hypot(...vector);
|
|
1075
|
+
return vector.map((component) => component / length);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// src/geometry/geometry.ts
|
|
1079
|
+
var import_core2 = __toESM(require_core(), 1);
|
|
1080
|
+
var Geometry2 = class extends Geometry {
|
|
1081
|
+
bufferLayout;
|
|
1082
|
+
constructor(props) {
|
|
1083
|
+
const attributes = {};
|
|
1084
|
+
const sourceNames = /* @__PURE__ */ new Map();
|
|
1085
|
+
for (const [name, attribute] of Object.entries(props.attributes)) {
|
|
1086
|
+
const shaderName = getGeometryShaderAttributeName(name);
|
|
1087
|
+
const previousName = sourceNames.get(shaderName);
|
|
1088
|
+
if (previousName) delete attributes[previousName];
|
|
1089
|
+
sourceNames.set(shaderName, name);
|
|
1090
|
+
attributes[name] = attribute;
|
|
1091
|
+
}
|
|
1092
|
+
const sourceIndices = props.indices;
|
|
1093
|
+
const indices = sourceIndices instanceof Uint8Array ? new Uint16Array(sourceIndices) : sourceIndices && !ArrayBuffer.isView(sourceIndices) && sourceIndices.value instanceof Uint8Array ? { ...sourceIndices, value: new Uint16Array(sourceIndices.value) } : sourceIndices;
|
|
1094
|
+
super({ ...props, attributes, indices });
|
|
1095
|
+
for (const [name, input] of Object.entries(attributes)) {
|
|
1096
|
+
if (!ArrayBuffer.isView(input) && Object.isExtensible(input) && name !== "indices") {
|
|
1097
|
+
Object.assign(input, this.attributes[name]);
|
|
1098
|
+
this.attributes[name] = input;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
this.bufferLayout = props.bufferLayout || getBufferLayoutFromGeometryAttributes(this.attributes);
|
|
718
1102
|
}
|
|
719
1103
|
};
|
|
720
1104
|
function getGeometryShaderAttributeName(attributeName) {
|
|
@@ -753,37 +1137,6 @@ var __exports__ = (() => {
|
|
|
753
1137
|
|
|
754
1138
|
// src/geometry/geometry-utils.ts
|
|
755
1139
|
var import_core3 = __toESM(require_core(), 1);
|
|
756
|
-
function unpackIndexedGeometry(geometry) {
|
|
757
|
-
const { indices, attributes } = geometry;
|
|
758
|
-
if (!indices) {
|
|
759
|
-
return geometry;
|
|
760
|
-
}
|
|
761
|
-
const vertexCount = indices.value.length;
|
|
762
|
-
const unpackedAttributes = {};
|
|
763
|
-
for (const attributeName in attributes) {
|
|
764
|
-
const attribute = attributes[attributeName];
|
|
765
|
-
if (!attribute) {
|
|
766
|
-
continue;
|
|
767
|
-
}
|
|
768
|
-
const { value, size } = attribute;
|
|
769
|
-
const constant = attribute["constant"];
|
|
770
|
-
if (constant || !size) {
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
|
-
const ArrayType = value.constructor;
|
|
774
|
-
const unpackedValue = new ArrayType(vertexCount * size);
|
|
775
|
-
for (let x = 0; x < vertexCount; ++x) {
|
|
776
|
-
const index = indices.value[x];
|
|
777
|
-
for (let i = 0; i < size; i++) {
|
|
778
|
-
unpackedValue[x * size + i] = value[index * size + i];
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
unpackedAttributes[attributeName] = { size, value: unpackedValue };
|
|
782
|
-
}
|
|
783
|
-
return {
|
|
784
|
-
attributes: Object.assign({}, attributes, unpackedAttributes)
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
1140
|
function makeInterleavedGeometry(geometry, options = {}) {
|
|
788
1141
|
const bufferName = options.bufferName || "geometry";
|
|
789
1142
|
if (isInterleavedGeometry(geometry, bufferName)) {
|
|
@@ -835,7 +1188,7 @@ var __exports__ = (() => {
|
|
|
835
1188
|
for (const attribute of interleavedAttributes) {
|
|
836
1189
|
writeInterleavedAttribute(arrayBuffer, attributeVertexCount, byteStride, attribute);
|
|
837
1190
|
}
|
|
838
|
-
return new
|
|
1191
|
+
return new Geometry2({
|
|
839
1192
|
id: geometry.id,
|
|
840
1193
|
topology: geometry.topology || "triangle-list",
|
|
841
1194
|
vertexCount: geometry.vertexCount,
|
|
@@ -862,17 +1215,20 @@ var __exports__ = (() => {
|
|
|
862
1215
|
});
|
|
863
1216
|
}
|
|
864
1217
|
function isInterleavedGeometry(geometry, bufferName) {
|
|
865
|
-
if (geometry.bufferLayout
|
|
1218
|
+
if (geometry.bufferLayout?.length !== 1) {
|
|
866
1219
|
return false;
|
|
867
1220
|
}
|
|
868
1221
|
const bufferLayout = geometry.bufferLayout[0];
|
|
869
1222
|
return bufferLayout.name === bufferName && Boolean(bufferLayout.attributes?.length) && Boolean(geometry.attributes[bufferName]);
|
|
870
1223
|
}
|
|
871
1224
|
function getInterleavedSourceAttributes(geometry, attributeNames) {
|
|
872
|
-
|
|
873
|
-
|
|
1225
|
+
const attributes = /* @__PURE__ */ new Map();
|
|
1226
|
+
const sourceNames = attributeNames || Object.keys(geometry.attributes);
|
|
1227
|
+
for (const name of sourceNames) {
|
|
1228
|
+
const attribute = geometry.attributes[name];
|
|
1229
|
+
if (attribute) attributes.set(getGeometryShaderAttributeName(name), [name, attribute]);
|
|
874
1230
|
}
|
|
875
|
-
return
|
|
1231
|
+
return Array.from(attributes.values());
|
|
876
1232
|
}
|
|
877
1233
|
function writeInterleavedAttribute(arrayBuffer, vertexCount, byteStride, attribute) {
|
|
878
1234
|
const ArrayType = attribute.value.constructor;
|
|
@@ -965,7 +1321,7 @@ var __exports__ = (() => {
|
|
|
965
1321
|
attributes[attributeName] = { ...source4, value: encodeMorphTargetAttribute(source4, values) };
|
|
966
1322
|
}
|
|
967
1323
|
}
|
|
968
|
-
const morphedGeometry = new
|
|
1324
|
+
const morphedGeometry = new Geometry2({
|
|
969
1325
|
id: geometry.id,
|
|
970
1326
|
topology: geometry.topology || "triangle-list",
|
|
971
1327
|
vertexCount: geometry.vertexCount,
|
|
@@ -4132,6 +4488,16 @@ var __exports__ = (() => {
|
|
|
4132
4488
|
|
|
4133
4489
|
// src/geometry/gpu-geometry.ts
|
|
4134
4490
|
var import_core7 = __toESM(require_core(), 1);
|
|
4491
|
+
|
|
4492
|
+
// src/utils/uid.ts
|
|
4493
|
+
var uidCounters = {};
|
|
4494
|
+
function uid(id = "id") {
|
|
4495
|
+
uidCounters[id] = uidCounters[id] || 1;
|
|
4496
|
+
const count = uidCounters[id]++;
|
|
4497
|
+
return `${id}-${count}`;
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4500
|
+
// src/geometry/gpu-geometry.ts
|
|
4135
4501
|
var GPUGeometry = class {
|
|
4136
4502
|
/** Application-provided or generated identifier. */
|
|
4137
4503
|
id;
|
|
@@ -4210,7 +4576,7 @@ var __exports__ = (() => {
|
|
|
4210
4576
|
function getAttributeBuffersFromGeometry(device, geometry) {
|
|
4211
4577
|
const attributes = {};
|
|
4212
4578
|
for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
|
|
4213
|
-
const name = geometry.bufferLayout
|
|
4579
|
+
const name = geometry.bufferLayout?.find((bufferLayout) => bufferLayout.name === attributeName)?.name || getGeometryShaderAttributeName(attributeName);
|
|
4214
4580
|
if (attribute) {
|
|
4215
4581
|
attributes[name] = device.createBuffer({
|
|
4216
4582
|
data: attribute.value,
|
|
@@ -4220,7 +4586,7 @@ var __exports__ = (() => {
|
|
|
4220
4586
|
}
|
|
4221
4587
|
return {
|
|
4222
4588
|
attributes,
|
|
4223
|
-
bufferLayout: geometry.bufferLayout,
|
|
4589
|
+
bufferLayout: geometry.bufferLayout || getBufferLayoutFromGeometryAttributes(geometry.attributes),
|
|
4224
4590
|
vertexCount: geometry.vertexCount
|
|
4225
4591
|
};
|
|
4226
4592
|
}
|
|
@@ -4570,7 +4936,7 @@ var __exports__ = (() => {
|
|
|
4570
4936
|
var import_shadertools2 = __toESM(require_shadertools(), 1);
|
|
4571
4937
|
|
|
4572
4938
|
// ../../node_modules/@math.gl/types/dist/is-array.js
|
|
4573
|
-
function
|
|
4939
|
+
function isTypedArray2(value) {
|
|
4574
4940
|
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
4575
4941
|
}
|
|
4576
4942
|
function isNumberArray(value) {
|
|
@@ -4580,7 +4946,7 @@ var __exports__ = (() => {
|
|
|
4580
4946
|
return false;
|
|
4581
4947
|
}
|
|
4582
4948
|
function isNumericArray(value) {
|
|
4583
|
-
return
|
|
4949
|
+
return isTypedArray2(value) || isNumberArray(value);
|
|
4584
4950
|
}
|
|
4585
4951
|
|
|
4586
4952
|
// src/model/split-uniforms-and-bindings.ts
|
|
@@ -6680,26 +7046,30 @@ void main(void) {
|
|
|
6680
7046
|
}
|
|
6681
7047
|
`
|
|
6682
7048
|
);
|
|
6683
|
-
var
|
|
7049
|
+
var QUAD_POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
7050
|
+
var TRIANGLE_POSITIONS = [-1, -1, 3, -1, -1, 3];
|
|
6684
7051
|
var ClipSpace = class extends Model {
|
|
6685
7052
|
constructor(device, props) {
|
|
6686
|
-
const
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
7053
|
+
const { geometryType = "quad", ...modelProps } = props;
|
|
7054
|
+
const positions = geometryType === "triangle" ? TRIANGLE_POSITIONS : QUAD_POSITIONS;
|
|
7055
|
+
const textureCoordinates = positions.map((position) => (position + 1) / 2);
|
|
7056
|
+
const vertexCount = positions.length / 2;
|
|
7057
|
+
if (modelProps.source) {
|
|
7058
|
+
modelProps.source = `${CLIPSPACE_VERTEX_SHADER_WGSL}
|
|
7059
|
+
${modelProps.source}`;
|
|
6690
7060
|
}
|
|
6691
7061
|
super(device, {
|
|
6692
|
-
id:
|
|
6693
|
-
...
|
|
7062
|
+
id: modelProps.id || uid("clip-space"),
|
|
7063
|
+
...modelProps,
|
|
6694
7064
|
vs: CLIPSPACE_VERTEX_SHADER,
|
|
6695
|
-
vertexCount
|
|
6696
|
-
geometry: new
|
|
6697
|
-
topology: "triangle-strip",
|
|
6698
|
-
vertexCount
|
|
7065
|
+
vertexCount,
|
|
7066
|
+
geometry: new Geometry2({
|
|
7067
|
+
topology: geometryType === "triangle" ? "triangle-list" : "triangle-strip",
|
|
7068
|
+
vertexCount,
|
|
6699
7069
|
attributes: {
|
|
6700
|
-
clipSpacePositions: { size: 2, value: new Float32Array(
|
|
6701
|
-
texCoords: { size: 2, value: new Float32Array(
|
|
6702
|
-
coordinates: { size: 2, value: new Float32Array(
|
|
7070
|
+
clipSpacePositions: { size: 2, value: new Float32Array(positions) },
|
|
7071
|
+
texCoords: { size: 2, value: new Float32Array(textureCoordinates) },
|
|
7072
|
+
coordinates: { size: 2, value: new Float32Array(textureCoordinates) }
|
|
6703
7073
|
}
|
|
6704
7074
|
})
|
|
6705
7075
|
});
|
|
@@ -7514,82 +7884,144 @@ void main(void) {
|
|
|
7514
7884
|
}
|
|
7515
7885
|
};
|
|
7516
7886
|
|
|
7517
|
-
// src/
|
|
7518
|
-
var
|
|
7887
|
+
// src/geometry/geometry-primitives.ts
|
|
7888
|
+
var CubeGeometry2 = class extends Geometry2 {
|
|
7519
7889
|
constructor(props = {}) {
|
|
7520
|
-
const
|
|
7521
|
-
const
|
|
7890
|
+
const source4 = new CubeGeometry({ size: 2 });
|
|
7891
|
+
const faceIndices = new Uint32Array(24);
|
|
7892
|
+
const faceOrder = [4, 5, 2, 3, 0, 1];
|
|
7893
|
+
for (let vertexIndex = 0; vertexIndex < faceIndices.length; vertexIndex++) {
|
|
7894
|
+
faceIndices[vertexIndex] = faceOrder[Math.floor(vertexIndex / 4)];
|
|
7895
|
+
}
|
|
7896
|
+
source4.attributes["faceIndex"] = { size: 1, value: faceIndices };
|
|
7897
|
+
if (props.indices === false) {
|
|
7898
|
+
source4.attributes["COLOR_0"] = {
|
|
7899
|
+
size: 3,
|
|
7900
|
+
value: new Float32Array(
|
|
7901
|
+
Array.from(source4.attributes["POSITION"].value, (value) => (value + 1) / 2)
|
|
7902
|
+
)
|
|
7903
|
+
};
|
|
7904
|
+
}
|
|
7905
|
+
const data = props.indices === false ? unpackIndexedGeometry(source4) : source4;
|
|
7522
7906
|
super({
|
|
7907
|
+
id: props.id,
|
|
7908
|
+
topology: source4.topology,
|
|
7909
|
+
indices: props.indices === false ? void 0 : source4.indices,
|
|
7910
|
+
attributes: mergeAttributes(data.attributes, props.attributes)
|
|
7911
|
+
});
|
|
7912
|
+
}
|
|
7913
|
+
};
|
|
7914
|
+
var SphereGeometry2 = class extends Geometry2 {
|
|
7915
|
+
constructor(props = {}) {
|
|
7916
|
+
const source4 = new SphereGeometry({
|
|
7523
7917
|
...props,
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7918
|
+
attributes: void 0,
|
|
7919
|
+
radius: props.radius ?? 1
|
|
7920
|
+
});
|
|
7921
|
+
for (const name of ["POSITION", "NORMAL"]) {
|
|
7922
|
+
const values = source4.attributes[name].value;
|
|
7923
|
+
for (let index = 0; index < values.length; index += 3) {
|
|
7924
|
+
const horizontal = values[index];
|
|
7925
|
+
values[index] = values[index + 2];
|
|
7926
|
+
values[index + 2] = horizontal;
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
const indices = source4.indices?.value;
|
|
7930
|
+
if (indices) {
|
|
7931
|
+
for (let index = 0; index < indices.length; index += 3) {
|
|
7932
|
+
const second = indices[index + 1];
|
|
7933
|
+
indices[index + 1] = indices[index + 2];
|
|
7934
|
+
indices[index + 2] = second;
|
|
7935
|
+
}
|
|
7936
|
+
}
|
|
7937
|
+
super({ ...source4, attributes: { ...source4.attributes, ...props.attributes } });
|
|
7938
|
+
}
|
|
7939
|
+
};
|
|
7940
|
+
var IcoSphereGeometry2 = class extends Geometry2 {
|
|
7941
|
+
constructor(props = {}) {
|
|
7942
|
+
const source4 = new IcoSphereGeometry({ ...props, radius: props.radius ?? 1 });
|
|
7943
|
+
super({ ...source4, attributes: source4.attributes });
|
|
7944
|
+
}
|
|
7945
|
+
};
|
|
7946
|
+
var TruncatedConeGeometry2 = class extends Geometry2 {
|
|
7947
|
+
constructor(props = {}) {
|
|
7948
|
+
const source4 = new TruncatedConeGeometry({ ...props, bottomRadius: props.bottomRadius ?? 1 });
|
|
7949
|
+
super({ ...source4, attributes: source4.attributes });
|
|
7950
|
+
}
|
|
7951
|
+
};
|
|
7952
|
+
var CylinderGeometry2 = class extends TruncatedConeGeometry2 {
|
|
7953
|
+
constructor(props = {}) {
|
|
7954
|
+
const radius = props.radius ?? 1;
|
|
7955
|
+
super({ ...props, topRadius: radius, bottomRadius: radius });
|
|
7956
|
+
}
|
|
7957
|
+
};
|
|
7958
|
+
var ConeGeometry2 = class extends TruncatedConeGeometry2 {
|
|
7959
|
+
constructor(props = {}) {
|
|
7960
|
+
const cap = props.cap ?? true;
|
|
7961
|
+
super({ ...props, topRadius: 0, bottomRadius: props.radius ?? 1, topCap: cap, bottomCap: cap });
|
|
7962
|
+
}
|
|
7963
|
+
};
|
|
7964
|
+
var PlaneGeometry2 = class extends Geometry2 {
|
|
7965
|
+
constructor(props = {}) {
|
|
7966
|
+
const { type = "x,y", offset = 0, flipCull = false } = props;
|
|
7967
|
+
const planeAxes = {
|
|
7968
|
+
"x,y": { sizeX: props.xlen, sizeZ: props.ylen, nx: props.nx, nz: props.ny },
|
|
7969
|
+
"x,z": { sizeX: props.xlen, sizeZ: props.zlen, nx: props.nx, nz: props.nz },
|
|
7970
|
+
"y,z": { sizeX: props.ylen, sizeZ: props.zlen, nx: props.ny, nz: props.nz }
|
|
7971
|
+
}[type];
|
|
7972
|
+
if (!planeAxes) throw new Error("Invalid plane axes");
|
|
7973
|
+
const source4 = new PlaneGeometry({
|
|
7974
|
+
sizeX: planeAxes.sizeX || 1,
|
|
7975
|
+
sizeZ: planeAxes.sizeZ || 1,
|
|
7976
|
+
nx: planeAxes.nx || 1,
|
|
7977
|
+
nz: planeAxes.nz || 1
|
|
7978
|
+
});
|
|
7979
|
+
orientPlane(source4, type, offset, flipCull);
|
|
7980
|
+
const data = props.unpack ? unpackIndexedGeometry(source4) : source4;
|
|
7981
|
+
super({
|
|
7982
|
+
id: props.id,
|
|
7983
|
+
topology: source4.topology,
|
|
7984
|
+
indices: props.unpack ? void 0 : source4.indices,
|
|
7985
|
+
attributes: mergeAttributes(data.attributes, props.attributes)
|
|
7528
7986
|
});
|
|
7529
7987
|
}
|
|
7530
7988
|
};
|
|
7531
|
-
function
|
|
7532
|
-
const
|
|
7533
|
-
const
|
|
7534
|
-
const
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
const v = y / nlat;
|
|
7550
|
-
const index = x + y * (nlong + 1);
|
|
7551
|
-
const i2 = index * 2;
|
|
7552
|
-
const i3 = index * 3;
|
|
7553
|
-
const theta = longRange * u;
|
|
7554
|
-
const phi = latRange * v;
|
|
7555
|
-
const sinTheta = Math.sin(theta);
|
|
7556
|
-
const cosTheta = Math.cos(theta);
|
|
7557
|
-
const sinPhi = Math.sin(phi);
|
|
7558
|
-
const cosPhi = Math.cos(phi);
|
|
7559
|
-
const ux = cosTheta * sinPhi;
|
|
7560
|
-
const uy = cosPhi;
|
|
7561
|
-
const uz = sinTheta * sinPhi;
|
|
7562
|
-
const r = radius(ux, uy, uz, u, v);
|
|
7563
|
-
positions[i3 + 0] = r * ux;
|
|
7564
|
-
positions[i3 + 1] = r * uy;
|
|
7565
|
-
positions[i3 + 2] = r * uz;
|
|
7566
|
-
normals[i3 + 0] = ux;
|
|
7567
|
-
normals[i3 + 1] = uy;
|
|
7568
|
-
normals[i3 + 2] = uz;
|
|
7569
|
-
texCoords[i2 + 0] = u;
|
|
7570
|
-
texCoords[i2 + 1] = 1 - v;
|
|
7571
|
-
}
|
|
7572
|
-
}
|
|
7573
|
-
const numVertsAround = nlong + 1;
|
|
7574
|
-
for (let x = 0; x < nlong; x++) {
|
|
7575
|
-
for (let y = 0; y < nlat; y++) {
|
|
7576
|
-
const index = (x * nlat + y) * 6;
|
|
7577
|
-
indices[index + 0] = y * numVertsAround + x;
|
|
7578
|
-
indices[index + 1] = y * numVertsAround + x + 1;
|
|
7579
|
-
indices[index + 2] = (y + 1) * numVertsAround + x;
|
|
7580
|
-
indices[index + 3] = (y + 1) * numVertsAround + x;
|
|
7581
|
-
indices[index + 4] = y * numVertsAround + x + 1;
|
|
7582
|
-
indices[index + 5] = (y + 1) * numVertsAround + x + 1;
|
|
7989
|
+
function orientPlane(geometry, type, offset, flipCull) {
|
|
7990
|
+
const positions = geometry.attributes["POSITION"].value;
|
|
7991
|
+
const normals = geometry.attributes["NORMAL"].value;
|
|
7992
|
+
const texCoords = geometry.attributes["TEXCOORD_0"].value;
|
|
7993
|
+
for (let vertexIndex = 0; vertexIndex < positions.length / 3; vertexIndex++) {
|
|
7994
|
+
const positionIndex = vertexIndex * 3;
|
|
7995
|
+
const horizontal = Number(positions[positionIndex]) * (flipCull ? -1 : 1);
|
|
7996
|
+
const vertical = -Number(positions[positionIndex + 2]);
|
|
7997
|
+
const normal = flipCull ? 1 : -1;
|
|
7998
|
+
if (type === "x,y") {
|
|
7999
|
+
positions.set([horizontal, vertical, offset], positionIndex);
|
|
8000
|
+
normals.set([0, 0, normal], positionIndex);
|
|
8001
|
+
} else if (type === "x,z") {
|
|
8002
|
+
positions.set([horizontal, offset, vertical], positionIndex);
|
|
8003
|
+
normals.set([0, normal, 0], positionIndex);
|
|
8004
|
+
} else {
|
|
8005
|
+
positions.set([offset, horizontal, vertical], positionIndex);
|
|
8006
|
+
normals.set([normal, 0, 0], positionIndex);
|
|
7583
8007
|
}
|
|
8008
|
+
if (flipCull) texCoords[vertexIndex * 2] = 1 - Number(texCoords[vertexIndex * 2]);
|
|
7584
8009
|
}
|
|
7585
|
-
|
|
7586
|
-
indices
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
8010
|
+
if (type !== "x,z" && geometry.indices) {
|
|
8011
|
+
const indices = geometry.indices.value;
|
|
8012
|
+
for (let index = 0; index < indices.length; index += 3) {
|
|
8013
|
+
const second = indices[index + 1];
|
|
8014
|
+
indices[index + 1] = indices[index + 2];
|
|
8015
|
+
indices[index + 2] = second;
|
|
7591
8016
|
}
|
|
7592
|
-
}
|
|
8017
|
+
}
|
|
8018
|
+
}
|
|
8019
|
+
function mergeAttributes(source4, overrides = {}) {
|
|
8020
|
+
const attributes = {};
|
|
8021
|
+
for (const [name, attribute] of Object.entries(source4)) {
|
|
8022
|
+
if (attribute) attributes[name] = attribute;
|
|
8023
|
+
}
|
|
8024
|
+
return { ...attributes, ...overrides };
|
|
7593
8025
|
}
|
|
7594
8026
|
|
|
7595
8027
|
// src/models/light-model-utils.ts
|
|
@@ -8001,7 +8433,7 @@ void main(void) {
|
|
|
8001
8433
|
}
|
|
8002
8434
|
|
|
8003
8435
|
// src/models/point-light-model.ts
|
|
8004
|
-
var POINT_LIGHT_GEOMETRY = new
|
|
8436
|
+
var POINT_LIGHT_GEOMETRY = new SphereGeometry2({
|
|
8005
8437
|
nlat: 8,
|
|
8006
8438
|
nlong: 12,
|
|
8007
8439
|
radius: 1
|
|
@@ -8018,132 +8450,8 @@ void main(void) {
|
|
|
8018
8450
|
}
|
|
8019
8451
|
};
|
|
8020
8452
|
|
|
8021
|
-
// src/geometries/truncated-cone-geometry.ts
|
|
8022
|
-
var INDEX_OFFSETS = {
|
|
8023
|
-
x: [2, 0, 1],
|
|
8024
|
-
y: [0, 1, 2],
|
|
8025
|
-
z: [1, 2, 0]
|
|
8026
|
-
};
|
|
8027
|
-
var TruncatedConeGeometry = class extends Geometry {
|
|
8028
|
-
constructor(props = {}) {
|
|
8029
|
-
const { id = uid("truncated-code-geometry") } = props;
|
|
8030
|
-
const { indices, attributes } = tesselateTruncatedCone(props);
|
|
8031
|
-
super({
|
|
8032
|
-
...props,
|
|
8033
|
-
id,
|
|
8034
|
-
topology: "triangle-list",
|
|
8035
|
-
indices,
|
|
8036
|
-
attributes: {
|
|
8037
|
-
POSITION: { size: 3, value: attributes.POSITION },
|
|
8038
|
-
NORMAL: { size: 3, value: attributes.NORMAL },
|
|
8039
|
-
TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 },
|
|
8040
|
-
...props.attributes
|
|
8041
|
-
}
|
|
8042
|
-
});
|
|
8043
|
-
}
|
|
8044
|
-
};
|
|
8045
|
-
function tesselateTruncatedCone(props = {}) {
|
|
8046
|
-
const {
|
|
8047
|
-
bottomRadius = 0,
|
|
8048
|
-
topRadius = 0,
|
|
8049
|
-
height = 1,
|
|
8050
|
-
nradial = 10,
|
|
8051
|
-
nvertical = 10,
|
|
8052
|
-
verticalAxis = "y",
|
|
8053
|
-
topCap = false,
|
|
8054
|
-
bottomCap = false
|
|
8055
|
-
} = props;
|
|
8056
|
-
const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
|
|
8057
|
-
const numVertices = (nradial + 1) * (nvertical + 1 + extra);
|
|
8058
|
-
const slant = Math.atan2(bottomRadius - topRadius, height);
|
|
8059
|
-
const msin = Math.sin;
|
|
8060
|
-
const mcos = Math.cos;
|
|
8061
|
-
const mpi = Math.PI;
|
|
8062
|
-
const cosSlant = mcos(slant);
|
|
8063
|
-
const sinSlant = msin(slant);
|
|
8064
|
-
const start = topCap ? -2 : 0;
|
|
8065
|
-
const end = nvertical + (bottomCap ? 2 : 0);
|
|
8066
|
-
const vertsAroundEdge = nradial + 1;
|
|
8067
|
-
const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
|
|
8068
|
-
const indexOffset = INDEX_OFFSETS[verticalAxis];
|
|
8069
|
-
const positions = new Float32Array(numVertices * 3);
|
|
8070
|
-
const normals = new Float32Array(numVertices * 3);
|
|
8071
|
-
const texCoords = new Float32Array(numVertices * 2);
|
|
8072
|
-
let i3 = 0;
|
|
8073
|
-
let i2 = 0;
|
|
8074
|
-
for (let i = start; i <= end; i++) {
|
|
8075
|
-
let v = i / nvertical;
|
|
8076
|
-
let y = height * v;
|
|
8077
|
-
let ringRadius;
|
|
8078
|
-
if (i < 0) {
|
|
8079
|
-
y = 0;
|
|
8080
|
-
v = 1;
|
|
8081
|
-
ringRadius = bottomRadius;
|
|
8082
|
-
} else if (i > nvertical) {
|
|
8083
|
-
y = height;
|
|
8084
|
-
v = 1;
|
|
8085
|
-
ringRadius = topRadius;
|
|
8086
|
-
} else {
|
|
8087
|
-
ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
|
|
8088
|
-
}
|
|
8089
|
-
if (i === -2 || i === nvertical + 2) {
|
|
8090
|
-
ringRadius = 0;
|
|
8091
|
-
v = 0;
|
|
8092
|
-
}
|
|
8093
|
-
y -= height / 2;
|
|
8094
|
-
for (let j = 0; j < vertsAroundEdge; j++) {
|
|
8095
|
-
const sin = msin(j * mpi * 2 / nradial);
|
|
8096
|
-
const cos = mcos(j * mpi * 2 / nradial);
|
|
8097
|
-
positions[i3 + indexOffset[0]] = sin * ringRadius;
|
|
8098
|
-
positions[i3 + indexOffset[1]] = y;
|
|
8099
|
-
positions[i3 + indexOffset[2]] = cos * ringRadius;
|
|
8100
|
-
normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
|
|
8101
|
-
normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
|
|
8102
|
-
normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
|
|
8103
|
-
texCoords[i2 + 0] = j / nradial;
|
|
8104
|
-
texCoords[i2 + 1] = v;
|
|
8105
|
-
i2 += 2;
|
|
8106
|
-
i3 += 3;
|
|
8107
|
-
}
|
|
8108
|
-
}
|
|
8109
|
-
for (let i = 0; i < nvertical + extra; i++) {
|
|
8110
|
-
for (let j = 0; j < nradial; j++) {
|
|
8111
|
-
const index = (i * nradial + j) * 6;
|
|
8112
|
-
indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
8113
|
-
indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
|
|
8114
|
-
indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
8115
|
-
indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
8116
|
-
indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
8117
|
-
indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
|
|
8118
|
-
}
|
|
8119
|
-
}
|
|
8120
|
-
return {
|
|
8121
|
-
indices,
|
|
8122
|
-
attributes: {
|
|
8123
|
-
POSITION: positions,
|
|
8124
|
-
NORMAL: normals,
|
|
8125
|
-
TEXCOORD_0: texCoords
|
|
8126
|
-
}
|
|
8127
|
-
};
|
|
8128
|
-
}
|
|
8129
|
-
|
|
8130
|
-
// src/geometries/cone-geometry.ts
|
|
8131
|
-
var ConeGeometry = class extends TruncatedConeGeometry {
|
|
8132
|
-
constructor(props = {}) {
|
|
8133
|
-
const { id = uid("cone-geometry"), radius = 1, cap = true } = props;
|
|
8134
|
-
super({
|
|
8135
|
-
...props,
|
|
8136
|
-
id,
|
|
8137
|
-
topRadius: 0,
|
|
8138
|
-
topCap: Boolean(cap),
|
|
8139
|
-
bottomCap: Boolean(cap),
|
|
8140
|
-
bottomRadius: radius
|
|
8141
|
-
});
|
|
8142
|
-
}
|
|
8143
|
-
};
|
|
8144
|
-
|
|
8145
8453
|
// src/models/spot-light-model.ts
|
|
8146
|
-
var SPOT_LIGHT_GEOMETRY = new
|
|
8454
|
+
var SPOT_LIGHT_GEOMETRY = new ConeGeometry2({
|
|
8147
8455
|
cap: true,
|
|
8148
8456
|
nradial: 16,
|
|
8149
8457
|
nvertical: 1,
|
|
@@ -8162,7 +8470,7 @@ void main(void) {
|
|
|
8162
8470
|
};
|
|
8163
8471
|
|
|
8164
8472
|
// src/models/directional-light-model.ts
|
|
8165
|
-
var DIRECTIONAL_LIGHT_GEOMETRY = new
|
|
8473
|
+
var DIRECTIONAL_LIGHT_GEOMETRY = new ConeGeometry2({
|
|
8166
8474
|
cap: true,
|
|
8167
8475
|
nradial: 12,
|
|
8168
8476
|
nvertical: 1,
|
|
@@ -8615,7 +8923,7 @@ void main(void) {
|
|
|
8615
8923
|
addEdge(third, first, normal);
|
|
8616
8924
|
}
|
|
8617
8925
|
const selected = [...edges.values()].filter((edge) => options.includeCoplanarEdges || edge.faceCount !== 2 || edge.crease).sort((left, right) => left.start - right.start || left.end - right.end);
|
|
8618
|
-
return new
|
|
8926
|
+
return new Geometry2({
|
|
8619
8927
|
id: `${geometry.id}-edges`,
|
|
8620
8928
|
topology: "line-list",
|
|
8621
8929
|
attributes: { [positionAttribute]: positions },
|
|
@@ -8652,7 +8960,7 @@ void main(void) {
|
|
|
8652
8960
|
positionOffset += attribute.value.length;
|
|
8653
8961
|
}
|
|
8654
8962
|
return makeEdgeGeometry(
|
|
8655
|
-
new
|
|
8963
|
+
new Geometry2({
|
|
8656
8964
|
id: `${geometries[0].id}-batch`,
|
|
8657
8965
|
topology: "triangle-list",
|
|
8658
8966
|
attributes: { [positionAttribute]: { ...firstAttribute, value: positions } },
|
|
@@ -8795,7 +9103,7 @@ void main(void) {
|
|
|
8795
9103
|
appendTriangle(start.outgoingRight, endRight, endLeft);
|
|
8796
9104
|
});
|
|
8797
9105
|
}
|
|
8798
|
-
return new
|
|
9106
|
+
return new Geometry2({
|
|
8799
9107
|
id: options.id,
|
|
8800
9108
|
topology: "triangle-list",
|
|
8801
9109
|
attributes: {
|
|
@@ -9213,936 +9521,6 @@ void main(void) {
|
|
|
9213
9521
|
return first.cost - second.cost || first.retainedVertex - second.retainedVertex || first.removedVertex - second.removedVertex;
|
|
9214
9522
|
}
|
|
9215
9523
|
|
|
9216
|
-
// src/geometries/cube-geometry.ts
|
|
9217
|
-
var CubeGeometry = class extends Geometry {
|
|
9218
|
-
constructor(props = {}) {
|
|
9219
|
-
const { id = uid("cube-geometry"), indices = true } = props;
|
|
9220
|
-
super(
|
|
9221
|
-
indices ? {
|
|
9222
|
-
...props,
|
|
9223
|
-
id,
|
|
9224
|
-
topology: "triangle-list",
|
|
9225
|
-
indices: { size: 1, value: CUBE_INDICES },
|
|
9226
|
-
attributes: { ...ATTRIBUTES, ...props.attributes }
|
|
9227
|
-
} : {
|
|
9228
|
-
...props,
|
|
9229
|
-
id,
|
|
9230
|
-
topology: "triangle-list",
|
|
9231
|
-
indices: void 0,
|
|
9232
|
-
attributes: { ...NON_INDEXED_ATTRIBUTES, ...props.attributes }
|
|
9233
|
-
}
|
|
9234
|
-
);
|
|
9235
|
-
}
|
|
9236
|
-
};
|
|
9237
|
-
var CUBE_INDICES = new Uint16Array([
|
|
9238
|
-
0,
|
|
9239
|
-
1,
|
|
9240
|
-
2,
|
|
9241
|
-
0,
|
|
9242
|
-
2,
|
|
9243
|
-
3,
|
|
9244
|
-
4,
|
|
9245
|
-
5,
|
|
9246
|
-
6,
|
|
9247
|
-
4,
|
|
9248
|
-
6,
|
|
9249
|
-
7,
|
|
9250
|
-
8,
|
|
9251
|
-
9,
|
|
9252
|
-
10,
|
|
9253
|
-
8,
|
|
9254
|
-
10,
|
|
9255
|
-
11,
|
|
9256
|
-
12,
|
|
9257
|
-
13,
|
|
9258
|
-
14,
|
|
9259
|
-
12,
|
|
9260
|
-
14,
|
|
9261
|
-
15,
|
|
9262
|
-
16,
|
|
9263
|
-
17,
|
|
9264
|
-
18,
|
|
9265
|
-
16,
|
|
9266
|
-
18,
|
|
9267
|
-
19,
|
|
9268
|
-
20,
|
|
9269
|
-
21,
|
|
9270
|
-
22,
|
|
9271
|
-
20,
|
|
9272
|
-
22,
|
|
9273
|
-
23
|
|
9274
|
-
]);
|
|
9275
|
-
var CUBE_POSITIONS = new Float32Array([
|
|
9276
|
-
-1,
|
|
9277
|
-
-1,
|
|
9278
|
-
1,
|
|
9279
|
-
1,
|
|
9280
|
-
-1,
|
|
9281
|
-
1,
|
|
9282
|
-
1,
|
|
9283
|
-
1,
|
|
9284
|
-
1,
|
|
9285
|
-
-1,
|
|
9286
|
-
1,
|
|
9287
|
-
1,
|
|
9288
|
-
-1,
|
|
9289
|
-
-1,
|
|
9290
|
-
-1,
|
|
9291
|
-
-1,
|
|
9292
|
-
1,
|
|
9293
|
-
-1,
|
|
9294
|
-
1,
|
|
9295
|
-
1,
|
|
9296
|
-
-1,
|
|
9297
|
-
1,
|
|
9298
|
-
-1,
|
|
9299
|
-
-1,
|
|
9300
|
-
-1,
|
|
9301
|
-
1,
|
|
9302
|
-
-1,
|
|
9303
|
-
-1,
|
|
9304
|
-
1,
|
|
9305
|
-
1,
|
|
9306
|
-
1,
|
|
9307
|
-
1,
|
|
9308
|
-
1,
|
|
9309
|
-
1,
|
|
9310
|
-
1,
|
|
9311
|
-
-1,
|
|
9312
|
-
-1,
|
|
9313
|
-
-1,
|
|
9314
|
-
-1,
|
|
9315
|
-
1,
|
|
9316
|
-
-1,
|
|
9317
|
-
-1,
|
|
9318
|
-
1,
|
|
9319
|
-
-1,
|
|
9320
|
-
1,
|
|
9321
|
-
-1,
|
|
9322
|
-
-1,
|
|
9323
|
-
1,
|
|
9324
|
-
1,
|
|
9325
|
-
-1,
|
|
9326
|
-
-1,
|
|
9327
|
-
1,
|
|
9328
|
-
1,
|
|
9329
|
-
-1,
|
|
9330
|
-
1,
|
|
9331
|
-
1,
|
|
9332
|
-
1,
|
|
9333
|
-
1,
|
|
9334
|
-
-1,
|
|
9335
|
-
1,
|
|
9336
|
-
-1,
|
|
9337
|
-
-1,
|
|
9338
|
-
-1,
|
|
9339
|
-
-1,
|
|
9340
|
-
-1,
|
|
9341
|
-
1,
|
|
9342
|
-
-1,
|
|
9343
|
-
1,
|
|
9344
|
-
1,
|
|
9345
|
-
-1,
|
|
9346
|
-
1,
|
|
9347
|
-
-1
|
|
9348
|
-
]);
|
|
9349
|
-
var CUBE_NORMALS = new Float32Array([
|
|
9350
|
-
// Front face
|
|
9351
|
-
0,
|
|
9352
|
-
0,
|
|
9353
|
-
1,
|
|
9354
|
-
0,
|
|
9355
|
-
0,
|
|
9356
|
-
1,
|
|
9357
|
-
0,
|
|
9358
|
-
0,
|
|
9359
|
-
1,
|
|
9360
|
-
0,
|
|
9361
|
-
0,
|
|
9362
|
-
1,
|
|
9363
|
-
// Back face
|
|
9364
|
-
0,
|
|
9365
|
-
0,
|
|
9366
|
-
-1,
|
|
9367
|
-
0,
|
|
9368
|
-
0,
|
|
9369
|
-
-1,
|
|
9370
|
-
0,
|
|
9371
|
-
0,
|
|
9372
|
-
-1,
|
|
9373
|
-
0,
|
|
9374
|
-
0,
|
|
9375
|
-
-1,
|
|
9376
|
-
// Top face
|
|
9377
|
-
0,
|
|
9378
|
-
1,
|
|
9379
|
-
0,
|
|
9380
|
-
0,
|
|
9381
|
-
1,
|
|
9382
|
-
0,
|
|
9383
|
-
0,
|
|
9384
|
-
1,
|
|
9385
|
-
0,
|
|
9386
|
-
0,
|
|
9387
|
-
1,
|
|
9388
|
-
0,
|
|
9389
|
-
// Bottom face
|
|
9390
|
-
0,
|
|
9391
|
-
-1,
|
|
9392
|
-
0,
|
|
9393
|
-
0,
|
|
9394
|
-
-1,
|
|
9395
|
-
0,
|
|
9396
|
-
0,
|
|
9397
|
-
-1,
|
|
9398
|
-
0,
|
|
9399
|
-
0,
|
|
9400
|
-
-1,
|
|
9401
|
-
0,
|
|
9402
|
-
// Right face
|
|
9403
|
-
1,
|
|
9404
|
-
0,
|
|
9405
|
-
0,
|
|
9406
|
-
1,
|
|
9407
|
-
0,
|
|
9408
|
-
0,
|
|
9409
|
-
1,
|
|
9410
|
-
0,
|
|
9411
|
-
0,
|
|
9412
|
-
1,
|
|
9413
|
-
0,
|
|
9414
|
-
0,
|
|
9415
|
-
// Left face
|
|
9416
|
-
-1,
|
|
9417
|
-
0,
|
|
9418
|
-
0,
|
|
9419
|
-
-1,
|
|
9420
|
-
0,
|
|
9421
|
-
0,
|
|
9422
|
-
-1,
|
|
9423
|
-
0,
|
|
9424
|
-
0,
|
|
9425
|
-
-1,
|
|
9426
|
-
0,
|
|
9427
|
-
0
|
|
9428
|
-
]);
|
|
9429
|
-
var CUBE_TEX_COORDS = new Float32Array([
|
|
9430
|
-
// Front face
|
|
9431
|
-
0,
|
|
9432
|
-
0,
|
|
9433
|
-
1,
|
|
9434
|
-
0,
|
|
9435
|
-
1,
|
|
9436
|
-
1,
|
|
9437
|
-
0,
|
|
9438
|
-
1,
|
|
9439
|
-
// Back face
|
|
9440
|
-
1,
|
|
9441
|
-
0,
|
|
9442
|
-
1,
|
|
9443
|
-
1,
|
|
9444
|
-
0,
|
|
9445
|
-
1,
|
|
9446
|
-
0,
|
|
9447
|
-
0,
|
|
9448
|
-
// Top face
|
|
9449
|
-
0,
|
|
9450
|
-
1,
|
|
9451
|
-
0,
|
|
9452
|
-
0,
|
|
9453
|
-
1,
|
|
9454
|
-
0,
|
|
9455
|
-
1,
|
|
9456
|
-
1,
|
|
9457
|
-
// Bottom face
|
|
9458
|
-
1,
|
|
9459
|
-
1,
|
|
9460
|
-
0,
|
|
9461
|
-
1,
|
|
9462
|
-
0,
|
|
9463
|
-
0,
|
|
9464
|
-
1,
|
|
9465
|
-
0,
|
|
9466
|
-
// Right face
|
|
9467
|
-
1,
|
|
9468
|
-
0,
|
|
9469
|
-
1,
|
|
9470
|
-
1,
|
|
9471
|
-
0,
|
|
9472
|
-
1,
|
|
9473
|
-
0,
|
|
9474
|
-
0,
|
|
9475
|
-
// Left face
|
|
9476
|
-
0,
|
|
9477
|
-
0,
|
|
9478
|
-
1,
|
|
9479
|
-
0,
|
|
9480
|
-
1,
|
|
9481
|
-
1,
|
|
9482
|
-
0,
|
|
9483
|
-
1
|
|
9484
|
-
]);
|
|
9485
|
-
var CUBE_FACE_INDICES = new Uint32Array([
|
|
9486
|
-
0,
|
|
9487
|
-
0,
|
|
9488
|
-
0,
|
|
9489
|
-
0,
|
|
9490
|
-
1,
|
|
9491
|
-
1,
|
|
9492
|
-
1,
|
|
9493
|
-
1,
|
|
9494
|
-
2,
|
|
9495
|
-
2,
|
|
9496
|
-
2,
|
|
9497
|
-
2,
|
|
9498
|
-
3,
|
|
9499
|
-
3,
|
|
9500
|
-
3,
|
|
9501
|
-
3,
|
|
9502
|
-
4,
|
|
9503
|
-
4,
|
|
9504
|
-
4,
|
|
9505
|
-
4,
|
|
9506
|
-
5,
|
|
9507
|
-
5,
|
|
9508
|
-
5,
|
|
9509
|
-
5
|
|
9510
|
-
]);
|
|
9511
|
-
var CUBE_NON_INDEXED_POSITIONS = new Float32Array([
|
|
9512
|
-
1,
|
|
9513
|
-
-1,
|
|
9514
|
-
1,
|
|
9515
|
-
-1,
|
|
9516
|
-
-1,
|
|
9517
|
-
1,
|
|
9518
|
-
-1,
|
|
9519
|
-
-1,
|
|
9520
|
-
-1,
|
|
9521
|
-
1,
|
|
9522
|
-
-1,
|
|
9523
|
-
-1,
|
|
9524
|
-
1,
|
|
9525
|
-
-1,
|
|
9526
|
-
1,
|
|
9527
|
-
-1,
|
|
9528
|
-
-1,
|
|
9529
|
-
-1,
|
|
9530
|
-
1,
|
|
9531
|
-
1,
|
|
9532
|
-
1,
|
|
9533
|
-
1,
|
|
9534
|
-
-1,
|
|
9535
|
-
1,
|
|
9536
|
-
1,
|
|
9537
|
-
-1,
|
|
9538
|
-
-1,
|
|
9539
|
-
1,
|
|
9540
|
-
1,
|
|
9541
|
-
-1,
|
|
9542
|
-
1,
|
|
9543
|
-
1,
|
|
9544
|
-
1,
|
|
9545
|
-
1,
|
|
9546
|
-
-1,
|
|
9547
|
-
-1,
|
|
9548
|
-
-1,
|
|
9549
|
-
1,
|
|
9550
|
-
1,
|
|
9551
|
-
1,
|
|
9552
|
-
1,
|
|
9553
|
-
1,
|
|
9554
|
-
1,
|
|
9555
|
-
1,
|
|
9556
|
-
-1,
|
|
9557
|
-
-1,
|
|
9558
|
-
1,
|
|
9559
|
-
-1,
|
|
9560
|
-
-1,
|
|
9561
|
-
1,
|
|
9562
|
-
1,
|
|
9563
|
-
1,
|
|
9564
|
-
1,
|
|
9565
|
-
-1,
|
|
9566
|
-
-1,
|
|
9567
|
-
-1,
|
|
9568
|
-
1,
|
|
9569
|
-
-1,
|
|
9570
|
-
1,
|
|
9571
|
-
1,
|
|
9572
|
-
-1,
|
|
9573
|
-
1,
|
|
9574
|
-
-1,
|
|
9575
|
-
-1,
|
|
9576
|
-
-1,
|
|
9577
|
-
-1,
|
|
9578
|
-
-1,
|
|
9579
|
-
-1,
|
|
9580
|
-
1,
|
|
9581
|
-
-1,
|
|
9582
|
-
1,
|
|
9583
|
-
-1,
|
|
9584
|
-
1,
|
|
9585
|
-
1,
|
|
9586
|
-
1,
|
|
9587
|
-
-1,
|
|
9588
|
-
1,
|
|
9589
|
-
1,
|
|
9590
|
-
-1,
|
|
9591
|
-
-1,
|
|
9592
|
-
1,
|
|
9593
|
-
-1,
|
|
9594
|
-
-1,
|
|
9595
|
-
1,
|
|
9596
|
-
1,
|
|
9597
|
-
-1,
|
|
9598
|
-
1,
|
|
9599
|
-
1,
|
|
9600
|
-
1,
|
|
9601
|
-
1,
|
|
9602
|
-
1,
|
|
9603
|
-
-1,
|
|
9604
|
-
-1,
|
|
9605
|
-
-1,
|
|
9606
|
-
-1,
|
|
9607
|
-
-1,
|
|
9608
|
-
-1,
|
|
9609
|
-
1,
|
|
9610
|
-
-1,
|
|
9611
|
-
1,
|
|
9612
|
-
1,
|
|
9613
|
-
-1,
|
|
9614
|
-
1,
|
|
9615
|
-
-1,
|
|
9616
|
-
-1,
|
|
9617
|
-
-1,
|
|
9618
|
-
1,
|
|
9619
|
-
-1
|
|
9620
|
-
]);
|
|
9621
|
-
var CUBE_NON_INDEXED_TEX_COORDS = new Float32Array([
|
|
9622
|
-
1,
|
|
9623
|
-
1,
|
|
9624
|
-
0,
|
|
9625
|
-
1,
|
|
9626
|
-
0,
|
|
9627
|
-
0,
|
|
9628
|
-
1,
|
|
9629
|
-
0,
|
|
9630
|
-
1,
|
|
9631
|
-
1,
|
|
9632
|
-
0,
|
|
9633
|
-
0,
|
|
9634
|
-
1,
|
|
9635
|
-
1,
|
|
9636
|
-
0,
|
|
9637
|
-
1,
|
|
9638
|
-
0,
|
|
9639
|
-
0,
|
|
9640
|
-
1,
|
|
9641
|
-
0,
|
|
9642
|
-
1,
|
|
9643
|
-
1,
|
|
9644
|
-
0,
|
|
9645
|
-
0,
|
|
9646
|
-
1,
|
|
9647
|
-
1,
|
|
9648
|
-
0,
|
|
9649
|
-
1,
|
|
9650
|
-
0,
|
|
9651
|
-
0,
|
|
9652
|
-
1,
|
|
9653
|
-
0,
|
|
9654
|
-
1,
|
|
9655
|
-
1,
|
|
9656
|
-
0,
|
|
9657
|
-
0,
|
|
9658
|
-
1,
|
|
9659
|
-
1,
|
|
9660
|
-
0,
|
|
9661
|
-
1,
|
|
9662
|
-
0,
|
|
9663
|
-
0,
|
|
9664
|
-
1,
|
|
9665
|
-
0,
|
|
9666
|
-
1,
|
|
9667
|
-
1,
|
|
9668
|
-
0,
|
|
9669
|
-
0,
|
|
9670
|
-
1,
|
|
9671
|
-
1,
|
|
9672
|
-
0,
|
|
9673
|
-
1,
|
|
9674
|
-
0,
|
|
9675
|
-
0,
|
|
9676
|
-
0,
|
|
9677
|
-
0,
|
|
9678
|
-
1,
|
|
9679
|
-
0,
|
|
9680
|
-
1,
|
|
9681
|
-
1,
|
|
9682
|
-
1,
|
|
9683
|
-
1,
|
|
9684
|
-
0,
|
|
9685
|
-
1,
|
|
9686
|
-
0,
|
|
9687
|
-
0,
|
|
9688
|
-
1,
|
|
9689
|
-
0,
|
|
9690
|
-
1,
|
|
9691
|
-
1,
|
|
9692
|
-
0,
|
|
9693
|
-
0
|
|
9694
|
-
]);
|
|
9695
|
-
var CUBE_NON_INDEXED_COLORS = new Float32Array([
|
|
9696
|
-
1,
|
|
9697
|
-
0,
|
|
9698
|
-
1,
|
|
9699
|
-
1,
|
|
9700
|
-
0,
|
|
9701
|
-
0,
|
|
9702
|
-
1,
|
|
9703
|
-
1,
|
|
9704
|
-
0,
|
|
9705
|
-
0,
|
|
9706
|
-
0,
|
|
9707
|
-
1,
|
|
9708
|
-
1,
|
|
9709
|
-
0,
|
|
9710
|
-
0,
|
|
9711
|
-
1,
|
|
9712
|
-
1,
|
|
9713
|
-
0,
|
|
9714
|
-
1,
|
|
9715
|
-
1,
|
|
9716
|
-
0,
|
|
9717
|
-
0,
|
|
9718
|
-
0,
|
|
9719
|
-
1,
|
|
9720
|
-
1,
|
|
9721
|
-
1,
|
|
9722
|
-
1,
|
|
9723
|
-
1,
|
|
9724
|
-
1,
|
|
9725
|
-
0,
|
|
9726
|
-
1,
|
|
9727
|
-
1,
|
|
9728
|
-
1,
|
|
9729
|
-
0,
|
|
9730
|
-
0,
|
|
9731
|
-
1,
|
|
9732
|
-
1,
|
|
9733
|
-
1,
|
|
9734
|
-
0,
|
|
9735
|
-
1,
|
|
9736
|
-
1,
|
|
9737
|
-
1,
|
|
9738
|
-
1,
|
|
9739
|
-
1,
|
|
9740
|
-
1,
|
|
9741
|
-
0,
|
|
9742
|
-
0,
|
|
9743
|
-
1,
|
|
9744
|
-
0,
|
|
9745
|
-
1,
|
|
9746
|
-
1,
|
|
9747
|
-
1,
|
|
9748
|
-
1,
|
|
9749
|
-
1,
|
|
9750
|
-
1,
|
|
9751
|
-
1,
|
|
9752
|
-
1,
|
|
9753
|
-
1,
|
|
9754
|
-
0,
|
|
9755
|
-
1,
|
|
9756
|
-
0,
|
|
9757
|
-
1,
|
|
9758
|
-
0,
|
|
9759
|
-
1,
|
|
9760
|
-
0,
|
|
9761
|
-
1,
|
|
9762
|
-
1,
|
|
9763
|
-
1,
|
|
9764
|
-
1,
|
|
9765
|
-
1,
|
|
9766
|
-
0,
|
|
9767
|
-
1,
|
|
9768
|
-
0,
|
|
9769
|
-
0,
|
|
9770
|
-
1,
|
|
9771
|
-
1,
|
|
9772
|
-
0,
|
|
9773
|
-
1,
|
|
9774
|
-
1,
|
|
9775
|
-
1,
|
|
9776
|
-
0,
|
|
9777
|
-
1,
|
|
9778
|
-
0,
|
|
9779
|
-
1,
|
|
9780
|
-
0,
|
|
9781
|
-
0,
|
|
9782
|
-
0,
|
|
9783
|
-
1,
|
|
9784
|
-
0,
|
|
9785
|
-
0,
|
|
9786
|
-
1,
|
|
9787
|
-
1,
|
|
9788
|
-
0,
|
|
9789
|
-
1,
|
|
9790
|
-
0,
|
|
9791
|
-
1,
|
|
9792
|
-
1,
|
|
9793
|
-
1,
|
|
9794
|
-
1,
|
|
9795
|
-
1,
|
|
9796
|
-
0,
|
|
9797
|
-
1,
|
|
9798
|
-
1,
|
|
9799
|
-
1,
|
|
9800
|
-
0,
|
|
9801
|
-
0,
|
|
9802
|
-
1,
|
|
9803
|
-
1,
|
|
9804
|
-
0,
|
|
9805
|
-
0,
|
|
9806
|
-
1,
|
|
9807
|
-
1,
|
|
9808
|
-
1,
|
|
9809
|
-
0,
|
|
9810
|
-
1,
|
|
9811
|
-
1,
|
|
9812
|
-
1,
|
|
9813
|
-
1,
|
|
9814
|
-
1,
|
|
9815
|
-
1,
|
|
9816
|
-
1,
|
|
9817
|
-
0,
|
|
9818
|
-
0,
|
|
9819
|
-
1,
|
|
9820
|
-
0,
|
|
9821
|
-
0,
|
|
9822
|
-
0,
|
|
9823
|
-
1,
|
|
9824
|
-
0,
|
|
9825
|
-
1,
|
|
9826
|
-
0,
|
|
9827
|
-
1,
|
|
9828
|
-
1,
|
|
9829
|
-
1,
|
|
9830
|
-
0,
|
|
9831
|
-
1,
|
|
9832
|
-
1,
|
|
9833
|
-
0,
|
|
9834
|
-
0,
|
|
9835
|
-
1,
|
|
9836
|
-
0,
|
|
9837
|
-
1,
|
|
9838
|
-
0,
|
|
9839
|
-
1
|
|
9840
|
-
]);
|
|
9841
|
-
var CUBE_NON_INDEXED_FACE_INDICES = new Uint32Array([
|
|
9842
|
-
3,
|
|
9843
|
-
3,
|
|
9844
|
-
3,
|
|
9845
|
-
3,
|
|
9846
|
-
3,
|
|
9847
|
-
3,
|
|
9848
|
-
4,
|
|
9849
|
-
4,
|
|
9850
|
-
4,
|
|
9851
|
-
4,
|
|
9852
|
-
4,
|
|
9853
|
-
4,
|
|
9854
|
-
2,
|
|
9855
|
-
2,
|
|
9856
|
-
2,
|
|
9857
|
-
2,
|
|
9858
|
-
2,
|
|
9859
|
-
2,
|
|
9860
|
-
5,
|
|
9861
|
-
5,
|
|
9862
|
-
5,
|
|
9863
|
-
5,
|
|
9864
|
-
5,
|
|
9865
|
-
5,
|
|
9866
|
-
0,
|
|
9867
|
-
0,
|
|
9868
|
-
0,
|
|
9869
|
-
0,
|
|
9870
|
-
0,
|
|
9871
|
-
0,
|
|
9872
|
-
1,
|
|
9873
|
-
1,
|
|
9874
|
-
1,
|
|
9875
|
-
1,
|
|
9876
|
-
1,
|
|
9877
|
-
1
|
|
9878
|
-
]);
|
|
9879
|
-
var ATTRIBUTES = {
|
|
9880
|
-
POSITION: { size: 3, value: CUBE_POSITIONS },
|
|
9881
|
-
NORMAL: { size: 3, value: CUBE_NORMALS },
|
|
9882
|
-
TEXCOORD_0: { size: 2, value: CUBE_TEX_COORDS },
|
|
9883
|
-
faceIndex: { size: 1, value: CUBE_FACE_INDICES }
|
|
9884
|
-
};
|
|
9885
|
-
var NON_INDEXED_ATTRIBUTES = {
|
|
9886
|
-
POSITION: { size: 3, value: CUBE_NON_INDEXED_POSITIONS },
|
|
9887
|
-
// NORMAL: {size: 3, value: CUBE_NON_INDEXED_NORMALS},
|
|
9888
|
-
TEXCOORD_0: { size: 2, value: CUBE_NON_INDEXED_TEX_COORDS },
|
|
9889
|
-
COLOR_0: { size: 3, value: CUBE_NON_INDEXED_COLORS },
|
|
9890
|
-
faceIndex: { size: 1, value: CUBE_NON_INDEXED_FACE_INDICES }
|
|
9891
|
-
};
|
|
9892
|
-
|
|
9893
|
-
// src/geometries/cylinder-geometry.ts
|
|
9894
|
-
var CylinderGeometry = class extends TruncatedConeGeometry {
|
|
9895
|
-
constructor(props = {}) {
|
|
9896
|
-
const { id = uid("cylinder-geometry"), radius = 1 } = props;
|
|
9897
|
-
super({
|
|
9898
|
-
...props,
|
|
9899
|
-
id,
|
|
9900
|
-
bottomRadius: radius,
|
|
9901
|
-
topRadius: radius
|
|
9902
|
-
});
|
|
9903
|
-
}
|
|
9904
|
-
};
|
|
9905
|
-
|
|
9906
|
-
// src/geometries/ico-sphere-geometry.ts
|
|
9907
|
-
var ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
|
|
9908
|
-
var ICO_INDICES = [3, 4, 5, 3, 5, 1, 3, 1, 0, 3, 0, 4, 4, 0, 2, 4, 2, 5, 2, 0, 1, 5, 2, 1];
|
|
9909
|
-
var IcoSphereGeometry = class extends Geometry {
|
|
9910
|
-
constructor(props = {}) {
|
|
9911
|
-
const { id = uid("ico-sphere-geometry") } = props;
|
|
9912
|
-
const { indices, attributes } = tesselateIcosaHedron(props);
|
|
9913
|
-
super({
|
|
9914
|
-
...props,
|
|
9915
|
-
id,
|
|
9916
|
-
topology: "triangle-list",
|
|
9917
|
-
indices,
|
|
9918
|
-
attributes: { ...attributes, ...props.attributes }
|
|
9919
|
-
});
|
|
9920
|
-
}
|
|
9921
|
-
};
|
|
9922
|
-
function tesselateIcosaHedron(props) {
|
|
9923
|
-
const { iterations = 0 } = props;
|
|
9924
|
-
const PI = Math.PI;
|
|
9925
|
-
const PI2 = PI * 2;
|
|
9926
|
-
const positions = [...ICO_POSITIONS];
|
|
9927
|
-
let indices = [...ICO_INDICES];
|
|
9928
|
-
positions.push();
|
|
9929
|
-
indices.push();
|
|
9930
|
-
const getMiddlePoint = /* @__PURE__ */ (() => {
|
|
9931
|
-
const pointMemo = {};
|
|
9932
|
-
return (i1, i2) => {
|
|
9933
|
-
i1 *= 3;
|
|
9934
|
-
i2 *= 3;
|
|
9935
|
-
const mini = i1 < i2 ? i1 : i2;
|
|
9936
|
-
const maxi = i1 > i2 ? i1 : i2;
|
|
9937
|
-
const key = `${mini}|${maxi}`;
|
|
9938
|
-
if (key in pointMemo) {
|
|
9939
|
-
return pointMemo[key];
|
|
9940
|
-
}
|
|
9941
|
-
const x1 = positions[i1];
|
|
9942
|
-
const y1 = positions[i1 + 1];
|
|
9943
|
-
const z1 = positions[i1 + 2];
|
|
9944
|
-
const x2 = positions[i2];
|
|
9945
|
-
const y2 = positions[i2 + 1];
|
|
9946
|
-
const z2 = positions[i2 + 2];
|
|
9947
|
-
let xm = (x1 + x2) / 2;
|
|
9948
|
-
let ym = (y1 + y2) / 2;
|
|
9949
|
-
let zm = (z1 + z2) / 2;
|
|
9950
|
-
const len = Math.sqrt(xm * xm + ym * ym + zm * zm);
|
|
9951
|
-
xm /= len;
|
|
9952
|
-
ym /= len;
|
|
9953
|
-
zm /= len;
|
|
9954
|
-
positions.push(xm, ym, zm);
|
|
9955
|
-
const pointIndex = positions.length / 3 - 1;
|
|
9956
|
-
pointMemo[key] = pointIndex;
|
|
9957
|
-
return pointIndex;
|
|
9958
|
-
};
|
|
9959
|
-
})();
|
|
9960
|
-
for (let i = 0; i < iterations; i++) {
|
|
9961
|
-
const indices2 = [];
|
|
9962
|
-
for (let j = 0; j < indices.length; j += 3) {
|
|
9963
|
-
const a = getMiddlePoint(indices[j + 0], indices[j + 1]);
|
|
9964
|
-
const b = getMiddlePoint(indices[j + 1], indices[j + 2]);
|
|
9965
|
-
const c = getMiddlePoint(indices[j + 2], indices[j + 0]);
|
|
9966
|
-
indices2.push(c, indices[j + 0], a, a, indices[j + 1], b, b, indices[j + 2], c, a, b, c);
|
|
9967
|
-
}
|
|
9968
|
-
indices = indices2;
|
|
9969
|
-
}
|
|
9970
|
-
const normals = new Array(positions.length);
|
|
9971
|
-
const texCoords = new Array(positions.length / 3 * 2);
|
|
9972
|
-
const l = indices.length;
|
|
9973
|
-
for (let i = l - 3; i >= 0; i -= 3) {
|
|
9974
|
-
const i1 = indices[i + 0];
|
|
9975
|
-
const i2 = indices[i + 1];
|
|
9976
|
-
const i3 = indices[i + 2];
|
|
9977
|
-
const in1 = i1 * 3;
|
|
9978
|
-
const in2 = i2 * 3;
|
|
9979
|
-
const in3 = i3 * 3;
|
|
9980
|
-
const iu1 = i1 * 2;
|
|
9981
|
-
const iu2 = i2 * 2;
|
|
9982
|
-
const iu3 = i3 * 2;
|
|
9983
|
-
const x1 = positions[in1 + 0];
|
|
9984
|
-
const y1 = positions[in1 + 1];
|
|
9985
|
-
const z1 = positions[in1 + 2];
|
|
9986
|
-
const theta1 = Math.acos(z1 / Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1));
|
|
9987
|
-
const phi1 = Math.atan2(y1, x1) + PI;
|
|
9988
|
-
const v1 = theta1 / PI;
|
|
9989
|
-
const u1 = 1 - phi1 / PI2;
|
|
9990
|
-
const x2 = positions[in2 + 0];
|
|
9991
|
-
const y2 = positions[in2 + 1];
|
|
9992
|
-
const z2 = positions[in2 + 2];
|
|
9993
|
-
const theta2 = Math.acos(z2 / Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2));
|
|
9994
|
-
const phi2 = Math.atan2(y2, x2) + PI;
|
|
9995
|
-
const v2 = theta2 / PI;
|
|
9996
|
-
const u2 = 1 - phi2 / PI2;
|
|
9997
|
-
const x3 = positions[in3 + 0];
|
|
9998
|
-
const y3 = positions[in3 + 1];
|
|
9999
|
-
const z3 = positions[in3 + 2];
|
|
10000
|
-
const theta3 = Math.acos(z3 / Math.sqrt(x3 * x3 + y3 * y3 + z3 * z3));
|
|
10001
|
-
const phi3 = Math.atan2(y3, x3) + PI;
|
|
10002
|
-
const v3 = theta3 / PI;
|
|
10003
|
-
const u3 = 1 - phi3 / PI2;
|
|
10004
|
-
const vec1 = [x3 - x2, y3 - y2, z3 - z2];
|
|
10005
|
-
const vec2 = [x1 - x2, y1 - y2, z1 - z2];
|
|
10006
|
-
const normal = new Vector3(vec1).cross(vec2).normalize();
|
|
10007
|
-
let newIndex;
|
|
10008
|
-
if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
|
|
10009
|
-
positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
|
|
10010
|
-
newIndex = positions.length / 3 - 1;
|
|
10011
|
-
indices.push(newIndex);
|
|
10012
|
-
texCoords[newIndex * 2 + 0] = 1;
|
|
10013
|
-
texCoords[newIndex * 2 + 1] = v1;
|
|
10014
|
-
normals[newIndex * 3 + 0] = normal.x;
|
|
10015
|
-
normals[newIndex * 3 + 1] = normal.y;
|
|
10016
|
-
normals[newIndex * 3 + 2] = normal.z;
|
|
10017
|
-
positions.push(positions[in2 + 0], positions[in2 + 1], positions[in2 + 2]);
|
|
10018
|
-
newIndex = positions.length / 3 - 1;
|
|
10019
|
-
indices.push(newIndex);
|
|
10020
|
-
texCoords[newIndex * 2 + 0] = 1;
|
|
10021
|
-
texCoords[newIndex * 2 + 1] = v2;
|
|
10022
|
-
normals[newIndex * 3 + 0] = normal.x;
|
|
10023
|
-
normals[newIndex * 3 + 1] = normal.y;
|
|
10024
|
-
normals[newIndex * 3 + 2] = normal.z;
|
|
10025
|
-
positions.push(positions[in3 + 0], positions[in3 + 1], positions[in3 + 2]);
|
|
10026
|
-
newIndex = positions.length / 3 - 1;
|
|
10027
|
-
indices.push(newIndex);
|
|
10028
|
-
texCoords[newIndex * 2 + 0] = 1;
|
|
10029
|
-
texCoords[newIndex * 2 + 1] = v3;
|
|
10030
|
-
normals[newIndex * 3 + 0] = normal.x;
|
|
10031
|
-
normals[newIndex * 3 + 1] = normal.y;
|
|
10032
|
-
normals[newIndex * 3 + 2] = normal.z;
|
|
10033
|
-
}
|
|
10034
|
-
normals[in1 + 0] = normals[in2 + 0] = normals[in3 + 0] = normal.x;
|
|
10035
|
-
normals[in1 + 1] = normals[in2 + 1] = normals[in3 + 1] = normal.y;
|
|
10036
|
-
normals[in1 + 2] = normals[in2 + 2] = normals[in3 + 2] = normal.z;
|
|
10037
|
-
texCoords[iu1 + 0] = u1;
|
|
10038
|
-
texCoords[iu1 + 1] = v1;
|
|
10039
|
-
texCoords[iu2 + 0] = u2;
|
|
10040
|
-
texCoords[iu2 + 1] = v2;
|
|
10041
|
-
texCoords[iu3 + 0] = u3;
|
|
10042
|
-
texCoords[iu3 + 1] = v3;
|
|
10043
|
-
}
|
|
10044
|
-
return {
|
|
10045
|
-
indices: { size: 1, value: new Uint16Array(indices) },
|
|
10046
|
-
attributes: {
|
|
10047
|
-
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
10048
|
-
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
10049
|
-
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) }
|
|
10050
|
-
}
|
|
10051
|
-
};
|
|
10052
|
-
}
|
|
10053
|
-
|
|
10054
|
-
// src/geometries/plane-geometry.ts
|
|
10055
|
-
var PlaneGeometry = class extends Geometry {
|
|
10056
|
-
constructor(props = {}) {
|
|
10057
|
-
const { id = uid("plane-geometry") } = props;
|
|
10058
|
-
const { indices, attributes } = tesselatePlane(props);
|
|
10059
|
-
super({
|
|
10060
|
-
...props,
|
|
10061
|
-
id,
|
|
10062
|
-
topology: "triangle-list",
|
|
10063
|
-
indices,
|
|
10064
|
-
attributes: { ...attributes, ...props.attributes }
|
|
10065
|
-
});
|
|
10066
|
-
}
|
|
10067
|
-
};
|
|
10068
|
-
function tesselatePlane(props) {
|
|
10069
|
-
const { type = "x,y", offset = 0, flipCull = false, unpack = false } = props;
|
|
10070
|
-
const coords = type.split(",");
|
|
10071
|
-
let c1len = props[`${coords[0]}len`] || 1;
|
|
10072
|
-
const c2len = props[`${coords[1]}len`] || 1;
|
|
10073
|
-
const subdivisions1 = props[`n${coords[0]}`] || 1;
|
|
10074
|
-
const subdivisions2 = props[`n${coords[1]}`] || 1;
|
|
10075
|
-
const numVertices = (subdivisions1 + 1) * (subdivisions2 + 1);
|
|
10076
|
-
const positions = new Float32Array(numVertices * 3);
|
|
10077
|
-
const normals = new Float32Array(numVertices * 3);
|
|
10078
|
-
const texCoords = new Float32Array(numVertices * 2);
|
|
10079
|
-
if (flipCull) {
|
|
10080
|
-
c1len = -c1len;
|
|
10081
|
-
}
|
|
10082
|
-
let i2 = 0;
|
|
10083
|
-
let i3 = 0;
|
|
10084
|
-
for (let z = 0; z <= subdivisions2; z++) {
|
|
10085
|
-
for (let x = 0; x <= subdivisions1; x++) {
|
|
10086
|
-
const u = x / subdivisions1;
|
|
10087
|
-
const v = z / subdivisions2;
|
|
10088
|
-
texCoords[i2 + 0] = flipCull ? 1 - u : u;
|
|
10089
|
-
texCoords[i2 + 1] = v;
|
|
10090
|
-
switch (type) {
|
|
10091
|
-
case "x,y":
|
|
10092
|
-
positions[i3 + 0] = c1len * u - c1len * 0.5;
|
|
10093
|
-
positions[i3 + 1] = c2len * v - c2len * 0.5;
|
|
10094
|
-
positions[i3 + 2] = offset;
|
|
10095
|
-
normals[i3 + 0] = 0;
|
|
10096
|
-
normals[i3 + 1] = 0;
|
|
10097
|
-
normals[i3 + 2] = flipCull ? 1 : -1;
|
|
10098
|
-
break;
|
|
10099
|
-
case "x,z":
|
|
10100
|
-
positions[i3 + 0] = c1len * u - c1len * 0.5;
|
|
10101
|
-
positions[i3 + 1] = offset;
|
|
10102
|
-
positions[i3 + 2] = c2len * v - c2len * 0.5;
|
|
10103
|
-
normals[i3 + 0] = 0;
|
|
10104
|
-
normals[i3 + 1] = flipCull ? 1 : -1;
|
|
10105
|
-
normals[i3 + 2] = 0;
|
|
10106
|
-
break;
|
|
10107
|
-
case "y,z":
|
|
10108
|
-
positions[i3 + 0] = offset;
|
|
10109
|
-
positions[i3 + 1] = c1len * u - c1len * 0.5;
|
|
10110
|
-
positions[i3 + 2] = c2len * v - c2len * 0.5;
|
|
10111
|
-
normals[i3 + 0] = flipCull ? 1 : -1;
|
|
10112
|
-
normals[i3 + 1] = 0;
|
|
10113
|
-
normals[i3 + 2] = 0;
|
|
10114
|
-
break;
|
|
10115
|
-
default:
|
|
10116
|
-
throw new Error("PlaneGeometry: unknown type");
|
|
10117
|
-
}
|
|
10118
|
-
i2 += 2;
|
|
10119
|
-
i3 += 3;
|
|
10120
|
-
}
|
|
10121
|
-
}
|
|
10122
|
-
const numVertsAcross = subdivisions1 + 1;
|
|
10123
|
-
const indices = new Uint16Array(subdivisions1 * subdivisions2 * 6);
|
|
10124
|
-
for (let z = 0; z < subdivisions2; z++) {
|
|
10125
|
-
for (let x = 0; x < subdivisions1; x++) {
|
|
10126
|
-
const index = (z * subdivisions1 + x) * 6;
|
|
10127
|
-
indices[index + 0] = (z + 0) * numVertsAcross + x;
|
|
10128
|
-
indices[index + 1] = (z + 1) * numVertsAcross + x;
|
|
10129
|
-
indices[index + 2] = (z + 0) * numVertsAcross + x + 1;
|
|
10130
|
-
indices[index + 3] = (z + 1) * numVertsAcross + x;
|
|
10131
|
-
indices[index + 4] = (z + 1) * numVertsAcross + x + 1;
|
|
10132
|
-
indices[index + 5] = (z + 0) * numVertsAcross + x + 1;
|
|
10133
|
-
}
|
|
10134
|
-
}
|
|
10135
|
-
const geometry = {
|
|
10136
|
-
indices: { size: 1, value: indices },
|
|
10137
|
-
attributes: {
|
|
10138
|
-
POSITION: { size: 3, value: positions },
|
|
10139
|
-
NORMAL: { size: 3, value: normals },
|
|
10140
|
-
TEXCOORD_0: { size: 2, value: texCoords }
|
|
10141
|
-
}
|
|
10142
|
-
};
|
|
10143
|
-
return unpack ? unpackIndexedGeometry(geometry) : geometry;
|
|
10144
|
-
}
|
|
10145
|
-
|
|
10146
9524
|
// src/application-utils/random.ts
|
|
10147
9525
|
function makeRandomGenerator() {
|
|
10148
9526
|
let s = 1;
|
|
@@ -10205,7 +9583,7 @@ void main(void) {
|
|
|
10205
9583
|
}
|
|
10206
9584
|
|
|
10207
9585
|
// src/dynamic-texture/video-texture.ts
|
|
10208
|
-
var
|
|
9586
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
10209
9587
|
var VideoTexture = class {
|
|
10210
9588
|
/** Device used to create copied and native external texture bindings. */
|
|
10211
9589
|
device;
|
|
@@ -10254,7 +9632,7 @@ void main(void) {
|
|
|
10254
9632
|
* @param props Live video source and copied texture options.
|
|
10255
9633
|
*/
|
|
10256
9634
|
constructor(device, props) {
|
|
10257
|
-
(0,
|
|
9635
|
+
(0, import_core26.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
10258
9636
|
this.device = device;
|
|
10259
9637
|
this.id = props.id || uid("video-texture");
|
|
10260
9638
|
this._source = props.source;
|
|
@@ -10268,7 +9646,7 @@ void main(void) {
|
|
|
10268
9646
|
* @param source Next caller-owned video source to follow.
|
|
10269
9647
|
*/
|
|
10270
9648
|
setSource(source4) {
|
|
10271
|
-
(0,
|
|
9649
|
+
(0, import_core26.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
10272
9650
|
this._destroyExternalTexture();
|
|
10273
9651
|
this._source = source4;
|
|
10274
9652
|
this._sourceVersion++;
|
|
@@ -10346,7 +9724,7 @@ void main(void) {
|
|
|
10346
9724
|
width: size.width,
|
|
10347
9725
|
height: size.height,
|
|
10348
9726
|
format: "rgba8unorm",
|
|
10349
|
-
usage:
|
|
9727
|
+
usage: import_core26.Texture.SAMPLE | import_core26.Texture.COPY_DST,
|
|
10350
9728
|
mipLevels: 1,
|
|
10351
9729
|
sampler: this._sampler
|
|
10352
9730
|
});
|
|
@@ -10381,7 +9759,7 @@ void main(void) {
|
|
|
10381
9759
|
*/
|
|
10382
9760
|
_getResolvedSize() {
|
|
10383
9761
|
const size = getVideoTextureSourceSize(this._source);
|
|
10384
|
-
(0,
|
|
9762
|
+
(0, import_core26.assert)(size.width > 0 && size.height > 0);
|
|
10385
9763
|
return size;
|
|
10386
9764
|
}
|
|
10387
9765
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -10446,11 +9824,11 @@ void main(void) {
|
|
|
10446
9824
|
}
|
|
10447
9825
|
|
|
10448
9826
|
// src/passes/shader-pass-renderer.ts
|
|
10449
|
-
var
|
|
9827
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
10450
9828
|
var import_shadertools7 = __toESM(require_shadertools(), 1);
|
|
10451
9829
|
|
|
10452
9830
|
// src/compute/swap.ts
|
|
10453
|
-
var
|
|
9831
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
10454
9832
|
var Swap = class {
|
|
10455
9833
|
id;
|
|
10456
9834
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -10482,7 +9860,7 @@ void main(void) {
|
|
|
10482
9860
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
10483
9861
|
id: `${props.id}-texture-0`,
|
|
10484
9862
|
format: colorAttachment,
|
|
10485
|
-
usage:
|
|
9863
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST,
|
|
10486
9864
|
width,
|
|
10487
9865
|
height
|
|
10488
9866
|
})
|
|
@@ -10492,7 +9870,7 @@ void main(void) {
|
|
|
10492
9870
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
10493
9871
|
id: `${props.id}-texture-1`,
|
|
10494
9872
|
format: colorAttachment,
|
|
10495
|
-
usage:
|
|
9873
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.RENDER | import_core27.Texture.COPY_SRC | import_core27.Texture.COPY_DST,
|
|
10496
9874
|
width,
|
|
10497
9875
|
height
|
|
10498
9876
|
})
|
|
@@ -10556,7 +9934,7 @@ void main(void) {
|
|
|
10556
9934
|
};
|
|
10557
9935
|
|
|
10558
9936
|
// src/compute/computation.ts
|
|
10559
|
-
var
|
|
9937
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
10560
9938
|
var import_shadertools6 = __toESM(require_shadertools(), 1);
|
|
10561
9939
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
10562
9940
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -10568,13 +9946,13 @@ void main(void) {
|
|
|
10568
9946
|
* constructor remains the synchronous compatibility path.
|
|
10569
9947
|
*/
|
|
10570
9948
|
static async createAsync(device, props) {
|
|
10571
|
-
const ownsCompilation = !
|
|
10572
|
-
const asyncCompilation = ownsCompilation ?
|
|
9949
|
+
const ownsCompilation = !import_core28.PipelineFactory.getAsyncCompilation(device);
|
|
9950
|
+
const asyncCompilation = ownsCompilation ? import_core28.PipelineFactory.beginAsyncCompilation(device) : import_core28.PipelineFactory.getAsyncCompilation(device);
|
|
10573
9951
|
let computation;
|
|
10574
9952
|
try {
|
|
10575
9953
|
computation = new _Computation(device, props);
|
|
10576
9954
|
} finally {
|
|
10577
|
-
if (ownsCompilation)
|
|
9955
|
+
if (ownsCompilation) import_core28.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
10578
9956
|
}
|
|
10579
9957
|
try {
|
|
10580
9958
|
if (ownsCompilation) {
|
|
@@ -10589,7 +9967,7 @@ void main(void) {
|
|
|
10589
9967
|
}
|
|
10590
9968
|
}
|
|
10591
9969
|
static defaultProps = {
|
|
10592
|
-
...
|
|
9970
|
+
...import_core28.ComputePipeline.defaultProps,
|
|
10593
9971
|
id: "unnamed",
|
|
10594
9972
|
handle: void 0,
|
|
10595
9973
|
userData: {},
|
|
@@ -10655,10 +10033,10 @@ void main(void) {
|
|
|
10655
10033
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
10656
10034
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
10657
10035
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
10658
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
10659
|
-
this.shaderFactory = props.shaderFactory ||
|
|
10036
|
+
this.pipelineFactory = props.pipelineFactory || import_core28.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
10037
|
+
this.shaderFactory = props.shaderFactory || import_core28.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
10660
10038
|
const shaderAssembler = this.props.shaderAssembler;
|
|
10661
|
-
(0,
|
|
10039
|
+
(0, import_core28.assert)(shaderAssembler instanceof import_shadertools6.WGSLShaderAssembler);
|
|
10662
10040
|
const {
|
|
10663
10041
|
source: source4,
|
|
10664
10042
|
getUniforms: getUniforms2,
|
|
@@ -10682,7 +10060,7 @@ void main(void) {
|
|
|
10682
10060
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
10683
10061
|
modules
|
|
10684
10062
|
) || null;
|
|
10685
|
-
const asyncCompilation =
|
|
10063
|
+
const asyncCompilation = import_core28.PipelineFactory.getAsyncCompilation(this.device);
|
|
10686
10064
|
if (asyncCompilation) {
|
|
10687
10065
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
10688
10066
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -10749,7 +10127,7 @@ void main(void) {
|
|
|
10749
10127
|
}
|
|
10750
10128
|
setShaderInputs(shaderInputs) {
|
|
10751
10129
|
this.shaderInputs = shaderInputs;
|
|
10752
|
-
this._uniformStore = new
|
|
10130
|
+
this._uniformStore = new import_core28.UniformStore(this.device, this.shaderInputs.modules);
|
|
10753
10131
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
10754
10132
|
if (shaderModuleHasUniforms(module)) {
|
|
10755
10133
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -10818,7 +10196,7 @@ void main(void) {
|
|
|
10818
10196
|
if (!this._pipelineNeedsUpdate) return null;
|
|
10819
10197
|
const previousShader = this.pipeline ? this.shader : null;
|
|
10820
10198
|
if (this.pipeline) {
|
|
10821
|
-
|
|
10199
|
+
import_core28.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
10822
10200
|
}
|
|
10823
10201
|
this._pipelineNeedsUpdate = false;
|
|
10824
10202
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -10836,27 +10214,27 @@ void main(void) {
|
|
|
10836
10214
|
_lastLogTime = 0;
|
|
10837
10215
|
_logOpen = false;
|
|
10838
10216
|
_logDrawCallStart() {
|
|
10839
|
-
const logDrawTimeout =
|
|
10840
|
-
if (
|
|
10217
|
+
const logDrawTimeout = import_core28.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
10218
|
+
if (import_core28.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
10841
10219
|
return;
|
|
10842
10220
|
}
|
|
10843
10221
|
this._lastLogTime = Date.now();
|
|
10844
10222
|
this._logOpen = true;
|
|
10845
|
-
|
|
10223
|
+
import_core28.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core28.log.level <= 2 })();
|
|
10846
10224
|
}
|
|
10847
10225
|
_logDrawCallEnd() {
|
|
10848
10226
|
if (this._logOpen) {
|
|
10849
10227
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
10850
|
-
|
|
10851
|
-
|
|
10228
|
+
import_core28.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
10229
|
+
import_core28.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
10852
10230
|
this._logOpen = false;
|
|
10853
10231
|
}
|
|
10854
10232
|
}
|
|
10855
10233
|
_drawCount = 0;
|
|
10856
10234
|
// TODO - fix typing of luma data types
|
|
10857
10235
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
10858
|
-
const TypedArrayConstructor =
|
|
10859
|
-
const typedArray = attribute instanceof
|
|
10236
|
+
const TypedArrayConstructor = import_core28.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
10237
|
+
const typedArray = attribute instanceof import_core28.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
10860
10238
|
return typedArray.toString();
|
|
10861
10239
|
}
|
|
10862
10240
|
};
|
|
@@ -11424,7 +10802,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11424
10802
|
this.parameterBuffer = device.createBuffer({
|
|
11425
10803
|
id: `${optimization.name}-parameters`,
|
|
11426
10804
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
11427
|
-
usage:
|
|
10805
|
+
usage: import_core29.Buffer.UNIFORM | import_core29.Buffer.COPY_DST
|
|
11428
10806
|
});
|
|
11429
10807
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
11430
10808
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -11709,7 +11087,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11709
11087
|
width: targetSize[0],
|
|
11710
11088
|
height: targetSize[1],
|
|
11711
11089
|
format: spec.format || device.preferredColorFormat,
|
|
11712
|
-
usage:
|
|
11090
|
+
usage: import_core29.Texture.SAMPLE | import_core29.Texture.RENDER | import_core29.Texture.COPY_SRC | import_core29.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core29.Texture.STORAGE : 0),
|
|
11713
11091
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
11714
11092
|
});
|
|
11715
11093
|
const framebuffer = device.createFramebuffer({
|
|
@@ -11764,17 +11142,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11764
11142
|
}
|
|
11765
11143
|
|
|
11766
11144
|
// src/compute/kernel.ts
|
|
11767
|
-
var
|
|
11145
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
11768
11146
|
var Kernel = class _Kernel {
|
|
11769
11147
|
/** Creates a kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
11770
11148
|
static async createAsync(device, props) {
|
|
11771
|
-
const ownsCompilation = !
|
|
11772
|
-
const asyncCompilation = ownsCompilation ?
|
|
11149
|
+
const ownsCompilation = !import_core30.PipelineFactory.getAsyncCompilation(device);
|
|
11150
|
+
const asyncCompilation = ownsCompilation ? import_core30.PipelineFactory.beginAsyncCompilation(device) : import_core30.PipelineFactory.getAsyncCompilation(device);
|
|
11773
11151
|
let kernel;
|
|
11774
11152
|
try {
|
|
11775
11153
|
kernel = new _Kernel(device, props);
|
|
11776
11154
|
} finally {
|
|
11777
|
-
if (ownsCompilation)
|
|
11155
|
+
if (ownsCompilation) import_core30.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
11778
11156
|
}
|
|
11779
11157
|
try {
|
|
11780
11158
|
if (ownsCompilation) {
|
|
@@ -11805,8 +11183,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11805
11183
|
this.device = device;
|
|
11806
11184
|
this.id = props.id ?? "kernel";
|
|
11807
11185
|
this.source = source4;
|
|
11808
|
-
this.pipelineFactory = pipelineFactory ??
|
|
11809
|
-
this.shaderFactory = shaderFactory ??
|
|
11186
|
+
this.pipelineFactory = pipelineFactory ?? import_core30.PipelineFactory.getDefaultPipelineFactory(device);
|
|
11187
|
+
this.shaderFactory = shaderFactory ?? import_core30.ShaderFactory.getDefaultShaderFactory(device);
|
|
11810
11188
|
this.shader = this.shaderFactory.createShader({
|
|
11811
11189
|
id: `${this.id}-compute`,
|
|
11812
11190
|
stage: "compute",
|
|
@@ -11814,7 +11192,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11814
11192
|
debugShaders
|
|
11815
11193
|
});
|
|
11816
11194
|
const computePipelineProps = { ...pipelineProps, shader: this.shader };
|
|
11817
|
-
const asyncCompilation =
|
|
11195
|
+
const asyncCompilation = import_core30.PipelineFactory.getAsyncCompilation(device);
|
|
11818
11196
|
if (asyncCompilation) {
|
|
11819
11197
|
const pipelineInitialization = this.pipelineFactory.createComputePipelineAsync(computePipelineProps);
|
|
11820
11198
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -11851,17 +11229,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11851
11229
|
};
|
|
11852
11230
|
|
|
11853
11231
|
// src/compute/render-kernel.ts
|
|
11854
|
-
var
|
|
11232
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
11855
11233
|
var RenderKernel = class _RenderKernel {
|
|
11856
11234
|
/** Creates a render kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
11857
11235
|
static async createAsync(device, props) {
|
|
11858
|
-
const ownsCompilation = !
|
|
11859
|
-
const asyncCompilation = ownsCompilation ?
|
|
11236
|
+
const ownsCompilation = !import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11237
|
+
const asyncCompilation = ownsCompilation ? import_core31.PipelineFactory.beginAsyncCompilation(device) : import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11860
11238
|
let kernel;
|
|
11861
11239
|
try {
|
|
11862
11240
|
kernel = new _RenderKernel(device, props);
|
|
11863
11241
|
} finally {
|
|
11864
|
-
if (ownsCompilation)
|
|
11242
|
+
if (ownsCompilation) import_core31.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
11865
11243
|
}
|
|
11866
11244
|
try {
|
|
11867
11245
|
if (ownsCompilation) {
|
|
@@ -11902,8 +11280,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11902
11280
|
this.id = props.id ?? "render-kernel";
|
|
11903
11281
|
this.vertexSource = vertexSource;
|
|
11904
11282
|
this.fragmentSource = fragmentSource;
|
|
11905
|
-
this.pipelineFactory = pipelineFactory ??
|
|
11906
|
-
this.shaderFactory = shaderFactory ??
|
|
11283
|
+
this.pipelineFactory = pipelineFactory ?? import_core31.PipelineFactory.getDefaultPipelineFactory(device);
|
|
11284
|
+
this.shaderFactory = shaderFactory ?? import_core31.ShaderFactory.getDefaultShaderFactory(device);
|
|
11907
11285
|
this.vertexShader = this.shaderFactory.createShader({
|
|
11908
11286
|
id: `${this.id}-vertex`,
|
|
11909
11287
|
stage: "vertex",
|
|
@@ -11921,7 +11299,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11921
11299
|
vs: this.vertexShader,
|
|
11922
11300
|
fs: this.fragmentShader
|
|
11923
11301
|
};
|
|
11924
|
-
const asyncCompilation =
|
|
11302
|
+
const asyncCompilation = import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11925
11303
|
if (asyncCompilation) {
|
|
11926
11304
|
const pipelineInitialization = this.pipelineFactory.createRenderPipelineAsync(renderPipelineProps);
|
|
11927
11305
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -11968,7 +11346,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11968
11346
|
};
|
|
11969
11347
|
|
|
11970
11348
|
// src/modules/picking/picking-manager.ts
|
|
11971
|
-
var
|
|
11349
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
11972
11350
|
|
|
11973
11351
|
// src/modules/picking/picking-uniforms.ts
|
|
11974
11352
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -12232,13 +11610,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
12232
11610
|
format: "rgba8unorm",
|
|
12233
11611
|
width: 1,
|
|
12234
11612
|
height: 1,
|
|
12235
|
-
usage:
|
|
11613
|
+
usage: import_core32.Texture.RENDER_ATTACHMENT
|
|
12236
11614
|
});
|
|
12237
11615
|
const pickingTexture = this.device.createTexture({
|
|
12238
11616
|
format: "rg32sint",
|
|
12239
11617
|
width: 1,
|
|
12240
11618
|
height: 1,
|
|
12241
|
-
usage:
|
|
11619
|
+
usage: import_core32.Texture.RENDER_ATTACHMENT | import_core32.Texture.COPY_SRC
|
|
12242
11620
|
});
|
|
12243
11621
|
return this.device.createFramebuffer({
|
|
12244
11622
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -12250,7 +11628,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
12250
11628
|
format: "rgba8unorm",
|
|
12251
11629
|
width: 1,
|
|
12252
11630
|
height: 1,
|
|
12253
|
-
usage:
|
|
11631
|
+
usage: import_core32.Texture.RENDER_ATTACHMENT | import_core32.Texture.COPY_SRC
|
|
12254
11632
|
});
|
|
12255
11633
|
return this.device.createFramebuffer({
|
|
12256
11634
|
colorAttachments: [pickingTexture],
|
|
@@ -12272,7 +11650,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
12272
11650
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
12273
11651
|
const readBuffer = this.device.createBuffer({
|
|
12274
11652
|
byteLength: layout.byteLength,
|
|
12275
|
-
usage:
|
|
11653
|
+
usage: import_core32.Buffer.COPY_DST | import_core32.Buffer.MAP_READ
|
|
12276
11654
|
});
|
|
12277
11655
|
try {
|
|
12278
11656
|
pickTexture.readBuffer(
|
|
@@ -12308,7 +11686,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
12308
11686
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
12309
11687
|
const readBuffer = this.device.createBuffer({
|
|
12310
11688
|
byteLength: layout.byteLength,
|
|
12311
|
-
usage:
|
|
11689
|
+
usage: import_core32.Buffer.COPY_DST | import_core32.Buffer.MAP_READ
|
|
12312
11690
|
});
|
|
12313
11691
|
try {
|
|
12314
11692
|
pickTexture.readBuffer(
|