@luma.gl/core 9.1.9 → 9.2.0-alpha.3
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.
- package/dist/adapter/adapter.d.ts +14 -1
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +27 -0
- package/dist/adapter/adapter.js.map +1 -1
- package/dist/adapter/canvas-context.d.ts +101 -48
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +255 -153
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/device.d.ts +112 -42
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +153 -56
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.d.ts +24 -22
- package/dist/adapter/luma.d.ts.map +1 -1
- package/dist/adapter/luma.js +76 -92
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/resources/buffer.d.ts +18 -12
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +14 -18
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +1 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -3
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +9 -2
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +7 -4
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pass.d.ts +2 -2
- package/dist/adapter/resources/compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pass.js +3 -3
- package/dist/adapter/resources/compute-pass.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pipeline.js +7 -7
- package/dist/adapter/resources/compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/external-texture.d.ts +1 -1
- package/dist/adapter/resources/external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/external-texture.js +5 -5
- package/dist/adapter/resources/external-texture.js.map +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +4 -4
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +8 -9
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/pipeline-layout.d.ts.map +1 -1
- package/dist/adapter/resources/pipeline-layout.js +3 -0
- package/dist/adapter/resources/pipeline-layout.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +1 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js +5 -5
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pass.d.ts +2 -2
- package/dist/adapter/resources/render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/render-pass.js +10 -13
- package/dist/adapter/resources/render-pass.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +7 -9
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +17 -29
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +1 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/sampler.d.ts.map +1 -1
- package/dist/adapter/resources/sampler.js +1 -3
- package/dist/adapter/resources/sampler.js.map +1 -1
- package/dist/adapter/resources/shader.d.ts +2 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +14 -14
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/texture-view.d.ts +2 -2
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture-view.js +7 -7
- package/dist/adapter/resources/texture-view.js.map +1 -1
- package/dist/adapter/resources/texture.d.ts +84 -135
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +136 -152
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/resources/vertex-array.d.ts +4 -2
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.js +4 -7
- package/dist/adapter/resources/vertex-array.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +3 -3
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +7 -3
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +5 -5
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +8 -0
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +6 -5
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +8 -7
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +1162 -851
- package/dist/dist.min.js +7 -6
- package/dist/image-utils/image-types.d.ts +19 -0
- package/dist/image-utils/image-types.d.ts.map +1 -0
- package/dist/image-utils/image-types.js +34 -0
- package/dist/image-utils/image-types.js.map +1 -0
- package/dist/index.cjs +1129 -819
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +17 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -12
- package/dist/index.js.map +1 -1
- package/dist/portable/uniform-block.d.ts +2 -2
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.d.ts +4 -3
- package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.js +3 -2
- package/dist/portable/uniform-buffer-layout.js.map +1 -1
- package/dist/portable/uniform-store.d.ts +2 -2
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/shadertypes/data-types/data-types.d.ts +32 -0
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -0
- package/dist/{gpu-type-utils/texture-formats.js → shadertypes/data-types/data-types.js} +1 -1
- package/dist/shadertypes/data-types/data-types.js.map +1 -0
- package/dist/shadertypes/data-types/decode-data-types.d.ts +16 -0
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-data-types.js +74 -0
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -0
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +17 -0
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-shader-types.js +171 -0
- package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -0
- package/dist/shadertypes/data-types/shader-types.d.ts +45 -0
- package/dist/shadertypes/data-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/shader-types.js.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts +112 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.js +193 -0
- package/dist/shadertypes/textures/pixel-utils.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +18 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -0
- package/dist/{gpu-type-utils/decode-texture-format.js → shadertypes/textures/texture-format-decoder.js} +52 -13
- package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts +33 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +1 -0
- package/dist/{gpu-type-utils/texture-features.js → shadertypes/textures/texture-format-generics.js} +1 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +1 -0
- package/dist/{gpu-type-utils → shadertypes/textures}/texture-format-table.d.ts +2 -3
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -0
- package/dist/{gpu-type-utils → shadertypes/textures}/texture-format-table.js +42 -43
- package/dist/shadertypes/textures/texture-format-table.js.map +1 -0
- package/dist/shadertypes/textures/texture-formats.d.ts +90 -0
- package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/textures/texture-formats.js +58 -0
- package/dist/shadertypes/textures/texture-formats.js.map +1 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +18 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +1 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +100 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +1 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +27 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +1 -0
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/promise-utils.d.ts +6 -0
- package/dist/utils/promise-utils.d.ts.map +1 -0
- package/dist/utils/promise-utils.js +15 -0
- package/dist/utils/promise-utils.js.map +1 -0
- package/package.json +2 -2
- package/src/adapter/adapter.ts +36 -1
- package/src/adapter/canvas-context.ts +321 -198
- package/src/adapter/device.ts +261 -110
- package/src/adapter/luma.ts +97 -113
- package/src/adapter/resources/buffer.ts +45 -28
- package/src/adapter/resources/command-buffer.ts +4 -4
- package/src/adapter/resources/command-encoder.ts +15 -6
- package/src/adapter/resources/compute-pass.ts +11 -11
- package/src/adapter/resources/compute-pipeline.ts +8 -8
- package/src/adapter/resources/external-texture.ts +6 -6
- package/src/adapter/resources/framebuffer.ts +14 -15
- package/src/adapter/resources/pipeline-layout.ts +4 -0
- package/src/adapter/resources/query-set.ts +6 -6
- package/src/adapter/resources/render-pass.ts +20 -23
- package/src/adapter/resources/render-pipeline.ts +36 -42
- package/src/adapter/resources/resource.ts +1 -0
- package/src/adapter/resources/sampler.ts +1 -4
- package/src/adapter/resources/shader.ts +15 -15
- package/src/adapter/resources/texture-view.ts +12 -12
- package/src/adapter/resources/texture.ts +206 -300
- package/src/adapter/resources/vertex-array.ts +9 -10
- package/src/adapter/types/attachments.ts +5 -5
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +16 -11
- package/src/adapter/types/shader-layout.ts +8 -5
- package/src/adapter-utils/format-compiler-log.ts +8 -0
- package/src/adapter-utils/get-attribute-from-layouts.ts +17 -12
- package/src/image-utils/image-types.ts +59 -0
- package/src/index.ts +67 -47
- package/src/portable/uniform-block.ts +2 -2
- package/src/portable/uniform-buffer-layout.ts +7 -5
- package/src/portable/uniform-store.ts +2 -2
- package/src/shadertypes/data-types/data-types.ts +96 -0
- package/src/shadertypes/data-types/decode-data-types.ts +91 -0
- package/src/shadertypes/data-types/decode-shader-types.ts +211 -0
- package/src/shadertypes/data-types/shader-types.ts +87 -0
- package/src/shadertypes/textures/pixel-utils.ts +239 -0
- package/src/{gpu-type-utils/decode-texture-format.ts → shadertypes/textures/texture-format-decoder.ts} +71 -20
- package/src/shadertypes/textures/texture-format-generics.ts +190 -0
- package/src/{gpu-type-utils → shadertypes/textures}/texture-format-table.ts +63 -56
- package/src/shadertypes/textures/texture-formats.ts +334 -0
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +124 -0
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +91 -0
- package/src/types.ts +12 -5
- package/src/utils/promise-utils.ts +19 -0
- package/dist/adapter-utils/buffer-layout-helper.d.ts +0 -12
- package/dist/adapter-utils/buffer-layout-helper.d.ts.map +0 -1
- package/dist/adapter-utils/buffer-layout-helper.js +0 -41
- package/dist/adapter-utils/buffer-layout-helper.js.map +0 -1
- package/dist/adapter-utils/buffer-layout-order.d.ts +0 -4
- package/dist/adapter-utils/buffer-layout-order.d.ts.map +0 -1
- package/dist/adapter-utils/buffer-layout-order.js +0 -16
- package/dist/adapter-utils/buffer-layout-order.js.map +0 -1
- package/dist/gpu-type-utils/decode-attribute-type.d.ts +0 -20
- package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-attribute-type.js +0 -68
- package/dist/gpu-type-utils/decode-attribute-type.js.map +0 -1
- package/dist/gpu-type-utils/decode-data-type.d.ts +0 -16
- package/dist/gpu-type-utils/decode-data-type.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-data-type.js +0 -48
- package/dist/gpu-type-utils/decode-data-type.js.map +0 -1
- package/dist/gpu-type-utils/decode-shader-types.d.ts +0 -9
- package/dist/gpu-type-utils/decode-shader-types.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-shader-types.js +0 -42
- package/dist/gpu-type-utils/decode-shader-types.js.map +0 -1
- package/dist/gpu-type-utils/decode-texture-format.d.ts +0 -11
- package/dist/gpu-type-utils/decode-texture-format.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-texture-format.js.map +0 -1
- package/dist/gpu-type-utils/decode-vertex-format.d.ts +0 -22
- package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-vertex-format.js +0 -34
- package/dist/gpu-type-utils/decode-vertex-format.js.map +0 -1
- package/dist/gpu-type-utils/shader-types.d.ts +0 -21
- package/dist/gpu-type-utils/shader-types.d.ts.map +0 -1
- package/dist/gpu-type-utils/shader-types.js.map +0 -1
- package/dist/gpu-type-utils/texture-features.d.ts +0 -6
- package/dist/gpu-type-utils/texture-features.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-features.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-capabilities.d.ts +0 -21
- package/dist/gpu-type-utils/texture-format-capabilities.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-capabilities.js +0 -27
- package/dist/gpu-type-utils/texture-format-capabilities.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-info.d.ts +0 -38
- package/dist/gpu-type-utils/texture-format-info.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-info.js +0 -5
- package/dist/gpu-type-utils/texture-format-info.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-table.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-table.js.map +0 -1
- package/dist/gpu-type-utils/texture-formats.d.ts +0 -11
- package/dist/gpu-type-utils/texture-formats.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-formats.js.map +0 -1
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts +0 -10
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +0 -1
- package/dist/gpu-type-utils/vertex-format-from-attribute.js +0 -91
- package/dist/gpu-type-utils/vertex-format-from-attribute.js.map +0 -1
- package/dist/gpu-type-utils/vertex-formats.d.ts +0 -14
- package/dist/gpu-type-utils/vertex-formats.d.ts.map +0 -1
- package/dist/gpu-type-utils/vertex-formats.js.map +0 -1
- package/dist/gpu-type-utils/wgsl-utils.d.ts +0 -4
- package/dist/gpu-type-utils/wgsl-utils.d.ts.map +0 -1
- package/dist/gpu-type-utils/wgsl-utils.js +0 -20
- package/dist/gpu-type-utils/wgsl-utils.js.map +0 -1
- package/src/adapter-utils/buffer-layout-helper.ts +0 -52
- package/src/adapter-utils/buffer-layout-order.ts +0 -27
- package/src/gpu-type-utils/decode-attribute-type.ts +0 -96
- package/src/gpu-type-utils/decode-data-type.ts +0 -66
- package/src/gpu-type-utils/decode-shader-types.ts +0 -49
- package/src/gpu-type-utils/decode-vertex-format.ts +0 -53
- package/src/gpu-type-utils/shader-types.ts +0 -78
- package/src/gpu-type-utils/texture-features.ts +0 -23
- package/src/gpu-type-utils/texture-format-capabilities.ts +0 -53
- package/src/gpu-type-utils/texture-format-info.ts +0 -42
- package/src/gpu-type-utils/texture-formats.ts +0 -161
- package/src/gpu-type-utils/vertex-format-from-attribute.ts +0 -114
- package/src/gpu-type-utils/vertex-formats.ts +0 -90
- package/src/gpu-type-utils/wgsl-utils.ts +0 -22
- /package/dist/{gpu-type-utils → shadertypes/data-types}/shader-types.js +0 -0
- /package/dist/{gpu-type-utils → shadertypes/vertex-arrays}/vertex-formats.js +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -52,62 +52,33 @@ var __exports__ = (() => {
|
|
|
52
52
|
Sampler: () => Sampler,
|
|
53
53
|
Shader: () => Shader,
|
|
54
54
|
Texture: () => Texture,
|
|
55
|
+
TextureFormatDecoder: () => TextureFormatDecoder,
|
|
55
56
|
TextureView: () => TextureView,
|
|
56
57
|
TransformFeedback: () => TransformFeedback,
|
|
57
58
|
UniformBlock: () => UniformBlock,
|
|
58
59
|
UniformBufferLayout: () => UniformBufferLayout,
|
|
59
60
|
UniformStore: () => UniformStore,
|
|
60
61
|
VertexArray: () => VertexArray,
|
|
61
|
-
_BufferLayoutHelper: () => BufferLayoutHelper,
|
|
62
62
|
_getTextureFormatDefinition: () => getTextureFormatDefinition,
|
|
63
63
|
_getTextureFormatTable: () => getTextureFormatTable,
|
|
64
|
-
decodeShaderAttributeType: () => decodeShaderAttributeType,
|
|
65
|
-
decodeShaderUniformType: () => decodeShaderUniformType,
|
|
66
|
-
decodeTextureFormat: () => decodeTextureFormat,
|
|
67
|
-
decodeVertexFormat: () => decodeVertexFormat,
|
|
68
64
|
getAttributeInfosFromLayouts: () => getAttributeInfosFromLayouts,
|
|
69
|
-
|
|
65
|
+
getAttributeShaderTypeInfo: () => getAttributeShaderTypeInfo,
|
|
66
|
+
getDataType: () => getDataType,
|
|
67
|
+
getDataTypeInfo: () => getDataTypeInfo,
|
|
68
|
+
getNormalizedDataType: () => getNormalizedDataType,
|
|
70
69
|
getScratchArray: () => getScratchArray,
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
getTypedArrayConstructor: () => getTypedArrayConstructor,
|
|
71
|
+
getVariableShaderTypeInfo: () => getVariableShaderTypeInfo,
|
|
73
72
|
getVertexFormatFromAttribute: () => getVertexFormatFromAttribute,
|
|
73
|
+
getVertexFormatInfo: () => getVertexFormatInfo,
|
|
74
74
|
log: () => log,
|
|
75
75
|
luma: () => luma,
|
|
76
|
-
|
|
76
|
+
makeVertexFormat: () => makeVertexFormat,
|
|
77
|
+
readPixel: () => readPixel,
|
|
78
|
+
textureFormatDecoder: () => textureFormatDecoder,
|
|
79
|
+
writePixel: () => writePixel
|
|
77
80
|
});
|
|
78
81
|
|
|
79
|
-
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
80
|
-
var window_ = globalThis;
|
|
81
|
-
var document_ = globalThis.document || {};
|
|
82
|
-
var process_ = globalThis.process || {};
|
|
83
|
-
var console_ = globalThis.console;
|
|
84
|
-
var navigator_ = globalThis.navigator || {};
|
|
85
|
-
|
|
86
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
87
|
-
function isElectron(mockUserAgent) {
|
|
88
|
-
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
|
|
95
|
-
const userAgent = mockUserAgent || realUserAgent;
|
|
96
|
-
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
100
|
-
function isBrowser() {
|
|
101
|
-
const isNode = (
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
typeof process === "object" && String(process) === "[object process]" && !process?.browser
|
|
104
|
-
);
|
|
105
|
-
return !isNode || isElectron();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
109
|
-
var VERSION = true ? "4.0.7" : "untranspiled source";
|
|
110
|
-
|
|
111
82
|
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
112
83
|
function getHiResTimestamp() {
|
|
113
84
|
let timestamp;
|
|
@@ -316,6 +287,38 @@ var __exports__ = (() => {
|
|
|
316
287
|
};
|
|
317
288
|
var lumaStats = new StatsManager();
|
|
318
289
|
|
|
290
|
+
// ../../node_modules/@probe.gl/env/dist/lib/globals.js
|
|
291
|
+
var window_ = globalThis;
|
|
292
|
+
var document_ = globalThis.document || {};
|
|
293
|
+
var process_ = globalThis.process || {};
|
|
294
|
+
var console_ = globalThis.console;
|
|
295
|
+
var navigator_ = globalThis.navigator || {};
|
|
296
|
+
|
|
297
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
298
|
+
function isElectron(mockUserAgent) {
|
|
299
|
+
if (typeof window !== "undefined" && window.process?.type === "renderer") {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
|
|
306
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
307
|
+
return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
311
|
+
function isBrowser() {
|
|
312
|
+
const isNode = (
|
|
313
|
+
// @ts-expect-error
|
|
314
|
+
typeof process === "object" && String(process) === "[object process]" && !process?.browser
|
|
315
|
+
);
|
|
316
|
+
return !isNode || isElectron();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
320
|
+
var VERSION = true ? "4.1.0" : "untranspiled source";
|
|
321
|
+
|
|
319
322
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
320
323
|
function getStorage(type) {
|
|
321
324
|
try {
|
|
@@ -889,10 +892,6 @@ var __exports__ = (() => {
|
|
|
889
892
|
clone(props) {
|
|
890
893
|
return this.device.createBuffer({ ...this.props, ...props });
|
|
891
894
|
}
|
|
892
|
-
/** Read data synchronously. @note WebGL2 only */
|
|
893
|
-
readSyncWebGL(byteOffset, byteLength) {
|
|
894
|
-
throw new Error("not implemented");
|
|
895
|
-
}
|
|
896
895
|
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
897
896
|
debugData = new ArrayBuffer(0);
|
|
898
897
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
@@ -912,21 +911,6 @@ var __exports__ = (() => {
|
|
|
912
911
|
}
|
|
913
912
|
};
|
|
914
913
|
var Buffer2 = _Buffer;
|
|
915
|
-
__publicField(Buffer2, "defaultProps", {
|
|
916
|
-
...Resource.defaultProps,
|
|
917
|
-
usage: 0,
|
|
918
|
-
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
919
|
-
byteLength: 0,
|
|
920
|
-
byteOffset: 0,
|
|
921
|
-
data: null,
|
|
922
|
-
indexType: "uint16",
|
|
923
|
-
mappedAtCreation: false
|
|
924
|
-
});
|
|
925
|
-
// Usage Flags
|
|
926
|
-
__publicField(Buffer2, "MAP_READ", 1);
|
|
927
|
-
__publicField(Buffer2, "MAP_WRITE", 2);
|
|
928
|
-
__publicField(Buffer2, "COPY_SRC", 4);
|
|
929
|
-
__publicField(Buffer2, "COPY_DST", 8);
|
|
930
914
|
/** Index buffer */
|
|
931
915
|
__publicField(Buffer2, "INDEX", 16);
|
|
932
916
|
/** Vertex buffer */
|
|
@@ -937,55 +921,176 @@ var __exports__ = (() => {
|
|
|
937
921
|
__publicField(Buffer2, "STORAGE", 128);
|
|
938
922
|
__publicField(Buffer2, "INDIRECT", 256);
|
|
939
923
|
__publicField(Buffer2, "QUERY_RESOLVE", 512);
|
|
924
|
+
// Usage Flags
|
|
925
|
+
__publicField(Buffer2, "MAP_READ", 1);
|
|
926
|
+
__publicField(Buffer2, "MAP_WRITE", 2);
|
|
927
|
+
__publicField(Buffer2, "COPY_SRC", 4);
|
|
928
|
+
__publicField(Buffer2, "COPY_DST", 8);
|
|
940
929
|
// PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)
|
|
941
930
|
/** Max amount of debug data saved. Two vec4's */
|
|
942
931
|
__publicField(Buffer2, "DEBUG_DATA_MAX_LENGTH", 32);
|
|
932
|
+
__publicField(Buffer2, "defaultProps", {
|
|
933
|
+
...Resource.defaultProps,
|
|
934
|
+
usage: 0,
|
|
935
|
+
// Buffer.COPY_DST | Buffer.COPY_SRC
|
|
936
|
+
byteLength: 0,
|
|
937
|
+
byteOffset: 0,
|
|
938
|
+
data: null,
|
|
939
|
+
indexType: "uint16",
|
|
940
|
+
onMapped: void 0
|
|
941
|
+
});
|
|
943
942
|
|
|
944
|
-
// src/
|
|
945
|
-
function
|
|
946
|
-
const
|
|
947
|
-
const bytes = getDataTypeBytes(dataType);
|
|
943
|
+
// src/shadertypes/data-types/decode-data-types.ts
|
|
944
|
+
function getDataTypeInfo(type) {
|
|
945
|
+
const [signedType, primitiveType, byteLength] = NORMALIZED_TYPE_MAP[type];
|
|
948
946
|
const normalized = type.includes("norm");
|
|
949
947
|
const integer = !normalized && !type.startsWith("float");
|
|
950
948
|
const signed = type.startsWith("s");
|
|
951
949
|
return {
|
|
952
|
-
|
|
953
|
-
|
|
950
|
+
signedType,
|
|
951
|
+
primitiveType,
|
|
952
|
+
byteLength,
|
|
953
|
+
normalized,
|
|
954
954
|
integer,
|
|
955
|
-
signed
|
|
956
|
-
normalized
|
|
955
|
+
signed
|
|
957
956
|
};
|
|
958
957
|
}
|
|
959
|
-
function
|
|
960
|
-
const
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
958
|
+
function getNormalizedDataType(signedDataType) {
|
|
959
|
+
const dataType = signedDataType;
|
|
960
|
+
switch (dataType) {
|
|
961
|
+
case "uint8":
|
|
962
|
+
return "unorm8";
|
|
963
|
+
case "sint8":
|
|
964
|
+
return "snorm8";
|
|
965
|
+
case "uint16":
|
|
966
|
+
return "unorm16";
|
|
967
|
+
case "sint16":
|
|
968
|
+
return "snorm16";
|
|
969
|
+
default:
|
|
970
|
+
return dataType;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
function alignTo(size, count) {
|
|
974
|
+
switch (count) {
|
|
975
|
+
case 1:
|
|
976
|
+
return size;
|
|
977
|
+
case 2:
|
|
978
|
+
return size + size % 2;
|
|
979
|
+
default:
|
|
980
|
+
return size + (4 - size % 4) % 4;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function getDataType(arrayOrType) {
|
|
984
|
+
const Constructor = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
985
|
+
if (Constructor === Uint8ClampedArray) {
|
|
986
|
+
return "uint8";
|
|
987
|
+
}
|
|
988
|
+
const info = Object.values(NORMALIZED_TYPE_MAP).find((entry) => Constructor === entry[4]);
|
|
989
|
+
if (!info) {
|
|
990
|
+
throw new Error(Constructor.name);
|
|
991
|
+
}
|
|
992
|
+
return info[0];
|
|
993
|
+
}
|
|
994
|
+
function getTypedArrayConstructor(type) {
|
|
995
|
+
const [, , , , Constructor] = NORMALIZED_TYPE_MAP[type];
|
|
996
|
+
return Constructor;
|
|
997
|
+
}
|
|
998
|
+
var NORMALIZED_TYPE_MAP = {
|
|
999
|
+
uint8: ["uint8", "u32", 1, false, Uint8Array],
|
|
1000
|
+
sint8: ["sint8", "i32", 1, false, Int8Array],
|
|
1001
|
+
unorm8: ["uint8", "f32", 1, true, Uint8Array],
|
|
1002
|
+
snorm8: ["sint8", "f32", 1, true, Int8Array],
|
|
1003
|
+
uint16: ["uint16", "u32", 2, false, Uint16Array],
|
|
1004
|
+
sint16: ["sint16", "i32", 2, false, Int16Array],
|
|
1005
|
+
unorm16: ["uint16", "u32", 2, true, Uint16Array],
|
|
1006
|
+
snorm16: ["sint16", "i32", 2, true, Int16Array],
|
|
1007
|
+
float16: ["float16", "f16", 2, false, Uint16Array],
|
|
1008
|
+
float32: ["float32", "f32", 4, false, Float32Array],
|
|
1009
|
+
uint32: ["uint32", "u32", 4, false, Uint32Array],
|
|
1010
|
+
sint32: ["sint32", "i32", 4, false, Int32Array]
|
|
986
1011
|
};
|
|
987
1012
|
|
|
988
|
-
// src/
|
|
1013
|
+
// src/shadertypes/vertex-arrays/decode-vertex-format.ts
|
|
1014
|
+
function getVertexFormatInfo(format) {
|
|
1015
|
+
let webglOnly;
|
|
1016
|
+
if (format.endsWith("-webgl")) {
|
|
1017
|
+
format.replace("-webgl", "");
|
|
1018
|
+
webglOnly = true;
|
|
1019
|
+
}
|
|
1020
|
+
const [type_, count] = format.split("x");
|
|
1021
|
+
const type = type_;
|
|
1022
|
+
const components = count ? parseInt(count) : 1;
|
|
1023
|
+
const decodedType = getDataTypeInfo(type);
|
|
1024
|
+
const result = {
|
|
1025
|
+
type,
|
|
1026
|
+
components,
|
|
1027
|
+
byteLength: decodedType.byteLength * components,
|
|
1028
|
+
integer: decodedType.integer,
|
|
1029
|
+
signed: decodedType.signed,
|
|
1030
|
+
normalized: decodedType.normalized
|
|
1031
|
+
};
|
|
1032
|
+
if (webglOnly) {
|
|
1033
|
+
result.webglOnly = true;
|
|
1034
|
+
}
|
|
1035
|
+
return result;
|
|
1036
|
+
}
|
|
1037
|
+
function makeVertexFormat(signedDataType, components, normalized) {
|
|
1038
|
+
const dataType = normalized ? getNormalizedDataType(signedDataType) : signedDataType;
|
|
1039
|
+
switch (dataType) {
|
|
1040
|
+
case "unorm8":
|
|
1041
|
+
if (components === 1) {
|
|
1042
|
+
return "unorm8";
|
|
1043
|
+
}
|
|
1044
|
+
if (components === 3) {
|
|
1045
|
+
return "unorm8x3-webgl";
|
|
1046
|
+
}
|
|
1047
|
+
return `${dataType}x${components}`;
|
|
1048
|
+
case "snorm8":
|
|
1049
|
+
case "uint8":
|
|
1050
|
+
case "sint8":
|
|
1051
|
+
case "uint16":
|
|
1052
|
+
case "sint16":
|
|
1053
|
+
case "unorm16":
|
|
1054
|
+
case "snorm16":
|
|
1055
|
+
case "float16":
|
|
1056
|
+
if (components === 1 || components === 3) {
|
|
1057
|
+
throw new Error(`size: ${components}`);
|
|
1058
|
+
}
|
|
1059
|
+
return `${dataType}x${components}`;
|
|
1060
|
+
default:
|
|
1061
|
+
return components === 1 ? dataType : `${dataType}x${components}`;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function getVertexFormatFromAttribute(typedArray, size, normalized) {
|
|
1065
|
+
if (!size || size > 4) {
|
|
1066
|
+
throw new Error(`size ${size}`);
|
|
1067
|
+
}
|
|
1068
|
+
const components = size;
|
|
1069
|
+
const signedDataType = getDataType(typedArray);
|
|
1070
|
+
return makeVertexFormat(signedDataType, components, normalized);
|
|
1071
|
+
}
|
|
1072
|
+
function getCompatibleVertexFormat(opts) {
|
|
1073
|
+
let vertexType;
|
|
1074
|
+
switch (opts.primitiveType) {
|
|
1075
|
+
case "f32":
|
|
1076
|
+
vertexType = "float32";
|
|
1077
|
+
break;
|
|
1078
|
+
case "i32":
|
|
1079
|
+
vertexType = "sint32";
|
|
1080
|
+
break;
|
|
1081
|
+
case "u32":
|
|
1082
|
+
vertexType = "uint32";
|
|
1083
|
+
break;
|
|
1084
|
+
case "f16":
|
|
1085
|
+
return opts.components <= 2 ? "float16x2" : "float16x4";
|
|
1086
|
+
}
|
|
1087
|
+
if (opts.components === 1) {
|
|
1088
|
+
return vertexType;
|
|
1089
|
+
}
|
|
1090
|
+
return `${vertexType}x${opts.components}`;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// src/shadertypes/textures/texture-format-table.ts
|
|
989
1094
|
var texture_compression_bc = "texture-compression-bc";
|
|
990
1095
|
var texture_compression_astc = "texture-compression-astc";
|
|
991
1096
|
var texture_compression_etc2 = "texture-compression-etc2";
|
|
@@ -1010,73 +1115,65 @@ var __exports__ = (() => {
|
|
|
1010
1115
|
function getTextureFormatTable() {
|
|
1011
1116
|
return TEXTURE_FORMAT_TABLE;
|
|
1012
1117
|
}
|
|
1013
|
-
var
|
|
1118
|
+
var TEXTURE_FORMAT_COLOR_DEPTH_TABLE = {
|
|
1014
1119
|
// 8-bit formats
|
|
1015
1120
|
"r8unorm": {},
|
|
1016
|
-
"r8snorm": { render: snorm8_renderable },
|
|
1017
|
-
"r8uint": {},
|
|
1018
|
-
"r8sint": {},
|
|
1019
|
-
// 16-bit formats
|
|
1020
1121
|
"rg8unorm": {},
|
|
1021
|
-
"rg8snorm": { render: snorm8_renderable },
|
|
1022
|
-
"rg8uint": {},
|
|
1023
|
-
"rg8sint": {},
|
|
1024
|
-
"r16uint": {},
|
|
1025
|
-
"r16sint": {},
|
|
1026
|
-
"r16float": { render: float16_renderable, filter: "float16-filterable-webgl" },
|
|
1027
|
-
"r16unorm-webgl": { f: norm16_renderable },
|
|
1028
|
-
"r16snorm-webgl": { f: snorm16_renderable },
|
|
1029
|
-
// Packed 16-bit formats
|
|
1030
|
-
"rgba4unorm-webgl": { channels: "rgba", bitsPerChannel: [4, 4, 4, 4], packed: true },
|
|
1031
|
-
"rgb565unorm-webgl": { channels: "rgb", bitsPerChannel: [5, 6, 5, 0], packed: true },
|
|
1032
|
-
"rgb5a1unorm-webgl": { channels: "rgba", bitsPerChannel: [5, 5, 5, 1], packed: true },
|
|
1033
|
-
// 24-bit formats
|
|
1034
1122
|
"rgb8unorm-webgl": {},
|
|
1035
|
-
"rgb8snorm-webgl": {},
|
|
1036
|
-
// 32-bit formats
|
|
1037
1123
|
"rgba8unorm": {},
|
|
1038
1124
|
"rgba8unorm-srgb": {},
|
|
1125
|
+
"r8snorm": { render: snorm8_renderable },
|
|
1126
|
+
"rg8snorm": { render: snorm8_renderable },
|
|
1127
|
+
"rgb8snorm-webgl": {},
|
|
1039
1128
|
"rgba8snorm": { render: snorm8_renderable },
|
|
1129
|
+
"r8uint": {},
|
|
1130
|
+
"rg8uint": {},
|
|
1040
1131
|
"rgba8uint": {},
|
|
1132
|
+
"r8sint": {},
|
|
1133
|
+
"rg8sint": {},
|
|
1041
1134
|
"rgba8sint": {},
|
|
1042
|
-
// 32-bit, reverse colors, webgpu only
|
|
1043
1135
|
"bgra8unorm": {},
|
|
1044
1136
|
"bgra8unorm-srgb": {},
|
|
1137
|
+
"r16unorm": { f: norm16_renderable },
|
|
1138
|
+
"rg16unorm": { render: norm16_renderable },
|
|
1139
|
+
"rgb16unorm-webgl": { f: norm16_renderable },
|
|
1140
|
+
// rgb not renderable
|
|
1141
|
+
"rgba16unorm": { render: norm16_renderable },
|
|
1142
|
+
"r16snorm": { f: snorm16_renderable },
|
|
1143
|
+
"rg16snorm": { render: snorm16_renderable },
|
|
1144
|
+
"rgb16snorm-webgl": { f: norm16_renderable },
|
|
1145
|
+
// rgb not renderable
|
|
1146
|
+
"rgba16snorm": { render: snorm16_renderable },
|
|
1147
|
+
"r16uint": {},
|
|
1045
1148
|
"rg16uint": {},
|
|
1149
|
+
"rgba16uint": {},
|
|
1150
|
+
"r16sint": {},
|
|
1046
1151
|
"rg16sint": {},
|
|
1152
|
+
"rgba16sint": {},
|
|
1153
|
+
"r16float": { render: float16_renderable, filter: "float16-filterable-webgl" },
|
|
1047
1154
|
"rg16float": { render: float16_renderable, filter: float16_filterable },
|
|
1048
|
-
"
|
|
1049
|
-
"rg16snorm-webgl": { render: snorm16_renderable },
|
|
1155
|
+
"rgba16float": { render: float16_renderable, filter: float16_filterable },
|
|
1050
1156
|
"r32uint": {},
|
|
1157
|
+
"rg32uint": {},
|
|
1158
|
+
"rgba32uint": {},
|
|
1051
1159
|
"r32sint": {},
|
|
1160
|
+
"rg32sint": {},
|
|
1161
|
+
"rgba32sint": {},
|
|
1052
1162
|
"r32float": { render: float32_renderable, filter: float32_filterable },
|
|
1163
|
+
"rg32float": { render: false, filter: float32_filterable },
|
|
1164
|
+
"rgb32float-webgl": { render: float32_renderable, filter: float32_filterable },
|
|
1165
|
+
"rgba32float": { render: float32_renderable, filter: float32_filterable },
|
|
1166
|
+
// Packed 16-bit formats
|
|
1167
|
+
"rgba4unorm-webgl": { channels: "rgba", bitsPerChannel: [4, 4, 4, 4], packed: true },
|
|
1168
|
+
"rgb565unorm-webgl": { channels: "rgb", bitsPerChannel: [5, 6, 5, 0], packed: true },
|
|
1169
|
+
"rgb5a1unorm-webgl": { channels: "rgba", bitsPerChannel: [5, 5, 5, 1], packed: true },
|
|
1053
1170
|
// Packed 32 bit formats
|
|
1054
1171
|
"rgb9e5ufloat": { channels: "rgb", packed: true, render: rgb9e5ufloat_renderable },
|
|
1055
1172
|
// , filter: true},
|
|
1056
1173
|
"rg11b10ufloat": { channels: "rgb", bitsPerChannel: [11, 11, 10, 0], packed: true, p: 1, render: float32_renderable },
|
|
1057
1174
|
"rgb10a2unorm": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1058
|
-
"rgb10a2uint
|
|
1059
|
-
//
|
|
1060
|
-
"rgb16unorm-webgl": { f: norm16_renderable },
|
|
1061
|
-
// rgb not renderable
|
|
1062
|
-
"rgb16snorm-webgl": { f: norm16_renderable },
|
|
1063
|
-
// rgb not renderable
|
|
1064
|
-
// 64-bit formats
|
|
1065
|
-
"rg32uint": {},
|
|
1066
|
-
"rg32sint": {},
|
|
1067
|
-
"rg32float": { render: false, filter: float32_filterable },
|
|
1068
|
-
"rgba16uint": {},
|
|
1069
|
-
"rgba16sint": {},
|
|
1070
|
-
"rgba16float": { render: float16_renderable, filter: float16_filterable },
|
|
1071
|
-
"rgba16unorm-webgl": { render: norm16_renderable },
|
|
1072
|
-
"rgba16snorm-webgl": { render: snorm16_renderable },
|
|
1073
|
-
// 96-bit formats (deprecated!)
|
|
1074
|
-
"rgb32float-webgl": { render: float32_renderable, filter: float32_filterable },
|
|
1075
|
-
// 128-bit formats
|
|
1076
|
-
"rgba32uint": {},
|
|
1077
|
-
"rgba32sint": {},
|
|
1078
|
-
"rgba32float": { render: float32_renderable, filter: float32_filterable },
|
|
1079
|
-
// Depth/stencil
|
|
1175
|
+
"rgb10a2uint": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1176
|
+
// Depth/stencil Formats
|
|
1080
1177
|
// Depth and stencil formats
|
|
1081
1178
|
stencil8: { attachment: "stencil", bitsPerChannel: [8, 0, 0, 0], dataType: "uint8" },
|
|
1082
1179
|
"depth16unorm": { attachment: "depth", bitsPerChannel: [16, 0, 0, 0], dataType: "uint16" },
|
|
@@ -1085,7 +1182,9 @@ var __exports__ = (() => {
|
|
|
1085
1182
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
1086
1183
|
"depth24plus-stencil8": { attachment: "depth-stencil", bitsPerChannel: [24, 8, 0, 0], packed: true },
|
|
1087
1184
|
// "depth32float-stencil8" feature
|
|
1088
|
-
"depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true }
|
|
1185
|
+
"depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true }
|
|
1186
|
+
};
|
|
1187
|
+
var TEXTURE_FORMAT_COMPRESSED_TABLE = {
|
|
1089
1188
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
1090
1189
|
"bc1-rgb-unorm-webgl": { f: texture_compression_bc },
|
|
1091
1190
|
"bc1-rgb-unorm-srgb-webgl": { f: texture_compression_bc },
|
|
@@ -1156,8 +1255,12 @@ var __exports__ = (() => {
|
|
|
1156
1255
|
"atc-rgba-unorm-webgl": { f: texture_compression_atc_webgl },
|
|
1157
1256
|
"atc-rgbai-unorm-webgl": { f: texture_compression_atc_webgl }
|
|
1158
1257
|
};
|
|
1258
|
+
var TEXTURE_FORMAT_TABLE = {
|
|
1259
|
+
...TEXTURE_FORMAT_COLOR_DEPTH_TABLE,
|
|
1260
|
+
...TEXTURE_FORMAT_COMPRESSED_TABLE
|
|
1261
|
+
};
|
|
1159
1262
|
|
|
1160
|
-
// src/
|
|
1263
|
+
// src/shadertypes/textures/texture-format-decoder.ts
|
|
1161
1264
|
var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
1162
1265
|
"bc1",
|
|
1163
1266
|
"bc2",
|
|
@@ -1174,12 +1277,51 @@ var __exports__ = (() => {
|
|
|
1174
1277
|
"pvrtc"
|
|
1175
1278
|
];
|
|
1176
1279
|
var RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if
|
|
1280
|
+
var TextureFormatDecoder = class {
|
|
1281
|
+
/** Returns information about a texture format, e.g. attatchment type, components, byte length and flags (integer, signed, normalized) */
|
|
1282
|
+
getInfo(format) {
|
|
1283
|
+
return getTextureFormatInfo(format);
|
|
1284
|
+
}
|
|
1285
|
+
/** Checks if a texture format is color */
|
|
1286
|
+
isColor(format) {
|
|
1287
|
+
return format.startsWith("rgba") || format.startsWith("bgra") || format.startsWith("rgb");
|
|
1288
|
+
}
|
|
1289
|
+
/** Checks if a texture format is depth or stencil */
|
|
1290
|
+
isDepthStencil(format) {
|
|
1291
|
+
return format.startsWith("depth") || format.startsWith("stencil");
|
|
1292
|
+
}
|
|
1293
|
+
/** Checks if a texture format is compressed */
|
|
1294
|
+
isCompressed(format) {
|
|
1295
|
+
return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => format.startsWith(prefix));
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Returns the "static" capabilities of a texture format.
|
|
1299
|
+
* @note Needs to be checked against current device
|
|
1300
|
+
*/
|
|
1301
|
+
getCapabilities(format) {
|
|
1302
|
+
const info = getTextureFormatDefinition(format);
|
|
1303
|
+
const formatCapabilities = {
|
|
1304
|
+
format,
|
|
1305
|
+
create: info.f ?? true,
|
|
1306
|
+
render: info.render ?? true,
|
|
1307
|
+
filter: info.filter ?? true,
|
|
1308
|
+
blend: info.blend ?? true,
|
|
1309
|
+
store: info.store ?? true
|
|
1310
|
+
};
|
|
1311
|
+
const formatInfo = getTextureFormatInfo(format);
|
|
1312
|
+
const isDepthStencil = format.startsWith("depth") || format.startsWith("stencil");
|
|
1313
|
+
const isSigned = formatInfo?.signed;
|
|
1314
|
+
const isInteger = formatInfo?.integer;
|
|
1315
|
+
const isWebGLSpecific = formatInfo?.webgl;
|
|
1316
|
+
formatCapabilities.render &&= !isSigned;
|
|
1317
|
+
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
1318
|
+
return formatCapabilities;
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
var textureFormatDecoder = new TextureFormatDecoder();
|
|
1322
|
+
function getTextureFormatInfo(format) {
|
|
1323
|
+
let formatInfo = getTextureFormatInfoUsingTable(format);
|
|
1324
|
+
if (textureFormatDecoder.isCompressed(format)) {
|
|
1183
1325
|
formatInfo.channels = "rgb";
|
|
1184
1326
|
formatInfo.components = 3;
|
|
1185
1327
|
formatInfo.bytesPerPixel = 1;
|
|
@@ -1195,7 +1337,7 @@ var __exports__ = (() => {
|
|
|
1195
1337
|
if (matches) {
|
|
1196
1338
|
const [, channels, length, type, srgb, suffix] = matches;
|
|
1197
1339
|
const dataType = `${type}${length}`;
|
|
1198
|
-
const decodedType =
|
|
1340
|
+
const decodedType = getDataTypeInfo(dataType);
|
|
1199
1341
|
const bits = decodedType.byteLength * 8;
|
|
1200
1342
|
const components = channels.length;
|
|
1201
1343
|
const bitsPerChannel = [
|
|
@@ -1207,7 +1349,7 @@ var __exports__ = (() => {
|
|
|
1207
1349
|
formatInfo = {
|
|
1208
1350
|
format,
|
|
1209
1351
|
attachment: formatInfo.attachment,
|
|
1210
|
-
dataType: decodedType.
|
|
1352
|
+
dataType: decodedType.signedType,
|
|
1211
1353
|
components,
|
|
1212
1354
|
channels,
|
|
1213
1355
|
integer: decodedType.integer,
|
|
@@ -1233,7 +1375,7 @@ var __exports__ = (() => {
|
|
|
1233
1375
|
}
|
|
1234
1376
|
return formatInfo;
|
|
1235
1377
|
}
|
|
1236
|
-
function
|
|
1378
|
+
function getTextureFormatInfoUsingTable(format) {
|
|
1237
1379
|
const info = getTextureFormatDefinition(format);
|
|
1238
1380
|
const bytesPerPixel = info.bytesPerPixel || 1;
|
|
1239
1381
|
const bitsPerChannel = info.bitsPerChannel || [8, 8, 8, 8];
|
|
@@ -1273,25 +1415,24 @@ var __exports__ = (() => {
|
|
|
1273
1415
|
return null;
|
|
1274
1416
|
}
|
|
1275
1417
|
|
|
1276
|
-
// src/
|
|
1277
|
-
function
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
return formatCapabilities;
|
|
1418
|
+
// src/image-utils/image-types.ts
|
|
1419
|
+
function isExternalImage(data) {
|
|
1420
|
+
return typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement || typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement || typeof VideoFrame !== "undefined" && data instanceof VideoFrame || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas;
|
|
1421
|
+
}
|
|
1422
|
+
function getExternalImageSize(data) {
|
|
1423
|
+
if (typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas) {
|
|
1424
|
+
return { width: data.width, height: data.height };
|
|
1425
|
+
}
|
|
1426
|
+
if (typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement) {
|
|
1427
|
+
return { width: data.naturalWidth, height: data.naturalHeight };
|
|
1428
|
+
}
|
|
1429
|
+
if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
|
|
1430
|
+
return { width: data.videoWidth, height: data.videoHeight };
|
|
1431
|
+
}
|
|
1432
|
+
if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
|
|
1433
|
+
return { width: data.displayWidth, height: data.displayHeight };
|
|
1434
|
+
}
|
|
1435
|
+
throw new Error("Unknown image type");
|
|
1295
1436
|
}
|
|
1296
1437
|
|
|
1297
1438
|
// src/adapter/device.ts
|
|
@@ -1315,9 +1456,8 @@ var __exports__ = (() => {
|
|
|
1315
1456
|
get [Symbol.toStringTag]() {
|
|
1316
1457
|
return "Device";
|
|
1317
1458
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1459
|
+
toString() {
|
|
1460
|
+
return `Device(${this.id})`;
|
|
1321
1461
|
}
|
|
1322
1462
|
/** id of this device, primarily for debugging */
|
|
1323
1463
|
id;
|
|
@@ -1333,23 +1473,46 @@ var __exports__ = (() => {
|
|
|
1333
1473
|
_reused = false;
|
|
1334
1474
|
/** Used by other luma.gl modules to store data on the device */
|
|
1335
1475
|
_lumaData = {};
|
|
1336
|
-
|
|
1476
|
+
_textureCaps = {};
|
|
1477
|
+
constructor(props) {
|
|
1478
|
+
this.props = { ..._Device.defaultProps, ...props };
|
|
1479
|
+
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1480
|
+
}
|
|
1481
|
+
getVertexFormatInfo(format) {
|
|
1482
|
+
return getVertexFormatInfo(format);
|
|
1483
|
+
}
|
|
1484
|
+
isVertexFormatSupported(format) {
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
/** Returns information about a texture format, such as data type, channels, bits per channel, compression etc */
|
|
1488
|
+
getTextureFormatInfo(format) {
|
|
1489
|
+
return textureFormatDecoder.getInfo(format);
|
|
1490
|
+
}
|
|
1491
|
+
/** Determines what operations are supported on a texture format on this particular device (checks against supported device features) */
|
|
1337
1492
|
getTextureFormatCapabilities(format) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
format
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
return
|
|
1493
|
+
let textureCaps = this._textureCaps[format];
|
|
1494
|
+
if (!textureCaps) {
|
|
1495
|
+
const capabilities = this._getDeviceTextureFormatCapabilities(format);
|
|
1496
|
+
textureCaps = this._getDeviceSpecificTextureFormatCapabilities(capabilities);
|
|
1497
|
+
this._textureCaps[format] = textureCaps;
|
|
1498
|
+
}
|
|
1499
|
+
return textureCaps;
|
|
1500
|
+
}
|
|
1501
|
+
/** Calculates the number of mip levels for a texture of width, height and in case of 3d textures only, depth */
|
|
1502
|
+
getMipLevelCount(width, height, depth3d = 1) {
|
|
1503
|
+
const maxSize = Math.max(width, height, depth3d);
|
|
1504
|
+
return 1 + Math.floor(Math.log2(maxSize));
|
|
1505
|
+
}
|
|
1506
|
+
/** Check if data is an external image */
|
|
1507
|
+
isExternalImage(data) {
|
|
1508
|
+
return isExternalImage(data);
|
|
1509
|
+
}
|
|
1510
|
+
/** Get the size of an external image */
|
|
1511
|
+
getExternalImageSize(data) {
|
|
1512
|
+
return getExternalImageSize(data);
|
|
1350
1513
|
}
|
|
1351
1514
|
/** Check if device supports a specific texture format (creation and `nearest` sampling) */
|
|
1352
|
-
isTextureFormatSupported(format
|
|
1515
|
+
isTextureFormatSupported(format) {
|
|
1353
1516
|
return this.getTextureFormatCapabilities(format).create;
|
|
1354
1517
|
}
|
|
1355
1518
|
/** Check if linear filtering (sampler interpolation) is supported for a specific texture format */
|
|
@@ -1362,7 +1525,17 @@ var __exports__ = (() => {
|
|
|
1362
1525
|
}
|
|
1363
1526
|
/** Check if a specific texture format is GPU compressed */
|
|
1364
1527
|
isTextureFormatCompressed(format) {
|
|
1365
|
-
return
|
|
1528
|
+
return textureFormatDecoder.isCompressed(format);
|
|
1529
|
+
}
|
|
1530
|
+
// DEBUG METHODS
|
|
1531
|
+
pushDebugGroup(groupLabel) {
|
|
1532
|
+
this.commandEncoder.pushDebugGroup(groupLabel);
|
|
1533
|
+
}
|
|
1534
|
+
popDebugGroup() {
|
|
1535
|
+
this.commandEncoder?.popDebugGroup();
|
|
1536
|
+
}
|
|
1537
|
+
insertDebugMarker(markerLabel) {
|
|
1538
|
+
this.commandEncoder?.insertDebugMarker(markerLabel);
|
|
1366
1539
|
}
|
|
1367
1540
|
/**
|
|
1368
1541
|
* Trigger device loss.
|
|
@@ -1372,9 +1545,44 @@ var __exports__ = (() => {
|
|
|
1372
1545
|
loseDevice() {
|
|
1373
1546
|
return false;
|
|
1374
1547
|
}
|
|
1375
|
-
/**
|
|
1376
|
-
|
|
1377
|
-
this.
|
|
1548
|
+
/** A monotonic counter for tracking buffer and texture updates */
|
|
1549
|
+
incrementTimestamp() {
|
|
1550
|
+
return this.timestamp++;
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Reports Device errors in a way that optimizes for developer experience / debugging.
|
|
1554
|
+
* - Logs so that the console error links directly to the source code that generated the error.
|
|
1555
|
+
* - Includes the object that reported the error in the log message, even if the error is asynchronous.
|
|
1556
|
+
*
|
|
1557
|
+
* Conventions when calling reportError():
|
|
1558
|
+
* - Always call the returned function - to ensure error is logged, at the error site
|
|
1559
|
+
* - Follow with a call to device.debug() - to ensure that the debugger breaks at the error site
|
|
1560
|
+
*
|
|
1561
|
+
* @param error - the error to report. If needed, just create a new Error object with the appropriate message.
|
|
1562
|
+
* @param context - pass `this` as context, otherwise it may not be available in the debugger for async errors.
|
|
1563
|
+
* @returns the logger function returned by device.props.onError() so that it can be called from the error site.
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* device.reportError(new Error(...), this)();
|
|
1567
|
+
* device.debug();
|
|
1568
|
+
*/
|
|
1569
|
+
reportError(error, context, ...args) {
|
|
1570
|
+
const isHandled = this.props.onError(error, context);
|
|
1571
|
+
if (!isHandled) {
|
|
1572
|
+
return log.error(error.message, context, ...args);
|
|
1573
|
+
}
|
|
1574
|
+
return () => {
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
/** Break in the debugger - if device.props.debug is true */
|
|
1578
|
+
debug() {
|
|
1579
|
+
if (this.props.debug) {
|
|
1580
|
+
debugger;
|
|
1581
|
+
} else {
|
|
1582
|
+
const message = `'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
1583
|
+
or create a device with the 'debug: true' prop.`;
|
|
1584
|
+
log.once(0, message)();
|
|
1585
|
+
}
|
|
1378
1586
|
}
|
|
1379
1587
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
1380
1588
|
getDefaultCanvasContext() {
|
|
@@ -1383,17 +1591,13 @@ var __exports__ = (() => {
|
|
|
1383
1591
|
}
|
|
1384
1592
|
return this.canvasContext;
|
|
1385
1593
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
/** A monotonic counter for tracking buffer and texture updates */
|
|
1390
|
-
incrementTimestamp() {
|
|
1391
|
-
return this.timestamp++;
|
|
1594
|
+
/** Create a RenderPass using the default CommandEncoder */
|
|
1595
|
+
beginRenderPass(props) {
|
|
1596
|
+
return this.commandEncoder.beginRenderPass(props);
|
|
1392
1597
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
this.props.onError(error);
|
|
1598
|
+
/** Create a ComputePass using the default CommandEncoder*/
|
|
1599
|
+
beginComputePass(props) {
|
|
1600
|
+
return this.commandEncoder.beginComputePass(props);
|
|
1397
1601
|
}
|
|
1398
1602
|
// DEPRECATED METHODS
|
|
1399
1603
|
/** @deprecated Use getDefaultCanvasContext() */
|
|
@@ -1435,19 +1639,36 @@ var __exports__ = (() => {
|
|
|
1435
1639
|
static _getCanvasContextProps(props) {
|
|
1436
1640
|
return props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
1437
1641
|
}
|
|
1642
|
+
_getDeviceTextureFormatCapabilities(format) {
|
|
1643
|
+
const genericCapabilities = textureFormatDecoder.getCapabilities(format);
|
|
1644
|
+
const checkFeature = (feature) => (typeof feature === "string" ? this.features.has(feature) : feature) ?? true;
|
|
1645
|
+
const supported = checkFeature(genericCapabilities.create);
|
|
1646
|
+
return {
|
|
1647
|
+
format,
|
|
1648
|
+
create: supported,
|
|
1649
|
+
render: supported && checkFeature(genericCapabilities.render),
|
|
1650
|
+
filter: supported && checkFeature(genericCapabilities.filter),
|
|
1651
|
+
blend: supported && checkFeature(genericCapabilities.blend),
|
|
1652
|
+
store: supported && checkFeature(genericCapabilities.store)
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1438
1655
|
/** Subclasses use this to support .createBuffer() overloads */
|
|
1439
1656
|
_normalizeBufferProps(props) {
|
|
1440
1657
|
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
1441
1658
|
props = { data: props };
|
|
1442
1659
|
}
|
|
1443
1660
|
const newProps = { ...props };
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1661
|
+
const usage = props.usage || 0;
|
|
1662
|
+
if (usage & Buffer2.INDEX) {
|
|
1663
|
+
if (!props.indexType) {
|
|
1664
|
+
if (props.data instanceof Uint32Array) {
|
|
1665
|
+
newProps.indexType = "uint32";
|
|
1666
|
+
} else if (props.data instanceof Uint16Array) {
|
|
1667
|
+
newProps.indexType = "uint16";
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
if (!newProps.indexType) {
|
|
1671
|
+
throw new Error("indices buffer content must be of type uint16 or uint32");
|
|
1451
1672
|
}
|
|
1452
1673
|
}
|
|
1453
1674
|
return newProps;
|
|
@@ -1459,34 +1680,47 @@ var __exports__ = (() => {
|
|
|
1459
1680
|
powerPreference: "high-performance",
|
|
1460
1681
|
failIfMajorPerformanceCaveat: false,
|
|
1461
1682
|
createCanvasContext: void 0,
|
|
1462
|
-
// Callbacks
|
|
1463
|
-
onError: (error) => log.error(error.message)(),
|
|
1464
|
-
// Experimental
|
|
1465
|
-
_reuseDevices: false,
|
|
1466
|
-
_requestMaxLimits: true,
|
|
1467
|
-
_factoryDestroyPolicy: "unused",
|
|
1468
|
-
// TODO - Change these after confirming things work as expected
|
|
1469
|
-
_initializeFeatures: true,
|
|
1470
|
-
_disabledFeatures: {
|
|
1471
|
-
"compilation-status-async-webgl": true
|
|
1472
|
-
},
|
|
1473
|
-
_resourceDefaults: {},
|
|
1474
1683
|
// WebGL specific
|
|
1475
1684
|
webgl: {},
|
|
1685
|
+
// Callbacks
|
|
1686
|
+
// eslint-disable-next-line handle-callback-err
|
|
1687
|
+
onError: (error, context) => {
|
|
1688
|
+
},
|
|
1689
|
+
onResize: (context, info) => {
|
|
1690
|
+
const [width, height] = context.getDevicePixelSize();
|
|
1691
|
+
log.log(1, `${context} resized => ${width}x${height}px`)();
|
|
1692
|
+
},
|
|
1693
|
+
onPositionChange: (context, info) => {
|
|
1694
|
+
const [left, top] = context.getPosition();
|
|
1695
|
+
log.log(1, `${context} repositioned => ${left},${top}`)();
|
|
1696
|
+
},
|
|
1697
|
+
onVisibilityChange: (context) => log.log(1, `${context} Visibility changed ${context.isVisible}`)(),
|
|
1698
|
+
onDevicePixelRatioChange: (context, info) => log.log(1, `${context} DPR changed ${info.oldRatio} => ${context.devicePixelRatio}`)(),
|
|
1699
|
+
// Debug flags
|
|
1476
1700
|
debug: log.get("debug") || void 0,
|
|
1477
1701
|
debugShaders: log.get("debug-shaders") || void 0,
|
|
1478
1702
|
debugFramebuffers: Boolean(log.get("debug-framebuffers")),
|
|
1703
|
+
debugFactories: Boolean(log.get("debug-factories")),
|
|
1479
1704
|
debugWebGL: Boolean(log.get("debug-webgl")),
|
|
1480
1705
|
debugSpectorJS: void 0,
|
|
1481
1706
|
// Note: log setting is queried by the spector.js code
|
|
1482
1707
|
debugSpectorJSUrl: void 0,
|
|
1708
|
+
// Experimental
|
|
1709
|
+
_reuseDevices: false,
|
|
1710
|
+
_requestMaxLimits: true,
|
|
1711
|
+
_cacheShaders: false,
|
|
1712
|
+
_cachePipelines: false,
|
|
1713
|
+
_cacheDestroyPolicy: "unused",
|
|
1714
|
+
// TODO - Change these after confirming things work as expected
|
|
1715
|
+
_initializeFeatures: true,
|
|
1716
|
+
_disabledFeatures: {
|
|
1717
|
+
"compilation-status-async-webgl": true
|
|
1718
|
+
},
|
|
1483
1719
|
// INTERNAL
|
|
1484
1720
|
_handle: void 0
|
|
1485
1721
|
});
|
|
1486
1722
|
|
|
1487
1723
|
// src/adapter/luma.ts
|
|
1488
|
-
var isPage = isBrowser() && typeof document !== "undefined";
|
|
1489
|
-
var isPageLoaded = () => isPage && document.readyState === "complete";
|
|
1490
1724
|
var STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
1491
1725
|
var ERROR_MESSAGE = "No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.";
|
|
1492
1726
|
var _Luma = class {
|
|
@@ -1520,6 +1754,34 @@ var __exports__ = (() => {
|
|
|
1520
1754
|
log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)();
|
|
1521
1755
|
globalThis.luma = this;
|
|
1522
1756
|
}
|
|
1757
|
+
/** Creates a device. Asynchronously. */
|
|
1758
|
+
async createDevice(props_ = {}) {
|
|
1759
|
+
const props = { ..._Luma.defaultProps, ...props_ };
|
|
1760
|
+
const adapter = this.selectAdapter(props.type, props.adapters);
|
|
1761
|
+
if (!adapter) {
|
|
1762
|
+
throw new Error(ERROR_MESSAGE);
|
|
1763
|
+
}
|
|
1764
|
+
if (props.waitForPageLoad) {
|
|
1765
|
+
await adapter.pageLoaded;
|
|
1766
|
+
}
|
|
1767
|
+
return await adapter.create(props);
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice).
|
|
1771
|
+
* @param handle Externally created WebGL context or WebGPU device
|
|
1772
|
+
*/
|
|
1773
|
+
async attachDevice(handle, props) {
|
|
1774
|
+
const type = this._getTypeFromHandle(handle, props.adapters);
|
|
1775
|
+
const adapter = type && this.selectAdapter(type, props.adapters);
|
|
1776
|
+
if (!adapter) {
|
|
1777
|
+
throw new Error(ERROR_MESSAGE);
|
|
1778
|
+
}
|
|
1779
|
+
return await adapter?.attach?.(handle, props);
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Global adapter registration.
|
|
1783
|
+
* @deprecated Use props.adapters instead
|
|
1784
|
+
*/
|
|
1523
1785
|
registerAdapters(adapters) {
|
|
1524
1786
|
for (const deviceClass of adapters) {
|
|
1525
1787
|
this.preregisteredAdapters.set(deviceClass.type, deviceClass);
|
|
@@ -1527,92 +1789,75 @@ var __exports__ = (() => {
|
|
|
1527
1789
|
}
|
|
1528
1790
|
/** Get type strings for supported Devices */
|
|
1529
1791
|
getSupportedAdapters(adapters = []) {
|
|
1530
|
-
const adapterMap = this.
|
|
1792
|
+
const adapterMap = this._getAdapterMap(adapters);
|
|
1531
1793
|
return Array.from(adapterMap).map(([, adapter]) => adapter).filter((adapter) => adapter.isSupported?.()).map((adapter) => adapter.type);
|
|
1532
1794
|
}
|
|
1533
1795
|
/** Get type strings for best available Device */
|
|
1534
|
-
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1796
|
+
getBestAvailableAdapterType(adapters = []) {
|
|
1797
|
+
const KNOWN_ADAPTERS = ["webgpu", "webgl", "null"];
|
|
1798
|
+
const adapterMap = this._getAdapterMap(adapters);
|
|
1799
|
+
for (const type of KNOWN_ADAPTERS) {
|
|
1800
|
+
if (adapterMap.get(type)?.isSupported?.()) {
|
|
1801
|
+
return type;
|
|
1802
|
+
}
|
|
1541
1803
|
}
|
|
1542
1804
|
return null;
|
|
1543
1805
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
/** Creates a device. Asynchronously. */
|
|
1548
|
-
async createDevice(props = {}) {
|
|
1549
|
-
props = { ..._Luma.defaultProps, ...props };
|
|
1550
|
-
if (props.waitForPageLoad) {
|
|
1551
|
-
await _Luma.pageLoaded;
|
|
1552
|
-
}
|
|
1553
|
-
const adapterMap = this.getAdapterMap(props.adapters);
|
|
1554
|
-
let type = props.type || "";
|
|
1806
|
+
/** Select adapter of type from registered adapters */
|
|
1807
|
+
selectAdapter(type, adapters = []) {
|
|
1808
|
+
let selectedType = type;
|
|
1555
1809
|
if (type === "best-available") {
|
|
1556
|
-
|
|
1557
|
-
}
|
|
1558
|
-
const adapters = this.getAdapterMap(props.adapters) || adapterMap;
|
|
1559
|
-
const adapter = adapters.get(type);
|
|
1560
|
-
const device = await adapter?.create?.(props);
|
|
1561
|
-
if (device) {
|
|
1562
|
-
return device;
|
|
1563
|
-
}
|
|
1564
|
-
throw new Error(ERROR_MESSAGE);
|
|
1565
|
-
}
|
|
1566
|
-
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
|
|
1567
|
-
async attachDevice(props) {
|
|
1568
|
-
const adapters = this.getAdapterMap(props.adapters);
|
|
1569
|
-
let type = "";
|
|
1570
|
-
if (props.handle instanceof WebGL2RenderingContext) {
|
|
1571
|
-
type = "webgl";
|
|
1572
|
-
}
|
|
1573
|
-
if (props.createCanvasContext) {
|
|
1574
|
-
await _Luma.pageLoaded;
|
|
1575
|
-
}
|
|
1576
|
-
if (props.handle === null) {
|
|
1577
|
-
type = "unknown";
|
|
1578
|
-
}
|
|
1579
|
-
const adapter = adapters.get(type);
|
|
1580
|
-
const device = await adapter?.attach?.(null);
|
|
1581
|
-
if (device) {
|
|
1582
|
-
return device;
|
|
1810
|
+
selectedType = this.getBestAvailableAdapterType(adapters);
|
|
1583
1811
|
}
|
|
1584
|
-
|
|
1812
|
+
const adapterMap = this._getAdapterMap(adapters);
|
|
1813
|
+
return selectedType && adapterMap.get(selectedType) || null;
|
|
1585
1814
|
}
|
|
1586
1815
|
/**
|
|
1587
1816
|
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility.
|
|
1588
1817
|
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts.
|
|
1589
1818
|
*/
|
|
1590
1819
|
enforceWebGL2(enforce = true, adapters = []) {
|
|
1591
|
-
const adapterMap = this.
|
|
1820
|
+
const adapterMap = this._getAdapterMap(adapters);
|
|
1592
1821
|
const webgl2Adapter = adapterMap.get("webgl");
|
|
1593
1822
|
if (!webgl2Adapter) {
|
|
1594
1823
|
log.warn("enforceWebGL2: webgl adapter not found")();
|
|
1595
1824
|
}
|
|
1596
1825
|
webgl2Adapter?.enforceWebGL2?.(enforce);
|
|
1597
1826
|
}
|
|
1827
|
+
// DEPRECATED
|
|
1828
|
+
/** @deprecated */
|
|
1829
|
+
setDefaultDeviceProps(props) {
|
|
1830
|
+
Object.assign(_Luma.defaultProps, props);
|
|
1831
|
+
}
|
|
1832
|
+
// HELPERS
|
|
1598
1833
|
/** Convert a list of adapters to a map */
|
|
1599
|
-
|
|
1834
|
+
_getAdapterMap(adapters = []) {
|
|
1600
1835
|
const map = new Map(this.preregisteredAdapters);
|
|
1601
1836
|
for (const adapter of adapters) {
|
|
1602
1837
|
map.set(adapter.type, adapter);
|
|
1603
1838
|
}
|
|
1604
1839
|
return map;
|
|
1605
1840
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1841
|
+
/** Get type of a handle (for attachDevice) */
|
|
1842
|
+
_getTypeFromHandle(handle, adapters = []) {
|
|
1843
|
+
if (handle instanceof WebGL2RenderingContext) {
|
|
1844
|
+
return "webgl";
|
|
1845
|
+
}
|
|
1846
|
+
if (typeof GPUDevice !== "undefined" && handle instanceof GPUDevice) {
|
|
1847
|
+
return "webgpu";
|
|
1848
|
+
}
|
|
1849
|
+
if (handle?.queue) {
|
|
1850
|
+
return "webgpu";
|
|
1851
|
+
}
|
|
1852
|
+
if (handle === null) {
|
|
1853
|
+
return "null";
|
|
1615
1854
|
}
|
|
1855
|
+
if (handle instanceof WebGLRenderingContext) {
|
|
1856
|
+
log.warn("WebGL1 is not supported", handle)();
|
|
1857
|
+
} else {
|
|
1858
|
+
log.warn("Unknown handle type", handle)();
|
|
1859
|
+
}
|
|
1860
|
+
return null;
|
|
1616
1861
|
}
|
|
1617
1862
|
};
|
|
1618
1863
|
var Luma = _Luma;
|
|
@@ -1622,224 +1867,326 @@ var __exports__ = (() => {
|
|
|
1622
1867
|
adapters: void 0,
|
|
1623
1868
|
waitForPageLoad: true
|
|
1624
1869
|
});
|
|
1625
|
-
/**
|
|
1626
|
-
* Page load promise
|
|
1627
|
-
* Get a 'lazy' promise that resolves when the DOM is loaded.
|
|
1628
|
-
* @note Since there may be limitations on number of `load` event listeners,
|
|
1629
|
-
* it is recommended avoid calling this function until actually needed.
|
|
1630
|
-
* I.e. don't call it until you know that you will be looking up a string in the DOM.
|
|
1631
|
-
*/
|
|
1632
|
-
__publicField(Luma, "pageLoaded", getPageLoadPromise().then(() => {
|
|
1633
|
-
log.probe(2, "DOM is loaded")();
|
|
1634
|
-
}));
|
|
1635
1870
|
var luma = new Luma();
|
|
1636
|
-
function getPageLoadPromise() {
|
|
1637
|
-
if (isPageLoaded() || typeof window === "undefined") {
|
|
1638
|
-
return Promise.resolve();
|
|
1639
|
-
}
|
|
1640
|
-
return new Promise((resolve) => {
|
|
1641
|
-
window.addEventListener("load", () => resolve());
|
|
1642
|
-
});
|
|
1643
|
-
}
|
|
1644
1871
|
|
|
1645
1872
|
// src/adapter/adapter.ts
|
|
1646
1873
|
var Adapter = class {
|
|
1874
|
+
/**
|
|
1875
|
+
* Page load promise
|
|
1876
|
+
* Resolves when the DOM is loaded.
|
|
1877
|
+
* @note Since are be limitations on number of `load` event listeners,
|
|
1878
|
+
* it is recommended avoid calling this accessor until actually needed.
|
|
1879
|
+
* I.e. we don't call it unless you know that you will be looking up a string in the DOM.
|
|
1880
|
+
*/
|
|
1881
|
+
get pageLoaded() {
|
|
1882
|
+
return getPageLoadPromise();
|
|
1883
|
+
}
|
|
1647
1884
|
};
|
|
1885
|
+
var isPage = isBrowser() && typeof document !== "undefined";
|
|
1886
|
+
var isPageLoaded = () => isPage && document.readyState === "complete";
|
|
1887
|
+
var pageLoadPromise = null;
|
|
1888
|
+
function getPageLoadPromise() {
|
|
1889
|
+
if (!pageLoadPromise) {
|
|
1890
|
+
if (isPageLoaded() || typeof window === "undefined") {
|
|
1891
|
+
pageLoadPromise = Promise.resolve();
|
|
1892
|
+
} else {
|
|
1893
|
+
pageLoadPromise = new Promise((resolve) => window.addEventListener("load", () => resolve()));
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return pageLoadPromise;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
// src/utils/promise-utils.ts
|
|
1900
|
+
function withResolvers() {
|
|
1901
|
+
let resolve;
|
|
1902
|
+
let reject;
|
|
1903
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
1904
|
+
resolve = _resolve;
|
|
1905
|
+
reject = _reject;
|
|
1906
|
+
});
|
|
1907
|
+
return { promise, resolve, reject };
|
|
1908
|
+
}
|
|
1648
1909
|
|
|
1649
1910
|
// src/adapter/canvas-context.ts
|
|
1650
1911
|
var _CanvasContext = class {
|
|
1912
|
+
static isHTMLCanvas(canvas) {
|
|
1913
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
1914
|
+
}
|
|
1915
|
+
static isOffscreenCanvas(canvas) {
|
|
1916
|
+
return typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas;
|
|
1917
|
+
}
|
|
1651
1918
|
id;
|
|
1652
1919
|
props;
|
|
1653
1920
|
canvas;
|
|
1921
|
+
/** Handle to HTML canvas */
|
|
1654
1922
|
htmlCanvas;
|
|
1923
|
+
/** Handle to wrapped OffScreenCanvas */
|
|
1655
1924
|
offscreenCanvas;
|
|
1656
1925
|
type;
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1661
|
-
|
|
1926
|
+
/** Promise that resolved once the resize observer has updated the pixel size */
|
|
1927
|
+
initialized;
|
|
1928
|
+
isInitialized = false;
|
|
1929
|
+
/** Visibility is automatically updated (via an IntersectionObserver) */
|
|
1930
|
+
isVisible = true;
|
|
1931
|
+
/** Width of canvas in CSS units (tracked by a ResizeObserver) */
|
|
1932
|
+
cssWidth;
|
|
1933
|
+
/** Height of canvas in CSS units (tracked by a ResizeObserver) */
|
|
1934
|
+
cssHeight;
|
|
1935
|
+
/** Device pixel ratio. Automatically updated via media queries */
|
|
1936
|
+
devicePixelRatio;
|
|
1937
|
+
/** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
1938
|
+
devicePixelWidth;
|
|
1939
|
+
/** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
1940
|
+
devicePixelHeight;
|
|
1941
|
+
/** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */
|
|
1942
|
+
drawingBufferWidth;
|
|
1943
|
+
/** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
|
|
1944
|
+
drawingBufferHeight;
|
|
1945
|
+
_initializedResolvers = withResolvers();
|
|
1946
|
+
_resizeObserver;
|
|
1947
|
+
_intersectionObserver;
|
|
1948
|
+
_position;
|
|
1949
|
+
destroyed = false;
|
|
1662
1950
|
toString() {
|
|
1663
1951
|
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
1664
1952
|
}
|
|
1665
1953
|
constructor(props) {
|
|
1666
1954
|
this.props = { ..._CanvasContext.defaultProps, ...props };
|
|
1667
1955
|
props = this.props;
|
|
1956
|
+
this.initialized = this._initializedResolvers.promise;
|
|
1668
1957
|
if (!isBrowser()) {
|
|
1669
|
-
this.
|
|
1670
|
-
|
|
1671
|
-
this.
|
|
1672
|
-
this.height = this.props.height;
|
|
1673
|
-
this.canvas = null;
|
|
1674
|
-
return;
|
|
1675
|
-
}
|
|
1676
|
-
if (!props.canvas) {
|
|
1677
|
-
const canvas = createCanvas(props);
|
|
1678
|
-
const container = getContainer(props?.container || null);
|
|
1679
|
-
container.insertBefore(canvas, container.firstChild);
|
|
1680
|
-
this.canvas = canvas;
|
|
1681
|
-
if (!props?.visible) {
|
|
1682
|
-
this.canvas.style.visibility = "hidden";
|
|
1683
|
-
}
|
|
1958
|
+
this.canvas = { width: props.width || 1, height: props.height || 1 };
|
|
1959
|
+
} else if (!props.canvas) {
|
|
1960
|
+
this.canvas = createCanvasElement(props);
|
|
1684
1961
|
} else if (typeof props.canvas === "string") {
|
|
1685
1962
|
this.canvas = getCanvasFromDOM(props.canvas);
|
|
1686
1963
|
} else {
|
|
1687
1964
|
this.canvas = props.canvas;
|
|
1688
1965
|
}
|
|
1689
|
-
if (this.canvas
|
|
1690
|
-
this.id = this.canvas.id;
|
|
1966
|
+
if (_CanvasContext.isHTMLCanvas(this.canvas)) {
|
|
1967
|
+
this.id = props.id || this.canvas.id;
|
|
1691
1968
|
this.type = "html-canvas";
|
|
1692
1969
|
this.htmlCanvas = this.canvas;
|
|
1693
|
-
} else {
|
|
1694
|
-
this.id = "offscreen-canvas";
|
|
1970
|
+
} else if (_CanvasContext.isOffscreenCanvas(this.canvas)) {
|
|
1971
|
+
this.id = props.id || "offscreen-canvas";
|
|
1695
1972
|
this.type = "offscreen-canvas";
|
|
1696
1973
|
this.offscreenCanvas = this.canvas;
|
|
1974
|
+
} else {
|
|
1975
|
+
this.id = props.id || "node-canvas-context";
|
|
1976
|
+
this.type = "node";
|
|
1697
1977
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1978
|
+
this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;
|
|
1979
|
+
this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;
|
|
1980
|
+
this.devicePixelWidth = this.canvas.width;
|
|
1981
|
+
this.devicePixelHeight = this.canvas.height;
|
|
1982
|
+
this.drawingBufferWidth = this.canvas.width;
|
|
1983
|
+
this.drawingBufferHeight = this.canvas.height;
|
|
1984
|
+
this.devicePixelRatio = globalThis.devicePixelRatio || 1;
|
|
1985
|
+
this._position = [0, 0];
|
|
1986
|
+
if (_CanvasContext.isHTMLCanvas(this.canvas)) {
|
|
1987
|
+
this._intersectionObserver = new IntersectionObserver(
|
|
1988
|
+
(entries) => this._handleIntersection(entries)
|
|
1989
|
+
);
|
|
1990
|
+
this._intersectionObserver.observe(this.canvas);
|
|
1991
|
+
this._resizeObserver = new ResizeObserver((entries) => this._handleResize(entries));
|
|
1992
|
+
try {
|
|
1993
|
+
this._resizeObserver.observe(this.canvas, { box: "device-pixel-content-box" });
|
|
1994
|
+
} catch {
|
|
1995
|
+
this._resizeObserver.observe(this.canvas, { box: "content-box" });
|
|
1996
|
+
}
|
|
1997
|
+
setTimeout(() => this._observeDevicePixelRatio(), 0);
|
|
1998
|
+
if (this.props.trackPosition) {
|
|
1999
|
+
this._trackPosition();
|
|
2000
|
+
}
|
|
1707
2001
|
}
|
|
1708
2002
|
}
|
|
2003
|
+
destroy() {
|
|
2004
|
+
this.destroyed = true;
|
|
2005
|
+
}
|
|
2006
|
+
// SIZE METHODS
|
|
1709
2007
|
/**
|
|
1710
|
-
* Returns the
|
|
1711
|
-
*
|
|
2008
|
+
* Returns the size covered by the canvas in CSS pixels
|
|
2009
|
+
* @note This can be different from the actual device pixel size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
2010
|
+
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
1712
2011
|
*/
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
return
|
|
2012
|
+
getCSSSize() {
|
|
2013
|
+
return [this.cssWidth, this.cssHeight];
|
|
2014
|
+
}
|
|
2015
|
+
getPosition() {
|
|
2016
|
+
return this._position;
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Returns the size covered by the canvas in actual device pixels.
|
|
2020
|
+
* @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
2021
|
+
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
2022
|
+
*/
|
|
2023
|
+
getDevicePixelSize() {
|
|
2024
|
+
return [this.devicePixelWidth, this.devicePixelHeight];
|
|
2025
|
+
}
|
|
2026
|
+
/** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */
|
|
2027
|
+
getDrawingBufferSize() {
|
|
2028
|
+
return [this.drawingBufferWidth, this.drawingBufferHeight];
|
|
2029
|
+
}
|
|
2030
|
+
/** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */
|
|
2031
|
+
getMaxDrawingBufferSize() {
|
|
2032
|
+
const maxTextureDimension = this.device.limits.maxTextureDimension2D;
|
|
2033
|
+
return [maxTextureDimension, maxTextureDimension];
|
|
2034
|
+
}
|
|
2035
|
+
/** Update the canvas drawing buffer size. Called automatically if props.autoResize is true. */
|
|
2036
|
+
setDrawingBufferSize(width, height) {
|
|
2037
|
+
this.canvas.width = width;
|
|
2038
|
+
this.canvas.height = height;
|
|
2039
|
+
this.drawingBufferWidth = width;
|
|
2040
|
+
this.drawingBufferHeight = height;
|
|
1726
2041
|
}
|
|
1727
2042
|
/**
|
|
1728
|
-
* Returns the
|
|
1729
|
-
* @note This can be
|
|
1730
|
-
*
|
|
1731
|
-
* This is the size required to cover the canvas, adjusted for DPR
|
|
2043
|
+
* Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true
|
|
2044
|
+
* @note This can be a fractional (non-integer) number, e.g. when the user zooms in the browser.
|
|
2045
|
+
* @note This function handles the non-HTML canvas cases
|
|
1732
2046
|
*/
|
|
2047
|
+
getDevicePixelRatio() {
|
|
2048
|
+
const dpr = typeof window !== "undefined" && window.devicePixelRatio;
|
|
2049
|
+
return dpr || 1;
|
|
2050
|
+
}
|
|
2051
|
+
// DEPRECATED METHODS
|
|
2052
|
+
/**
|
|
2053
|
+
* Maps CSS pixel position to device pixel position
|
|
2054
|
+
*/
|
|
2055
|
+
cssToDevicePixels(cssPixel, yInvert = true) {
|
|
2056
|
+
const ratio = this.cssToDeviceRatio();
|
|
2057
|
+
const [width, height] = this.getDrawingBufferSize();
|
|
2058
|
+
return scalePixels(cssPixel, ratio, width, height, yInvert);
|
|
2059
|
+
}
|
|
2060
|
+
/** @deprecated - use .getDevicePixelSize() */
|
|
1733
2061
|
getPixelSize() {
|
|
1734
|
-
|
|
1735
|
-
case "node":
|
|
1736
|
-
return [this.width, this.height];
|
|
1737
|
-
case "offscreen-canvas":
|
|
1738
|
-
return [this.canvas.width, this.canvas.height];
|
|
1739
|
-
case "html-canvas":
|
|
1740
|
-
const dpr = this.getDevicePixelRatio();
|
|
1741
|
-
const canvas = this.canvas;
|
|
1742
|
-
return canvas.parentElement ? [canvas.clientWidth * dpr, canvas.clientHeight * dpr] : [this.canvas.width, this.canvas.height];
|
|
1743
|
-
default:
|
|
1744
|
-
throw new Error(this.type);
|
|
1745
|
-
}
|
|
2062
|
+
return this.getDevicePixelSize();
|
|
1746
2063
|
}
|
|
2064
|
+
/** @deprecated - TODO which values should we use for aspect */
|
|
1747
2065
|
getAspect() {
|
|
1748
|
-
const [width, height] = this.
|
|
2066
|
+
const [width, height] = this.getDevicePixelSize();
|
|
1749
2067
|
return width / height;
|
|
1750
2068
|
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Returns multiplier need to convert CSS size to Device size
|
|
1753
|
-
*/
|
|
2069
|
+
/** @deprecated Returns multiplier need to convert CSS size to Device size */
|
|
1754
2070
|
cssToDeviceRatio() {
|
|
1755
2071
|
try {
|
|
1756
2072
|
const [drawingBufferWidth] = this.getDrawingBufferSize();
|
|
1757
|
-
const
|
|
1758
|
-
return
|
|
2073
|
+
const [cssWidth] = this.getCSSSize();
|
|
2074
|
+
return cssWidth ? drawingBufferWidth / cssWidth : 1;
|
|
1759
2075
|
} catch {
|
|
1760
2076
|
return 1;
|
|
1761
2077
|
}
|
|
1762
2078
|
}
|
|
2079
|
+
/** @deprecated Use canvasContext.setDrawingBufferSize() */
|
|
2080
|
+
resize(size) {
|
|
2081
|
+
this.setDrawingBufferSize(size.width, size.height);
|
|
2082
|
+
}
|
|
2083
|
+
// IMPLEMENTATION
|
|
1763
2084
|
/**
|
|
1764
|
-
*
|
|
2085
|
+
* Allows subclass constructor to override the canvas id for auto created canvases.
|
|
2086
|
+
* This can really help when debugging DOM in apps that create multiple devices
|
|
1765
2087
|
*/
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
2088
|
+
_setAutoCreatedCanvasId(id) {
|
|
2089
|
+
if (this.htmlCanvas?.id === "lumagl-auto-created-canvas") {
|
|
2090
|
+
this.htmlCanvas.id = id;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
/** reacts to an observed intersection */
|
|
2094
|
+
_handleIntersection(entries) {
|
|
2095
|
+
const entry = entries.find((entry_) => entry_.target === this.canvas);
|
|
2096
|
+
if (!entry) {
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
const isVisible = entry.isIntersecting;
|
|
2100
|
+
if (this.isVisible !== isVisible) {
|
|
2101
|
+
this.isVisible = isVisible;
|
|
2102
|
+
this.device.props.onVisibilityChange(this);
|
|
2103
|
+
}
|
|
1770
2104
|
}
|
|
1771
2105
|
/**
|
|
1772
|
-
*
|
|
1773
|
-
* @
|
|
2106
|
+
* Reacts to an observed resize by using the most accurate pixel size information the browser can provide
|
|
2107
|
+
* @see https://web.dev/articles/device-pixel-content-box
|
|
2108
|
+
* @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html
|
|
1774
2109
|
*/
|
|
1775
|
-
|
|
1776
|
-
|
|
2110
|
+
_handleResize(entries) {
|
|
2111
|
+
const entry = entries.find((entry_) => entry_.target === this.canvas);
|
|
2112
|
+
if (!entry) {
|
|
1777
2113
|
return;
|
|
1778
2114
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
this.htmlCanvas.width = canvasWidth;
|
|
1793
|
-
this.htmlCanvas.height = canvasHeight;
|
|
1794
|
-
const gl = this.device.gl;
|
|
1795
|
-
if (gl) {
|
|
1796
|
-
const [drawingBufferWidth, drawingBufferHeight] = this.getDrawingBufferSize();
|
|
1797
|
-
if (drawingBufferWidth !== canvasWidth || drawingBufferHeight !== canvasHeight) {
|
|
1798
|
-
clampedPixelRatio = Math.min(
|
|
1799
|
-
drawingBufferWidth / clientWidth,
|
|
1800
|
-
drawingBufferHeight / clientHeight
|
|
1801
|
-
);
|
|
1802
|
-
this.htmlCanvas.width = Math.floor(clientWidth * clampedPixelRatio);
|
|
1803
|
-
this.htmlCanvas.height = Math.floor(clientHeight * clampedPixelRatio);
|
|
1804
|
-
log.warn("Device pixel ratio clamped")();
|
|
1805
|
-
}
|
|
1806
|
-
this._canvasSizeInfo.clientWidth = clientWidth;
|
|
1807
|
-
this._canvasSizeInfo.clientHeight = clientHeight;
|
|
1808
|
-
this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;
|
|
2115
|
+
this.cssWidth = entry.contentBoxSize[0].inlineSize;
|
|
2116
|
+
this.cssHeight = entry.contentBoxSize[0].blockSize;
|
|
2117
|
+
const oldPixelSize = this.getDevicePixelSize();
|
|
2118
|
+
const devicePixelWidth = entry.devicePixelContentBoxSize?.[0].inlineSize || entry.contentBoxSize[0].inlineSize * devicePixelRatio;
|
|
2119
|
+
const devicePixelHeight = entry.devicePixelContentBoxSize?.[0].blockSize || entry.contentBoxSize[0].blockSize * devicePixelRatio;
|
|
2120
|
+
const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();
|
|
2121
|
+
this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
|
|
2122
|
+
this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
|
|
2123
|
+
if (this.props.autoResize) {
|
|
2124
|
+
if (this.props.useDevicePixels) {
|
|
2125
|
+
this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
|
|
2126
|
+
} else {
|
|
2127
|
+
this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
|
|
1809
2128
|
}
|
|
1810
|
-
|
|
2129
|
+
this._updateDevice();
|
|
2130
|
+
}
|
|
2131
|
+
this._initializedResolvers.resolve();
|
|
2132
|
+
this.isInitialized = true;
|
|
2133
|
+
this.updatePosition();
|
|
2134
|
+
this.device.props.onResize(this, { oldPixelSize });
|
|
2135
|
+
}
|
|
2136
|
+
/** Monitor DPR changes */
|
|
2137
|
+
_observeDevicePixelRatio() {
|
|
2138
|
+
const oldRatio = this.devicePixelRatio;
|
|
2139
|
+
this.devicePixelRatio = window.devicePixelRatio;
|
|
2140
|
+
this.updatePosition();
|
|
2141
|
+
this.device.props.onDevicePixelRatioChange(this, { oldRatio });
|
|
2142
|
+
matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener(
|
|
2143
|
+
"change",
|
|
2144
|
+
() => this._observeDevicePixelRatio(),
|
|
2145
|
+
{ once: true }
|
|
2146
|
+
);
|
|
1811
2147
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2148
|
+
/** Start tracking positions with a timer */
|
|
2149
|
+
_trackPosition(intervalMs = 100) {
|
|
2150
|
+
const intervalId = setInterval(() => {
|
|
2151
|
+
if (this.destroyed) {
|
|
2152
|
+
clearInterval(intervalId);
|
|
2153
|
+
} else {
|
|
2154
|
+
this.updatePosition();
|
|
2155
|
+
}
|
|
2156
|
+
}, intervalMs);
|
|
1820
2157
|
}
|
|
1821
2158
|
/**
|
|
1822
|
-
*
|
|
1823
|
-
*
|
|
2159
|
+
* Calculated the absolute position of the canvas
|
|
2160
|
+
* @note - getBoundingClientRect() is normally cheap but can be expensive
|
|
2161
|
+
* if called before browser has finished a reflow. Should not be the case here.
|
|
1824
2162
|
*/
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
2163
|
+
updatePosition() {
|
|
2164
|
+
const newRect = this.htmlCanvas?.getBoundingClientRect();
|
|
2165
|
+
if (newRect) {
|
|
2166
|
+
const position = [newRect.left, newRect.top];
|
|
2167
|
+
this._position ??= position;
|
|
2168
|
+
const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];
|
|
2169
|
+
if (positionChanged) {
|
|
2170
|
+
const oldPosition = this._position;
|
|
2171
|
+
this._position = position;
|
|
2172
|
+
this.device.props.onPositionChange?.(this, { oldPosition });
|
|
2173
|
+
}
|
|
1828
2174
|
}
|
|
1829
2175
|
}
|
|
1830
2176
|
};
|
|
1831
2177
|
var CanvasContext = _CanvasContext;
|
|
1832
2178
|
__publicField(CanvasContext, "defaultProps", {
|
|
2179
|
+
id: void 0,
|
|
1833
2180
|
canvas: null,
|
|
1834
2181
|
width: 800,
|
|
1835
|
-
// width are height are only used by headless gl
|
|
1836
2182
|
height: 600,
|
|
1837
2183
|
useDevicePixels: true,
|
|
1838
2184
|
autoResize: true,
|
|
1839
2185
|
container: null,
|
|
1840
2186
|
visible: true,
|
|
1841
2187
|
alphaMode: "opaque",
|
|
1842
|
-
colorSpace: "srgb"
|
|
2188
|
+
colorSpace: "srgb",
|
|
2189
|
+
trackPosition: false
|
|
1843
2190
|
});
|
|
1844
2191
|
function getContainer(container) {
|
|
1845
2192
|
if (typeof container === "string") {
|
|
@@ -1848,27 +2195,33 @@ var __exports__ = (() => {
|
|
|
1848
2195
|
throw new Error(`${container} is not an HTML element`);
|
|
1849
2196
|
}
|
|
1850
2197
|
return element;
|
|
1851
|
-
}
|
|
2198
|
+
}
|
|
2199
|
+
if (container) {
|
|
1852
2200
|
return container;
|
|
1853
2201
|
}
|
|
1854
2202
|
return document.body;
|
|
1855
2203
|
}
|
|
1856
2204
|
function getCanvasFromDOM(canvasId) {
|
|
1857
2205
|
const canvas = document.getElementById(canvasId);
|
|
1858
|
-
if (!(canvas
|
|
2206
|
+
if (!CanvasContext.isHTMLCanvas(canvas)) {
|
|
1859
2207
|
throw new Error("Object is not a canvas element");
|
|
1860
2208
|
}
|
|
1861
2209
|
return canvas;
|
|
1862
2210
|
}
|
|
1863
|
-
function
|
|
2211
|
+
function createCanvasElement(props) {
|
|
1864
2212
|
const { width, height } = props;
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
2213
|
+
const newCanvas = document.createElement("canvas");
|
|
2214
|
+
newCanvas.id = uid("lumagl-auto-created-canvas");
|
|
2215
|
+
newCanvas.width = width || 1;
|
|
2216
|
+
newCanvas.height = height || 1;
|
|
2217
|
+
newCanvas.style.width = Number.isFinite(width) ? `${width}px` : "100%";
|
|
2218
|
+
newCanvas.style.height = Number.isFinite(height) ? `${height}px` : "100%";
|
|
2219
|
+
if (!props?.visible) {
|
|
2220
|
+
newCanvas.style.visibility = "hidden";
|
|
2221
|
+
}
|
|
2222
|
+
const container = getContainer(props?.container || null);
|
|
2223
|
+
container.insertBefore(newCanvas, container.firstChild);
|
|
2224
|
+
return newCanvas;
|
|
1872
2225
|
}
|
|
1873
2226
|
function scalePixels(pixel, ratio, width, height, yInvert) {
|
|
1874
2227
|
const point = pixel;
|
|
@@ -1901,16 +2254,50 @@ var __exports__ = (() => {
|
|
|
1901
2254
|
return yInvert ? Math.max(0, height - 1 - Math.round(y * ratio)) : Math.min(Math.round(y * ratio), height - 1);
|
|
1902
2255
|
}
|
|
1903
2256
|
|
|
1904
|
-
// src/adapter/resources/
|
|
1905
|
-
var
|
|
2257
|
+
// src/adapter/resources/sampler.ts
|
|
2258
|
+
var _Sampler = class extends Resource {
|
|
1906
2259
|
get [Symbol.toStringTag]() {
|
|
1907
|
-
return "
|
|
2260
|
+
return "Sampler";
|
|
1908
2261
|
}
|
|
1909
|
-
|
|
1910
|
-
|
|
2262
|
+
constructor(device, props) {
|
|
2263
|
+
props = _Sampler.normalizeProps(device, props);
|
|
2264
|
+
super(device, props, _Sampler.defaultProps);
|
|
2265
|
+
}
|
|
2266
|
+
static normalizeProps(device, props) {
|
|
2267
|
+
return props;
|
|
1911
2268
|
}
|
|
2269
|
+
};
|
|
2270
|
+
var Sampler = _Sampler;
|
|
2271
|
+
__publicField(Sampler, "defaultProps", {
|
|
2272
|
+
...Resource.defaultProps,
|
|
2273
|
+
type: "color-sampler",
|
|
2274
|
+
addressModeU: "clamp-to-edge",
|
|
2275
|
+
addressModeV: "clamp-to-edge",
|
|
2276
|
+
addressModeW: "clamp-to-edge",
|
|
2277
|
+
magFilter: "nearest",
|
|
2278
|
+
minFilter: "nearest",
|
|
2279
|
+
mipmapFilter: "none",
|
|
2280
|
+
lodMinClamp: 0,
|
|
2281
|
+
lodMaxClamp: 32,
|
|
2282
|
+
// Per WebGPU spec
|
|
2283
|
+
compare: "less-equal",
|
|
2284
|
+
maxAnisotropy: 1
|
|
2285
|
+
});
|
|
2286
|
+
|
|
2287
|
+
// src/adapter/resources/texture.ts
|
|
2288
|
+
var BASE_DIMENSIONS = {
|
|
2289
|
+
"1d": "1d",
|
|
2290
|
+
"2d": "2d",
|
|
2291
|
+
"2d-array": "2d",
|
|
2292
|
+
cube: "2d",
|
|
2293
|
+
"cube-array": "2d",
|
|
2294
|
+
"3d": "3d"
|
|
2295
|
+
};
|
|
2296
|
+
var _Texture = class extends Resource {
|
|
1912
2297
|
/** dimension of this texture */
|
|
1913
2298
|
dimension;
|
|
2299
|
+
/** base dimension of this texture */
|
|
2300
|
+
baseDimension;
|
|
1914
2301
|
/** format of this texture */
|
|
1915
2302
|
format;
|
|
1916
2303
|
/** width in pixels of this texture */
|
|
@@ -1923,133 +2310,55 @@ var __exports__ = (() => {
|
|
|
1923
2310
|
mipLevels;
|
|
1924
2311
|
/** "Time" of last update. Monotonically increasing timestamp. TODO move to AsyncTexture? */
|
|
1925
2312
|
updateTimestamp;
|
|
2313
|
+
get [Symbol.toStringTag]() {
|
|
2314
|
+
return "Texture";
|
|
2315
|
+
}
|
|
2316
|
+
toString() {
|
|
2317
|
+
return `Texture(${this.id},${this.format},${this.width}x${this.height})`;
|
|
2318
|
+
}
|
|
1926
2319
|
/** Do not use directly. Create with device.createTexture() */
|
|
1927
2320
|
constructor(device, props) {
|
|
1928
2321
|
props = _Texture.normalizeProps(device, props);
|
|
1929
2322
|
super(device, props, _Texture.defaultProps);
|
|
1930
2323
|
this.dimension = this.props.dimension;
|
|
2324
|
+
this.baseDimension = BASE_DIMENSIONS[this.dimension];
|
|
1931
2325
|
this.format = this.props.format;
|
|
1932
2326
|
this.width = this.props.width;
|
|
1933
2327
|
this.height = this.props.height;
|
|
1934
2328
|
this.depth = this.props.depth;
|
|
2329
|
+
this.mipLevels = this.props.mipLevels;
|
|
1935
2330
|
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2331
|
+
if (device.isExternalImage(props.data)) {
|
|
2332
|
+
const size = device.getExternalImageSize(props.data);
|
|
2333
|
+
this.width = size?.width || 1;
|
|
2334
|
+
this.height = size?.height || 1;
|
|
2335
|
+
} else {
|
|
2336
|
+
this.width = 1;
|
|
2337
|
+
this.height = 1;
|
|
2338
|
+
if (this.props.width === void 0 || this.props.height === void 0) {
|
|
2339
|
+
log.warn(
|
|
2340
|
+
`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`
|
|
2341
|
+
)();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
1942
2344
|
}
|
|
1943
|
-
this.mipLevels = this.props.mipLevels === "pyramid" ? _Texture.getMipLevelCount(this.width, this.height) : this.props.mipLevels || 1;
|
|
1944
2345
|
this.updateTimestamp = device.incrementTimestamp();
|
|
1945
2346
|
}
|
|
2347
|
+
/** Set sampler props associated with this texture */
|
|
2348
|
+
setSampler(sampler) {
|
|
2349
|
+
this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
|
|
2350
|
+
}
|
|
1946
2351
|
/**
|
|
1947
|
-
* Create a new texture with the same parameters and optionally
|
|
2352
|
+
* Create a new texture with the same parameters and optionally a different size
|
|
1948
2353
|
* @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size.
|
|
1949
2354
|
* @note Does not copy contents of the texture
|
|
1950
2355
|
*/
|
|
1951
2356
|
clone(size) {
|
|
1952
2357
|
return this.device.createTexture({ ...this.props, ...size });
|
|
1953
2358
|
}
|
|
1954
|
-
/** Check if data is an external image */
|
|
1955
|
-
static isExternalImage(data) {
|
|
1956
|
-
return typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement || typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement || typeof VideoFrame !== "undefined" && data instanceof VideoFrame || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas;
|
|
1957
|
-
}
|
|
1958
|
-
/** Determine size (width and height) of provided image data */
|
|
1959
|
-
static getExternalImageSize(data) {
|
|
1960
|
-
if (typeof ImageData !== "undefined" && data instanceof ImageData || typeof ImageBitmap !== "undefined" && data instanceof ImageBitmap || typeof HTMLCanvasElement !== "undefined" && data instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && data instanceof OffscreenCanvas) {
|
|
1961
|
-
return { width: data.width, height: data.height };
|
|
1962
|
-
}
|
|
1963
|
-
if (typeof HTMLImageElement !== "undefined" && data instanceof HTMLImageElement) {
|
|
1964
|
-
return { width: data.naturalWidth, height: data.naturalHeight };
|
|
1965
|
-
}
|
|
1966
|
-
if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
|
|
1967
|
-
return { width: data.videoWidth, height: data.videoHeight };
|
|
1968
|
-
}
|
|
1969
|
-
if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
|
|
1970
|
-
return { width: data.displayWidth, height: data.displayHeight };
|
|
1971
|
-
}
|
|
1972
|
-
throw new Error("Unknown image type");
|
|
1973
|
-
}
|
|
1974
|
-
/** Check if texture data is a typed array */
|
|
1975
|
-
static isTextureLevelData(data) {
|
|
1976
|
-
const typedArray = data?.data;
|
|
1977
|
-
return ArrayBuffer.isView(typedArray);
|
|
1978
|
-
}
|
|
1979
|
-
/** Get the size of the texture described by the provided TextureData */
|
|
1980
|
-
static getTextureDataSize(data) {
|
|
1981
|
-
if (!data) {
|
|
1982
|
-
return null;
|
|
1983
|
-
}
|
|
1984
|
-
if (ArrayBuffer.isView(data)) {
|
|
1985
|
-
return null;
|
|
1986
|
-
}
|
|
1987
|
-
if (Array.isArray(data)) {
|
|
1988
|
-
return _Texture.getTextureDataSize(data[0]);
|
|
1989
|
-
}
|
|
1990
|
-
if (_Texture.isExternalImage(data)) {
|
|
1991
|
-
return _Texture.getExternalImageSize(data);
|
|
1992
|
-
}
|
|
1993
|
-
if (data && typeof data === "object" && data.constructor === Object) {
|
|
1994
|
-
const textureDataArray = Object.values(data);
|
|
1995
|
-
const untypedData = textureDataArray[0];
|
|
1996
|
-
return { width: untypedData.width, height: untypedData.height };
|
|
1997
|
-
}
|
|
1998
|
-
throw new Error("texture size deduction failed");
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Normalize TextureData to an array of TextureLevelData / ExternalImages
|
|
2002
|
-
* @param data
|
|
2003
|
-
* @param options
|
|
2004
|
-
* @returns array of TextureLevelData / ExternalImages
|
|
2005
|
-
*/
|
|
2006
|
-
static normalizeTextureData(data, options) {
|
|
2007
|
-
let lodArray;
|
|
2008
|
-
if (ArrayBuffer.isView(data)) {
|
|
2009
|
-
lodArray = [
|
|
2010
|
-
{
|
|
2011
|
-
// ts-expect-error does data really need to be Uint8ClampedArray?
|
|
2012
|
-
data,
|
|
2013
|
-
width: options.width,
|
|
2014
|
-
height: options.height
|
|
2015
|
-
// depth: options.depth
|
|
2016
|
-
}
|
|
2017
|
-
];
|
|
2018
|
-
} else if (!Array.isArray(data)) {
|
|
2019
|
-
lodArray = [data];
|
|
2020
|
-
} else {
|
|
2021
|
-
lodArray = data;
|
|
2022
|
-
}
|
|
2023
|
-
return lodArray;
|
|
2024
|
-
}
|
|
2025
|
-
/** Calculate the number of mip levels for a texture of width and height */
|
|
2026
|
-
static getMipLevelCount(width, height) {
|
|
2027
|
-
return Math.floor(Math.log2(Math.max(width, height))) + 1;
|
|
2028
|
-
}
|
|
2029
|
-
/** Convert luma.gl cubemap face constants to depth index */
|
|
2030
|
-
static getCubeFaceDepth(face) {
|
|
2031
|
-
switch (face) {
|
|
2032
|
-
case "+X":
|
|
2033
|
-
return 0;
|
|
2034
|
-
case "-X":
|
|
2035
|
-
return 1;
|
|
2036
|
-
case "+Y":
|
|
2037
|
-
return 2;
|
|
2038
|
-
case "-Y":
|
|
2039
|
-
return 3;
|
|
2040
|
-
case "+Z":
|
|
2041
|
-
return 4;
|
|
2042
|
-
case "-Z":
|
|
2043
|
-
return 5;
|
|
2044
|
-
default:
|
|
2045
|
-
throw new Error(face);
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
2359
|
/** Ensure we have integer coordinates */
|
|
2049
2360
|
static normalizeProps(device, props) {
|
|
2050
2361
|
const newProps = { ...props };
|
|
2051
|
-
const overriddenDefaultProps = device?.props?._resourceDefaults?.texture || {};
|
|
2052
|
-
Object.assign(newProps, overriddenDefaultProps);
|
|
2053
2362
|
const { width, height } = newProps;
|
|
2054
2363
|
if (typeof width === "number") {
|
|
2055
2364
|
newProps.width = Math.max(1, Math.ceil(width));
|
|
@@ -2059,30 +2368,98 @@ var __exports__ = (() => {
|
|
|
2059
2368
|
}
|
|
2060
2369
|
return newProps;
|
|
2061
2370
|
}
|
|
2371
|
+
// HELPERS
|
|
2372
|
+
/** Initialize texture with supplied props */
|
|
2373
|
+
// eslint-disable-next-line max-statements
|
|
2374
|
+
_initializeData(data) {
|
|
2375
|
+
if (this.device.isExternalImage(data)) {
|
|
2376
|
+
this.copyExternalImage({
|
|
2377
|
+
image: data,
|
|
2378
|
+
width: this.width,
|
|
2379
|
+
height: this.height,
|
|
2380
|
+
depth: this.depth,
|
|
2381
|
+
mipLevel: 0,
|
|
2382
|
+
x: 0,
|
|
2383
|
+
y: 0,
|
|
2384
|
+
z: 0,
|
|
2385
|
+
aspect: "all",
|
|
2386
|
+
colorSpace: "srgb",
|
|
2387
|
+
premultipliedAlpha: false,
|
|
2388
|
+
flipY: false
|
|
2389
|
+
});
|
|
2390
|
+
} else if (data) {
|
|
2391
|
+
this.copyImageData({
|
|
2392
|
+
data,
|
|
2393
|
+
// width: this.width,
|
|
2394
|
+
// height: this.height,
|
|
2395
|
+
// depth: this.depth,
|
|
2396
|
+
mipLevel: 0,
|
|
2397
|
+
x: 0,
|
|
2398
|
+
y: 0,
|
|
2399
|
+
z: 0,
|
|
2400
|
+
aspect: "all"
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
_normalizeCopyImageDataOptions(options_) {
|
|
2405
|
+
const { width, height, depth } = this;
|
|
2406
|
+
const options = { ..._Texture.defaultCopyDataOptions, width, height, depth, ...options_ };
|
|
2407
|
+
const info = this.device.getTextureFormatInfo(this.format);
|
|
2408
|
+
if (!options_.bytesPerRow && !info.bytesPerPixel) {
|
|
2409
|
+
throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);
|
|
2410
|
+
}
|
|
2411
|
+
options.bytesPerRow = options_.bytesPerRow || width * (info.bytesPerPixel || 4);
|
|
2412
|
+
options.rowsPerImage = options_.rowsPerImage || height;
|
|
2413
|
+
return options;
|
|
2414
|
+
}
|
|
2415
|
+
_normalizeCopyExternalImageOptions(options_) {
|
|
2416
|
+
const size = this.device.getExternalImageSize(options_.image);
|
|
2417
|
+
const options = { ..._Texture.defaultCopyExternalImageOptions, ...size, ...options_ };
|
|
2418
|
+
options.width = Math.min(options.width, this.width - options.x);
|
|
2419
|
+
options.height = Math.min(options.height, this.height - options.y);
|
|
2420
|
+
return options;
|
|
2421
|
+
}
|
|
2062
2422
|
};
|
|
2063
2423
|
var Texture = _Texture;
|
|
2424
|
+
/** The texture can be bound for use as a sampled texture in a shader */
|
|
2425
|
+
__publicField(Texture, "SAMPLE", 4);
|
|
2426
|
+
/** The texture can be bound for use as a storage texture in a shader */
|
|
2427
|
+
__publicField(Texture, "STORAGE", 8);
|
|
2428
|
+
/** The texture can be used as a color or depth/stencil attachment in a render pass */
|
|
2429
|
+
__publicField(Texture, "RENDER", 16);
|
|
2430
|
+
/** The texture can be used as the source of a copy operation */
|
|
2064
2431
|
__publicField(Texture, "COPY_SRC", 1);
|
|
2432
|
+
/** he texture can be used as the destination of a copy or write operation */
|
|
2065
2433
|
__publicField(Texture, "COPY_DST", 2);
|
|
2434
|
+
/** @deprecated Use Texture.SAMPLE */
|
|
2066
2435
|
__publicField(Texture, "TEXTURE", 4);
|
|
2067
|
-
|
|
2436
|
+
/** @deprecated Use Texture.RENDER */
|
|
2068
2437
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
2069
|
-
|
|
2438
|
+
/** Default options */
|
|
2070
2439
|
__publicField(Texture, "defaultProps", {
|
|
2071
2440
|
...Resource.defaultProps,
|
|
2072
2441
|
data: null,
|
|
2073
2442
|
dimension: "2d",
|
|
2074
2443
|
format: "rgba8unorm",
|
|
2444
|
+
usage: _Texture.TEXTURE | _Texture.RENDER_ATTACHMENT | _Texture.COPY_DST,
|
|
2075
2445
|
width: void 0,
|
|
2076
2446
|
height: void 0,
|
|
2077
2447
|
depth: 1,
|
|
2078
|
-
|
|
2079
|
-
compressed: false,
|
|
2080
|
-
usage: 0,
|
|
2081
|
-
mipLevels: void 0,
|
|
2448
|
+
mipLevels: 1,
|
|
2082
2449
|
samples: void 0,
|
|
2083
2450
|
sampler: {},
|
|
2084
|
-
view: void 0
|
|
2085
|
-
|
|
2451
|
+
view: void 0
|
|
2452
|
+
});
|
|
2453
|
+
__publicField(Texture, "defaultCopyDataOptions", {
|
|
2454
|
+
data: void 0,
|
|
2455
|
+
byteOffset: 0,
|
|
2456
|
+
bytesPerRow: void 0,
|
|
2457
|
+
rowsPerImage: void 0,
|
|
2458
|
+
mipLevel: 0,
|
|
2459
|
+
x: 0,
|
|
2460
|
+
y: 0,
|
|
2461
|
+
z: 0,
|
|
2462
|
+
aspect: "all"
|
|
2086
2463
|
});
|
|
2087
2464
|
/** Default options */
|
|
2088
2465
|
__publicField(Texture, "defaultCopyExternalImageOptions", {
|
|
@@ -2158,6 +2535,13 @@ var __exports__ = (() => {
|
|
|
2158
2535
|
});
|
|
2159
2536
|
}
|
|
2160
2537
|
}
|
|
2538
|
+
while (log2.length > currentMessage) {
|
|
2539
|
+
const message = log2[currentMessage++];
|
|
2540
|
+
formattedLog += formatCompilerMessage(message, [], 0, {
|
|
2541
|
+
...options,
|
|
2542
|
+
inlineSource: false
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2161
2545
|
return formattedLog;
|
|
2162
2546
|
case "issues":
|
|
2163
2547
|
case "no":
|
|
@@ -2253,19 +2637,19 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
|
|
|
2253
2637
|
if (trigger === "warnings" && messages?.length === 0) {
|
|
2254
2638
|
return;
|
|
2255
2639
|
}
|
|
2256
|
-
this._displayShaderLog(messages);
|
|
2640
|
+
this._displayShaderLog(messages, this.id);
|
|
2257
2641
|
}
|
|
2258
2642
|
// PRIVATE
|
|
2259
2643
|
/**
|
|
2260
2644
|
* In-browser UI logging of errors
|
|
2261
2645
|
* TODO - this HTML formatting code should not be in Device, should be pluggable
|
|
2262
2646
|
*/
|
|
2263
|
-
_displayShaderLog(messages) {
|
|
2647
|
+
_displayShaderLog(messages, shaderId) {
|
|
2264
2648
|
if (typeof document === "undefined" || !document?.createElement) {
|
|
2265
2649
|
return;
|
|
2266
2650
|
}
|
|
2267
|
-
const shaderName =
|
|
2268
|
-
const shaderTitle = `${this.stage} ${shaderName}`;
|
|
2651
|
+
const shaderName = shaderId;
|
|
2652
|
+
const shaderTitle = `${this.stage} shader "${shaderName}"`;
|
|
2269
2653
|
let htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: "all", html: true });
|
|
2270
2654
|
const translatedSource = this.getTranslatedSource();
|
|
2271
2655
|
if (translatedSource) {
|
|
@@ -2273,7 +2657,7 @@ ${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.mes
|
|
|
2273
2657
|
}
|
|
2274
2658
|
const button = document.createElement("Button");
|
|
2275
2659
|
button.innerHTML = `
|
|
2276
|
-
<h1>
|
|
2660
|
+
<h1>Compilation error in ${shaderTitle}</h1><br /><br />
|
|
2277
2661
|
<code style="user-select:text;"><pre>
|
|
2278
2662
|
${htmlLog}
|
|
2279
2663
|
</pre></code>`;
|
|
@@ -2311,38 +2695,6 @@ ${htmlLog}
|
|
|
2311
2695
|
return match ? match[1] : defaultName;
|
|
2312
2696
|
}
|
|
2313
2697
|
|
|
2314
|
-
// src/adapter/resources/sampler.ts
|
|
2315
|
-
var _Sampler = class extends Resource {
|
|
2316
|
-
get [Symbol.toStringTag]() {
|
|
2317
|
-
return "Sampler";
|
|
2318
|
-
}
|
|
2319
|
-
constructor(device, props) {
|
|
2320
|
-
props = _Sampler.normalizeProps(device, props);
|
|
2321
|
-
super(device, props, _Sampler.defaultProps);
|
|
2322
|
-
}
|
|
2323
|
-
static normalizeProps(device, props) {
|
|
2324
|
-
const overriddenDefaultProps = device?.props?._resourceDefaults?.sampler || {};
|
|
2325
|
-
const newProps = { ...props, ...overriddenDefaultProps };
|
|
2326
|
-
return newProps;
|
|
2327
|
-
}
|
|
2328
|
-
};
|
|
2329
|
-
var Sampler = _Sampler;
|
|
2330
|
-
__publicField(Sampler, "defaultProps", {
|
|
2331
|
-
...Resource.defaultProps,
|
|
2332
|
-
type: "color-sampler",
|
|
2333
|
-
addressModeU: "clamp-to-edge",
|
|
2334
|
-
addressModeV: "clamp-to-edge",
|
|
2335
|
-
addressModeW: "clamp-to-edge",
|
|
2336
|
-
magFilter: "nearest",
|
|
2337
|
-
minFilter: "nearest",
|
|
2338
|
-
mipmapFilter: "none",
|
|
2339
|
-
lodMinClamp: 0,
|
|
2340
|
-
lodMaxClamp: 32,
|
|
2341
|
-
// Per WebGPU spec
|
|
2342
|
-
compare: "less-equal",
|
|
2343
|
-
maxAnisotropy: 1
|
|
2344
|
-
});
|
|
2345
|
-
|
|
2346
2698
|
// src/adapter/resources/framebuffer.ts
|
|
2347
2699
|
var _Framebuffer = class extends Resource {
|
|
2348
2700
|
get [Symbol.toStringTag]() {
|
|
@@ -2432,8 +2784,7 @@ ${htmlLog}
|
|
|
2432
2784
|
usage: Texture.RENDER_ATTACHMENT,
|
|
2433
2785
|
format,
|
|
2434
2786
|
width: this.width,
|
|
2435
|
-
height: this.height
|
|
2436
|
-
mipmaps: false
|
|
2787
|
+
height: this.height
|
|
2437
2788
|
});
|
|
2438
2789
|
}
|
|
2439
2790
|
/**
|
|
@@ -2494,16 +2845,6 @@ ${htmlLog}
|
|
|
2494
2845
|
this.shaderLayout = this.props.shaderLayout;
|
|
2495
2846
|
this.bufferLayout = this.props.bufferLayout || [];
|
|
2496
2847
|
}
|
|
2497
|
-
// DEPRECATED METHODS
|
|
2498
|
-
/**
|
|
2499
|
-
* Uniforms
|
|
2500
|
-
* @deprecated Use uniforms buffers
|
|
2501
|
-
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
2502
|
-
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
2503
|
-
*/
|
|
2504
|
-
setUniformsWebGL(uniforms) {
|
|
2505
|
-
throw new Error("Use uniform blocks");
|
|
2506
|
-
}
|
|
2507
2848
|
};
|
|
2508
2849
|
var RenderPipeline = _RenderPipeline;
|
|
2509
2850
|
__publicField(RenderPipeline, "defaultProps", {
|
|
@@ -2517,10 +2858,9 @@ ${htmlLog}
|
|
|
2517
2858
|
shaderLayout: null,
|
|
2518
2859
|
bufferLayout: [],
|
|
2519
2860
|
topology: "triangle-list",
|
|
2861
|
+
colorAttachmentFormats: void 0,
|
|
2862
|
+
depthStencilAttachmentFormat: void 0,
|
|
2520
2863
|
parameters: {},
|
|
2521
|
-
// isInstanced: false,
|
|
2522
|
-
// instanceCount: 0,
|
|
2523
|
-
// vertexCount: 0,
|
|
2524
2864
|
bindings: {},
|
|
2525
2865
|
uniforms: {}
|
|
2526
2866
|
});
|
|
@@ -2535,9 +2875,7 @@ ${htmlLog}
|
|
|
2535
2875
|
super(device, props, _RenderPass.defaultProps);
|
|
2536
2876
|
}
|
|
2537
2877
|
static normalizeProps(device, props) {
|
|
2538
|
-
|
|
2539
|
-
const newProps = { ...overriddenDefaultProps, ...props };
|
|
2540
|
-
return newProps;
|
|
2878
|
+
return props;
|
|
2541
2879
|
}
|
|
2542
2880
|
};
|
|
2543
2881
|
var RenderPass = _RenderPass;
|
|
@@ -2589,12 +2927,12 @@ ${htmlLog}
|
|
|
2589
2927
|
|
|
2590
2928
|
// src/adapter/resources/compute-pass.ts
|
|
2591
2929
|
var _ComputePass = class extends Resource {
|
|
2592
|
-
get [Symbol.toStringTag]() {
|
|
2593
|
-
return "ComputePass";
|
|
2594
|
-
}
|
|
2595
2930
|
constructor(device, props) {
|
|
2596
2931
|
super(device, props, _ComputePass.defaultProps);
|
|
2597
2932
|
}
|
|
2933
|
+
get [Symbol.toStringTag]() {
|
|
2934
|
+
return "ComputePass";
|
|
2935
|
+
}
|
|
2598
2936
|
};
|
|
2599
2937
|
var ComputePass = _ComputePass;
|
|
2600
2938
|
__publicField(ComputePass, "defaultProps", {
|
|
@@ -2612,11 +2950,11 @@ ${htmlLog}
|
|
|
2612
2950
|
constructor(device, props) {
|
|
2613
2951
|
super(device, props, _CommandEncoder.defaultProps);
|
|
2614
2952
|
}
|
|
2615
|
-
// TODO - luma.gl has these on the device, should we align with WebGPU API?
|
|
2616
|
-
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
2617
|
-
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
2618
2953
|
};
|
|
2619
2954
|
var CommandEncoder = _CommandEncoder;
|
|
2955
|
+
// TODO - luma.gl has these on the device, should we align with WebGPU API?
|
|
2956
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
2957
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
2620
2958
|
__publicField(CommandEncoder, "defaultProps", {
|
|
2621
2959
|
...Resource.defaultProps,
|
|
2622
2960
|
measureExecutionTime: void 0
|
|
@@ -2636,42 +2974,31 @@ ${htmlLog}
|
|
|
2636
2974
|
...Resource.defaultProps
|
|
2637
2975
|
});
|
|
2638
2976
|
|
|
2639
|
-
// src/
|
|
2640
|
-
function
|
|
2641
|
-
const
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
const
|
|
2977
|
+
// src/shadertypes/data-types/decode-shader-types.ts
|
|
2978
|
+
function getVariableShaderTypeInfo(format) {
|
|
2979
|
+
const decoded = UNIFORM_FORMATS[format];
|
|
2980
|
+
return decoded;
|
|
2981
|
+
}
|
|
2982
|
+
function getAttributeShaderTypeInfo(attributeType) {
|
|
2983
|
+
const [primitiveType, components] = TYPE_INFO[attributeType];
|
|
2984
|
+
const integer = primitiveType === "i32" || primitiveType === "u32";
|
|
2985
|
+
const signed = primitiveType !== "u32";
|
|
2986
|
+
const byteLength = PRIMITIVE_TYPE_SIZES[primitiveType] * components;
|
|
2646
2987
|
return {
|
|
2647
|
-
|
|
2988
|
+
primitiveType,
|
|
2648
2989
|
components,
|
|
2649
|
-
defaultVertexFormat,
|
|
2650
2990
|
byteLength,
|
|
2651
2991
|
integer,
|
|
2652
2992
|
signed
|
|
2653
2993
|
};
|
|
2654
2994
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
vertexType = "sint32";
|
|
2663
|
-
break;
|
|
2664
|
-
case "u32":
|
|
2665
|
-
vertexType = "uint32";
|
|
2666
|
-
break;
|
|
2667
|
-
case "f16":
|
|
2668
|
-
return components <= 2 ? "float16x2" : "float16x4";
|
|
2669
|
-
}
|
|
2670
|
-
if (components === 1) {
|
|
2671
|
-
return vertexType;
|
|
2672
|
-
}
|
|
2673
|
-
return `${vertexType}x${components}`;
|
|
2674
|
-
}
|
|
2995
|
+
var PRIMITIVE_TYPE_SIZES = {
|
|
2996
|
+
f32: 4,
|
|
2997
|
+
f16: 2,
|
|
2998
|
+
i32: 4,
|
|
2999
|
+
u32: 4
|
|
3000
|
+
// 'bool-webgl': 4,
|
|
3001
|
+
};
|
|
2675
3002
|
var TYPE_INFO = {
|
|
2676
3003
|
f32: ["f32", 1],
|
|
2677
3004
|
"vec2<f32>": ["f32", 2],
|
|
@@ -2690,38 +3017,115 @@ ${htmlLog}
|
|
|
2690
3017
|
"vec3<u32>": ["u32", 3],
|
|
2691
3018
|
"vec4<u32>": ["u32", 4]
|
|
2692
3019
|
};
|
|
2693
|
-
var
|
|
2694
|
-
f32:
|
|
2695
|
-
f16:
|
|
2696
|
-
i32:
|
|
2697
|
-
u32:
|
|
2698
|
-
// 'bool-webgl':
|
|
3020
|
+
var UNIFORM_FORMATS = {
|
|
3021
|
+
f32: { type: "f32", components: 1 },
|
|
3022
|
+
f16: { type: "f16", components: 1 },
|
|
3023
|
+
i32: { type: "i32", components: 1 },
|
|
3024
|
+
u32: { type: "u32", components: 1 },
|
|
3025
|
+
// 'bool-webgl': {type: 'bool-webgl', components: 1},
|
|
3026
|
+
"vec2<f32>": { type: "f32", components: 2 },
|
|
3027
|
+
"vec3<f32>": { type: "f32", components: 3 },
|
|
3028
|
+
"vec4<f32>": { type: "f32", components: 4 },
|
|
3029
|
+
"vec2<f16>": { type: "f16", components: 2 },
|
|
3030
|
+
"vec3<f16>": { type: "f16", components: 3 },
|
|
3031
|
+
"vec4<f16>": { type: "f16", components: 4 },
|
|
3032
|
+
"vec2<i32>": { type: "i32", components: 2 },
|
|
3033
|
+
"vec3<i32>": { type: "i32", components: 3 },
|
|
3034
|
+
"vec4<i32>": { type: "i32", components: 4 },
|
|
3035
|
+
"vec2<u32>": { type: "u32", components: 2 },
|
|
3036
|
+
"vec3<u32>": { type: "u32", components: 3 },
|
|
3037
|
+
"vec4<u32>": { type: "u32", components: 4 },
|
|
3038
|
+
"mat2x2<f32>": { type: "f32", components: 4 },
|
|
3039
|
+
"mat2x3<f32>": { type: "f32", components: 6 },
|
|
3040
|
+
"mat2x4<f32>": { type: "f32", components: 8 },
|
|
3041
|
+
"mat3x2<f32>": { type: "f32", components: 6 },
|
|
3042
|
+
"mat3x3<f32>": { type: "f32", components: 9 },
|
|
3043
|
+
"mat3x4<f32>": { type: "f32", components: 12 },
|
|
3044
|
+
"mat4x2<f32>": { type: "f32", components: 8 },
|
|
3045
|
+
"mat4x3<f32>": { type: "f32", components: 12 },
|
|
3046
|
+
"mat4x4<f32>": { type: "f32", components: 16 },
|
|
3047
|
+
"mat2x2<f16>": { type: "f16", components: 4 },
|
|
3048
|
+
"mat2x3<f16>": { type: "f16", components: 6 },
|
|
3049
|
+
"mat2x4<f16>": { type: "f16", components: 8 },
|
|
3050
|
+
"mat3x2<f16>": { type: "f16", components: 6 },
|
|
3051
|
+
"mat3x3<f16>": { type: "f16", components: 9 },
|
|
3052
|
+
"mat3x4<f16>": { type: "f16", components: 12 },
|
|
3053
|
+
"mat4x2<f16>": { type: "f16", components: 8 },
|
|
3054
|
+
"mat4x3<f16>": { type: "f16", components: 12 },
|
|
3055
|
+
"mat4x4<f16>": { type: "f16", components: 16 },
|
|
3056
|
+
"mat2x2<i32>": { type: "i32", components: 4 },
|
|
3057
|
+
"mat2x3<i32>": { type: "i32", components: 6 },
|
|
3058
|
+
"mat2x4<i32>": { type: "i32", components: 8 },
|
|
3059
|
+
"mat3x2<i32>": { type: "i32", components: 6 },
|
|
3060
|
+
"mat3x3<i32>": { type: "i32", components: 9 },
|
|
3061
|
+
"mat3x4<i32>": { type: "i32", components: 12 },
|
|
3062
|
+
"mat4x2<i32>": { type: "i32", components: 8 },
|
|
3063
|
+
"mat4x3<i32>": { type: "i32", components: 12 },
|
|
3064
|
+
"mat4x4<i32>": { type: "i32", components: 16 },
|
|
3065
|
+
"mat2x2<u32>": { type: "u32", components: 4 },
|
|
3066
|
+
"mat2x3<u32>": { type: "u32", components: 6 },
|
|
3067
|
+
"mat2x4<u32>": { type: "u32", components: 8 },
|
|
3068
|
+
"mat3x2<u32>": { type: "u32", components: 6 },
|
|
3069
|
+
"mat3x3<u32>": { type: "u32", components: 9 },
|
|
3070
|
+
"mat3x4<u32>": { type: "u32", components: 12 },
|
|
3071
|
+
"mat4x2<u32>": { type: "u32", components: 8 },
|
|
3072
|
+
"mat4x3<u32>": { type: "u32", components: 12 },
|
|
3073
|
+
"mat4x4<u32>": { type: "u32", components: 16 }
|
|
3074
|
+
};
|
|
3075
|
+
var WGSL_ATTRIBUTE_TYPE_ALIAS_MAP = {
|
|
3076
|
+
vec2i: "vec2<i32>",
|
|
3077
|
+
vec3i: "vec3<i32>",
|
|
3078
|
+
vec4i: "vec4<i32>",
|
|
3079
|
+
vec2u: "vec2<u32>",
|
|
3080
|
+
vec3u: "vec3<u32>",
|
|
3081
|
+
vec4u: "vec4<u32>",
|
|
3082
|
+
vec2f: "vec2<f32>",
|
|
3083
|
+
vec3f: "vec3<f32>",
|
|
3084
|
+
vec4f: "vec4<f32>",
|
|
3085
|
+
// Requires the f16 extension.
|
|
3086
|
+
vec2h: "vec2<f16>",
|
|
3087
|
+
vec3h: "vec3<f16>",
|
|
3088
|
+
vec4h: "vec4<f16>"
|
|
3089
|
+
};
|
|
3090
|
+
var WGSL_VARIABLE_TYPE_ALIAS_MAP = {
|
|
3091
|
+
...WGSL_ATTRIBUTE_TYPE_ALIAS_MAP,
|
|
3092
|
+
mat2x2f: "mat2x2<f32>",
|
|
3093
|
+
mat2x3f: "mat2x3<f32>",
|
|
3094
|
+
mat2x4f: "mat2x4<f32>",
|
|
3095
|
+
mat3x2f: "mat3x2<f32>",
|
|
3096
|
+
mat3x3f: "mat3x3<f32>",
|
|
3097
|
+
mat3x4f: "mat3x4<f32>",
|
|
3098
|
+
mat4x2f: "mat4x2<f32>",
|
|
3099
|
+
mat4x3f: "mat4x3<f32>",
|
|
3100
|
+
mat4x4f: "mat4x4<f32>",
|
|
3101
|
+
mat2x2i: "mat2x2<i32>",
|
|
3102
|
+
mat2x3i: "mat2x3<i32>",
|
|
3103
|
+
mat2x4i: "mat2x4<i32>",
|
|
3104
|
+
mat3x2i: "mat3x2<i32>",
|
|
3105
|
+
mat3x3i: "mat3x3<i32>",
|
|
3106
|
+
mat3x4i: "mat3x4<i32>",
|
|
3107
|
+
mat4x2i: "mat4x2<i32>",
|
|
3108
|
+
mat4x3i: "mat4x3<i32>",
|
|
3109
|
+
mat4x4i: "mat4x4<i32>",
|
|
3110
|
+
mat2x2u: "mat2x2<u32>",
|
|
3111
|
+
mat2x3u: "mat2x3<u32>",
|
|
3112
|
+
mat2x4u: "mat2x4<u32>",
|
|
3113
|
+
mat3x2u: "mat3x2<u32>",
|
|
3114
|
+
mat3x3u: "mat3x3<u32>",
|
|
3115
|
+
mat3x4u: "mat3x4<u32>",
|
|
3116
|
+
mat4x2u: "mat4x2<u32>",
|
|
3117
|
+
mat4x3u: "mat4x3<u32>",
|
|
3118
|
+
mat4x4u: "mat4x4<u32>",
|
|
3119
|
+
mat2x2h: "mat2x2<f16>",
|
|
3120
|
+
mat2x3h: "mat2x3<f16>",
|
|
3121
|
+
mat2x4h: "mat2x4<f16>",
|
|
3122
|
+
mat3x2h: "mat3x2<f16>",
|
|
3123
|
+
mat3x3h: "mat3x3<f16>",
|
|
3124
|
+
mat3x4h: "mat3x4<f16>",
|
|
3125
|
+
mat4x2h: "mat4x2<f16>",
|
|
3126
|
+
mat4x3h: "mat4x3<f16>",
|
|
3127
|
+
mat4x4h: "mat4x4<f16>"
|
|
2699
3128
|
};
|
|
2700
|
-
|
|
2701
|
-
// src/gpu-type-utils/decode-vertex-format.ts
|
|
2702
|
-
function decodeVertexFormat(format) {
|
|
2703
|
-
let webglOnly;
|
|
2704
|
-
if (format.endsWith("-webgl")) {
|
|
2705
|
-
format.replace("-webgl", "");
|
|
2706
|
-
webglOnly = true;
|
|
2707
|
-
}
|
|
2708
|
-
const [type_, count] = format.split("x");
|
|
2709
|
-
const type = type_;
|
|
2710
|
-
const components = count ? parseInt(count) : 1;
|
|
2711
|
-
const decodedType = decodeVertexType(type);
|
|
2712
|
-
const result = {
|
|
2713
|
-
type,
|
|
2714
|
-
components,
|
|
2715
|
-
byteLength: decodedType.byteLength * components,
|
|
2716
|
-
integer: decodedType.integer,
|
|
2717
|
-
signed: decodedType.signed,
|
|
2718
|
-
normalized: decodedType.normalized
|
|
2719
|
-
};
|
|
2720
|
-
if (webglOnly) {
|
|
2721
|
-
result.webglOnly = true;
|
|
2722
|
-
}
|
|
2723
|
-
return result;
|
|
2724
|
-
}
|
|
2725
3129
|
|
|
2726
3130
|
// src/adapter-utils/get-attribute-from-layouts.ts
|
|
2727
3131
|
function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
|
|
@@ -2751,15 +3155,16 @@ ${htmlLog}
|
|
|
2751
3155
|
if (!shaderDeclaration) {
|
|
2752
3156
|
return null;
|
|
2753
3157
|
}
|
|
2754
|
-
const attributeTypeInfo =
|
|
2755
|
-
const
|
|
2756
|
-
const
|
|
3158
|
+
const attributeTypeInfo = getAttributeShaderTypeInfo(shaderDeclaration.type);
|
|
3159
|
+
const defaultVertexFormat = getCompatibleVertexFormat(attributeTypeInfo);
|
|
3160
|
+
const vertexFormat = bufferMapping?.vertexFormat || defaultVertexFormat;
|
|
3161
|
+
const vertexFormatInfo = getVertexFormatInfo(vertexFormat);
|
|
2757
3162
|
return {
|
|
2758
3163
|
attributeName: bufferMapping?.attributeName || shaderDeclaration.name,
|
|
2759
3164
|
bufferName: bufferMapping?.bufferName || shaderDeclaration.name,
|
|
2760
3165
|
location: shaderDeclaration.location,
|
|
2761
3166
|
shaderType: shaderDeclaration.type,
|
|
2762
|
-
|
|
3167
|
+
primitiveType: attributeTypeInfo.primitiveType,
|
|
2763
3168
|
shaderComponents: attributeTypeInfo.components,
|
|
2764
3169
|
vertexFormat,
|
|
2765
3170
|
bufferDataType: vertexFormatInfo.type,
|
|
@@ -2821,7 +3226,7 @@ ${htmlLog}
|
|
|
2821
3226
|
let byteStride = bufferLayout.byteStride;
|
|
2822
3227
|
if (typeof bufferLayout.byteStride !== "number") {
|
|
2823
3228
|
for (const attributeMapping2 of bufferLayout.attributes || []) {
|
|
2824
|
-
const info =
|
|
3229
|
+
const info = getVertexFormatInfo(attributeMapping2.format);
|
|
2825
3230
|
byteStride += info.byteLength;
|
|
2826
3231
|
}
|
|
2827
3232
|
}
|
|
@@ -2858,26 +3263,23 @@ ${htmlLog}
|
|
|
2858
3263
|
super(device, props, _VertexArray.defaultProps);
|
|
2859
3264
|
this.maxVertexAttributes = device.limits.maxVertexAttributes;
|
|
2860
3265
|
this.attributes = new Array(this.maxVertexAttributes).fill(null);
|
|
2861
|
-
const { shaderLayout, bufferLayout } = props.renderPipeline || {};
|
|
2862
|
-
if (!shaderLayout || !bufferLayout) {
|
|
2863
|
-
throw new Error("VertexArray");
|
|
2864
|
-
}
|
|
2865
3266
|
this.attributeInfos = getAttributeInfosByLocation(
|
|
2866
|
-
shaderLayout,
|
|
2867
|
-
bufferLayout,
|
|
3267
|
+
props.shaderLayout,
|
|
3268
|
+
props.bufferLayout,
|
|
2868
3269
|
this.maxVertexAttributes
|
|
2869
3270
|
);
|
|
2870
3271
|
}
|
|
2871
3272
|
// DEPRECATED METHODS
|
|
2872
3273
|
/** @deprecated Set constant attributes (WebGL only) */
|
|
2873
3274
|
setConstantWebGL(location, value) {
|
|
2874
|
-
this.device.reportError(new Error("constant attributes not supported"));
|
|
3275
|
+
this.device.reportError(new Error("constant attributes not supported"), this)();
|
|
2875
3276
|
}
|
|
2876
3277
|
};
|
|
2877
3278
|
var VertexArray = _VertexArray;
|
|
2878
3279
|
__publicField(VertexArray, "defaultProps", {
|
|
2879
3280
|
...Resource.defaultProps,
|
|
2880
|
-
|
|
3281
|
+
shaderLayout: void 0,
|
|
3282
|
+
bufferLayout: []
|
|
2881
3283
|
});
|
|
2882
3284
|
|
|
2883
3285
|
// src/adapter/resources/transform-feedback.ts
|
|
@@ -2930,46 +3332,6 @@ ${htmlLog}
|
|
|
2930
3332
|
}
|
|
2931
3333
|
});
|
|
2932
3334
|
|
|
2933
|
-
// src/gpu-type-utils/decode-shader-types.ts
|
|
2934
|
-
var UNIFORM_FORMATS = {
|
|
2935
|
-
f32: { type: "f32", components: 1 },
|
|
2936
|
-
i32: { type: "i32", components: 1 },
|
|
2937
|
-
u32: { type: "u32", components: 1 },
|
|
2938
|
-
// 'bool-webgl': {type: 'bool-webgl', components: 1},
|
|
2939
|
-
"vec2<f32>": { type: "f32", components: 2 },
|
|
2940
|
-
"vec3<f32>": { type: "f32", components: 3 },
|
|
2941
|
-
"vec4<f32>": { type: "f32", components: 4 },
|
|
2942
|
-
"vec2<i32>": { type: "i32", components: 2 },
|
|
2943
|
-
"vec3<i32>": { type: "i32", components: 3 },
|
|
2944
|
-
"vec4<i32>": { type: "i32", components: 4 },
|
|
2945
|
-
"vec2<u32>": { type: "u32", components: 2 },
|
|
2946
|
-
"vec3<u32>": { type: "u32", components: 3 },
|
|
2947
|
-
"vec4<u32>": { type: "u32", components: 4 },
|
|
2948
|
-
"mat2x2<f32>": { type: "f32", components: 4 },
|
|
2949
|
-
"mat2x3<f32>": { type: "f32", components: 6 },
|
|
2950
|
-
"mat2x4<f32>": { type: "f32", components: 8 },
|
|
2951
|
-
"mat3x2<f32>": { type: "f32", components: 6 },
|
|
2952
|
-
"mat3x3<f32>": { type: "f32", components: 9 },
|
|
2953
|
-
"mat3x4<f32>": { type: "f32", components: 12 },
|
|
2954
|
-
"mat4x2<f32>": { type: "f32", components: 8 },
|
|
2955
|
-
"mat4x3<f32>": { type: "f32", components: 12 },
|
|
2956
|
-
"mat4x4<f32>": { type: "f32", components: 16 }
|
|
2957
|
-
};
|
|
2958
|
-
function decodeShaderUniformType(format) {
|
|
2959
|
-
const decoded = UNIFORM_FORMATS[format];
|
|
2960
|
-
return decoded;
|
|
2961
|
-
}
|
|
2962
|
-
function alignTo(size, count) {
|
|
2963
|
-
switch (count) {
|
|
2964
|
-
case 1:
|
|
2965
|
-
return size;
|
|
2966
|
-
case 2:
|
|
2967
|
-
return size + size % 2;
|
|
2968
|
-
default:
|
|
2969
|
-
return size + (4 - size % 4) % 4;
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
3335
|
// src/utils/array-utils-flat.ts
|
|
2974
3336
|
var arrayBuffer;
|
|
2975
3337
|
function getScratchArrayBuffer(byteLength) {
|
|
@@ -3004,7 +3366,7 @@ ${htmlLog}
|
|
|
3004
3366
|
constructor(uniformTypes) {
|
|
3005
3367
|
let size = 0;
|
|
3006
3368
|
for (const [key, uniformType] of Object.entries(uniformTypes)) {
|
|
3007
|
-
const typeAndComponents =
|
|
3369
|
+
const typeAndComponents = getVariableShaderTypeInfo(uniformType);
|
|
3008
3370
|
const { type, components: count } = typeAndComponents;
|
|
3009
3371
|
size = alignTo(size, count);
|
|
3010
3372
|
const offset = size;
|
|
@@ -3253,137 +3615,86 @@ ${htmlLog}
|
|
|
3253
3615
|
}
|
|
3254
3616
|
};
|
|
3255
3617
|
|
|
3256
|
-
// src/
|
|
3257
|
-
function
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
return
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
}
|
|
3307
|
-
const components = size;
|
|
3308
|
-
let dataType = getDataTypeFromTypedArray(typedArray);
|
|
3309
|
-
if (dataType === "uint8" && normalized && components === 1) {
|
|
3310
|
-
return "unorm8-webgl";
|
|
3311
|
-
}
|
|
3312
|
-
if (dataType === "uint8" && normalized && components === 3) {
|
|
3313
|
-
return "unorm8x3-webgl";
|
|
3314
|
-
}
|
|
3315
|
-
if (dataType === "uint8" || dataType === "sint8") {
|
|
3316
|
-
if (components === 1 || components === 3) {
|
|
3317
|
-
throw new Error(`size: ${size}`);
|
|
3318
|
-
}
|
|
3319
|
-
if (normalized) {
|
|
3320
|
-
dataType = dataType.replace("int", "norm");
|
|
3321
|
-
}
|
|
3322
|
-
return `${dataType}x${components}`;
|
|
3323
|
-
}
|
|
3324
|
-
if (dataType === "uint16" || dataType === "sint16") {
|
|
3325
|
-
if (components === 1 || components === 3) {
|
|
3326
|
-
throw new Error(`size: ${size}`);
|
|
3327
|
-
}
|
|
3328
|
-
if (normalized) {
|
|
3329
|
-
dataType = dataType.replace("int", "norm");
|
|
3330
|
-
}
|
|
3331
|
-
return `${dataType}x${components}`;
|
|
3332
|
-
}
|
|
3333
|
-
if (components === 1) {
|
|
3334
|
-
return dataType;
|
|
3618
|
+
// src/shadertypes/textures/pixel-utils.ts
|
|
3619
|
+
function readPixel(pixelData, x, y, bitsPerChannel) {
|
|
3620
|
+
if (x < 0 || x >= pixelData.width || y < 0 || y >= pixelData.height) {
|
|
3621
|
+
throw new Error("Coordinates out of bounds.");
|
|
3622
|
+
}
|
|
3623
|
+
const byteOffset = y * pixelData.bytesPerRow + x * pixelData.bytesPerPixel;
|
|
3624
|
+
const pixelDataView = new DataView(pixelData.arrayBuffer, byteOffset, pixelData.bytesPerPixel);
|
|
3625
|
+
let bitOffsetWithinPixel = 0;
|
|
3626
|
+
const channels = [];
|
|
3627
|
+
for (let i = 0; i < 4; i++) {
|
|
3628
|
+
const bits = bitsPerChannel[i];
|
|
3629
|
+
if (bits <= 0) {
|
|
3630
|
+
channels.push(0);
|
|
3631
|
+
} else {
|
|
3632
|
+
const channelValue = readBitsFromDataView(pixelDataView, bitOffsetWithinPixel, bits);
|
|
3633
|
+
channels.push(channelValue);
|
|
3634
|
+
bitOffsetWithinPixel += bits;
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
return [channels[0], channels[1], channels[2], channels[3]];
|
|
3638
|
+
}
|
|
3639
|
+
function writePixel(dataView, bitOffset, bitsPerChannel, pixel) {
|
|
3640
|
+
let currentBitOffset = bitOffset;
|
|
3641
|
+
for (let channel = 0; channel < 4; channel++) {
|
|
3642
|
+
const bits = bitsPerChannel[channel];
|
|
3643
|
+
const maxValue = (1 << bits) - 1;
|
|
3644
|
+
const channelValue = pixel[channel] & maxValue;
|
|
3645
|
+
writeBitsToDataView(dataView, currentBitOffset, bits, channelValue);
|
|
3646
|
+
currentBitOffset += bits;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
function readBitsFromDataView(dataView, bitOffset, bitCount) {
|
|
3650
|
+
if (bitOffset % 8 === 0) {
|
|
3651
|
+
const byteOffset = bitOffset / 8;
|
|
3652
|
+
if (bitCount === 8 && byteOffset + 1 <= dataView.byteLength) {
|
|
3653
|
+
return dataView.getUint8(byteOffset);
|
|
3654
|
+
} else if (bitCount === 16 && byteOffset + 2 <= dataView.byteLength) {
|
|
3655
|
+
return dataView.getUint16(byteOffset, false);
|
|
3656
|
+
} else if (bitCount === 32 && byteOffset + 4 <= dataView.byteLength) {
|
|
3657
|
+
return dataView.getUint32(byteOffset, false);
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
let value = 0;
|
|
3661
|
+
for (let i = 0; i < bitCount; i++) {
|
|
3662
|
+
const overallBitIndex = bitOffset + i;
|
|
3663
|
+
const byteIndex = Math.floor(overallBitIndex / 8);
|
|
3664
|
+
const bitIndex = overallBitIndex % 8;
|
|
3665
|
+
const byteValue = dataView.getUint8(byteIndex);
|
|
3666
|
+
const bit = byteValue >> 7 - bitIndex & 1;
|
|
3667
|
+
value = value << 1 | bit;
|
|
3335
3668
|
}
|
|
3336
|
-
return
|
|
3669
|
+
return value;
|
|
3337
3670
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
return bufferLayout.attributes ? bufferLayout.attributes?.map((layout) => layout.attribute) : [bufferLayout.name];
|
|
3351
|
-
}
|
|
3352
|
-
mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
|
|
3353
|
-
const mergedLayouts = [...bufferLayouts1];
|
|
3354
|
-
for (const attribute of bufferLayouts2) {
|
|
3355
|
-
const index = mergedLayouts.findIndex((attribute2) => attribute2.name === attribute.name);
|
|
3356
|
-
if (index < 0) {
|
|
3357
|
-
mergedLayouts.push(attribute);
|
|
3358
|
-
} else {
|
|
3359
|
-
mergedLayouts[index] = attribute;
|
|
3360
|
-
}
|
|
3671
|
+
function writeBitsToDataView(dataView, bitOffset, bitCount, value) {
|
|
3672
|
+
if (bitOffset % 8 === 0) {
|
|
3673
|
+
const byteOffset = bitOffset / 8;
|
|
3674
|
+
if (bitCount === 8 && byteOffset + 1 <= dataView.byteLength) {
|
|
3675
|
+
dataView.setUint8(byteOffset, value & 255);
|
|
3676
|
+
return;
|
|
3677
|
+
} else if (bitCount === 16 && byteOffset + 2 <= dataView.byteLength) {
|
|
3678
|
+
dataView.setUint16(byteOffset, value & 65535, false);
|
|
3679
|
+
return;
|
|
3680
|
+
} else if (bitCount === 32 && byteOffset + 4 <= dataView.byteLength) {
|
|
3681
|
+
dataView.setUint32(byteOffset, value, false);
|
|
3682
|
+
return;
|
|
3361
3683
|
}
|
|
3362
|
-
return mergedLayouts;
|
|
3363
3684
|
}
|
|
3364
|
-
|
|
3365
|
-
const
|
|
3366
|
-
|
|
3367
|
-
|
|
3685
|
+
for (let i = 0; i < bitCount; i++) {
|
|
3686
|
+
const overallBitIndex = bitOffset + i;
|
|
3687
|
+
const byteIndex = Math.floor(overallBitIndex / 8);
|
|
3688
|
+
const bitIndex = overallBitIndex % 8;
|
|
3689
|
+
const mask = 1 << 7 - bitIndex;
|
|
3690
|
+
const bitValue = value >> bitCount - 1 - i & 1;
|
|
3691
|
+
let currentByte = dataView.getUint8(byteIndex);
|
|
3692
|
+
currentByte &= ~mask;
|
|
3693
|
+
if (bitValue) {
|
|
3694
|
+
currentByte |= mask;
|
|
3368
3695
|
}
|
|
3369
|
-
|
|
3696
|
+
dataView.setUint8(byteIndex, currentByte);
|
|
3370
3697
|
}
|
|
3371
|
-
};
|
|
3372
|
-
|
|
3373
|
-
// src/adapter-utils/buffer-layout-order.ts
|
|
3374
|
-
function sortedBufferLayoutByShaderSourceLocations(shaderLayout, bufferLayout) {
|
|
3375
|
-
const shaderLayoutMap = Object.fromEntries(
|
|
3376
|
-
shaderLayout.attributes.map((attr) => [attr.name, attr.location])
|
|
3377
|
-
);
|
|
3378
|
-
const sortedLayout = bufferLayout.slice();
|
|
3379
|
-
sortedLayout.sort((a, b) => {
|
|
3380
|
-
const attributeNamesA = a.attributes ? a.attributes.map((attr) => attr.attribute) : [a.name];
|
|
3381
|
-
const attributeNamesB = b.attributes ? b.attributes.map((attr) => attr.attribute) : [b.name];
|
|
3382
|
-
const minLocationA = Math.min(...attributeNamesA.map((name2) => shaderLayoutMap[name2]));
|
|
3383
|
-
const minLocationB = Math.min(...attributeNamesB.map((name2) => shaderLayoutMap[name2]));
|
|
3384
|
-
return minLocationA - minLocationB;
|
|
3385
|
-
});
|
|
3386
|
-
return sortedLayout;
|
|
3387
3698
|
}
|
|
3388
3699
|
return __toCommonJS(bundle_exports);
|
|
3389
3700
|
})();
|