@luma.gl/engine 9.0.0-alpha.41 → 9.0.0-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -38,6 +38,7 @@ var __exports__ = (() => {
38
38
  ConeGeometry: () => ConeGeometry,
39
39
  CubeGeometry: () => CubeGeometry,
40
40
  CylinderGeometry: () => CylinderGeometry,
41
+ GPUGeometry: () => GPUGeometry,
41
42
  Geometry: () => Geometry,
42
43
  GroupNode: () => GroupNode,
43
44
  IcoSphereGeometry: () => IcoSphereGeometry,
@@ -1905,6 +1906,26 @@ var __exports__ = (() => {
1905
1906
  }
1906
1907
  };
1907
1908
 
1909
+ // ../core/src/lib/utils/uniform.ts
1910
+ function isUniformValue(value) {
1911
+ return isNumberArray(value) !== null || typeof value === "number" || typeof value === "boolean";
1912
+ }
1913
+ function splitUniformsAndBindings(uniforms) {
1914
+ const result = {
1915
+ bindings: {},
1916
+ uniforms: {}
1917
+ };
1918
+ Object.keys(uniforms).forEach((name2) => {
1919
+ const uniform = uniforms[name2];
1920
+ if (isUniformValue(uniform)) {
1921
+ result.uniforms[name2] = uniform;
1922
+ } else {
1923
+ result.bindings[name2] = uniform;
1924
+ }
1925
+ });
1926
+ return result;
1927
+ }
1928
+
1908
1929
  // ../core/src/lib/utils/deep-equal.ts
1909
1930
  function deepEqual(a, b, depth) {
1910
1931
  if (a === b) {
@@ -2594,7 +2615,7 @@ var __exports__ = (() => {
2594
2615
  vs,
2595
2616
  fs,
2596
2617
  dependencies = [],
2597
- uniforms = {},
2618
+ uniformPropTypes = {},
2598
2619
  getUniforms,
2599
2620
  deprecations = [],
2600
2621
  defines = {},
@@ -2609,8 +2630,8 @@ var __exports__ = (() => {
2609
2630
  this.deprecations = this._parseDeprecationDefinitions(deprecations);
2610
2631
  this.defines = defines;
2611
2632
  this.injections = normalizeInjections(inject);
2612
- if (uniforms) {
2613
- this.uniforms = makePropValidators(uniforms);
2633
+ if (uniformPropTypes) {
2634
+ this.uniforms = makePropValidators(uniformPropTypes);
2614
2635
  }
2615
2636
  }
2616
2637
  // Extracts the source code chunk for the specified shader type from the named shader module
@@ -5644,21 +5665,15 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
5644
5665
  this.instanceCount = instanceCount;
5645
5666
  }
5646
5667
  /**
5647
- * Updates shader module settings (which results in uniforms being set)
5668
+ * Updates shader module settings (which results in bindings & uniforms being set)
5648
5669
  */
5649
5670
  setShaderModuleProps(props) {
5650
- const uniforms = this._getModuleUniforms(props);
5651
- const keys = Object.keys(uniforms).filter((k) => {
5652
- const uniform = uniforms[k];
5653
- return !Array.isArray(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
5654
- });
5655
- const bindings = {};
5656
- for (const k of keys) {
5657
- bindings[k] = uniforms[k];
5658
- delete uniforms[k];
5659
- }
5660
- Object.assign(this.uniforms, uniforms);
5671
+ const {
5672
+ bindings,
5673
+ uniforms
5674
+ } = splitUniformsAndBindings(this._getModuleUniforms(props));
5661
5675
  Object.assign(this.bindings, bindings);
5676
+ Object.assign(this.uniforms, uniforms);
5662
5677
  }
5663
5678
  /**
5664
5679
  * @deprecated Updates shader module settings (which results in uniforms being set)
@@ -5875,7 +5890,7 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
5875
5890
  const uniformTypes = {};
5876
5891
  for (const [name2, {
5877
5892
  format
5878
- }] of Object.entries(props.shaderModule.uniforms)) {
5893
+ }] of Object.entries(props.shaderModule.uniformPropTypes || {})) {
5879
5894
  uniformTypes[name2] = format;
5880
5895
  }
5881
5896
  this.uniformBufferLayout = new UniformBufferLayout(uniformTypes);
@@ -1 +1 @@
1
- {"version":3,"file":"gpu-geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/gpu-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACnE,OAA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AAY,EAAE,YAAY,EAAE,CAAM;IAE3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEhC,KAAK,EAAE,gBAAgB;IAenC,OAAO,IAAI,IAAI;IAQf,cAAc,IAAI,MAAM;IAIxB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIvC,UAAU,IAAI,MAAM,GAAG,IAAI;IAI3B,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAKjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,WAAW,CAc7F;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAMjG;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,YAAY,EAAE,YAAY,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CAmBzF"}
@@ -1 +1 @@
1
- {"version":3,"file":"gpu-geometry.js","names":["Buffer","uid","assert","GPUGeometry","constructor","props","id","userData","topology","bufferLayout","vertexCount","indices","attributes","usage","INDEX","destroy","_this$attributes$colo","positions","normals","texCoords","colors","getVertexCount","getAttributes","getIndexes","_calculateVertexCount","byteLength","makeGPUGeometry","device","geometry","getIndexBufferFromGeometry","getAttributeBuffersFromGeometry","undefined","data","value","createBuffer","attributeName","attribute","Object","entries","name","push","format","size"],"sources":["../../src/geometry/gpu-geometry.ts"],"sourcesContent":["import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';\nimport {Device, Buffer, uid, assert} from '@luma.gl/core';\nimport type {Geometry} from '../geometry/geometry';\n\nexport type GPUGeometryProps = {\n id?: string;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology:\n | 'point-list'\n | 'line-list'\n | 'line-strip'\n | 'line-loop-webgl'\n | 'triangle-list'\n | 'triangle-strip'\n | 'triangle-fan-webgl';\n /** Auto calculated from attributes if not provided */\n vertexCount: number;\n bufferLayout: BufferLayout[];\n indices?: Buffer | null;\n attributes: Record<string, Buffer>;\n};\n\nexport class GPUGeometry {\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n readonly topology?: PrimitiveTopology;\n readonly bufferLayout: BufferLayout[] = [];\n\n readonly vertexCount: number;\n readonly indices?: Buffer | null;\n readonly attributes: Record<string, Buffer>;\n\n constructor(props: GPUGeometryProps) {\n this.id = props.id || uid('geometry');\n this.topology = props.topology;\n this.indices = props.indices || null;\n this.attributes = props.attributes;\n\n this.vertexCount = props.vertexCount;\n\n this.bufferLayout = props.bufferLayout || [];\n\n if (this.indices) {\n assert(this.indices.usage === Buffer.INDEX);\n }\n }\n\n destroy(): void {\n this.indices.destroy();\n this.attributes.positions.destroy();\n this.attributes.normals.destroy();\n this.attributes.texCoords.destroy();\n this.attributes.colors?.destroy();\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n getAttributes(): Record<string, Buffer> {\n return this.attributes;\n }\n\n getIndexes(): Buffer | null {\n return this.indices;\n }\n\n _calculateVertexCount(positions: Buffer): number {\n // Assume that positions is a fully packed float32x3 buffer\n const vertexCount = positions.byteLength / 12;\n return vertexCount;\n }\n}\n\nexport function makeGPUGeometry(device: Device, geometry: Geometry | GPUGeometry): GPUGeometry {\n if (geometry instanceof GPUGeometry) {\n return geometry;\n }\n\n const indices = getIndexBufferFromGeometry(device, geometry);\n const {attributes, bufferLayout} = getAttributeBuffersFromGeometry(device, geometry);\n return new GPUGeometry({\n topology: geometry.topology || 'triangle-list',\n bufferLayout,\n vertexCount: geometry.vertexCount,\n indices,\n attributes\n });\n}\n\nexport function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {\n if (!geometry.indices) {\n return undefined;\n }\n const data = geometry.indices.value;\n return device.createBuffer({usage: Buffer.INDEX, data});\n}\n\nexport function getAttributeBuffersFromGeometry(\n device: Device,\n geometry: Geometry\n): {attributes: Record<string, Buffer>, bufferLayout: BufferLayout[], vertexCount: number} {\n const bufferLayout: BufferLayout[] = [];\n\n const attributes: Record<string, Buffer> = {};\n for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {\n let name: string = attributeName;\n // TODO Map some GLTF attribute names (is this still needed?)\n switch (attributeName) {\n case 'POSITION': name = 'positions'; break;\n case 'NORMAL': name = 'normals'; break;\n case 'TEXCOORD_0': name = 'texCoords'; break;\n }\n\n attributes[name] = device.createBuffer({data: attribute.value, id: `${attributeName}-buffer`});\n bufferLayout.push({name, format: `float32x${attribute.size as 2 | 3 | 4}`});\n }\n\n const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices)\n\n return {attributes, bufferLayout, vertexCount};\n}\n"],"mappings":"AACA,SAAgBA,MAAM,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AAqBzD,OAAO,MAAMC,WAAW,CAAC;EAYvBC,WAAWA,CAACC,KAAuB,EAAE;IAAA,KAX5BC,EAAE;IAAA,KACXC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAG7BC,QAAQ;IAAA,KACRC,YAAY,GAAmB,EAAE;IAAA,KAEjCC,WAAW;IAAA,KACXC,OAAO;IAAA,KACPC,UAAU;IAGjB,IAAI,CAACN,EAAE,GAAGD,KAAK,CAACC,EAAE,IAAIL,GAAG,CAAC,UAAU,CAAC;IACrC,IAAI,CAACO,QAAQ,GAAGH,KAAK,CAACG,QAAQ;IAC9B,IAAI,CAACG,OAAO,GAAGN,KAAK,CAACM,OAAO,IAAI,IAAI;IACpC,IAAI,CAACC,UAAU,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AACM,IAAkB;IAAC,CAAC,CAAC;EAC7E;EAEA,MAAMhC,WAAW,GAAGkB,QAAQ,CAACJ,qBAAqB,CAACI,QAAQ,CAAChB,UAAU,EAAEgB,QAAQ,CAACjB,OAAO,CAAC;EAEzF,OAAO;IAACC,UAAU;IAAEH,YAAY;IAAEC;EAAW,CAAC;AAChD"}
1
+ {"version":3,"file":"gpu-geometry.js","names":["Buffer","uid","assert","GPUGeometry","constructor","props","id","userData","topology","bufferLayout","vertexCount","indices","attributes","usage","INDEX","destroy","_this$attributes$colo","positions","normals","texCoords","colors","getVertexCount","getAttributes","getIndexes","_calculateVertexCount","byteLength","makeGPUGeometry","device","geometry","getIndexBufferFromGeometry","getAttributeBuffersFromGeometry","undefined","data","value","createBuffer","attributeName","attribute","Object","entries","name","push","format","size"],"sources":["../../src/geometry/gpu-geometry.ts"],"sourcesContent":["import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';\nimport {Device, Buffer, uid, assert} from '@luma.gl/core';\nimport type {Geometry} from '../geometry/geometry';\n\nexport type GPUGeometryProps = {\n id?: string;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology:\n | 'point-list'\n | 'line-list'\n | 'line-strip'\n | 'line-loop-webgl'\n | 'triangle-list'\n | 'triangle-strip'\n | 'triangle-fan-webgl';\n /** Auto calculated from attributes if not provided */\n vertexCount: number;\n bufferLayout: BufferLayout[];\n indices?: Buffer | null;\n attributes: Record<string, Buffer>;\n};\n\nexport class GPUGeometry {\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n readonly topology?: PrimitiveTopology;\n readonly bufferLayout: BufferLayout[] = [];\n\n readonly vertexCount: number;\n readonly indices?: Buffer | null;\n readonly attributes: Record<string, Buffer>;\n\n constructor(props: GPUGeometryProps) {\n this.id = props.id || uid('geometry');\n this.topology = props.topology;\n this.indices = props.indices || null;\n this.attributes = props.attributes;\n\n this.vertexCount = props.vertexCount;\n\n this.bufferLayout = props.bufferLayout || [];\n\n if (this.indices) {\n assert(this.indices.usage === Buffer.INDEX);\n }\n }\n\n destroy(): void {\n this.indices.destroy();\n this.attributes.positions.destroy();\n this.attributes.normals.destroy();\n this.attributes.texCoords.destroy();\n this.attributes.colors?.destroy();\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n getAttributes(): Record<string, Buffer> {\n return this.attributes;\n }\n\n getIndexes(): Buffer | null {\n return this.indices;\n }\n\n _calculateVertexCount(positions: Buffer): number {\n // Assume that positions is a fully packed float32x3 buffer\n const vertexCount = positions.byteLength / 12;\n return vertexCount;\n }\n}\n\nexport function makeGPUGeometry(device: Device, geometry: Geometry | GPUGeometry): GPUGeometry {\n if (geometry instanceof GPUGeometry) {\n return geometry;\n }\n\n const indices = getIndexBufferFromGeometry(device, geometry);\n const {attributes, bufferLayout} = getAttributeBuffersFromGeometry(device, geometry);\n return new GPUGeometry({\n topology: geometry.topology || 'triangle-list',\n bufferLayout,\n vertexCount: geometry.vertexCount,\n indices,\n attributes\n });\n}\n\nexport function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {\n if (!geometry.indices) {\n return undefined;\n }\n const data = geometry.indices.value;\n return device.createBuffer({usage: Buffer.INDEX, data});\n}\n\nexport function getAttributeBuffersFromGeometry(\n device: Device,\n geometry: Geometry\n): {attributes: Record<string, Buffer>, bufferLayout: BufferLayout[], vertexCount: number} {\n const bufferLayout: BufferLayout[] = [];\n\n const attributes: Record<string, Buffer> = {};\n for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {\n let name: string = attributeName;\n // TODO Map some GLTF attribute names (is this still needed?)\n switch (attributeName) {\n case 'POSITION': name = 'positions'; break;\n case 'NORMAL': name = 'normals'; break;\n case 'TEXCOORD_0': name = 'texCoords'; break;\n }\n attributes[name] = device.createBuffer({data: attribute.value, id: `${attributeName}-buffer`});\n bufferLayout.push({name, format: `float32x${attribute.size as 2 | 3 | 4}`});\n }\n\n const vertexCount = geometry._calculateVertexCount(geometry.attribut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;EAC7C,KAAK,MAAM,CAACuB,aAAa,EAAEC,SAAS,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACV,QAAQ,CAAChB,UAAU,CAAC,EAAE;IAC5E,IAAI2B,IAAY,GAAGJ,aAAa;IAEhC,QAAQA,aAAa;MACnB,KAAK,UAAU;QAAEI,IAAI,GAAG,WAAW;QAAE;MACrC,KAAK,QAAQ;QAAEA,IAAI,GAAG,SAAS;QAAE;MACjC,KAAK,YAAY;QAAEA,IAAI,GAAG,WAAW;QAAE;IACzC;IACA3B,UAAU,CAAC2B,IAAI,CAAC,GAAGZ,MAAM,CAACO,YAAY,CAAC;MAACF,IAAI,EAAEI,SAAS,CAACH,KAAK;MAAE3B,EAAE,EAAG,GAAE6B,aAAc;IAAQ,CAAC,CAAC;IAC9F1B,YAAY,CAAC+B,IAAI,CAAC;MAACD,IAAI;MAAEE,MAAM,EAAG,WAAUL,SAAS,CAACM,IAAkB;IAAC,CAAC,CAAC;EAC7E;EAEA,MAAMhC,WAAW,GAAGkB,QAAQ,CAACJ,qBAAqB,CAACI,QAAQ,CAAChB,UAAU,EAAEgB,QAAQ,CAACjB,OAAO,CAAC;EAEzF,OAAO;IAACC,UAAU;IAAEH,YAAY;IAAEC;EAAW,CAAC;AAChD"}
package/dist/index.cjs CHANGED
@@ -63,6 +63,7 @@ __export(src_exports, {
63
63
  ConeGeometry: () => ConeGeometry,
64
64
  CubeGeometry: () => CubeGeometry,
65
65
  CylinderGeometry: () => CylinderGeometry,
66
+ GPUGeometry: () => GPUGeometry,
66
67
  Geometry: () => Geometry,
67
68
  GroupNode: () => GroupNode,
68
69
  IcoSphereGeometry: () => IcoSphereGeometry,
@@ -991,21 +992,12 @@ var _Model = class {
991
992
  this.instanceCount = instanceCount;
992
993
  }
993
994
  /**
994
- * Updates shader module settings (which results in uniforms being set)
995
+ * Updates shader module settings (which results in bindings & uniforms being set)
995
996
  */
996
997
  setShaderModuleProps(props) {
997
- const uniforms = this._getModuleUniforms(props);
998
- const keys = Object.keys(uniforms).filter((k) => {
999
- const uniform = uniforms[k];
1000
- return !Array.isArray(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
1001
- });
1002
- const bindings = {};
1003
- for (const k of keys) {
1004
- bindings[k] = uniforms[k];
1005
- delete uniforms[k];
1006
- }
1007
- Object.assign(this.uniforms, uniforms);
998
+ const { bindings, uniforms } = (0, import_core6.splitUniformsAndBindings)(this._getModuleUniforms(props));
1008
999
  Object.assign(this.bindings, bindings);
1000
+ Object.assign(this.uniforms, uniforms);
1009
1001
  }
1010
1002
  /**
1011
1003
  * @deprecated Updates shader module settings (which results in uniforms being set)
@@ -1214,7 +1206,7 @@ var ShaderModuleUniforms = class {
1214
1206
  this.shaderModule = props.shaderModule;
1215
1207
  this.useUniformBuffers = this.device.info.type !== "webgl";
1216
1208
  const uniformTypes = {};
1217
- for (const [name, { format }] of Object.entries(props.shaderModule.uniforms)) {
1209
+ for (const [name, { format }] of Object.entries(props.shaderModule.uniformPropTypes || {})) {
1218
1210
  uniformTypes[name] = format;
1219
1211
  }
1220
1212
  this.uniformBufferLayout = new import_core9.UniformBufferLayout(uniformTypes);
package/dist/index.d.ts CHANGED
@@ -14,9 +14,12 @@ export { ShaderModuleUniforms } from './shadertools/shader-module-uniforms';
14
14
  export { ClipSpace } from './lib/clip-space';
15
15
  export { ScenegraphNode } from './scenegraph/scenegraph-node';
16
16
  export { GroupNode } from './scenegraph/group-node';
17
+ export type { ModelNodeProps } from './scenegraph/model-node';
17
18
  export { ModelNode } from './scenegraph/model-node';
18
19
  export type { GeometryProps } from './geometry/geometry';
19
20
  export { Geometry } from './geometry/geometry';
21
+ export type { GPUGeometryProps } from './geometry/gpu-geometry';
22
+ export { GPUGeometry } from './geometry/gpu-geometry';
20
23
  export type { ConeGeometryProps } from './geometries/cone-geometry';
21
24
  export { ConeGeometry } from './geometries/cone-geometry';
22
25
  export type { CubeGeometryProps } from './geometries/cube-geometry';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.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,sCAAsC,CAAC"}
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
12
12
  export { GroupNode } from "./scenegraph/group-node.js";
13
13
  export { ModelNode } from "./scenegraph/model-node.js";
14
14
  export { Geometry } from "./geometry/geometry.js";
15
+ export { GPUGeometry } from "./geometry/gpu-geometry.js";
15
16
  export { ConeGeometry } from "./geometries/cone-geometry.js";
16
17
  export { CubeGeometry } from "./geometries/cube-geometry.js";
17
18
  export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","Transform","PipelineFactory","ShaderModuleUniforms","ClipSpace","ScenegraphNode","GroupNode","ModelNode","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry"],"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\nexport {Transform} from './transform/transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// shadertools\nexport {ShaderModuleUniforms} from './shadertools/shader-module-uniforms';\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 {ModelNode} from './scenegraph/model-node';\n\n// Geometries\nexport type {GeometryProps} from './geometry/geometry';\nexport {Geometry} from './geometry/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"],"mappings":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAELC,SAAS;AAAA,SAETC,eAAe;AAAA,SAGfC,oBAAoB;AAAA,SAGpBC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,SAAS;AAAA,SACTC,SAAS;AAAA,SAITC,QAAQ;AAAA,SAIRC,YAAY;AAAA,SAEZC,YAAY;AAAA,SAEZC,gBAAgB;AAAA,SAEhBC,iBAAiB;AAAA,SAEjBC,aAAa;AAAA,SAEbC,cAAc;AAAA,SAEdC,qBAAqB"}
1
+ {"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","Transform","PipelineFactory","ShaderModuleUniforms","ClipSpace","ScenegraphNode","GroupNode","ModelNode","Geometry","GPUGeometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry"],"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\nexport {Transform} from './transform/transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// shadertools\nexport {ShaderModuleUniforms} from './shadertools/shader-module-uniforms';\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"],"mappings":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAELC,SAAS;AAAA,SAETC,eAAe;AAAA,SAGfC,oBAAoB;AAAA,SAGpBC,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"}
@@ -132,7 +132,7 @@ export declare class Model {
132
132
  */
133
133
  setInstanceCount(instanceCount: number): void;
134
134
  /**
135
- * Updates shader module settings (which results in uniforms being set)
135
+ * Updates shader module settings (which results in bindings & uniforms being set)
136
136
  */
137
137
  setShaderModuleProps(props: Record<string, any>): void;
138
138
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAE9F,OAAO,KAAK,EAAC,YAAY,EAAe,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAC,QAAQ,EA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Ae,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI;IAqBnD;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,wBAAwB;IASlD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIzC;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAMtD;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAItD;;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;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAgCpD;;;;;;;OAOG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAWnE,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;CAqBlC"}
@@ -1,4 +1,4 @@
1
- import { RenderPipeline, log, uid, deepEqual } from '@luma.gl/core';
1
+ import { RenderPipeline, log, uid, deepEqual, splitUniformsAndBindings } from '@luma.gl/core';
2
2
  import { getAttributeInfosFromLayouts } from '@luma.gl/core';
3
3
  import { ShaderAssembler } from '@luma.gl/shadertools';
4
4
  import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
@@ -154,18 +154,12 @@ export class Model {
154
154
  this.instanceCount = instanceCount;
155
155
  }
156
156
  setShaderModuleProps(props) {
157
- const uniforms = this._getModuleUniforms(props);
158
- const keys = Object.keys(uniforms).filter(k => {
159
- const uniform = uniforms[k];
160
- return !Array.isArray(uniform) && typeof uniform !== 'number' && typeof uniform !== 'boolean';
161
- });
162
- const bindings = {};
163
- for (const k of keys) {
164
- bindings[k] = uniforms[k];
165
- delete uniforms[k];
166
- }
167
- Object.assign(this.uniforms, uniforms);
157
+ const {
158
+ bindings,
159
+ uniforms
160
+ } = splitUniformsAndBindings(this._getModuleUniforms(props));
168
161
  Object.assign(this.bindings, bindings);
162
+ Object.assign(this.uniforms, uniforms);
169
163
  }
170
164
  updateModuleSettings(props) {
171
165
  this.setShaderModuleProps(props);
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","getAttributeInfosFromLayouts","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","vertexArray","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","keys","filter","k","uniform","Array","isArray","buffers","warn","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","name","attributeNames","map","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n TypedArray,\n RenderPipelineProps,\n RenderPipelineParameters,\n BufferLayout,\n VertexArray,\n AttributeInfo\n} from '@luma.gl/core';\nimport type {Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, log, uid, deepEqual} 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 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 /** 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 /** 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: {},\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n\n pipelineFactory: 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 /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\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 _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 /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(\n platformInfo,\n this.props\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 this.updateModuleSettings(props.moduleSettings);\n }\n\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 }\n\n // Draw call\n\n draw(renderPass: RenderPass): void {\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 });\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 /**\n * Updates shader module settings (which results in uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n\n // Extract textures & framebuffers set by the modules\n // TODO better way to extract bindings\n const keys = Object.keys(uniforms).filter(k => {\n const uniform = uniforms[k];\n return !Array.isArray(uniform) && (typeof uniform !== 'number') && (typeof uniform !== 'boolean');\n });\n const bindings: Record<string, Binding> = {};\n for (const k of keys) {\n bindings[k] = uniforms[k];\n delete uniforms[k];\n }\n\n Object.assign(this.uniforms, uniforms);\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n this.setShaderModuleProps(props);\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 * 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 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(`Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`)();\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(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\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 ? this.device.createShader({id: '{$this.id}-fragment', stage: 'fragment', source: this.fs}) : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\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"],"mappings":"AAYA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAC7F,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AA8CvB,OAAO,MAAMC,KAAK,CAAC;EAuEjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAnDtCD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC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EAEtBT,eAAe,EAAE8F,SAAU;EAC3BjE,eAAe,EAAEvC,eAAe,CAAC2G,yBAAyB,CAAC;AAC7D,CAAC;AA8YH,SAASxC,kBAAkBA,CAACyC,QAAwB,EAAEC,QAAwB,EAAkB;EAC9F,MAAMC,OAAO,GAAG,CAAC,GAAGF,QAAQ,CAAC;EAC7B,KAAK,MAAMnB,SAAS,IAAIoB,QAAQ,EAAE;IAChC,MAAME,KAAK,GAAGD,OAAO,CAACE,SAAS,CAACC,UAAU,IAAIA,UAAU,CAAC3B,IAAI,KAAKG,SAAS,CAACH,IAAI,CAAC;IACjF,IAAIyB,KAAK,GAAG,CAAC,EAAE;MACbD,OAAO,CAACI,IAAI,CAACzB,SAAS,CAAC;IACzB,CAAC,MAAM;MACLqB,OAAO,CAACC,KAAK,CAAC,GAAGtB,SAAS;IAC5B;EACF;EACA,OAAOqB,OAAO;AAChB"}
1
+ {"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","splitUniformsAndBindings","getAttributeInfosFromLayouts","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","vertexArray","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","buffers","warn","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","name","attributeNames","map","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n TypedArray,\n RenderPipelineProps,\n RenderPipelineParameters,\n BufferLayout,\n VertexArray,\n AttributeInfo\n} from '@luma.gl/core';\nimport type {Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, 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 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 /** 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 /** 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: {},\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n\n pipelineFactory: 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 /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\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 _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 /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(\n platformInfo,\n this.props\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 this.updateModuleSettings(props.moduleSettings);\n }\n\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 }\n\n // Draw call\n\n draw(renderPass: RenderPass): void {\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 });\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 /**\n * Updates shader module settings (which results in bindings & uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));\n Object.assign(this.bindings, bindings);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n this.setShaderModuleProps(props);\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 * 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 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(`Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`)();\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(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\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 ? this.device.createShader({id: '{$this.id}-fragment', stage: 'fragment', source: this.fs}) : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\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"],"mappings":"AAYA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,EAAEC,wBAAwB,QAAO,eAAe;AACvH,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AA8CvB,OAAO,MAAMC,KAAK,CAAC;EAuEjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAnDtCD,MAAM;IAAA,KACNE,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,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OAAO;AAChB"}
@@ -17,7 +17,7 @@ export class ShaderModuleUniforms {
17
17
  const uniformTypes = {};
18
18
  for (const [name, {
19
19
  format
20
- }] of Object.entries(props.shaderModule.uniforms)) {
20
+ }] of Object.entries(props.shaderModule.uniformPropTypes || {})) {
21
21
  uniformTypes[name] = format;
22
22
  }
23
23
  this.uniformBufferLayout = new UniformBufferLayout(uniformTypes);
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module-uniforms.js","names":["isNumberArray","Buffer","UniformBufferLayout","ShaderModuleUniforms","constructor","props","device","shaderModule","useUniformBuffers","uniformBufferLayout","uniformBuffer","uniforms","modifiedUniforms","modified","needsRedraw","info","type","uniformTypes","name","format","Object","entries","createBuffer","usage","UNIFORM","byteLength","setUniforms","key","value","_setUniform","setNeedsRedraw","reason","getUniformBuffer","getModifiedUniforms","data","getData","write","getUniforms","groupName","arrayEqual","a","b","limit","arguments","length","undefined","arrayA","arrayB","i"],"sources":["../../src/shadertools/shader-module-uniforms.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {NumberArray, isNumberArray} from '@luma.gl/core';\nimport {Device, Buffer, UniformBufferLayout, ShaderUniformType} from '@luma.gl/core';\nimport {ShaderModule} from '@luma.gl/shadertools';\n\n/** Duplicates definition in core module to avoid cross dependencies */\nexport type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;\n\n/** A uniform store holds a number of uniform values and does some book keeping on what has changes */\nexport class ShaderModuleUniforms<TUniforms extends Record<string, UniformValue>> {\n device: Device;\n shaderModule: ShaderModule<TUniforms>;\n\n useUniformBuffers: boolean;\n uniformBufferLayout: UniformBufferLayout;\n uniformBuffer: Buffer | null = null;\n\n uniforms: Record<string, UniformValue> = {};\n modifiedUniforms: Record<string, boolean> = {};\n modified: boolean = true;\n\n needsRedraw: string | false = 'initialized';\n\n constructor(props?: {\n device: Device;\n shaderModule: ShaderModule<TUniforms>\n }) {\n this.device = props.device;\n this.shaderModule = props.shaderModule;\n this.useUniformBuffers = this.device.info.type !== 'webgl';\n\n // extract uniform formats and create a uniform buffer layout\n const uniformTypes: Record<string, ShaderUniformType> = {};\n for (const [name, {format}] of Object.entries(props.shaderModule.uniforms)) {\n uniformTypes[name] = format;\n }\n this.uniformBufferLayout = new UniformBufferLayout(uniformTypes);\n\n // create a uniform buffer\n if (this.useUniformBuffers) {\n this.uniformBuffer = this.device.createBuffer({\n usage: Buffer.UNIFORM,\n byteLength: this.uniformBufferLayout.byteLength\n }); \n }\n }\n\n /** Set a map of uniforms */\n setUniforms(uniforms: TUniforms): void {\n for (const [key, value] of Object.entries(uniforms)) {\n this._setUniform(key, value);\n this.setNeedsRedraw(key);\n }\n }\n\n setNeedsRedraw(reason: string): void {\n this.needsRedraw = this.needsRedraw || reason;\n }\n\n /** \n * Updates the uniform buffer if needed. \n * Clears the dirty flag.\n */\n getUniformBuffer(): Buffer {\n if (this.needsRedraw) {\n const modifiedUniforms = this.getModifiedUniforms();\n const data = this.uniformBufferLayout.getData(modifiedUniforms);\n this.uniformBuffer.write(data);\n }\n return this.uniformBuffer;\n }\n\n /** Returns all uniforms */\n getUniforms(groupName: string): Record<string, UniformValue> {\n this.modifiedUniforms = {};\n this.needsRedraw = false;\n return (this.uniforms[groupName] || {}) as Record<string, UniformValue>;\n }\n\n /** Returns modified uniforms */\n getModifiedUniforms() {\n const modifiedUniforms = this.modifiedUniforms;\n this.modifiedUniforms = {};\n this.needsRedraw = false;\n return modifiedUniforms;\n }\n\n /** Set a single uniform */\n private _setUniform(key: string, value: UniformValue) {\n // if (this.layout[key] !== undefined) {\n // this.uniforms[key] = value;\n // this.modifiedUniforms[key] = true;\n // this.modified = true;\n // } else {\n // log.warn(`Unknown uniform ${key}`)\n // }\n if (arrayEqual(this.uniforms[key], value)) {\n return;\n }\n this.uniforms[key] = value;\n this.modifiedUniforms[key] = true;\n this.modified = true;\n }\n}\n\nfunction arrayEqual(a: unknown, b: unknown, limit: number = 16) {\n if (a !== b) {\n return false;\n }\n const arrayA = isNumberArray(a);\n if (!arrayA) {\n return false;\n }\n const arrayB = isNumberArray(b);\n if (arrayB && arrayA.length === arrayB.length) {\n for (let i = 0; i < arrayA.length; ++i) {\n if (arrayB[i] !== arrayA[i]) {\n return false;\n }\n }\n }\n return true;\n}\n\n\n// export function makeUniformStore<I extends Record<string, Record<string, unknown>>>(name: string, uniforms: I): UniformStore<{ [P in keyof I]: I[P] }> {\n// return new UniformStore<{ [P in keyof I]: I[P] }>({name, uniforms});\n// }\n\n// type ShaderModule<Uniforms extends Record<string, unknown> = {}> = {\n// uniformTypes: Record<keyof Uniforms, string>;\n// };\n\n// type Module1Uniforms = {\n// uniform1?: number;\n// uniform2?: [number, number];\n// }\n\n// type Module2Uniforms = {\n// uniform3: number;\n// uniform4: [number, number];\n// }\n\n// const shaderModule: ShaderModule<Module1Uniforms> = {\n// uniformTypes: {\n// uniform1: 'aaa',\n// uniform2: 'aaa'\n// }\n// }\n\n\n// const module1Uniforms = new ShaderModuleUniforms<Module1Uniforms>();\n\n// module1Uniforms.setUniforms({\n// uniform1: 1,\n// uniform2: [1, 1]\n// });\n\n\n\n// setUniformStore(pipeline, blockIndex, block);\n\n// GLSL utilities\n\n\n// TYPE TESTS\n\n/*\nnew UniformStore<ModuleUniforms>().setUniforms({\n uniform1: 1,\n uniform2: 1,\n});\n\nnew UniformStore<ModuleUniforms>().setUniforms({\n three: 1,\n uniform1: 1,\n});\n*/\n"],"mappings":"AACA,SAAqBA,aAAa,QAAO,eAAe;AACxD,SAAgBC,MAAM,EAAEC,mBAAmB,QAA0B,eAAe;AAOpF,OAAO,MAAMC,oBAAoB,CAAiD;EAchFC,WAAWA,CAACC,KAGX,EAAE;IAAA,KAhBHC,MAAM;IAAA,KACNC,YAAY;IAAA,KAEZC,iBAAiB;IAAA,KACjBC,mBAAmB;IAAA,KACnBC,aAAa,GAAkB,IAAI;IAAA,KAEnCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAC3C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,EAAE;IACX,OAAO,KAAK;EACd;EACA,MAAMC,MAAM,GAAG/C,aAAa,CAACyC,CAAC,CAAC;EAC/B,IAAIM,MAAM,IAAID,MAAM,CAACF,MAAM,KAAKG,MAAM,CAACH,MAAM,EAAE;IAC7C,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACF,MAAM,EAAE,EAAEI,CAAC,EAAE;MACtC,IAAID,MAAM,CAACC,CAAC,CAAC,KAAKF,MAAM,CAACE,CAAC,CAAC,EAAE;QAC3B,OAAO,KAAK;MACd;IACF;EACF;EACA,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"shader-module-uniforms.js","names":["isNumberArray","Buffer","UniformBufferLayout","ShaderModuleUniforms","constructor","props","device","shaderModule","useUniformBuffers","uniformBufferLayout","uniformBuffer","uniforms","modifiedUniforms","modified","needsRedraw","info","type","uniformTypes","name","format","Object","entries","uniformPropTypes","createBuffer","usage","UNIFORM","byteLength","setUniforms","key","value","_setUniform","setNeedsRedraw","reason","getUniformBuffer","getModifiedUniforms","data","getData","write","getUniforms","groupName","arrayEqual","a","b","limit","arguments","length","undefined","arrayA","arrayB","i"],"sources":["../../src/shadertools/shader-module-uniforms.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {NumberArray, isNumberArray} from '@luma.gl/core';\nimport {Device, Buffer, UniformBufferLayout, ShaderUniformType} from '@luma.gl/core';\nimport {ShaderModule} from '@luma.gl/shadertools';\n\n/** Duplicates definition in core module to avoid cross dependencies */\nexport type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;\n\n/** A uniform store holds a number of uniform values and does some book keeping on what has changes */\nexport class ShaderModuleUniforms<TUniforms extends Record<string, UniformValue>> {\n device: Device;\n shaderModule: ShaderModule<TUniforms>;\n\n useUniformBuffers: boolean;\n uniformBufferLayout: UniformBufferLayout;\n uniformBuffer: Buffer | null = null;\n\n uniforms: Record<string, UniformValue> = {};\n modifiedUniforms: Record<string, boolean> = {};\n modified: boolean = true;\n\n needsRedraw: string | false = 'initialized';\n\n constructor(props?: {\n device: Device;\n shaderModule: ShaderModule<TUniforms>\n }) {\n this.device = props.device;\n this.shaderModule = props.shaderModule;\n this.useUniformBuffers = this.device.info.type !== 'webgl';\n\n // extract uniform formats and create a uniform buffer layout\n const uniformTypes: Record<string, ShaderUniformType> = {};\n for (const [name, {format}] of Object.entries(props.shaderModule.uniformPropTypes || {})) {\n uniformTypes[name] = format;\n }\n this.uniformBufferLayout = new UniformBufferLayout(uniformTypes);\n\n // create a uniform buffer\n if (this.useUniformBuffers) {\n this.uniformBuffer = this.device.createBuffer({\n usage: Buffer.UNIFORM,\n byteLength: this.uniformBufferLayout.byteLength\n }); \n }\n }\n\n /** Set a map of uniforms */\n setUniforms(uniforms: TUniforms): void {\n for (const [key, value] of Object.entries(uniforms)) {\n this._setUniform(key, value);\n this.setNeedsRedraw(key);\n }\n }\n\n setNeedsRedraw(reason: string): void {\n this.needsRedraw = this.needsRedraw || reason;\n }\n\n /** \n * Updates the uniform buffer if needed. \n * Clears the dirty flag.\n */\n getUniformBuffer(): Buffer {\n if (this.needsRedraw) {\n const modifiedUniforms = this.getModifiedUniforms();\n const data = this.uniformBufferLayout.getData(modifiedUniforms);\n this.uniformBuffer.write(data);\n }\n return this.uniformBuffer;\n }\n\n /** Returns all uniforms */\n getUniforms(groupName: string): Record<string, UniformValue> {\n this.modifiedUniforms = {};\n this.needsRedraw = false;\n return (this.uniforms[groupName] || {}) as Record<string, UniformValue>;\n }\n\n /** Returns modified uniforms */\n getModifiedUniforms() {\n const modifiedUniforms = this.modifiedUniforms;\n this.modifiedUniforms = {};\n this.needsRedraw = false;\n return modifiedUniforms;\n }\n\n /** Set a single uniform */\n private _setUniform(key: string, value: UniformValue) {\n // if (this.layout[key] !== undefined) {\n // this.uniforms[key] = value;\n // this.modifiedUniforms[key] = true;\n // this.modified = true;\n // } else {\n // log.warn(`Unknown uniform ${key}`)\n // }\n if (arrayEqual(this.uniforms[key], value)) {\n return;\n }\n this.uniforms[key] = value;\n this.modifiedUniforms[key] = true;\n this.modified = true;\n }\n}\n\nfunction arrayEqual(a: unknown, b: unknown, limit: number = 16) {\n if (a !== b) {\n return false;\n }\n const arrayA = isNumberArray(a);\n if (!arrayA) {\n return false;\n }\n const arrayB = isNumberArray(b);\n if (arrayB && arrayA.length === arrayB.length) {\n for (let i = 0; i < arrayA.length; ++i) {\n if (arrayB[i] !== arrayA[i]) {\n return false;\n }\n }\n }\n return true;\n}\n\n\n// export function makeUniformStore<I extends Record<string, Record<string, unknown>>>(name: string, uniforms: I): UniformStore<{ [P in keyof I]: I[P] }> {\n// return new UniformStore<{ [P in keyof I]: I[P] }>({name, uniforms});\n// }\n\n// type ShaderModule<Uniforms extends Record<string, unknown> = {}> = {\n// uniformTypes: Record<keyof Uniforms, string>;\n// };\n\n// type Module1Uniforms = {\n// uniform1?: number;\n// uniform2?: [number, number];\n// }\n\n// type Module2Uniforms = {\n// uniform3: number;\n// uniform4: [number, number];\n// }\n\n// const shaderModule: ShaderModule<Module1Uniforms> = {\n// uniformTypes: {\n// uniform1: 'aaa',\n// uniform2: 'aaa'\n// }\n// }\n\n\n// const module1Uniforms = new ShaderModuleUniforms<Module1Uniforms>();\n\n// module1Uniforms.setUniforms({\n// uniform1: 1,\n// uniform2: [1, 1]\n// });\n\n\n\n// setUniformStore(pipeline, blockIndex, block);\n\n// GLSL utilities\n\n\n// TYPE TESTS\n\n/*\nnew UniformStore<ModuleUniforms>().setUniforms({\n uniform1: 1,\n uniform2: 1,\n});\n\nnew UniformStore<ModuleUniforms>().setUniforms({\n three: 1,\n uniform1: 1,\n});\n*/\n"],"mappings":"AACA,SAAqBA,aAAa,QAAO,eAAe;AACxD,SAAgBC,MAAM,EAAEC,mBAAmB,QAA0B,eAAe;AAOpF,OAAO,MAAMC,oBAAoB,CAAiD;EAchFC,WAAWA,CAACC,KAGX,EAAE;IAAA,KAhBHC,MAA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