@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/index.cjs
CHANGED
|
@@ -79,8 +79,11 @@ __export(index_exports, {
|
|
|
79
79
|
loadImage: () => loadImage,
|
|
80
80
|
loadImageBitmap: () => loadImageBitmap,
|
|
81
81
|
makeAnimationLoop: () => makeAnimationLoop,
|
|
82
|
+
makeEdgeGeometry: () => makeEdgeGeometry,
|
|
83
|
+
makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
|
|
82
84
|
makeInterleavedGeometry: () => makeInterleavedGeometry,
|
|
83
85
|
makeRandomGenerator: () => makeRandomGenerator,
|
|
86
|
+
makeStrokeGeometry: () => makeStrokeGeometry,
|
|
84
87
|
picking: () => picking4,
|
|
85
88
|
requestAnimationFramePolyfill: () => requestAnimationFramePolyfill,
|
|
86
89
|
resolvePickingBackend: () => resolvePickingBackend,
|
|
@@ -2955,6 +2958,7 @@ var Model = class _Model {
|
|
|
2955
2958
|
static defaultProps = {
|
|
2956
2959
|
...import_core13.RenderPipeline.defaultProps,
|
|
2957
2960
|
source: void 0,
|
|
2961
|
+
sourceLanguage: void 0,
|
|
2958
2962
|
vs: null,
|
|
2959
2963
|
fs: null,
|
|
2960
2964
|
id: "unnamed",
|
|
@@ -3104,7 +3108,7 @@ var Model = class _Model {
|
|
|
3104
3108
|
if (isWebGPU && this.props.source) {
|
|
3105
3109
|
const shaderAssembler = this.props.shaderAssembler;
|
|
3106
3110
|
(0, import_core13.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
3107
|
-
const { source: source4, getUniforms: getUniforms2, bindingTable, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
3111
|
+
const { source: source4, getUniforms: getUniforms2, bindingTable, entryPoints = {}, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
3108
3112
|
platformInfo,
|
|
3109
3113
|
...this.props,
|
|
3110
3114
|
modules,
|
|
@@ -3114,6 +3118,8 @@ var Model = class _Model {
|
|
|
3114
3118
|
pluginVaryings: resolvedPlugins.varyings
|
|
3115
3119
|
});
|
|
3116
3120
|
this.source = source4;
|
|
3121
|
+
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
3122
|
+
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
3117
3123
|
this._getModuleUniforms = getUniforms2;
|
|
3118
3124
|
this._bindingTable = bindingTable;
|
|
3119
3125
|
const scannedOrReflectedShaderLayout = assembledShaderLayout ?? ((_a = device.getShaderLayout) == null ? void 0 : _a.call(device, this.source));
|
|
@@ -3478,9 +3484,12 @@ var Model = class _Model {
|
|
|
3478
3484
|
}
|
|
3479
3485
|
/**
|
|
3480
3486
|
* Sets attributes (buffers)
|
|
3487
|
+
* @param options.byteOffsets Optional byte offsets, keyed by buffer name, where each buffer's
|
|
3488
|
+
* vertex data starts. Buffers without an entry are bound at offset 0.
|
|
3481
3489
|
* @note Overrides any attributes previously set with the same name
|
|
3482
3490
|
*/
|
|
3483
3491
|
setAttributes(buffers, options) {
|
|
3492
|
+
var _a;
|
|
3484
3493
|
this._drawBlockedReason = false;
|
|
3485
3494
|
const disableWarnings = (options == null ? void 0 : options.disableWarnings) ?? this.props.disableWarnings;
|
|
3486
3495
|
if (buffers["indices"]) {
|
|
@@ -3509,11 +3518,13 @@ var Model = class _Model {
|
|
|
3509
3518
|
}
|
|
3510
3519
|
continue;
|
|
3511
3520
|
}
|
|
3512
|
-
|
|
3521
|
+
const byteOffset = ((_a = options == null ? void 0 : options.byteOffsets) == null ? void 0 : _a[bufferName]) ?? 0;
|
|
3522
|
+
this.vertexArray.setBuffer(bufferSlot, resolvedBuffer, byteOffset);
|
|
3513
3523
|
if (buffer instanceof DynamicBuffer) {
|
|
3514
3524
|
this._dynamicAttributeBufferSources[bufferSlot] = {
|
|
3515
3525
|
source: buffer,
|
|
3516
|
-
generation: buffer.generation
|
|
3526
|
+
generation: buffer.generation,
|
|
3527
|
+
byteOffset
|
|
3517
3528
|
};
|
|
3518
3529
|
} else {
|
|
3519
3530
|
delete this._dynamicAttributeBufferSources[bufferSlot];
|
|
@@ -3826,7 +3837,7 @@ var Model = class _Model {
|
|
|
3826
3837
|
}
|
|
3827
3838
|
for (const [locationKey, entry] of Object.entries(this._dynamicAttributeBufferSources)) {
|
|
3828
3839
|
if (entry.generation !== entry.source.generation) {
|
|
3829
|
-
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer);
|
|
3840
|
+
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer, entry.byteOffset);
|
|
3830
3841
|
entry.generation = entry.source.generation;
|
|
3831
3842
|
this.setNeedsRedraw("dynamic attribute buffer");
|
|
3832
3843
|
}
|
|
@@ -6210,13 +6221,303 @@ function getInstancedScenegraphBounds(bounds, instanceMatrices) {
|
|
|
6210
6221
|
return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
|
|
6211
6222
|
}
|
|
6212
6223
|
|
|
6213
|
-
// dist/geometry/
|
|
6224
|
+
// dist/geometry/edge-geometry.js
|
|
6214
6225
|
var import_core23 = require("@luma.gl/core");
|
|
6226
|
+
function makeEdgeGeometry(geometry, options = {}) {
|
|
6227
|
+
var _a;
|
|
6228
|
+
const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
|
|
6229
|
+
const positions = getTrianglePositions(geometry, positionAttribute);
|
|
6230
|
+
(0, import_core23.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
|
|
6231
|
+
(0, import_core23.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
|
|
6232
|
+
const sourceIndices = (_a = geometry.indices) == null ? void 0 : _a.value;
|
|
6233
|
+
const sourceCount = positions.value.length / 3;
|
|
6234
|
+
const representatives = /* @__PURE__ */ new Map();
|
|
6235
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
6236
|
+
const faces = /* @__PURE__ */ new Set();
|
|
6237
|
+
const edges = /* @__PURE__ */ new Map();
|
|
6238
|
+
const cosineThreshold = Math.cos(angleThreshold * Math.PI / 180);
|
|
6239
|
+
const toleranceSquared = weldTolerance * weldTolerance;
|
|
6240
|
+
function readPosition(index) {
|
|
6241
|
+
return [
|
|
6242
|
+
positions.value[index * 3],
|
|
6243
|
+
positions.value[index * 3 + 1],
|
|
6244
|
+
positions.value[index * 3 + 2]
|
|
6245
|
+
];
|
|
6246
|
+
}
|
|
6247
|
+
function weldPosition(index) {
|
|
6248
|
+
const cached = representatives.get(index);
|
|
6249
|
+
if (cached !== void 0)
|
|
6250
|
+
return cached;
|
|
6251
|
+
(0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
|
|
6252
|
+
const position = readPosition(index);
|
|
6253
|
+
(0, import_core23.assert)(position.every(Number.isFinite));
|
|
6254
|
+
const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
|
|
6255
|
+
const radius = weldTolerance > 0 ? 1 : 0;
|
|
6256
|
+
for (let east = -radius; east <= radius; east++) {
|
|
6257
|
+
for (let north = -radius; north <= radius; north++) {
|
|
6258
|
+
for (let up = -radius; up <= radius; up++) {
|
|
6259
|
+
const candidates = buckets.get(`${cell[0] + east},${cell[1] + north},${cell[2] + up}`);
|
|
6260
|
+
for (const candidate of candidates || []) {
|
|
6261
|
+
const other = readPosition(candidate);
|
|
6262
|
+
const distanceSquared = (position[0] - other[0]) ** 2 + (position[1] - other[1]) ** 2 + (position[2] - other[2]) ** 2;
|
|
6263
|
+
if (distanceSquared <= toleranceSquared) {
|
|
6264
|
+
representatives.set(index, candidate);
|
|
6265
|
+
return candidate;
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
const key = cell.join(",");
|
|
6272
|
+
const bucket = buckets.get(key) || [];
|
|
6273
|
+
bucket.push(index);
|
|
6274
|
+
buckets.set(key, bucket);
|
|
6275
|
+
representatives.set(index, index);
|
|
6276
|
+
return index;
|
|
6277
|
+
}
|
|
6278
|
+
function addEdge(first, second, normal) {
|
|
6279
|
+
const start = Math.min(first, second);
|
|
6280
|
+
const end = Math.max(first, second);
|
|
6281
|
+
const key = `${start},${end}`;
|
|
6282
|
+
const edge = edges.get(key);
|
|
6283
|
+
if (edge) {
|
|
6284
|
+
edge.faceCount++;
|
|
6285
|
+
const cosine = normal[0] * edge.normal[0] + normal[1] * edge.normal[1] + normal[2] * edge.normal[2];
|
|
6286
|
+
edge.crease ||= cosine < 1 - 1e-7 && cosine <= cosineThreshold + 1e-7;
|
|
6287
|
+
} else {
|
|
6288
|
+
edges.set(key, { start, end, normal, faceCount: 1, crease: false });
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
for (let offset = 0; offset < geometry.vertexCount; offset += 3) {
|
|
6292
|
+
const first = weldPosition((sourceIndices == null ? void 0 : sourceIndices[offset]) ?? offset);
|
|
6293
|
+
const second = weldPosition((sourceIndices == null ? void 0 : sourceIndices[offset + 1]) ?? offset + 1);
|
|
6294
|
+
const third = weldPosition((sourceIndices == null ? void 0 : sourceIndices[offset + 2]) ?? offset + 2);
|
|
6295
|
+
if (first === second || second === third || third === first)
|
|
6296
|
+
continue;
|
|
6297
|
+
const faceKey = [first, second, third].sort((left, right) => left - right).join(",");
|
|
6298
|
+
if (faces.has(faceKey))
|
|
6299
|
+
continue;
|
|
6300
|
+
faces.add(faceKey);
|
|
6301
|
+
const start = readPosition(first);
|
|
6302
|
+
const end = readPosition(second);
|
|
6303
|
+
const corner = readPosition(third);
|
|
6304
|
+
const firstDirection = end.map((value, axis) => value - start[axis]);
|
|
6305
|
+
const secondDirection = corner.map((value, axis) => value - start[axis]);
|
|
6306
|
+
const normal = [
|
|
6307
|
+
firstDirection[1] * secondDirection[2] - firstDirection[2] * secondDirection[1],
|
|
6308
|
+
firstDirection[2] * secondDirection[0] - firstDirection[0] * secondDirection[2],
|
|
6309
|
+
firstDirection[0] * secondDirection[1] - firstDirection[1] * secondDirection[0]
|
|
6310
|
+
];
|
|
6311
|
+
const magnitude = Math.hypot(...normal);
|
|
6312
|
+
if (magnitude === 0)
|
|
6313
|
+
continue;
|
|
6314
|
+
normal[0] /= magnitude;
|
|
6315
|
+
normal[1] /= magnitude;
|
|
6316
|
+
normal[2] /= magnitude;
|
|
6317
|
+
addEdge(first, second, normal);
|
|
6318
|
+
addEdge(second, third, normal);
|
|
6319
|
+
addEdge(third, first, normal);
|
|
6320
|
+
}
|
|
6321
|
+
const selected = [...edges.values()].filter((edge) => options.includeCoplanarEdges || edge.faceCount !== 2 || edge.crease).sort((left, right) => left.start - right.start || left.end - right.end);
|
|
6322
|
+
return new Geometry({
|
|
6323
|
+
id: `${geometry.id}-edges`,
|
|
6324
|
+
topology: "line-list",
|
|
6325
|
+
attributes: { [positionAttribute]: positions },
|
|
6326
|
+
indices: new Uint32Array(selected.flatMap((edge) => [edge.start, edge.end]))
|
|
6327
|
+
});
|
|
6328
|
+
}
|
|
6329
|
+
function makeEdgeGeometryFromGeometries(geometries, options = {}) {
|
|
6330
|
+
var _a;
|
|
6331
|
+
(0, import_core23.assert)(geometries.length > 0);
|
|
6332
|
+
const positionAttribute = options.positionAttribute ?? "POSITION";
|
|
6333
|
+
const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
|
|
6334
|
+
const firstAttribute = attributes[0];
|
|
6335
|
+
(0, import_core23.assert)(attributes.every((attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])));
|
|
6336
|
+
const PositionArray = firstAttribute.value.constructor;
|
|
6337
|
+
const positions = new PositionArray(attributes.reduce((count, attribute) => count + attribute.value.length, 0));
|
|
6338
|
+
const indices = new Uint32Array(geometries.reduce((count, geometry) => count + geometry.vertexCount, 0));
|
|
6339
|
+
let positionOffset = 0;
|
|
6340
|
+
let indexOffset = 0;
|
|
6341
|
+
for (const [geometryIndex, geometry] of geometries.entries()) {
|
|
6342
|
+
const attribute = attributes[geometryIndex];
|
|
6343
|
+
positions.set(attribute.value, positionOffset);
|
|
6344
|
+
for (let offset = 0; offset < geometry.vertexCount; offset++) {
|
|
6345
|
+
const index = ((_a = geometry.indices) == null ? void 0 : _a.value[offset]) ?? offset;
|
|
6346
|
+
(0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
|
|
6347
|
+
indices[indexOffset++] = index + positionOffset / 3;
|
|
6348
|
+
}
|
|
6349
|
+
positionOffset += attribute.value.length;
|
|
6350
|
+
}
|
|
6351
|
+
return makeEdgeGeometry(new Geometry({
|
|
6352
|
+
id: `${geometries[0].id}-batch`,
|
|
6353
|
+
topology: "triangle-list",
|
|
6354
|
+
attributes: { [positionAttribute]: { ...firstAttribute, value: positions } },
|
|
6355
|
+
indices
|
|
6356
|
+
}), options);
|
|
6357
|
+
}
|
|
6358
|
+
function getTrianglePositions(geometry, positionAttribute) {
|
|
6359
|
+
var _a;
|
|
6360
|
+
const positions = geometry.attributes[positionAttribute];
|
|
6361
|
+
(0, import_core23.assert)(geometry.topology === "triangle-list" && (positions == null ? void 0 : positions.size) === 3);
|
|
6362
|
+
(0, import_core23.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
|
|
6363
|
+
(0, import_core23.assert)(!positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3);
|
|
6364
|
+
(0, import_core23.assert)(geometry.vertexCount >= 0 && geometry.vertexCount <= (((_a = geometry.indices) == null ? void 0 : _a.value.length) ?? positions.value.length / 3));
|
|
6365
|
+
return positions;
|
|
6366
|
+
}
|
|
6367
|
+
|
|
6368
|
+
// dist/geometry/stroke-geometry.js
|
|
6369
|
+
var import_core24 = require("@luma.gl/core");
|
|
6370
|
+
function makeStrokeGeometry(path, options = {}) {
|
|
6371
|
+
const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
|
|
6372
|
+
(0, import_core24.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
|
|
6373
|
+
(0, import_core24.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
|
|
6374
|
+
const points = [];
|
|
6375
|
+
for (const position of path) {
|
|
6376
|
+
(0, import_core24.assert)(Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0));
|
|
6377
|
+
const previous = points.at(-1);
|
|
6378
|
+
if (!previous || previous[0] !== position[0] || previous[1] !== position[1])
|
|
6379
|
+
points.push([position[0], position[1], position[2] ?? 0]);
|
|
6380
|
+
}
|
|
6381
|
+
if (options.closed && points.length > 1 && points[0][0] === points.at(-1)[0] && points[0][1] === points.at(-1)[1])
|
|
6382
|
+
points.pop();
|
|
6383
|
+
const closed = Boolean(options.closed && points.length > 2);
|
|
6384
|
+
const positions = [];
|
|
6385
|
+
const coordinates = [];
|
|
6386
|
+
const halfWidth = width / 2;
|
|
6387
|
+
if (points.length > 1 && width > 0) {
|
|
6388
|
+
const segments = [];
|
|
6389
|
+
const distances = [0];
|
|
6390
|
+
for (let index = 0; index < points.length - (closed ? 0 : 1); index++) {
|
|
6391
|
+
const start = points[index];
|
|
6392
|
+
const end = points[(index + 1) % points.length];
|
|
6393
|
+
const horizontal = end[0] - start[0];
|
|
6394
|
+
const vertical = end[1] - start[1];
|
|
6395
|
+
const length = Math.hypot(horizontal, vertical);
|
|
6396
|
+
segments.push({ direction: [horizontal / length, vertical / length], length });
|
|
6397
|
+
distances.push(distances.at(-1) + length);
|
|
6398
|
+
}
|
|
6399
|
+
const corners = points.map((point, index) => {
|
|
6400
|
+
const previous = segments[(index - 1 + segments.length) % segments.length];
|
|
6401
|
+
const next = segments[index % segments.length];
|
|
6402
|
+
const distance = distances[index];
|
|
6403
|
+
if (!closed && (index === 0 || index === points.length - 1)) {
|
|
6404
|
+
const direction = index === 0 ? next.direction : previous.direction;
|
|
6405
|
+
const extension = cap === "square" ? index === 0 ? -halfWidth : halfWidth : 0;
|
|
6406
|
+
const left = createVertex(point, direction, halfWidth, extension, distance + extension);
|
|
6407
|
+
const right = createVertex(point, direction, -halfWidth, extension, distance + extension);
|
|
6408
|
+
if (cap === "round")
|
|
6409
|
+
appendCap(point, direction, distance, index === 0);
|
|
6410
|
+
return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
|
|
6411
|
+
}
|
|
6412
|
+
const incoming = previous.direction;
|
|
6413
|
+
const outgoing = next.direction;
|
|
6414
|
+
const turn = incoming[0] * outgoing[1] - incoming[1] * outgoing[0];
|
|
6415
|
+
const cosine = incoming[0] * outgoing[0] + incoming[1] * outgoing[1];
|
|
6416
|
+
const result = {
|
|
6417
|
+
incomingLeft: createVertex(point, incoming, halfWidth, 0, distance),
|
|
6418
|
+
incomingRight: createVertex(point, incoming, -halfWidth, 0, distance),
|
|
6419
|
+
outgoingLeft: createVertex(point, outgoing, halfWidth, 0, distance),
|
|
6420
|
+
outgoingRight: createVertex(point, outgoing, -halfWidth, 0, distance)
|
|
6421
|
+
};
|
|
6422
|
+
if (1 + cosine < 1e-8) {
|
|
6423
|
+
if (join === "round") {
|
|
6424
|
+
appendCap(point, incoming, distance, false);
|
|
6425
|
+
appendCap(point, outgoing, distance, true);
|
|
6426
|
+
}
|
|
6427
|
+
return result;
|
|
6428
|
+
}
|
|
6429
|
+
const miter = [
|
|
6430
|
+
-(incoming[1] + outgoing[1]) * halfWidth / (1 + cosine),
|
|
6431
|
+
(incoming[0] + outgoing[0]) * halfWidth / (1 + cosine)
|
|
6432
|
+
];
|
|
6433
|
+
const miterLength = Math.hypot(...miter);
|
|
6434
|
+
if (Math.abs(turn) < 1e-8 || join === "miter" && miterLength <= miterLimit * halfWidth) {
|
|
6435
|
+
const left = offsetVertex(point, miter, distance, halfWidth);
|
|
6436
|
+
const right = offsetVertex(point, [-miter[0], -miter[1]], distance, -halfWidth);
|
|
6437
|
+
return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
|
|
6438
|
+
}
|
|
6439
|
+
const innerSide = Math.sign(turn);
|
|
6440
|
+
const innerScale = Math.min(1, Math.min(previous.length, next.length) / (2 * miterLength));
|
|
6441
|
+
const inner = offsetVertex(point, [miter[0] * innerSide * innerScale, miter[1] * innerSide * innerScale], distance, halfWidth * innerSide);
|
|
6442
|
+
if (innerSide > 0) {
|
|
6443
|
+
result.incomingLeft = inner;
|
|
6444
|
+
result.outgoingLeft = inner;
|
|
6445
|
+
} else {
|
|
6446
|
+
result.incomingRight = inner;
|
|
6447
|
+
result.outgoingRight = inner;
|
|
6448
|
+
}
|
|
6449
|
+
const outerStart = innerSide > 0 ? result.incomingRight : result.incomingLeft;
|
|
6450
|
+
const outerEnd = innerSide > 0 ? result.outgoingRight : result.outgoingLeft;
|
|
6451
|
+
if (join === "round") {
|
|
6452
|
+
const sweep = Math.atan2(turn, cosine);
|
|
6453
|
+
const startAngle = Math.atan2(outerStart.position[1] - point[1], outerStart.position[0] - point[0]);
|
|
6454
|
+
const steps = Math.max(1, Math.ceil(Math.abs(sweep) / Math.PI * roundSegments));
|
|
6455
|
+
let previousOuter = outerStart;
|
|
6456
|
+
for (let step = 1; step <= steps; step++) {
|
|
6457
|
+
const angle = startAngle + sweep * step / steps;
|
|
6458
|
+
const currentOuter = step === steps ? outerEnd : offsetVertex(point, [Math.cos(angle) * halfWidth, Math.sin(angle) * halfWidth], distance, -halfWidth * innerSide);
|
|
6459
|
+
appendTriangle(inner, previousOuter, currentOuter);
|
|
6460
|
+
previousOuter = currentOuter;
|
|
6461
|
+
}
|
|
6462
|
+
} else
|
|
6463
|
+
appendTriangle(inner, outerStart, outerEnd);
|
|
6464
|
+
return result;
|
|
6465
|
+
});
|
|
6466
|
+
segments.forEach((_segment, index) => {
|
|
6467
|
+
const start = corners[index];
|
|
6468
|
+
const end = corners[(index + 1) % corners.length];
|
|
6469
|
+
const closing = closed && index === segments.length - 1;
|
|
6470
|
+
const endLeft = closing ? { ...end.incomingLeft, distance: distances.at(-1) } : end.incomingLeft;
|
|
6471
|
+
const endRight = closing ? { ...end.incomingRight, distance: distances.at(-1) } : end.incomingRight;
|
|
6472
|
+
appendTriangle(start.outgoingLeft, start.outgoingRight, endLeft);
|
|
6473
|
+
appendTriangle(start.outgoingRight, endRight, endLeft);
|
|
6474
|
+
});
|
|
6475
|
+
}
|
|
6476
|
+
return new Geometry({
|
|
6477
|
+
id: options.id,
|
|
6478
|
+
topology: "triangle-list",
|
|
6479
|
+
attributes: {
|
|
6480
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
6481
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(coordinates) }
|
|
6482
|
+
}
|
|
6483
|
+
});
|
|
6484
|
+
function appendTriangle(first, second, third) {
|
|
6485
|
+
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]);
|
|
6486
|
+
if (area === 0)
|
|
6487
|
+
return;
|
|
6488
|
+
for (const vertex of area > 0 ? [first, second, third] : [first, third, second]) {
|
|
6489
|
+
positions.push(...vertex.position);
|
|
6490
|
+
coordinates.push(vertex.distance, vertex.across);
|
|
6491
|
+
}
|
|
6492
|
+
}
|
|
6493
|
+
function offsetVertex(point, offset, distance, across) {
|
|
6494
|
+
return { position: [point[0] + offset[0], point[1] + offset[1], point[2]], distance, across };
|
|
6495
|
+
}
|
|
6496
|
+
function createVertex(point, direction, across, along, distance) {
|
|
6497
|
+
return offsetVertex(point, [-direction[1] * across + direction[0] * along, direction[0] * across + direction[1] * along], distance, across);
|
|
6498
|
+
}
|
|
6499
|
+
function appendCap(point, direction, distance, start) {
|
|
6500
|
+
const center = { position: point, distance, across: 0 };
|
|
6501
|
+
const startAngle = Math.atan2(direction[1], direction[0]) + (start ? -Math.PI / 2 : Math.PI / 2);
|
|
6502
|
+
let previous;
|
|
6503
|
+
for (let step = 0; step <= roundSegments; step++) {
|
|
6504
|
+
const angle = startAngle - Math.PI * step / roundSegments;
|
|
6505
|
+
const offset = [Math.cos(angle) * halfWidth, Math.sin(angle) * halfWidth];
|
|
6506
|
+
const current = offsetVertex(point, offset, distance + offset[0] * direction[0] + offset[1] * direction[1], -offset[0] * direction[1] + offset[1] * direction[0]);
|
|
6507
|
+
if (previous)
|
|
6508
|
+
appendTriangle(center, previous, current);
|
|
6509
|
+
previous = current;
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
// dist/geometry/mesh-simplification.js
|
|
6515
|
+
var import_core25 = require("@luma.gl/core");
|
|
6215
6516
|
var QUADRIC_COMPONENTS = 10;
|
|
6216
6517
|
var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
|
|
6217
6518
|
function simplifyMesh(options) {
|
|
6218
6519
|
const { positions, indices, attributes = [], preserveBoundary = true } = options;
|
|
6219
|
-
(0,
|
|
6520
|
+
(0, import_core25.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
|
|
6220
6521
|
const targetIndexCount = Math.max(0, Math.min(indices.length, Math.floor((options.targetIndexCount ?? indices.length * (options.targetRatio ?? 0.5)) / 3) * 3));
|
|
6221
6522
|
if (indices.length === 0 || targetIndexCount >= indices.length) {
|
|
6222
6523
|
return { indices: indices.slice(), geometricError: 0 };
|
|
@@ -6303,7 +6604,7 @@ function simplifyMesh(options) {
|
|
|
6303
6604
|
const firstVertex = indices[indexOffset2];
|
|
6304
6605
|
const secondVertex = indices[indexOffset2 + 1];
|
|
6305
6606
|
const thirdVertex = indices[indexOffset2 + 2];
|
|
6306
|
-
(0,
|
|
6607
|
+
(0, import_core25.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
|
|
6307
6608
|
const triangle = {
|
|
6308
6609
|
vertices: [firstVertex, secondVertex, thirdVertex],
|
|
6309
6610
|
active: false
|
|
@@ -7260,7 +7561,7 @@ var CylinderGeometry = class extends TruncatedConeGeometry {
|
|
|
7260
7561
|
};
|
|
7261
7562
|
|
|
7262
7563
|
// dist/geometries/ico-sphere-geometry.js
|
|
7263
|
-
var
|
|
7564
|
+
var import_core26 = require("@math.gl/core");
|
|
7264
7565
|
var ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
|
|
7265
7566
|
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];
|
|
7266
7567
|
var IcoSphereGeometry = class extends Geometry {
|
|
@@ -7360,7 +7661,7 @@ function tesselateIcosaHedron(props) {
|
|
|
7360
7661
|
const u3 = 1 - phi3 / PI2;
|
|
7361
7662
|
const vec1 = [x3 - x2, y3 - y2, z3 - z2];
|
|
7362
7663
|
const vec2 = [x1 - x2, y1 - y2, z1 - z2];
|
|
7363
|
-
const normal = new
|
|
7664
|
+
const normal = new import_core26.Vector3(vec1).cross(vec2).normalize();
|
|
7364
7665
|
let newIndex;
|
|
7365
7666
|
if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
|
|
7366
7667
|
positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
|
|
@@ -7562,7 +7863,7 @@ function isAbsoluteLoadFileUrl(url) {
|
|
|
7562
7863
|
}
|
|
7563
7864
|
|
|
7564
7865
|
// dist/dynamic-texture/video-texture.js
|
|
7565
|
-
var
|
|
7866
|
+
var import_core27 = require("@luma.gl/core");
|
|
7566
7867
|
var VideoTexture = class {
|
|
7567
7868
|
/** Device used to create copied and native external texture bindings. */
|
|
7568
7869
|
device;
|
|
@@ -7611,7 +7912,7 @@ var VideoTexture = class {
|
|
|
7611
7912
|
* @param props Live video source and copied texture options.
|
|
7612
7913
|
*/
|
|
7613
7914
|
constructor(device, props) {
|
|
7614
|
-
(0,
|
|
7915
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(props == null ? void 0 : props.source) || isVideoFrameSource(props == null ? void 0 : props.source));
|
|
7615
7916
|
this.device = device;
|
|
7616
7917
|
this.id = props.id || uid("video-texture");
|
|
7617
7918
|
this._source = props.source;
|
|
@@ -7625,7 +7926,7 @@ var VideoTexture = class {
|
|
|
7625
7926
|
* @param source Next caller-owned video source to follow.
|
|
7626
7927
|
*/
|
|
7627
7928
|
setSource(source4) {
|
|
7628
|
-
(0,
|
|
7929
|
+
(0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
|
|
7629
7930
|
this._destroyExternalTexture();
|
|
7630
7931
|
this._source = source4;
|
|
7631
7932
|
this._sourceVersion++;
|
|
@@ -7705,7 +8006,7 @@ var VideoTexture = class {
|
|
|
7705
8006
|
width: size.width,
|
|
7706
8007
|
height: size.height,
|
|
7707
8008
|
format: "rgba8unorm",
|
|
7708
|
-
usage:
|
|
8009
|
+
usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
|
|
7709
8010
|
mipLevels: 1,
|
|
7710
8011
|
sampler: this._sampler
|
|
7711
8012
|
});
|
|
@@ -7741,7 +8042,7 @@ var VideoTexture = class {
|
|
|
7741
8042
|
*/
|
|
7742
8043
|
_getResolvedSize() {
|
|
7743
8044
|
const size = getVideoTextureSourceSize(this._source);
|
|
7744
|
-
(0,
|
|
8045
|
+
(0, import_core27.assert)(size.width > 0 && size.height > 0);
|
|
7745
8046
|
return size;
|
|
7746
8047
|
}
|
|
7747
8048
|
/** Observes current source readiness and frame identity before binding resolution. */
|
|
@@ -7806,11 +8107,11 @@ function getVideoTextureSourceFrameToken(source4, sourceVersion) {
|
|
|
7806
8107
|
}
|
|
7807
8108
|
|
|
7808
8109
|
// dist/passes/shader-pass-renderer.js
|
|
7809
|
-
var
|
|
8110
|
+
var import_core30 = require("@luma.gl/core");
|
|
7810
8111
|
var import_shadertools7 = require("@luma.gl/shadertools");
|
|
7811
8112
|
|
|
7812
8113
|
// dist/compute/swap.js
|
|
7813
|
-
var
|
|
8114
|
+
var import_core28 = require("@luma.gl/core");
|
|
7814
8115
|
var Swap = class {
|
|
7815
8116
|
id;
|
|
7816
8117
|
/** The current resource - usually the source for renders or computations */
|
|
@@ -7843,7 +8144,7 @@ var SwapFramebuffers = class extends Swap {
|
|
|
7843
8144
|
let colorAttachments = (_a = props.colorAttachments) == null ? void 0 : _a.map((colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
7844
8145
|
id: `${props.id}-texture-0`,
|
|
7845
8146
|
format: colorAttachment,
|
|
7846
|
-
usage:
|
|
8147
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
7847
8148
|
width,
|
|
7848
8149
|
height
|
|
7849
8150
|
}));
|
|
@@ -7851,7 +8152,7 @@ var SwapFramebuffers = class extends Swap {
|
|
|
7851
8152
|
colorAttachments = (_b = props.colorAttachments) == null ? void 0 : _b.map((colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
|
|
7852
8153
|
id: `${props.id}-texture-1`,
|
|
7853
8154
|
format: colorAttachment,
|
|
7854
|
-
usage:
|
|
8155
|
+
usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
|
|
7855
8156
|
width,
|
|
7856
8157
|
height
|
|
7857
8158
|
}));
|
|
@@ -7914,7 +8215,7 @@ var SwapBuffers = class extends Swap {
|
|
|
7914
8215
|
};
|
|
7915
8216
|
|
|
7916
8217
|
// dist/compute/computation.js
|
|
7917
|
-
var
|
|
8218
|
+
var import_core29 = require("@luma.gl/core");
|
|
7918
8219
|
var import_shadertools6 = require("@luma.gl/shadertools");
|
|
7919
8220
|
var import_types2 = require("@math.gl/types");
|
|
7920
8221
|
var LOG_DRAW_PRIORITY2 = 2;
|
|
@@ -7927,14 +8228,14 @@ var Computation = class _Computation {
|
|
|
7927
8228
|
* constructor remains the synchronous compatibility path.
|
|
7928
8229
|
*/
|
|
7929
8230
|
static async createAsync(device, props) {
|
|
7930
|
-
const ownsCompilation = !
|
|
7931
|
-
const asyncCompilation = ownsCompilation ?
|
|
8231
|
+
const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
8232
|
+
const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
|
|
7932
8233
|
let computation;
|
|
7933
8234
|
try {
|
|
7934
8235
|
computation = new _Computation(device, props);
|
|
7935
8236
|
} finally {
|
|
7936
8237
|
if (ownsCompilation)
|
|
7937
|
-
|
|
8238
|
+
import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
7938
8239
|
}
|
|
7939
8240
|
try {
|
|
7940
8241
|
if (ownsCompilation) {
|
|
@@ -7949,11 +8250,12 @@ var Computation = class _Computation {
|
|
|
7949
8250
|
}
|
|
7950
8251
|
}
|
|
7951
8252
|
static defaultProps = {
|
|
7952
|
-
...
|
|
8253
|
+
...import_core29.ComputePipeline.defaultProps,
|
|
7953
8254
|
id: "unnamed",
|
|
7954
8255
|
handle: void 0,
|
|
7955
8256
|
userData: {},
|
|
7956
8257
|
source: "",
|
|
8258
|
+
sourceLanguage: void 0,
|
|
7957
8259
|
modules: [],
|
|
7958
8260
|
defines: {},
|
|
7959
8261
|
plugins: [],
|
|
@@ -8012,23 +8314,26 @@ var Computation = class _Computation {
|
|
|
8012
8314
|
const modules = mergeShaderModules(this.props.modules, (_a = this.shaderInputs) == null ? void 0 : _a.getModules());
|
|
8013
8315
|
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
8014
8316
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
8015
|
-
this.pipelineFactory = props.pipelineFactory ||
|
|
8016
|
-
this.shaderFactory = props.shaderFactory ||
|
|
8317
|
+
this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
8318
|
+
this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
8017
8319
|
const shaderAssembler = this.props.shaderAssembler;
|
|
8018
|
-
(0,
|
|
8019
|
-
const { source: source4, getUniforms: getUniforms2, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
8320
|
+
(0, import_core29.assert)(shaderAssembler instanceof import_shadertools6.WGSLShaderAssembler);
|
|
8321
|
+
const { source: source4, getUniforms: getUniforms2, entryPoints = {}, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
8020
8322
|
platformInfo,
|
|
8021
8323
|
...this.props,
|
|
8022
8324
|
modules,
|
|
8023
8325
|
defines,
|
|
8326
|
+
shaderStage: "compute",
|
|
8327
|
+
computeEntryPoint: this.props.entryPoint,
|
|
8024
8328
|
scanVertexAttributes: false,
|
|
8025
8329
|
pluginInjections: resolvedPlugins.injections
|
|
8026
8330
|
});
|
|
8027
8331
|
this.source = source4;
|
|
8332
|
+
this.props.entryPoint = entryPoints.compute || this.props.entryPoint;
|
|
8028
8333
|
this._getModuleUniforms = getUniforms2;
|
|
8029
8334
|
const inferredShaderLayout = assembledShaderLayout ?? ((_b = device.getShaderLayout) == null ? void 0 : _b.call(device, this.source, { scanVertexAttributes: false }));
|
|
8030
8335
|
this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout || inferredShaderLayout || null, modules) || null;
|
|
8031
|
-
const asyncCompilation =
|
|
8336
|
+
const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
|
|
8032
8337
|
if (asyncCompilation) {
|
|
8033
8338
|
this._pipelineInitialization = this._updatePipelineAsync();
|
|
8034
8339
|
asyncCompilation.push(this._pipelineInitialization);
|
|
@@ -8098,7 +8403,7 @@ var Computation = class _Computation {
|
|
|
8098
8403
|
}
|
|
8099
8404
|
setShaderInputs(shaderInputs) {
|
|
8100
8405
|
this.shaderInputs = shaderInputs;
|
|
8101
|
-
this._uniformStore = new
|
|
8406
|
+
this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
|
|
8102
8407
|
for (const [moduleName, module2] of Object.entries(this.shaderInputs.modules)) {
|
|
8103
8408
|
if (shaderModuleHasUniforms(module2)) {
|
|
8104
8409
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
@@ -8168,7 +8473,7 @@ var Computation = class _Computation {
|
|
|
8168
8473
|
return null;
|
|
8169
8474
|
const previousShader = this.pipeline ? this.shader : null;
|
|
8170
8475
|
if (this.pipeline) {
|
|
8171
|
-
|
|
8476
|
+
import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
8172
8477
|
}
|
|
8173
8478
|
this._pipelineNeedsUpdate = false;
|
|
8174
8479
|
this.shader = this.shaderFactory.createShader({
|
|
@@ -8187,27 +8492,27 @@ var Computation = class _Computation {
|
|
|
8187
8492
|
_lastLogTime = 0;
|
|
8188
8493
|
_logOpen = false;
|
|
8189
8494
|
_logDrawCallStart() {
|
|
8190
|
-
const logDrawTimeout =
|
|
8191
|
-
if (
|
|
8495
|
+
const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
|
|
8496
|
+
if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
8192
8497
|
return;
|
|
8193
8498
|
}
|
|
8194
8499
|
this._lastLogTime = Date.now();
|
|
8195
8500
|
this._logOpen = true;
|
|
8196
|
-
|
|
8501
|
+
import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
|
|
8197
8502
|
}
|
|
8198
8503
|
_logDrawCallEnd() {
|
|
8199
8504
|
if (this._logOpen) {
|
|
8200
8505
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
8201
|
-
|
|
8202
|
-
|
|
8506
|
+
import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
|
|
8507
|
+
import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
|
|
8203
8508
|
this._logOpen = false;
|
|
8204
8509
|
}
|
|
8205
8510
|
}
|
|
8206
8511
|
_drawCount = 0;
|
|
8207
8512
|
// TODO - fix typing of luma data types
|
|
8208
8513
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
8209
|
-
const TypedArrayConstructor =
|
|
8210
|
-
const typedArray = attribute instanceof
|
|
8514
|
+
const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
8515
|
+
const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
8211
8516
|
return typedArray.toString();
|
|
8212
8517
|
}
|
|
8213
8518
|
};
|
|
@@ -8743,7 +9048,7 @@ var CompositeShaderPassComputeRenderer = class {
|
|
|
8743
9048
|
this.parameterBuffer = device.createBuffer({
|
|
8744
9049
|
id: `${optimization.name}-parameters`,
|
|
8745
9050
|
byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
|
|
8746
|
-
usage:
|
|
9051
|
+
usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
|
|
8747
9052
|
});
|
|
8748
9053
|
const outputBindings = Object.entries(optimization.outputs).map(([bindingName, targetName], outputIndex) => ({
|
|
8749
9054
|
name: bindingName,
|
|
@@ -9003,7 +9308,7 @@ function createTargetResources(device, name, spec, targetSize) {
|
|
|
9003
9308
|
width: targetSize[0],
|
|
9004
9309
|
height: targetSize[1],
|
|
9005
9310
|
format: spec.format || device.preferredColorFormat,
|
|
9006
|
-
usage:
|
|
9311
|
+
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),
|
|
9007
9312
|
...spec.sampler ? { sampler: spec.sampler } : {}
|
|
9008
9313
|
});
|
|
9009
9314
|
const framebuffer = device.createFramebuffer({
|
|
@@ -9059,18 +9364,18 @@ function calculateTextureScale(sourceTexture, outputTexture) {
|
|
|
9059
9364
|
}
|
|
9060
9365
|
|
|
9061
9366
|
// dist/compute/kernel.js
|
|
9062
|
-
var
|
|
9367
|
+
var import_core31 = require("@luma.gl/core");
|
|
9063
9368
|
var Kernel = class _Kernel {
|
|
9064
9369
|
/** Creates a kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
9065
9370
|
static async createAsync(device, props) {
|
|
9066
|
-
const ownsCompilation = !
|
|
9067
|
-
const asyncCompilation = ownsCompilation ?
|
|
9371
|
+
const ownsCompilation = !import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
9372
|
+
const asyncCompilation = ownsCompilation ? import_core31.PipelineFactory.beginAsyncCompilation(device) : import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
9068
9373
|
let kernel;
|
|
9069
9374
|
try {
|
|
9070
9375
|
kernel = new _Kernel(device, props);
|
|
9071
9376
|
} finally {
|
|
9072
9377
|
if (ownsCompilation)
|
|
9073
|
-
|
|
9378
|
+
import_core31.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
9074
9379
|
}
|
|
9075
9380
|
try {
|
|
9076
9381
|
if (ownsCompilation) {
|
|
@@ -9101,8 +9406,8 @@ var Kernel = class _Kernel {
|
|
|
9101
9406
|
this.device = device;
|
|
9102
9407
|
this.id = props.id ?? "kernel";
|
|
9103
9408
|
this.source = source4;
|
|
9104
|
-
this.pipelineFactory = pipelineFactory ??
|
|
9105
|
-
this.shaderFactory = shaderFactory ??
|
|
9409
|
+
this.pipelineFactory = pipelineFactory ?? import_core31.PipelineFactory.getDefaultPipelineFactory(device);
|
|
9410
|
+
this.shaderFactory = shaderFactory ?? import_core31.ShaderFactory.getDefaultShaderFactory(device);
|
|
9106
9411
|
this.shader = this.shaderFactory.createShader({
|
|
9107
9412
|
id: `${this.id}-compute`,
|
|
9108
9413
|
stage: "compute",
|
|
@@ -9110,7 +9415,7 @@ var Kernel = class _Kernel {
|
|
|
9110
9415
|
debugShaders
|
|
9111
9416
|
});
|
|
9112
9417
|
const computePipelineProps = { ...pipelineProps, shader: this.shader };
|
|
9113
|
-
const asyncCompilation =
|
|
9418
|
+
const asyncCompilation = import_core31.PipelineFactory.getAsyncCompilation(device);
|
|
9114
9419
|
if (asyncCompilation) {
|
|
9115
9420
|
const pipelineInitialization = this.pipelineFactory.createComputePipelineAsync(computePipelineProps);
|
|
9116
9421
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -9147,18 +9452,18 @@ var Kernel = class _Kernel {
|
|
|
9147
9452
|
};
|
|
9148
9453
|
|
|
9149
9454
|
// dist/compute/render-kernel.js
|
|
9150
|
-
var
|
|
9455
|
+
var import_core32 = require("@luma.gl/core");
|
|
9151
9456
|
var RenderKernel = class _RenderKernel {
|
|
9152
9457
|
/** Creates a render kernel while allowing the backend to compile its pipeline asynchronously. */
|
|
9153
9458
|
static async createAsync(device, props) {
|
|
9154
|
-
const ownsCompilation = !
|
|
9155
|
-
const asyncCompilation = ownsCompilation ?
|
|
9459
|
+
const ownsCompilation = !import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
9460
|
+
const asyncCompilation = ownsCompilation ? import_core32.PipelineFactory.beginAsyncCompilation(device) : import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
9156
9461
|
let kernel;
|
|
9157
9462
|
try {
|
|
9158
9463
|
kernel = new _RenderKernel(device, props);
|
|
9159
9464
|
} finally {
|
|
9160
9465
|
if (ownsCompilation)
|
|
9161
|
-
|
|
9466
|
+
import_core32.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
9162
9467
|
}
|
|
9163
9468
|
try {
|
|
9164
9469
|
if (ownsCompilation) {
|
|
@@ -9192,8 +9497,8 @@ var RenderKernel = class _RenderKernel {
|
|
|
9192
9497
|
this.id = props.id ?? "render-kernel";
|
|
9193
9498
|
this.vertexSource = vertexSource;
|
|
9194
9499
|
this.fragmentSource = fragmentSource;
|
|
9195
|
-
this.pipelineFactory = pipelineFactory ??
|
|
9196
|
-
this.shaderFactory = shaderFactory ??
|
|
9500
|
+
this.pipelineFactory = pipelineFactory ?? import_core32.PipelineFactory.getDefaultPipelineFactory(device);
|
|
9501
|
+
this.shaderFactory = shaderFactory ?? import_core32.ShaderFactory.getDefaultShaderFactory(device);
|
|
9197
9502
|
this.vertexShader = this.shaderFactory.createShader({
|
|
9198
9503
|
id: `${this.id}-vertex`,
|
|
9199
9504
|
stage: "vertex",
|
|
@@ -9211,7 +9516,7 @@ var RenderKernel = class _RenderKernel {
|
|
|
9211
9516
|
vs: this.vertexShader,
|
|
9212
9517
|
fs: this.fragmentShader
|
|
9213
9518
|
};
|
|
9214
|
-
const asyncCompilation =
|
|
9519
|
+
const asyncCompilation = import_core32.PipelineFactory.getAsyncCompilation(device);
|
|
9215
9520
|
if (asyncCompilation) {
|
|
9216
9521
|
const pipelineInitialization = this.pipelineFactory.createRenderPipelineAsync(renderPipelineProps);
|
|
9217
9522
|
this._pipelineInitialization = pipelineInitialization;
|
|
@@ -9259,7 +9564,7 @@ var RenderKernel = class _RenderKernel {
|
|
|
9259
9564
|
};
|
|
9260
9565
|
|
|
9261
9566
|
// dist/modules/picking/picking-manager.js
|
|
9262
|
-
var
|
|
9567
|
+
var import_core33 = require("@luma.gl/core");
|
|
9263
9568
|
|
|
9264
9569
|
// dist/modules/picking/picking-uniforms.js
|
|
9265
9570
|
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
@@ -9518,13 +9823,13 @@ var PickingManager = class _PickingManager {
|
|
|
9518
9823
|
format: "rgba8unorm",
|
|
9519
9824
|
width: 1,
|
|
9520
9825
|
height: 1,
|
|
9521
|
-
usage:
|
|
9826
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT
|
|
9522
9827
|
});
|
|
9523
9828
|
const pickingTexture = this.device.createTexture({
|
|
9524
9829
|
format: "rg32sint",
|
|
9525
9830
|
width: 1,
|
|
9526
9831
|
height: 1,
|
|
9527
|
-
usage:
|
|
9832
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
|
|
9528
9833
|
});
|
|
9529
9834
|
return this.device.createFramebuffer({
|
|
9530
9835
|
colorAttachments: [colorTexture, pickingTexture],
|
|
@@ -9536,7 +9841,7 @@ var PickingManager = class _PickingManager {
|
|
|
9536
9841
|
format: "rgba8unorm",
|
|
9537
9842
|
width: 1,
|
|
9538
9843
|
height: 1,
|
|
9539
|
-
usage:
|
|
9844
|
+
usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
|
|
9540
9845
|
});
|
|
9541
9846
|
return this.device.createFramebuffer({
|
|
9542
9847
|
colorAttachments: [pickingTexture],
|
|
@@ -9560,7 +9865,7 @@ var PickingManager = class _PickingManager {
|
|
|
9560
9865
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
9561
9866
|
const readBuffer = this.device.createBuffer({
|
|
9562
9867
|
byteLength: layout.byteLength,
|
|
9563
|
-
usage:
|
|
9868
|
+
usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
|
|
9564
9869
|
});
|
|
9565
9870
|
try {
|
|
9566
9871
|
pickTexture.readBuffer({
|
|
@@ -9594,7 +9899,7 @@ var PickingManager = class _PickingManager {
|
|
|
9594
9899
|
const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
|
|
9595
9900
|
const readBuffer = this.device.createBuffer({
|
|
9596
9901
|
byteLength: layout.byteLength,
|
|
9597
|
-
usage:
|
|
9902
|
+
usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
|
|
9598
9903
|
});
|
|
9599
9904
|
try {
|
|
9600
9905
|
pickTexture.readBuffer({
|