@luma.gl/engine 9.0.0-alpha.35 → 9.0.0-alpha.37

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.
Files changed (48) hide show
  1. package/dist/animation/timeline.d.ts +4 -4
  2. package/dist/animation/timeline.d.ts.map +1 -1
  3. package/dist/animation/timeline.js +13 -13
  4. package/dist/animation/timeline.js.map +1 -1
  5. package/dist/animation-loop/animation-loop.d.ts +2 -2
  6. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  7. package/dist/animation-loop/animation-loop.js +5 -6
  8. package/dist/animation-loop/animation-loop.js.map +1 -1
  9. package/dist/animation-loop/animation-props.d.ts +1 -2
  10. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  11. package/dist/animation-loop/animation-props.js.map +1 -1
  12. package/dist/dist.dev.js +999 -9127
  13. package/dist/index.cjs +269 -125
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/lib/clip-space.d.ts +1 -1
  19. package/dist/lib/clip-space.d.ts.map +1 -1
  20. package/dist/lib/clip-space.js +1 -2
  21. package/dist/lib/clip-space.js.map +1 -1
  22. package/dist/model/model.d.ts +44 -22
  23. package/dist/model/model.d.ts.map +1 -1
  24. package/dist/model/model.js +80 -22
  25. package/dist/model/model.js.map +1 -1
  26. package/dist/scenegraph/scenegraph-node.d.ts +5 -5
  27. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  28. package/dist/scenegraph/scenegraph-node.js.map +1 -1
  29. package/dist/shadertools/shader-module-uniforms.d.ts +36 -0
  30. package/dist/shadertools/shader-module-uniforms.d.ts.map +1 -0
  31. package/dist/shadertools/shader-module-uniforms.js +87 -0
  32. package/dist/shadertools/shader-module-uniforms.js.map +1 -0
  33. package/dist/transform/transform.d.ts +2 -2
  34. package/dist/transform/transform.d.ts.map +1 -1
  35. package/dist/transform/transform.js +0 -18
  36. package/dist/transform/transform.js.map +1 -1
  37. package/dist.min.js +107 -165
  38. package/package.json +5 -6
  39. package/src/.DS_Store +0 -0
  40. package/src/animation/timeline.ts +13 -13
  41. package/src/animation-loop/animation-loop.ts +6 -8
  42. package/src/animation-loop/animation-props.ts +1 -2
  43. package/src/index.ts +3 -0
  44. package/src/lib/clip-space.ts +2 -3
  45. package/src/model/model.ts +169 -63
  46. package/src/scenegraph/scenegraph-node.ts +5 -5
  47. package/src/shadertools/shader-module-uniforms.ts +178 -0
  48. package/src/transform/transform.ts +8 -6
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export type { ModelProps } from './model/model';
10
10
  export { Model } from './model/model';
11
11
  export { Transform } from './transform/transform';
12
12
  export { PipelineFactory } from './lib/pipeline-factory';
13
+ export { ShaderModuleUniforms } from './shadertools/shader-module-uniforms';
13
14
  export { ClipSpace } from './lib/clip-space';
14
15
  export { ScenegraphNode } from './scenegraph/scenegraph-node';
15
16
  export { GroupNode } from './scenegraph/group-node';
@@ -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;AAEpC,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AAO,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"}
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
6
6
  export { Model } from "./model/model.js";
7
7
  export { Transform } from "./transform/transform.js";
8
8
  export { PipelineFactory } from "./lib/pipeline-factory.js";
9
+ export { ShaderModuleUniforms } from "./shadertools/shader-module-uniforms.js";
9
10
  export { ClipSpace } from "./lib/clip-space.js";
10
11
  export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
11
12
  export { GroupNode } from "./scenegraph/group-node.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","Transform","PipelineFactory","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// 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,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","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"}
@@ -4,6 +4,6 @@ import { Model, ModelProps } from '../model/model';
4
4
  * A flat geometry that covers the "visible area" that the GPU renders.
5
5
  */
6
6
  export declare class ClipSpace extends Model {
7
- constructor(device: Device | WebGLRenderingContext, opts?: ModelProps);
7
+ constructor(device: Device, opts?: ModelProps);
8
8
  }
9
9
  //# sourceMappingURL=clip-space.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAO,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,IAAI,CAAC,EAAE,UAAU;CAqBtE"}
1
+ {"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAO,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU;CAqB9C"}
@@ -1,5 +1,4 @@
1
1
  import { glsl } from '@luma.gl/core';
2
- import { WebGLDevice } from '@luma.gl/webgl';
3
2
  import { Model } from "../model/model.js";
4
3
  import { Geometry } from "../geometry/geometry.js";
5
4
  const CLIPSPACE_VERTEX_SHADER = glsl`\
@@ -22,7 +21,7 @@ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
22
21
  export class ClipSpace extends Model {
23
22
  constructor(device, opts) {
24
23
  const TEX_COORDS = POSITIONS.map(coord => coord === -1 ? 0 : coord);
25
- super(WebGLDevice.attach(device), {
24
+ super(device, {
26
25
  ...opts,
27
26
  vs: CLIPSPACE_VERTEX_SHADER,
28
27
  vertexCount: 4,
@@ -1 +1 @@
1
- {"version":3,"file":"clip-space.js","names":["glsl","WebGLDevice","Model","Geometry","CLIPSPACE_VERTEX_SHADER","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","attach","vs","vertexCount","geometry","topology","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport {Device, glsl} from '@luma.gl/core';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {Model, ModelProps} from '../model/model';\nimport {Geometry} from '../geometry/geometry';\n\nconst CLIPSPACE_VERTEX_SHADER = glsl`\\\nattribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n`;\n\n/* eslint-disable indent, no-multi-spaces */\nconst POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];\n\n/**\n * A flat geometry that covers the \"visible area\" that the GPU renders.\n */\nexport class ClipSpace extends Model {\n constructor(device: Device | WebGLRenderingContext, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n WebGLDevice.attach(device),\n {\n ...opts,\n vs: CLIPSPACE_VERTEX_SHADER,\n vertexCount: 4,\n geometry: new Geometry({\n topology: 'triangle-strip',\n vertexCount: 4,\n attributes: {\n aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},\n aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},\n aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}\n }\n })\n }\n );\n }\n}\n"],"mappings":"AAEA,SAAgBA,IAAI,QAAO,eAAe;AAC1C,SAAQC,WAAW,QAAO,gBAAgB;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGJ,IAAK;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAGD,MAAMK,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAK9C,OAAO,MAAMC,SAAS,SAASJ,KAAK,CAAC;EACnCK,WAAWA,CAACC,MAAsC,EAAEC,IAAiB,EAAE;IACrE,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHX,WAAW,CAACY,MAAM,CAACL,MAAM,CAAC,EAC1B;MACE,GAAGC,IAAI;MACPK,EAAE,EAAEV,uBAAuB;MAC3BW,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIb,QAAQ,CAAC;QACrBc,QAAQ,EAAE,gBAAgB;QAC1BF,WAAW,EAAE,CAAC;QACdG,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACjB,SAAS;UAAC,CAAC;UACjEkB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACZ,UAAU;UAAC,CAAC;UACzDc,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACZ,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CACF,CAAC;EACH;AACF"}
1
+ {"version":3,"file":"clip-space.js","names":["glsl","Model","Geometry","CLIPSPACE_VERTEX_SHADER","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","vs","vertexCount","geometry","topology","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport {Device, glsl} from '@luma.gl/core';\nimport {Model, ModelProps} from '../model/model';\nimport {Geometry} from '../geometry/geometry';\n\nconst CLIPSPACE_VERTEX_SHADER = glsl`\\\nattribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n`;\n\n/* eslint-disable indent, no-multi-spaces */\nconst POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];\n\n/**\n * A flat geometry that covers the \"visible area\" that the GPU renders.\n */\nexport class ClipSpace extends Model {\n constructor(device: Device, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n device,\n {\n ...opts,\n vs: CLIPSPACE_VERTEX_SHADER,\n vertexCount: 4,\n geometry: new Geometry({\n topology: 'triangle-strip',\n vertexCount: 4,\n attributes: {\n aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},\n aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},\n aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}\n }\n })\n }\n );\n }\n}\n"],"mappings":"AAEA,SAAgBA,IAAI,QAAO,eAAe;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGH,IAAK;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAGD,MAAMI,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAK9C,OAAO,MAAMC,SAAS,SAASJ,KAAK,CAAC;EACnCK,WAAWA,CAACC,MAAc,EAAEC,IAAiB,EAAE;IAC7C,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHJ,MAAM,EACN;MACE,GAAGC,IAAI;MACPI,EAAE,EAAET,uBAAuB;MAC3BU,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIZ,QAAQ,CAAC;QACrBa,QAAQ,EAAE,gBAAgB;QAC1BF,WAAW,EAAE,CAAC;QACdG,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAAChB,SAAS;UAAC,CAAC;UACjEiB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC,CAAC;UACzDa,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CACF,CAAC;EACH;AACF"}
@@ -1,4 +1,4 @@
1
- import type { TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout } from '@luma.gl/core';
1
+ import type { TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout, VertexArray, AttributeInfo } from '@luma.gl/core';
2
2
  import type { Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';
3
3
  import { Device, Buffer, RenderPipeline, RenderPass } from '@luma.gl/core';
4
4
  import type { ShaderModule } from '@luma.gl/shadertools';
@@ -23,16 +23,21 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
23
23
  pipelineFactory?: PipelineFactory;
24
24
  /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
25
25
  shaderAssembler?: ShaderAssembler;
26
- /** Geometry */
27
- geometry?: GPUGeometry | Geometry | null;
28
26
  /** Parameters that are built into the pipeline */
29
27
  parameters?: RenderPipelineParameters;
30
- /** shadertool modules */
31
- moduleSettings?: Record<string, Record<string, any>>;
28
+ /** Geometry */
29
+ geometry?: GPUGeometry | Geometry | null;
32
30
  /** Vertex count */
33
31
  vertexCount?: number;
34
32
  /** instance count */
35
33
  instanceCount?: number;
34
+ indexBuffer?: Buffer | null;
35
+ /** @note this is really a map of buffers, not a map of attributes */
36
+ attributes?: Record<string, Buffer>;
37
+ /** */
38
+ constantAttributes?: Record<string, TypedArray>;
39
+ /** Mapped uniforms for shadertool modules */
40
+ moduleSettings?: Record<string, Record<string, any>>;
36
41
  };
37
42
  /**
38
43
  * v9 Model API
@@ -63,7 +68,7 @@ export declare class Model {
63
68
  /** instance count */
64
69
  instanceCount: number;
65
70
  /** Index buffer */
66
- indices: Buffer | null;
71
+ indexBuffer: Buffer | null;
67
72
  /** Buffer-valued attributes */
68
73
  bufferAttributes: Record<string, Buffer>;
69
74
  /** Constant-valued attributes */
@@ -74,7 +79,15 @@ export declare class Model {
74
79
  uniforms: Record<string, UniformValue>;
75
80
  /** The underlying GPU "program". @note May be recreated if parameters change */
76
81
  pipeline: RenderPipeline;
82
+ /**
83
+ * VertexArray
84
+ * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
85
+ * @todo - allow application to define multiple vertex arrays?
86
+ * */
87
+ vertexArray: VertexArray;
77
88
  _pipelineNeedsUpdate: string | false;
89
+ _attributeInfos: Record<string, AttributeInfo>;
90
+ _gpuGeometry: GPUGeometry | null;
78
91
  private _getModuleUniforms;
79
92
  private props;
80
93
  constructor(device: Device, props: ModelProps);
@@ -82,10 +95,16 @@ export declare class Model {
82
95
  draw(renderPass: RenderPass): void;
83
96
  /**
84
97
  * Updates the optional geometry
85
- * Geometry, sets several attributes, indices, and also vertex count and topology
98
+ * Geometry, set topology and bufferLayout
99
+ * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
100
+ */
101
+ setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry;
102
+ /**
103
+ * Updates the optional geometry attributes
104
+ * Geometry, sets several attributes, indexBuffer, and also vertex count
86
105
  * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
87
106
  */
88
- setGeometry(geometry: GPUGeometry | Geometry): void;
107
+ _setGeometryAttributes(gpuGeometry: GPUGeometry): void;
89
108
  /**
90
109
  * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
91
110
  * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
@@ -120,33 +139,36 @@ export declare class Model {
120
139
  * @deprecated Updates shader module settings (which results in uniforms being set)
121
140
  */
122
141
  updateModuleSettings(props: Record<string, any>): void;
142
+ /**
143
+ * Sets bindings (textures, samplers, uniform buffers)
144
+ */
145
+ setBindings(bindings: Record<string, Binding>): void;
146
+ /**
147
+ * Sets individual uniforms
148
+ * @deprecated WebGL only, use uniform buffers for portability
149
+ * @param uniforms
150
+ * @returns self for chaining
151
+ */
152
+ setUniforms(uniforms: Record<string, UniformValue>): void;
123
153
  /**
124
154
  * Sets the index buffer
125
155
  * @todo - how to unset it if we change geometry?
126
156
  */
127
- setIndexBuffer(indices: Buffer | null): void;
157
+ setIndexBuffer(indexBuffer: Buffer | null): void;
128
158
  /**
129
159
  * Sets attributes (buffers)
130
160
  * @note Overrides any attributes previously set with the same name
131
161
  */
132
- setAttributes(bufferAttributes: Record<string, Buffer>): void;
162
+ setAttributes(buffers: Record<string, Buffer>): void;
133
163
  /**
134
164
  * Sets constant attributes
135
165
  * @note Overrides any attributes previously set with the same name
166
+ * Constant attributes are only supported in WebGL, not in WebGPU
167
+ * Any attribute that is disabled in the current vertex array object
168
+ * is read from the context's global constant value for that attribute location.
136
169
  * @param constantAttributes
137
170
  */
138
- setConstantAttributes(constantAttributes: Record<string, TypedArray>): void;
139
- /**
140
- * Sets bindings (textures, samplers, uniform buffers)
141
- */
142
- setBindings(bindings: Record<string, Binding>): void;
143
- /**
144
- * Sets individual uniforms
145
- * @deprecated WebGL only, use uniform buffers for portability
146
- * @param uniforms
147
- * @returns self for chaining
148
- */
149
- setUniforms(uniforms: Record<string, UniformValue>): void;
171
+ setConstantAttributes(attributes: Record<string, TypedArray>): void;
150
172
  _setPipelineNeedsUpdate(reason: string): void;
151
173
  _updatePipeline(): RenderPipeline;
152
174
  }
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,YAAY,EAAC,MAAM,eAAe,C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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;IAKtD;;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,5 @@
1
1
  import { RenderPipeline, log, uid, deepEqual } from '@luma.gl/core';
2
+ import { getAttributeInfosFromLayouts } from '@luma.gl/core';
2
3
  import { ShaderAssembler } from '@luma.gl/shadertools';
3
4
  import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
4
5
  import { PipelineFactory } from "../lib/pipeline-factory.js";
@@ -15,13 +16,16 @@ export class Model {
15
16
  this.bufferLayout = void 0;
16
17
  this.vertexCount = void 0;
17
18
  this.instanceCount = 0;
18
- this.indices = null;
19
+ this.indexBuffer = null;
19
20
  this.bufferAttributes = {};
20
21
  this.constantAttributes = {};
21
22
  this.bindings = {};
22
23
  this.uniforms = {};
23
24
  this.pipeline = void 0;
25
+ this.vertexArray = void 0;
24
26
  this._pipelineNeedsUpdate = 'newly created';
27
+ this._attributeInfos = {};
28
+ this._gpuGeometry = null;
25
29
  this._getModuleUniforms = void 0;
26
30
  this.props = void 0;
27
31
  this.props = {
@@ -52,10 +56,16 @@ export class Model {
52
56
  this.bufferLayout = this.props.bufferLayout;
53
57
  this.parameters = this.props.parameters;
54
58
  if (props.geometry) {
55
- this.setGeometry(props.geometry);
59
+ this._gpuGeometry = this.setGeometry(props.geometry);
56
60
  }
57
61
  this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
58
62
  this.pipeline = this._updatePipeline();
63
+ this.vertexArray = device.createVertexArray({
64
+ renderPipeline: this.pipeline
65
+ });
66
+ if (this._gpuGeometry) {
67
+ this._setGeometryAttributes(this._gpuGeometry);
68
+ }
59
69
  if (props.vertexCount) {
60
70
  this.setVertexCount(props.vertexCount);
61
71
  }
@@ -63,11 +73,17 @@ export class Model {
63
73
  this.setInstanceCount(props.instanceCount);
64
74
  }
65
75
  if (props.indices) {
66
- this.setIndexBuffer(props.indices);
76
+ throw new Error('Model.props.indices removed. Use props.indexBuffer');
77
+ }
78
+ if (props.indexBuffer) {
79
+ this.setIndexBuffer(props.indexBuffer);
67
80
  }
68
81
  if (props.attributes) {
69
82
  this.setAttributes(props.attributes);
70
83
  }
84
+ if (props.constantAttributes) {
85
+ this.setConstantAttributes(props.constantAttributes);
86
+ }
71
87
  if (props.bindings) {
72
88
  this.setBindings(props.bindings);
73
89
  }
@@ -85,13 +101,11 @@ export class Model {
85
101
  }
86
102
  draw(renderPass) {
87
103
  this.pipeline = this._updatePipeline();
88
- this.pipeline.setIndexBuffer(this.indices);
89
- this.pipeline.setAttributes(this.bufferAttributes);
90
- this.pipeline.setConstantAttributes(this.constantAttributes);
91
104
  this.pipeline.setBindings(this.bindings);
92
105
  this.pipeline.setUniforms(this.uniforms);
93
106
  this.pipeline.draw({
94
107
  renderPass,
108
+ vertexArray: this.vertexArray,
95
109
  vertexCount: this.vertexCount,
96
110
  instanceCount: this.instanceCount
97
111
  });
@@ -100,6 +114,12 @@ export class Model {
100
114
  const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);
101
115
  this.setTopology(gpuGeometry.topology || 'triangle-list');
102
116
  this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);
117
+ if (this.vertexArray) {
118
+ this._setGeometryAttributes(gpuGeometry);
119
+ }
120
+ return gpuGeometry;
121
+ }
122
+ _setGeometryAttributes(gpuGeometry) {
103
123
  this.vertexCount = gpuGeometry.vertexCount;
104
124
  this.setAttributes(gpuGeometry.attributes);
105
125
  this.setIndexBuffer(gpuGeometry.indices);
@@ -111,9 +131,14 @@ export class Model {
111
131
  }
112
132
  }
113
133
  setBufferLayout(bufferLayout) {
114
- if (bufferLayout !== this.bufferLayout) {
115
- this.bufferLayout = bufferLayout;
116
- this._setPipelineNeedsUpdate('bufferLayout');
134
+ this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
135
+ this._setPipelineNeedsUpdate('bufferLayout');
136
+ this.pipeline = this._updatePipeline();
137
+ this.vertexArray = this.device.createVertexArray({
138
+ renderPipeline: this.pipeline
139
+ });
140
+ if (this._gpuGeometry) {
141
+ this._setGeometryAttributes(this._gpuGeometry);
117
142
  }
118
143
  }
119
144
  setParameters(parameters) {
@@ -135,18 +160,6 @@ export class Model {
135
160
  updateModuleSettings(props) {
136
161
  this.setShaderModuleProps(props);
137
162
  }
138
- setIndexBuffer(indices) {
139
- this.indices = indices;
140
- }
141
- setAttributes(bufferAttributes) {
142
- if (bufferAttributes.indices) {
143
- log.warn(`Model:${this.id} setAttributes() - indices should be set using setIndexBuffer()`);
144
- }
145
- Object.assign(this.bufferAttributes, bufferAttributes);
146
- }
147
- setConstantAttributes(constantAttributes) {
148
- Object.assign(this.constantAttributes, constantAttributes);
149
- }
150
163
  setBindings(bindings) {
151
164
  Object.assign(this.bindings, bindings);
152
165
  }
@@ -154,12 +167,51 @@ export class Model {
154
167
  this.pipeline.setUniforms(uniforms);
155
168
  Object.assign(this.uniforms, uniforms);
156
169
  }
170
+ setIndexBuffer(indexBuffer) {
171
+ this.vertexArray.setIndexBuffer(indexBuffer);
172
+ }
173
+ setAttributes(buffers) {
174
+ if (buffers.indices) {
175
+ log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);
176
+ }
177
+ for (const [bufferName, buffer] of Object.entries(buffers)) {
178
+ var _bufferLayout$attribu;
179
+ const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);
180
+ if (!bufferLayout) {
181
+ continue;
182
+ }
183
+ const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map(layout => layout.attribute) : [bufferLayout.name];
184
+ let set = false;
185
+ for (const attributeName of attributeNames) {
186
+ const attributeInfo = this._attributeInfos[attributeName];
187
+ if (attributeInfo) {
188
+ this.vertexArray.setBuffer(attributeInfo.location, buffer);
189
+ set = true;
190
+ }
191
+ }
192
+ if (!set) {
193
+ log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
194
+ }
195
+ }
196
+ }
197
+ setConstantAttributes(attributes) {
198
+ for (const [attributeName, value] of Object.entries(attributes)) {
199
+ const attributeInfo = this._attributeInfos[attributeName];
200
+ if (attributeInfo) {
201
+ this.vertexArray.setConstant(attributeInfo.location, value);
202
+ } else {
203
+ log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
204
+ }
205
+ }
206
+ }
157
207
  _setPipelineNeedsUpdate(reason) {
158
208
  this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
159
209
  }
160
210
  _updatePipeline() {
161
211
  if (this._pipelineNeedsUpdate) {
162
- log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
212
+ if (this.pipeline) {
213
+ log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
214
+ }
163
215
  this._pipelineNeedsUpdate = false;
164
216
  this.pipeline = this.device.createRenderPipeline({
165
217
  ...this.props,
@@ -167,14 +219,17 @@ export class Model {
167
219
  topology: this.topology,
168
220
  parameters: this.parameters,
169
221
  vs: this.device.createShader({
222
+ id: '{$this.id}-vertex',
170
223
  stage: 'vertex',
171
224
  source: this.vs
172
225
  }),
173
226
  fs: this.fs ? this.device.createShader({
227
+ id: '{$this.id}-fragment',
174
228
  stage: 'fragment',
175
229
  source: this.fs
176
230
  }) : null
177
231
  });
232
+ this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
178
233
  }
179
234
  return this.pipeline;
180
235
  }
@@ -190,6 +245,9 @@ Model.defaultProps = {
190
245
  modules: [],
191
246
  moduleSettings: {},
192
247
  geometry: null,
248
+ indexBuffer: null,
249
+ attributes: {},
250
+ constantAttributes: {},
193
251
  pipelineFactory: undefined,
194
252
  shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
195
253
  };
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indices","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","_pipelineNeedsUpdate","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","setVertexCount","setInstanceCount","setIndexBuffer","attributes","setAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","setConstantAttributes","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","warn","reason","createRenderPipeline","createShader","stage","source","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","attribute","index","findIndex","attribute2","name","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout} 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 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\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 /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n /** shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\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\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 indices: 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 _pipelineNeedsUpdate: string | false = 'newly created';\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(platformInfo, this.props);\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 several attributes, indices, and also vertex count and topology\n if (props.geometry) {\n 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 // Now we can apply geometry attributes\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 if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\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.setIndexBuffer(this.indices);\n this.pipeline.setAttributes(this.bufferAttributes);\n this.pipeline.setConstantAttributes(this.constantAttributes);\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\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, sets several attributes, indices, and also vertex count and topology\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): void {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n\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 if (bufferLayout !== this.bufferLayout) {\n this.bufferLayout = bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\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 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 the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indices: Buffer | null): void {\n this.indices = indices;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(bufferAttributes: Record<string, Buffer>): void {\n if (bufferAttributes.indices) {\n log.warn(`Model:${this.id} setAttributes() - indices should be set using setIndexBuffer()`);\n }\n\n Object.assign(this.bufferAttributes, bufferAttributes);\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * @param constantAttributes\n */\n setConstantAttributes(constantAttributes: Record<string, TypedArray>): void {\n // TODO - this doesn't work under WebGPU, we'll need to create buffers or inject uniforms\n Object.assign(this.constantAttributes, constantAttributes);\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 _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n log.log(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\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({stage: 'vertex', source: this.vs}),\n fs: this.fs ? this.device.createShader({stage: 'fragment', source: this.fs}) : null\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(\n (attribute2) => attribute2.name === attribute.name\n );\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}"],"mappings":"AAIA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAE7F,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AAsCvB,OAAO,MAAMC,KAAK,CAAC;EA0DjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAzCtCD,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,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,OAAO,GAAkB,IAAI;IAAA,KAE7BC,gBAAgB,GAA2B,CAAC,CAAC;IAAA,KAE7CC,kBAAkB,GAA+B,CAAC,CAAC;IAAA,KAEnDC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAG3CC,QAAQ;IAAA,KACRC,oBAAoB,GAAmB,eAAe;IAAA,KAC9CC,kBAAkB;IAAA,KAClBlB,KAAK;IAGX,IAAI,CAACA,KAAK,GAAG;MAAC,GAAGH,KAAK,CAACsB,YAAY;MAAE,GAAGnB;IAAK,CAAC;IAC9CA,KAAK,GAAG,IAAI,CAACA,KAAK;IAClB,IAAI,CAACC,EAAE,GAAGD,KAAK,CAACC,EAAE,IAAIT,GAAG,CAAC,OAAO,CAAC;IAClC,IAAI,CAACO,MAAM,GAAGA,MAAM;IAEpBqB,MAAM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;EACZ6D,OAAO,EAAE,CAAC,CAAC;EACXC,OAAO,EAAE,EAAE;EACXxB,cAAc,EAAE,CAAC,CAAC;EAClBX,QAAQ,EAAE,IAAI;EAEd5B,eAAe,EAAE6D,SAAU;EAC3BnC,eAAe,EAAEpC,eAAe,CAAC0E,yBAAyB,CAAC;AAC7D,CAAC;AAuSH,SAASf,kBAAkBA,CAACgB,QAAwB,EAAEC,QAAwB,EAAkB;EAC9F,MAAMC,OAAO,GAAG,CAAC,GAAGF,QAAQ,CAAC;EAC7B,KAAK,MAAMG,SAAS,IAAIF,QAAQ,EAAE;IAChC,MAAMG,KAAK,GAAGF,OAAO,CAACG,SAAS,CAC5BC,UAAU,IAAKA,UAAU,CAACC,IAAI,KAAKJ,SAAS,CAACI,IAChD,CAAC;IACD,IAAIH,KAAK,GAAG,CAAC,EAAE;MACbF,OAAO,CAACM,IAAI,CAACL,SAAS,CAAC;IACzB,CAAC,MAAM;MACLD,OAAO,CAACE,KAAK,CAAC,GAAGD,SAAS;IAC5B;EACF;EACA,OAAOD,OAAO;AAChB"}
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","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\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 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":"AAWA,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,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC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AAI,CAACgB,eAAe,GAAG1B,4BAA4B,CACjD,IAAI,CAACuB,QAAQ,CAAC0E,YAAY,EAC1B,IAAI,CAAClF,YACP,CAAC;IACH;IACA,OAAO,IAAI,CAACQ,QAAQ;EACtB;AACF;AA/YanB,KAAK,CACTyB,YAAY,GAAyB;EAC1C,GAAGjC,cAAc,CAACiC,YAAY;EAC9BpB,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRF,EAAE,EAAE,SAAS;EACb0F,MAAM,EAAEC,SAAS;EACjBvF,QAAQ,EAAE,CAAC,CAAC;EACZwF,OAAO,EAAE,CAAC,CAAC;EACXC,OAAO,EAAE,EAAE;EACX1C,cAAc,EAAE,CAAC,CAAC;EAClBjB,QAAQ,EAAE,IAAI;EACdxB,WAAW,EAAE,IAAI;EACjBoC,UAAU,EAAE,CAAC,CAAC;EACdlC,kBAAkB,EAAE,CAAC,CAAC;EAEtBT,eAAe,EAAEwF,SAAU;EAC3B3D,eAAe,EAAEvC,eAAe,CAACqG,yBAAyB,CAAC;AAC7D,CAAC;AAgYH,SAASlC,kBAAkBA,CAACmC,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,14 +1,14 @@
1
- import { NumericArray } from '@luma.gl/core';
1
+ import { NumberArray } from '@luma.gl/core';
2
2
  import { Vector3, Matrix4 } from '@math.gl/core';
3
3
  /** Properties for creating a new Scenegraph */
4
4
  export type ScenegraphNodeProps = {
5
5
  id?: string;
6
6
  /** whether to display the object at all */
7
7
  display?: boolean;
8
- matrix?: NumericArray;
9
- position?: NumericArray;
10
- rotation?: NumericArray;
11
- scale?: NumericArray;
8
+ matrix?: NumberArray;
9
+ position?: NumberArray;
10
+ rotation?: NumberArray;
11
+ scale?: NumberArray;
12
12
  update?: boolean;
13
13
  };
14
14
  export declare class ScenegraphNode {
@@ -1 +1 @@
1
- {"version":3,"file":"scenegraph-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAEF,qBAAa,cAAc;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAiB;IAEhC,OAAO,UAAQ;IACf,QAAQ,UAAiB;IACzB,QAAQ,UAAiB;IACzB,KAAK,UAAwB;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAEvC,KAAK,EAAE,mBAAmB,CAAM;gBAEpB,KAAK,GAAE,mBAAwB;IAQ3C,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAIxC,OAAO,IAAI,IAAI;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