@luma.gl/core 9.0.10 → 9.1.0-alpha.1

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 (236) hide show
  1. package/dist/adapter/canvas-context.d.ts +5 -0
  2. package/dist/adapter/canvas-context.d.ts.map +1 -1
  3. package/dist/adapter/device.d.ts +10 -8
  4. package/dist/adapter/device.d.ts.map +1 -1
  5. package/dist/adapter/device.js +20 -18
  6. package/dist/{lib → adapter}/luma.d.ts +2 -2
  7. package/dist/adapter/luma.d.ts.map +1 -0
  8. package/dist/{lib → adapter}/luma.js +7 -7
  9. package/dist/adapter/resources/buffer.js +5 -5
  10. package/dist/adapter/resources/compute-pipeline.d.ts +2 -0
  11. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  12. package/dist/adapter/resources/compute-pipeline.js +3 -0
  13. package/dist/adapter/resources/external-texture.d.ts +1 -1
  14. package/dist/adapter/resources/external-texture.d.ts.map +1 -1
  15. package/dist/adapter/resources/external-texture.js +1 -1
  16. package/dist/adapter/resources/framebuffer.d.ts +3 -3
  17. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  18. package/dist/adapter/resources/framebuffer.js +2 -83
  19. package/dist/adapter/resources/render-pass.d.ts +2 -2
  20. package/dist/adapter/resources/render-pass.d.ts.map +1 -1
  21. package/dist/adapter/resources/render-pipeline.d.ts +2 -5
  22. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  23. package/dist/adapter/resources/resource.d.ts +3 -3
  24. package/dist/adapter/resources/resource.d.ts.map +1 -1
  25. package/dist/adapter/resources/resource.js +1 -1
  26. package/dist/adapter/resources/shader.d.ts +5 -2
  27. package/dist/adapter/resources/shader.d.ts.map +1 -1
  28. package/dist/adapter/resources/shader.js +15 -9
  29. package/dist/adapter/resources/texture-view.d.ts +1 -1
  30. package/dist/adapter/resources/texture-view.d.ts.map +1 -1
  31. package/dist/adapter/resources/texture.d.ts +111 -49
  32. package/dist/adapter/resources/texture.d.ts.map +1 -1
  33. package/dist/adapter/resources/texture.js +96 -12
  34. package/dist/adapter/resources/transform-feedback.d.ts +1 -1
  35. package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
  36. package/dist/adapter/resources/vertex-array.d.ts +1 -1
  37. package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
  38. package/dist/adapter/resources/vertex-array.js +6 -2
  39. package/dist/adapter/types/{types.d.ts → attachments.d.ts} +5 -16
  40. package/dist/adapter/types/attachments.d.ts.map +1 -0
  41. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  42. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  43. package/dist/adapter/types/compiler-message.d.ts.map +1 -0
  44. package/dist/adapter/types/parameters.d.ts +2 -6
  45. package/dist/adapter/types/parameters.d.ts.map +1 -1
  46. package/dist/adapter/types/shader-layout.d.ts +23 -3
  47. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  48. package/dist/adapter/types/uniforms.d.ts +4 -0
  49. package/dist/adapter/types/uniforms.d.ts.map +1 -0
  50. package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.d.ts +1 -1
  51. package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -0
  52. package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.d.ts +4 -11
  53. package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -0
  54. package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.js +10 -30
  55. package/dist/adapter-utils/is-uniform-value.d.ts +3 -0
  56. package/dist/adapter-utils/is-uniform-value.d.ts.map +1 -0
  57. package/dist/adapter-utils/is-uniform-value.js +7 -0
  58. package/dist/dist.dev.js +266 -588
  59. package/dist/dist.min.js +4 -4
  60. package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.d.ts +3 -3
  61. package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +1 -0
  62. package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.d.ts +1 -1
  63. package/dist/gpu-type-utils/decode-data-type.d.ts.map +1 -0
  64. package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.d.ts +1 -1
  65. package/dist/gpu-type-utils/decode-shader-types.d.ts.map +1 -0
  66. package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.js +0 -2
  67. package/dist/{adapter/type-utils → gpu-type-utils}/decode-texture-format.d.ts +2 -2
  68. package/dist/gpu-type-utils/decode-texture-format.d.ts.map +1 -0
  69. package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.d.ts +1 -1
  70. package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +1 -0
  71. package/dist/gpu-type-utils/shader-types.d.ts.map +1 -0
  72. package/dist/{adapter/types → gpu-type-utils}/texture-formats.d.ts +1 -1
  73. package/dist/gpu-type-utils/texture-formats.d.ts.map +1 -0
  74. package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.d.ts +2 -2
  75. package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +1 -0
  76. package/dist/gpu-type-utils/vertex-formats.d.ts.map +1 -0
  77. package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.d.ts +1 -1
  78. package/dist/gpu-type-utils/wgsl-utils.d.ts.map +1 -0
  79. package/dist/index.cjs +190 -411
  80. package/dist/index.cjs.map +4 -4
  81. package/dist/index.d.ts +28 -42
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +19 -36
  84. package/dist/init.js +1 -1
  85. package/dist/{lib/uniforms → portable}/uniform-block.d.ts +3 -3
  86. package/dist/portable/uniform-block.d.ts.map +1 -0
  87. package/dist/{lib/uniforms → portable}/uniform-block.js +2 -2
  88. package/dist/{lib/uniforms → portable}/uniform-buffer-layout.d.ts +2 -2
  89. package/dist/portable/uniform-buffer-layout.d.ts.map +1 -0
  90. package/dist/{lib/uniforms → portable}/uniform-buffer-layout.js +6 -7
  91. package/dist/{lib/uniforms → portable}/uniform-store.d.ts +4 -4
  92. package/dist/portable/uniform-store.d.ts.map +1 -0
  93. package/dist/{lib/uniforms → portable}/uniform-store.js +11 -9
  94. package/dist/types.d.ts +0 -10
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/utils/array-equal.d.ts.map +1 -1
  97. package/dist/utils/array-equal.js +6 -7
  98. package/dist/utils/array-utils-flat.d.ts +1 -7
  99. package/dist/utils/array-utils-flat.d.ts.map +1 -1
  100. package/dist/utils/array-utils-flat.js +0 -23
  101. package/dist/utils/is-array.d.ts +2 -2
  102. package/dist/utils/is-array.d.ts.map +1 -1
  103. package/dist/utils/is-array.js +2 -2
  104. package/dist/utils/uid.d.ts +7 -0
  105. package/dist/utils/uid.d.ts.map +1 -0
  106. package/dist/utils/{utils.js → uid.js} +0 -11
  107. package/package.json +5 -5
  108. package/src/adapter/canvas-context.ts +6 -0
  109. package/src/adapter/device.ts +34 -31
  110. package/src/{lib → adapter}/luma.ts +9 -9
  111. package/src/adapter/resources/buffer.ts +5 -5
  112. package/src/adapter/resources/command-encoder.ts +1 -1
  113. package/src/adapter/resources/compute-pass.ts +3 -3
  114. package/src/adapter/resources/compute-pipeline.ts +6 -3
  115. package/src/adapter/resources/external-texture.ts +2 -2
  116. package/src/adapter/resources/framebuffer.ts +5 -92
  117. package/src/adapter/resources/query-set.ts +2 -2
  118. package/src/adapter/resources/render-pass.ts +11 -7
  119. package/src/adapter/resources/render-pipeline.ts +3 -6
  120. package/src/adapter/resources/resource.ts +7 -7
  121. package/src/adapter/resources/shader.ts +18 -11
  122. package/src/adapter/resources/texture-view.ts +5 -5
  123. package/src/adapter/resources/texture.ts +226 -77
  124. package/src/adapter/resources/transform-feedback.ts +1 -1
  125. package/src/adapter/resources/vertex-array.ts +7 -3
  126. package/src/adapter/types/{types.ts → attachments.ts} +8 -17
  127. package/src/adapter/types/buffer-layout.ts +1 -1
  128. package/src/adapter/types/parameters.ts +10 -14
  129. package/src/adapter/types/shader-layout.ts +31 -29
  130. package/src/adapter/types/uniforms.ts +10 -0
  131. package/src/{lib/compiler-log → adapter-utils}/format-compiler-log.ts +1 -1
  132. package/src/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.ts +18 -42
  133. package/src/adapter-utils/is-uniform-value.ts +10 -0
  134. package/src/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.ts +3 -3
  135. package/src/{adapter/type-utils → gpu-type-utils}/decode-data-type.ts +1 -1
  136. package/src/{adapter/type-utils → gpu-type-utils}/decode-shader-types.ts +1 -3
  137. package/src/{adapter/type-utils → gpu-type-utils}/decode-texture-format.ts +2 -2
  138. package/src/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.ts +1 -1
  139. package/src/{adapter/types → gpu-type-utils}/texture-formats.ts +1 -1
  140. package/src/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.ts +2 -2
  141. package/src/{adapter/type-utils → gpu-type-utils}/wgsl-utils.ts +1 -1
  142. package/src/index.ts +69 -84
  143. package/src/{lib/uniforms → portable}/uniform-block.ts +5 -5
  144. package/src/{lib/uniforms → portable}/uniform-buffer-layout.ts +9 -9
  145. package/src/{lib/uniforms → portable}/uniform-store.ts +14 -12
  146. package/src/types.ts +0 -12
  147. package/src/utils/array-equal.ts +6 -7
  148. package/src/utils/array-utils-flat.ts +1 -31
  149. package/src/utils/is-array.ts +4 -4
  150. package/src/utils/{utils.ts → uid.ts} +0 -12
  151. package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +0 -1
  152. package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +0 -1
  153. package/dist/adapter/type-utils/decode-data-type.d.ts.map +0 -1
  154. package/dist/adapter/type-utils/decode-shader-types.d.ts.map +0 -1
  155. package/dist/adapter/type-utils/decode-texture-format.d.ts.map +0 -1
  156. package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +0 -1
  157. package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +0 -1
  158. package/dist/adapter/type-utils/wgsl-utils.d.ts.map +0 -1
  159. package/dist/adapter/types/accessor.d.ts +0 -23
  160. package/dist/adapter/types/accessor.d.ts.map +0 -1
  161. package/dist/adapter/types/shader-types.d.ts.map +0 -1
  162. package/dist/adapter/types/texture-formats.d.ts.map +0 -1
  163. package/dist/adapter/types/types.d.ts.map +0 -1
  164. package/dist/adapter/types/vertex-formats.d.ts.map +0 -1
  165. package/dist/lib/compiler-log/compiler-message.d.ts.map +0 -1
  166. package/dist/lib/compiler-log/format-compiler-log.d.ts.map +0 -1
  167. package/dist/lib/compiler-log/get-shader-info.d.ts +0 -9
  168. package/dist/lib/compiler-log/get-shader-info.d.ts.map +0 -1
  169. package/dist/lib/compiler-log/get-shader-info.js +0 -29
  170. package/dist/lib/luma.d.ts.map +0 -1
  171. package/dist/lib/uniforms/uniform-block.d.ts.map +0 -1
  172. package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +0 -1
  173. package/dist/lib/uniforms/uniform-store.d.ts.map +0 -1
  174. package/dist/lib/uniforms/uniform.d.ts +0 -10
  175. package/dist/lib/uniforms/uniform.d.ts.map +0 -1
  176. package/dist/lib/uniforms/uniform.js +0 -20
  177. package/dist/utils/assert.d.ts +0 -2
  178. package/dist/utils/assert.d.ts.map +0 -1
  179. package/dist/utils/assert.js +0 -10
  180. package/dist/utils/cast.d.ts +0 -3
  181. package/dist/utils/cast.d.ts.map +0 -1
  182. package/dist/utils/cast.js +0 -7
  183. package/dist/utils/check-props.d.ts +0 -7
  184. package/dist/utils/check-props.d.ts.map +0 -1
  185. package/dist/utils/check-props.js +0 -36
  186. package/dist/utils/deep-equal.d.ts +0 -9
  187. package/dist/utils/deep-equal.d.ts.map +0 -1
  188. package/dist/utils/deep-equal.js +0 -50
  189. package/dist/utils/format-value.d.ts +0 -7
  190. package/dist/utils/format-value.d.ts.map +0 -1
  191. package/dist/utils/format-value.js +0 -39
  192. package/dist/utils/load-file.d.ts +0 -35
  193. package/dist/utils/load-file.d.ts.map +0 -1
  194. package/dist/utils/load-file.js +0 -74
  195. package/dist/utils/random.d.ts +0 -5
  196. package/dist/utils/random.d.ts.map +0 -1
  197. package/dist/utils/random.js +0 -18
  198. package/dist/utils/request-animation-frame.d.ts +0 -3
  199. package/dist/utils/request-animation-frame.d.ts.map +0 -1
  200. package/dist/utils/request-animation-frame.js +0 -16
  201. package/dist/utils/stub-methods.d.ts +0 -2
  202. package/dist/utils/stub-methods.d.ts.map +0 -1
  203. package/dist/utils/stub-methods.js +0 -19
  204. package/dist/utils/utils.d.ts +0 -9
  205. package/dist/utils/utils.d.ts.map +0 -1
  206. package/src/adapter/types/accessor.ts +0 -37
  207. package/src/lib/compiler-log/get-shader-info.ts +0 -42
  208. package/src/lib/uniforms/uniform.ts +0 -31
  209. package/src/utils/assert.ts +0 -11
  210. package/src/utils/cast.ts +0 -8
  211. package/src/utils/check-props.ts +0 -82
  212. package/src/utils/deep-equal.ts +0 -51
  213. package/src/utils/format-value.ts +0 -47
  214. package/src/utils/load-file.ts +0 -91
  215. package/src/utils/random.ts +0 -21
  216. package/src/utils/request-animation-frame.ts +0 -19
  217. package/src/utils/stub-methods.ts +0 -29
  218. /package/dist/adapter/types/{accessor.js → attachments.js} +0 -0
  219. /package/dist/{lib/compiler-log → adapter/types}/compiler-message.d.ts +0 -0
  220. /package/dist/{lib/compiler-log → adapter/types}/compiler-message.js +0 -0
  221. /package/dist/adapter/types/{shader-types.js → uniforms.js} +0 -0
  222. /package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.js +0 -0
  223. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.js +0 -0
  224. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.js +0 -0
  225. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-texture-format.js +0 -0
  226. /package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.js +0 -0
  227. /package/dist/{adapter/types → gpu-type-utils}/shader-types.d.ts +0 -0
  228. /package/dist/{adapter/types/texture-formats.js → gpu-type-utils/shader-types.js} +0 -0
  229. /package/dist/{adapter/types/types.js → gpu-type-utils/texture-formats.js} +0 -0
  230. /package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.js +0 -0
  231. /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.d.ts +0 -0
  232. /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.js +0 -0
  233. /package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.js +0 -0
  234. /package/src/{lib/compiler-log → adapter/types}/compiler-message.ts +0 -0
  235. /package/src/{adapter/types → gpu-type-utils}/shader-types.ts +0 -0
  236. /package/src/{adapter/types → gpu-type-utils}/vertex-formats.ts +0 -0
package/dist/dist.dev.js CHANGED
@@ -49,7 +49,6 @@ var __exports__ = (() => {
49
49
  Resource: () => Resource,
50
50
  Sampler: () => Sampler,
51
51
  Shader: () => Shader,
52
- StatsManager: () => StatsManager,
53
52
  Texture: () => Texture,
54
53
  TextureView: () => TextureView,
55
54
  TransformFeedback: () => TransformFeedback,
@@ -58,18 +57,10 @@ var __exports__ = (() => {
58
57
  UniformStore: () => UniformStore,
59
58
  VERSION: () => VERSION2,
60
59
  VertexArray: () => VertexArray,
61
- assert: () => assert2,
62
- cancelAnimationFrame: () => cancelAnimationFrame,
63
- cast: () => cast,
64
- checkProps: () => checkProps,
65
60
  decodeShaderAttributeType: () => decodeShaderAttributeType,
66
61
  decodeShaderUniformType: () => decodeShaderUniformType,
67
62
  decodeTextureFormat: () => decodeTextureFormat,
68
63
  decodeVertexFormat: () => decodeVertexFormat,
69
- deepEqual: () => deepEqual,
70
- fillArray: () => fillArray,
71
- formatCompilerLog: () => formatCompilerLog,
72
- formatValue: () => formatValue,
73
64
  getAttributeInfosFromLayouts: () => getAttributeInfosFromLayouts,
74
65
  getDataTypeFromTypedArray: () => getDataTypeFromTypedArray,
75
66
  getScratchArray: () => getScratchArray,
@@ -77,59 +68,41 @@ var __exports__ = (() => {
77
68
  getTypedArrayFromDataType: () => getTypedArrayFromDataType,
78
69
  getVertexFormatFromAttribute: () => getVertexFormatFromAttribute,
79
70
  glsl: () => glsl,
80
- isNumberArray: () => isNumberArray,
81
- isObjectEmpty: () => isObjectEmpty,
82
- isTypedArray: () => isTypedArray,
83
- isUniformValue: () => isUniformValue,
84
- loadFile: () => loadFile,
85
- loadImage: () => loadImage,
86
- loadImageBitmap: () => loadImageBitmap,
87
- loadScript: () => loadScript,
88
71
  log: () => log,
89
- luma: () => luma,
90
- makeRandomNumberGenerator: () => makeRandomNumberGenerator,
91
- mergeShaderLayout: () => mergeShaderLayout,
92
- random: () => random,
93
- requestAnimationFrame: () => requestAnimationFrame,
94
- setPathPrefix: () => setPathPrefix,
95
- splitUniformsAndBindings: () => splitUniformsAndBindings,
96
- stubRemovedMethods: () => stubRemovedMethods,
97
- uid: () => uid
72
+ luma: () => luma
98
73
  });
99
74
 
75
+ // ../../node_modules/@probe.gl/env/dist/lib/globals.js
76
+ var window_ = globalThis;
77
+ var document_ = globalThis.document || {};
78
+ var process_ = globalThis.process || {};
79
+ var console_ = globalThis.console;
80
+ var navigator_ = globalThis.navigator || {};
81
+
100
82
  // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
101
83
  function isElectron(mockUserAgent) {
102
- if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
84
+ if (typeof window !== "undefined" && window.process?.type === "renderer") {
103
85
  return true;
104
86
  }
105
- if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
87
+ if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
106
88
  return true;
107
89
  }
108
- const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
90
+ const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
109
91
  const userAgent = mockUserAgent || realUserAgent;
110
- if (userAgent && userAgent.indexOf("Electron") >= 0) {
111
- return true;
112
- }
113
- return false;
92
+ return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
114
93
  }
115
94
 
116
95
  // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
117
96
  function isBrowser() {
118
- const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
97
+ const isNode = (
98
+ // @ts-expect-error
99
+ typeof process === "object" && String(process) === "[object process]" && !process?.browser
100
+ );
119
101
  return !isNode || isElectron();
120
102
  }
121
103
 
122
- // ../../node_modules/@probe.gl/env/dist/lib/globals.js
123
- var self_ = globalThis.self || globalThis.window || globalThis.global;
124
- var window_ = globalThis.window || globalThis.self || globalThis.global;
125
- var document_ = globalThis.document || {};
126
- var process_ = globalThis.process || {};
127
- var console_ = globalThis.console;
128
- var navigator_ = globalThis.navigator || {};
129
-
130
- // ../../node_modules/@probe.gl/env/dist/utils/globals.js
131
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
132
- var isBrowser2 = isBrowser();
104
+ // ../../node_modules/@probe.gl/env/dist/index.js
105
+ var VERSION = true ? "4.0.7" : "untranspiled source";
133
106
 
134
107
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
135
108
  function getStorage(type) {
@@ -144,11 +117,7 @@ var __exports__ = (() => {
144
117
  }
145
118
  }
146
119
  var LocalStorage = class {
147
- constructor(id, defaultConfig) {
148
- let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
149
- this.storage = void 0;
150
- this.id = void 0;
151
- this.config = void 0;
120
+ constructor(id, defaultConfig, type = "sessionStorage") {
152
121
  this.storage = getStorage(type);
153
122
  this.id = id;
154
123
  this.config = defaultConfig;
@@ -164,6 +133,7 @@ var __exports__ = (() => {
164
133
  this.storage.setItem(this.id, serialized);
165
134
  }
166
135
  }
136
+ // Get config from persistent store, if available
167
137
  _loadConfiguration() {
168
138
  let configuration = {};
169
139
  if (this.storage) {
@@ -189,22 +159,10 @@ var __exports__ = (() => {
189
159
  }
190
160
  return formatted;
191
161
  }
192
- function leftPad(string) {
193
- let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
162
+ function leftPad(string, length = 8) {
194
163
  const padLength = Math.max(length - string.length, 0);
195
164
  return `${" ".repeat(padLength)}${string}`;
196
165
  }
197
- function formatImage(image, message, scale) {
198
- let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
199
- const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
200
- if (image.width > maxWidth) {
201
- scale = Math.min(scale, maxWidth / image.width);
202
- }
203
- const width = image.width * scale;
204
- const height = image.height * scale;
205
- const style = ["font-size:1px;", `padding:${Math.floor(height / 2)}px ${Math.floor(width / 2)}px;`, `line-height:${height}px;`, `background:url(${imageUrl});`, `background-size:${width}px ${height}px;`, "color:transparent;"].join("");
206
- return [`${message} %c+`, style];
207
- }
208
166
 
209
167
  // ../../node_modules/@probe.gl/log/dist/utils/color.js
210
168
  var COLOR;
@@ -249,8 +207,7 @@ var __exports__ = (() => {
249
207
  }
250
208
 
251
209
  // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
252
- function autobind(obj) {
253
- let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
210
+ function autobind(obj, predefined = ["constructor"]) {
254
211
  const proto = Object.getPrototypeOf(obj);
255
212
  const propNames = Object.getOwnPropertyNames(proto);
256
213
  const object = obj;
@@ -275,11 +232,9 @@ var __exports__ = (() => {
275
232
  function getHiResTimestamp() {
276
233
  let timestamp;
277
234
  if (isBrowser() && window_.performance) {
278
- var _window$performance, _window$performance$n;
279
- timestamp = window_ === null || window_ === void 0 ? void 0 : (_window$performance = window_.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
235
+ timestamp = window_?.performance?.now?.();
280
236
  } else if ("hrtime" in process_) {
281
- var _process$hrtime;
282
- const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
237
+ const timeParts = process_?.hrtime?.();
283
238
  timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
284
239
  } else {
285
240
  timestamp = Date.now();
@@ -302,21 +257,12 @@ var __exports__ = (() => {
302
257
  function noop() {
303
258
  }
304
259
  var cache = {};
305
- var ONCE = {
306
- once: true
307
- };
260
+ var ONCE = { once: true };
308
261
  var Log = class {
309
- constructor() {
310
- let {
311
- id
312
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
313
- id: ""
314
- };
315
- this.id = void 0;
262
+ constructor({ id } = { id: "" }) {
316
263
  this.VERSION = VERSION;
317
264
  this._startTs = getHiResTimestamp();
318
265
  this._deltaTs = getHiResTimestamp();
319
- this._storage = void 0;
320
266
  this.userData = {};
321
267
  this.LOG_THROTTLE_TIMEOUT = 0;
322
268
  this.id = id;
@@ -338,42 +284,44 @@ var __exports__ = (() => {
338
284
  getLevel() {
339
285
  return this._storage.config.level;
340
286
  }
287
+ /** @return milliseconds, with fractions */
341
288
  getTotal() {
342
289
  return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
343
290
  }
291
+ /** @return milliseconds, with fractions */
344
292
  getDelta() {
345
293
  return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
346
294
  }
295
+ /** @deprecated use logLevel */
347
296
  set priority(newPriority) {
348
297
  this.level = newPriority;
349
298
  }
299
+ /** @deprecated use logLevel */
350
300
  get priority() {
351
301
  return this.level;
352
302
  }
303
+ /** @deprecated use logLevel */
353
304
  getPriority() {
354
305
  return this.level;
355
306
  }
356
- enable() {
357
- let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
358
- this._storage.setConfiguration({
359
- enabled
360
- });
307
+ // Configure
308
+ enable(enabled = true) {
309
+ this._storage.setConfiguration({ enabled });
361
310
  return this;
362
311
  }
363
312
  setLevel(level) {
364
- this._storage.setConfiguration({
365
- level
366
- });
313
+ this._storage.setConfiguration({ level });
367
314
  return this;
368
315
  }
316
+ /** return the current status of the setting */
369
317
  get(setting) {
370
318
  return this._storage.config[setting];
371
319
  }
320
+ // update the status of the setting
372
321
  set(setting, value) {
373
- this._storage.setConfiguration({
374
- [setting]: value
375
- });
322
+ this._storage.setConfiguration({ [setting]: value });
376
323
  }
324
+ /** Logs the current settings as a table */
377
325
  settings() {
378
326
  if (console.table) {
379
327
  console.table(this._storage.config);
@@ -381,8 +329,11 @@ var __exports__ = (() => {
381
329
  console.log(this._storage.config);
382
330
  }
383
331
  }
332
+ // Unconditional logging
384
333
  assert(condition, message) {
385
- assert(condition, message);
334
+ if (!condition) {
335
+ throw new Error(message || "Assertion failed");
336
+ }
386
337
  }
387
338
  warn(message) {
388
339
  return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
@@ -390,9 +341,11 @@ var __exports__ = (() => {
390
341
  error(message) {
391
342
  return this._getLogFunction(0, message, originalConsole.error, arguments);
392
343
  }
344
+ /** Print a deprecation warning */
393
345
  deprecated(oldUsage, newUsage) {
394
346
  return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
395
347
  }
348
+ /** Print a removal warning */
396
349
  removed(oldUsage, newUsage) {
397
350
  return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
398
351
  }
@@ -411,6 +364,7 @@ var __exports__ = (() => {
411
364
  once(logLevel, message) {
412
365
  return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
413
366
  }
367
+ /** Logs an object as a table */
414
368
  table(logLevel, table, columns) {
415
369
  if (table) {
416
370
  return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
@@ -419,27 +373,6 @@ var __exports__ = (() => {
419
373
  }
420
374
  return noop;
421
375
  }
422
- image(_ref) {
423
- let {
424
- logLevel,
425
- priority,
426
- image,
427
- message = "",
428
- scale = 1
429
- } = _ref;
430
- if (!this._shouldLog(logLevel || priority)) {
431
- return noop;
432
- }
433
- return isBrowser() ? logImageInBrowser({
434
- image,
435
- message,
436
- scale
437
- }) : logImageInNode({
438
- image,
439
- message,
440
- scale
441
- });
442
- }
443
376
  time(logLevel, message) {
444
377
  return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
445
378
  }
@@ -449,30 +382,19 @@ var __exports__ = (() => {
449
382
  timeStamp(logLevel, message) {
450
383
  return this._getLogFunction(logLevel, message, console.timeStamp || noop);
451
384
  }
452
- group(logLevel, message) {
453
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
454
- collapsed: false
455
- };
456
- const options = normalizeArguments({
457
- logLevel,
458
- message,
459
- opts
460
- });
461
- const {
462
- collapsed
463
- } = opts;
385
+ group(logLevel, message, opts = { collapsed: false }) {
386
+ const options = normalizeArguments({ logLevel, message, opts });
387
+ const { collapsed } = opts;
464
388
  options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
465
389
  return this._getLogFunction(options);
466
390
  }
467
- groupCollapsed(logLevel, message) {
468
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
469
- return this.group(logLevel, message, Object.assign({}, opts, {
470
- collapsed: true
471
- }));
391
+ groupCollapsed(logLevel, message, opts = {}) {
392
+ return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
472
393
  }
473
394
  groupEnd(logLevel) {
474
395
  return this._getLogFunction(logLevel, "", console.groupEnd || noop);
475
396
  }
397
+ // EXPERIMENTAL
476
398
  withGroup(logLevel, message, func) {
477
399
  this.group(logLevel, message)();
478
400
  try {
@@ -486,17 +408,14 @@ var __exports__ = (() => {
486
408
  console.trace();
487
409
  }
488
410
  }
411
+ // PRIVATE METHODS
412
+ /** Deduces log level from a variety of arguments */
489
413
  _shouldLog(logLevel) {
490
414
  return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
491
415
  }
492
416
  _getLogFunction(logLevel, message, method, args, opts) {
493
417
  if (this._shouldLog(logLevel)) {
494
- opts = normalizeArguments({
495
- logLevel,
496
- message,
497
- args,
498
- opts
499
- });
418
+ opts = normalizeArguments({ logLevel, message, args, opts });
500
419
  method = method || opts.method;
501
420
  assert(method);
502
421
  opts.total = this.getTotal();
@@ -536,10 +455,7 @@ var __exports__ = (() => {
536
455
  return resolvedLevel;
537
456
  }
538
457
  function normalizeArguments(opts) {
539
- const {
540
- logLevel,
541
- message
542
- } = opts;
458
+ const { logLevel, message } = opts;
543
459
  opts.logLevel = normalizeLogLevel(logLevel);
544
460
  const args = opts.args ? Array.from(opts.args) : [];
545
461
  while (args.length && args.shift() !== message) {
@@ -562,9 +478,7 @@ var __exports__ = (() => {
562
478
  }
563
479
  const messageType = typeof opts.message;
564
480
  assert(messageType === "string" || messageType === "object");
565
- return Object.assign(opts, {
566
- args
567
- }, opts.opts);
481
+ return Object.assign(opts, { args }, opts.opts);
568
482
  }
569
483
  function decorateMessage(id, message, opts) {
570
484
  if (typeof message === "string") {
@@ -574,43 +488,6 @@ var __exports__ = (() => {
574
488
  }
575
489
  return message;
576
490
  }
577
- function logImageInNode(_ref2) {
578
- let {
579
- image,
580
- message = "",
581
- scale = 1
582
- } = _ref2;
583
- console.warn("removed");
584
- return noop;
585
- }
586
- function logImageInBrowser(_ref3) {
587
- let {
588
- image,
589
- message = "",
590
- scale = 1
591
- } = _ref3;
592
- if (typeof image === "string") {
593
- const img = new Image();
594
- img.onload = () => {
595
- const args = formatImage(img, message, scale);
596
- console.log(...args);
597
- };
598
- img.src = image;
599
- return noop;
600
- }
601
- const element = image.nodeName || "";
602
- if (element.toLowerCase() === "img") {
603
- console.log(...formatImage(image, message, scale));
604
- return noop;
605
- }
606
- if (element.toLowerCase() === "canvas") {
607
- const img = new Image();
608
- img.onload = () => console.log(...formatImage(img, message, scale));
609
- img.src = image.toDataURL();
610
- return noop;
611
- }
612
- return noop;
613
- }
614
491
  function getTableHeader(table) {
615
492
  for (const key in table) {
616
493
  for (const title in table[key]) {
@@ -620,10 +497,11 @@ var __exports__ = (() => {
620
497
  return "empty";
621
498
  }
622
499
 
500
+ // ../../node_modules/@probe.gl/log/dist/init.js
501
+ globalThis.probe = {};
502
+
623
503
  // ../../node_modules/@probe.gl/log/dist/index.js
624
- var dist_default = new Log({
625
- id: "@probe.gl/log"
626
- });
504
+ var dist_default = new Log({ id: "@probe.gl/log" });
627
505
 
628
506
  // src/utils/log.ts
629
507
  var log = new Log({ id: "luma.gl" });
@@ -645,8 +523,6 @@ var __exports__ = (() => {
645
523
  // ../../node_modules/@probe.gl/stats/dist/lib/stat.js
646
524
  var Stat = class {
647
525
  constructor(name2, type) {
648
- this.name = void 0;
649
- this.type = void 0;
650
526
  this.sampleSize = 1;
651
527
  this.time = 0;
652
528
  this.count = 0;
@@ -681,26 +557,31 @@ var __exports__ = (() => {
681
557
  this.sampleSize = samples;
682
558
  return this;
683
559
  }
560
+ /** Call to increment count (+1) */
684
561
  incrementCount() {
685
562
  this.addCount(1);
686
563
  return this;
687
564
  }
565
+ /** Call to decrement count (-1) */
688
566
  decrementCount() {
689
567
  this.subtractCount(1);
690
568
  return this;
691
569
  }
570
+ /** Increase count */
692
571
  addCount(value) {
693
572
  this._count += value;
694
573
  this._samples++;
695
574
  this._checkSampling();
696
575
  return this;
697
576
  }
577
+ /** Decrease count */
698
578
  subtractCount(value) {
699
579
  this._count -= value;
700
580
  this._samples++;
701
581
  this._checkSampling();
702
582
  return this;
703
583
  }
584
+ /** Add an arbitrary timing and bump the count */
704
585
  addTime(time) {
705
586
  this._time += time;
706
587
  this.lastTiming = time;
@@ -708,11 +589,13 @@ var __exports__ = (() => {
708
589
  this._checkSampling();
709
590
  return this;
710
591
  }
592
+ /** Start a timer */
711
593
  timeStart() {
712
594
  this._startTime = getHiResTimestamp2();
713
595
  this._timerPending = true;
714
596
  return this;
715
597
  }
598
+ /** End a timer. Adds to time and bumps the timing count. */
716
599
  timeEnd() {
717
600
  if (!this._timerPending) {
718
601
  return this;
@@ -725,18 +608,22 @@ var __exports__ = (() => {
725
608
  getSampleAverageCount() {
726
609
  return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
727
610
  }
611
+ /** Calculate average time / count for the previous window */
728
612
  getSampleAverageTime() {
729
613
  return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
730
614
  }
615
+ /** Calculate counts per second for the previous window */
731
616
  getSampleHz() {
732
617
  return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
733
618
  }
734
619
  getAverageCount() {
735
620
  return this.samples > 0 ? this.count / this.samples : 0;
736
621
  }
622
+ /** Calculate average time / count */
737
623
  getAverageTime() {
738
624
  return this.samples > 0 ? this.time / this.samples : 0;
739
625
  }
626
+ /** Calculate counts per second */
740
627
  getHz() {
741
628
  return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
742
629
  }
@@ -757,23 +644,20 @@ var __exports__ = (() => {
757
644
  // ../../node_modules/@probe.gl/stats/dist/lib/stats.js
758
645
  var Stats = class {
759
646
  constructor(options) {
760
- this.id = void 0;
761
647
  this.stats = {};
762
648
  this.id = options.id;
763
649
  this.stats = {};
764
650
  this._initializeStats(options.stats);
765
651
  Object.seal(this);
766
652
  }
767
- get(name2) {
768
- let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
769
- return this._getOrCreate({
770
- name: name2,
771
- type
772
- });
653
+ /** Acquire a stat. Create if it doesn't exist. */
654
+ get(name2, type = "count") {
655
+ return this._getOrCreate({ name: name2, type });
773
656
  }
774
657
  get size() {
775
658
  return Object.keys(this.stats).length;
776
659
  }
660
+ /** Reset all stats */
777
661
  reset() {
778
662
  for (const stat of Object.values(this.stats)) {
779
663
  stat.reset();
@@ -797,15 +681,11 @@ var __exports__ = (() => {
797
681
  });
798
682
  return table;
799
683
  }
800
- _initializeStats() {
801
- let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
684
+ _initializeStats(stats = []) {
802
685
  stats.forEach((stat) => this._getOrCreate(stat));
803
686
  }
804
687
  _getOrCreate(stat) {
805
- const {
806
- name: name2,
807
- type
808
- } = stat;
688
+ const { name: name2, type } = stat;
809
689
  let result = this.stats[name2];
810
690
  if (!result) {
811
691
  if (stat instanceof Stat) {
@@ -860,32 +740,13 @@ var __exports__ = (() => {
860
740
  }
861
741
  var VERSION2 = initializeLuma();
862
742
 
863
- // src/utils/is-array.ts
864
- function isTypedArray(value) {
865
- return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
866
- }
867
- function isNumberArray(value) {
868
- if (Array.isArray(value)) {
869
- return value.length === 0 || typeof value[0] === "number" ? value : null;
870
- }
871
- return isTypedArray(value);
872
- }
873
-
874
- // src/utils/utils.ts
743
+ // src/utils/uid.ts
875
744
  var uidCounters = {};
876
745
  function uid(id = "id") {
877
746
  uidCounters[id] = uidCounters[id] || 1;
878
747
  const count = uidCounters[id]++;
879
748
  return `${id}-${count}`;
880
749
  }
881
- function isObjectEmpty(obj) {
882
- let isEmpty = true;
883
- for (const key in obj) {
884
- isEmpty = false;
885
- break;
886
- }
887
- return isEmpty;
888
- }
889
750
 
890
751
  // src/adapter/resources/resource.ts
891
752
  var Resource = class {
@@ -1050,17 +911,17 @@ var __exports__ = (() => {
1050
911
  debugData = new ArrayBuffer(0);
1051
912
  /** This doesn't handle partial non-zero offset updates correctly */
1052
913
  _setDebugData(data, byteOffset, byteLength) {
1053
- const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
914
+ const arrayBuffer2 = ArrayBuffer.isView(data) ? data.buffer : data;
1054
915
  const debugDataLength = Math.min(
1055
916
  data ? data.byteLength : byteLength,
1056
917
  _Buffer.DEBUG_DATA_MAX_LENGTH
1057
918
  );
1058
- if (data === null) {
919
+ if (arrayBuffer2 === null) {
1059
920
  this.debugData = new ArrayBuffer(debugDataLength);
1060
- } else if (byteOffset === 0 && byteLength === data.byteLength) {
1061
- this.debugData = buffer.slice(0, debugDataLength);
921
+ } else if (byteOffset === 0 && byteLength === arrayBuffer2.byteLength) {
922
+ this.debugData = arrayBuffer2.slice(0, debugDataLength);
1062
923
  } else {
1063
- this.debugData = buffer.slice(byteOffset, byteOffset + debugDataLength);
924
+ this.debugData = arrayBuffer2.slice(byteOffset, byteOffset + debugDataLength);
1064
925
  }
1065
926
  }
1066
927
  };
@@ -1094,7 +955,7 @@ var __exports__ = (() => {
1094
955
  /** Max amount of debug data saved. Two vec4's */
1095
956
  __publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
1096
957
 
1097
- // src/adapter/type-utils/decode-data-type.ts
958
+ // src/gpu-type-utils/decode-data-type.ts
1098
959
  function decodeVertexType(type) {
1099
960
  const dataType = TYPE_MAP[type];
1100
961
  const bytes = getDataTypeBytes(dataType);
@@ -1138,7 +999,7 @@ var __exports__ = (() => {
1138
999
  sint32: 4
1139
1000
  };
1140
1001
 
1141
- // src/adapter/type-utils/decode-texture-format.ts
1002
+ // src/gpu-type-utils/decode-texture-format.ts
1142
1003
  var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
1143
1004
  "bc1",
1144
1005
  "bc2",
@@ -1227,7 +1088,7 @@ var __exports__ = (() => {
1227
1088
  yield* this.features;
1228
1089
  }
1229
1090
  has(feature) {
1230
- return !this.disabledFeatures[feature] && this.features.has(feature);
1091
+ return !this.disabledFeatures?.[feature] && this.features.has(feature);
1231
1092
  }
1232
1093
  };
1233
1094
  var _Device = class {
@@ -1260,6 +1121,10 @@ var __exports__ = (() => {
1260
1121
  loseDevice() {
1261
1122
  return false;
1262
1123
  }
1124
+ /** Report error (normally for unhandled device errors) */
1125
+ error(error) {
1126
+ this.props.onError(error);
1127
+ }
1263
1128
  /** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
1264
1129
  getCanvasContext() {
1265
1130
  if (!this.canvasContext) {
@@ -1267,10 +1132,8 @@ var __exports__ = (() => {
1267
1132
  }
1268
1133
  return this.canvasContext;
1269
1134
  }
1135
+ // createTexture(data: Promise<TextureData>): Texture;
1270
1136
  createTexture(props) {
1271
- if (props instanceof Promise || typeof props === "string") {
1272
- props = { data: props };
1273
- }
1274
1137
  return this._createTexture(props);
1275
1138
  }
1276
1139
  createCommandEncoder(props = {}) {
@@ -1344,42 +1207,35 @@ var __exports__ = (() => {
1344
1207
  // width are height are only used by headless gl
1345
1208
  height: 600,
1346
1209
  requestMaxLimits: true,
1210
+ // Callbacks
1211
+ onError: (error) => log.error(error.message),
1212
+ gl: null,
1213
+ // alpha: undefined,
1214
+ // depth: undefined,
1215
+ // stencil: undefined,
1216
+ // antialias: undefined,
1217
+ // premultipliedAlpha: undefined,
1218
+ // preserveDrawingBuffer: undefined,
1219
+ // failIfMajorPerformanceCaveat: undefined
1347
1220
  debug: Boolean(log.get("debug")),
1348
1221
  // Instrument context (at the expense of performance)
1349
1222
  spector: Boolean(log.get("spector")),
1350
1223
  // Initialize the SpectorJS WebGL debugger
1351
- break: [],
1224
+ break: log.get("break") || [],
1352
1225
  // TODO - Change these after confirming things work as expected
1353
1226
  initalizeFeatures: true,
1354
1227
  disabledFeatures: {
1355
1228
  "compilation-status-async-webgl": true
1356
1229
  },
1357
- // alpha: undefined,
1358
- // depth: undefined,
1359
- // stencil: undefined,
1360
- // antialias: undefined,
1361
- // premultipliedAlpha: undefined,
1362
- // preserveDrawingBuffer: undefined,
1363
- // failIfMajorPerformanceCaveat: undefined
1364
- gl: null,
1365
- // Callbacks
1366
- onError: (error) => log.error(error.message)
1230
+ _factoryDestroyPolicy: "unused"
1367
1231
  });
1368
1232
  __publicField(Device, "VERSION", VERSION2);
1369
1233
 
1370
- // src/utils/assert.ts
1371
- function assert2(condition, message) {
1372
- if (!condition) {
1373
- throw new Error(message || "luma.gl: assertion failed.");
1374
- }
1375
- }
1376
-
1377
- // src/lib/luma.ts
1234
+ // src/adapter/luma.ts
1378
1235
  var deviceMap = /* @__PURE__ */ new Map();
1379
- var luma = class {
1236
+ var _luma = class {
1380
1237
  static registerDevices(deviceClasses) {
1381
1238
  for (const deviceClass of deviceClasses) {
1382
- assert2(deviceClass.type && deviceClass.isSupported && deviceClass.create);
1383
1239
  deviceMap.set(deviceClass.type, deviceClass);
1384
1240
  }
1385
1241
  }
@@ -1390,7 +1246,7 @@ var __exports__ = (() => {
1390
1246
  return Array.from(deviceMap).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
1391
1247
  }
1392
1248
  static setDefaultDeviceProps(props) {
1393
- Object.assign(Device.defaultProps, props);
1249
+ Object.assign(_luma.defaultProps, props);
1394
1250
  }
1395
1251
  /** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
1396
1252
  static async attachDevice(props) {
@@ -1413,20 +1269,22 @@ var __exports__ = (() => {
1413
1269
  }
1414
1270
  /** Creates a device. Asynchronously. */
1415
1271
  static async createDevice(props = {}) {
1416
- props = { ...Device.defaultProps, ...props };
1272
+ props = { ..._luma.defaultProps, ...props };
1417
1273
  if (props.gl) {
1418
1274
  props.type = "webgl";
1419
1275
  }
1420
1276
  const devices = getDeviceMap(props.devices) || deviceMap;
1277
+ let WebGPUDevice;
1278
+ let WebGLDevice;
1421
1279
  switch (props.type) {
1422
1280
  case "webgpu":
1423
- let WebGPUDevice = devices.get("webgpu");
1281
+ WebGPUDevice = devices.get("webgpu");
1424
1282
  if (WebGPUDevice) {
1425
1283
  return await WebGPUDevice.create(props);
1426
1284
  }
1427
1285
  break;
1428
1286
  case "webgl":
1429
- let WebGLDevice = devices.get("webgl");
1287
+ WebGLDevice = devices.get("webgl");
1430
1288
  if (WebGLDevice) {
1431
1289
  return await WebGLDevice.create(props);
1432
1290
  }
@@ -1468,6 +1326,7 @@ var __exports__ = (() => {
1468
1326
  };
1469
1327
  }
1470
1328
  };
1329
+ var luma = _luma;
1471
1330
  __publicField(luma, "defaultProps", {
1472
1331
  ...Device.defaultProps,
1473
1332
  type: "best-available",
@@ -1778,20 +1637,102 @@ var __exports__ = (() => {
1778
1637
  height;
1779
1638
  /** depth of this texture */
1780
1639
  depth;
1640
+ /** mip levels in this texture */
1641
+ mipLevels;
1781
1642
  /** "Time" of last update. Monotonically increasing timestamp */
1782
1643
  updateTimestamp;
1644
+ /** Check if data is an external image */
1645
+ static isExternalImage(data) {
1646
+ return typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement;
1647
+ }
1648
+ /** Determine size (width and height) of provided image data */
1649
+ static getExternalImageSize(data) {
1650
+ if (typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement) {
1651
+ return { width: data.width, height: data.height };
1652
+ }
1653
+ if (typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement) {
1654
+ return { width: data.naturalWidth, height: data.naturalHeight };
1655
+ }
1656
+ if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
1657
+ return { width: data.videoWidth, height: data.videoHeight };
1658
+ }
1659
+ return null;
1660
+ }
1661
+ /** Check if texture data is a typed array */
1662
+ isTextureLevelData(data) {
1663
+ const typedArray = data?.data;
1664
+ return ArrayBuffer.isView(typedArray);
1665
+ }
1666
+ /** Get the size of the texture described by the provided TextureData */
1667
+ getTextureDataSize(data) {
1668
+ if (!data) {
1669
+ return null;
1670
+ }
1671
+ if (ArrayBuffer.isView(data)) {
1672
+ return null;
1673
+ }
1674
+ if (Array.isArray(data)) {
1675
+ return this.getTextureDataSize(data[0]);
1676
+ }
1677
+ if (_Texture.isExternalImage(data)) {
1678
+ return _Texture.getExternalImageSize(data);
1679
+ }
1680
+ if (data && typeof data === "object" && data.constructor === Object) {
1681
+ const untypedData = data;
1682
+ return { width: untypedData.width, height: untypedData.height };
1683
+ }
1684
+ throw new Error("texture size deduction failed");
1685
+ }
1686
+ /** Calculate the number of mip levels for a texture of width and height */
1687
+ getMipLevelCount(width, height) {
1688
+ return Math.floor(Math.log2(Math.max(width, height))) + 1;
1689
+ }
1690
+ /** Convert luma.gl cubemap face constants to depth index */
1691
+ getCubeFaceDepth(face) {
1692
+ switch (face) {
1693
+ case "+X":
1694
+ return 0;
1695
+ case "-X":
1696
+ return 1;
1697
+ case "+Y":
1698
+ return 2;
1699
+ case "-Y":
1700
+ return 3;
1701
+ case "+Z":
1702
+ return 4;
1703
+ case "-Z":
1704
+ return 5;
1705
+ default:
1706
+ throw new Error(face);
1707
+ }
1708
+ }
1783
1709
  /** Do not use directly. Create with device.createTexture() */
1784
- constructor(device, props, defaultProps = _Texture.defaultProps) {
1785
- super(device, props, defaultProps);
1710
+ constructor(device, props) {
1711
+ super(device, props, _Texture.defaultProps);
1786
1712
  this.dimension = this.props.dimension;
1787
1713
  this.format = this.props.format;
1788
1714
  this.width = this.props.width;
1789
1715
  this.height = this.props.height;
1790
1716
  this.depth = this.props.depth;
1717
+ if (this.props.width === void 0 || this.props.height === void 0) {
1718
+ const size = this.getTextureDataSize(this.props.data);
1719
+ this.width = size?.width || 1;
1720
+ this.height = size?.height || 1;
1721
+ }
1722
+ if (this.props.mipmaps && this.props.mipLevels === void 0) {
1723
+ this.props.mipLevels = "pyramid";
1724
+ }
1725
+ this.mipLevels = this.props.mipLevels === "pyramid" ? this.getMipLevelCount(this.width, this.height) : this.props.mipLevels || 1;
1791
1726
  this.updateTimestamp = device.incrementTimestamp();
1792
1727
  }
1793
1728
  };
1794
1729
  var Texture = _Texture;
1730
+ __publicField(Texture, "COPY_SRC", 1);
1731
+ __publicField(Texture, "COPY_DST", 2);
1732
+ __publicField(Texture, "TEXTURE", 4);
1733
+ __publicField(Texture, "STORAGE", 8);
1734
+ __publicField(Texture, "RENDER_ATTACHMENT", 16);
1735
+ __publicField(Texture, "CubeFaces", ["+X", "-X", "+Y", "-Y", "+Z", "-Z"]);
1795
1736
  __publicField(Texture, "defaultProps", {
1796
1737
  ...Resource.defaultProps,
1797
1738
  data: null,
@@ -1800,23 +1741,14 @@ var __exports__ = (() => {
1800
1741
  width: void 0,
1801
1742
  height: void 0,
1802
1743
  depth: 1,
1803
- mipmaps: true,
1804
- // type: undefined,
1744
+ mipmaps: false,
1805
1745
  compressed: false,
1806
- // mipLevels: 1,
1807
1746
  usage: 0,
1808
- // usage: GPUTextureUsage.COPY_DST
1809
1747
  mipLevels: void 0,
1810
1748
  samples: void 0,
1811
- type: void 0,
1812
1749
  sampler: {},
1813
1750
  view: void 0
1814
1751
  });
1815
- __publicField(Texture, "COPY_SRC", 1);
1816
- __publicField(Texture, "COPY_DST", 2);
1817
- __publicField(Texture, "TEXTURE_BINDING", 4);
1818
- __publicField(Texture, "STORAGE_BINDING", 8);
1819
- __publicField(Texture, "RENDER_ATTACHMENT", 16);
1820
1752
 
1821
1753
  // src/adapter/resources/texture-view.ts
1822
1754
  var _TextureView = class extends Resource {
@@ -1852,11 +1784,11 @@ var __exports__ = (() => {
1852
1784
  var ExternalTexture = _ExternalTexture;
1853
1785
  __publicField(ExternalTexture, "defaultProps", {
1854
1786
  ...Resource.defaultProps,
1855
- source: null,
1787
+ source: void 0,
1856
1788
  colorSpace: "srgb"
1857
1789
  });
1858
1790
 
1859
- // src/lib/compiler-log/format-compiler-log.ts
1791
+ // src/adapter-utils/format-compiler-log.ts
1860
1792
  function formatCompilerLog(shaderLog, source, options) {
1861
1793
  let formattedLog = "";
1862
1794
  const lines = source.split(/\r?\n/);
@@ -1922,31 +1854,6 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
1922
1854
  return unsafe.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#039;");
1923
1855
  }
1924
1856
 
1925
- // src/lib/compiler-log/get-shader-info.ts
1926
- function getShaderInfo(source, defaultName) {
1927
- return {
1928
- name: getShaderName(source, defaultName),
1929
- language: "glsl",
1930
- version: getShaderVersion(source)
1931
- };
1932
- }
1933
- function getShaderName(shader, defaultName = "unnamed") {
1934
- const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
1935
- const match = SHADER_NAME_REGEXP.exec(shader);
1936
- return match ? match[1] : defaultName;
1937
- }
1938
- function getShaderVersion(source) {
1939
- let version = 100;
1940
- const words = source.match(/[^\s]+/g);
1941
- if (words && words.length >= 2 && words[0] === "#version") {
1942
- const v = parseInt(words[1], 10);
1943
- if (Number.isFinite(v)) {
1944
- version = v;
1945
- }
1946
- }
1947
- return version;
1948
- }
1949
-
1950
1857
  // src/adapter/resources/shader.ts
1951
1858
  var _Shader = class extends Resource {
1952
1859
  get [Symbol.toStringTag]() {
@@ -1994,12 +1901,15 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
1994
1901
  this._displayShaderLog(messages);
1995
1902
  }
1996
1903
  // PRIVATE
1997
- /** In-browser UI logging of errors */
1904
+ /**
1905
+ * In-browser UI logging of errors
1906
+ * TODO - this HTML formatting code should not be in Device, should be pluggable
1907
+ */
1998
1908
  _displayShaderLog(messages) {
1999
1909
  if (typeof document === "undefined" || !document?.createElement) {
2000
1910
  return;
2001
1911
  }
2002
- const shaderName = getShaderInfo(this.source).name;
1912
+ const shaderName = getShaderName(this.source);
2003
1913
  const shaderTitle = `${this.stage} ${shaderName}`;
2004
1914
  let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
2005
1915
  const translatedSource = this.getTranslatedSource();
@@ -2020,9 +1930,7 @@ ${htmlLog}
2020
1930
  button.style.textAlign = "left";
2021
1931
  document.body.appendChild(button);
2022
1932
  const errors = document.getElementsByClassName("luma-compiler-log-error");
2023
- if (errors[0]?.scrollIntoView) {
2024
- errors[0].scrollIntoView();
2025
- }
1933
+ errors[0]?.scrollIntoView();
2026
1934
  button.onclick = () => {
2027
1935
  const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
2028
1936
  navigator.clipboard.writeText(dataURI);
@@ -2040,7 +1948,12 @@ ${htmlLog}
2040
1948
  debug: "errors"
2041
1949
  });
2042
1950
  function getShaderIdFromProps(props) {
2043
- return getShaderInfo(props.source).name || props.id || uid(`unnamed ${props.stage}-shader`);
1951
+ return getShaderName(props.source) || props.id || uid(`unnamed ${props.stage}-shader`);
1952
+ }
1953
+ function getShaderName(shader, defaultName = "unnamed") {
1954
+ const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
1955
+ const match = SHADER_NAME_REGEXP.exec(shader);
1956
+ return match ? match[1] : defaultName;
2044
1957
  }
2045
1958
 
2046
1959
  // src/adapter/resources/sampler.ts
@@ -2078,10 +1991,6 @@ ${htmlLog}
2078
1991
  width;
2079
1992
  /** Height of all attachments in this framebuffer */
2080
1993
  height;
2081
- /** Color attachments */
2082
- colorAttachments = [];
2083
- /** Depth-stencil attachment, if provided */
2084
- depthStencilAttachment = null;
2085
1994
  constructor(device, props = {}) {
2086
1995
  super(device, props, _Framebuffer.defaultProps);
2087
1996
  this.width = this.props.width;
@@ -2158,7 +2067,7 @@ ${htmlLog}
2158
2067
  for (let i = 0; i < this.colorAttachments.length; ++i) {
2159
2068
  if (this.colorAttachments[i]) {
2160
2069
  const resizedTexture = this.device._createTexture({
2161
- ...this.colorAttachments[i].props,
2070
+ ...this.colorAttachments[i].texture.props,
2162
2071
  width,
2163
2072
  height
2164
2073
  });
@@ -2169,7 +2078,7 @@ ${htmlLog}
2169
2078
  }
2170
2079
  if (this.depthStencilAttachment) {
2171
2080
  const resizedTexture = this.device._createTexture({
2172
- ...this.depthStencilAttachment.props,
2081
+ ...this.depthStencilAttachment.texture.props,
2173
2082
  width,
2174
2083
  height
2175
2084
  });
@@ -2283,8 +2192,11 @@ ${htmlLog}
2283
2192
  return "ComputePipeline";
2284
2193
  }
2285
2194
  hash = "";
2195
+ /** The merged shader layout */
2196
+ shaderLayout;
2286
2197
  constructor(device, props) {
2287
2198
  super(device, props, _ComputePipeline.defaultProps);
2199
+ this.shaderLayout = props.shaderLayout;
2288
2200
  }
2289
2201
  };
2290
2202
  var ComputePipeline = _ComputePipeline;
@@ -2345,7 +2257,7 @@ ${htmlLog}
2345
2257
  ...Resource.defaultProps
2346
2258
  });
2347
2259
 
2348
- // src/adapter/type-utils/decode-attribute-type.ts
2260
+ // src/gpu-type-utils/decode-attribute-type.ts
2349
2261
  function decodeShaderAttributeType(attributeType) {
2350
2262
  const [dataType, components] = TYPE_INFO[attributeType];
2351
2263
  const integer = dataType === "i32" || dataType === "u32";
@@ -2407,7 +2319,7 @@ ${htmlLog}
2407
2319
  // 'bool-webgl': 4,
2408
2320
  };
2409
2321
 
2410
- // src/adapter/type-utils/decode-vertex-format.ts
2322
+ // src/gpu-type-utils/decode-vertex-format.ts
2411
2323
  function decodeVertexFormat(format) {
2412
2324
  let webglOnly;
2413
2325
  if (format.endsWith("-webgl")) {
@@ -2432,15 +2344,14 @@ ${htmlLog}
2432
2344
  return result;
2433
2345
  }
2434
2346
 
2435
- // src/adapter/attribute-utils/get-attribute-from-layouts.ts
2347
+ // src/adapter-utils/get-attribute-from-layouts.ts
2436
2348
  function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
2437
2349
  const attributeInfos = {};
2438
2350
  for (const attribute of shaderLayout.attributes) {
2439
- attributeInfos[attribute.name] = getAttributeInfoFromLayouts(
2440
- shaderLayout,
2441
- bufferLayout,
2442
- attribute.name
2443
- );
2351
+ const attributeInfo = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
2352
+ if (attributeInfo) {
2353
+ attributeInfos[attribute.name] = attributeInfo;
2354
+ }
2444
2355
  }
2445
2356
  return attributeInfos;
2446
2357
  }
@@ -2454,7 +2365,10 @@ ${htmlLog}
2454
2365
  }
2455
2366
  function getAttributeInfoFromLayouts(shaderLayout, bufferLayout, name2) {
2456
2367
  const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name2);
2457
- const bufferMapping = getAttributeFromBufferLayout(bufferLayout, name2);
2368
+ const bufferMapping = getAttributeFromBufferLayout(
2369
+ bufferLayout,
2370
+ name2
2371
+ );
2458
2372
  if (!shaderDeclaration) {
2459
2373
  return null;
2460
2374
  }
@@ -2475,7 +2389,7 @@ ${htmlLog}
2475
2389
  normalized: vertexFormatInfo.normalized,
2476
2390
  // integer is a property of the shader declaration
2477
2391
  integer: attributeTypeInfo.integer,
2478
- stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,
2392
+ stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode || "vertex",
2479
2393
  byteOffset: bufferMapping?.byteOffset || 0,
2480
2394
  byteStride: bufferMapping?.byteStride || 0
2481
2395
  };
@@ -2540,28 +2454,13 @@ ${htmlLog}
2540
2454
  stepMode: bufferLayout.stepMode,
2541
2455
  vertexFormat: attributeMapping.format,
2542
2456
  byteOffset: attributeMapping.byteOffset,
2457
+ // @ts-ignore
2543
2458
  byteStride
2544
2459
  };
2545
2460
  }
2546
2461
  }
2547
2462
  return null;
2548
2463
  }
2549
- function mergeShaderLayout(baseLayout, overrideLayout) {
2550
- const mergedLayout = {
2551
- ...baseLayout,
2552
- attributes: baseLayout.attributes.map((attribute) => ({ ...attribute }))
2553
- };
2554
- for (const attribute of overrideLayout?.attributes || []) {
2555
- const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
2556
- if (!baseAttribute) {
2557
- log.warn(`shader layout attribute ${attribute.name} not present in shader`);
2558
- } else {
2559
- baseAttribute.type = attribute.type || baseAttribute.type;
2560
- baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
2561
- }
2562
- }
2563
- return mergedLayout;
2564
- }
2565
2464
 
2566
2465
  // src/adapter/resources/vertex-array.ts
2567
2466
  var _VertexArray = class extends Resource {
@@ -2580,9 +2479,13 @@ ${htmlLog}
2580
2479
  super(device, props, _VertexArray.defaultProps);
2581
2480
  this.maxVertexAttributes = device.limits.maxVertexAttributes;
2582
2481
  this.attributes = new Array(this.maxVertexAttributes).fill(null);
2482
+ const { shaderLayout, bufferLayout } = props.renderPipeline || {};
2483
+ if (!shaderLayout || !bufferLayout) {
2484
+ throw new Error("VertexArray");
2485
+ }
2583
2486
  this.attributeInfos = getAttributeInfosByLocation(
2584
- props.renderPipeline.shaderLayout,
2585
- props.renderPipeline.bufferLayout,
2487
+ shaderLayout,
2488
+ bufferLayout,
2586
2489
  this.maxVertexAttributes
2587
2490
  );
2588
2491
  }
@@ -2630,7 +2533,7 @@ ${htmlLog}
2630
2533
  count: void 0
2631
2534
  });
2632
2535
 
2633
- // src/adapter/type-utils/decode-shader-types.ts
2536
+ // src/gpu-type-utils/decode-shader-types.ts
2634
2537
  var UNIFORM_FORMATS = {
2635
2538
  f32: { type: "f32", components: 1 },
2636
2539
  i32: { type: "i32", components: 1 },
@@ -2657,7 +2560,6 @@ ${htmlLog}
2657
2560
  };
2658
2561
  function decodeShaderUniformType(format) {
2659
2562
  const decoded = UNIFORM_FORMATS[format];
2660
- assert2(format);
2661
2563
  return decoded;
2662
2564
  }
2663
2565
  function alignTo(size, count) {
@@ -2683,27 +2585,19 @@ ${htmlLog}
2683
2585
  const scratchArrayBuffer = getScratchArrayBuffer(Type.BYTES_PER_ELEMENT * length);
2684
2586
  return new Type(scratchArrayBuffer, 0, length);
2685
2587
  }
2686
- function fillArray(options) {
2687
- const { target, source, start = 0, count = 1 } = options;
2688
- const length = source.length;
2689
- const total = count * length;
2690
- let copied = 0;
2691
- for (let i = start; copied < length; copied++) {
2692
- target[i++] = source[copied];
2693
- }
2694
- while (copied < total) {
2695
- if (copied < total - copied) {
2696
- target.copyWithin(start + copied, start, start + copied);
2697
- copied *= 2;
2698
- } else {
2699
- target.copyWithin(start + copied, start, start + total - copied);
2700
- copied = total;
2701
- }
2588
+
2589
+ // src/utils/is-array.ts
2590
+ function isTypedArray(value) {
2591
+ return ArrayBuffer.isView(value) && !(value instanceof DataView);
2592
+ }
2593
+ function isNumberArray(value) {
2594
+ if (Array.isArray(value)) {
2595
+ return value.length === 0 || typeof value[0] === "number";
2702
2596
  }
2703
- return options.target;
2597
+ return isTypedArray(value);
2704
2598
  }
2705
2599
 
2706
- // src/lib/uniforms/uniform-buffer-layout.ts
2600
+ // src/portable/uniform-buffer-layout.ts
2707
2601
  var minBufferSize = 1024;
2708
2602
  var UniformBufferLayout = class {
2709
2603
  layout = {};
@@ -2752,14 +2646,13 @@ ${htmlLog}
2752
2646
  }
2753
2647
  typedArray[offset] = Number(value);
2754
2648
  } else {
2755
- const numericArray = isNumberArray(value);
2756
- if (!numericArray) {
2649
+ if (!isNumberArray(value)) {
2757
2650
  log.warn(
2758
2651
  `Supplied value for multi component / array uniform ${name2} is not a numeric array: ${value}`
2759
2652
  )();
2760
2653
  continue;
2761
2654
  }
2762
- typedArray.set(numericArray, offset);
2655
+ typedArray.set(value, offset);
2763
2656
  }
2764
2657
  }
2765
2658
  return new Uint8Array(arrayBuffer2);
@@ -2780,12 +2673,12 @@ ${htmlLog}
2780
2673
  if (a !== b) {
2781
2674
  return false;
2782
2675
  }
2783
- const arrayA = isNumberArray(a);
2784
- if (!arrayA) {
2676
+ const arrayA = a;
2677
+ const arrayB = b;
2678
+ if (!isNumberArray(arrayA)) {
2785
2679
  return false;
2786
2680
  }
2787
- const arrayB = isNumberArray(b);
2788
- if (arrayB && arrayA.length === arrayB.length) {
2681
+ if (isNumberArray(arrayB) && arrayA.length === arrayB.length) {
2789
2682
  for (let i = 0; i < arrayA.length; ++i) {
2790
2683
  if (arrayB[i] !== arrayA[i]) {
2791
2684
  return false;
@@ -2795,14 +2688,13 @@ ${htmlLog}
2795
2688
  return true;
2796
2689
  }
2797
2690
  function arrayCopy(a) {
2798
- const numberArray = isNumberArray(a);
2799
- if (numberArray) {
2800
- return numberArray.slice();
2691
+ if (isNumberArray(a)) {
2692
+ return a.slice();
2801
2693
  }
2802
2694
  return a;
2803
2695
  }
2804
2696
 
2805
- // src/lib/uniforms/uniform-block.ts
2697
+ // src/portable/uniform-block.ts
2806
2698
  var UniformBlock = class {
2807
2699
  name;
2808
2700
  uniforms = {};
@@ -2811,7 +2703,7 @@ ${htmlLog}
2811
2703
  bindingLayout = {};
2812
2704
  needsRedraw = "initialized";
2813
2705
  constructor(props) {
2814
- this.name = props?.name;
2706
+ this.name = props?.name || "unnamed";
2815
2707
  if (props?.name && props?.shaderLayout) {
2816
2708
  const binding = props?.shaderLayout.bindings?.find(
2817
2709
  (binding2) => binding2.type === "uniform" && binding2.name === props?.name
@@ -2854,7 +2746,7 @@ ${htmlLog}
2854
2746
  }
2855
2747
  };
2856
2748
 
2857
- // src/lib/uniforms/uniform-store.ts
2749
+ // src/portable/uniform-store.ts
2858
2750
  var UniformStore = class {
2859
2751
  /** Stores the uniform values for each uniform block */
2860
2752
  uniformBlocks = /* @__PURE__ */ new Map();
@@ -2888,18 +2780,18 @@ ${htmlLog}
2888
2780
  */
2889
2781
  setUniforms(uniforms) {
2890
2782
  for (const [blockName, uniformValues] of Object.entries(uniforms)) {
2891
- this.uniformBlocks.get(blockName).setUniforms(uniformValues);
2783
+ this.uniformBlocks.get(blockName)?.setUniforms(uniformValues);
2892
2784
  }
2893
2785
  this.updateUniformBuffers();
2894
2786
  }
2895
2787
  /** Get the required minimum length of the uniform buffer */
2896
2788
  getUniformBufferByteLength(uniformBufferName) {
2897
- return this.uniformBufferLayouts.get(uniformBufferName).byteLength;
2789
+ return this.uniformBufferLayouts.get(uniformBufferName)?.byteLength || 0;
2898
2790
  }
2899
2791
  /** Get formatted binary memory that can be uploaded to a buffer */
2900
2792
  getUniformBufferData(uniformBufferName) {
2901
- const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2902
- return this.uniformBufferLayouts.get(uniformBufferName).getData(uniformValues);
2793
+ const uniformValues = this.uniformBlocks.get(uniformBufferName)?.getAllUniforms() || {};
2794
+ return this.uniformBufferLayouts.get(uniformBufferName)?.getData(uniformValues);
2903
2795
  }
2904
2796
  /**
2905
2797
  * Creates an unmanaged uniform buffer (umnanaged means that application is responsible for destroying it)
@@ -2947,12 +2839,12 @@ ${htmlLog}
2947
2839
  const uniformBlock = this.uniformBlocks.get(uniformBufferName);
2948
2840
  const uniformBuffer = this.uniformBuffers.get(uniformBufferName);
2949
2841
  let reason = false;
2950
- if (uniformBuffer && uniformBlock.needsRedraw) {
2842
+ if (uniformBuffer && uniformBlock?.needsRedraw) {
2951
2843
  reason ||= uniformBlock.needsRedraw;
2952
2844
  const uniformBufferData = this.getUniformBufferData(uniformBufferName);
2953
2845
  const uniformBuffer2 = this.uniformBuffers.get(uniformBufferName);
2954
- uniformBuffer2.write(uniformBufferData);
2955
- const uniformValues = this.uniformBlocks.get(uniformBufferName).getAllUniforms();
2846
+ uniformBuffer2?.write(uniformBufferData);
2847
+ const uniformValues = this.uniformBlocks.get(uniformBufferName)?.getAllUniforms();
2956
2848
  log.log(
2957
2849
  4,
2958
2850
  `Writing to uniform buffer ${String(uniformBufferName)}`,
@@ -2964,7 +2856,7 @@ ${htmlLog}
2964
2856
  }
2965
2857
  };
2966
2858
 
2967
- // src/adapter/type-utils/vertex-format-from-attribute.ts
2859
+ // src/gpu-type-utils/vertex-format-from-attribute.ts
2968
2860
  function getDataTypeFromTypedArray(arrayOrType) {
2969
2861
  const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
2970
2862
  switch (type) {
@@ -3041,220 +2933,6 @@ ${htmlLog}
3041
2933
  return `${dataType}x${components}`;
3042
2934
  }
3043
2935
 
3044
- // src/utils/cast.ts
3045
- function cast(value) {
3046
- return value;
3047
- }
3048
-
3049
- // src/lib/uniforms/uniform.ts
3050
- function isUniformValue(value) {
3051
- return isNumberArray(value) !== null || typeof value === "number" || typeof value === "boolean";
3052
- }
3053
- function splitUniformsAndBindings(uniforms) {
3054
- const result = { bindings: {}, uniforms: {} };
3055
- Object.keys(uniforms).forEach((name2) => {
3056
- const uniform = uniforms[name2];
3057
- if (isUniformValue(uniform)) {
3058
- result.uniforms[name2] = uniform;
3059
- } else {
3060
- result.bindings[name2] = uniform;
3061
- }
3062
- });
3063
- return result;
3064
- }
3065
-
3066
- // src/utils/format-value.ts
3067
- function formatArrayValue(v, opts = {}) {
3068
- const { maxElts = 16, size = 1 } = opts;
3069
- let string = "[";
3070
- for (let i = 0; i < v.length && i < maxElts; ++i) {
3071
- if (i > 0) {
3072
- string += `,${i % size === 0 ? " " : ""}`;
3073
- }
3074
- string += formatValue(v[i], opts);
3075
- }
3076
- const terminator = v.length > maxElts ? "..." : "]";
3077
- return `${string}${terminator}`;
3078
- }
3079
- function formatValue(v, opts = {}) {
3080
- const EPSILON = 1e-16;
3081
- const { isInteger = false } = opts;
3082
- if (Array.isArray(v) || ArrayBuffer.isView(v)) {
3083
- return formatArrayValue(v, opts);
3084
- }
3085
- if (typeof v !== "number") {
3086
- return String(v);
3087
- }
3088
- if (Math.abs(v) < EPSILON) {
3089
- return isInteger ? "0" : "0.";
3090
- }
3091
- if (isInteger) {
3092
- return v.toFixed(0);
3093
- }
3094
- if (Math.abs(v) > 100 && Math.abs(v) < 1e4) {
3095
- return v.toFixed(0);
3096
- }
3097
- const string = v.toPrecision(2);
3098
- const decimal = string.indexOf(".0");
3099
- return decimal === string.length - 2 ? string.slice(0, -1) : string;
3100
- }
3101
-
3102
- // src/utils/stub-methods.ts
3103
- function stubRemovedMethods(instance, className, version, methodNames) {
3104
- const upgradeMessage = `See luma.gl ${version} Upgrade Guide at https://luma.gl/docs/upgrade-guide`;
3105
- const prototype = Object.getPrototypeOf(instance);
3106
- methodNames.forEach((methodName) => {
3107
- if (prototype.methodName) {
3108
- return;
3109
- }
3110
- prototype[methodName] = () => {
3111
- log.removed(`Calling removed method ${className}.${methodName}: `, upgradeMessage)();
3112
- throw new Error(methodName);
3113
- };
3114
- });
3115
- }
3116
-
3117
- // src/utils/check-props.ts
3118
- function checkProps(className, props, propChecks) {
3119
- const { removedProps = {}, deprecatedProps = {}, replacedProps = {} } = propChecks;
3120
- for (const propName in removedProps) {
3121
- if (propName in props) {
3122
- const replacementProp = removedProps[propName];
3123
- const replacement = replacementProp ? `${className}.${removedProps[propName]}` : "N/A";
3124
- log.removed(`${className}.${propName}`, replacement)();
3125
- }
3126
- }
3127
- for (const propName in deprecatedProps) {
3128
- if (propName in props) {
3129
- const replacementProp = deprecatedProps[propName];
3130
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
3131
- }
3132
- }
3133
- let newProps = null;
3134
- for (const [propName, replacementProp] of Object.entries(replacedProps)) {
3135
- if (propName in props) {
3136
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
3137
- newProps = newProps || Object.assign({}, props);
3138
- newProps[replacementProp] = props[propName];
3139
- delete newProps[propName];
3140
- }
3141
- }
3142
- return newProps || props;
3143
- }
3144
-
3145
- // src/utils/load-file.ts
3146
- var pathPrefix = "";
3147
- function setPathPrefix(prefix) {
3148
- pathPrefix = prefix;
3149
- }
3150
- async function loadFile(url, options) {
3151
- url = url.startsWith("http") ? url : pathPrefix + url;
3152
- const dataType = options?.dataType || "text";
3153
- const response = await fetch(url, options);
3154
- return await response[dataType]();
3155
- }
3156
- async function loadImageBitmap(url, opts) {
3157
- const image = new Image();
3158
- image.crossOrigin = opts?.crossOrigin || "anonymous";
3159
- image.src = url.startsWith("http") ? url : pathPrefix + url;
3160
- await image.decode();
3161
- return await createImageBitmap(image);
3162
- }
3163
- async function loadImage(url, opts) {
3164
- return await new Promise((resolve, reject) => {
3165
- try {
3166
- const image = new Image();
3167
- image.onload = () => resolve(image);
3168
- image.onerror = () => reject(new Error(`Could not load image ${url}.`));
3169
- image.crossOrigin = opts?.crossOrigin || "anonymous";
3170
- image.src = url.startsWith("http") ? url : pathPrefix + url;
3171
- } catch (error) {
3172
- reject(error);
3173
- }
3174
- });
3175
- }
3176
- async function loadScript(scriptUrl, scriptId) {
3177
- const head = document.getElementsByTagName("head")[0];
3178
- if (!head) {
3179
- throw new Error("loadScript");
3180
- }
3181
- const script = document.createElement("script");
3182
- script.setAttribute("type", "text/javascript");
3183
- script.setAttribute("src", scriptUrl);
3184
- if (scriptId) {
3185
- script.id = scriptId;
3186
- }
3187
- return new Promise((resolve, reject) => {
3188
- script.onload = resolve;
3189
- script.onerror = (error) => reject(new Error(`Unable to load script '${scriptUrl}': ${error}`));
3190
- head.appendChild(script);
3191
- });
3192
- }
3193
-
3194
- // src/utils/random.ts
3195
- function makeRandomNumberGenerator() {
3196
- let s = 1;
3197
- let c = 1;
3198
- return () => {
3199
- s = Math.sin(c * 17.23);
3200
- c = Math.cos(s * 27.92);
3201
- return fract(Math.abs(s * c) * 1432.71);
3202
- };
3203
- }
3204
- function fract(n) {
3205
- return n - Math.floor(n);
3206
- }
3207
- var random = makeRandomNumberGenerator();
3208
-
3209
- // src/utils/deep-equal.ts
3210
- function deepEqual(a, b, depth) {
3211
- if (a === b) {
3212
- return true;
3213
- }
3214
- if (!depth || !a || !b) {
3215
- return false;
3216
- }
3217
- if (Array.isArray(a)) {
3218
- if (!Array.isArray(b) || a.length !== b.length) {
3219
- return false;
3220
- }
3221
- for (let i = 0; i < a.length; i++) {
3222
- if (!deepEqual(a[i], b[i], depth - 1)) {
3223
- return false;
3224
- }
3225
- }
3226
- return true;
3227
- }
3228
- if (Array.isArray(b)) {
3229
- return false;
3230
- }
3231
- if (typeof a === "object" && typeof b === "object") {
3232
- const aKeys = Object.keys(a);
3233
- const bKeys = Object.keys(b);
3234
- if (aKeys.length !== bKeys.length) {
3235
- return false;
3236
- }
3237
- for (const key of aKeys) {
3238
- if (!b.hasOwnProperty(key)) {
3239
- return false;
3240
- }
3241
- if (!deepEqual(a[key], b[key], depth - 1)) {
3242
- return false;
3243
- }
3244
- }
3245
- return true;
3246
- }
3247
- return false;
3248
- }
3249
-
3250
- // src/utils/request-animation-frame.ts
3251
- function requestAnimationFrame(callback) {
3252
- return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame(callback) : setTimeout(callback, 1e3 / 60);
3253
- }
3254
- function cancelAnimationFrame(timerId) {
3255
- return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame(timerId) : clearTimeout(timerId);
3256
- }
3257
-
3258
2936
  // src/index.ts
3259
2937
  var glsl = (x) => `${x}`;
3260
2938
  return __toCommonJS(bundle_exports);