@luma.gl/engine 10.0.0-alpha.2 → 10.0.0-alpha.3
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/compute/computation.d.ts +2 -0
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +5 -1
- package/dist/compute/computation.js.map +1 -1
- package/dist/dist.dev.js +390 -55
- package/dist/dist.min.js +31 -31
- package/dist/geometry/edge-geometry.d.ts +16 -0
- package/dist/geometry/edge-geometry.d.ts.map +1 -0
- package/dist/geometry/edge-geometry.js +160 -0
- package/dist/geometry/edge-geometry.js.map +1 -0
- package/dist/geometry/stroke-geometry.d.ts +15 -0
- package/dist/geometry/stroke-geometry.d.ts.map +1 -0
- package/dist/geometry/stroke-geometry.js +168 -0
- package/dist/geometry/stroke-geometry.js.map +1 -0
- package/dist/index.cjs +364 -59
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts +5 -0
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +11 -4
- package/dist/model/model.js.map +1 -1
- package/package.json +6 -6
- package/src/compute/computation.ts +7 -0
- package/src/geometry/edge-geometry.ts +204 -0
- package/src/geometry/stroke-geometry.ts +236 -0
- package/src/index.ts +7 -0
- package/src/model/model.ts +18 -5
package/dist/dist.dev.js
CHANGED
|
@@ -119,8 +119,11 @@ var __exports__ = (() => {
|
|
|
119
119
|
loadImage: () => loadImage,
|
|
120
120
|
loadImageBitmap: () => loadImageBitmap,
|
|
121
121
|
makeAnimationLoop: () => makeAnimationLoop,
|
|
122
|
+
makeEdgeGeometry: () => makeEdgeGeometry,
|
|
123
|
+
makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
|
|
122
124
|
makeInterleavedGeometry: () => makeInterleavedGeometry,
|
|
123
125
|
makeRandomGenerator: () => makeRandomGenerator,
|
|
126
|
+
makeStrokeGeometry: () => makeStrokeGeometry,
|
|
124
127
|
picking: () => picking4,
|
|
125
128
|
requestAnimationFramePolyfill: () => requestAnimationFramePolyfill,
|
|
126
129
|
resolvePickingBackend: () => resolvePickingBackend,
|
|
@@ -5184,6 +5187,7 @@ var __exports__ = (() => {
|
|
|
5184
5187
|
static defaultProps = {
|
|
5185
5188
|
...import_core13.RenderPipeline.defaultProps,
|
|
5186
5189
|
source: void 0,
|
|
5190
|
+
sourceLanguage: void 0,
|
|
5187
5191
|
vs: null,
|
|
5188
5192
|
fs: null,
|
|
5189
5193
|
id: "unnamed",
|
|
@@ -5339,6 +5343,7 @@ var __exports__ = (() => {
|
|
|
5339
5343
|
source: source4,
|
|
5340
5344
|
getUniforms: getUniforms2,
|
|
5341
5345
|
bindingTable,
|
|
5346
|
+
entryPoints = {},
|
|
5342
5347
|
shaderLayout: assembledShaderLayout
|
|
5343
5348
|
} = shaderAssembler.assembleWGSLShader({
|
|
5344
5349
|
platformInfo,
|
|
@@ -5350,6 +5355,8 @@ var __exports__ = (() => {
|
|
|
5350
5355
|
pluginVaryings: resolvedPlugins.varyings
|
|
5351
5356
|
});
|
|
5352
5357
|
this.source = source4;
|
|
5358
|
+
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
5359
|
+
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
5353
5360
|
this._getModuleUniforms = getUniforms2;
|
|
5354
5361
|
this._bindingTable = bindingTable;
|
|
5355
5362
|
const scannedOrReflectedShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(
|
|
@@ -5715,6 +5722,8 @@ var __exports__ = (() => {
|
|
|
5715
5722
|
}
|
|
5716
5723
|
/**
|
|
5717
5724
|
* Sets attributes (buffers)
|
|
5725
|
+
* @param options.byteOffsets Optional byte offsets, keyed by buffer name, where each buffer's
|
|
5726
|
+
* vertex data starts. Buffers without an entry are bound at offset 0.
|
|
5718
5727
|
* @note Overrides any attributes previously set with the same name
|
|
5719
5728
|
*/
|
|
5720
5729
|
setAttributes(buffers, options) {
|
|
@@ -5753,11 +5762,13 @@ var __exports__ = (() => {
|
|
|
5753
5762
|
}
|
|
5754
5763
|
continue;
|
|
5755
5764
|
}
|
|
5756
|
-
|
|
5765
|
+
const byteOffset = options?.byteOffsets?.[bufferName] ?? 0;
|
|
5766
|
+
this.vertexArray.setBuffer(bufferSlot, resolvedBuffer, byteOffset);
|
|
5757
5767
|
if (buffer instanceof DynamicBuffer) {
|
|
5758
5768
|
this._dynamicAttributeBufferSources[bufferSlot] = {
|
|
5759
5769
|
source: buffer,
|
|
5760
|
-
generation: buffer.generation
|
|
5770
|
+
generation: buffer.generation,
|
|
5771
|
+
byteOffset
|
|
5761
5772
|
};
|
|
5762
5773
|
} else {
|
|
5763
5774
|
delete this._dynamicAttributeBufferSources[bufferSlot];
|
|
@@ -6075,7 +6086,7 @@ var __exports__ = (() => {
|
|
|
6075
6086
|
}
|
|
6076
6087
|
for (const [locationKey, entry] of Object.entries(this._dynamicAttributeBufferSources)) {
|
|
6077
6088
|
if (entry.generation !== entry.source.generation) {
|
|
6078
|
-
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer);
|
|
6089
|
+
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer, entry.byteOffset);
|
|
6079
6090
|
entry.generation = entry.source.generation;
|
|
6080
6091
|
this.setNeedsRedraw("dynamic attribute buffer");
|
|
6081
6092
|
}
|
|
@@ -8511,13 +8522,332 @@ void main(void) {
|
|
|
8511
8522
|
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
8512
8523
|
}
|
|
8513
8524
|
|
|
8514
|
-
// src/geometry/
|
|
8525
|
+
// src/geometry/edge-geometry.ts
|
|
8515
8526
|
var import_core23 = __toESM(require_core(), 1);
|
|
8527
|
+
function makeEdgeGeometry(geometry, options = {}) {
|
|
8528
|
+
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
8529
|
+
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
8530
|
+
(0, import_core23.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
8531
|
+
(0, import_core23.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
8532
|
+
const sourceIndices = geometry.indices?.value;
|
|
8533
|
+
const sourceCount = positions.value.length / 3;
|
|
8534
|
+
const representatives = /* @__PURE__ */ new Map();
|
|
8535
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
8536
|
+
const faces = /* @__PURE__ */ new Set();
|
|
8537
|
+
const edges = /* @__PURE__ */ new Map();
|
|
8538
|
+
const cosineThreshold = Math.cos(angleThreshold * Math.PI / 180);
|
|
8539
|
+
const toleranceSquared = weldTolerance * weldTolerance;
|
|
8540
|
+
function readPosition(index) {
|
|
8541
|
+
return [
|
|
8542
|
+
positions.value[index * 3],
|
|
8543
|
+
positions.value[index * 3 + 1],
|
|
8544
|
+
positions.value[index * 3 + 2]
|
|
8545
|
+
];
|
|
8546
|
+
}
|
|
8547
|
+
function weldPosition(index) {
|
|
8548
|
+
const cached = representatives.get(index);
|
|
8549
|
+
if (cached !== void 0) return cached;
|
|
8550
|
+
(0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
8551
|
+
const position = readPosition(index);
|
|
8552
|
+
(0, import_core23.assert)(position.every(Number.isFinite));
|
|
8553
|
+
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
8554
|
+
const radius = weldTolerance > 0 ? 1 : 0;
|
|
8555
|
+
for (let east = -radius; east <= radius; east++) {
|
|
8556
|
+
for (let north = -radius; north <= radius; north++) {
|
|
8557
|
+
for (let up = -radius; up <= radius; up++) {
|
|
8558
|
+
const candidates = buckets.get(`${cell[0] + east},${cell[1] + north},${cell[2] + up}`);
|
|
8559
|
+
for (const candidate of candidates || []) {
|
|
8560
|
+
const other = readPosition(candidate);
|
|
8561
|
+
const distanceSquared = (position[0] - other[0]) ** 2 + (position[1] - other[1]) ** 2 + (position[2] - other[2]) ** 2;
|
|
8562
|
+
if (distanceSquared <= toleranceSquared) {
|
|
8563
|
+
representatives.set(index, candidate);
|
|
8564
|
+
return candidate;
|
|
8565
|
+
}
|
|
8566
|
+
}
|
|
8567
|
+
}
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
const key = cell.join(",");
|
|
8571
|
+
const bucket = buckets.get(key) || [];
|
|
8572
|
+
bucket.push(index);
|
|
8573
|
+
buckets.set(key, bucket);
|
|
8574
|
+
representatives.set(index, index);
|
|
8575
|
+
return index;
|
|
8576
|
+
}
|
|
8577
|
+
function addEdge(first, second, normal) {
|
|
8578
|
+
const start = Math.min(first, second);
|
|
8579
|
+
const end = Math.max(first, second);
|
|
8580
|
+
const key = `${start},${end}`;
|
|
8581
|
+
const edge = edges.get(key);
|
|
8582
|
+
if (edge) {
|
|
8583
|
+
edge.faceCount++;
|
|
8584
|
+
const cosine = normal[0] * edge.normal[0] + normal[1] * edge.normal[1] + normal[2] * edge.normal[2];
|
|
8585
|
+
edge.crease ||= cosine < 1 - 1e-7 && cosine <= cosineThreshold + 1e-7;
|
|
8586
|
+
} else {
|
|
8587
|
+
edges.set(key, { start, end, normal, faceCount: 1, crease: false });
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8590
|
+
for (let offset = 0; offset < geometry.vertexCount; offset += 3) {
|
|
8591
|
+
const first = weldPosition(sourceIndices?.[offset] ?? offset);
|
|
8592
|
+
const second = weldPosition(sourceIndices?.[offset + 1] ?? offset + 1);
|
|
8593
|
+
const third = weldPosition(sourceIndices?.[offset + 2] ?? offset + 2);
|
|
8594
|
+
if (first === second || second === third || third === first) continue;
|
|
8595
|
+
const faceKey = [first, second, third].sort((left, right) => left - right).join(",");
|
|
8596
|
+
if (faces.has(faceKey)) continue;
|
|
8597
|
+
faces.add(faceKey);
|
|
8598
|
+
const start = readPosition(first);
|
|
8599
|
+
const end = readPosition(second);
|
|
8600
|
+
const corner = readPosition(third);
|
|
8601
|
+
const firstDirection = end.map((value, axis) => value - start[axis]);
|
|
8602
|
+
const secondDirection = corner.map((value, axis) => value - start[axis]);
|
|
8603
|
+
const normal = [
|
|
8604
|
+
firstDirection[1] * secondDirection[2] - firstDirection[2] * secondDirection[1],
|
|
8605
|
+
firstDirection[2] * secondDirection[0] - firstDirection[0] * secondDirection[2],
|
|
8606
|
+
firstDirection[0] * secondDirection[1] - firstDirection[1] * secondDirection[0]
|
|
8607
|
+
];
|
|
8608
|
+
const magnitude = Math.hypot(...normal);
|
|
8609
|
+
if (magnitude === 0) continue;
|
|
8610
|
+
normal[0] /= magnitude;
|
|
8611
|
+
normal[1] /= magnitude;
|
|
8612
|
+
normal[2] /= magnitude;
|
|
8613
|
+
addEdge(first, second, normal);
|
|
8614
|
+
addEdge(second, third, normal);
|
|
8615
|
+
addEdge(third, first, normal);
|
|
8616
|
+
}
|
|
8617
|
+
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 Geometry({
|
|
8619
|
+
id: `${geometry.id}-edges`,
|
|
8620
|
+
topology: "line-list",
|
|
8621
|
+
attributes: { [positionAttribute]: positions },
|
|
8622
|
+
indices: new Uint32Array(selected.flatMap((edge) => [edge.start, edge.end]))
|
|
8623
|
+
});
|
|
8624
|
+
}
|
|
8625
|
+
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
8626
|
+
(0, import_core23.assert)(geometries.length > 0);
|
|
8627
|
+
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
8628
|
+
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
8629
|
+
const firstAttribute = attributes[0];
|
|
8630
|
+
(0, import_core23.assert)(
|
|
8631
|
+
attributes.every(
|
|
8632
|
+
(attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
|
|
8633
|
+
)
|
|
8634
|
+
);
|
|
8635
|
+
const PositionArray = firstAttribute.value.constructor;
|
|
8636
|
+
const positions = new PositionArray(
|
|
8637
|
+
attributes.reduce((count, attribute) => count + attribute.value.length, 0)
|
|
8638
|
+
);
|
|
8639
|
+
const indices = new Uint32Array(
|
|
8640
|
+
geometries.reduce((count, geometry) => count + geometry.vertexCount, 0)
|
|
8641
|
+
);
|
|
8642
|
+
let positionOffset = 0;
|
|
8643
|
+
let indexOffset = 0;
|
|
8644
|
+
for (const [geometryIndex, geometry] of geometries.entries()) {
|
|
8645
|
+
const attribute = attributes[geometryIndex];
|
|
8646
|
+
positions.set(attribute.value, positionOffset);
|
|
8647
|
+
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
8648
|
+
const index = geometry.indices?.value[offset] ?? offset;
|
|
8649
|
+
(0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
8650
|
+
indices[indexOffset++] = index + positionOffset / 3;
|
|
8651
|
+
}
|
|
8652
|
+
positionOffset += attribute.value.length;
|
|
8653
|
+
}
|
|
8654
|
+
return makeEdgeGeometry(
|
|
8655
|
+
new Geometry({
|
|
8656
|
+
id: `${geometries[0].id}-batch`,
|
|
8657
|
+
topology: "triangle-list",
|
|
8658
|
+
attributes: { [positionAttribute]: { ...firstAttribute, value: positions } },
|
|
8659
|
+
indices
|
|
8660
|
+
}),
|
|
8661
|
+
options
|
|
8662
|
+
);
|
|
8663
|
+
}
|
|
8664
|
+
function getTrianglePositions(geometry, positionAttribute) {
|
|
8665
|
+
const positions = geometry.attributes[positionAttribute];
|
|
8666
|
+
(0, import_core23.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
|
|
8667
|
+
(0, import_core23.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
8668
|
+
(0, import_core23.assert)(
|
|
8669
|
+
!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
|
|
8670
|
+
);
|
|
8671
|
+
(0, import_core23.assert)(
|
|
8672
|
+
geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
|
|
8673
|
+
);
|
|
8674
|
+
return positions;
|
|
8675
|
+
}
|
|
8676
|
+
|
|
8677
|
+
// src/geometry/stroke-geometry.ts
|
|
8678
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
8679
|
+
function makeStrokeGeometry(path, options = {}) {
|
|
8680
|
+
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
8681
|
+
(0, import_core24.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
8682
|
+
(0, import_core24.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
8683
|
+
const points = [];
|
|
8684
|
+
for (const position of path) {
|
|
8685
|
+
(0, import_core24.assert)(
|
|
8686
|
+
Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
|
|
8687
|
+
);
|
|
8688
|
+
const previous = points.at(-1);
|
|
8689
|
+
if (!previous || previous[0] !== position[0] || previous[1] !== position[1])
|
|
8690
|
+
points.push([position[0], position[1], position[2] ?? 0]);
|
|
8691
|
+
}
|
|
8692
|
+
if (options.closed && points.length > 1 && points[0][0] === points.at(-1)[0] && points[0][1] === points.at(-1)[1])
|
|
8693
|
+
points.pop();
|
|
8694
|
+
const closed = Boolean(options.closed && points.length > 2);
|
|
8695
|
+
const positions = [];
|
|
8696
|
+
const coordinates = [];
|
|
8697
|
+
const halfWidth = width / 2;
|
|
8698
|
+
if (points.length > 1 && width > 0) {
|
|
8699
|
+
const segments = [];
|
|
8700
|
+
const distances = [0];
|
|
8701
|
+
for (let index = 0; index < points.length - (closed ? 0 : 1); index++) {
|
|
8702
|
+
const start = points[index];
|
|
8703
|
+
const end = points[(index + 1) % points.length];
|
|
8704
|
+
const horizontal = end[0] - start[0];
|
|
8705
|
+
const vertical = end[1] - start[1];
|
|
8706
|
+
const length = Math.hypot(horizontal, vertical);
|
|
8707
|
+
segments.push({ direction: [horizontal / length, vertical / length], length });
|
|
8708
|
+
distances.push(distances.at(-1) + length);
|
|
8709
|
+
}
|
|
8710
|
+
const corners = points.map((point, index) => {
|
|
8711
|
+
const previous = segments[(index - 1 + segments.length) % segments.length];
|
|
8712
|
+
const next = segments[index % segments.length];
|
|
8713
|
+
const distance = distances[index];
|
|
8714
|
+
if (!closed && (index === 0 || index === points.length - 1)) {
|
|
8715
|
+
const direction = index === 0 ? next.direction : previous.direction;
|
|
8716
|
+
const extension = cap === "square" ? index === 0 ? -halfWidth : halfWidth : 0;
|
|
8717
|
+
const left = createVertex(point, direction, halfWidth, extension, distance + extension);
|
|
8718
|
+
const right = createVertex(point, direction, -halfWidth, extension, distance + extension);
|
|
8719
|
+
if (cap === "round") appendCap(point, direction, distance, index === 0);
|
|
8720
|
+
return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
|
|
8721
|
+
}
|
|
8722
|
+
const incoming = previous.direction;
|
|
8723
|
+
const outgoing = next.direction;
|
|
8724
|
+
const turn = incoming[0] * outgoing[1] - incoming[1] * outgoing[0];
|
|
8725
|
+
const cosine = incoming[0] * outgoing[0] + incoming[1] * outgoing[1];
|
|
8726
|
+
const result = {
|
|
8727
|
+
incomingLeft: createVertex(point, incoming, halfWidth, 0, distance),
|
|
8728
|
+
incomingRight: createVertex(point, incoming, -halfWidth, 0, distance),
|
|
8729
|
+
outgoingLeft: createVertex(point, outgoing, halfWidth, 0, distance),
|
|
8730
|
+
outgoingRight: createVertex(point, outgoing, -halfWidth, 0, distance)
|
|
8731
|
+
};
|
|
8732
|
+
if (1 + cosine < 1e-8) {
|
|
8733
|
+
if (join === "round") {
|
|
8734
|
+
appendCap(point, incoming, distance, false);
|
|
8735
|
+
appendCap(point, outgoing, distance, true);
|
|
8736
|
+
}
|
|
8737
|
+
return result;
|
|
8738
|
+
}
|
|
8739
|
+
const miter = [
|
|
8740
|
+
-(incoming[1] + outgoing[1]) * halfWidth / (1 + cosine),
|
|
8741
|
+
(incoming[0] + outgoing[0]) * halfWidth / (1 + cosine)
|
|
8742
|
+
];
|
|
8743
|
+
const miterLength = Math.hypot(...miter);
|
|
8744
|
+
if (Math.abs(turn) < 1e-8 || join === "miter" && miterLength <= miterLimit * halfWidth) {
|
|
8745
|
+
const left = offsetVertex(point, miter, distance, halfWidth);
|
|
8746
|
+
const right = offsetVertex(point, [-miter[0], -miter[1]], distance, -halfWidth);
|
|
8747
|
+
return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
|
|
8748
|
+
}
|
|
8749
|
+
const innerSide = Math.sign(turn);
|
|
8750
|
+
const innerScale = Math.min(1, Math.min(previous.length, next.length) / (2 * miterLength));
|
|
8751
|
+
const inner = offsetVertex(
|
|
8752
|
+
point,
|
|
8753
|
+
[miter[0] * innerSide * innerScale, miter[1] * innerSide * innerScale],
|
|
8754
|
+
distance,
|
|
8755
|
+
halfWidth * innerSide
|
|
8756
|
+
);
|
|
8757
|
+
if (innerSide > 0) {
|
|
8758
|
+
result.incomingLeft = inner;
|
|
8759
|
+
result.outgoingLeft = inner;
|
|
8760
|
+
} else {
|
|
8761
|
+
result.incomingRight = inner;
|
|
8762
|
+
result.outgoingRight = inner;
|
|
8763
|
+
}
|
|
8764
|
+
const outerStart = innerSide > 0 ? result.incomingRight : result.incomingLeft;
|
|
8765
|
+
const outerEnd = innerSide > 0 ? result.outgoingRight : result.outgoingLeft;
|
|
8766
|
+
if (join === "round") {
|
|
8767
|
+
const sweep = Math.atan2(turn, cosine);
|
|
8768
|
+
const startAngle = Math.atan2(
|
|
8769
|
+
outerStart.position[1] - point[1],
|
|
8770
|
+
outerStart.position[0] - point[0]
|
|
8771
|
+
);
|
|
8772
|
+
const steps = Math.max(1, Math.ceil(Math.abs(sweep) / Math.PI * roundSegments));
|
|
8773
|
+
let previousOuter = outerStart;
|
|
8774
|
+
for (let step = 1; step <= steps; step++) {
|
|
8775
|
+
const angle2 = startAngle + sweep * step / steps;
|
|
8776
|
+
const currentOuter = step === steps ? outerEnd : offsetVertex(
|
|
8777
|
+
point,
|
|
8778
|
+
[Math.cos(angle2) * halfWidth, Math.sin(angle2) * halfWidth],
|
|
8779
|
+
distance,
|
|
8780
|
+
-halfWidth * innerSide
|
|
8781
|
+
);
|
|
8782
|
+
appendTriangle(inner, previousOuter, currentOuter);
|
|
8783
|
+
previousOuter = currentOuter;
|
|
8784
|
+
}
|
|
8785
|
+
} else appendTriangle(inner, outerStart, outerEnd);
|
|
8786
|
+
return result;
|
|
8787
|
+
});
|
|
8788
|
+
segments.forEach((_segment, index) => {
|
|
8789
|
+
const start = corners[index];
|
|
8790
|
+
const end = corners[(index + 1) % corners.length];
|
|
8791
|
+
const closing = closed && index === segments.length - 1;
|
|
8792
|
+
const endLeft = closing ? { ...end.incomingLeft, distance: distances.at(-1) } : end.incomingLeft;
|
|
8793
|
+
const endRight = closing ? { ...end.incomingRight, distance: distances.at(-1) } : end.incomingRight;
|
|
8794
|
+
appendTriangle(start.outgoingLeft, start.outgoingRight, endLeft);
|
|
8795
|
+
appendTriangle(start.outgoingRight, endRight, endLeft);
|
|
8796
|
+
});
|
|
8797
|
+
}
|
|
8798
|
+
return new Geometry({
|
|
8799
|
+
id: options.id,
|
|
8800
|
+
topology: "triangle-list",
|
|
8801
|
+
attributes: {
|
|
8802
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
8803
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(coordinates) }
|
|
8804
|
+
}
|
|
8805
|
+
});
|
|
8806
|
+
function appendTriangle(first, second, third) {
|
|
8807
|
+
const area = (second.position[0] - first.position[0]) * (third.position[1] - first.position[1]) - (second.position[1] - first.position[1]) * (third.position[0] - first.position[0]);
|
|
8808
|
+
if (area === 0) return;
|
|
8809
|
+
for (const vertex of area > 0 ? [first, second, third] : [first, third, second]) {
|
|
8810
|
+
positions.push(...vertex.position);
|
|
8811
|
+
coordinates.push(vertex.distance, vertex.across);
|
|
8812
|
+
}
|
|
8813
|
+
}
|
|
8814
|
+
function offsetVertex(point, offset, distance, across) {
|
|
8815
|
+
return { position: [point[0] + offset[0], point[1] + offset[1], point[2]], distance, across };
|
|
8816
|
+
}
|
|
8817
|
+
function createVertex(point, direction, across, along, distance) {
|
|
8818
|
+
return offsetVertex(
|
|
8819
|
+
point,
|
|
8820
|
+
[-direction[1] * across + direction[0] * along, direction[0] * across + direction[1] * along],
|
|
8821
|
+
distance,
|
|
8822
|
+
across
|
|
8823
|
+
);
|
|
8824
|
+
}
|
|
8825
|
+
function appendCap(point, direction, distance, start) {
|
|
8826
|
+
const center = { position: point, distance, across: 0 };
|
|
8827
|
+
const startAngle = Math.atan2(direction[1], direction[0]) + (start ? -Math.PI / 2 : Math.PI / 2);
|
|
8828
|
+
let previous;
|
|
8829
|
+
for (let step = 0; step <= roundSegments; step++) {
|
|
8830
|
+
const angle2 = startAngle - Math.PI * step / roundSegments;
|
|
8831
|
+
const offset = [Math.cos(angle2) * halfWidth, Math.sin(angle2) * halfWidth];
|
|
8832
|
+
const current = offsetVertex(
|
|
8833
|
+
point,
|
|
8834
|
+
offset,
|
|
8835
|
+
distance + offset[0] * direction[0] + offset[1] * direction[1],
|
|
8836
|
+
-offset[0] * direction[1] + offset[1] * direction[0]
|
|
8837
|
+
);
|
|
8838
|
+
if (previous) appendTriangle(center, previous, current);
|
|
8839
|
+
previous = current;
|
|
8840
|
+
}
|
|
8841
|
+
}
|
|
8842
|
+
}
|
|
8843
|
+
|
|
8844
|
+
// src/geometry/mesh-simplification.ts
|
|
8845
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
8516
8846
|
var QUADRIC_COMPONENTS = 10;
|
|
8517
8847
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
8518
8848
|
function simplifyMesh(options) {
|
|
8519
8849
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
8520
|
-
(0,
|
|
8850
|
+
(0, import_core25.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
8521
8851
|
const targetIndexCount = Math.max(
|
|
8522
8852
|
0,
|
|
8523
8853
|
Math.min(
|
|
@@ -8610,7 +8940,7 @@ void main(void) {
|
|
|
8610
8940
|
const firstVertex = indices[indexOffset2];
|
|
8611
8941
|
const secondVertex = indices[indexOffset2 + 1];
|
|
8612
8942
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
8613
|
-
(0,
|
|
8943
|
+
(0, import_core25.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
8614
8944
|
const triangle = {
|
|
8615
8945
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
8616
8946
|
active: false
|
|
@@ -9875,7 +10205,7 @@ void main(void) {
|
|
|
9875
10205
|
}
|
|
9876
10206
|
|
|
9877
10207
|
// src/dynamic-texture/video-texture.ts
|
|
9878
|
-
var
|
|
10208
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
9879
10209
|
var VideoTexture = class {
|
|
9880
10210
|
/** Device used to create copied and native external texture bindings. */
|
|
9881
10211
|
device;
|
|
@@ -9924,7 +10254,7 @@ void main(void) {
|
|
|
9924
10254
|
* @param props Live video source and copied texture options.
|
|
9925
10255
|
*/
|
|
9926
10256
|
constructor(device, props) {
|
|
9927
|
-
(0,
|
|
10257
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
|
|
9928
10258
|
this.device = device;
|
|
9929
10259
|
this.id = props.id || uid("video-texture");
|
|
9930
10260
|
this._source = props.source;
|
|
@@ -9938,7 +10268,7 @@ void main(void) {
|
|
|
9938
10268
|
* @param source Next caller-owned video source to follow.
|
|
9939
10269
|
*/
|
|
9940
10270
|
setSource(source4) {
|
|
9941
|
-
(0,
|
|
10271
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
9942
10272
|
this._destroyExternalTexture();
|
|
9943
10273
|
this._source = source4;
|
|
9944
10274
|
this._sourceVersion++;
|
|
@@ -10016,7 +10346,7 @@ void main(void) {
|
|
|
10016
10346
|
width: size.width,
|
|
10017
10347
|
height: size.height,
|
|
10018
10348
|
format: "rgba8unorm",
|
|
10019
|
-
usage:
|
|
10349
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
|
|
10020
10350
|
mipLevels: 1,
|
|
10021
10351
|
sampler: this._sampler
|
|
10022
10352
|
});
|
|
@@ -10051,7 +10381,7 @@ void main(void) {
|
|
|
10051
10381
|
*/
|
|
10052
10382
|
_getResolvedSize() {
|
|
10053
10383
|
const size = getVideoTextureSourceSize(this._source);
|
|
10054
|
-
(0,
|
|
10384
|
+
(0, import_core27.assert)(size.width > 0 && size.height > 0);
|
|
10055
10385
|
return size;
|
|
10056
10386
|
}
|
|
10057
10387
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -10116,11 +10446,11 @@ void main(void) {
|
|
|
10116
10446
|
}
|
|
10117
10447
|
|
|
10118
10448
|
// src/passes/shader-pass-renderer.ts
|
|
10119
|
-
var
|
|
10449
|
+
var import_core30 = __toESM(require_core(), 1);
|
|
10120
10450
|
var import_shadertools7 = __toESM(require_shadertools(), 1);
|
|
10121
10451
|
|
|
10122
10452
|
// src/compute/swap.ts
|
|
10123
|
-
var
|
|
10453
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
10124
10454
|
var Swap = class {
|
|
10125
10455
|
id;
|
|
10126
10456
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -10152,7 +10482,7 @@ void main(void) {
|
|
|
10152
10482
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
10153
10483
|
id: `${props.id}-texture-0`,
|
|
10154
10484
|
format: colorAttachment,
|
|
10155
|
-
usage:
|
|
10485
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
10156
10486
|
width,
|
|
10157
10487
|
height
|
|
10158
10488
|
})
|
|
@@ -10162,7 +10492,7 @@ void main(void) {
|
|
|
10162
10492
|
(colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
10163
10493
|
id: `${props.id}-texture-1`,
|
|
10164
10494
|
format: colorAttachment,
|
|
10165
|
-
usage:
|
|
10495
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
10166
10496
|
width,
|
|
10167
10497
|
height
|
|
10168
10498
|
})
|
|
@@ -10226,7 +10556,7 @@ void main(void) {
|
|
|
10226
10556
|
};
|
|
10227
10557
|
|
|
10228
10558
|
// src/compute/computation.ts
|
|
10229
|
-
var
|
|
10559
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
10230
10560
|
var import_shadertools6 = __toESM(require_shadertools(), 1);
|
|
10231
10561
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
10232
10562
|
var LOG_DRAW_TIMEOUT2 = 1e4;
|
|
@@ -10238,13 +10568,13 @@ void main(void) {
|
|
|
10238
10568
|
* constructor remains the synchronous compatibility path.
|
|
10239
10569
|
*/
|
|
10240
10570
|
static async createAsync(device, props) {
|
|
10241
|
-
const ownsCompilation = !
|
|
10242
|
-
const asyncCompilation = ownsCompilation ?
|
|
10571
|
+
const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
10572
|
+
const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
10243
10573
|
let computation;
|
|
10244
10574
|
try {
|
|
10245
10575
|
computation = new _Computation(device, props);
|
|
10246
10576
|
} finally {
|
|
10247
|
-
if (ownsCompilation)
|
|
10577
|
+
if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
10248
10578
|
}
|
|
10249
10579
|
try {
|
|
10250
10580
|
if (ownsCompilation) {
|
|
@@ -10259,11 +10589,12 @@ void main(void) {
|
|
|
10259
10589
|
}
|
|
10260
10590
|
}
|
|
10261
10591
|
static defaultProps = {
|
|
10262
|
-
...
|
|
10592
|
+
...import_core29.ComputePipeline.defaultProps,
|
|
10263
10593
|
id: "unnamed",
|
|
10264
10594
|
handle: void 0,
|
|
10265
10595
|
userData: {},
|
|
10266
10596
|
source: "",
|
|
10597
|
+
sourceLanguage: void 0,
|
|
10267
10598
|
modules: [],
|
|
10268
10599
|
defines: {},
|
|
10269
10600
|
plugins: [],
|
|
@@ -10324,30 +10655,34 @@ void main(void) {
|
|
|
10324
10655
|
const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
|
|
10325
10656
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
10326
10657
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
10327
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
10328
|
-
this.shaderFactory = props.shaderFactory ||
|
|
10658
|
+
this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
10659
|
+
this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
10329
10660
|
const shaderAssembler = this.props.shaderAssembler;
|
|
10330
|
-
(0,
|
|
10661
|
+
(0, import_core29.assert)(shaderAssembler instanceof import_shadertools6.WGSLShaderAssembler);
|
|
10331
10662
|
const {
|
|
10332
10663
|
source: source4,
|
|
10333
10664
|
getUniforms: getUniforms2,
|
|
10665
|
+
entryPoints = {},
|
|
10334
10666
|
shaderLayout: assembledShaderLayout
|
|
10335
10667
|
} = shaderAssembler.assembleWGSLShader({
|
|
10336
10668
|
platformInfo,
|
|
10337
10669
|
...this.props,
|
|
10338
10670
|
modules,
|
|
10339
10671
|
defines,
|
|
10672
|
+
shaderStage: "compute",
|
|
10673
|
+
computeEntryPoint: this.props.entryPoint,
|
|
10340
10674
|
scanVertexAttributes: false,
|
|
10341
10675
|
pluginInjections: resolvedPlugins.injections
|
|
10342
10676
|
});
|
|
10343
10677
|
this.source = source4;
|
|
10678
|
+
this.props.entryPoint = entryPoints.compute || this.props.entryPoint;
|
|
10344
10679
|
this._getModuleUniforms = getUniforms2;
|
|
10345
10680
|
const inferredShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(this.source, { scanVertexAttributes: false });
|
|
10346
10681
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(
|
|
10347
10682
|
this.props.shaderLayout || inferredShaderLayout || null,
|
|
10348
10683
|
modules
|
|
10349
10684
|
) || null;
|
|
10350
|
-
const asyncCompilation =
|
|
10685
|
+
const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
|
|
10351
10686
|
if (asyncCompilation) {
|
|
10352
10687
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
10353
10688
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -10414,7 +10749,7 @@ void main(void) {
|
|
|
10414
10749
|
}
|
|
10415
10750
|
setShaderInputs(shaderInputs) {
|
|
10416
10751
|
this.shaderInputs = shaderInputs;
|
|
10417
|
-
this._uniformStore = new
|
|
10752
|
+
this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
|
|
10418
10753
|
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
10419
10754
|
if (shaderModuleHasUniforms(module)) {
|
|
10420
10755
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -10483,7 +10818,7 @@ void main(void) {
|
|
|
10483
10818
|
if (!this._pipelineNeedsUpdate) return null;
|
|
10484
10819
|
const previousShader = this.pipeline ? this.shader : null;
|
|
10485
10820
|
if (this.pipeline) {
|
|
10486
|
-
|
|
10821
|
+
import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
10487
10822
|
}
|
|
10488
10823
|
this._pipelineNeedsUpdate = false;
|
|
10489
10824
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -10501,27 +10836,27 @@ void main(void) {
|
|
|
10501
10836
|
_lastLogTime = 0;
|
|
10502
10837
|
_logOpen = false;
|
|
10503
10838
|
_logDrawCallStart() {
|
|
10504
|
-
const logDrawTimeout =
|
|
10505
|
-
if (
|
|
10839
|
+
const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
10840
|
+
if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
10506
10841
|
return;
|
|
10507
10842
|
}
|
|
10508
10843
|
this._lastLogTime = Date.now();
|
|
10509
10844
|
this._logOpen = true;
|
|
10510
|
-
|
|
10845
|
+
import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
|
|
10511
10846
|
}
|
|
10512
10847
|
_logDrawCallEnd() {
|
|
10513
10848
|
if (this._logOpen) {
|
|
10514
10849
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
10515
|
-
|
|
10516
|
-
|
|
10850
|
+
import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
10851
|
+
import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
10517
10852
|
this._logOpen = false;
|
|
10518
10853
|
}
|
|
10519
10854
|
}
|
|
10520
10855
|
_drawCount = 0;
|
|
10521
10856
|
// TODO - fix typing of luma data types
|
|
10522
10857
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
10523
|
-
const TypedArrayConstructor =
|
|
10524
|
-
const typedArray = attribute instanceof
|
|
10858
|
+
const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
10859
|
+
const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
10525
10860
|
return typedArray.toString();
|
|
10526
10861
|
}
|
|
10527
10862
|
};
|
|
@@ -11089,7 +11424,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11089
11424
|
this.parameterBuffer = device.createBuffer({
|
|
11090
11425
|
id: `${optimization.name}-parameters`,
|
|
11091
11426
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
11092
|
-
usage:
|
|
11427
|
+
usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
|
|
11093
11428
|
});
|
|
11094
11429
|
const outputBindings = Object.entries(optimization.outputs).map(
|
|
11095
11430
|
([bindingName, targetName], outputIndex) => ({
|
|
@@ -11374,7 +11709,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11374
11709
|
width: targetSize[0],
|
|
11375
11710
|
height: targetSize[1],
|
|
11376
11711
|
format: spec.format || device.preferredColorFormat,
|
|
11377
|
-
usage:
|
|
11712
|
+
usage: import_core30.Texture.SAMPLE | import_core30.Texture.RENDER | import_core30.Texture.COPY_SRC | import_core30.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core30.Texture.STORAGE : 0),
|
|
11378
11713
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
11379
11714
|
});
|
|
11380
11715
|
const framebuffer = device.createFramebuffer({
|
|
@@ -11429,17 +11764,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11429
11764
|
}
|
|
11430
11765
|
|
|
11431
11766
|
// src/compute/kernel.ts
|
|
11432
|
-
var
|
|
11767
|
+
var import_core31 = __toESM(require_core(), 1);
|
|
11433
11768
|
var Kernel = class _Kernel {
|
|
11434
11769
|
/** Creates a kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
11435
11770
|
static async createAsync(device, props) {
|
|
11436
|
-
const ownsCompilation = !
|
|
11437
|
-
const asyncCompilation = ownsCompilation ?
|
|
11771
|
+
const ownsCompilation = !import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11772
|
+
const asyncCompilation = ownsCompilation ? import_core31.PipelineFactory.beginAsyncCompilation(device) : import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11438
11773
|
let kernel;
|
|
11439
11774
|
try {
|
|
11440
11775
|
kernel = new _Kernel(device, props);
|
|
11441
11776
|
} finally {
|
|
11442
|
-
if (ownsCompilation)
|
|
11777
|
+
if (ownsCompilation) import_core31.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
11443
11778
|
}
|
|
11444
11779
|
try {
|
|
11445
11780
|
if (ownsCompilation) {
|
|
@@ -11470,8 +11805,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11470
11805
|
this.device = device;
|
|
11471
11806
|
this.id = props.id ?? "kernel";
|
|
11472
11807
|
this.source = source4;
|
|
11473
|
-
this.pipelineFactory = pipelineFactory ??
|
|
11474
|
-
this.shaderFactory = shaderFactory ??
|
|
11808
|
+
this.pipelineFactory = pipelineFactory ?? import_core31.PipelineFactory.getDefaultPipelineFactory(device);
|
|
11809
|
+
this.shaderFactory = shaderFactory ?? import_core31.ShaderFactory.getDefaultShaderFactory(device);
|
|
11475
11810
|
this.shader = this.shaderFactory.createShader({
|
|
11476
11811
|
id: `${this.id}-compute`,
|
|
11477
11812
|
stage: "compute",
|
|
@@ -11479,7 +11814,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11479
11814
|
debugShaders
|
|
11480
11815
|
});
|
|
11481
11816
|
const computePipelineProps = { ...pipelineProps, shader: this.shader };
|
|
11482
|
-
const asyncCompilation =
|
|
11817
|
+
const asyncCompilation = import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
11483
11818
|
if (asyncCompilation) {
|
|
11484
11819
|
const pipelineInitialization = this.pipelineFactory.createComputePipelineAsync(computePipelineProps);
|
|
11485
11820
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -11516,17 +11851,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11516
11851
|
};
|
|
11517
11852
|
|
|
11518
11853
|
// src/compute/render-kernel.ts
|
|
11519
|
-
var
|
|
11854
|
+
var import_core32 = __toESM(require_core(), 1);
|
|
11520
11855
|
var RenderKernel = class _RenderKernel {
|
|
11521
11856
|
/** Creates a render kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
11522
11857
|
static async createAsync(device, props) {
|
|
11523
|
-
const ownsCompilation = !
|
|
11524
|
-
const asyncCompilation = ownsCompilation ?
|
|
11858
|
+
const ownsCompilation = !import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
11859
|
+
const asyncCompilation = ownsCompilation ? import_core32.PipelineFactory.beginAsyncCompilation(device) : import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
11525
11860
|
let kernel;
|
|
11526
11861
|
try {
|
|
11527
11862
|
kernel = new _RenderKernel(device, props);
|
|
11528
11863
|
} finally {
|
|
11529
|
-
if (ownsCompilation)
|
|
11864
|
+
if (ownsCompilation) import_core32.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
11530
11865
|
}
|
|
11531
11866
|
try {
|
|
11532
11867
|
if (ownsCompilation) {
|
|
@@ -11567,8 +11902,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11567
11902
|
this.id = props.id ?? "render-kernel";
|
|
11568
11903
|
this.vertexSource = vertexSource;
|
|
11569
11904
|
this.fragmentSource = fragmentSource;
|
|
11570
|
-
this.pipelineFactory = pipelineFactory ??
|
|
11571
|
-
this.shaderFactory = shaderFactory ??
|
|
11905
|
+
this.pipelineFactory = pipelineFactory ?? import_core32.PipelineFactory.getDefaultPipelineFactory(device);
|
|
11906
|
+
this.shaderFactory = shaderFactory ?? import_core32.ShaderFactory.getDefaultShaderFactory(device);
|
|
11572
11907
|
this.vertexShader = this.shaderFactory.createShader({
|
|
11573
11908
|
id: `${this.id}-vertex`,
|
|
11574
11909
|
stage: "vertex",
|
|
@@ -11586,7 +11921,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11586
11921
|
vs: this.vertexShader,
|
|
11587
11922
|
fs: this.fragmentShader
|
|
11588
11923
|
};
|
|
11589
|
-
const asyncCompilation =
|
|
11924
|
+
const asyncCompilation = import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
11590
11925
|
if (asyncCompilation) {
|
|
11591
11926
|
const pipelineInitialization = this.pipelineFactory.createRenderPipelineAsync(renderPipelineProps);
|
|
11592
11927
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -11633,7 +11968,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
|
|
|
11633
11968
|
};
|
|
11634
11969
|
|
|
11635
11970
|
// src/modules/picking/picking-manager.ts
|
|
11636
|
-
var
|
|
11971
|
+
var import_core33 = __toESM(require_core(), 1);
|
|
11637
11972
|
|
|
11638
11973
|
// src/modules/picking/picking-uniforms.ts
|
|
11639
11974
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -11897,13 +12232,13 @@ layout(std140) uniform pickingUniforms {
|
|
|
11897
12232
|
format: "rgba8unorm",
|
|
11898
12233
|
width: 1,
|
|
11899
12234
|
height: 1,
|
|
11900
|
-
usage:
|
|
12235
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT
|
|
11901
12236
|
});
|
|
11902
12237
|
const pickingTexture = this.device.createTexture({
|
|
11903
12238
|
format: "rg32sint",
|
|
11904
12239
|
width: 1,
|
|
11905
12240
|
height: 1,
|
|
11906
|
-
usage:
|
|
12241
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
|
|
11907
12242
|
});
|
|
11908
12243
|
return this.device.createFramebuffer({
|
|
11909
12244
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -11915,7 +12250,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
11915
12250
|
format: "rgba8unorm",
|
|
11916
12251
|
width: 1,
|
|
11917
12252
|
height: 1,
|
|
11918
|
-
usage:
|
|
12253
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
|
|
11919
12254
|
});
|
|
11920
12255
|
return this.device.createFramebuffer({
|
|
11921
12256
|
colorAttachments: [pickingTexture],
|
|
@@ -11937,7 +12272,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
11937
12272
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
11938
12273
|
const readBuffer = this.device.createBuffer({
|
|
11939
12274
|
byteLength: layout.byteLength,
|
|
11940
|
-
usage:
|
|
12275
|
+
usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
|
|
11941
12276
|
});
|
|
11942
12277
|
try {
|
|
11943
12278
|
pickTexture.readBuffer(
|
|
@@ -11973,7 +12308,7 @@ layout(std140) uniform pickingUniforms {
|
|
|
11973
12308
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
11974
12309
|
const readBuffer = this.device.createBuffer({
|
|
11975
12310
|
byteLength: layout.byteLength,
|
|
11976
|
-
usage:
|
|
12311
|
+
usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
|
|
11977
12312
|
});
|
|
11978
12313
|
try {
|
|
11979
12314
|
pickTexture.readBuffer(
|