@luma.gl/engine 9.0.0-alpha.48 → 9.0.0-alpha.50
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/animation-loop/animation-loop.js +1 -1
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/dist.dev.js +161 -54
- package/dist/index.cjs +125 -65
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js.map +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +8 -7
- package/dist/shader-inputs.js.map +1 -1
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/{transform.js → buffer-transform.js} +13 -41
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +67 -67
- package/package.json +5 -5
- package/src/animation-loop/animation-loop.ts +1 -1
- package/src/index.ts +5 -1
- package/src/model/model.ts +2 -0
- package/src/shader-inputs.ts +6 -5
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/transform/transform.d.ts +0 -65
- package/dist/transform/transform.d.ts.map +0 -1
- package/dist/transform/transform.js.map +0 -1
- package/src/transform/transform.ts +0 -261
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ var src_exports = {};
|
|
|
27
27
|
__export(src_exports, {
|
|
28
28
|
AnimationLoop: () => AnimationLoop,
|
|
29
29
|
AnimationLoopTemplate: () => AnimationLoopTemplate,
|
|
30
|
+
BufferTransform: () => BufferTransform,
|
|
30
31
|
ClipSpace: () => ClipSpace,
|
|
31
32
|
ConeGeometry: () => ConeGeometry,
|
|
32
33
|
CubeGeometry: () => CubeGeometry,
|
|
@@ -42,8 +43,8 @@ __export(src_exports, {
|
|
|
42
43
|
PlaneGeometry: () => PlaneGeometry,
|
|
43
44
|
ScenegraphNode: () => ScenegraphNode,
|
|
44
45
|
SphereGeometry: () => SphereGeometry,
|
|
46
|
+
TextureTransform: () => TextureTransform,
|
|
45
47
|
Timeline: () => Timeline,
|
|
46
|
-
Transform: () => Transform,
|
|
47
48
|
TruncatedConeGeometry: () => TruncatedConeGeometry,
|
|
48
49
|
_ShaderInputs: () => ShaderInputs,
|
|
49
50
|
makeAnimationLoop: () => makeAnimationLoop
|
|
@@ -421,7 +422,7 @@ var AnimationLoop = class {
|
|
|
421
422
|
this._animationFrameId = (0, import_core2.requestAnimationFrame)(this._animationFrame.bind(this));
|
|
422
423
|
}
|
|
423
424
|
_cancelAnimationFrame() {
|
|
424
|
-
if (this._animationFrameId
|
|
425
|
+
if (this._animationFrameId === null) {
|
|
425
426
|
return;
|
|
426
427
|
}
|
|
427
428
|
(0, import_core2.cancelAnimationFrame)(this._animationFrameId);
|
|
@@ -642,7 +643,6 @@ var ShaderInputs = class {
|
|
|
642
643
|
* @param modules
|
|
643
644
|
*/
|
|
644
645
|
constructor(modules) {
|
|
645
|
-
var _a;
|
|
646
646
|
const allModules = (0, import_shadertools._resolveModules)(Object.values(modules));
|
|
647
647
|
import_core4.log.log(1, "Creating ShaderInputs with modules", allModules.map((m) => m.name))();
|
|
648
648
|
this.modules = modules;
|
|
@@ -650,7 +650,7 @@ var ShaderInputs = class {
|
|
|
650
650
|
this.moduleBindings = {};
|
|
651
651
|
for (const [name, module2] of Object.entries(modules)) {
|
|
652
652
|
const moduleName = name;
|
|
653
|
-
this.moduleUniforms[moduleName] =
|
|
653
|
+
this.moduleUniforms[moduleName] = module2.defaultUniforms || {};
|
|
654
654
|
this.moduleBindings[moduleName] = {};
|
|
655
655
|
}
|
|
656
656
|
}
|
|
@@ -666,10 +666,9 @@ var ShaderInputs = class {
|
|
|
666
666
|
const moduleName = name;
|
|
667
667
|
const moduleProps = props[moduleName];
|
|
668
668
|
const module2 = this.modules[moduleName];
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
this.moduleUniforms[moduleName] = uniforms
|
|
672
|
-
console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName]);
|
|
669
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
670
|
+
const uniforms = ((_a = module2.getUniforms) == null ? void 0 : _a.call(module2, moduleProps, this.moduleUniforms[moduleName])) || moduleProps;
|
|
671
|
+
this.moduleUniforms[moduleName] = { ...oldUniforms, ...uniforms };
|
|
673
672
|
}
|
|
674
673
|
}
|
|
675
674
|
/** Merges all bindings for the shader (from the various modules) */
|
|
@@ -1255,10 +1254,10 @@ function getPlatformInfo(device) {
|
|
|
1255
1254
|
};
|
|
1256
1255
|
}
|
|
1257
1256
|
|
|
1258
|
-
// src/transform/transform.ts
|
|
1257
|
+
// src/transform/buffer-transform.ts
|
|
1259
1258
|
var import_core10 = require("@luma.gl/core");
|
|
1260
1259
|
var import_shadertools3 = require("@luma.gl/shadertools");
|
|
1261
|
-
var
|
|
1260
|
+
var BufferTransform = class {
|
|
1262
1261
|
device;
|
|
1263
1262
|
model;
|
|
1264
1263
|
transformFeedback;
|
|
@@ -1266,23 +1265,14 @@ var Transform = class {
|
|
|
1266
1265
|
static isSupported(device) {
|
|
1267
1266
|
return device.features.has("transform-feedback-webgl2");
|
|
1268
1267
|
}
|
|
1269
|
-
|
|
1270
|
-
// textureTransform: TextureTransform | null = null;
|
|
1271
|
-
elementIDBuffer = null;
|
|
1272
|
-
constructor(device, props = {}) {
|
|
1268
|
+
constructor(device, props = Model.defaultProps) {
|
|
1273
1269
|
(0, import_core10.assert)(device.features.has("transform-feedback-webgl2"), "Device must support transform feedback");
|
|
1274
1270
|
this.device = device;
|
|
1275
1271
|
this.model = new Model(this.device, {
|
|
1276
|
-
|
|
1277
|
-
fs: props.fs || (0, import_shadertools3.getPassthroughFS)({ version:
|
|
1278
|
-
id: props.id || "transform-model",
|
|
1279
|
-
varyings: props.varyings,
|
|
1280
|
-
attributes: props.attributes,
|
|
1281
|
-
bufferLayout: props.bufferLayout,
|
|
1272
|
+
id: props.id || "buffer-transform-model",
|
|
1273
|
+
fs: props.fs || (0, import_shadertools3.getPassthroughFS)({ version: 300 }),
|
|
1282
1274
|
topology: props.topology || "point-list",
|
|
1283
|
-
|
|
1284
|
-
defines: props.defines,
|
|
1285
|
-
modules: props.modules
|
|
1275
|
+
...props
|
|
1286
1276
|
});
|
|
1287
1277
|
this.transformFeedback = this.device.createTransformFeedback({
|
|
1288
1278
|
layout: this.model.pipeline.shaderLayout,
|
|
@@ -1297,18 +1287,19 @@ var Transform = class {
|
|
|
1297
1287
|
this.model.destroy();
|
|
1298
1288
|
}
|
|
1299
1289
|
}
|
|
1290
|
+
/** @deprecated Use {@link destroy}. */
|
|
1291
|
+
delete() {
|
|
1292
|
+
this.destroy();
|
|
1293
|
+
}
|
|
1300
1294
|
/** Run one transform loop. */
|
|
1301
1295
|
run(options) {
|
|
1302
|
-
const
|
|
1303
|
-
const renderPass = this.device.beginRenderPass({ framebuffer, parameters, discard });
|
|
1304
|
-
if (uniforms)
|
|
1305
|
-
this.model.setUniforms(uniforms);
|
|
1296
|
+
const renderPass = this.device.beginRenderPass(options);
|
|
1306
1297
|
this.model.draw(renderPass);
|
|
1307
1298
|
renderPass.end();
|
|
1308
1299
|
}
|
|
1309
|
-
/**
|
|
1310
|
-
|
|
1311
|
-
|
|
1300
|
+
/** @deprecated */
|
|
1301
|
+
update(...args) {
|
|
1302
|
+
console.warn("TextureTransform#update() not implemented");
|
|
1312
1303
|
}
|
|
1313
1304
|
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
1314
1305
|
getBuffer(varyingName) {
|
|
@@ -1322,45 +1313,114 @@ var Transform = class {
|
|
|
1322
1313
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
1323
1314
|
return buffer.readAsync(byteOffset, byteLength);
|
|
1324
1315
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
// src/transform/texture-transform.ts
|
|
1319
|
+
var import_shadertools4 = require("@luma.gl/shadertools");
|
|
1320
|
+
var FS_OUTPUT_VARIABLE = "transform_output";
|
|
1321
|
+
var TextureTransform = class {
|
|
1322
|
+
device;
|
|
1323
|
+
model;
|
|
1324
|
+
sampler;
|
|
1325
|
+
currentIndex = 0;
|
|
1326
|
+
samplerTextureMap = null;
|
|
1327
|
+
bindings = [];
|
|
1328
|
+
// each element is an object : {sourceTextures, targetTexture, framebuffer}
|
|
1329
|
+
resources = {};
|
|
1330
|
+
// resources to be deleted
|
|
1331
|
+
constructor(device, props) {
|
|
1332
|
+
this.device = device;
|
|
1333
|
+
this.sampler = device.createSampler({
|
|
1334
|
+
addressModeU: "clamp-to-edge",
|
|
1335
|
+
addressModeV: "clamp-to-edge",
|
|
1336
|
+
minFilter: "nearest",
|
|
1337
|
+
magFilter: "nearest",
|
|
1338
|
+
mipmapFilter: "nearest"
|
|
1339
|
+
});
|
|
1340
|
+
this.model = new Model(this.device, {
|
|
1341
|
+
id: props.id || "texture-transform-model",
|
|
1342
|
+
fs: props.fs || (0, import_shadertools4.getPassthroughFS)({
|
|
1343
|
+
version: 300,
|
|
1344
|
+
input: props.targetTextureVarying,
|
|
1345
|
+
inputChannels: props.targetTextureChannels,
|
|
1346
|
+
output: FS_OUTPUT_VARIABLE
|
|
1347
|
+
}),
|
|
1348
|
+
vertexCount: props.vertexCount,
|
|
1349
|
+
// TODO(donmccurdy): Naming?
|
|
1350
|
+
...props
|
|
1351
|
+
});
|
|
1352
|
+
this._initialize(props);
|
|
1353
|
+
Object.seal(this);
|
|
1331
1354
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
throw new Error("Not implemented");
|
|
1355
|
+
// Delete owned resources.
|
|
1356
|
+
destroy() {
|
|
1335
1357
|
}
|
|
1336
|
-
/**
|
|
1337
|
-
|
|
1338
|
-
|
|
1358
|
+
/** @deprecated Use {@link destroy}. */
|
|
1359
|
+
delete() {
|
|
1360
|
+
this.destroy();
|
|
1361
|
+
}
|
|
1362
|
+
run(options) {
|
|
1363
|
+
const { framebuffer } = this.bindings[this.currentIndex];
|
|
1364
|
+
const renderPass = this.device.beginRenderPass({ framebuffer, ...options });
|
|
1365
|
+
this.model.draw(renderPass);
|
|
1366
|
+
renderPass.end();
|
|
1367
|
+
}
|
|
1368
|
+
/** @deprecated */
|
|
1369
|
+
update(...args) {
|
|
1370
|
+
console.warn("TextureTransform#update() not implemented");
|
|
1371
|
+
}
|
|
1372
|
+
getData({ packed = false } = {}) {
|
|
1373
|
+
throw new Error("getData() not implemented");
|
|
1374
|
+
}
|
|
1375
|
+
getTargetTexture() {
|
|
1376
|
+
const { targetTexture } = this.bindings[this.currentIndex];
|
|
1377
|
+
return targetTexture;
|
|
1378
|
+
}
|
|
1379
|
+
getFramebuffer() {
|
|
1380
|
+
const currentResources = this.bindings[this.currentIndex];
|
|
1381
|
+
return currentResources.framebuffer;
|
|
1339
1382
|
}
|
|
1340
1383
|
// Private
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1384
|
+
_initialize(props) {
|
|
1385
|
+
this._updateBindings(props);
|
|
1386
|
+
}
|
|
1387
|
+
_updateBindings(props) {
|
|
1388
|
+
this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], props);
|
|
1389
|
+
}
|
|
1390
|
+
_updateBinding(binding, { sourceBuffers, sourceTextures, targetTexture }) {
|
|
1391
|
+
if (!binding) {
|
|
1392
|
+
binding = {
|
|
1393
|
+
sourceBuffers: {},
|
|
1394
|
+
sourceTextures: {},
|
|
1395
|
+
targetTexture: null
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
Object.assign(binding.sourceTextures, sourceTextures);
|
|
1399
|
+
Object.assign(binding.sourceBuffers, sourceBuffers);
|
|
1400
|
+
if (targetTexture) {
|
|
1401
|
+
binding.targetTexture = targetTexture;
|
|
1402
|
+
const { width, height } = targetTexture;
|
|
1403
|
+
if (binding.framebuffer) {
|
|
1404
|
+
binding.framebuffer.destroy();
|
|
1405
|
+
}
|
|
1406
|
+
binding.framebuffer = this.device.createFramebuffer({
|
|
1407
|
+
id: "transform-framebuffer",
|
|
1408
|
+
width,
|
|
1409
|
+
height,
|
|
1410
|
+
colorAttachments: [targetTexture]
|
|
1411
|
+
});
|
|
1412
|
+
binding.framebuffer.resize({ width, height });
|
|
1413
|
+
}
|
|
1414
|
+
return binding;
|
|
1415
|
+
}
|
|
1416
|
+
// set texture filtering parameters on source textures.
|
|
1417
|
+
_setSourceTextureParameters() {
|
|
1418
|
+
const index = this.currentIndex;
|
|
1419
|
+
const { sourceTextures } = this.bindings[index];
|
|
1420
|
+
for (const name in sourceTextures) {
|
|
1421
|
+
sourceTextures[name].sampler = this.sampler;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1364
1424
|
};
|
|
1365
1425
|
|
|
1366
1426
|
// src/lib/clip-space.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ export type { MakeAnimationLoopProps } from './animation-loop/make-animation-loo
|
|
|
8
8
|
export { makeAnimationLoop } from './animation-loop/make-animation-loop';
|
|
9
9
|
export type { ModelProps } from './model/model';
|
|
10
10
|
export { Model } from './model/model';
|
|
11
|
-
export {
|
|
11
|
+
export type { BufferTransformProps } from './transform/buffer-transform';
|
|
12
|
+
export { BufferTransform } from './transform/buffer-transform';
|
|
13
|
+
export type { TextureTransformProps } from './transform/texture-transform';
|
|
14
|
+
export { TextureTransform } from './transform/texture-transform';
|
|
12
15
|
export { PipelineFactory } from './lib/pipeline-factory';
|
|
13
16
|
export { ClipSpace } from './lib/clip-space';
|
|
14
17
|
export { ScenegraphNode } from './scenegraph/scenegraph-node';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAC,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAEnE,YAAY,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,YAAY,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AAEvE,YAAY,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAC,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAEnE,YAAY,EAAC,kBAAkB,EAAC,MAAM,iCAAi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AC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAChE,YAAY,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AACnE,YAAY,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,YAAY,EAAC,0BAA0B,EAAC,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAC,qBAAqB,EAAC,MAAM,sCAAsC,CAAC;AAG3E,YAAY,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,YAAY,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export { AnimationLoopTemplate } from "./animation-loop/render-loop.js";
|
|
|
4
4
|
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
5
5
|
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
6
6
|
export { Model } from "./model/model.js";
|
|
7
|
-
export {
|
|
7
|
+
export { BufferTransform } from "./transform/buffer-transform.js";
|
|
8
|
+
export { TextureTransform } from "./transform/texture-transform.js";
|
|
8
9
|
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
9
10
|
export { ClipSpace } from "./lib/clip-space.js";
|
|
10
11
|
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","BufferTransform","TextureTransform","PipelineFactory","ClipSpace","ScenegraphNode","GroupNode","ModelNode","Geometry","GPUGeometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry","ShaderInputs","_ShaderInputs"],"sources":["../src/index.ts"],"sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/render-loop';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './model/model';\nexport {Model} from './model/model';\n\n// Transforms\nexport type {BufferTransformProps} from './transform/buffer-transform';\nexport {BufferTransform} from './transform/buffer-transform';\nexport type {TextureTransformProps} from './transform/texture-transform';\nexport {TextureTransform} from './transform/texture-transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// Utils\nexport {ClipSpace} from './lib/clip-space';\n\n// Scenegraph Core nodes\nexport {ScenegraphNode} from './scenegraph/scenegraph-node';\nexport {GroupNode} from './scenegraph/group-node';\nexport type {ModelNodeProps} from './scenegraph/model-node';\nexport {ModelNode} from './scenegraph/model-node';\n\n// Geometries\nexport type {GeometryProps} from './geometry/geometry';\nexport {Geometry} from './geometry/geometry';\nexport type {GPUGeometryProps} from './geometry/gpu-geometry';\nexport {GPUGeometry} from './geometry/gpu-geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n// EXPERIMENTAL\nexport type {ShaderModuleInputs} from './shader-inputs';\nexport {ShaderInputs as _ShaderInputs} from './shader-inputs';\n"],"mappings":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAILC,eAAe;AAAA,SAEfC,gBAAgB;AAAA,SAEhBC,eAAe;AAAA,SAGfC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,SAAS;AAAA,SAETC,SAAS;AAAA,SAITC,QAAQ;AAAA,SAERC,WAAW;AAAA,SAIXC,YAAY;AAAA,SAEZC,YAAY;AAAA,SAEZC,gBAAgB;AAAA,SAEhBC,iBAAiB;AAAA,SAEjBC,aAAa;AAAA,SAEbC,cAAc;AAAA,SAEdC,qBAAqB;AAAA,SAIrBC,YAAY,IAAIC,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,YAAY,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ACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAajD,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAQtD;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpD;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAKzD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIhD;;OAEG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI;IAIvE;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAiCpD;;;;;;;OAOG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAanE,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;CA8BlC;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAQ5D"}
|
package/dist/model/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","names":["RenderPipeline","UniformStore","log","uid","deepEqual","splitUniformsAndBindings","getAttributeInfosFromLayouts","ShaderAssembler","ShaderInputs","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","_this$props$modules","_this$props$modules2","_this$shaderInputs","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","vertexArray","transformFeedback","pipeline","shaderInputs","_uniformStore","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","moduleMap","fromEntries","modules","map","module","name","setShaderInputs","platformInfo","getPlatformInfo","length","getModules","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","console","warn","updateModuleSettings","seal","destroy","release","predraw","updateShaderInputs","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","moduleName","keys","uniformBuffer","getManagedUniformBuffer","getUniformValues","setTransformFeedback","buffers","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","attributeNames","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","varyings","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push","type","info","shaderLanguage","shadingLanguage","shaderLanguageVersion","shadingLanguageVersion","gpu","features"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';\nimport type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';\nimport type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core';\nimport {log, uid, deepEqual, splitUniformsAndBindings} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport {ShaderInputs} from '../shader-inputs';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string shaders\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** Shader inputs, used to generated uniform buffers and bindings */\n shaderInputs?: ShaderInputs;\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */\n varyings?: string[];\n\n transformFeedback?: TransformFeedback;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: undefined!,\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n varyings: [],\n\n shaderInputs: undefined!,\n pipelineFactory: undefined!,\n transformFeedback: undefined,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n /** TransformFeedback, WebGL 2 only. */\n transformFeedback: TransformFeedback | null = null;\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /** ShaderInputs instance */\n shaderInputs: ShaderInputs;\n\n _uniformStore: UniformStore;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n // Setup shader module inputs\n const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);\n this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));\n\n // Setup shader assembler\n const platformInfo = getPlatformInfo(device);\n const modules = (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({platformInfo, ...this.props, modules});\n\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer');\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n console.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()');\n this.updateModuleSettings(props.moduleSettings);\n }\n if (props.transformFeedback) {\n this.transformFeedback = props.transformFeedback;\n }\n\n // WebGL1?\n // this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n this._uniformStore.destroy();\n }\n\n // Draw call\n\n predraw() {\n // Update uniform buffers if needed\n this.updateShaderInputs();\n }\n\n draw(renderPass: RenderPass): void {\n this.predraw();\n\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount,\n transformFeedback: this.transformFeedback\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n\n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n setShaderInputs(shaderInputs: ShaderInputs): void {\n this.shaderInputs = shaderInputs;\n this._uniformStore = new UniformStore(this.shaderInputs.modules);\n // Create uniform buffer bindings for all modules\n for (const moduleName of Object.keys(this.shaderInputs.modules)) {\n const uniformBuffer = this._uniformStore.getManagedUniformBuffer(\n this.device,\n moduleName\n );\n this.bindings[`${moduleName}Uniforms`] = uniformBuffer;\n }\n }\n\n updateShaderInputs(): void {\n this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n console.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()');\n const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));\n Object.assign(this.bindings, bindings);\n Object.assign(this.uniforms, uniforms);\n }\n \n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Updates optional transform feedback. WebGL 2 only.\n */\n setTransformFeedback(transformFeedback: TransformFeedback | null): void {\n this.transformFeedback = transformFeedback;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n log.warn(`Model(${this.id}): Missing layout for buffer \"${bufferName}\".`)();\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(\n `Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`\n )();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(\n 1,\n `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`\n )();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs\n ? this.device.createShader({\n id: '{$this.id}-fragment',\n stage: 'fragment',\n source: this.fs\n })\n : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\n\n// HELPERS\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n\n/** Create a shadertools platform info from the Device */\nexport function getPlatformInfo(device: Device): PlatformInfo {\n return {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguage,\n shaderLanguageVersion: device.info.shadingLanguageVersion as 100 | 300,\n gpu: device.info.gpu,\n features: device.features\n };\n}\n"],"mappings":"AAMA,SAAwBA,cAAc,EAAcC,YAAY,QAAO,eAAe;AACtF,SAAQC,GAAG,EAAEC,GAAG,EAAEC,SAAS,EAAEC,wBAAwB,QAAO,eAAe;AAC3E,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAC7CC,YAAY;AAAA,SAECC,eAAe;AAAA,SAC5BC,eAAe;AAqDvB,OAAO,MAAMC,KAAK,CAAC;EAkFjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,IAAAC,mBAAA,EAAAC,oBAAA,EAAAC,kBAAA;IAAA,KA3DtCJ,MAAM;IAAA,KACNK,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,WAAW,GAAkB,IAAI;IAAA,KAEjCC,gBAAgB,GAA2B,CAAC,CAAC;IAAA,KAE7CC,kBAAkB,GAA+B,CAAC,CAAC;IAAA,KAEnDC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAO3CC,WAAW;IAAA,KAGXC,iBAAiB,GAA6B,IAAI;IAAA,KAGlDC,QAAQ;IAAA,KAGRC,YAAY;IAAA,KAEZC,aAAa;IAAA,KAEbC,oBAAoB,GAAmB,eAAe;IAAA,KACtDC,eAAe,GAAkC,CAAC,CAAC;IAAA,KACnDC,YAAY,GAAuB,IAAI;IAAA,KAC/BC,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OAAO;AAChB;AAGA,OAAO,SAAS3E,eAAeA,CAACxC,MAAc,EAAgB;EAC5D,OAAO;IACLwH,IAAI,EAAExH,MAAM,CAACyH,IAAI,CAACD,IAAI;IACtBE,cAAc,EAAE1H,MAAM,CAACyH,IAAI,CAACE,eAAe;IAC3CC,qBAAqB,EAAE5H,MAAM,CAACyH,IAAI,CAACI,sBAAmC;IACtEC,GAAG,EAAE9H,MAAM,CAACyH,IAAI,CAACK,GAAG;IACpBC,QAAQ,EAAE/H,MAAM,CAAC+H;EACnB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"model.js","names":["RenderPipeline","UniformStore","log","uid","deepEqual","splitUniformsAndBindings","getAttributeInfosFromLayouts","ShaderAssembler","ShaderInputs","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","_this$props$modules","_this$props$modules2","_this$shaderInputs","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","vertexArray","transformFeedback","pipeline","shaderInputs","_uniformStore","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","moduleMap","fromEntries","modules","map","module","name","setShaderInputs","platformInfo","getPlatformInfo","length","getModules","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","console","warn","updateModuleSettings","seal","destroy","release","predraw","updateShaderInputs","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","moduleName","keys","uniformBuffer","getManagedUniformBuffer","getUniformValues","setTransformFeedback","buffers","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","attributeNames","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","varyings","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push","type","info","shaderLanguage","shadingLanguage","shaderLanguageVersion","shadingLanguageVersion","gpu","features"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';\nimport type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';\nimport type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core';\nimport {log, uid, deepEqual, splitUniformsAndBindings} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport {ShaderInputs} from '../shader-inputs';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string shaders\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** Shader inputs, used to generated uniform buffers and bindings */\n shaderInputs?: ShaderInputs;\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */\n varyings?: string[];\n\n transformFeedback?: TransformFeedback;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: undefined!,\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n varyings: [],\n\n shaderInputs: undefined!,\n pipelineFactory: undefined!,\n transformFeedback: undefined,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n /** TransformFeedback, WebGL 2 only. */\n transformFeedback: TransformFeedback | null = null;\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /** ShaderInputs instance */\n shaderInputs: ShaderInputs;\n\n _uniformStore: UniformStore;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n // Setup shader module inputs\n const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);\n this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));\n\n // Setup shader assembler\n const platformInfo = getPlatformInfo(device);\n const modules = (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({platformInfo, ...this.props, modules});\n\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer');\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n // eslint-disable-next-line no-console\n console.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()');\n this.updateModuleSettings(props.moduleSettings);\n }\n if (props.transformFeedback) {\n this.transformFeedback = props.transformFeedback;\n }\n\n // WebGL1?\n // this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n this._uniformStore.destroy();\n }\n\n // Draw call\n\n predraw() {\n // Update uniform buffers if needed\n this.updateShaderInputs();\n }\n\n draw(renderPass: RenderPass): void {\n this.predraw();\n\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount,\n transformFeedback: this.transformFeedback\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n\n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n setShaderInputs(shaderInputs: ShaderInputs): void {\n this.shaderInputs = shaderInputs;\n this._uniformStore = new UniformStore(this.shaderInputs.modules);\n // Create uniform buffer bindings for all modules\n for (const moduleName of Object.keys(this.shaderInputs.modules)) {\n const uniformBuffer = this._uniformStore.getManagedUniformBuffer(\n this.device,\n moduleName\n );\n this.bindings[`${moduleName}Uniforms`] = uniformBuffer;\n }\n }\n\n updateShaderInputs(): void {\n this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n // eslint-disable-next-line no-console\n console.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()');\n const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));\n Object.assign(this.bindings, bindings);\n Object.assign(this.uniforms, uniforms);\n }\n \n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Updates optional transform feedback. WebGL 2 only.\n */\n setTransformFeedback(transformFeedback: TransformFeedback | null): void {\n this.transformFeedback = transformFeedback;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n log.warn(`Model(${this.id}): Missing layout for buffer \"${bufferName}\".`)();\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(\n `Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`\n )();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(\n 1,\n `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`\n )();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs\n ? this.device.createShader({\n id: '{$this.id}-fragment',\n stage: 'fragment',\n source: this.fs\n })\n : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\n\n// HELPERS\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n\n/** Create a shadertools platform info from the Device */\nexport function getPlatformInfo(device: Device): PlatformInfo {\n return {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguage,\n shaderLanguageVersion: device.info.shadingLanguageVersion as 100 | 300,\n gpu: device.info.gpu,\n features: device.features\n };\n}\n"],"mappings":"AAMA,SAAwBA,cAAc,EAAcC,YAAY,QAAO,eAAe;AACtF,SAAQC,GAAG,EAAEC,GAAG,EAAEC,SAAS,EAAEC,wBAAwB,QAAO,eAAe;AAC3E,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAC7CC,YAAY;AAAA,SAECC,eAAe;AAAA,SAC5BC,eAAe;AAqDvB,OAAO,MAAMC,KAAK,CAAC;EAkFjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,IAAAC,mBAAA,EAAAC,oBAAA,EAAAC,kBAAA;IAAA,KA3DtCJ,MAAM;IAAA,K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OAAO,CAAC;SAAE,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;KAAC,CAAC,GAAG,IAAI;IAoBtF,oEAAoE;IAKpE;;;OAGG;IACH,UAAU,IAAI,oBAAoB,EAAE;IAIpC,6CAA6C;IAC7C,gBAAgB,IAAI,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAI5E,oEAAoE;IACpE,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;CAOjD"}
|
package/dist/shader-inputs.js
CHANGED
|
@@ -12,23 +12,24 @@ export class ShaderInputs {
|
|
|
12
12
|
this.moduleUniforms = {};
|
|
13
13
|
this.moduleBindings = {};
|
|
14
14
|
for (const [name, module] of Object.entries(modules)) {
|
|
15
|
-
var _module$getUniforms;
|
|
16
15
|
const moduleName = name;
|
|
17
|
-
this.moduleUniforms[moduleName] =
|
|
16
|
+
this.moduleUniforms[moduleName] = module.defaultUniforms || {};
|
|
18
17
|
this.moduleBindings[moduleName] = {};
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
destroy() {}
|
|
22
21
|
setProps(props) {
|
|
23
22
|
for (const name of Object.keys(props)) {
|
|
24
|
-
var _module$
|
|
23
|
+
var _module$getUniforms;
|
|
25
24
|
const moduleName = name;
|
|
26
25
|
const moduleProps = props[moduleName];
|
|
27
26
|
const module = this.modules[moduleName];
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
this.moduleUniforms[moduleName] =
|
|
31
|
-
|
|
27
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
28
|
+
const uniforms = ((_module$getUniforms = module.getUniforms) === null || _module$getUniforms === void 0 ? void 0 : _module$getUniforms.call(module, moduleProps, this.moduleUniforms[moduleName])) || moduleProps;
|
|
29
|
+
this.moduleUniforms[moduleName] = {
|
|
30
|
+
...oldUniforms,
|
|
31
|
+
...uniforms
|
|
32
|
+
};
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
getModules() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-inputs.js","names":["log","_resolveModules","ShaderInputs","constructor","modules","moduleUniforms","moduleBindings","moduleUniformsChanged","allModules","Object","values","map","m","name","module","entries","
|
|
1
|
+
{"version":3,"file":"shader-inputs.js","names":["log","_resolveModules","ShaderInputs","constructor","modules","moduleUniforms","moduleBindings","moduleUniformsChanged","allModules","Object","values","map","m","name","module","entries","moduleName","defaultUniforms","destroy","setProps","props","keys","_module$getUniforms","moduleProps","oldUniforms","uniforms","getUniforms","call","getModules","getUniformValues","getBindings","bindings","assign"],"sources":["../src/shader-inputs.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {UniformValue, Texture, Sampler} from '@luma.gl/core';\nimport {log} from '@luma.gl/core';\n// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';\nimport {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools'\n\n\n/** Minimal ShaderModule subset, we don't need shader code etc */\nexport type ShaderModuleInputs<\n PropsT extends Record<string, unknown> = Record<string, unknown>,\n UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>,\n BindingsT extends Record<string, Texture | Sampler> = Record<string, Texture | Sampler>\n> = {\n defaultUniforms?: UniformsT;\n getUniforms?: (settings: Partial<PropsT>, prevUniforms?: UniformsT) => UniformsT;\n\n /** Not used. Used to access props type */\n props?: PropsT;\n\n bindings?: Record<\n keyof BindingsT,\n {\n location: number;\n type: 'texture' | 'sampler' | 'uniforms';\n }\n >;\n\n uniformTypes?: any;\n};\n\n/**\n * ShaderInputs holds uniform and binding values for one or more shader modules,\n * - It can generate binary data for any uniform buffer\n * - It can manage a uniform buffer for each block\n * - It can update managed uniform buffers with a single call\n * - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.\n */\nexport class ShaderInputs<\n ShaderPropsT extends Partial<Record<string, Record<string, unknown>>> = Partial<\n Record<string, Record<string, unknown>>\n >\n> {\n /** \n * The map of modules \n * @todo should should this include the resolved dependencies?\n */\n modules: Readonly<{[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}>;\n\n /** Stores the uniform values for each module */\n moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n /** Stores the uniform bindings for each module */\n moduleBindings: Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n /** Tracks if uniforms have changed */\n moduleUniformsChanged: Record<keyof ShaderPropsT, false | string>;\n\n /**\n * Create a new UniformStore instance\n * @param modules\n */\n constructor(modules: {[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>}) {\n // TODO - get all dependencies from modules\n const allModules =_resolveModules(Object.values(modules));\n log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();\n\n // Store the module definitions and create storage for uniform values and binding values, per module\n this.modules = modules;\n this.moduleUniforms = {} as Record<keyof ShaderPropsT, Record<string, UniformValue>>;\n this.moduleBindings = {} as Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;\n\n // Initialize the modules\n for (const [name, module] of Object.entries(modules)) {\n const moduleName = name as keyof ShaderPropsT;\n\n // Get default uniforms from module\n this.moduleUniforms[moduleName] = module.defaultUniforms || {};\n this.moduleBindings[moduleName] = {};\n }\n }\n\n /** Destroy */\n destroy(): void {}\n\n /**\n * Set module props\n */\n setProps(props: Partial<{[P in keyof ShaderPropsT]?: Partial<ShaderPropsT[P]>}>): void {\n for (const name of Object.keys(props)) {\n const moduleName = name as keyof ShaderPropsT;\n const moduleProps = props[moduleName];\n const module = this.modules[moduleName];\n\n const oldUniforms = this.moduleUniforms[moduleName]; \n const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps as any;\n // console.error(uniforms)\n this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};\n // this.moduleUniformsChanged ||= moduleName;\n\n // console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName])\n\n // TODO - Get Module bindings\n // const bindings = module.getBindings?.(moduleProps);\n // this.moduleUniforms[moduleName] = bindings;\n }\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n // getUniformBlocks(): Record<string, Texture | Sampler> {\n // return this.moduleUniforms;\n // }\n\n /** \n * Return the map of modules \n * @todo should should this include the resolved dependencies?\n */\n getModules(): ShaderModuleInstance[] {\n return Object.values(this.modules);\n }\n\n /** Get all uniform values for all modules */\n getUniformValues(): Record<keyof ShaderPropsT, Record<string, UniformValue>> {\n return this.moduleUniforms;\n }\n\n /** Merges all bindings for the shader (from the various modules) */\n getBindings(): Record<string, Texture | Sampler> {\n const bindings = {} as Record<string, Texture | Sampler>;\n for (const moduleBindings of Object.values(this.moduleBindings)) {\n Object.assign(bindings, moduleBindings);\n }\n return bindings;\n }\n}\n"],"mappings":"AAEA,SAAQA,GAAG,QAAO,eAAe;AAEjC,SAAQC,eAAe,QAA6B,sBAAsB;AAiC1E,OAAO,MAAMC,YAAY,CAIvB;EAkBAC,WAAWA,CAACC,OAAyE,EAAE;IAAA,KAbvFA,OAAO;IAAA,KAGPC,cAAc;IAAA,KAEdC,cAAc;IAAA,KAEdC,qBAAqB;IAQnB,MAAMC,UAAU,GAAEP,eAAe,CAACQ,MAAM,CAACC,MAAM,CAACN,OAAO,CAAC,CAAC;IACzDJ,GAAG,CAACA,GAAG,CAAC,CAAC,EAAE,oCAAoC,EAAEQ,UAAU,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;IAG/E,IAAI,CAACT,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAG,CAAC,CAA6D;IACpF,IAAI,CAACC,cAAc,GAAG,CAAC,CAAkE;IAGzF,KAAK,MAAM,CAACO,IAAI,EAAEC,MAAM,CAAC,IAAIL,MAAM,CAACM,OAAO,CAACX,OAAO,CAAC,EAAE;MACp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