@luma.gl/engine 9.0.0-beta.5 → 9.0.0-beta.7

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 (115) hide show
  1. package/dist/animation/timeline.d.ts.map +1 -1
  2. package/dist/animation/timeline.js +3 -3
  3. package/dist/animation-loop/animation-loop-template.d.ts +1 -1
  4. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
  5. package/dist/animation-loop/animation-loop-template.js +3 -1
  6. package/dist/animation-loop/animation-loop.d.ts +2 -2
  7. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  8. package/dist/animation-loop/animation-loop.js +14 -6
  9. package/dist/animation-loop/animation-props.d.ts +2 -2
  10. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  11. package/dist/animation-loop/make-animation-loop.d.ts +2 -2
  12. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  13. package/dist/animation-loop/make-animation-loop.js +4 -2
  14. package/dist/computation.d.ts +95 -0
  15. package/dist/computation.d.ts.map +1 -0
  16. package/dist/computation.js +248 -0
  17. package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
  18. package/dist/debug/copy-texture-to-image.js +5 -2
  19. package/dist/debug/debug-framebuffer.d.ts.map +1 -1
  20. package/dist/debug/debug-framebuffer.js +0 -1
  21. package/dist/debug/pixel-data-utils.d.ts.map +1 -1
  22. package/dist/debug/pixel-data-utils.js +2 -1
  23. package/dist/dist.dev.js +713 -329
  24. package/dist/geometries/cone-geometry.d.ts +1 -1
  25. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  26. package/dist/geometries/cone-geometry.js +1 -1
  27. package/dist/geometries/cube-geometry.d.ts +1 -1
  28. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  29. package/dist/geometries/cube-geometry.js +16 -14
  30. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  31. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cylinder-geometry.js +1 -1
  33. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  34. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  35. package/dist/geometries/ico-sphere-geometry.js +1 -1
  36. package/dist/geometries/plane-geometry.d.ts +1 -1
  37. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  38. package/dist/geometries/plane-geometry.js +2 -2
  39. package/dist/geometries/sphere-geometry.d.ts +1 -1
  40. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  41. package/dist/geometries/sphere-geometry.js +1 -1
  42. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  43. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/truncated-cone-geometry.js +1 -1
  45. package/dist/geometry/geometry-table.d.ts.map +1 -1
  46. package/dist/geometry/geometry-table.js +3 -0
  47. package/dist/geometry/geometry.d.ts.map +1 -1
  48. package/dist/geometry/geometry.js +3 -0
  49. package/dist/geometry/gpu-geometry.d.ts +1 -1
  50. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  51. package/dist/geometry/gpu-geometry.js +4 -5
  52. package/dist/index.cjs +661 -291
  53. package/dist/index.cjs.map +4 -4
  54. package/dist/index.d.ts +43 -40
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +25 -23
  57. package/dist/lib/clip-space.d.ts +1 -1
  58. package/dist/lib/clip-space.d.ts.map +1 -1
  59. package/dist/lib/clip-space.js +8 -10
  60. package/dist/lib/pipeline-factory.d.ts +10 -6
  61. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  62. package/dist/lib/pipeline-factory.js +47 -22
  63. package/dist/lib/shader-factory.d.ts +17 -0
  64. package/dist/lib/shader-factory.d.ts.map +1 -0
  65. package/dist/lib/shader-factory.js +46 -0
  66. package/dist/model/model.d.ts +58 -45
  67. package/dist/model/model.d.ts.map +1 -1
  68. package/dist/model/model.js +213 -120
  69. package/dist/scenegraph/group-node.d.ts +1 -1
  70. package/dist/scenegraph/group-node.d.ts.map +1 -1
  71. package/dist/scenegraph/group-node.js +10 -5
  72. package/dist/scenegraph/model-node.d.ts +3 -3
  73. package/dist/scenegraph/model-node.d.ts.map +1 -1
  74. package/dist/scenegraph/model-node.js +2 -2
  75. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  76. package/dist/shader-inputs.d.ts.map +1 -1
  77. package/dist/shader-inputs.js +3 -0
  78. package/dist/transform/buffer-transform.d.ts +1 -1
  79. package/dist/transform/buffer-transform.d.ts.map +1 -1
  80. package/dist/transform/buffer-transform.js +7 -6
  81. package/dist/transform/texture-transform.d.ts +1 -1
  82. package/dist/transform/texture-transform.d.ts.map +1 -1
  83. package/dist/transform/texture-transform.js +10 -8
  84. package/dist.min.js +2 -2
  85. package/package.json +2 -2
  86. package/src/animation/timeline.ts +20 -20
  87. package/src/animation-loop/animation-loop-template.ts +10 -8
  88. package/src/animation-loop/animation-loop.ts +20 -10
  89. package/src/animation-loop/animation-props.ts +1 -1
  90. package/src/animation-loop/make-animation-loop.ts +17 -8
  91. package/src/computation.ts +346 -0
  92. package/src/debug/copy-texture-to-image.ts +8 -6
  93. package/src/debug/debug-framebuffer.ts +16 -3
  94. package/src/debug/debug-shader-layout.ts +1 -1
  95. package/src/debug/pixel-data-utils.ts +3 -6
  96. package/src/geometries/cube-geometry.ts +17 -13
  97. package/src/geometries/ico-sphere-geometry.ts +1 -1
  98. package/src/geometries/plane-geometry.ts +1 -1
  99. package/src/geometries/sphere-geometry.ts +1 -1
  100. package/src/geometries/truncated-cone-geometry.ts +2 -1
  101. package/src/geometry/geometry-table.ts +9 -6
  102. package/src/geometry/geometry-utils.ts +1 -1
  103. package/src/geometry/geometry.ts +9 -6
  104. package/src/geometry/gpu-geometry.ts +18 -11
  105. package/src/index.ts +3 -0
  106. package/src/lib/clip-space.ts +14 -18
  107. package/src/lib/pipeline-factory.ts +62 -28
  108. package/src/lib/shader-factory.ts +57 -0
  109. package/src/model/model.ts +249 -146
  110. package/src/scenegraph/group-node.ts +14 -10
  111. package/src/scenegraph/model-node.ts +2 -2
  112. package/src/scenegraph/scenegraph-node.ts +2 -2
  113. package/src/shader-inputs.ts +19 -12
  114. package/src/transform/buffer-transform.ts +15 -7
  115. package/src/transform/texture-transform.ts +14 -13
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC,CAAA;AAEA,KAAK,OAAO,GAAG;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,KAAK,SAAS,GAAG;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE;QACT,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;KAChC,CAAA;CACF,CAAA;AAKD,qBAAa,QAAQ;IACnB,IAAI,EAAE,MAAM,CAAK;IACjB,QAAQ,uBAA8B;IACtC,UAAU,yBAAgC;IAC1C,OAAO,EAAE,OAAO,CAAS;IACzB,cAAc,EAAE,MAAM,CAAM;;IAK5B,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAiBzC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAUtC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAStC,OAAO,CAAC,SAAS,CAAC,EA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,OAAO,EAAE,OAAO,CAAS;IACzB,cAAc,EAAE,MAAM,CAAM;;IAI5B,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAiBzC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAUtC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAStC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAcnC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAe3B,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAKb,KAAK,IAAI,IAAI;IAIb,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAa5E,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIxC,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAUhC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAWtD"}
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  let channelHandles = 1;
4
5
  let animationHandles = 1;
@@ -8,8 +9,7 @@ export class Timeline {
8
9
  animations = new Map();
9
10
  playing = false;
10
11
  lastEngineTime = -1;
11
- constructor() {
12
- }
12
+ constructor() { }
13
13
  addChannel(props) {
14
14
  const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;
15
15
  const channelId = channelHandles++;
@@ -1,4 +1,4 @@
1
- import type { AnimationProps } from './animation-props';
1
+ import type { AnimationProps } from "./animation-props.js";
2
2
  /**
3
3
  * Minimal class that represents a "componentized" rendering life cycle
4
4
  * (resource construction, repeated rendering, resource destruction)
@@ -1 +1 @@
1
- {"version":3,"file":"animation-loop-template.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,qBAAqB;gBAC7B,cAAc,CAAC,EAAE,cAAc;IACrC,YAAY,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IACpE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO;IAC1D,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;CAC1D"}
1
+ {"version":3,"file":"animation-loop-template.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,6BAA0B;AAEtD;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,qBAAqB;gBAC7B,cAAc,CAAC,EAAE,cAAc;IACrC,YAAY,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAGpE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO;IAC1D,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI;CAC1D"}
@@ -15,5 +15,7 @@
15
15
  */
16
16
  export class AnimationLoopTemplate {
17
17
  constructor(animationProps) { }
18
- async onInitialize(animationProps) { return null; }
18
+ async onInitialize(animationProps) {
19
+ return null;
20
+ }
19
21
  }
@@ -1,6 +1,6 @@
1
1
  import { Device } from '@luma.gl/core';
2
- import { Timeline } from '../animation/timeline';
3
- import { AnimationProps } from './animation-props';
2
+ import { Timeline } from "../animation/timeline.js";
3
+ import { AnimationProps } from "./animation-props.js";
4
4
  import { Stats, Stat } from '@probe.gl/stats';
5
5
  /** AnimationLoop properties */
6
6
  export type AnimationLoopProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-loop.ts"],"names":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}
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  import { luma } from '@luma.gl/core';
4
5
  import { requestAnimationFrame, cancelAnimationFrame } from '@luma.gl/core';
@@ -7,15 +8,17 @@ let statIdCounter = 0;
7
8
  const DEFAULT_ANIMATION_LOOP_PROPS = {
8
9
  device: null,
9
10
  onAddHTML: () => '',
10
- onInitialize: async () => { return null; },
11
+ onInitialize: async () => {
12
+ return null;
13
+ },
11
14
  onRender: () => { },
12
15
  onFinalize: () => { },
13
- onError: (error) => console.error(error), // eslint-disable-line no-console
16
+ onError: error => console.error(error), // eslint-disable-line no-console
14
17
  stats: luma.stats.get(`animation-loop-${statIdCounter++}`),
15
18
  // view parameters
16
19
  useDevicePixels: true,
17
20
  autoResizeViewport: false,
18
- autoResizeDrawingBuffer: false,
21
+ autoResizeDrawingBuffer: false
19
22
  };
20
23
  /** Convenient animation loop */
21
24
  export class AnimationLoop {
@@ -172,7 +175,7 @@ export class AnimationLoop {
172
175
  waitForRender() {
173
176
  this.setNeedsRedraw('waitForRender');
174
177
  if (!this._nextFramePromise) {
175
- this._nextFramePromise = new Promise((resolve) => {
178
+ this._nextFramePromise = new Promise(resolve => {
176
179
  this._resolveNextFrame = resolve;
177
180
  });
178
181
  }
@@ -375,10 +378,15 @@ export class AnimationLoop {
375
378
  }
376
379
  /** Default viewport setup */
377
380
  _resizeViewport() {
381
+ // TODO can we use canvas context to code this in a portable way?
378
382
  // @ts-expect-error Expose on canvasContext
379
383
  if (this.props.autoResizeViewport && this.device.gl) {
380
384
  // @ts-expect-error Expose canvasContext
381
- this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);
385
+ this.device.gl.viewport(0, 0,
386
+ // @ts-expect-error Expose canvasContext
387
+ this.device.gl.drawingBufferWidth,
388
+ // @ts-expect-error Expose canvasContext
389
+ this.device.gl.drawingBufferHeight);
382
390
  }
383
391
  }
384
392
  /**
@@ -1,6 +1,6 @@
1
1
  import { Device } from '@luma.gl/core';
2
- import { Timeline } from '../animation/timeline';
3
- import type { AnimationLoop } from './animation-loop';
2
+ import { Timeline } from "../animation/timeline.js";
3
+ import type { AnimationLoop } from "./animation-loop.js";
4
4
  /** Properties passed to every render frame */
5
5
  export type AnimationProps = {
6
6
  device: Device;
@@ -1 +1 @@
1
- {"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAEpD,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAE7B,oCAAoC;IACpC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC5C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG1B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
1
+ {"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAC/C,OAAO,KAAK,EAAC,aAAa,EAAC,4BAAyB;AAEpD,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAE7B,oCAAoC;IACpC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAC;IAC5C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG1B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
@@ -1,5 +1,5 @@
1
- import { AnimationLoopTemplate } from './animation-loop-template';
2
- import { AnimationLoop, AnimationLoopProps } from './animation-loop';
1
+ import { AnimationLoopTemplate } from "./animation-loop-template.js";
2
+ import { AnimationLoop, AnimationLoopProps } from "./animation-loop.js";
3
3
  export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
4
4
  /** Instantiates and runs the render loop */
5
5
  export declare function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop;
@@ -1 +1 @@
1
- {"version":3,"file":"make-animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/make-animation-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAA;AAGlE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAE7H,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,yBAAyB,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC,EAAE,sBAAsB,GAAG,aAAa,CAkCxI"}
1
+ {"version":3,"file":"make-animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/make-animation-loop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,qBAAqB,EAAC,qCAAkC;AAChE,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,4BAAyB;AAGnE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,kBAAkB,EAClB,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAC9D,CAAC;AAEF,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAC/B,yBAAyB,EAAE,OAAO,qBAAqB,EACvD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,aAAa,CAkCf"}
@@ -1,6 +1,8 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
2
4
  import { luma } from '@luma.gl/core';
3
- import { AnimationLoop } from './animation-loop';
5
+ import { AnimationLoop } from "./animation-loop.js";
4
6
  /** Instantiates and runs the render loop */
5
7
  export function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
6
8
  let renderLoop = null;
@@ -0,0 +1,95 @@
1
+ import type { TypedArray } from '@luma.gl/core';
2
+ import type { ComputePipelineProps, Shader, Binding } from '@luma.gl/core';
3
+ import { Device, Buffer, ComputePipeline, ComputePass, UniformStore } from '@luma.gl/core';
4
+ import type { ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
5
+ import { ShaderAssembler } from '@luma.gl/shadertools';
6
+ import { ShaderInputs } from "./shader-inputs.js";
7
+ import { PipelineFactory } from "./lib/pipeline-factory.js";
8
+ import { ShaderFactory } from "./lib/shader-factory.js";
9
+ export type ComputationProps = Omit<ComputePipelineProps, 'shader'> & {
10
+ source?: string;
11
+ /** shadertool shader modules (added to shader code) */
12
+ modules?: ShaderModule[];
13
+ /** Shadertool module defines (configures shader code)*/
14
+ defines?: Record<string, string | number | boolean>;
15
+ /** Shader inputs, used to generated uniform buffers and bindings */
16
+ shaderInputs?: ShaderInputs;
17
+ /** Bindings */
18
+ bindings?: Record<string, Binding>;
19
+ /** Show shader source in browser? */
20
+ debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
21
+ /** Factory used to create a {@link ComputePipeline}. Defaults to {@link Device} default factory. */
22
+ pipelineFactory?: PipelineFactory;
23
+ /** Factory used to create a {@link Shader}. Defaults to {@link Device} default factory. */
24
+ shaderFactory?: ShaderFactory;
25
+ /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
26
+ shaderAssembler?: ShaderAssembler;
27
+ };
28
+ /**
29
+ * v9 Model API
30
+ * A model
31
+ * - automatically reuses pipelines (programs) when possible
32
+ * - automatically rebuilds pipelines if necessary to accommodate changed settings
33
+ * shadertools integration
34
+ * - accepts modules and performs shader transpilation
35
+ */
36
+ export declare class Computation {
37
+ static defaultProps: Required<ComputationProps>;
38
+ readonly device: Device;
39
+ readonly id: string;
40
+ readonly pipelineFactory: PipelineFactory;
41
+ readonly shaderFactory: ShaderFactory;
42
+ userData: {
43
+ [key: string]: any;
44
+ };
45
+ /** Bindings (textures, samplers, uniform buffers) */
46
+ bindings: Record<string, Binding>;
47
+ /** The underlying GPU "program". @note May be recreated if parameters change */
48
+ pipeline: ComputePipeline;
49
+ /** the underlying compiled compute shader */
50
+ shader: Shader;
51
+ source: string;
52
+ /** ShaderInputs instance */
53
+ shaderInputs: ShaderInputs;
54
+ _uniformStore: UniformStore;
55
+ _pipelineNeedsUpdate: string | false;
56
+ private _getModuleUniforms;
57
+ private props;
58
+ private _destroyed;
59
+ constructor(device: Device, props: ComputationProps);
60
+ destroy(): void;
61
+ predraw(): void;
62
+ dispatch(computePass: ComputePass, x: number, y?: number, z?: number): void;
63
+ /**
64
+ * Updates the vertex count (used in draw calls)
65
+ * @note Any attributes with stepMode=vertex need to be at least this big
66
+ */
67
+ setVertexCount(vertexCount: number): void;
68
+ /**
69
+ * Updates the instance count (used in draw calls)
70
+ * @note Any attributes with stepMode=instance need to be at least this big
71
+ */
72
+ setInstanceCount(instanceCount: number): void;
73
+ setShaderInputs(shaderInputs: ShaderInputs): void;
74
+ /**
75
+ * Updates shader module settings (which results in uniforms being set)
76
+ */
77
+ setShaderModuleProps(props: Record<string, any>): void;
78
+ updateShaderInputs(): void;
79
+ /**
80
+ * Sets bindings (textures, samplers, uniform buffers)
81
+ */
82
+ setBindings(bindings: Record<string, Binding>): void;
83
+ _setPipelineNeedsUpdate(reason: string): void;
84
+ _updatePipeline(): ComputePipeline;
85
+ /** Throttle draw call logging */
86
+ _lastLogTime: number;
87
+ _logOpen: boolean;
88
+ _logDrawCallStart(): void;
89
+ _logDrawCallEnd(): void;
90
+ protected _drawCount: number;
91
+ _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string;
92
+ }
93
+ /** Create a shadertools platform info from the Device */
94
+ export declare function getPlatformInfo(device: Device): PlatformInfo;
95
+ //# sourceMappingURL=computation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computation.d.ts","sourceRoot":"","sources":["../src/computation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAgB,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM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IAAI,IAAI;IAazB,eAAe,IAAI,IAAI;IAgBvB,SAAS,CAAC,UAAU,SAAK;IAGzB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM;CAMlF;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS5D"}
@@ -0,0 +1,248 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { Buffer, ComputePipeline, UniformStore } from '@luma.gl/core';
5
+ import { log, uid, isNumberArray } from '@luma.gl/core';
6
+ import { getTypedArrayFromDataType } from '@luma.gl/core';
7
+ import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
8
+ import { ShaderInputs } from "./shader-inputs.js";
9
+ import { PipelineFactory } from "./lib/pipeline-factory.js";
10
+ import { ShaderFactory } from "./lib/shader-factory.js";
11
+ // import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
12
+ const LOG_DRAW_PRIORITY = 2;
13
+ const LOG_DRAW_TIMEOUT = 10000;
14
+ /**
15
+ * v9 Model API
16
+ * A model
17
+ * - automatically reuses pipelines (programs) when possible
18
+ * - automatically rebuilds pipelines if necessary to accommodate changed settings
19
+ * shadertools integration
20
+ * - accepts modules and performs shader transpilation
21
+ */
22
+ export class Computation {
23
+ static defaultProps = {
24
+ ...ComputePipeline.defaultProps,
25
+ id: 'unnamed',
26
+ handle: undefined,
27
+ userData: {},
28
+ source: '',
29
+ modules: [],
30
+ defines: {},
31
+ bindings: undefined,
32
+ shaderInputs: undefined,
33
+ pipelineFactory: undefined,
34
+ shaderFactory: undefined,
35
+ shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
36
+ debugShaders: undefined
37
+ };
38
+ device;
39
+ id;
40
+ pipelineFactory;
41
+ shaderFactory;
42
+ userData = {};
43
+ /** Bindings (textures, samplers, uniform buffers) */
44
+ bindings = {};
45
+ /** The underlying GPU "program". @note May be recreated if parameters change */
46
+ pipeline;
47
+ /** the underlying compiled compute shader */
48
+ shader;
49
+ source;
50
+ /** ShaderInputs instance */
51
+ shaderInputs;
52
+ _uniformStore;
53
+ _pipelineNeedsUpdate = 'newly created';
54
+ _getModuleUniforms;
55
+ props;
56
+ _destroyed = false;
57
+ constructor(device, props) {
58
+ if (device.type !== 'webgpu') {
59
+ throw new Error('Computation is only supported in WebGPU');
60
+ }
61
+ this.props = { ...Computation.defaultProps, ...props };
62
+ props = this.props;
63
+ this.id = props.id || uid('model');
64
+ this.device = device;
65
+ Object.assign(this.userData, props.userData);
66
+ // Setup shader module inputs
67
+ const moduleMap = Object.fromEntries(this.props.modules?.map(module => [module.name, module]) || []);
68
+ this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));
69
+ // Support WGSL shader layout introspection
70
+ // TODO - Don't modify props!!
71
+ this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source);
72
+ // Setup shader assembler
73
+ const platformInfo = getPlatformInfo(device);
74
+ // Extract modules from shader inputs if not supplied
75
+ const modules = (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
76
+ this.pipelineFactory =
77
+ props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
78
+ this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
79
+ const { source, getUniforms } = this.props.shaderAssembler.assembleShader({
80
+ platformInfo,
81
+ ...this.props,
82
+ modules
83
+ });
84
+ this.source = source;
85
+ this._getModuleUniforms = getUniforms;
86
+ // Create the pipeline
87
+ // @note order is important
88
+ this.pipeline = this._updatePipeline();
89
+ // Apply any dynamic settings that will not trigger pipeline change
90
+ if (props.bindings) {
91
+ this.setBindings(props.bindings);
92
+ }
93
+ // Catch any access to non-standard props
94
+ Object.seal(this);
95
+ }
96
+ destroy() {
97
+ if (this._destroyed)
98
+ return;
99
+ this.pipelineFactory.release(this.pipeline);
100
+ this.shaderFactory.release(this.shader);
101
+ this._uniformStore.destroy();
102
+ this._destroyed = true;
103
+ }
104
+ // Draw call
105
+ predraw() {
106
+ // Update uniform buffers if needed
107
+ this.updateShaderInputs();
108
+ }
109
+ dispatch(computePass, x, y, z) {
110
+ try {
111
+ this._logDrawCallStart();
112
+ // Check if the pipeline is invalidated
113
+ // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?
114
+ this.pipeline = this._updatePipeline();
115
+ // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
116
+ // Any caching needs to be done inside the pipeline functions
117
+ this.pipeline.setBindings(this.bindings);
118
+ computePass.setPipeline(this.pipeline);
119
+ // @ts-expect-error
120
+ computePass.setBindings([]);
121
+ computePass.dispatch(x, y, z);
122
+ }
123
+ finally {
124
+ this._logDrawCallEnd();
125
+ }
126
+ }
127
+ // Update fixed fields (can trigger pipeline rebuild)
128
+ // Update dynamic fields
129
+ /**
130
+ * Updates the vertex count (used in draw calls)
131
+ * @note Any attributes with stepMode=vertex need to be at least this big
132
+ */
133
+ setVertexCount(vertexCount) {
134
+ // this.vertexCount = vertexCount;
135
+ }
136
+ /**
137
+ * Updates the instance count (used in draw calls)
138
+ * @note Any attributes with stepMode=instance need to be at least this big
139
+ */
140
+ setInstanceCount(instanceCount) {
141
+ // this.instanceCount = instanceCount;
142
+ }
143
+ setShaderInputs(shaderInputs) {
144
+ this.shaderInputs = shaderInputs;
145
+ this._uniformStore = new UniformStore(this.shaderInputs.modules);
146
+ // Create uniform buffer bindings for all modules
147
+ for (const moduleName of Object.keys(this.shaderInputs.modules)) {
148
+ const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
149
+ this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
150
+ }
151
+ }
152
+ /**
153
+ * Updates shader module settings (which results in uniforms being set)
154
+ */
155
+ setShaderModuleProps(props) {
156
+ const uniforms = this._getModuleUniforms(props);
157
+ // Extract textures & framebuffers set by the modules
158
+ // TODO better way to extract bindings
159
+ const keys = Object.keys(uniforms).filter(k => {
160
+ const uniform = uniforms[k];
161
+ return !isNumberArray(uniform) && typeof uniform !== 'number' && typeof uniform !== 'boolean';
162
+ });
163
+ const bindings = {};
164
+ for (const k of keys) {
165
+ bindings[k] = uniforms[k];
166
+ delete uniforms[k];
167
+ }
168
+ }
169
+ updateShaderInputs() {
170
+ this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());
171
+ }
172
+ /**
173
+ * Sets bindings (textures, samplers, uniform buffers)
174
+ */
175
+ setBindings(bindings) {
176
+ Object.assign(this.bindings, bindings);
177
+ }
178
+ _setPipelineNeedsUpdate(reason) {
179
+ this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;
180
+ }
181
+ _updatePipeline() {
182
+ if (this._pipelineNeedsUpdate) {
183
+ let prevShader = null;
184
+ if (this.pipeline) {
185
+ log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
186
+ prevShader = this.shader;
187
+ }
188
+ this._pipelineNeedsUpdate = false;
189
+ this.shader = this.shaderFactory.createShader({
190
+ id: `${this.id}-fragment`,
191
+ stage: 'compute',
192
+ source: this.source,
193
+ debug: this.props.debugShaders
194
+ });
195
+ this.pipeline = this.pipelineFactory.createComputePipeline({
196
+ ...this.props,
197
+ shader: this.shader
198
+ });
199
+ if (prevShader) {
200
+ this.shaderFactory.release(prevShader);
201
+ }
202
+ }
203
+ return this.pipeline;
204
+ }
205
+ /** Throttle draw call logging */
206
+ _lastLogTime = 0;
207
+ _logOpen = false;
208
+ _logDrawCallStart() {
209
+ // IF level is 4 or higher, log every frame.
210
+ const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
211
+ if (log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
212
+ return;
213
+ }
214
+ this._lastLogTime = Date.now();
215
+ this._logOpen = true;
216
+ log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: log.level <= 2 })();
217
+ }
218
+ _logDrawCallEnd() {
219
+ if (this._logOpen) {
220
+ // const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.props.shaderLayout, this.id);
221
+ // log.table(logLevel, attributeTable)();
222
+ // log.table(logLevel, uniformTable)();
223
+ // log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
224
+ const uniformTable = this.shaderInputs.getDebugTable();
225
+ log.table(LOG_DRAW_PRIORITY, uniformTable)();
226
+ log.groupEnd(LOG_DRAW_PRIORITY)();
227
+ this._logOpen = false;
228
+ }
229
+ }
230
+ _drawCount = 0;
231
+ // TODO - fix typing of luma data types
232
+ _getBufferOrConstantValues(attribute, dataType) {
233
+ const TypedArrayConstructor = getTypedArrayFromDataType(dataType);
234
+ const typedArray = attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
235
+ return typedArray.toString();
236
+ }
237
+ }
238
+ /** Create a shadertools platform info from the Device */
239
+ export function getPlatformInfo(device) {
240
+ return {
241
+ type: device.type,
242
+ shaderLanguage: device.info.shadingLanguage,
243
+ shaderLanguageVersion: device.info.shadingLanguageVersion,
244
+ gpu: device.info.gpu,
245
+ // HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
246
+ features: device.features
247
+ };
248
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"copy-texture-to-image.d.ts","sourceRoot":"","sources":["../../src/debug/copy-texture-to-image.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAInD;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GAAG,WAAW,EAC7B,OAAO,CAAC,EAAE,yBAAyB,GAClC,gBAAgB,CAOlB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,GAAG,WAAW,EAC7B,OAAO,GAAE,yBAA8B,GACtC,MAAM,CA4BR"}
1
+ {"version":3,"file":"copy-texture-to-image.d.ts","sourceRoot":"","sources":["../../src/debug/copy-texture-to-image.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAInD;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GAAG,WAAW,EAC7B,OAAO,CAAC,EAAE,yBAAyB,GAClC,gBAAgB,CAMlB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,GAAG,WAAW,EAC7B,OAAO,GAAE,yBAA8B,GACtC,MAAM,CA4BR"}
@@ -1,5 +1,8 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { GL } from '@luma.gl/constants';
2
- import { flipRows, scalePixels } from './pixel-data-utils';
5
+ import { flipRows, scalePixels } from "./pixel-data-utils.js";
3
6
  /**
4
7
  * Reads pixels from a Framebuffer or Texture object into an HTML Image
5
8
  * @todo - can we move this to @luma.gl/core?
@@ -20,7 +23,7 @@ export function copyTextureToImage(source, options) {
20
23
  * @param options
21
24
  */
22
25
  export function copyTextureToDataUrl(source, options = {}) {
23
- const { sourceAttachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
26
+ const { sourceAttachment = 36064, // TODO - support gl.readBuffer
24
27
  targetMaxHeight = Number.MAX_SAFE_INTEGER } = options;
25
28
  let data = source.device.readPixelsToArrayWebGL(source, { sourceAttachment });
26
29
  // Scale down
@@ -1 +1 @@
1
- {"version":3,"file":"debug-framebuffer.d.ts","sourceRoot":"","sources":["../../src/debug/debug-framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAQxD,qDAAqD;AAErD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,GAAG,OAAO,EAC1B,EAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAS,EAAE,IAAU,EAAE,SAAa,EAAC,EAAE;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,QA4ChK"}
1
+ {"version":3,"file":"debug-framebuffer.d.ts","sourceRoot":"","sources":["../../src/debug/debug-framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAQxD,qDAAqD;AAErD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,GAAG,OAAO,EAC1B,EACE,EAAE,EACF,OAAO,EACP,MAAM,EACN,GAAS,EACT,IAAU,EACV,SAAa,EACd,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,QA2CF"}
@@ -44,4 +44,3 @@ export function debugFramebuffer(fbo, { id, minimap, opaque, top = '0', left = '
44
44
  }
45
45
  ctx.putImageData(imageData, 0, 0);
46
46
  }
47
- ;
@@ -1 +1 @@
1
- {"version":3,"file":"pixel-data-utils.d.ts","sourceRoot":"","sources":["../../src/debug/pixel-data-utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAgBP;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG;IACF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
1
+ {"version":3,"file":"pixel-data-utils.d.ts","sourceRoot":"","sources":["../../src/debug/pixel-data-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAgBP;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG;IACvF,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAaA"}
@@ -1,4 +1,5 @@
1
- // luma.gl, MIT license
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
  /**
4
5
  * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)