@luma.gl/core 9.0.17 → 9.1.0-alpha.10

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 (248) hide show
  1. package/dist/adapter/adapter.d.ts +11 -0
  2. package/dist/adapter/adapter.d.ts.map +1 -0
  3. package/dist/adapter/adapter.js +8 -0
  4. package/dist/adapter/canvas-context.d.ts +5 -0
  5. package/dist/adapter/canvas-context.d.ts.map +1 -1
  6. package/dist/adapter/device.d.ts +23 -11
  7. package/dist/adapter/device.d.ts.map +1 -1
  8. package/dist/adapter/device.js +22 -20
  9. package/dist/adapter/luma.d.ts +70 -0
  10. package/dist/adapter/luma.d.ts.map +1 -0
  11. package/dist/adapter/luma.js +159 -0
  12. package/dist/adapter/resources/buffer.js +5 -5
  13. package/dist/adapter/resources/compute-pipeline.d.ts +2 -0
  14. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  15. package/dist/adapter/resources/compute-pipeline.js +3 -0
  16. package/dist/adapter/resources/external-texture.d.ts +1 -1
  17. package/dist/adapter/resources/external-texture.d.ts.map +1 -1
  18. package/dist/adapter/resources/external-texture.js +1 -1
  19. package/dist/adapter/resources/framebuffer.d.ts +3 -3
  20. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  21. package/dist/adapter/resources/framebuffer.js +2 -83
  22. package/dist/adapter/resources/render-pass.d.ts +2 -2
  23. package/dist/adapter/resources/render-pass.d.ts.map +1 -1
  24. package/dist/adapter/resources/render-pipeline.d.ts +2 -5
  25. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  26. package/dist/adapter/resources/resource.d.ts +3 -3
  27. package/dist/adapter/resources/resource.d.ts.map +1 -1
  28. package/dist/adapter/resources/resource.js +1 -1
  29. package/dist/adapter/resources/shader.d.ts +5 -2
  30. package/dist/adapter/resources/shader.d.ts.map +1 -1
  31. package/dist/adapter/resources/shader.js +15 -9
  32. package/dist/adapter/resources/texture-view.d.ts +1 -1
  33. package/dist/adapter/resources/texture-view.d.ts.map +1 -1
  34. package/dist/adapter/resources/texture.d.ts +144 -47
  35. package/dist/adapter/resources/texture.d.ts.map +1 -1
  36. package/dist/adapter/resources/texture.js +120 -12
  37. package/dist/adapter/resources/transform-feedback.d.ts +1 -1
  38. package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
  39. package/dist/adapter/resources/vertex-array.d.ts +1 -1
  40. package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
  41. package/dist/adapter/resources/vertex-array.js +6 -2
  42. package/dist/adapter/types/{types.d.ts → attachments.d.ts} +7 -17
  43. package/dist/adapter/types/attachments.d.ts.map +1 -0
  44. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  45. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  46. package/dist/adapter/types/compiler-message.d.ts.map +1 -0
  47. package/dist/adapter/types/parameters.d.ts +4 -6
  48. package/dist/adapter/types/parameters.d.ts.map +1 -1
  49. package/dist/adapter/types/parameters.js +1 -0
  50. package/dist/adapter/types/shader-layout.d.ts +23 -3
  51. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  52. package/dist/adapter/types/uniforms.d.ts +4 -0
  53. package/dist/adapter/types/uniforms.d.ts.map +1 -0
  54. package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.d.ts +1 -1
  55. package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -0
  56. package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.d.ts +4 -11
  57. package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -0
  58. package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.js +10 -30
  59. package/dist/adapter-utils/is-uniform-value.d.ts +3 -0
  60. package/dist/adapter-utils/is-uniform-value.d.ts.map +1 -0
  61. package/dist/adapter-utils/is-uniform-value.js +7 -0
  62. package/dist/dist.dev.js +635 -821
  63. package/dist/dist.min.js +6 -6
  64. package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.d.ts +3 -3
  65. package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +1 -0
  66. package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.d.ts +1 -1
  67. package/dist/gpu-type-utils/decode-data-type.d.ts.map +1 -0
  68. package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.d.ts +1 -1
  69. package/dist/gpu-type-utils/decode-shader-types.d.ts.map +1 -0
  70. package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.js +0 -2
  71. package/dist/gpu-type-utils/decode-texture-format.d.ts +43 -0
  72. package/dist/gpu-type-utils/decode-texture-format.d.ts.map +1 -0
  73. package/dist/{adapter/type-utils → gpu-type-utils}/decode-texture-format.js +67 -31
  74. package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.d.ts +1 -1
  75. package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +1 -0
  76. package/dist/gpu-type-utils/shader-types.d.ts.map +1 -0
  77. package/dist/{adapter/types → gpu-type-utils}/texture-formats.d.ts +3 -5
  78. package/dist/gpu-type-utils/texture-formats.d.ts.map +1 -0
  79. package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.d.ts +2 -2
  80. package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +1 -0
  81. package/dist/gpu-type-utils/vertex-formats.d.ts.map +1 -0
  82. package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.d.ts +1 -1
  83. package/dist/gpu-type-utils/wgsl-utils.d.ts.map +1 -0
  84. package/dist/index.cjs +396 -567
  85. package/dist/index.cjs.map +4 -4
  86. package/dist/index.d.ts +28 -44
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +19 -37
  89. package/dist/{lib/uniforms → portable}/uniform-block.d.ts +3 -3
  90. package/dist/portable/uniform-block.d.ts.map +1 -0
  91. package/dist/{lib/uniforms → portable}/uniform-block.js +2 -2
  92. package/dist/{lib/uniforms → portable}/uniform-buffer-layout.d.ts +2 -2
  93. package/dist/portable/uniform-buffer-layout.d.ts.map +1 -0
  94. package/dist/{lib/uniforms → portable}/uniform-buffer-layout.js +6 -7
  95. package/dist/{lib/uniforms → portable}/uniform-store.d.ts +9 -4
  96. package/dist/portable/uniform-store.d.ts.map +1 -0
  97. package/dist/{lib/uniforms → portable}/uniform-store.js +11 -9
  98. package/dist/types.d.ts +0 -10
  99. package/dist/types.d.ts.map +1 -1
  100. package/dist/utils/array-equal.d.ts.map +1 -1
  101. package/dist/utils/array-equal.js +6 -7
  102. package/dist/utils/array-utils-flat.d.ts +1 -7
  103. package/dist/utils/array-utils-flat.d.ts.map +1 -1
  104. package/dist/utils/array-utils-flat.js +0 -23
  105. package/dist/utils/is-array.d.ts +3 -3
  106. package/dist/utils/is-array.d.ts.map +1 -1
  107. package/dist/utils/is-array.js +2 -2
  108. package/dist/utils/uid.d.ts +7 -0
  109. package/dist/utils/uid.d.ts.map +1 -0
  110. package/dist/utils/{utils.js → uid.js} +0 -11
  111. package/package.json +5 -5
  112. package/src/adapter/adapter.ts +16 -0
  113. package/src/adapter/canvas-context.ts +6 -0
  114. package/src/adapter/device.ts +52 -36
  115. package/src/adapter/luma.ts +219 -0
  116. package/src/adapter/resources/buffer.ts +5 -5
  117. package/src/adapter/resources/command-encoder.ts +1 -1
  118. package/src/adapter/resources/compute-pass.ts +3 -3
  119. package/src/adapter/resources/compute-pipeline.ts +6 -3
  120. package/src/adapter/resources/external-texture.ts +2 -2
  121. package/src/adapter/resources/framebuffer.ts +5 -92
  122. package/src/adapter/resources/query-set.ts +2 -2
  123. package/src/adapter/resources/render-pass.ts +11 -7
  124. package/src/adapter/resources/render-pipeline.ts +3 -6
  125. package/src/adapter/resources/resource.ts +7 -7
  126. package/src/adapter/resources/shader.ts +18 -11
  127. package/src/adapter/resources/texture-view.ts +5 -5
  128. package/src/adapter/resources/texture.ts +285 -76
  129. package/src/adapter/resources/transform-feedback.ts +1 -1
  130. package/src/adapter/resources/vertex-array.ts +7 -3
  131. package/src/adapter/types/{types.ts → attachments.ts} +10 -18
  132. package/src/adapter/types/buffer-layout.ts +1 -1
  133. package/src/adapter/types/parameters.ts +14 -14
  134. package/src/adapter/types/shader-layout.ts +31 -29
  135. package/src/adapter/types/uniforms.ts +10 -0
  136. package/src/{lib/compiler-log → adapter-utils}/format-compiler-log.ts +1 -1
  137. package/src/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.ts +18 -42
  138. package/src/adapter-utils/is-uniform-value.ts +10 -0
  139. package/src/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.ts +3 -3
  140. package/src/{adapter/type-utils → gpu-type-utils}/decode-data-type.ts +1 -1
  141. package/src/{adapter/type-utils → gpu-type-utils}/decode-shader-types.ts +1 -3
  142. package/src/{adapter/type-utils → gpu-type-utils}/decode-texture-format.ts +99 -39
  143. package/src/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.ts +1 -1
  144. package/src/{adapter/types → gpu-type-utils}/texture-formats.ts +3 -14
  145. package/src/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.ts +2 -2
  146. package/src/{adapter/type-utils → gpu-type-utils}/wgsl-utils.ts +1 -1
  147. package/src/index.ts +67 -83
  148. package/src/{lib/uniforms → portable}/uniform-block.ts +5 -5
  149. package/src/{lib/uniforms → portable}/uniform-buffer-layout.ts +9 -9
  150. package/src/{lib/uniforms → portable}/uniform-store.ts +20 -12
  151. package/src/types.ts +0 -12
  152. package/src/utils/array-equal.ts +6 -7
  153. package/src/utils/array-utils-flat.ts +1 -31
  154. package/src/utils/is-array.ts +5 -5
  155. package/src/utils/{utils.ts → uid.ts} +0 -12
  156. package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +0 -1
  157. package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +0 -1
  158. package/dist/adapter/type-utils/decode-data-type.d.ts.map +0 -1
  159. package/dist/adapter/type-utils/decode-shader-types.d.ts.map +0 -1
  160. package/dist/adapter/type-utils/decode-texture-format.d.ts +0 -23
  161. package/dist/adapter/type-utils/decode-texture-format.d.ts.map +0 -1
  162. package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +0 -1
  163. package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +0 -1
  164. package/dist/adapter/type-utils/wgsl-utils.d.ts.map +0 -1
  165. package/dist/adapter/types/accessor.d.ts +0 -23
  166. package/dist/adapter/types/accessor.d.ts.map +0 -1
  167. package/dist/adapter/types/shader-types.d.ts.map +0 -1
  168. package/dist/adapter/types/texture-formats.d.ts.map +0 -1
  169. package/dist/adapter/types/types.d.ts.map +0 -1
  170. package/dist/adapter/types/vertex-formats.d.ts.map +0 -1
  171. package/dist/init.d.ts +0 -5
  172. package/dist/init.d.ts.map +0 -1
  173. package/dist/init.js +0 -37
  174. package/dist/lib/compiler-log/compiler-message.d.ts.map +0 -1
  175. package/dist/lib/compiler-log/format-compiler-log.d.ts.map +0 -1
  176. package/dist/lib/compiler-log/get-shader-info.d.ts +0 -9
  177. package/dist/lib/compiler-log/get-shader-info.d.ts.map +0 -1
  178. package/dist/lib/compiler-log/get-shader-info.js +0 -29
  179. package/dist/lib/luma.d.ts +0 -38
  180. package/dist/lib/luma.d.ts.map +0 -1
  181. package/dist/lib/luma.js +0 -141
  182. package/dist/lib/uniforms/uniform-block.d.ts.map +0 -1
  183. package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +0 -1
  184. package/dist/lib/uniforms/uniform-store.d.ts.map +0 -1
  185. package/dist/lib/uniforms/uniform.d.ts +0 -10
  186. package/dist/lib/uniforms/uniform.d.ts.map +0 -1
  187. package/dist/lib/uniforms/uniform.js +0 -20
  188. package/dist/utils/assert.d.ts +0 -2
  189. package/dist/utils/assert.d.ts.map +0 -1
  190. package/dist/utils/assert.js +0 -10
  191. package/dist/utils/cast.d.ts +0 -3
  192. package/dist/utils/cast.d.ts.map +0 -1
  193. package/dist/utils/cast.js +0 -7
  194. package/dist/utils/check-props.d.ts +0 -7
  195. package/dist/utils/check-props.d.ts.map +0 -1
  196. package/dist/utils/check-props.js +0 -36
  197. package/dist/utils/deep-equal.d.ts +0 -9
  198. package/dist/utils/deep-equal.d.ts.map +0 -1
  199. package/dist/utils/deep-equal.js +0 -50
  200. package/dist/utils/format-value.d.ts +0 -7
  201. package/dist/utils/format-value.d.ts.map +0 -1
  202. package/dist/utils/format-value.js +0 -39
  203. package/dist/utils/load-file.d.ts +0 -35
  204. package/dist/utils/load-file.d.ts.map +0 -1
  205. package/dist/utils/load-file.js +0 -74
  206. package/dist/utils/random.d.ts +0 -5
  207. package/dist/utils/random.d.ts.map +0 -1
  208. package/dist/utils/random.js +0 -18
  209. package/dist/utils/request-animation-frame.d.ts +0 -3
  210. package/dist/utils/request-animation-frame.d.ts.map +0 -1
  211. package/dist/utils/request-animation-frame.js +0 -16
  212. package/dist/utils/stub-methods.d.ts +0 -2
  213. package/dist/utils/stub-methods.d.ts.map +0 -1
  214. package/dist/utils/stub-methods.js +0 -19
  215. package/dist/utils/utils.d.ts +0 -9
  216. package/dist/utils/utils.d.ts.map +0 -1
  217. package/src/adapter/types/accessor.ts +0 -37
  218. package/src/init.ts +0 -53
  219. package/src/lib/compiler-log/get-shader-info.ts +0 -42
  220. package/src/lib/luma.ts +0 -190
  221. package/src/lib/uniforms/uniform.ts +0 -31
  222. package/src/utils/assert.ts +0 -11
  223. package/src/utils/cast.ts +0 -8
  224. package/src/utils/check-props.ts +0 -82
  225. package/src/utils/deep-equal.ts +0 -51
  226. package/src/utils/format-value.ts +0 -47
  227. package/src/utils/load-file.ts +0 -91
  228. package/src/utils/random.ts +0 -21
  229. package/src/utils/request-animation-frame.ts +0 -19
  230. package/src/utils/stub-methods.ts +0 -29
  231. /package/dist/adapter/types/{accessor.js → attachments.js} +0 -0
  232. /package/dist/{lib/compiler-log → adapter/types}/compiler-message.d.ts +0 -0
  233. /package/dist/{lib/compiler-log → adapter/types}/compiler-message.js +0 -0
  234. /package/dist/adapter/types/{shader-types.js → uniforms.js} +0 -0
  235. /package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.js +0 -0
  236. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.js +0 -0
  237. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.js +0 -0
  238. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.js +0 -0
  239. /package/dist/{adapter/types → gpu-type-utils}/shader-types.d.ts +0 -0
  240. /package/dist/{adapter/types/texture-formats.js → gpu-type-utils/shader-types.js} +0 -0
  241. /package/dist/{adapter/types/types.js → gpu-type-utils/texture-formats.js} +0 -0
  242. /package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.js +0 -0
  243. /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.d.ts +0 -0
  244. /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.js +0 -0
  245. /package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.js +0 -0
  246. /package/src/{lib/compiler-log → adapter/types}/compiler-message.ts +0 -0
  247. /package/src/{adapter/types → gpu-type-utils}/shader-types.ts +0 -0
  248. /package/src/{adapter/types → gpu-type-utils}/vertex-formats.ts +0 -0
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ var __publicField = (obj, key, value) => {
25
25
  // dist/index.js
26
26
  var dist_exports = {};
27
27
  __export(dist_exports, {
28
+ Adapter: () => Adapter,
28
29
  Buffer: () => Buffer2,
29
30
  CanvasContext: () => CanvasContext,
30
31
  CommandBuffer: () => CommandBuffer,
@@ -42,62 +43,27 @@ __export(dist_exports, {
42
43
  Resource: () => Resource,
43
44
  Sampler: () => Sampler,
44
45
  Shader: () => Shader,
45
- StatsManager: () => StatsManager,
46
46
  Texture: () => Texture,
47
47
  TextureView: () => TextureView,
48
48
  TransformFeedback: () => TransformFeedback,
49
49
  UniformBlock: () => UniformBlock,
50
50
  UniformBufferLayout: () => UniformBufferLayout,
51
51
  UniformStore: () => UniformStore,
52
- VERSION: () => VERSION,
53
52
  VertexArray: () => VertexArray,
54
- assert: () => assert,
55
- cancelAnimationFrame: () => cancelAnimationFrame,
56
- cast: () => cast,
57
- checkProps: () => checkProps,
58
53
  decodeShaderAttributeType: () => decodeShaderAttributeType,
59
54
  decodeShaderUniformType: () => decodeShaderUniformType,
60
55
  decodeTextureFormat: () => decodeTextureFormat,
61
56
  decodeVertexFormat: () => decodeVertexFormat,
62
- deepEqual: () => deepEqual,
63
- fillArray: () => fillArray,
64
- formatCompilerLog: () => formatCompilerLog,
65
- formatValue: () => formatValue,
66
57
  getAttributeInfosFromLayouts: () => getAttributeInfosFromLayouts,
67
58
  getDataTypeFromTypedArray: () => getDataTypeFromTypedArray,
68
59
  getScratchArray: () => getScratchArray,
69
- getScratchArrayBuffer: () => getScratchArrayBuffer,
70
60
  getTypedArrayFromDataType: () => getTypedArrayFromDataType,
71
61
  getVertexFormatFromAttribute: () => getVertexFormatFromAttribute,
72
- glsl: () => glsl,
73
- isNumberArray: () => isNumberArray,
74
- isObjectEmpty: () => isObjectEmpty,
75
- isTypedArray: () => isTypedArray,
76
- isUniformValue: () => isUniformValue,
77
- loadFile: () => loadFile,
78
- loadImage: () => loadImage,
79
- loadImageBitmap: () => loadImageBitmap,
80
- loadScript: () => loadScript,
81
62
  log: () => log,
82
- luma: () => luma,
83
- makeRandomNumberGenerator: () => makeRandomNumberGenerator,
84
- mergeShaderLayout: () => mergeShaderLayout,
85
- random: () => random,
86
- requestAnimationFrame: () => requestAnimationFrame,
87
- setPathPrefix: () => setPathPrefix,
88
- splitUniformsAndBindings: () => splitUniformsAndBindings,
89
- stubRemovedMethods: () => stubRemovedMethods,
90
- uid: () => uid
63
+ luma: () => luma
91
64
  });
92
65
  module.exports = __toCommonJS(dist_exports);
93
66
 
94
- // dist/init.js
95
- var import_env = require("@probe.gl/env");
96
-
97
- // dist/utils/log.js
98
- var import_log = require("@probe.gl/log");
99
- var log = new import_log.Log({ id: "luma.gl" });
100
-
101
67
  // dist/utils/stats-manager.js
102
68
  var import_stats = require("@probe.gl/stats");
103
69
  var StatsManager = class {
@@ -114,56 +80,17 @@ var StatsManager = class {
114
80
  };
115
81
  var lumaStats = new StatsManager();
116
82
 
117
- // dist/init.js
118
- function initializeLuma() {
119
- const VERSION2 = true ? "9.0.17" : "running from source";
120
- const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
121
- if (globalThis.luma && globalThis.luma.VERSION !== VERSION2) {
122
- throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION2}`);
123
- }
124
- if (!globalThis.luma) {
125
- if ((0, import_env.isBrowser)()) {
126
- log.log(1, `${VERSION2} - ${STARTUP_MESSAGE}`)();
127
- }
128
- globalThis.luma = globalThis.luma || {
129
- VERSION: VERSION2,
130
- version: VERSION2,
131
- log,
132
- // A global stats object that various components can add information to
133
- // E.g. see webgl/resource.js
134
- stats: lumaStats
135
- };
136
- }
137
- return VERSION2;
138
- }
139
- var VERSION = initializeLuma();
140
-
141
- // dist/utils/is-array.js
142
- function isTypedArray(value) {
143
- return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
144
- }
145
- function isNumberArray(value) {
146
- if (Array.isArray(value)) {
147
- return value.length === 0 || typeof value[0] === "number" ? value : null;
148
- }
149
- return isTypedArray(value);
150
- }
83
+ // dist/utils/log.js
84
+ var import_log = require("@probe.gl/log");
85
+ var log = new import_log.Log({ id: "luma.gl" });
151
86
 
152
- // dist/utils/utils.js
87
+ // dist/utils/uid.js
153
88
  var uidCounters = {};
154
89
  function uid(id = "id") {
155
90
  uidCounters[id] = uidCounters[id] || 1;
156
91
  const count = uidCounters[id]++;
157
92
  return `${id}-${count}`;
158
93
  }
159
- function isObjectEmpty(obj) {
160
- let isEmpty = true;
161
- for (const key in obj) {
162
- isEmpty = false;
163
- break;
164
- }
165
- return isEmpty;
166
- }
167
94
 
168
95
  // dist/adapter/resources/resource.js
169
96
  var Resource = class {
@@ -328,14 +255,14 @@ var _Buffer = class extends Resource {
328
255
  debugData = new ArrayBuffer(0);
329
256
  /** This doesn't handle partial non-zero offset updates correctly */
330
257
  _setDebugData(data, byteOffset, byteLength) {
331
- const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
258
+ const arrayBuffer2 = ArrayBuffer.isView(data) ? data.buffer : data;
332
259
  const debugDataLength = Math.min(data ? data.byteLength : byteLength, _Buffer.DEBUG_DATA_MAX_LENGTH);
333
- if (data === null) {
260
+ if (arrayBuffer2 === null) {
334
261
  this.debugData = new ArrayBuffer(debugDataLength);
335
- } else if (byteOffset === 0 && byteLength === data.byteLength) {
336
- this.debugData = buffer.slice(0, debugDataLength);
262
+ } else if (byteOffset === 0 && byteLength === arrayBuffer2.byteLength) {
263
+ this.debugData = arrayBuffer2.slice(0, debugDataLength);
337
264
  } else {
338
- this.debugData = buffer.slice(byteOffset, byteOffset + debugDataLength);
265
+ this.debugData = arrayBuffer2.slice(byteOffset, byteOffset + debugDataLength);
339
266
  }
340
267
  }
341
268
  };
@@ -369,7 +296,7 @@ __publicField(Buffer2, "QUERY_RESOLVE", 512);
369
296
  /** Max amount of debug data saved. Two vec4's */
370
297
  __publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
371
298
 
372
- // dist/adapter/type-utils/decode-data-type.js
299
+ // dist/gpu-type-utils/decode-data-type.js
373
300
  function decodeVertexType(type) {
374
301
  const dataType = TYPE_MAP[type];
375
302
  const bytes = getDataTypeBytes(dataType);
@@ -413,7 +340,7 @@ var TYPE_SIZES = {
413
340
  sint32: 4
414
341
  };
415
342
 
416
- // dist/adapter/type-utils/decode-texture-format.js
343
+ // dist/gpu-type-utils/decode-texture-format.js
417
344
  var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
418
345
  "bc1",
419
346
  "bc2",
@@ -429,64 +356,98 @@ var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
429
356
  "astc",
430
357
  "pvrtc"
431
358
  ];
432
- var REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
359
+ var REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
433
360
  function isTextureFormatCompressed(textureFormat) {
434
361
  return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => textureFormat.startsWith(prefix));
435
362
  }
436
363
  function decodeTextureFormat(format) {
437
364
  const matches = REGEX.exec(format);
438
365
  if (matches) {
439
- const [, format2, length, type, srgb, suffix] = matches;
440
- if (format2) {
366
+ const [, channels, length, type, srgb, suffix] = matches;
367
+ if (format) {
441
368
  const dataType = `${type}${length}`;
442
369
  const decodedType = decodeVertexType(dataType);
443
- return {
444
- format: format2,
445
- components: format2.length,
446
- // dataType - overwritten by decodedType
447
- srgb: srgb === "-srgb",
448
- unsized: suffix === "-unsized",
449
- webgl: suffix === "-webgl",
450
- ...decodedType
370
+ const info = {
371
+ channels,
372
+ components: channels.length,
373
+ bitsPerChannel: decodedType.byteLength * 8,
374
+ bytesPerPixel: decodedType.byteLength * channels.length,
375
+ dataType: decodedType.dataType,
376
+ integer: decodedType.integer,
377
+ signed: decodedType.signed,
378
+ normalized: decodedType.normalized
451
379
  };
380
+ if (suffix === "-webgl") {
381
+ info.webgl = true;
382
+ }
383
+ if (srgb === "-srgb") {
384
+ info.srgb = true;
385
+ }
386
+ return info;
452
387
  }
453
388
  }
454
389
  return decodeNonStandardFormat(format);
455
390
  }
456
391
  var EXCEPTIONS = {
457
392
  // Packed 16 bit formats
458
- "rgba4unorm-webgl": { format: "rgba", bpp: 2 },
459
- "rgb565unorm-webgl": { format: "rgb", bpp: 2 },
460
- "rgb5a1unorm-webgl": { format: "rgba", bbp: 2 },
393
+ "rgba4unorm-webgl": { channels: "rgba", bytesPerPixel: 2, packed: true },
394
+ "rgb565unorm-webgl": { channels: "rgb", bytesPerPixel: 2, packed: true },
395
+ "rgb5a1unorm-webgl": { channels: "rgba", bytesPerPixel: 2, packed: true },
461
396
  // Packed 32 bit formats
462
- rgb9e5ufloat: { format: "rgb", bbp: 4 },
463
- rg11b10ufloat: { format: "rgb", bbp: 4 },
464
- rgb10a2unorm: { format: "rgba", bbp: 4 },
465
- "rgb10a2uint-webgl": { format: "rgba", bbp: 4 },
397
+ rgb9e5ufloat: { channels: "rgb", bytesPerPixel: 4, packed: true },
398
+ rg11b10ufloat: { channels: "rgb", bytesPerPixel: 4, packed: true },
399
+ rgb10a2unorm: { channels: "rgba", bytesPerPixel: 4, packed: true },
400
+ "rgb10a2uint-webgl": { channels: "rgba", bytesPerPixel: 4, packed: true },
466
401
  // Depth/stencil
467
- stencil8: { components: 1, bpp: 1, a: "stencil" },
468
- depth16unorm: { components: 1, bpp: 2, a: "depth" },
469
- depth24plus: { components: 1, bpp: 3, a: "depth" },
470
- depth32float: { components: 1, bpp: 4, a: "depth" },
471
- "depth24plus-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
472
- // "depth24unorm-stencil8" feature
473
- "depth24unorm-stencil8": { components: 2, bpp: 4, a: "depth-stencil" },
402
+ stencil8: { components: 1, bytesPerPixel: 1, a: "stencil", dataType: "uint8" },
403
+ depth16unorm: { components: 1, bytesPerPixel: 2, a: "depth", dataType: "uint16" },
404
+ depth24plus: { components: 1, bytesPerPixel: 3, a: "depth", dataType: "uint32" },
405
+ depth32float: { components: 1, bytesPerPixel: 4, a: "depth", dataType: "float32" },
406
+ "depth24plus-stencil8": { components: 2, bytesPerPixel: 4, a: "depth-stencil", packed: true },
474
407
  // "depth32float-stencil8" feature
475
- "depth32float-stencil8": { components: 2, bpp: 4, a: "depth-stencil" }
408
+ "depth32float-stencil8": { components: 2, bytesPerPixel: 4, a: "depth-stencil", packed: true }
476
409
  };
477
410
  function decodeNonStandardFormat(format) {
478
411
  var _a;
412
+ if (isTextureFormatCompressed(format)) {
413
+ const info2 = {
414
+ channels: "rgb",
415
+ components: 3,
416
+ bytesPerPixel: 1,
417
+ srgb: false,
418
+ compressed: true
419
+ };
420
+ const blockSize = getCompressedTextureBlockSize(format);
421
+ if (blockSize) {
422
+ info2.blockWidth = blockSize.blockWidth;
423
+ info2.blockHeight = blockSize.blockHeight;
424
+ }
425
+ return info2;
426
+ }
479
427
  const data = EXCEPTIONS[format];
480
428
  if (!data) {
481
429
  throw new Error(`Unknown format ${format}`);
482
430
  }
483
- return {
484
- format: data.format || "",
485
- components: data.components || ((_a = data.format) == null ? void 0 : _a.length) || 1,
486
- byteLength: data.bpp || 1,
487
- srgb: false,
488
- unsized: false
431
+ const info = {
432
+ ...data,
433
+ channels: data.channels || "",
434
+ components: data.components || ((_a = data.channels) == null ? void 0 : _a.length) || 1,
435
+ bytesPerPixel: data.bytesPerPixel || 1,
436
+ srgb: false
489
437
  };
438
+ if (data.packed) {
439
+ info.packed = data.packed;
440
+ }
441
+ return info;
442
+ }
443
+ function getCompressedTextureBlockSize(format) {
444
+ const REGEX2 = /.*-(\d+)x(\d+)-.*/;
445
+ const matches = REGEX2.exec(format);
446
+ if (matches) {
447
+ const [, blockWidth, blockHeight] = matches;
448
+ return { blockWidth: Number(blockWidth), blockHeight: Number(blockHeight) };
449
+ }
450
+ return null;
490
451
  }
491
452
 
492
453
  // dist/adapter/device.js
@@ -503,7 +464,8 @@ var DeviceFeatures = class {
503
464
  yield* this.features;
504
465
  }
505
466
  has(feature) {
506
- return !this.disabledFeatures[feature] && this.features.has(feature);
467
+ var _a;
468
+ return !((_a = this.disabledFeatures) == null ? void 0 : _a[feature]) && this.features.has(feature);
507
469
  }
508
470
  };
509
471
  var _Device = class {
@@ -536,6 +498,10 @@ var _Device = class {
536
498
  loseDevice() {
537
499
  return false;
538
500
  }
501
+ /** Report error (normally for unhandled device errors) */
502
+ error(error) {
503
+ this.props.onError(error);
504
+ }
539
505
  /** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
540
506
  getCanvasContext() {
541
507
  if (!this.canvasContext) {
@@ -543,10 +509,8 @@ var _Device = class {
543
509
  }
544
510
  return this.canvasContext;
545
511
  }
512
+ // createTexture(data: Promise<TextureData>): Texture;
546
513
  createTexture(props) {
547
- if (props instanceof Promise || typeof props === "string") {
548
- props = { data: props };
549
- }
550
514
  return this._createTexture(props);
551
515
  }
552
516
  createCommandEncoder(props = {}) {
@@ -620,16 +584,9 @@ __publicField(Device, "defaultProps", {
620
584
  // width are height are only used by headless gl
621
585
  height: 600,
622
586
  requestMaxLimits: true,
623
- debug: Boolean(log.get("debug")),
624
- // Instrument context (at the expense of performance)
625
- spector: Boolean(log.get("spector") || log.get("spectorjs")),
626
- // Initialize the SpectorJS WebGL debugger
627
- break: [],
628
- // TODO - Change these after confirming things work as expected
629
- initalizeFeatures: true,
630
- disabledFeatures: {
631
- "compilation-status-async-webgl": true
632
- },
587
+ // Callbacks
588
+ onError: (error) => log.error(error.message),
589
+ gl: null,
633
590
  // alpha: undefined,
634
591
  // depth: undefined,
635
592
  // stencil: undefined,
@@ -637,134 +594,165 @@ __publicField(Device, "defaultProps", {
637
594
  // premultipliedAlpha: undefined,
638
595
  // preserveDrawingBuffer: undefined,
639
596
  // failIfMajorPerformanceCaveat: undefined
640
- gl: null,
641
- // Callbacks
642
- onError: (error) => log.error(error.message)
597
+ debug: Boolean(log.get("debug")),
598
+ // Instrument context (at the expense of performance)
599
+ break: log.get("break") || [],
600
+ // WebGL specific debugging
601
+ debugWithSpectorJS: void 0,
602
+ spectorUrl: void 0,
603
+ // TODO - Change these after confirming things work as expected
604
+ initalizeFeatures: true,
605
+ disabledFeatures: {
606
+ "compilation-status-async-webgl": true
607
+ },
608
+ _factoryDestroyPolicy: "unused"
643
609
  });
644
- __publicField(Device, "VERSION", VERSION);
645
610
 
646
- // dist/utils/assert.js
647
- function assert(condition, message) {
648
- if (!condition) {
649
- throw new Error(message || "luma.gl: assertion failed.");
611
+ // dist/adapter/luma.js
612
+ var STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
613
+ var ERROR_MESSAGE = "No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.";
614
+ var _Luma = class {
615
+ /** Global stats for all devices */
616
+ stats = lumaStats;
617
+ /**
618
+ * Global log
619
+ *
620
+ * Assign luma.log.level in console to control logging: \
621
+ * 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
622
+ * luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
623
+ */
624
+ log = log;
625
+ /** Version of luma.gl */
626
+ VERSION = (
627
+ // Version detection using build plugin
628
+ // @ts-expect-error no-undef
629
+ true ? "9.1.0-alpha.10" : "running from source"
630
+ );
631
+ spector;
632
+ preregisteredAdapters = /* @__PURE__ */ new Map();
633
+ constructor() {
634
+ if (globalThis.luma) {
635
+ if (globalThis.luma.VERSION !== this.VERSION) {
636
+ log.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)();
637
+ log.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)();
638
+ throw new Error(`luma.gl - multiple versions detected: see console log`);
639
+ }
640
+ log.error("This version of luma.gl has already been initialized")();
641
+ }
642
+ log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)();
643
+ globalThis.luma = this;
650
644
  }
651
- }
652
-
653
- // dist/lib/luma.js
654
- var deviceMap = /* @__PURE__ */ new Map();
655
- var _luma = class {
656
- static registerDevices(deviceClasses) {
657
- for (const deviceClass of deviceClasses) {
658
- assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
659
- deviceMap.set(deviceClass.type, deviceClass);
645
+ registerAdapters(adapters) {
646
+ for (const deviceClass of adapters) {
647
+ this.preregisteredAdapters.set(deviceClass.type, deviceClass);
660
648
  }
661
649
  }
662
- static getAvailableDevices() {
663
- return Array.from(deviceMap).map((Device2) => Device2.type);
650
+ /** Get type strings for supported Devices */
651
+ getSupportedAdapters(adapters = []) {
652
+ const adapterMap = this.getAdapterMap(adapters);
653
+ return Array.from(adapterMap).map(([, adapter]) => adapter).filter((adapter) => {
654
+ var _a;
655
+ return (_a = adapter.isSupported) == null ? void 0 : _a.call(adapter);
656
+ }).map((adapter) => adapter.type);
664
657
  }
665
- static getSupportedDevices() {
666
- return Array.from(deviceMap).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
658
+ /** Get type strings for best available Device */
659
+ getBestAvailableAdapter(adapters = []) {
660
+ var _a, _b, _c, _d;
661
+ const adapterMap = this.getAdapterMap(adapters);
662
+ if ((_b = (_a = adapterMap.get("webgpu")) == null ? void 0 : _a.isSupported) == null ? void 0 : _b.call(_a)) {
663
+ return "webgpu";
664
+ }
665
+ if ((_d = (_c = adapterMap.get("webgl")) == null ? void 0 : _c.isSupported) == null ? void 0 : _d.call(_c)) {
666
+ return "webgl";
667
+ }
668
+ return null;
667
669
  }
668
- static setDefaultDeviceProps(props) {
669
- Object.assign(Device.defaultProps, props);
670
+ setDefaultDeviceProps(props) {
671
+ Object.assign(_Luma.defaultProps, props);
672
+ }
673
+ /** Creates a device. Asynchronously. */
674
+ async createDevice(props = {}) {
675
+ var _a;
676
+ props = { ..._Luma.defaultProps, ...props };
677
+ const adapterMap = this.getAdapterMap(props.adapters);
678
+ let type = props.type || "";
679
+ if (type === "best-available") {
680
+ type = this.getBestAvailableAdapter(props.adapters) || type;
681
+ }
682
+ const adapters = this.getAdapterMap(props.adapters) || adapterMap;
683
+ const adapter = adapters.get(type);
684
+ const device = await ((_a = adapter == null ? void 0 : adapter.create) == null ? void 0 : _a.call(adapter, props));
685
+ if (device) {
686
+ return device;
687
+ }
688
+ throw new Error(ERROR_MESSAGE);
670
689
  }
671
690
  /** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
672
- static async attachDevice(props) {
673
- const devices = getDeviceMap(props.devices) || deviceMap;
691
+ async attachDevice(props) {
692
+ var _a;
693
+ const adapters = this.getAdapterMap(props.adapters);
694
+ let type = "";
674
695
  if (props.handle instanceof WebGL2RenderingContext) {
675
- const WebGLDevice = devices.get("webgl");
676
- if (WebGLDevice) {
677
- return await WebGLDevice.attach(props.handle);
678
- }
696
+ type = "webgl";
679
697
  }
680
698
  if (props.handle === null) {
681
- const UnknownDevice = devices.get("unknown");
682
- if (UnknownDevice) {
683
- return await UnknownDevice.attach(null);
684
- }
699
+ type = "unknown";
685
700
  }
686
- throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
701
+ const adapter = adapters.get(type);
702
+ const device = await ((_a = adapter == null ? void 0 : adapter.attach) == null ? void 0 : _a.call(adapter, null));
703
+ if (device) {
704
+ return device;
705
+ }
706
+ throw new Error(ERROR_MESSAGE);
687
707
  }
688
- /** Creates a device. Asynchronously. */
689
- static async createDevice(props = {}) {
690
- var _a, _b;
691
- props = { ..._luma.defaultProps, ...props };
692
- if (props.gl) {
693
- props.type = "webgl";
694
- }
695
- const devices = getDeviceMap(props.devices) || deviceMap;
696
- switch (props.type) {
697
- case "webgpu":
698
- let WebGPUDevice = devices.get("webgpu");
699
- if (WebGPUDevice) {
700
- return await WebGPUDevice.create(props);
701
- }
702
- break;
703
- case "webgl":
704
- let WebGLDevice = devices.get("webgl");
705
- if (WebGLDevice) {
706
- return await WebGLDevice.create(props);
707
- }
708
- break;
709
- case "unknown":
710
- const UnknownDevice = devices.get("unknown");
711
- if (UnknownDevice) {
712
- return await UnknownDevice.create(props);
713
- }
714
- break;
715
- case "best-available":
716
- WebGPUDevice = devices.get("webgpu");
717
- if ((_a = WebGPUDevice == null ? void 0 : WebGPUDevice.isSupported) == null ? void 0 : _a.call(WebGPUDevice)) {
718
- return await WebGPUDevice.create(props);
719
- }
720
- WebGLDevice = devices.get("webgl");
721
- if ((_b = WebGLDevice == null ? void 0 : WebGLDevice.isSupported) == null ? void 0 : _b.call(WebGLDevice)) {
722
- return await WebGLDevice.create(props);
723
- }
724
- break;
708
+ /**
709
+ * Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility.
710
+ * Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts.
711
+ */
712
+ enforceWebGL2(enforce = true, adapters = []) {
713
+ var _a;
714
+ const adapterMap = this.getAdapterMap(adapters);
715
+ const webgl2Adapter = adapterMap.get("webgl");
716
+ if (!webgl2Adapter) {
717
+ log.warn("enforceWebGL2: webgl adapter not found")();
725
718
  }
726
- throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
719
+ (_a = webgl2Adapter == null ? void 0 : webgl2Adapter.enforceWebGL2) == null ? void 0 : _a.call(webgl2Adapter, enforce);
727
720
  }
728
- static enforceWebGL2(enforce = true) {
729
- const prototype = HTMLCanvasElement.prototype;
730
- if (!enforce && prototype.originalGetContext) {
731
- prototype.getContext = prototype.originalGetContext;
732
- prototype.originalGetContext = void 0;
733
- return;
721
+ /** Convert a list of adapters to a map */
722
+ getAdapterMap(adapters = []) {
723
+ const map = new Map(this.preregisteredAdapters);
724
+ for (const adapter of adapters) {
725
+ map.set(adapter.type, adapter);
734
726
  }
735
- prototype.originalGetContext = prototype.getContext;
736
- prototype.getContext = function(contextId, options) {
737
- if (contextId === "webgl" || contextId === "experimental-webgl") {
738
- return this.originalGetContext("webgl2", options);
727
+ return map;
728
+ }
729
+ // DEPRECATED
730
+ /** @deprecated Use registerAdapters */
731
+ registerDevices(deviceClasses) {
732
+ log.warn("luma.registerDevices() is deprecated, use luma.registerAdapters() instead");
733
+ for (const deviceClass of deviceClasses) {
734
+ const adapter = deviceClass.adapter;
735
+ if (adapter) {
736
+ this.preregisteredAdapters.set(adapter.type, adapter);
739
737
  }
740
- return this.originalGetContext(contextId, options);
741
- };
738
+ }
742
739
  }
743
740
  };
744
- var luma = _luma;
745
- __publicField(luma, "defaultProps", {
741
+ var Luma = _Luma;
742
+ __publicField(Luma, "defaultProps", {
746
743
  ...Device.defaultProps,
747
744
  type: "best-available",
748
- devices: void 0
745
+ adapters: void 0
749
746
  });
750
- /** Global stats for all devices */
751
- __publicField(luma, "stats", lumaStats);
752
- /** Global log */
753
- __publicField(luma, "log", log);
754
- function getDeviceMap(deviceClasses) {
755
- if (!deviceClasses || (deviceClasses == null ? void 0 : deviceClasses.length) === 0) {
756
- return null;
757
- }
758
- const map = /* @__PURE__ */ new Map();
759
- for (const deviceClass of deviceClasses) {
760
- map.set(deviceClass.type, deviceClass);
761
- }
762
- return map;
763
- }
747
+ var luma = new Luma();
748
+
749
+ // dist/adapter/adapter.js
750
+ var Adapter = class {
751
+ };
764
752
 
765
753
  // dist/adapter/canvas-context.js
766
- var import_env2 = require("@probe.gl/env");
767
- var isPage = (0, import_env2.isBrowser)() && typeof document !== "undefined";
754
+ var import_env = require("@probe.gl/env");
755
+ var isPage = (0, import_env.isBrowser)() && typeof document !== "undefined";
768
756
  var isPageLoaded = () => isPage && document.readyState === "complete";
769
757
  var DEFAULT_CANVAS_CONTEXT_PROPS = {
770
758
  canvas: null,
@@ -797,7 +785,7 @@ var CanvasContext = class {
797
785
  constructor(props) {
798
786
  this.props = { ...DEFAULT_CANVAS_CONTEXT_PROPS, ...props };
799
787
  props = this.props;
800
- if (!(0, import_env2.isBrowser)()) {
788
+ if (!(0, import_env.isBrowser)()) {
801
789
  this.id = "node-canvas-context";
802
790
  this.type = "node";
803
791
  this.width = this.props.width;
@@ -1051,20 +1039,106 @@ var _Texture = class extends Resource {
1051
1039
  height;
1052
1040
  /** depth of this texture */
1053
1041
  depth;
1042
+ /** mip levels in this texture */
1043
+ mipLevels;
1054
1044
  /** "Time" of last update. Monotonically increasing timestamp */
1055
1045
  updateTimestamp;
1046
+ /** Check if data is an external image */
1047
+ static isExternalImage(data) {
1048
+ return typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement || typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement || typeof VideoFrame !== "undefined" && data instanceof VideoFrame || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas;
1049
+ }
1050
+ /** Determine size (width and height) of provided image data */
1051
+ static getExternalImageSize(data) {
1052
+ if (typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas) {
1053
+ return { width: data.width, height: data.height };
1054
+ }
1055
+ if (typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement) {
1056
+ return { width: data.naturalWidth, height: data.naturalHeight };
1057
+ }
1058
+ if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
1059
+ return { width: data.videoWidth, height: data.videoHeight };
1060
+ }
1061
+ if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
1062
+ return { width: data.displayWidth, height: data.displayHeight };
1063
+ }
1064
+ throw new Error("Unknown image type");
1065
+ }
1066
+ /** Check if texture data is a typed array */
1067
+ static isTextureLevelData(data) {
1068
+ const typedArray = data == null ? void 0 : data.data;
1069
+ return ArrayBuffer.isView(typedArray);
1070
+ }
1071
+ /** Get the size of the texture described by the provided TextureData */
1072
+ static getTextureDataSize(data) {
1073
+ if (!data) {
1074
+ return null;
1075
+ }
1076
+ if (ArrayBuffer.isView(data)) {
1077
+ return null;
1078
+ }
1079
+ if (Array.isArray(data)) {
1080
+ return _Texture.getTextureDataSize(data[0]);
1081
+ }
1082
+ if (_Texture.isExternalImage(data)) {
1083
+ return _Texture.getExternalImageSize(data);
1084
+ }
1085
+ if (data && typeof data === "object" && data.constructor === Object) {
1086
+ const textureDataArray = Object.values(data);
1087
+ const untypedData = textureDataArray[0];
1088
+ return { width: untypedData.width, height: untypedData.height };
1089
+ }
1090
+ throw new Error("texture size deduction failed");
1091
+ }
1092
+ /** Calculate the number of mip levels for a texture of width and height */
1093
+ static getMipLevelCount(width, height) {
1094
+ return Math.floor(Math.log2(Math.max(width, height))) + 1;
1095
+ }
1096
+ /** Convert luma.gl cubemap face constants to depth index */
1097
+ static getCubeFaceDepth(face) {
1098
+ switch (face) {
1099
+ case "+X":
1100
+ return 0;
1101
+ case "-X":
1102
+ return 1;
1103
+ case "+Y":
1104
+ return 2;
1105
+ case "-Y":
1106
+ return 3;
1107
+ case "+Z":
1108
+ return 4;
1109
+ case "-Z":
1110
+ return 5;
1111
+ default:
1112
+ throw new Error(face);
1113
+ }
1114
+ }
1056
1115
  /** Do not use directly. Create with device.createTexture() */
1057
- constructor(device, props, defaultProps = _Texture.defaultProps) {
1058
- super(device, props, defaultProps);
1116
+ constructor(device, props) {
1117
+ super(device, props, _Texture.defaultProps);
1059
1118
  this.dimension = this.props.dimension;
1060
1119
  this.format = this.props.format;
1061
1120
  this.width = this.props.width;
1062
1121
  this.height = this.props.height;
1063
1122
  this.depth = this.props.depth;
1123
+ if (this.props.width === void 0 || this.props.height === void 0) {
1124
+ const size = _Texture.getTextureDataSize(this.props.data);
1125
+ this.width = (size == null ? void 0 : size.width) || 1;
1126
+ this.height = (size == null ? void 0 : size.height) || 1;
1127
+ }
1128
+ if (this.props.mipmaps && this.props.mipLevels === void 0) {
1129
+ this.props.mipLevels = "pyramid";
1130
+ }
1131
+ this.mipLevels = this.props.mipLevels === "pyramid" ? _Texture.getMipLevelCount(this.width, this.height) : this.props.mipLevels || 1;
1064
1132
  this.updateTimestamp = device.incrementTimestamp();
1065
1133
  }
1066
1134
  };
1067
1135
  var Texture = _Texture;
1136
+ __publicField(Texture, "COPY_SRC", 1);
1137
+ __publicField(Texture, "COPY_DST", 2);
1138
+ __publicField(Texture, "TEXTURE", 4);
1139
+ __publicField(Texture, "STORAGE", 8);
1140
+ __publicField(Texture, "RENDER_ATTACHMENT", 16);
1141
+ __publicField(Texture, "CubeFaces", ["+X", "-X", "+Y", "-Y", "+Z", "-Z"]);
1068
1142
  __publicField(Texture, "defaultProps", {
1069
1143
  ...Resource.defaultProps,
1070
1144
  data: null,
@@ -1073,23 +1147,30 @@ __publicField(Texture, "defaultProps", {
1073
1147
  width: void 0,
1074
1148
  height: void 0,
1075
1149
  depth: 1,
1076
- mipmaps: true,
1077
- // type: undefined,
1150
+ mipmaps: false,
1078
1151
  compressed: false,
1079
- // mipLevels: 1,
1080
1152
  usage: 0,
1081
- // usage: GPUTextureUsage.COPY_DST
1082
1153
  mipLevels: void 0,
1083
1154
  samples: void 0,
1084
- type: void 0,
1085
1155
  sampler: {},
1086
1156
  view: void 0
1087
1157
  });
1088
- __publicField(Texture, "COPY_SRC", 1);
1089
- __publicField(Texture, "COPY_DST", 2);
1090
- __publicField(Texture, "TEXTURE_BINDING", 4);
1091
- __publicField(Texture, "STORAGE_BINDING", 8);
1092
- __publicField(Texture, "RENDER_ATTACHMENT", 16);
1158
+ /** Default options */
1159
+ __publicField(Texture, "defaultCopyExternalImageOptions", {
1160
+ image: void 0,
1161
+ sourceX: 0,
1162
+ sourceY: 0,
1163
+ width: void 0,
1164
+ height: void 0,
1165
+ depth: 1,
1166
+ mipLevel: 0,
1167
+ x: 0,
1168
+ y: 0,
1169
+ z: 0,
1170
+ aspect: "all",
1171
+ colorSpace: "srgb",
1172
+ premultipliedAlpha: false
1173
+ });
1093
1174
 
1094
1175
  // dist/adapter/resources/texture-view.js
1095
1176
  var _TextureView = class extends Resource {
@@ -1125,11 +1206,11 @@ var _ExternalTexture = class extends Resource {
1125
1206
  var ExternalTexture = _ExternalTexture;
1126
1207
  __publicField(ExternalTexture, "defaultProps", {
1127
1208
  ...Resource.defaultProps,
1128
- source: null,
1209
+ source: void 0,
1129
1210
  colorSpace: "srgb"
1130
1211
  });
1131
1212
 
1132
- // dist/lib/compiler-log/format-compiler-log.js
1213
+ // dist/adapter-utils/format-compiler-log.js
1133
1214
  function formatCompilerLog(shaderLog, source, options) {
1134
1215
  let formattedLog = "";
1135
1216
  const lines = source.split(/\r?\n/);
@@ -1195,31 +1276,6 @@ function escapeHTML(unsafe) {
1195
1276
  return unsafe.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#039;");
1196
1277
  }
1197
1278
 
1198
- // dist/lib/compiler-log/get-shader-info.js
1199
- function getShaderInfo(source, defaultName) {
1200
- return {
1201
- name: getShaderName(source, defaultName),
1202
- language: "glsl",
1203
- version: getShaderVersion(source)
1204
- };
1205
- }
1206
- function getShaderName(shader, defaultName = "unnamed") {
1207
- const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
1208
- const match = SHADER_NAME_REGEXP.exec(shader);
1209
- return match ? match[1] : defaultName;
1210
- }
1211
- function getShaderVersion(source) {
1212
- let version = 100;
1213
- const words = source.match(/[^\s]+/g);
1214
- if (words && words.length >= 2 && words[0] === "#version") {
1215
- const v = parseInt(words[1], 10);
1216
- if (Number.isFinite(v)) {
1217
- version = v;
1218
- }
1219
- }
1220
- return version;
1221
- }
1222
-
1223
1279
  // dist/adapter/resources/shader.js
1224
1280
  var _Shader = class extends Resource {
1225
1281
  get [Symbol.toStringTag]() {
@@ -1267,13 +1323,16 @@ var _Shader = class extends Resource {
1267
1323
  this._displayShaderLog(messages);
1268
1324
  }
1269
1325
  // PRIVATE
1270
- /** In-browser UI logging of errors */
1326
+ /**
1327
+ * In-browser UI logging of errors
1328
+ * TODO - this HTML formatting code should not be in Device, should be pluggable
1329
+ */
1271
1330
  _displayShaderLog(messages) {
1272
1331
  var _a;
1273
1332
  if (typeof document === "undefined" || !(document == null ? void 0 : document.createElement)) {
1274
1333
  return;
1275
1334
  }
1276
- const shaderName = getShaderInfo(this.source).name;
1335
+ const shaderName = getShaderName(this.source);
1277
1336
  const shaderTitle = `${this.stage} ${shaderName}`;
1278
1337
  let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
1279
1338
  const translatedSource = this.getTranslatedSource();
@@ -1294,9 +1353,7 @@ ${htmlLog}
1294
1353
  button.style.textAlign = "left";
1295
1354
  document.body.appendChild(button);
1296
1355
  const errors = document.getElementsByClassName("luma-compiler-log-error");
1297
- if ((_a = errors[0]) == null ? void 0 : _a.scrollIntoView) {
1298
- errors[0].scrollIntoView();
1299
- }
1356
+ (_a = errors[0]) == null ? void 0 : _a.scrollIntoView();
1300
1357
  button.onclick = () => {
1301
1358
  const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
1302
1359
  navigator.clipboard.writeText(dataURI);
@@ -1314,7 +1371,12 @@ __publicField(Shader, "defaultProps", {
1314
1371
  debug: "errors"
1315
1372
  });
1316
1373
  function getShaderIdFromProps(props) {
1317
- return getShaderInfo(props.source).name || props.id || uid(`unnamed ${props.stage}-shader`);
1374
+ return getShaderName(props.source) || props.id || uid(`unnamed ${props.stage}-shader`);
1375
+ }
1376
+ function getShaderName(shader, defaultName = "unnamed") {
1377
+ const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
1378
+ const match = SHADER_NAME_REGEXP.exec(shader);
1379
+ return match ? match[1] : defaultName;
1318
1380
  }
1319
1381
 
1320
1382
  // dist/adapter/resources/sampler.js
@@ -1352,10 +1414,6 @@ var _Framebuffer = class extends Resource {
1352
1414
  width;
1353
1415
  /** Height of all attachments in this framebuffer */
1354
1416
  height;
1355
- /** Color attachments */
1356
- colorAttachments = [];
1357
- /** Depth-stencil attachment, if provided */
1358
- depthStencilAttachment = null;
1359
1417
  constructor(device, props = {}) {
1360
1418
  super(device, props, _Framebuffer.defaultProps);
1361
1419
  this.width = this.props.width;
@@ -1432,7 +1490,7 @@ var _Framebuffer = class extends Resource {
1432
1490
  for (let i = 0; i < this.colorAttachments.length; ++i) {
1433
1491
  if (this.colorAttachments[i]) {
1434
1492
  const resizedTexture = this.device._createTexture({
1435
- ...this.colorAttachments[i].props,
1493
+ ...this.colorAttachments[i].texture.props,
1436
1494
  width,
1437
1495
  height
1438
1496
  });
@@ -1443,7 +1501,7 @@ var _Framebuffer = class extends Resource {
1443
1501
  }
1444
1502
  if (this.depthStencilAttachment) {
1445
1503
  const resizedTexture = this.device._createTexture({
1446
- ...this.depthStencilAttachment.props,
1504
+ ...this.depthStencilAttachment.texture.props,
1447
1505
  width,
1448
1506
  height
1449
1507
  });
@@ -1546,8 +1604,11 @@ var _ComputePipeline = class extends Resource {
1546
1604
  return "ComputePipeline";
1547
1605
  }
1548
1606
  hash = "";
1607
+ /** The merged shader layout */
1608
+ shaderLayout;
1549
1609
  constructor(device, props) {
1550
1610
  super(device, props, _ComputePipeline.defaultProps);
1611
+ this.shaderLayout = props.shaderLayout;
1551
1612
  }
1552
1613
  };
1553
1614
  var ComputePipeline = _ComputePipeline;
@@ -1605,7 +1666,7 @@ __publicField(CommandBuffer, "defaultProps", {
1605
1666
  ...Resource.defaultProps
1606
1667
  });
1607
1668
 
1608
- // dist/adapter/type-utils/decode-attribute-type.js
1669
+ // dist/gpu-type-utils/decode-attribute-type.js
1609
1670
  function decodeShaderAttributeType(attributeType) {
1610
1671
  const [dataType, components] = TYPE_INFO[attributeType];
1611
1672
  const integer = dataType === "i32" || dataType === "u32";
@@ -1667,7 +1728,7 @@ var TYPE_SIZES2 = {
1667
1728
  // 'bool-webgl': 4,
1668
1729
  };
1669
1730
 
1670
- // dist/adapter/type-utils/decode-vertex-format.js
1731
+ // dist/gpu-type-utils/decode-vertex-format.js
1671
1732
  function decodeVertexFormat(format) {
1672
1733
  let webglOnly;
1673
1734
  if (format.endsWith("-webgl")) {
@@ -1692,11 +1753,14 @@ function decodeVertexFormat(format) {
1692
1753
  return result;
1693
1754
  }
1694
1755
 
1695
- // dist/adapter/attribute-utils/get-attribute-from-layouts.js
1756
+ // dist/adapter-utils/get-attribute-from-layouts.js
1696
1757
  function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
1697
1758
  const attributeInfos = {};
1698
1759
  for (const attribute of shaderLayout.attributes) {
1699
- attributeInfos[attribute.name] = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
1760
+ const attributeInfo = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
1761
+ if (attributeInfo) {
1762
+ attributeInfos[attribute.name] = attributeInfo;
1763
+ }
1700
1764
  }
1701
1765
  return attributeInfos;
1702
1766
  }
@@ -1731,7 +1795,7 @@ function getAttributeInfoFromLayouts(shaderLayout, bufferLayout, name2) {
1731
1795
  normalized: vertexFormatInfo.normalized,
1732
1796
  // integer is a property of the shader declaration
1733
1797
  integer: attributeTypeInfo.integer,
1734
- stepMode: (bufferMapping == null ? void 0 : bufferMapping.stepMode) || shaderDeclaration.stepMode,
1798
+ stepMode: (bufferMapping == null ? void 0 : bufferMapping.stepMode) || shaderDeclaration.stepMode || "vertex",
1735
1799
  byteOffset: (bufferMapping == null ? void 0 : bufferMapping.byteOffset) || 0,
1736
1800
  byteStride: (bufferMapping == null ? void 0 : bufferMapping.byteStride) || 0
1737
1801
  };
@@ -1797,28 +1861,13 @@ function getAttributeFromAttributesList(bufferLayouts, name2) {
1797
1861
  stepMode: bufferLayout.stepMode,
1798
1862
  vertexFormat: attributeMapping.format,
1799
1863
  byteOffset: attributeMapping.byteOffset,
1864
+ // @ts-ignore
1800
1865
  byteStride
1801
1866
  };
1802
1867
  }
1803
1868
  }
1804
1869
  return null;
1805
1870
  }
1806
- function mergeShaderLayout(baseLayout, overrideLayout) {
1807
- const mergedLayout = {
1808
- ...baseLayout,
1809
- attributes: baseLayout.attributes.map((attribute) => ({ ...attribute }))
1810
- };
1811
- for (const attribute of (overrideLayout == null ? void 0 : overrideLayout.attributes) || []) {
1812
- const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
1813
- if (!baseAttribute) {
1814
- log.warn(`shader layout attribute ${attribute.name} not present in shader`);
1815
- } else {
1816
- baseAttribute.type = attribute.type || baseAttribute.type;
1817
- baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
1818
- }
1819
- }
1820
- return mergedLayout;
1821
- }
1822
1871
 
1823
1872
  // dist/adapter/resources/vertex-array.js
1824
1873
  var _VertexArray = class extends Resource {
@@ -1837,7 +1886,11 @@ var _VertexArray = class extends Resource {
1837
1886
  super(device, props, _VertexArray.defaultProps);
1838
1887
  this.maxVertexAttributes = device.limits.maxVertexAttributes;
1839
1888
  this.attributes = new Array(this.maxVertexAttributes).fill(null);
1840
- this.attributeInfos = getAttributeInfosByLocation(props.renderPipeline.shaderLayout, props.renderPipeline.bufferLayout, this.maxVertexAttributes);
1889
+ const { shaderLayout, bufferLayout } = props.renderPipeline || {};
1890
+ if (!shaderLayout || !bufferLayout) {
1891
+ throw new Error("VertexArray");
1892
+ }
1893
+ this.attributeInfos = getAttributeInfosByLocation(shaderLayout, bufferLayout, this.maxVertexAttributes);
1841
1894
  }
1842
1895
  // DEPRECATED METHODS
1843
1896
  /** @deprecated Set constant attributes (WebGL only) */
@@ -1883,7 +1936,7 @@ __publicField(QuerySet, "defaultProps", {
1883
1936
  count: void 0
1884
1937
  });
1885
1938
 
1886
- // dist/adapter/type-utils/decode-shader-types.js
1939
+ // dist/gpu-type-utils/decode-shader-types.js
1887
1940
  var UNIFORM_FORMATS = {
1888
1941
  f32: { type: "f32", components: 1 },
1889
1942
  i32: { type: "i32", components: 1 },
@@ -1910,7 +1963,6 @@ var UNIFORM_FORMATS = {
1910
1963
  };
1911
1964
  function decodeShaderUniformType(format) {
1912
1965
  const decoded = UNIFORM_FORMATS[format];
1913
- assert(format);
1914
1966
  return decoded;
1915
1967
  }
1916
1968
  function alignTo(size, count) {
@@ -1936,27 +1988,19 @@ function getScratchArray(Type, length) {
1936
1988
  const scratchArrayBuffer = getScratchArrayBuffer(Type.BYTES_PER_ELEMENT * length);
1937
1989
  return new Type(scratchArrayBuffer, 0, length);
1938
1990
  }
1939
- function fillArray(options) {
1940
- const { target, source, start = 0, count = 1 } = options;
1941
- const length = source.length;
1942
- const total = count * length;
1943
- let copied = 0;
1944
- for (let i = start; copied < length; copied++) {
1945
- target[i++] = source[copied];
1946
- }
1947
- while (copied < total) {
1948
- if (copied < total - copied) {
1949
- target.copyWithin(start + copied, start, start + copied);
1950
- copied *= 2;
1951
- } else {
1952
- target.copyWithin(start + copied, start, start + total - copied);
1953
- copied = total;
1954
- }
1991
+
1992
+ // dist/utils/is-array.js
1993
+ function isTypedArray(value) {
1994
+ return ArrayBuffer.isView(value) && !(value instanceof DataView);
1995
+ }
1996
+ function isNumberArray(value) {
1997
+ if (Array.isArray(value)) {
1998
+ return value.length === 0 || typeof value[0] === "number";
1955
1999
  }
1956
- return options.target;
2000
+ return isTypedArray(value);
1957
2001
  }
1958
2002
 
1959
- // dist/lib/uniforms/uniform-buffer-layout.js
2003
+ // dist/portable/uniform-buffer-layout.js
1960
2004
  var minBufferSize = 1024;
1961
2005
  var UniformBufferLayout = class {
1962
2006
  layout = {};
@@ -2003,12 +2047,11 @@ var UniformBufferLayout = class {
2003
2047
  }
2004
2048
  typedArray[offset] = Number(value);
2005
2049
  } else {
2006
- const numericArray = isNumberArray(value);
2007
- if (!numericArray) {
2050
+ if (!isNumberArray(value)) {
2008
2051
  log.warn(`Supplied value for multi component / array uniform ${name2} is not a numeric array: ${value}`)();
2009
2052
  continue;
2010
2053
  }
2011
- typedArray.set(numericArray, offset);
2054
+ typedArray.set(value, offset);
2012
2055
  }
2013
2056
  }
2014
2057
  return new Uint8Array(arrayBuffer2);
@@ -2029,12 +2072,12 @@ function arrayEqual(a, b, limit = 16) {
2029
2072
  if (a !== b) {
2030
2073
  return false;
2031
2074
  }
2032
- const arrayA = isNumberArray(a);
2033
- if (!arrayA) {
2075
+ const arrayA = a;
2076
+ const arrayB = b;
2077
+ if (!isNumberArray(arrayA)) {
2034
2078
  return false;
2035
2079
  }
2036
- const arrayB = isNumberArray(b);
2037
- if (arrayB && arrayA.length === arrayB.length) {
2080
+ if (isNumberArray(arrayB) && arrayA.length === arrayB.length) {
2038
2081
  for (let i = 0; i < arrayA.length; ++i) {
2039
2082
  if (arrayB[i] !== arrayA[i]) {
2040
2083
  return false;
@@ -2044,14 +2087,13 @@ function arrayEqual(a, b, limit = 16) {
2044
2087
  return true;
2045
2088
  }
2046
2089
  function arrayCopy(a) {
2047
- const numberArray = isNumberArray(a);
2048
- if (numberArray) {
2049
- return numberArray.slice();
2090
+ if (isNumberArray(a)) {
2091
+ return a.slice();
2050
2092
  }
2051
2093
  return a;
2052
2094
  }
2053
2095
 
2054
- // dist/lib/uniforms/uniform-block.js
2096
+ // dist/portable/uniform-block.js
2055
2097
  var UniformBlock = class {
2056
2098
  name;
2057
2099
  uniforms = {};
@@ -2061,7 +2103,7 @@ var UniformBlock = class {
2061
2103
  needsRedraw = "initialized";
2062
2104
  constructor(props) {
2063
2105
  var _a;
2064
- this.name = props == null ? void 0 : props.name;
2106
+ this.name = (props == null ? void 0 : props.name) || "unnamed";
2065
2107
  if ((props == null ? void 0 : props.name) && (props == null ? void 0 : props.shaderLayout)) {
2066
2108
  const binding = (_a = props == null ? void 0 : props.shaderLayout.bindings) == null ? void 0 : _a.find((binding2) => binding2.type === "uniform" && binding2.name === (props == null ? void 0 : props.name));
2067
2109
  if (!binding) {
@@ -2102,7 +2144,7 @@ var UniformBlock = class {
2102
2144
  }
2103
2145
  };
2104
2146
 
2105
- // dist/lib/uniforms/uniform-store.js
2147
+ // dist/portable/uniform-store.js
2106
2148
  var UniformStore = class {
2107
2149
  /** Stores the uniform values for each uniform block */
2108
2150
  uniformBlocks = /* @__PURE__ */ new Map();
@@ -2135,19 +2177,22 @@ var UniformStore = class {
2135
2177
  * Makes all properties partial
2136
2178
  */
2137
2179
  setUniforms(uniforms) {
2180
+ var _a;
2138
2181
  for (const [blockName, uniformValues] of Object.entries(uniforms)) {
2139
- this.uniformBlocks.get(blockName).setUniforms(uniformValues);
2182
+ (_a = this.uniformBlocks.get(blockName)) == null ? void 0 : _a.setUniforms(uniformValues);
2140
2183
  }
2141
2184
  this.updateUniformBuffers();
2142
2185
  }
2143
2186
  /** Get the required minimum length of the uniform buffer */
2144
2187
  getUniformBufferByteLength(uniformBufferName) {
2145
- return this.uniformBufferLayouts.get(uniformBufferName).byteLength;
2188
+ var _a;
2189
+ return ((_a = this.uniformBufferLayouts.get(uniformBufferName)) == null ? void 0 : _a.byteLength) || 0;
2146
2190
  }
2147
2191
  /** Get formatted binary memory that can be uploaded to a buffer */
2148
2192
  getUniformBufferData(uniformBufferName) {
2149
- const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2150
- return this.uniformBufferLayouts.get(uniformBufferName).getData(uniformValues);
2193
+ var _a, _b;
2194
+ const uniformValues = ((_a = this.uniformBlocks.get(uniformBufferName)) == null ? void 0 : _a.getAllUniforms()) || {};
2195
+ return (_b = this.uniformBufferLayouts.get(uniformBufferName)) == null ? void 0 : _b.getData(uniformValues);
2151
2196
  }
2152
2197
  /**
2153
2198
  * Creates an unmanaged uniform buffer (umnanaged means that application is responsible for destroying it)
@@ -2192,22 +2237,23 @@ var UniformStore = class {
2192
2237
  }
2193
2238
  /** Update one uniform buffer. Only updates if values have changed */
2194
2239
  updateUniformBuffer(uniformBufferName) {
2240
+ var _a;
2195
2241
  const uniformBlock = this.uniformBlocks.get(uniformBufferName);
2196
2242
  const uniformBuffer = this.uniformBuffers.get(uniformBufferName);
2197
2243
  let reason = false;
2198
- if (uniformBuffer && uniformBlock.needsRedraw) {
2244
+ if (uniformBuffer && (uniformBlock == null ? void 0 : uniformBlock.needsRedraw)) {
2199
2245
  reason ||= uniformBlock.needsRedraw;
2200
2246
  const uniformBufferData = this.getUniformBufferData(uniformBufferName);
2201
2247
  const uniformBuffer2 = this.uniformBuffers.get(uniformBufferName);
2202
- uniformBuffer2.write(uniformBufferData);
2203
- const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2248
+ uniformBuffer2 == null ? void 0 : uniformBuffer2.write(uniformBufferData);
2249
+ const uniformValues = (_a = this.uniformBlocks.get(uniformBufferName)) == null ? void 0 : _a.getAllUniforms();
2204
2250
  log.log(4, `Writing to uniform buffer ${String(uniformBufferName)}`, uniformBufferData, uniformValues)();
2205
2251
  }
2206
2252
  return reason;
2207
2253
  }
2208
2254
  };
2209
2255
 
2210
- // dist/adapter/type-utils/vertex-format-from-attribute.js
2256
+ // dist/gpu-type-utils/vertex-format-from-attribute.js
2211
2257
  function getDataTypeFromTypedArray(arrayOrType) {
2212
2258
  const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
2213
2259
  switch (type) {
@@ -2283,221 +2329,4 @@ function getVertexFormatFromAttribute(typedArray, size, normalized) {
2283
2329
  }
2284
2330
  return `${dataType}x${components}`;
2285
2331
  }
2286
-
2287
- // dist/utils/cast.js
2288
- function cast(value) {
2289
- return value;
2290
- }
2291
-
2292
- // dist/lib/uniforms/uniform.js
2293
- function isUniformValue(value) {
2294
- return isNumberArray(value) !== null || typeof value === "number" || typeof value === "boolean";
2295
- }
2296
- function splitUniformsAndBindings(uniforms) {
2297
- const result = { bindings: {}, uniforms: {} };
2298
- Object.keys(uniforms).forEach((name2) => {
2299
- const uniform = uniforms[name2];
2300
- if (isUniformValue(uniform)) {
2301
- result.uniforms[name2] = uniform;
2302
- } else {
2303
- result.bindings[name2] = uniform;
2304
- }
2305
- });
2306
- return result;
2307
- }
2308
-
2309
- // dist/utils/format-value.js
2310
- function formatArrayValue(v, opts = {}) {
2311
- const { maxElts = 16, size = 1 } = opts;
2312
- let string = "[";
2313
- for (let i = 0; i < v.length && i < maxElts; ++i) {
2314
- if (i > 0) {
2315
- string += `,${i % size === 0 ? " " : ""}`;
2316
- }
2317
- string += formatValue(v[i], opts);
2318
- }
2319
- const terminator = v.length > maxElts ? "..." : "]";
2320
- return `${string}${terminator}`;
2321
- }
2322
- function formatValue(v, opts = {}) {
2323
- const EPSILON = 1e-16;
2324
- const { isInteger = false } = opts;
2325
- if (Array.isArray(v) || ArrayBuffer.isView(v)) {
2326
- return formatArrayValue(v, opts);
2327
- }
2328
- if (typeof v !== "number") {
2329
- return String(v);
2330
- }
2331
- if (Math.abs(v) < EPSILON) {
2332
- return isInteger ? "0" : "0.";
2333
- }
2334
- if (isInteger) {
2335
- return v.toFixed(0);
2336
- }
2337
- if (Math.abs(v) > 100 && Math.abs(v) < 1e4) {
2338
- return v.toFixed(0);
2339
- }
2340
- const string = v.toPrecision(2);
2341
- const decimal = string.indexOf(".0");
2342
- return decimal === string.length - 2 ? string.slice(0, -1) : string;
2343
- }
2344
-
2345
- // dist/utils/stub-methods.js
2346
- function stubRemovedMethods(instance, className, version, methodNames) {
2347
- const upgradeMessage = `See luma.gl ${version} Upgrade Guide at https://luma.gl/docs/upgrade-guide`;
2348
- const prototype = Object.getPrototypeOf(instance);
2349
- methodNames.forEach((methodName) => {
2350
- if (prototype.methodName) {
2351
- return;
2352
- }
2353
- prototype[methodName] = () => {
2354
- log.removed(`Calling removed method ${className}.${methodName}: `, upgradeMessage)();
2355
- throw new Error(methodName);
2356
- };
2357
- });
2358
- }
2359
-
2360
- // dist/utils/check-props.js
2361
- function checkProps(className, props, propChecks) {
2362
- const { removedProps = {}, deprecatedProps = {}, replacedProps = {} } = propChecks;
2363
- for (const propName in removedProps) {
2364
- if (propName in props) {
2365
- const replacementProp = removedProps[propName];
2366
- const replacement = replacementProp ? `${className}.${removedProps[propName]}` : "N/A";
2367
- log.removed(`${className}.${propName}`, replacement)();
2368
- }
2369
- }
2370
- for (const propName in deprecatedProps) {
2371
- if (propName in props) {
2372
- const replacementProp = deprecatedProps[propName];
2373
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
2374
- }
2375
- }
2376
- let newProps = null;
2377
- for (const [propName, replacementProp] of Object.entries(replacedProps)) {
2378
- if (propName in props) {
2379
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
2380
- newProps = newProps || Object.assign({}, props);
2381
- newProps[replacementProp] = props[propName];
2382
- delete newProps[propName];
2383
- }
2384
- }
2385
- return newProps || props;
2386
- }
2387
-
2388
- // dist/utils/load-file.js
2389
- var pathPrefix = "";
2390
- function setPathPrefix(prefix) {
2391
- pathPrefix = prefix;
2392
- }
2393
- async function loadFile(url, options) {
2394
- url = url.startsWith("http") ? url : pathPrefix + url;
2395
- const dataType = (options == null ? void 0 : options.dataType) || "text";
2396
- const response = await fetch(url, options);
2397
- return await response[dataType]();
2398
- }
2399
- async function loadImageBitmap(url, opts) {
2400
- const image = new Image();
2401
- image.crossOrigin = (opts == null ? void 0 : opts.crossOrigin) || "anonymous";
2402
- image.src = url.startsWith("http") ? url : pathPrefix + url;
2403
- await image.decode();
2404
- return await createImageBitmap(image);
2405
- }
2406
- async function loadImage(url, opts) {
2407
- return await new Promise((resolve, reject) => {
2408
- try {
2409
- const image = new Image();
2410
- image.onload = () => resolve(image);
2411
- image.onerror = () => reject(new Error(`Could not load image ${url}.`));
2412
- image.crossOrigin = (opts == null ? void 0 : opts.crossOrigin) || "anonymous";
2413
- image.src = url.startsWith("http") ? url : pathPrefix + url;
2414
- } catch (error) {
2415
- reject(error);
2416
- }
2417
- });
2418
- }
2419
- async function loadScript(scriptUrl, scriptId) {
2420
- const head = document.getElementsByTagName("head")[0];
2421
- if (!head) {
2422
- throw new Error("loadScript");
2423
- }
2424
- const script = document.createElement("script");
2425
- script.setAttribute("type", "text/javascript");
2426
- script.setAttribute("src", scriptUrl);
2427
- if (scriptId) {
2428
- script.id = scriptId;
2429
- }
2430
- return new Promise((resolve, reject) => {
2431
- script.onload = resolve;
2432
- script.onerror = (error) => reject(new Error(`Unable to load script '${scriptUrl}': ${error}`));
2433
- head.appendChild(script);
2434
- });
2435
- }
2436
-
2437
- // dist/utils/random.js
2438
- function makeRandomNumberGenerator() {
2439
- let s = 1;
2440
- let c = 1;
2441
- return () => {
2442
- s = Math.sin(c * 17.23);
2443
- c = Math.cos(s * 27.92);
2444
- return fract(Math.abs(s * c) * 1432.71);
2445
- };
2446
- }
2447
- function fract(n) {
2448
- return n - Math.floor(n);
2449
- }
2450
- var random = makeRandomNumberGenerator();
2451
-
2452
- // dist/utils/deep-equal.js
2453
- function deepEqual(a, b, depth) {
2454
- if (a === b) {
2455
- return true;
2456
- }
2457
- if (!depth || !a || !b) {
2458
- return false;
2459
- }
2460
- if (Array.isArray(a)) {
2461
- if (!Array.isArray(b) || a.length !== b.length) {
2462
- return false;
2463
- }
2464
- for (let i = 0; i < a.length; i++) {
2465
- if (!deepEqual(a[i], b[i], depth - 1)) {
2466
- return false;
2467
- }
2468
- }
2469
- return true;
2470
- }
2471
- if (Array.isArray(b)) {
2472
- return false;
2473
- }
2474
- if (typeof a === "object" && typeof b === "object") {
2475
- const aKeys = Object.keys(a);
2476
- const bKeys = Object.keys(b);
2477
- if (aKeys.length !== bKeys.length) {
2478
- return false;
2479
- }
2480
- for (const key of aKeys) {
2481
- if (!b.hasOwnProperty(key)) {
2482
- return false;
2483
- }
2484
- if (!deepEqual(a[key], b[key], depth - 1)) {
2485
- return false;
2486
- }
2487
- }
2488
- return true;
2489
- }
2490
- return false;
2491
- }
2492
-
2493
- // dist/utils/request-animation-frame.js
2494
- function requestAnimationFrame(callback) {
2495
- return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame(callback) : setTimeout(callback, 1e3 / 60);
2496
- }
2497
- function cancelAnimationFrame(timerId) {
2498
- return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame(timerId) : clearTimeout(timerId);
2499
- }
2500
-
2501
- // dist/index.js
2502
- var glsl = (x) => `${x}`;
2503
2332
  //# sourceMappingURL=index.cjs.map