@luma.gl/core 9.0.0-beta.9 → 9.0.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/resources/render-pipeline.d.ts +3 -1
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/dist.dev.js +74 -90
- package/dist/dist.min.js +4 -4
- package/dist/index.cjs +57 -18
- package/dist/index.cjs.map +2 -2
- package/dist/init.js +1 -1
- package/dist/lib/luma.d.ts +13 -2
- package/dist/lib/luma.d.ts.map +1 -1
- package/dist/lib/luma.js +66 -17
- package/package.json +2 -2
- package/src/adapter/resources/render-pipeline.ts +4 -1
- package/src/lib/luma.ts +92 -19
package/dist/index.cjs
CHANGED
|
@@ -116,7 +116,7 @@ var lumaStats = new StatsManager();
|
|
|
116
116
|
|
|
117
117
|
// dist/init.js
|
|
118
118
|
function initializeLuma() {
|
|
119
|
-
const VERSION2 = true ? "9.0.
|
|
119
|
+
const VERSION2 = true ? "9.0.2" : "running from source";
|
|
120
120
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
121
121
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION2) {
|
|
122
122
|
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION2}`);
|
|
@@ -647,61 +647,100 @@ function assert(condition, message) {
|
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
// dist/lib/luma.js
|
|
650
|
-
var
|
|
650
|
+
var deviceMap = /* @__PURE__ */ new Map();
|
|
651
651
|
var luma = class {
|
|
652
652
|
static registerDevices(deviceClasses) {
|
|
653
653
|
for (const deviceClass of deviceClasses) {
|
|
654
654
|
assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
|
|
655
|
-
|
|
655
|
+
deviceMap.set(deviceClass.type, deviceClass);
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
static getAvailableDevices() {
|
|
659
|
-
return Array.from(
|
|
659
|
+
return Array.from(deviceMap).map((Device2) => Device2.type);
|
|
660
660
|
}
|
|
661
661
|
static getSupportedDevices() {
|
|
662
|
-
return Array.from(
|
|
662
|
+
return Array.from(deviceMap).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
|
|
663
663
|
}
|
|
664
664
|
static setDefaultDeviceProps(props) {
|
|
665
665
|
Object.assign(Device.defaultProps, props);
|
|
666
666
|
}
|
|
667
|
+
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
|
|
668
|
+
static async attachDevice(props) {
|
|
669
|
+
const devices = getDeviceMap(props.devices) || deviceMap;
|
|
670
|
+
if (props.handle instanceof WebGL2RenderingContext) {
|
|
671
|
+
const WebGLDevice = devices.get("webgl");
|
|
672
|
+
if (WebGLDevice) {
|
|
673
|
+
return await WebGLDevice.attach(props.handle);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
if (props.handle === null) {
|
|
677
|
+
const UnknownDevice = devices.get("unknown");
|
|
678
|
+
if (UnknownDevice) {
|
|
679
|
+
return await UnknownDevice.attach(null);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
|
|
683
|
+
}
|
|
667
684
|
/** Creates a device. Asynchronously. */
|
|
668
685
|
static async createDevice(props = {}) {
|
|
686
|
+
var _a, _b;
|
|
669
687
|
props = { ...Device.defaultProps, ...props };
|
|
670
688
|
if (props.gl) {
|
|
671
689
|
props.type = "webgl";
|
|
672
690
|
}
|
|
673
|
-
|
|
691
|
+
const devices = getDeviceMap(props.devices) || deviceMap;
|
|
674
692
|
switch (props.type) {
|
|
675
693
|
case "webgpu":
|
|
676
|
-
|
|
677
|
-
if (
|
|
678
|
-
return await
|
|
694
|
+
let WebGPUDevice = devices.get("webgpu");
|
|
695
|
+
if (WebGPUDevice) {
|
|
696
|
+
return await WebGPUDevice.create(props);
|
|
679
697
|
}
|
|
680
698
|
break;
|
|
681
699
|
case "webgl":
|
|
682
|
-
|
|
683
|
-
if (
|
|
684
|
-
return await
|
|
700
|
+
let WebGLDevice = devices.get("webgl");
|
|
701
|
+
if (WebGLDevice) {
|
|
702
|
+
return await WebGLDevice.create(props);
|
|
703
|
+
}
|
|
704
|
+
break;
|
|
705
|
+
case "unknown":
|
|
706
|
+
const UnknownDevice = devices.get("unknown");
|
|
707
|
+
if (UnknownDevice) {
|
|
708
|
+
return await UnknownDevice.create(props);
|
|
685
709
|
}
|
|
686
710
|
break;
|
|
687
711
|
case "best-available":
|
|
688
|
-
|
|
689
|
-
if (
|
|
690
|
-
return await
|
|
712
|
+
WebGPUDevice = devices.get("webgpu");
|
|
713
|
+
if ((_a = WebGPUDevice == null ? void 0 : WebGPUDevice.isSupported) == null ? void 0 : _a.call(WebGPUDevice)) {
|
|
714
|
+
return await WebGPUDevice.create(props);
|
|
691
715
|
}
|
|
692
|
-
|
|
693
|
-
if (
|
|
694
|
-
return await
|
|
716
|
+
WebGLDevice = devices.get("webgl");
|
|
717
|
+
if ((_b = WebGLDevice == null ? void 0 : WebGLDevice.isSupported) == null ? void 0 : _b.call(WebGLDevice)) {
|
|
718
|
+
return await WebGLDevice.create(props);
|
|
695
719
|
}
|
|
696
720
|
break;
|
|
697
721
|
}
|
|
698
722
|
throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.");
|
|
699
723
|
}
|
|
700
724
|
};
|
|
725
|
+
__publicField(luma, "defaultProps", {
|
|
726
|
+
...Device.defaultProps,
|
|
727
|
+
type: "best-available",
|
|
728
|
+
devices: void 0
|
|
729
|
+
});
|
|
701
730
|
/** Global stats for all devices */
|
|
702
731
|
__publicField(luma, "stats", lumaStats);
|
|
703
732
|
/** Global log */
|
|
704
733
|
__publicField(luma, "log", log);
|
|
734
|
+
function getDeviceMap(deviceClasses) {
|
|
735
|
+
if (!deviceClasses || (deviceClasses == null ? void 0 : deviceClasses.length) === 0) {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
const map = /* @__PURE__ */ new Map();
|
|
739
|
+
for (const deviceClass of deviceClasses) {
|
|
740
|
+
map.set(deviceClass.type, deviceClass);
|
|
741
|
+
}
|
|
742
|
+
return map;
|
|
743
|
+
}
|
|
705
744
|
|
|
706
745
|
// dist/adapter/canvas-context.js
|
|
707
746
|
var import_env2 = require("@probe.gl/env");
|