@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.2

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 (191) hide show
  1. package/LICENSE +3 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +6 -27
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +8 -8
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +18 -49
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/animation-loop/animation-loop-template.d.ts +23 -0
  11. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
  12. package/dist/animation-loop/animation-loop-template.js +7 -0
  13. package/dist/animation-loop/animation-loop-template.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
  15. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  16. package/dist/{lib → animation-loop}/animation-loop.js +77 -192
  17. package/dist/animation-loop/animation-loop.js.map +1 -0
  18. package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
  19. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  20. package/dist/animation-loop/animation-props.js.map +1 -0
  21. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  22. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/make-animation-loop.js +28 -0
  24. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  25. package/dist/debug/copy-texture-to-image.d.ts +26 -0
  26. package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
  27. package/dist/debug/copy-texture-to-image.js +46 -0
  28. package/dist/debug/copy-texture-to-image.js.map +1 -0
  29. package/dist/debug/debug-framebuffer.d.ts +11 -0
  30. package/dist/debug/debug-framebuffer.d.ts.map +1 -0
  31. package/dist/debug/debug-framebuffer.js +43 -0
  32. package/dist/debug/debug-framebuffer.js.map +1 -0
  33. package/dist/debug/debug-shader-layout.d.ts +9 -0
  34. package/dist/debug/debug-shader-layout.d.ts.map +1 -0
  35. package/dist/debug/debug-shader-layout.js +28 -0
  36. package/dist/debug/debug-shader-layout.js.map +1 -0
  37. package/dist/debug/pixel-data-utils.d.ts +24 -0
  38. package/dist/debug/pixel-data-utils.d.ts.map +1 -0
  39. package/dist/debug/pixel-data-utils.js +41 -0
  40. package/dist/debug/pixel-data-utils.js.map +1 -0
  41. package/dist/dist.dev.js +10073 -0
  42. package/dist/geometries/cone-geometry.d.ts +1 -1
  43. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  44. package/dist/geometries/cone-geometry.js +6 -5
  45. package/dist/geometries/cone-geometry.js.map +1 -1
  46. package/dist/geometries/cube-geometry.d.ts +2 -2
  47. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  48. package/dist/geometries/cube-geometry.js +16 -10
  49. package/dist/geometries/cube-geometry.js.map +1 -1
  50. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  51. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  52. package/dist/geometries/cylinder-geometry.js +6 -5
  53. package/dist/geometries/cylinder-geometry.js.map +1 -1
  54. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  55. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  56. package/dist/geometries/ico-sphere-geometry.js +10 -19
  57. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  58. package/dist/geometries/plane-geometry.d.ts +2 -2
  59. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  60. package/dist/geometries/plane-geometry.js +14 -23
  61. package/dist/geometries/plane-geometry.js.map +1 -1
  62. package/dist/geometries/sphere-geometry.d.ts +2 -2
  63. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  64. package/dist/geometries/sphere-geometry.js +9 -13
  65. package/dist/geometries/sphere-geometry.js.map +1 -1
  66. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  67. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  68. package/dist/geometries/truncated-cone-geometry.js +9 -25
  69. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  70. package/dist/geometry/geometry-table.d.ts +2 -2
  71. package/dist/geometry/geometry-table.d.ts.map +1 -1
  72. package/dist/geometry/geometry-table.js.map +1 -1
  73. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  74. package/dist/geometry/geometry-utils.js +0 -9
  75. package/dist/geometry/geometry-utils.js.map +1 -1
  76. package/dist/geometry/geometry.d.ts +43 -43
  77. package/dist/geometry/geometry.d.ts.map +1 -1
  78. package/dist/geometry/geometry.js +20 -86
  79. package/dist/geometry/geometry.js.map +1 -1
  80. package/dist/geometry/gpu-geometry.d.ts +37 -0
  81. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  82. package/dist/geometry/gpu-geometry.js +110 -0
  83. package/dist/geometry/gpu-geometry.js.map +1 -0
  84. package/dist/geometry/gpu-table.d.ts +1 -0
  85. package/dist/geometry/gpu-table.d.ts.map +1 -0
  86. package/dist/geometry/gpu-table.js +2 -0
  87. package/dist/geometry/gpu-table.js.map +1 -0
  88. package/dist/index.cjs +3120 -0
  89. package/dist/index.d.ts +24 -8
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +23 -14
  92. package/dist/index.js.map +1 -1
  93. package/dist/lib/clip-space.d.ts +8 -0
  94. package/dist/lib/clip-space.d.ts.map +1 -1
  95. package/dist/lib/clip-space.js +47 -0
  96. package/dist/lib/clip-space.js.map +1 -1
  97. package/dist/lib/pipeline-factory.d.ts +12 -46
  98. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  99. package/dist/lib/pipeline-factory.js +36 -179
  100. package/dist/lib/pipeline-factory.js.map +1 -1
  101. package/dist/model/model.d.ts +206 -0
  102. package/dist/model/model.d.ts.map +1 -0
  103. package/dist/model/model.js +440 -0
  104. package/dist/model/model.js.map +1 -0
  105. package/dist/scenegraph/group-node.d.ts +21 -0
  106. package/dist/scenegraph/group-node.d.ts.map +1 -0
  107. package/dist/scenegraph/group-node.js +94 -0
  108. package/dist/scenegraph/group-node.js.map +1 -0
  109. package/dist/scenegraph/model-node.d.ts +18 -0
  110. package/dist/scenegraph/model-node.d.ts.map +1 -0
  111. package/dist/scenegraph/model-node.js +28 -0
  112. package/dist/scenegraph/model-node.js.map +1 -0
  113. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  114. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  115. package/dist/scenegraph/scenegraph-node.js +141 -0
  116. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  117. package/dist/shader-inputs.d.ts +63 -0
  118. package/dist/shader-inputs.d.ts.map +1 -0
  119. package/dist/shader-inputs.js +66 -0
  120. package/dist/shader-inputs.js.map +1 -0
  121. package/dist/transform/buffer-transform.d.ts +35 -0
  122. package/dist/transform/buffer-transform.d.ts.map +1 -0
  123. package/dist/transform/buffer-transform.js +62 -0
  124. package/dist/transform/buffer-transform.js.map +1 -0
  125. package/dist/transform/texture-transform.d.ts +57 -0
  126. package/dist/transform/texture-transform.d.ts.map +1 -0
  127. package/dist/transform/texture-transform.js +122 -0
  128. package/dist/transform/texture-transform.js.map +1 -0
  129. package/dist.min.js +293 -0
  130. package/package.json +21 -12
  131. package/src/animation/timeline.ts +15 -14
  132. package/src/animation-loop/animation-loop-template.ts +23 -0
  133. package/src/{lib → animation-loop}/animation-loop.ts +99 -88
  134. package/src/{lib → animation-loop}/animation-props.ts +1 -1
  135. package/src/animation-loop/make-animation-loop.ts +44 -0
  136. package/src/debug/copy-texture-to-image.ts +72 -0
  137. package/src/debug/debug-framebuffer.ts +57 -0
  138. package/src/debug/debug-shader-layout.ts +38 -0
  139. package/src/debug/pixel-data-utils.ts +57 -0
  140. package/src/geometries/cone-geometry.ts +1 -1
  141. package/src/geometries/cube-geometry.ts +47 -45
  142. package/src/geometries/cylinder-geometry.ts +2 -2
  143. package/src/geometries/ico-sphere-geometry.ts +6 -5
  144. package/src/geometries/plane-geometry.ts +5 -4
  145. package/src/geometries/sphere-geometry.ts +4 -3
  146. package/src/geometries/truncated-cone-geometry.ts +4 -13
  147. package/src/geometry/geometry-table.ts +1 -1
  148. package/src/geometry/geometry-utils.ts +19 -3
  149. package/src/geometry/geometry.ts +65 -110
  150. package/src/geometry/gpu-geometry.ts +125 -0
  151. package/src/geometry/gpu-table.ts +41 -0
  152. package/src/index.ts +34 -10
  153. package/src/lib/clip-space.ts +22 -21
  154. package/src/lib/pipeline-factory.ts +48 -179
  155. package/src/model/model.ts +733 -0
  156. package/src/scenegraph/group-node.ts +103 -0
  157. package/src/scenegraph/model-node.ts +50 -0
  158. package/src/scenegraph/scenegraph-node.ts +204 -0
  159. package/src/shader-inputs.ts +150 -0
  160. package/src/transform/buffer-transform.ts +94 -0
  161. package/src/transform/texture-transform.ts +169 -0
  162. package/dist/bundle.d.ts +0 -2
  163. package/dist/bundle.d.ts.map +0 -1
  164. package/dist/bundle.js +0 -5
  165. package/dist/bundle.js.map +0 -1
  166. package/dist/geometry/primitive-utils.d.ts +0 -1
  167. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  168. package/dist/geometry/primitive-utils.js +0 -2
  169. package/dist/geometry/primitive-utils.js.map +0 -1
  170. package/dist/lib/animation-loop.d.ts.map +0 -1
  171. package/dist/lib/animation-loop.js.map +0 -1
  172. package/dist/lib/animation-props.d.ts.map +0 -1
  173. package/dist/lib/animation-props.js.map +0 -1
  174. package/dist/lib/model-utils.d.ts +0 -5
  175. package/dist/lib/model-utils.d.ts.map +0 -1
  176. package/dist/lib/model-utils.js +0 -45
  177. package/dist/lib/model-utils.js.map +0 -1
  178. package/dist/lib/model.d.ts +0 -41
  179. package/dist/lib/model.d.ts.map +0 -1
  180. package/dist/lib/model.js +0 -182
  181. package/dist/lib/model.js.map +0 -1
  182. package/dist/lib/render-loop.d.ts +0 -14
  183. package/dist/lib/render-loop.d.ts.map +0 -1
  184. package/dist/lib/render-loop.js +0 -49
  185. package/dist/lib/render-loop.js.map +0 -1
  186. package/src/bundle.ts +0 -4
  187. package/src/geometry/primitive-utils.ts +0 -30
  188. package/src/lib/model-utils.ts +0 -124
  189. package/src/lib/model.ts +0 -183
  190. package/src/lib/render-loop.ts +0 -58
  191. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-animation-loop.js","names":["luma","AnimationLoop","makeAnimationLoop","AnimationLoopTemplateCtor","props","renderLoop","device","createDevice","animationLoop","onInitialize","animationProps","_renderLoop","onRender","_renderLoop2","onFinalize","_renderLoop3","getInfo","info"],"sources":["../../src/animation-loop/make-animation-loop.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {luma} from '@luma.gl/core';\nimport {AnimationLoopTemplate} from './animation-loop-template'\nimport {AnimationLoop, AnimationLoopProps} from './animation-loop'\nimport type {AnimationProps} from './animation-props';\n\nexport type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;\n\n/** Instantiates and runs the render loop */\nexport function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop {\n let renderLoop: AnimationLoopTemplate | null = null;\n\n const device = props?.device || luma.createDevice();\n\n // Create an animation loop;\n const animationLoop = new AnimationLoop({\n ... props,\n\n device,\n\n async onInitialize(animationProps: AnimationProps): Promise<unknown> {\n // @ts-expect-error abstract to prevent instantiation\n renderLoop = new AnimationLoopTemplateCtor(animationProps);\n // Any async loading can be handled here\n return await renderLoop?.onInitialize(animationProps);\n },\n\n onRender: (animationProps: AnimationProps) => renderLoop?.onRender(animationProps),\n \n onFinalize: (animationProps: AnimationProps) => renderLoop?.onFinalize(animationProps)\n });\n\n // @ts-expect-error Hack: adds info for the website to find\n animationLoop.getInfo = () => {\n // @ts-ignore\n // eslint-disable-next-line no-invalid-this\n return this.AnimationLoopTemplateCtor.info;\n }\n\n // Start the loop automatically\n // animationLoop.start();\n\n return animationLoop;\n}\n"],"mappings":"AACA,SAAQA,IAAI,QAAO,eAAe;AAAC,SAE3BC,aAAa;AAMrB,OAAO,SAASC,iBAAiBA,CAACC,yBAAuD,EAAEC,KAA8B,EAAiB;EACxI,IAAIC,UAAwC,GAAG,IAAI;EAEnD,MAAMC,MAAM,GAAG,CAAAF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,MAAM,KAAIN,IAAI,CAACO,YAAY,CAAC,CAAC;EAGnD,MAAMC,aAAa,GAAG,IAAIP,aAAa,CAAC;IACtC,GAAIG,KAAK;IAETE,MAAM;IAEN,MAAMG,YAAYA,CAACC,cAA8B,EAAoB;MAAA,IAAAC,WAAA;MAEnEN,UAAU,GAAG,IAAIF,yBAAyB,CAACO,cAAc,CAAC;MAE1D,OAAO,QAAAC,WAAA,GAAMN,UAAU,cAAAM,WAAA,uBAAVA,WAAA,CAAYF,YAAY,CAACC,cAAc,CAAC;IACvD,CAAC;IAEDE,QAAQ,EAAGF,cAA8B;MAAA,IAAAG,YAAA;MAAA,QAAAA,YAAA,GAAKR,UAAU,cAAAQ,YAAA,uBAAVA,YAAA,CAAYD,QAAQ,CAACF,cAAc,CAAC;IAAA;IAElFI,UAAU,EAAGJ,cAA8B;MAAA,IAAAK,YAAA;MAAA,QAAAA,YAAA,GAAKV,UAAU,cAAAU,YAAA,uBAAVA,YAAA,CAAYD,UAAU,CAACJ,cAAc,CAAC;IAAA;EACxF,CAAC,CAAC;EAGFF,aAAa,CAACQ,OAAO,GAAG,MAAM;IAG5B,OAAO,IAAI,CAACb,yBAAyB,CAACc,IAAI;EAC5C,CAAC;EAKD,OAAOT,aAAa;AACtB"}
@@ -0,0 +1,26 @@
1
+ import { Texture, Framebuffer } from '@luma.gl/core';
2
+ /**
3
+ * Options for copying texture pixels to image
4
+ * @todo - support gl.readBuffer
5
+ */
6
+ export type CopyTextureToImageOptions = {
7
+ sourceAttachment?: number;
8
+ targetMaxHeight?: number;
9
+ targetImage?: HTMLImageElement;
10
+ };
11
+ /**
12
+ * Reads pixels from a Framebuffer or Texture object into an HTML Image
13
+ * @todo - can we move this to @luma.gl/core?
14
+ * @param source
15
+ * @param options options passed to copyToDataUrl
16
+ * @returns
17
+ */
18
+ export declare function copyTextureToImage(source: Texture | Framebuffer, options?: CopyTextureToImageOptions): HTMLImageElement;
19
+ /**
20
+ * Reads pixels from a Framebuffer or Texture object to a dataUrl
21
+ * @todo - can we move this to @luma.gl/core?
22
+ * @param source texture or framebuffer to read from
23
+ * @param options
24
+ */
25
+ export declare function copyTextureToDataUrl(source: Texture | Framebuffer, options?: CopyTextureToImageOptions): string;
26
+ //# sourceMappingURL=copy-texture-to-image.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,46 @@
1
+ import { flipRows, scalePixels } from "./pixel-data-utils.js";
2
+ export function copyTextureToImage(source, options) {
3
+ const dataUrl = copyTextureToDataUrl(source, options);
4
+ const targetImage = (options === null || options === void 0 ? void 0 : options.targetImage) || new Image();
5
+ targetImage.src = dataUrl;
6
+ return targetImage;
7
+ }
8
+ export function copyTextureToDataUrl(source) {
9
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10
+ const {
11
+ sourceAttachment = 36064,
12
+ targetMaxHeight = Number.MAX_SAFE_INTEGER
13
+ } = options;
14
+ let data = source.device.readPixelsToArrayWebGL(source, {
15
+ sourceAttachment
16
+ });
17
+ let {
18
+ width,
19
+ height
20
+ } = source;
21
+ while (height > targetMaxHeight) {
22
+ ({
23
+ data,
24
+ width,
25
+ height
26
+ } = scalePixels({
27
+ data,
28
+ width,
29
+ height
30
+ }));
31
+ }
32
+ flipRows({
33
+ data,
34
+ width,
35
+ height
36
+ });
37
+ const canvas = document.createElement('canvas');
38
+ canvas.width = width;
39
+ canvas.height = height;
40
+ const context = canvas.getContext('2d');
41
+ const imageData = context.createImageData(width, height);
42
+ imageData.data.set(data);
43
+ context.putImageData(imageData, 0, 0);
44
+ return canvas.toDataURL('image/png');
45
+ }
46
+ //# sourceMappingURL=copy-texture-to-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-texture-to-image.js","names":["flipRows","scalePixels","copyTextureToImage","source","options","dataUrl","copyTextureToDataUrl","targetImage","Image","src","arguments","length","undefined","sourceAttachment","targetMaxHeight","Number","MAX_SAFE_INTEGER","data","device","readPixelsToArrayWebGL","width","height","canvas","document","createElement","context","getContext","imageData","createImageData","set","putImageData","toDataURL"],"sources":["../../src/debug/copy-texture-to-image.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, Framebuffer} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {flipRows, scalePixels} from './pixel-data-utils';\n\n/**\n * Options for copying texture pixels to image\n * @todo - support gl.readBuffer\n */\nexport type CopyTextureToImageOptions = {\n sourceAttachment?: number; \n targetMaxHeight?: number;\n targetImage?: HTMLImageElement;\n};\n\n/**\n * Reads pixels from a Framebuffer or Texture object into an HTML Image\n * @todo - can we move this to @luma.gl/core?\n * @param source \n * @param options options passed to copyToDataUrl\n * @returns \n */\nexport function copyTextureToImage(\n source: Texture | Framebuffer,\n options?: CopyTextureToImageOptions\n): HTMLImageElement {\n\n const dataUrl = copyTextureToDataUrl(source, options);\n const targetImage: HTMLImageElement = options?.targetImage || new Image();\n targetImage.src = dataUrl;\n\n return targetImage;\n}\n\n/**\n * Reads pixels from a Framebuffer or Texture object to a dataUrl\n * @todo - can we move this to @luma.gl/core?\n * @param source texture or framebuffer to read from\n * @param options \n */\nexport function copyTextureToDataUrl(\n source: Texture | Framebuffer,\n options: CopyTextureToImageOptions = {}\n): string {\n const {\n sourceAttachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMaxHeight = Number.MAX_SAFE_INTEGER\n } = options;\n\n let data = source.device.readPixelsToArrayWebGL(source, {sourceAttachment});\n\n // Scale down\n let {width, height} = source;\n while (height > targetMaxHeight) {\n ({data, width, height} = scalePixels({data, width, height}));\n }\n\n // Flip to top down coordinate system\n flipRows({data, width, height});\n\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const context = canvas.getContext('2d');\n\n // Copy the pixels to a 2D canvas\n const imageData = context.createImageData(width, height);\n imageData.data.set(data);\n context.putImageData(imageData, 0, 0);\n\n return canvas.toDataURL('image/png');\n}\n"],"mappings":"SAGQA,QAAQ,EAAEC,WAAW;AAmB7B,OAAO,SAASC,kBAAkBA,CAChCC,MAA6B,EAC7BC,OAAmC,EACjB;EAElB,MAAMC,OAAO,GAAGC,oBAAoB,CAACH,MAAM,EAAEC,OAAO,CAAC;EACrD,MAAMG,WAA6B,GAAG,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,WAAW,KAAI,IAAIC,KAAK,CAAC,CAAC;EACzED,WAAW,CAACE,GAAG,GAAGJ,OAAO;EAEzB,OAAOE,WAAW;AACpB;AAQA,OAAO,SAASD,oBAAoBA,CAClCH,MAA6B,EAErB;EAAA,IADRC,OAAkC,GAAAM,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEvC,MAAM;IACJG,gBAAgB,QAAuB;IACvCC,eAAe,GAAGC,MAAM,CAACC;EAC3B,CAAC,GAAGZ,OAAO;EAEX,IAAIa,IAAI,GAAGd,MAAM,CAACe,MAAM,CAACC,sBAAsB,CAAChB,MAAM,EAAE;IAACU;EAAgB,CAAC,CAAC;EAG3E,IAAI;IAACO,KAAK;IAAEC;EAAM,CAAC,GAAGlB,MAAM;EAC5B,OAAOkB,MAAM,GAAGP,eAAe,EAAE;IAC/B,CAAC;MAACG,IAAI;MAAEG,KAAK;MAAEC;IAAM,CAAC,GAAGpB,WAAW,CAAC;MAACgB,IAAI;MAAEG,KAAK;MAAEC;IAAM,CAAC,CAAC;EAC7D;EAGArB,QAAQ,CAAC;IAACiB,IAAI;IAAEG,KAAK;IAAEC;EAAM,CAAC,CAAC;EAE/B,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACF,KAAK,GAAGA,KAAK;EACpBE,MAAM,CAACD,MAAM,GAAGA,MAAM;EACtB,MAAMI,OAAO,GAAGH,MAAM,CAACI,UAAU,CAAC,IAAI,CAAC;EAGvC,MAAMC,SAAS,GAAGF,OAAO,CAACG,eAAe,CAACR,KAAK,EAAEC,MAAM,CAAC;EACxDM,SAAS,CAACV,IAAI,CAACY,GAAG,CAACZ,IAAI,CAAC;EACxBQ,OAAO,CAACK,YAAY,CAACH,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;EAErC,OAAOL,MAAM,CAACS,SAAS,CAAC,WAAW,CAAC;AACtC"}
@@ -0,0 +1,11 @@
1
+ import type { Framebuffer, Texture } from '@luma.gl/core';
2
+ /** Debug utility to draw FBO contents onto screen */
3
+ export declare function debugFramebuffer(fbo: Framebuffer | Texture, { id, minimap, opaque, top, left, rgbaScale }: {
4
+ id: string;
5
+ minimap?: boolean;
6
+ opaque?: boolean;
7
+ top?: string;
8
+ left?: string;
9
+ rgbaScale?: number;
10
+ }): void;
11
+ //# sourceMappingURL=debug-framebuffer.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,43 @@
1
+ let canvas = null;
2
+ let ctx = null;
3
+ export function debugFramebuffer(fbo, _ref) {
4
+ let {
5
+ id,
6
+ minimap,
7
+ opaque,
8
+ top = '0',
9
+ left = '0',
10
+ rgbaScale = 1
11
+ } = _ref;
12
+ if (!canvas) {
13
+ canvas = document.createElement('canvas');
14
+ canvas.id = id;
15
+ canvas.title = id;
16
+ canvas.style.zIndex = '100';
17
+ canvas.style.position = 'absolute';
18
+ canvas.style.top = top;
19
+ canvas.style.left = left;
20
+ canvas.style.border = 'blue 1px solid';
21
+ canvas.style.transform = 'scaleY(-1)';
22
+ document.body.appendChild(canvas);
23
+ ctx = canvas.getContext('2d');
24
+ }
25
+ if (canvas.width !== fbo.width || canvas.height !== fbo.height) {
26
+ canvas.width = fbo.width / 2;
27
+ canvas.height = fbo.height / 2;
28
+ canvas.style.width = '400px';
29
+ canvas.style.height = '400px';
30
+ }
31
+ const color = fbo.device.readPixelsToArrayWebGL(fbo);
32
+ const imageData = ctx.createImageData(fbo.width, fbo.height);
33
+ const offset = 0;
34
+ for (let i = 0; i < color.length; i += 4) {
35
+ imageData.data[offset + i + 0] = color[i + 0] * rgbaScale;
36
+ imageData.data[offset + i + 1] = color[i + 1] * rgbaScale;
37
+ imageData.data[offset + i + 2] = color[i + 2] * rgbaScale;
38
+ imageData.data[offset + i + 3] = opaque ? 255 : color[i + 3] * rgbaScale;
39
+ }
40
+ ctx.putImageData(imageData, 0, 0);
41
+ }
42
+ ;
43
+ //# sourceMappingURL=debug-framebuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-framebuffer.js","names":["canvas","ctx","debugFramebuffer","fbo","_ref","id","minimap","opaque","top","left","rgbaScale","document","createElement","title","style","zIndex","position","border","transform","body","appendChild","getContext","width","height","color","device","readPixelsToArrayWebGL","imageData","createImageData","offset","i","length","data","putImageData"],"sources":["../../src/debug/debug-framebuffer.ts"],"sourcesContent":["import type {Framebuffer, Texture} from '@luma.gl/core';\n// import {copyTextureToImage} from '../debug/copy-texture-to-image';\n\n/** Only works with 1st device? */\nlet canvas: HTMLCanvasElement | null = null;\nlet ctx: CanvasRenderingContext2D | null = null;\n// let targetImage: HTMLImageElement | null = null;\n\n/** Debug utility to draw FBO contents onto screen */\n// eslint-disable-next-line\nexport function debugFramebuffer(\n fbo: Framebuffer | Texture,\n {id, minimap, opaque, top = '0', left = '0', rgbaScale = 1}: {id: string, minimap?: boolean; opaque?: boolean, top?: string, left?: string, rgbaScale?: number}\n) {\n if (!canvas) {\n canvas = document.createElement('canvas');\n canvas.id = id;\n canvas.title = id;\n canvas.style.zIndex = '100';\n canvas.style.position = 'absolute';\n canvas.style.top = top; // ⚠️\n canvas.style.left = left; // ⚠️\n canvas.style.border = 'blue 1px solid';\n canvas.style.transform = 'scaleY(-1)';\n document.body.appendChild(canvas);\n\n ctx = canvas.getContext('2d');\n // targetImage = new Image();\n }\n\n // const canvasHeight = (minimap ? 2 : 1) * fbo.height;\n if (canvas.width !== fbo.width || canvas.height !== fbo.height) {\n canvas.width = fbo.width / 2;\n canvas.height = fbo.height / 2;\n canvas.style.width = '400px';\n canvas.style.height = '400px';\n\n }\n\n // const image = copyTextureToImage(fbo, {targetMaxHeight: 100, targetImage});\n // ctx.drawImage(image, 0, 0);\n\n const color = fbo.device.readPixelsToArrayWebGL(fbo);\n const imageData = ctx.createImageData(fbo.width, fbo.height);\n // Full map\n const offset = 0;\n // if (color.some((v) => v > 0)) {\n // console.error('THERE IS NON-ZERO DATA IN THE FBO!');\n // }\n for (let i = 0; i < color.length; i += 4) {\n imageData.data[offset + i + 0] = color[i + 0] * rgbaScale;\n imageData.data[offset + i + 1] = color[i + 1] * rgbaScale;\n imageData.data[offset + i + 2] = color[i + 2] * rgbaScale;\n imageData.data[offset + i + 3] = opaque ? 255 : color[i + 3] * rgbaScale;\n }\n ctx.putImageData(imageData, 0, 0);\n};"],"mappings":"AAIA,IAAIA,MAAgC,GAAG,IAAI;AAC3C,IAAIC,GAAoC,GAAG,IAAI;AAK/C,OAAO,SAASC,gBAAgBA,CAC9BC,GAA0B,EAAAC,IAAA,EAE1B;EAAA,IADA;IAACC,EAAE;IAAEC,OAAO;IAAEC,MAAM;IAAEC,GAAG,GAAG,GAAG;IAAEC,IAAI,GAAG,GAAG;IAAEC,SAAS,GAAG;EAAqG,CAAC,GAAAN,IAAA;EAE/J,IAAI,CAACJ,MAAM,EAAE;IACXA,MAAM,GAAGW,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IACzCZ,MAAM,CAACK,EAAE,GAAGA,EAAE;IACdL,MAAM,CAACa,KAAK,GAAGR,EAAE;IACjBL,MAAM,CAACc,KAAK,CAACC,MAAM,GAAG,KAAK;IAC3Bf,MAAM,CAACc,KAAK,CAACE,QAAQ,GAAG,UAAU;IAClChB,MAAM,CAACc,KAAK,CAACN,GAAG,GAAGA,GAAG;IACtBR,MAAM,CAACc,KAAK,CAACL,IAAI,GAAGA,IAAI;IACxBT,MAAM,CAACc,KAAK,CAACG,MAAM,GAAG,gBAAgB;IACtCjB,MAAM,CAACc,KAAK,CAACI,SAAS,GAAG,YAAY;IACrCP,QAAQ,CAACQ,IAAI,CAACC,WAAW,CAACpB,MAAM,CAAC;IAEjCC,GAAG,GAAGD,MAAM,CAACqB,UAAU,CAAC,IAAI,CAAC;EAE/B;EAGA,IAAIrB,MAAM,CAACsB,KAAK,KAAKnB,GAAG,CAACmB,KAAK,IAAItB,MAAM,CAACuB,MAAM,KAAKpB,GAAG,CAACoB,MAAM,EAAE;IAC9DvB,MAAM,CAACsB,KAAK,GAAGnB,GAAG,CAACmB,KAAK,GAAG,CAAC;IAC5BtB,MAAM,CAACuB,MAAM,GAAGpB,GAAG,CAACoB,MAAM,GAAG,CAAC;IAC9BvB,MAAM,CAACc,KAAK,CAACQ,KAAK,GAAG,OAAO;IAC5BtB,MAAM,CAACc,KAAK,CAACS,MAAM,GAAG,OAAO;EAE/B;EAKA,MAAMC,KAAK,GAAGrB,GAAG,CAACsB,MAAM,CAACC,sBAAsB,CAACvB,GAAG,CAAC;EACpD,MAAMwB,SAAS,GAAG1B,GAAG,CAAC2B,eAAe,CAACzB,GAAG,CAACmB,KAAK,EAAEnB,GAAG,CAACoB,MAAM,CAAC;EAE5D,MAAMM,MAAM,GAAG,CAAC;EAIhB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,EAAED,CAAC,IAAI,CAAC,EAAE;IACxCH,SAAS,CAACK,IAAI,CAACH,MAAM,GAAGC,CAAC,GAAG,CAAC,CAAC,GAAGN,KAAK,CAACM,CAAC,GAAG,CAAC,CAAC,GAAGpB,SAAS;IACzDiB,SAAS,CAACK,IAAI,CAACH,MAAM,GAAGC,CAAC,GAAG,CAAC,CAAC,GAAGN,KAAK,CAACM,CAAC,GAAG,CAAC,CAAC,GAAGpB,SAAS;IACzDiB,SAAS,CAACK,IAAI,CAACH,MAAM,GAAGC,CAAC,GAAG,CAAC,CAAC,GAAGN,KAAK,CAACM,CAAC,GAAG,CAAC,CAAC,GAAGpB,SAAS;IACzDiB,SAAS,CAACK,IAAI,CAACH,MAAM,GAAGC,CAAC,GAAG,CAAC,CAAC,GAAGvB,MAAM,GAAG,GAAG,GAAGiB,KAAK,CAACM,CAAC,GAAG,CAAC,CAAC,GAAGpB,SAAS;EAC1E;EACAT,GAAG,CAACgC,YAAY,CAACN,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AACnC;AAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ShaderLayout } from '@luma.gl/core';
2
+ /**
3
+ * Extracts a table suitable for `console.table()` from a shader layout to assist in debugging.
4
+ * @param layout shader layout
5
+ * @param name app should provide the most meaningful name, usually the model or pipeline name / id.
6
+ * @returns
7
+ */
8
+ export declare function getDebugTableForShaderLayout(layout: ShaderLayout, name: string): Record<string, Record<string, string>>;
9
+ //# sourceMappingURL=debug-shader-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-shader-layout.d.ts","sourceRoot":"","sources":["../../src/debug/debug-shader-layout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsBxC"}
@@ -0,0 +1,28 @@
1
+ export function getDebugTableForShaderLayout(layout, name) {
2
+ var _layout$varyings;
3
+ const table = {};
4
+ const header = 'Values';
5
+ if (layout.attributes.length === 0 && !((_layout$varyings = layout.varyings) !== null && _layout$varyings !== void 0 && _layout$varyings.length)) {
6
+ return {
7
+ 'No attributes or varyings': {
8
+ [header]: 'N/A'
9
+ }
10
+ };
11
+ }
12
+ for (const attributeDeclaration of layout.attributes) {
13
+ if (attributeDeclaration) {
14
+ const glslDeclaration = `${attributeDeclaration.location} ${attributeDeclaration.name}: ${attributeDeclaration.type}`;
15
+ table[`in ${glslDeclaration}`] = {
16
+ [header]: attributeDeclaration.stepMode || 'vertex'
17
+ };
18
+ }
19
+ }
20
+ for (const varyingDeclaration of layout.varyings || []) {
21
+ const glslDeclaration = `${varyingDeclaration.location} ${varyingDeclaration.name}`;
22
+ table[`out ${glslDeclaration}`] = {
23
+ [header]: JSON.stringify(varyingDeclaration.accessor)
24
+ };
25
+ }
26
+ return table;
27
+ }
28
+ //# sourceMappingURL=debug-shader-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-shader-layout.js","names":["getDebugTableForShaderLayout","layout","name","_layout$varyings","table","header","attributes","length","varyings","attributeDeclaration","glslDeclaration","location","type","stepMode","varyingDeclaration","JSON","stringify","accessor"],"sources":["../../src/debug/debug-shader-layout.ts"],"sourcesContent":["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderLayout} from '@luma.gl/core';\n\n/**\n * Extracts a table suitable for `console.table()` from a shader layout to assist in debugging.\n * @param layout shader layout\n * @param name app should provide the most meaningful name, usually the model or pipeline name / id.\n * @returns \n */\nexport function getDebugTableForShaderLayout(\n layout: ShaderLayout,\n name: string\n): Record<string, Record<string, string>> {\n const table: Record<string, Record<string, string>> = {};\n\n const header = 'Values'; // '`Shader Layout for ${name}`;\n\n if (layout.attributes.length === 0 && !layout.varyings?.length) {\n return {'No attributes or varyings': {[header]: 'N/A'}};\n }\n\n for (const attributeDeclaration of layout.attributes) {\n if (attributeDeclaration) {\n const glslDeclaration = `${attributeDeclaration.location} ${attributeDeclaration.name}: ${attributeDeclaration.type}`;\n table[`in ${glslDeclaration}`] = {[header]: attributeDeclaration.stepMode || 'vertex'};\n }\n }\n\n for (const varyingDeclaration of layout.varyings || []) {\n const glslDeclaration = `${varyingDeclaration.location} ${varyingDeclaration.name}`;\n table[`out ${glslDeclaration}`] = {[header]: JSON.stringify(varyingDeclaration.accessor)};\n }\n\n return table;\n}\n"],"mappings":"AAYA,OAAO,SAASA,4BAA4BA,CAC1CC,MAAoB,EACpBC,IAAY,EAC4B;EAAA,IAAAC,gBAAA;EACxC,MAAMC,KAA6C,GAAG,CAAC,CAAC;EAExD,MAAMC,MAAM,GAAG,QAAQ;EAEvB,IAAIJ,MAAM,CAACK,UAAU,CAACC,MAAM,KAAK,CAAC,IAAI,GAAAJ,gBAAA,GAACF,MAAM,CAACO,QAAQ,cAAAL,gBAAA,eAAfA,gBAAA,CAAiBI,MAAM,GAAE;IAC9D,OAAO;MAAC,2BAA2B,EAAE;QAAC,CAACF,MAAM,GAAG;MAAK;IAAC,CAAC;EACzD;EAEA,KAAK,MAAMI,oBAAoB,IAAIR,MAAM,CAACK,UAAU,EAAE;IACpD,IAAIG,oBAAoB,EAAE;MACxB,MAAMC,eAAe,GAAI,GAAED,oBAAoB,CAACE,QAAS,IAAGF,oBAAoB,CAACP,IAAK,KAAIO,oBAAoB,CAACG,IAAK,EAAC;MACrHR,KAAK,CAAE,MAAKM,eAAgB,EAAC,CAAC,GAAG;QAAC,CAACL,MAAM,GAAGI,oBAAoB,CAACI,QAAQ,IAAI;MAAQ,CAAC;IACxF;EACF;EAEA,KAAK,MAAMC,kBAAkB,IAAIb,MAAM,CAACO,QAAQ,IAAI,EAAE,EAAE;IACtD,MAAME,eAAe,GAAI,GAAEI,kBAAkB,CAACH,QAAS,IAAGG,kBAAkB,CAACZ,IAAK,EAAC;IACnFE,KAAK,CAAE,OAAMM,eAAgB,EAAC,CAAC,GAAG;MAAC,CAACL,MAAM,GAAGU,IAAI,CAACC,SAAS,CAACF,kBAAkB,CAACG,QAAQ;IAAC,CAAC;EAC3F;EAEA,OAAOb,KAAK;AACd"}
@@ -0,0 +1,24 @@
1
+ import { TypedArray } from '@luma.gl/core';
2
+ /**
3
+ * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)
4
+ * https: *stackoverflow.com/questions/41969562/
5
+ * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels
6
+ * @param param0
7
+ */
8
+ export declare function flipRows(options: {
9
+ data: TypedArray;
10
+ width: number;
11
+ height: number;
12
+ bytesPerPixel?: number;
13
+ temp?: Uint8Array;
14
+ }): void;
15
+ export declare function scalePixels(options: {
16
+ data: TypedArray;
17
+ width: number;
18
+ height: number;
19
+ }): {
20
+ data: Uint8Array;
21
+ width: number;
22
+ height: number;
23
+ };
24
+ //# sourceMappingURL=pixel-data-utils.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,41 @@
1
+ export function flipRows(options) {
2
+ const {
3
+ data,
4
+ width,
5
+ height,
6
+ bytesPerPixel = 4,
7
+ temp
8
+ } = options;
9
+ const bytesPerRow = width * bytesPerPixel;
10
+ const tempBuffer = temp || new Uint8Array(bytesPerRow);
11
+ for (let y = 0; y < height / 2; ++y) {
12
+ const topOffset = y * bytesPerRow;
13
+ const bottomOffset = (height - y - 1) * bytesPerRow;
14
+ tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));
15
+ data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);
16
+ data.set(tempBuffer, bottomOffset);
17
+ }
18
+ }
19
+ export function scalePixels(options) {
20
+ const {
21
+ data,
22
+ width,
23
+ height
24
+ } = options;
25
+ const newWidth = Math.round(width / 2);
26
+ const newHeight = Math.round(height / 2);
27
+ const newData = new Uint8Array(newWidth * newHeight * 4);
28
+ for (let y = 0; y < newHeight; y++) {
29
+ for (let x = 0; x < newWidth; x++) {
30
+ for (let c = 0; c < 4; c++) {
31
+ newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];
32
+ }
33
+ }
34
+ }
35
+ return {
36
+ data: newData,
37
+ width: newWidth,
38
+ height: newHeight
39
+ };
40
+ }
41
+ //# sourceMappingURL=pixel-data-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixel-data-utils.js","names":["flipRows","options","data","width","height","bytesPerPixel","temp","bytesPerRow","tempBuffer","Uint8Array","y","topOffset","bottomOffset","set","subarray","copyWithin","scalePixels","newWidth","Math","round","newHeight","newData","x","c"],"sources":["../../src/debug/pixel-data-utils.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray} from '@luma.gl/core';\n\n/**\n * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)\n * https: *stackoverflow.com/questions/41969562/\n * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels\n * @param param0\n */\nexport function flipRows(options: {\n data: TypedArray;\n width: number;\n height: number;\n bytesPerPixel?: number;\n temp?: Uint8Array;\n}): void {\n const {data, width, height, bytesPerPixel = 4, temp} = options;\n const bytesPerRow = width * bytesPerPixel;\n\n // make a temp buffer to hold one row\n const tempBuffer = temp || new Uint8Array(bytesPerRow);\n for (let y = 0; y < height / 2; ++y) {\n const topOffset = y * bytesPerRow;\n const bottomOffset = (height - y - 1) * bytesPerRow;\n // make copy of a row on the top half\n tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));\n // copy a row from the bottom half to the top\n data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);\n // copy the copy of the top half row to the bottom half\n data.set(tempBuffer, bottomOffset);\n }\n}\n\nexport function scalePixels(options: {\n data: TypedArray;\n width: number;\n height: number;\n}): {\n data: Uint8Array;\n width: number;\n height: number;\n} {\n const {data, width, height} = options;\n const newWidth = Math.round(width / 2);\n const newHeight = Math.round(height / 2);\n const newData = new Uint8Array(newWidth * newHeight * 4);\n for (let y = 0; y < newHeight; y++) {\n for (let x = 0; x < newWidth; x++) {\n for (let c = 0; c < 4; c++) {\n newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];\n }\n }\n }\n return {data: newData, width: newWidth, height: newHeight};\n}\n"],"mappings":"AAWA,OAAO,SAASA,QAAQA,CAACC,OAMxB,EAAQ;EACP,MAAM;IAACC,IAAI;IAAEC,KAAK;IAAEC,MAAM;IAAEC,aAAa,GAAG,CAAC;IAAEC;EAAI,CAAC,GAAGL,OAAO;EAC9D,MAAMM,WAAW,GAAGJ,KAAK,GAAGE,aAAa;EAGzC,MAAMG,UAAU,GAAGF,IAAI,IAAI,IAAIG,UAAU,CAACF,WAAW,CAAC;EACtD,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,MAAM,GAAG,CAAC,EAAE,EAAEM,CAAC,EAAE;IACnC,MAAMC,SAAS,GAAGD,CAAC,GAAGH,WAAW;IACjC,MAAMK,YAAY,GAAG,CAACR,MAAM,GAAGM,CAAC,GAAG,CAAC,IAAIH,WAAW;IAEnDC,UAAU,CAACK,GAAG,CAACX,IAAI,CAACY,QAAQ,CAACH,SAAS,EAAEA,SAAS,GAAGJ,WAAW,CAAC,CAAC;IAEjEL,IAAI,CAACa,UAAU,CAACJ,SAAS,EAAEC,YAAY,EAAEA,YAAY,GAAGL,WAAW,CAAC;IAEpEL,IAAI,CAACW,GAAG,CAACL,UAAU,EAAEI,YAAY,CAAC;EACpC;AACF;AAEA,OAAO,SAASI,WAAWA,CAACf,OAI3B,EAIC;EACA,MAAM;IAACC,IAAI;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGH,OAAO;EACrC,MAAMgB,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAAChB,KAAK,GAAG,CAAC,CAAC;EACtC,MAAMiB,SAAS,GAAGF,IAAI,CAACC,KAAK,CAACf,MAAM,GAAG,CAAC,CAAC;EACxC,MAAMiB,OAAO,GAAG,IAAIZ,UAAU,CAACQ,QAAQ,GAAGG,SAAS,GAAG,CAAC,CAAC;EACxD,KAAK,IAAIV,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGU,SAAS,EAAEV,CAAC,EAAE,EAAE;IAClC,KAAK,IAAIY,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,QAAQ,EAAEK,CAAC,EAAE,EAAE;MACjC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;QAC1BF,OAAO,CAAC,CAACX,CAAC,GAAGO,QAAQ,GAAGK,CAAC,IAAI,CAAC,GAAGC,CAAC,CAAC,GAAGrB,IAAI,CAAC,CAACQ,CAAC,GAAG,CAAC,GAAGP,KAAK,GAAGmB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAGC,CAAC,CAAC;MAC7E;IACF;EACF;EACA,OAAO;IAACrB,IAAI,EAAEmB,OAAO;IAAElB,KAAK,EAAEc,QAAQ;IAAEb,MAAM,EAAEgB;EAAS,CAAC;AAC5D"}