@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
@@ -1,16 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- // Node.js polyfills for requestAnimationFrame and cancelAnimationFrame
5
- /* global window, setTimeout, clearTimeout */
6
- // / <reference types="@types/node" />
7
- export function requestAnimationFrame(callback) {
8
- return typeof window !== 'undefined' && window.requestAnimationFrame
9
- ? window.requestAnimationFrame(callback)
10
- : setTimeout(callback, 1000 / 60);
11
- }
12
- export function cancelAnimationFrame(timerId) {
13
- return typeof window !== 'undefined' && window.cancelAnimationFrame
14
- ? window.cancelAnimationFrame(timerId)
15
- : clearTimeout(timerId);
16
- }
@@ -1,2 +0,0 @@
1
- export declare function stubRemovedMethods(instance: any, className: string, version: string, methodNames: string[]): void;
2
- //# sourceMappingURL=stub-methods.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stub-methods.d.ts","sourceRoot":"","sources":["../../src/utils/stub-methods.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,QAiBtB"}
@@ -1,19 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- import { log } from "./log.js";
5
- // Install stubs for removed methods
6
- export function stubRemovedMethods(instance, className, version, methodNames) {
7
- const upgradeMessage = `See luma.gl ${version} Upgrade Guide at \
8
- https://luma.gl/docs/upgrade-guide`;
9
- const prototype = Object.getPrototypeOf(instance);
10
- methodNames.forEach((methodName) => {
11
- if (prototype.methodName) {
12
- return;
13
- }
14
- prototype[methodName] = () => {
15
- log.removed(`Calling removed method ${className}.${methodName}: `, upgradeMessage)();
16
- throw new Error(methodName);
17
- };
18
- });
19
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Returns a UID.
3
- * @param id= - Identifier base name
4
- * @return uid
5
- **/
6
- export declare function uid(id?: string): string;
7
- /** Returns true if given object is empty, false otherwise. */
8
- export declare function isObjectEmpty(obj: object): boolean;
9
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAMA;;;;IAII;AACJ,wBAAgB,GAAG,CAAC,EAAE,GAAE,MAAa,GAAG,MAAM,CAI7C;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASlD"}
@@ -1,37 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import type {Buffer} from '../resources/buffer';
6
- // import type {VertexFormat} from './data-formats';
7
-
8
- // ACCESSORS
9
-
10
- /**
11
- * Attribute descriptor object
12
- * @deprecated Use ShaderLayout
13
- */
14
- export interface AccessorObject {
15
- buffer?: Buffer;
16
- // format: VertexFormat;
17
- offset?: number;
18
- // can now be described with single WebGPU-style `format` string
19
-
20
- //
21
- stride?: number;
22
-
23
- /** @deprecated - Use accessor.stepMode */
24
- divisor?: number;
25
-
26
- /** @deprecated - Infer from format */
27
- type?: number;
28
- /** @deprecated - Infer from format */
29
- size?: number;
30
- /** @deprecated - Infer from format */
31
- normalized?: boolean;
32
- /** @deprecated - Infer from format */
33
- integer?: boolean;
34
-
35
- /** @deprecated */
36
- index?: number;
37
- }
package/src/init.ts DELETED
@@ -1,53 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import {isBrowser} from '@probe.gl/env';
6
- import {log} from './utils/log';
7
- import {lumaStats} from './utils/stats-manager';
8
-
9
- declare global {
10
- // eslint-disable-next-line no-var
11
- var luma: any;
12
- }
13
-
14
- /**
15
- * By adding the result of init() to Device.VERSION we guarantee it will be called
16
- * @returns version
17
- */
18
- function initializeLuma(): string {
19
- // Version detection using babel plugin
20
- // @ts-expect-error
21
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'running from source';
22
-
23
- const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
24
- // Assign luma.log.level in console to control logging: \
25
- // 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
26
- // luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
27
-
28
- if (globalThis.luma && globalThis.luma.VERSION !== VERSION) {
29
- throw new Error(
30
- `luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION}`
31
- );
32
- }
33
-
34
- if (!globalThis.luma) {
35
- if (isBrowser()) {
36
- log.log(1, `${VERSION} - ${STARTUP_MESSAGE}`)();
37
- }
38
-
39
- globalThis.luma = globalThis.luma || {
40
- VERSION,
41
- version: VERSION,
42
- log,
43
-
44
- // A global stats object that various components can add information to
45
- // E.g. see webgl/resource.js
46
- stats: lumaStats
47
- };
48
- }
49
-
50
- return VERSION;
51
- }
52
-
53
- export const VERSION = initializeLuma();
@@ -1,42 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- // Note: This was the only dependency that made @luma.gl/webgl depend on @luma.gl/shadertools
6
- // This file was coped from shadertools to avoid the dependency
7
-
8
- /** Information extracted from shader source code */
9
- export type ShaderInfo = {
10
- name: string;
11
- language: 'glsl' | 'wgsl';
12
- version: number;
13
- };
14
-
15
- /** Extracts information from shader source code */
16
- export function getShaderInfo(source: string, defaultName?: string): ShaderInfo {
17
- return {
18
- name: getShaderName(source, defaultName),
19
- language: 'glsl',
20
- version: getShaderVersion(source)
21
- };
22
- }
23
-
24
- /** Extracts GLSLIFY style naming of shaders: `#define SHADER_NAME ...` */
25
- function getShaderName(shader: string, defaultName: string = 'unnamed'): string {
26
- const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
27
- const match = SHADER_NAME_REGEXP.exec(shader);
28
- return match ? match[1] : defaultName;
29
- }
30
-
31
- /** returns GLSL shader version of given shader string */
32
- function getShaderVersion(source: string): number {
33
- let version = 100;
34
- const words = source.match(/[^\s]+/g);
35
- if (words && words.length >= 2 && words[0] === '#version') {
36
- const v = parseInt(words[1], 10);
37
- if (Number.isFinite(v)) {
38
- version = v;
39
- }
40
- }
41
- return version;
42
- }
package/src/lib/luma.ts DELETED
@@ -1,190 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import type {Log} from '@probe.gl/log';
6
- import type {DeviceProps} from '../adapter/device';
7
- import {Device} from '../adapter/device';
8
- import {StatsManager} from '../utils/stats-manager';
9
- import {lumaStats} from '../utils/stats-manager';
10
- import {log} from '../utils/log';
11
- import {assert} from '../utils/assert';
12
-
13
- const deviceMap = new Map<string, typeof Device>();
14
-
15
- /** Properties for creating a new device */
16
- export type CreateDeviceProps = DeviceProps & {
17
- /** Selects the type of device. `best-available` uses webgpu if available, then webgl. */
18
- type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available';
19
- devices?: any[];
20
- };
21
-
22
- /** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */
23
- export type AttachDeviceProps = DeviceProps & {
24
- /** Externally created WebGL context or WebGPU device */
25
- handle: WebGL2RenderingContext; // | GPUDevice;
26
- devices?: any[];
27
- };
28
-
29
- /**
30
- * Entry point to the luma.gl GPU abstraction
31
- * Register WebGPU and/or WebGL devices (controls application bundle size)
32
- * Run-time selection of the first available Device
33
- */
34
- export class luma {
35
- static defaultProps: Required<CreateDeviceProps> = {
36
- ...Device.defaultProps,
37
- type: 'best-available',
38
- devices: undefined!
39
- };
40
-
41
- /** Global stats for all devices */
42
- static stats: StatsManager = lumaStats;
43
-
44
- /** Global log */
45
- static log: Log = log;
46
-
47
- static registerDevices(deviceClasses: any[] /* : typeof Device */): void {
48
- for (const deviceClass of deviceClasses) {
49
- assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
50
- deviceMap.set(deviceClass.type, deviceClass);
51
- }
52
- }
53
-
54
- static getAvailableDevices(): string[] {
55
- // @ts-expect-error
56
- return Array.from(deviceMap).map(Device => Device.type);
57
- }
58
-
59
- static getSupportedDevices(): string[] {
60
- return (
61
- Array.from(deviceMap)
62
- // @ts-expect-error
63
- .filter(Device => Device.isSupported())
64
- // @ts-expect-error
65
- .map(Device => Device.type)
66
- );
67
- }
68
-
69
- static setDefaultDeviceProps(props: CreateDeviceProps): void {
70
- Object.assign(Device.defaultProps, props);
71
- }
72
-
73
- /** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
74
- static async attachDevice(props: AttachDeviceProps): Promise<Device> {
75
- const devices = getDeviceMap(props.devices) || deviceMap;
76
-
77
- // WebGL
78
- if (props.handle instanceof WebGL2RenderingContext) {
79
- const WebGLDevice = devices.get('webgl') as any;
80
- if (WebGLDevice) {
81
- return (await WebGLDevice.attach(props.handle)) as Device;
82
- }
83
- }
84
-
85
- // TODO - WebGPU does not yet have a stable API
86
- // if (props.handle instanceof GPUDevice) {
87
- // const WebGPUDevice = devices.get('webgpu') as any;
88
- // if (WebGPUDevice) {
89
- // return (await WebGPUDevice.attach(props.handle)) as Device;
90
- // }
91
- // }
92
-
93
- // null
94
- if (props.handle === null) {
95
- const UnknownDevice = devices.get('unknown') as any;
96
- if (UnknownDevice) {
97
- return (await UnknownDevice.attach(null)) as Device;
98
- }
99
- }
100
-
101
- throw new Error(
102
- 'Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'
103
- );
104
- }
105
-
106
- /** Creates a device. Asynchronously. */
107
- static async createDevice(props: CreateDeviceProps = {}): Promise<Device> {
108
- props = {...luma.defaultProps, ...props};
109
- if (props.gl) {
110
- props.type = 'webgl';
111
- }
112
-
113
- const devices = getDeviceMap(props.devices) || deviceMap;
114
-
115
- switch (props.type) {
116
- case 'webgpu':
117
- let WebGPUDevice = devices.get('webgpu') as any;
118
- if (WebGPUDevice) {
119
- return await WebGPUDevice.create(props);
120
- }
121
- break;
122
-
123
- case 'webgl':
124
- let WebGLDevice = devices.get('webgl') as any;
125
- if (WebGLDevice) {
126
- return await WebGLDevice.create(props);
127
- }
128
- break;
129
-
130
- case 'unknown':
131
- const UnknownDevice = devices.get('unknown') as any;
132
- if (UnknownDevice) {
133
- return await UnknownDevice.create(props);
134
- }
135
- break;
136
-
137
- case 'best-available':
138
- WebGPUDevice = devices.get('webgpu') as any;
139
- if (WebGPUDevice?.isSupported?.()) {
140
- return await WebGPUDevice.create(props);
141
- }
142
- WebGLDevice = devices.get('webgl');
143
- if (WebGLDevice?.isSupported?.()) {
144
- return await WebGLDevice.create(props);
145
- }
146
- break;
147
- }
148
- throw new Error(
149
- 'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'
150
- );
151
- }
152
-
153
- static enforceWebGL2(enforce: boolean = true): void {
154
- const prototype = HTMLCanvasElement.prototype as any;
155
- if (!enforce && prototype.originalGetContext) {
156
- // Reset the original getContext function
157
- prototype.getContext = prototype.originalGetContext;
158
- prototype.originalGetContext = undefined;
159
- return;
160
- }
161
-
162
- // Store the original getContext function
163
- prototype.originalGetContext = prototype.getContext;
164
-
165
- // Override the getContext function
166
- prototype.getContext = function (contextId: string, options?: WebGLContextAttributes) {
167
- // Attempt to force WebGL2 for all WebGL1 contexts
168
- if (contextId === 'webgl' || contextId === 'experimental-webgl') {
169
- return this.originalGetContext('webgl2', options);
170
- }
171
- // For any other type, return the original context
172
- return this.originalGetContext(contextId, options);
173
- };
174
- }
175
- }
176
-
177
- /** Convert a list of devices to a map */
178
- function getDeviceMap(
179
- deviceClasses?: any[] /* : typeof Device */
180
- ): Map<string, typeof Device> | null {
181
- if (!deviceClasses || deviceClasses?.length === 0) {
182
- return null;
183
- }
184
- const map = new Map<string, typeof Device>();
185
- for (const deviceClass of deviceClasses) {
186
- // assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
187
- map.set(deviceClass.type, deviceClass);
188
- }
189
- return map;
190
- }
@@ -1,31 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import type {UniformValue} from '../../adapter/types/types';
6
- import type {Binding} from '../../adapter/types/shader-layout';
7
- import {isNumberArray} from '../../utils/is-array';
8
-
9
- export function isUniformValue(value: unknown): boolean {
10
- return isNumberArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
11
- }
12
-
13
- type UniformsAndBindings = {
14
- bindings: Record<string, Binding>;
15
- uniforms: Record<string, UniformValue>;
16
- };
17
- export function splitUniformsAndBindings(
18
- uniforms: Record<string, Binding | UniformValue>
19
- ): UniformsAndBindings {
20
- const result: UniformsAndBindings = {bindings: {}, uniforms: {}};
21
- Object.keys(uniforms).forEach(name => {
22
- const uniform = uniforms[name];
23
- if (isUniformValue(uniform)) {
24
- result.uniforms[name] = uniform as UniformValue;
25
- } else {
26
- result.bindings[name] = uniform as Binding;
27
- }
28
- });
29
-
30
- return result;
31
- }
@@ -1,11 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- // Recommendation is to ignore message but current test suite checks agains the
6
- // message so keep it for now.
7
- export function assert(condition: unknown, message?: string): void | never {
8
- if (!condition) {
9
- throw new Error(message || 'luma.gl: assertion failed.');
10
- }
11
- }
package/src/utils/cast.ts DELETED
@@ -1,8 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- /** Helper for type downcasts, e.g. Buffer -> WebGPUBuffer */
6
- export function cast<T>(value: any) {
7
- return value as T;
8
- }
@@ -1,82 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import {log} from './log';
6
-
7
- /* Use as
8
- import {checkProps} from '../util/check-props;'
9
-
10
- const PROP_CHECKS = {
11
- // Removed props no longer supported, print error and link to upgrade guide
12
- removedProps: {
13
- },
14
- // Deprecated props
15
- deprecatedProps: {
16
- offset: 'accessor',
17
- stride: 'accessor',
18
- type: 'accessor',
19
- size: 'accessor',
20
- divisor: 'accessor',
21
- normalized: 'accessor',
22
- integer: 'accessor'
23
- },
24
- // Deprecated props that can be autosubstituted, print warning and return updated props object
25
- replacedProps: {
26
- bytes: 'byteLength'
27
- }
28
- }
29
-
30
- class Buffer {
31
- setProps(props) {
32
- checkProps('Buffer', props, PROP_CHECKS);
33
- }
34
- }
35
- */
36
-
37
- export type PropChecks = {
38
- removedProps?: Record<string, any>;
39
- replacedProps?: Record<string, string>;
40
- deprecatedProps?: Record<string, string>;
41
- };
42
-
43
- export function checkProps(
44
- className: string,
45
- props: Record<string, any>,
46
- propChecks: PropChecks
47
- ): Record<string, unknown> {
48
- const {removedProps = {}, deprecatedProps = {}, replacedProps = {}} = propChecks;
49
-
50
- // removedProps: Removed props no longer supported
51
- // print error and link to upgrade guide
52
- for (const propName in removedProps) {
53
- if (propName in props) {
54
- const replacementProp = removedProps[propName];
55
- const replacement = replacementProp ? `${className}.${removedProps[propName]}` : 'N/A';
56
- log.removed(`${className}.${propName}`, replacement)();
57
- }
58
- }
59
-
60
- // deprecatedProps: Deprecated props that can not be autosubstituted
61
- // print warning and rely on caller to substitute
62
- for (const propName in deprecatedProps) {
63
- if (propName in props) {
64
- const replacementProp = deprecatedProps[propName];
65
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
66
- }
67
- }
68
-
69
- // replacedProps: Deprecated props that can be autosubstituted
70
- // print warning and return updated props object
71
- let newProps = null;
72
- for (const [propName, replacementProp] of Object.entries(replacedProps)) {
73
- if (propName in props) {
74
- log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
75
- newProps = newProps || Object.assign({}, props);
76
- newProps[replacementProp] = props[propName];
77
- delete newProps[propName];
78
- }
79
- }
80
-
81
- return newProps || props;
82
- }
@@ -1,51 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- /**
6
- * Fast partial deep equal for prop.
7
- *
8
- * @param a Prop
9
- * @param b Prop to compare against `a`
10
- * @param depth Depth to which to recurse in nested Objects/Arrays. Use 0 (default) for shallow comparison, -1 for infinite depth
11
- */
12
- /* eslint-disable complexity */
13
- export function deepEqual(a: any, b: any, depth: number): boolean {
14
- if (a === b) {
15
- return true;
16
- }
17
- if (!depth || !a || !b) {
18
- return false;
19
- }
20
- if (Array.isArray(a)) {
21
- if (!Array.isArray(b) || a.length !== b.length) {
22
- return false;
23
- }
24
- for (let i = 0; i < a.length; i++) {
25
- if (!deepEqual(a[i], b[i], depth - 1)) {
26
- return false;
27
- }
28
- }
29
- return true;
30
- }
31
- if (Array.isArray(b)) {
32
- return false;
33
- }
34
- if (typeof a === 'object' && typeof b === 'object') {
35
- const aKeys = Object.keys(a);
36
- const bKeys = Object.keys(b);
37
- if (aKeys.length !== bKeys.length) {
38
- return false;
39
- }
40
- for (const key of aKeys) {
41
- if (!b.hasOwnProperty(key)) {
42
- return false;
43
- }
44
- if (!deepEqual(a[key], b[key], depth - 1)) {
45
- return false;
46
- }
47
- }
48
- return true;
49
- }
50
- return false;
51
- }
@@ -1,47 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- /* eslint-disable no-console */
6
- import type {NumberArray} from '../types';
7
-
8
- /** TODO @deprecated - delete when confident that probe.gl logging implements all opts */
9
- function formatArrayValue(v: NumberArray, opts: {maxElts?: number; size?: number} = {}): string {
10
- const {maxElts = 16, size = 1} = opts;
11
- let string = '[';
12
- for (let i = 0; i < v.length && i < maxElts; ++i) {
13
- if (i > 0) {
14
- string += `,${i % size === 0 ? ' ' : ''}`;
15
- }
16
- string += formatValue(v[i], opts);
17
- }
18
- const terminator = v.length > maxElts ? '...' : ']';
19
- return `${string}${terminator}`;
20
- }
21
-
22
- /** TODO @deprecated - delete when confident that probe.gl logging implements all opts */
23
- export function formatValue(
24
- v: number | NumberArray | unknown,
25
- opts: {isInteger?: boolean; size?: number} = {}
26
- ): string {
27
- const EPSILON = 1e-16;
28
- const {isInteger = false} = opts;
29
- if (Array.isArray(v) || ArrayBuffer.isView(v)) {
30
- return formatArrayValue(v as NumberArray, opts);
31
- }
32
- if (typeof v !== 'number') {
33
- return String(v);
34
- }
35
- if (Math.abs(v) < EPSILON) {
36
- return isInteger ? '0' : '0.';
37
- }
38
- if (isInteger) {
39
- return v.toFixed(0);
40
- }
41
- if (Math.abs(v) > 100 && Math.abs(v) < 10000) {
42
- return v.toFixed(0);
43
- }
44
- const string = v.toPrecision(2);
45
- const decimal = string.indexOf('.0');
46
- return decimal === string.length - 2 ? string.slice(0, -1) : string;
47
- }