@luma.gl/core
Advanced tools
Comparing version 9.1.0-alpha.2 to 9.1.0-alpha.9
@@ -114,3 +114,3 @@ import { StatsManager } from "../utils/stats-manager.js"; | ||
export type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures; | ||
export type WebGPUDeviceFeature = 'depth-clip-control' | 'indirect-first-instance' | 'timestamp-query' | 'shader-f16' | 'depth24unorm-stencil8' | 'depth32float-stencil8' | 'rg11b10ufloat-renderable' | 'float32-filterable' | 'bgra8unorm-storage' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc'; | ||
export type WebGPUDeviceFeature = 'depth-clip-control' | 'indirect-first-instance' | 'timestamp-query' | 'shader-f16' | 'depth32float-stencil8' | 'rg11b10ufloat-renderable' | 'float32-filterable' | 'bgra8unorm-storage' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc'; | ||
export type WebGLDeviceFeature = 'timer-query-webgl' | 'compilation-status-async-webgl' | 'provoking-vertex-webgl' | 'polygon-mode-webgl' | 'shader-noperspective-interpolation-webgl' | 'shader-conservative-depth-webgl' | 'shader-clip-cull-distance-webgl' | 'float32-renderable-webgl' | 'float16-renderable-webgl' | 'rgb9e5ufloat_renderable-webgl' | 'snorm8-renderable-webgl' | 'norm16-renderable-webgl' | 'snorm16-renderable-webgl' | 'float16-filterable-webgl' | 'texture-filterable-anisotropic-webgl' | 'bgra8unorm-storage' | 'texture-blend-float-webgl'; | ||
@@ -135,3 +135,5 @@ type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-bc7-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl'; | ||
/** WebGL: Initialize the SpectorJS WebGL debugger */ | ||
spector?: boolean; | ||
debugWithSpectorJS?: boolean; | ||
/** SpectorJS URL. Override if CDN is down or different SpectorJS version is desired */ | ||
spectorUrl?: string; | ||
/** Set to false to disable WebGL state management instrumentation: TODO- Unclear if still supported / useful */ | ||
@@ -147,2 +149,11 @@ manageState?: boolean; | ||
/** | ||
* Create and attach devices for a specific backend. Currently static methods on each device | ||
*/ | ||
export interface DeviceFactory { | ||
type: string; | ||
isSupported(): boolean; | ||
create(props: DeviceProps): Promise<Device>; | ||
attach?(handle: unknown): Device; | ||
} | ||
/** | ||
* WebGPU Device/WebGL context abstraction | ||
@@ -153,3 +164,2 @@ */ | ||
get [Symbol.toStringTag](): string; | ||
static VERSION: string; | ||
constructor(props: DeviceProps); | ||
@@ -156,0 +166,0 @@ /** id of this device, primarily for debugging */ |
// luma.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
import { VERSION } from "../init.js"; | ||
import { lumaStats } from "../utils/stats-manager.js"; | ||
@@ -51,4 +50,6 @@ import { log } from "../utils/log.js"; | ||
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance) | ||
spector: Boolean(log.get('spector')), // Initialize the SpectorJS WebGL debugger | ||
break: log.get('break') || [], | ||
// WebGL specific debugging | ||
debugWithSpectorJS: undefined, | ||
spectorUrl: undefined, | ||
// TODO - Change these after confirming things work as expected | ||
@@ -64,3 +65,2 @@ initalizeFeatures: true, | ||
} | ||
static VERSION = VERSION; | ||
constructor(props) { | ||
@@ -67,0 +67,0 @@ this.props = { ...Device.defaultProps, ...props }; |
import type { Log } from '@probe.gl/log'; | ||
import type { DeviceProps } from "./device.js"; | ||
import { Device } from "./device.js"; | ||
import { Adapter } from "./adapter.js"; | ||
import { StatsManager } from "../utils/stats-manager.js"; | ||
declare global { | ||
var luma: Luma; | ||
} | ||
/** Properties for creating a new device */ | ||
@@ -9,3 +13,3 @@ export type CreateDeviceProps = DeviceProps & { | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
devices?: any[]; | ||
adapters?: Adapter[]; | ||
}; | ||
@@ -15,26 +19,54 @@ /** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */ | ||
/** Externally created WebGL context or WebGPU device */ | ||
handle: WebGL2RenderingContext; | ||
devices?: any[]; | ||
handle: unknown; | ||
/** List of adapters. Will also search any pre-registered adapterss */ | ||
adapters?: Adapter[]; | ||
}; | ||
/** | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL devices (controls application bundle size) | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export declare class luma { | ||
export declare class Luma { | ||
static defaultProps: Required<CreateDeviceProps>; | ||
/** Global stats for all devices */ | ||
static stats: StatsManager; | ||
/** Global log */ | ||
static log: Log; | ||
static registerDevices(deviceClasses: any[]): void; | ||
static getAvailableDevices(): string[]; | ||
static getSupportedDevices(): string[]; | ||
static setDefaultDeviceProps(props: CreateDeviceProps): void; | ||
readonly stats: StatsManager; | ||
/** | ||
* Global log | ||
* | ||
* Assign luma.log.level in console to control logging: \ | ||
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs | ||
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`; | ||
*/ | ||
readonly log: Log; | ||
/** Version of luma.gl */ | ||
readonly VERSION: string; | ||
spector: unknown; | ||
protected preregisteredAdapters: Map<string, Adapter>; | ||
constructor(); | ||
registerAdapters(adapters: Adapter[]): void; | ||
/** Get type strings for supported Devices */ | ||
getSupportedAdapters(adapters?: Adapter[]): string[]; | ||
/** Get type strings for best available Device */ | ||
getBestAvailableAdapter(adapters?: Adapter[]): 'webgpu' | 'webgl' | null; | ||
setDefaultDeviceProps(props: CreateDeviceProps): void; | ||
/** Creates a device. Asynchronously. */ | ||
createDevice(props?: CreateDeviceProps): Promise<Device>; | ||
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */ | ||
static attachDevice(props: AttachDeviceProps): Promise<Device>; | ||
/** Creates a device. Asynchronously. */ | ||
static createDevice(props?: CreateDeviceProps): Promise<Device>; | ||
static enforceWebGL2(enforce?: boolean): void; | ||
attachDevice(props: AttachDeviceProps): Promise<Device>; | ||
/** | ||
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility. | ||
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts. | ||
*/ | ||
enforceWebGL2(enforce?: boolean, adapters?: Adapter[]): void; | ||
/** Convert a list of adapters to a map */ | ||
protected getAdapterMap(adapters?: Adapter[]): Map<string, Adapter>; | ||
/** @deprecated Use registerAdapters */ | ||
registerDevices(deviceClasses: any[]): void; | ||
} | ||
/** | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export declare const luma: Luma; | ||
//# sourceMappingURL=luma.d.ts.map |
@@ -7,50 +7,102 @@ // luma.gl | ||
import { log } from "../utils/log.js"; | ||
const deviceMap = new Map(); | ||
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering'; | ||
const ERROR_MESSAGE = 'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'; | ||
/** | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL devices (controls application bundle size) | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export class luma { | ||
export class Luma { | ||
static defaultProps = { | ||
...Device.defaultProps, | ||
type: 'best-available', | ||
devices: undefined | ||
adapters: undefined | ||
}; | ||
/** Global stats for all devices */ | ||
static stats = lumaStats; | ||
/** Global log */ | ||
static log = log; | ||
static registerDevices(deviceClasses /* : typeof Device */) { | ||
for (const deviceClass of deviceClasses) { | ||
deviceMap.set(deviceClass.type, deviceClass); | ||
stats = lumaStats; | ||
/** | ||
* Global log | ||
* | ||
* Assign luma.log.level in console to control logging: \ | ||
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs | ||
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`; | ||
*/ | ||
log = log; | ||
/** Version of luma.gl */ | ||
VERSION = | ||
// Version detection using build plugin | ||
// @ts-expect-error no-undef | ||
typeof "9.1.0-alpha.9" !== 'undefined' ? "9.1.0-alpha.9" : 'running from source'; | ||
spector; | ||
preregisteredAdapters = new Map(); | ||
constructor() { | ||
if (globalThis.luma) { | ||
if (globalThis.luma.VERSION !== this.VERSION) { | ||
log.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(); | ||
log.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)(); | ||
throw new Error(`luma.gl - multiple versions detected: see console log`); | ||
} | ||
log.error('This version of luma.gl has already been initialized')(); | ||
} | ||
log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)(); | ||
globalThis.luma = this; | ||
} | ||
static getAvailableDevices() { | ||
// @ts-expect-error | ||
return Array.from(deviceMap).map(Device => Device.type); | ||
registerAdapters(adapters) { | ||
for (const deviceClass of adapters) { | ||
this.preregisteredAdapters.set(deviceClass.type, deviceClass); | ||
} | ||
} | ||
static getSupportedDevices() { | ||
return (Array.from(deviceMap) | ||
// @ts-expect-error | ||
.filter(Device => Device.isSupported()) | ||
// @ts-expect-error | ||
.map(Device => Device.type)); | ||
/** Get type strings for supported Devices */ | ||
getSupportedAdapters(adapters = []) { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
return Array.from(adapterMap) | ||
.map(([, adapter]) => adapter) | ||
.filter(adapter => adapter.isSupported?.()) | ||
.map(adapter => adapter.type); | ||
} | ||
static setDefaultDeviceProps(props) { | ||
Object.assign(luma.defaultProps, props); | ||
/** Get type strings for best available Device */ | ||
getBestAvailableAdapter(adapters = []) { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
if (adapterMap.get('webgpu')?.isSupported?.()) { | ||
return 'webgpu'; | ||
} | ||
if (adapterMap.get('webgl')?.isSupported?.()) { | ||
return 'webgl'; | ||
} | ||
return null; | ||
} | ||
setDefaultDeviceProps(props) { | ||
Object.assign(Luma.defaultProps, props); | ||
} | ||
/** Creates a device. Asynchronously. */ | ||
async createDevice(props = {}) { | ||
props = { ...Luma.defaultProps, ...props }; | ||
// Should be handled by attach device | ||
// if (props.gl) { | ||
// props.type = 'webgl'; | ||
// } | ||
const adapterMap = this.getAdapterMap(props.adapters); | ||
let type = props.type || ''; | ||
if (type === 'best-available') { | ||
type = this.getBestAvailableAdapter(props.adapters) || type; | ||
} | ||
const adapters = this.getAdapterMap(props.adapters) || adapterMap; | ||
const adapter = adapters.get(type); | ||
const device = await adapter?.create?.(props); | ||
if (device) { | ||
return device; | ||
} | ||
throw new Error(ERROR_MESSAGE); | ||
} | ||
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */ | ||
static async attachDevice(props) { | ||
const devices = getDeviceMap(props.devices) || deviceMap; | ||
async attachDevice(props) { | ||
const adapters = this.getAdapterMap(props.adapters); | ||
// WebGL | ||
let type = ''; | ||
if (props.handle instanceof WebGL2RenderingContext) { | ||
const WebGLDevice = devices.get('webgl'); | ||
if (WebGLDevice) { | ||
return (await WebGLDevice.attach(props.handle)); | ||
} | ||
type = 'webgl'; | ||
} | ||
// TODO - WebGPU does not yet have a stable API | ||
// if (props.handle instanceof GPUDevice) { | ||
// const WebGPUDevice = devices.get('webgpu') as any; | ||
// const WebGPUDevice = adapters.get('webgpu') as any; | ||
// if (WebGPUDevice) { | ||
@@ -62,82 +114,48 @@ // return (await WebGPUDevice.attach(props.handle)) as Device; | ||
if (props.handle === null) { | ||
const UnknownDevice = devices.get('unknown'); | ||
if (UnknownDevice) { | ||
return (await UnknownDevice.attach(null)); | ||
} | ||
type = 'unknown'; | ||
} | ||
throw new Error('Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'); | ||
const adapter = adapters.get(type); | ||
const device = await adapter?.attach?.(null); | ||
if (device) { | ||
return device; | ||
} | ||
throw new Error(ERROR_MESSAGE); | ||
} | ||
/** Creates a device. Asynchronously. */ | ||
static async createDevice(props = {}) { | ||
props = { ...luma.defaultProps, ...props }; | ||
if (props.gl) { | ||
props.type = 'webgl'; | ||
/** | ||
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility. | ||
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts. | ||
*/ | ||
enforceWebGL2(enforce = true, adapters = []) { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
const webgl2Adapter = adapterMap.get('webgl'); | ||
if (!webgl2Adapter) { | ||
log.warn('enforceWebGL2: webgl adapter not found')(); | ||
} | ||
const devices = getDeviceMap(props.devices) || deviceMap; | ||
let WebGPUDevice; | ||
let WebGLDevice; | ||
switch (props.type) { | ||
case 'webgpu': | ||
WebGPUDevice = devices.get('webgpu'); | ||
if (WebGPUDevice) { | ||
return await WebGPUDevice.create(props); | ||
} | ||
break; | ||
case 'webgl': | ||
WebGLDevice = devices.get('webgl'); | ||
if (WebGLDevice) { | ||
return await WebGLDevice.create(props); | ||
} | ||
break; | ||
case 'unknown': | ||
const UnknownDevice = devices.get('unknown'); | ||
if (UnknownDevice) { | ||
return await UnknownDevice.create(props); | ||
} | ||
break; | ||
case 'best-available': | ||
WebGPUDevice = devices.get('webgpu'); | ||
if (WebGPUDevice?.isSupported?.()) { | ||
return await WebGPUDevice.create(props); | ||
} | ||
WebGLDevice = devices.get('webgl'); | ||
if (WebGLDevice?.isSupported?.()) { | ||
return await WebGLDevice.create(props); | ||
} | ||
break; | ||
webgl2Adapter?.enforceWebGL2?.(enforce); | ||
} | ||
/** Convert a list of adapters to a map */ | ||
getAdapterMap(adapters = []) { | ||
const map = new Map(this.preregisteredAdapters); | ||
for (const adapter of adapters) { | ||
map.set(adapter.type, adapter); | ||
} | ||
throw new Error('No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'); | ||
return map; | ||
} | ||
static enforceWebGL2(enforce = true) { | ||
const prototype = HTMLCanvasElement.prototype; | ||
if (!enforce && prototype.originalGetContext) { | ||
// Reset the original getContext function | ||
prototype.getContext = prototype.originalGetContext; | ||
prototype.originalGetContext = undefined; | ||
return; | ||
// DEPRECATED | ||
/** @deprecated Use registerAdapters */ | ||
registerDevices(deviceClasses) { | ||
log.warn('luma.registerDevices() is deprecated, use luma.registerAdapters() instead'); | ||
for (const deviceClass of deviceClasses) { | ||
const adapter = deviceClass.adapter; | ||
if (adapter) { | ||
this.preregisteredAdapters.set(adapter.type, adapter); | ||
} | ||
} | ||
// Store the original getContext function | ||
prototype.originalGetContext = prototype.getContext; | ||
// Override the getContext function | ||
prototype.getContext = function (contextId, options) { | ||
// Attempt to force WebGL2 for all WebGL1 contexts | ||
if (contextId === 'webgl' || contextId === 'experimental-webgl') { | ||
return this.originalGetContext('webgl2', options); | ||
} | ||
// For any other type, return the original context | ||
return this.originalGetContext(contextId, options); | ||
}; | ||
} | ||
} | ||
/** Convert a list of devices to a map */ | ||
function getDeviceMap(deviceClasses /* : typeof Device */) { | ||
if (!deviceClasses || deviceClasses?.length === 0) { | ||
return null; | ||
} | ||
const map = new Map(); | ||
for (const deviceClass of deviceClasses) { | ||
// assert(deviceClass.type && deviceClass.isSupported && deviceClass.create); | ||
map.set(deviceClass.type, deviceClass); | ||
} | ||
return map; | ||
} | ||
/** | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export const luma = new Luma(); |
@@ -31,5 +31,5 @@ import type { Device } from "../device.js"; | ||
* Built-in data types that can be used to initialize textures | ||
* @note WebGL supports OffscreenCanvas but seems WebGPU does not? | ||
* @note ImageData can be used for 8 bit data via Uint8ClampedArray | ||
*/ | ||
export type ExternalImage = ImageData | ImageBitmap | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement; | ||
export type ExternalImage = ImageBitmap | ImageData | HTMLImageElement | HTMLVideoElement | VideoFrame | HTMLCanvasElement | OffscreenCanvas; | ||
export type TextureLevelSource = TextureLevelData | ExternalImage; | ||
@@ -133,3 +133,3 @@ /** Texture data can be one or more mip levels */ | ||
height: number; | ||
} | null; | ||
}; | ||
/** Check if texture data is a typed array */ | ||
@@ -136,0 +136,0 @@ isTextureLevelData(data: TextureData): data is TextureLevelData; |
@@ -55,4 +55,6 @@ // luma.gl | ||
(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 HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement)); | ||
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas)); | ||
} | ||
@@ -63,3 +65,4 @@ /** Determine size (width and height) of provided image data */ | ||
(typeof ImageBitmap !== 'undefined' && data instanceof ImageBitmap) || | ||
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement)) { | ||
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement) || | ||
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas)) { | ||
return { width: data.width, height: data.height }; | ||
@@ -73,3 +76,7 @@ } | ||
} | ||
return null; | ||
if (typeof VideoFrame !== 'undefined' && data instanceof VideoFrame) { | ||
// TODO: is this the right choice for width and height? | ||
return { width: data.displayWidth, height: data.displayHeight }; | ||
} | ||
throw new Error('Unknown image type'); | ||
} | ||
@@ -97,3 +104,4 @@ /** Check if texture data is a typed array */ | ||
if (data && typeof data === 'object' && data.constructor === Object) { | ||
const untypedData = data; | ||
const textureDataArray = Object.values(data); | ||
const untypedData = textureDataArray[0]; | ||
return { width: untypedData.width, height: untypedData.height }; | ||
@@ -100,0 +108,0 @@ } |
@@ -78,2 +78,4 @@ import { DepthStencilTextureFormat } from "../../gpu-type-utils/texture-formats.js"; | ||
export type ColorParameters = { | ||
/** Enable blending */ | ||
blend?: boolean; | ||
/** Defines the operation used to calculate the values written to the target attachment components. */ | ||
@@ -80,0 +82,0 @@ blendColorOperation?: BlendOperation; |
@@ -28,2 +28,3 @@ // luma.gl | ||
// Color and blend parameters | ||
blend: false, | ||
blendColorOperation: 'add', | ||
@@ -30,0 +31,0 @@ blendColorSrcFactor: 'one', |
@@ -7,13 +7,13 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['luma'] = factory();})(globalThis, function () { | ||
"use strict";var __exports__=(()=>{var Q=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var le=(r,t,e)=>t in r?Q(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var me=(r,t)=>{for(var e in t)Q(r,e,{get:t[e],enumerable:!0})},he=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ce(t))!fe.call(r,o)&&o!==e&&Q(r,o,{get:()=>t[o],enumerable:!(n=ue(t,o))||n.enumerable});return r};var de=r=>he(Q({},"__esModule",{value:!0}),r);var a=(r,t,e)=>(le(r,typeof t!="symbol"?t+"":t,e),e);var tr={};me(tr,{Buffer:()=>m,CanvasContext:()=>D,CommandBuffer:()=>j,CommandEncoder:()=>O,ComputePass:()=>W,ComputePipeline:()=>V,Device:()=>b,DeviceFeatures:()=>it,DeviceLimits:()=>st,ExternalTexture:()=>U,Framebuffer:()=>z,QuerySet:()=>q,RenderPass:()=>k,RenderPipeline:()=>G,Resource:()=>u,Sampler:()=>H,Shader:()=>F,Texture:()=>h,TextureView:()=>N,TransformFeedback:()=>Z,UniformBlock:()=>P,UniformBufferLayout:()=>C,UniformStore:()=>mt,VERSION:()=>nt,VertexArray:()=>X,decodeShaderAttributeType:()=>ct,decodeShaderUniformType:()=>ft,decodeTextureFormat:()=>jt,decodeVertexFormat:()=>Y,getAttributeInfosFromLayouts:()=>Ct,getDataTypeFromTypedArray:()=>Rt,getScratchArray:()=>re,getScratchArrayBuffer:()=>K,getTypedArrayFromDataType:()=>ie,getVertexFormatFromAttribute:()=>ae,glsl:()=>Je,log:()=>f,luma:()=>T});var J=globalThis,pe=globalThis.document||{},tt=globalThis.process||{},ge=globalThis.console,rr=globalThis.navigator||{};function Dt(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,e=r||t;return Boolean(e&&e.indexOf("Electron")>=0)}function d(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Dt()}var ht="4.0.7";function be(r){try{let t=window[r],e="__storage_test__";return t.setItem(e,e),t.removeItem(e),t}catch{return null}}var et=class{constructor(t,e,n="sessionStorage"){this.storage=be(n),this.id=t,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let t={};if(this.storage){let e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}};function $t(r){let t;return r<10?t=`${r.toFixed(2)}ms`:r<100?t=`${r.toFixed(1)}ms`:r<1e3?t=`${r.toFixed(0)}ms`:t=`${(r/1e3).toFixed(2)}s`,t}function Nt(r,t=8){let e=Math.max(t-r.length,0);return`${" ".repeat(e)}${r}`}var rt;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(rt||(rt={}));var we=10;function Ut(r){return typeof r!="string"?r:(r=r.toUpperCase(),rt[r]||rt.WHITE)}function Ft(r,t,e){return!d&&typeof r=="string"&&(t&&(r=`\x1B[${Ut(t)}m${r}\x1B[39m`),e&&(r=`\x1B[${Ut(e)+we}m${r}\x1B[49m`)),r}function Ht(r,t=["constructor"]){let e=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(e),o=r;for(let s of n){let i=o[s];typeof i=="function"&&(t.find(c=>s===c)||(o[s]=i.bind(r)))}}function B(r,t){if(!r)throw new Error(t||"Assertion failed")}function w(){let r;if(d()&&J.performance)r=J?.performance?.now?.();else if("hrtime"in tt){let t=tt?.hrtime?.();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var S={debug:d()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},xe={enabled:!0,level:0};function v(){}var zt={},Gt={once:!0},y=class{constructor({id:t}={id:""}){this.VERSION=ht,this._startTs=w(),this._deltaTs=w(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new et(`__probe-${this.id}__`,xe),this.timeStamp(`${this.id} started`),Ht(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((w()-this._startTs).toPrecision(10))}getDelta(){return Number((w()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.setConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){if(!t)throw new Error(e||"Assertion failed")}warn(t){return this._getLogFunction(0,t,S.warn,arguments,Gt)}error(t){return this._getLogFunction(0,t,S.error,arguments)}deprecated(t,e){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${e}\` instead`)}removed(t,e){return this.error(`\`${t}\` has been removed. Use \`${e}\` instead`)}probe(t,e){return this._getLogFunction(t,e,S.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,S.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){return this._getLogFunction(t,e,S.debug||S.info,arguments,Gt)}table(t,e,n){return e?this._getLogFunction(t,e,console.table||v,n&&[n],{tag:Se(e)}):v}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||v)}group(t,e,n={collapsed:!1}){let o=kt({logLevel:t,message:e,opts:n}),{collapsed:s}=n;return o.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(o)}groupCollapsed(t,e,n={}){return this.group(t,e,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||v)}withGroup(t,e,n){this.group(t,e)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=Vt(t)}_getLogFunction(t,e,n,o,s){if(this._shouldLog(t)){s=kt({logLevel:t,message:e,args:o,opts:s}),n=n||s.method,B(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=w();let i=s.tag||s.message;if(s.once&&i)if(!zt[i])zt[i]=w();else return v;return e=Te(this.id,s.message,s),n.bind(console,e,...s.args)}return v}};y.VERSION=ht;function Vt(r){if(!r)return 0;let t;switch(typeof r){case"number":t=r;break;case"object":t=r.logLevel||r.priority||0;break;default:return 0}return B(Number.isFinite(t)&&t>=0),t}function kt(r){let{logLevel:t,message:e}=r;r.logLevel=Vt(t);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==e;);switch(typeof t){case"string":case"function":e!==void 0&&n.unshift(e),r.message=t;break;case"object":Object.assign(r,t);break;default:}typeof r.message=="function"&&(r.message=r.message());let o=typeof r.message;return B(o==="string"||o==="object"),Object.assign(r,{args:n},r.opts)}function Te(r,t,e){if(typeof t=="string"){let n=e.time?Nt($t(e.total)):"";t=e.time?`${r}: ${n} ${t}`:`${r}: ${t}`,t=Ft(t,e.color,e.background)}return t}function Se(r){for(let t in r)for(let e in r[t])return e||"untitled";return"empty"}globalThis.probe={};var Lr=new y({id:"@probe.gl/log"});var f=new y({id:"luma.gl"});function M(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var x=class{constructor(t,e){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=e,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=M(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(M()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var E=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let e of Object.values(this.stats))t(e)}getTable(){let t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(e=>this._getOrCreate(e))}_getOrCreate(t){let{name:e,type:n}=t,o=this.stats[e];return o||(t instanceof x?o=t:o=new x(e,n),this.stats[e]=o),o}};var dt=class{stats=new Map;getStats(t){return this.get(t)}get(t){return this.stats.has(t)||this.stats.set(t,new E({id:t})),this.stats.get(t)}},A=new dt;function ve(){let r="9.1.0-alpha.2",t="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==r)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${r}`);return globalThis.luma||(d()&&f.log(1,`${r} - ${t}`)(),globalThis.luma=globalThis.luma||{VERSION:r,version:r,log:f,stats:A}),r}var nt=ve();var pt={};function _(r="id"){pt[r]=pt[r]||1;let t=pt[r]++;return`${r}-${t}`}var u=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(t,e,n){if(!t)throw new Error("no device");this._device=t,this.props=Ee(e,n);let o=this.props.id!=="undefined"?this.props.id:_(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(t){this._attachedResources.add(t)}detachResource(t){this._attachedResources.delete(t)}destroyAttachedResource(t){this._attachedResources.delete(t)&&t.destroy()}destroyAttachedResources(){for(let t of Object.values(this._attachedResources))t.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get(`${e}s Active`).decrementCount()}trackAllocatedMemory(t,e=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(t),n.get(`${e} Memory`).addCount(t),this.allocatedBytes=t}trackDeallocatedMemory(t=this[Symbol.toStringTag]){let e=this._device.statsManager.getStats("Resource Counts");e.get("GPU Memory").subtractCount(this.allocatedBytes),e.get(`${t} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get("Resources Created").incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount()}};a(u,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Ee(r,t){let e={...t};for(let n in r)r[n]!==void 0&&(e[n]=r[n]);return e}var R=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(t,e){let n={...e};(e.usage||0)&R.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?n.indexType="uint32":e.data instanceof Uint16Array&&(n.indexType="uint16")),super(t,n,R.defaultProps),this.usage=e.usage||0,this.indexType=n.indexType,this.updateTimestamp=t.incrementTimestamp()}readSyncWebGL(t,e){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(t,e,n){let o=ArrayBuffer.isView(t)?t.buffer:t,s=Math.min(t?t.byteLength:n,R.DEBUG_DATA_MAX_LENGTH);o===null?this.debugData=new ArrayBuffer(s):e===0&&n===o.byteLength?this.debugData=o.slice(0,s):this.debugData=o.slice(e,e+s)}},m=R;a(m,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),a(m,"MAP_READ",1),a(m,"MAP_WRITE",2),a(m,"COPY_SRC",4),a(m,"COPY_DST",8),a(m,"INDEX",16),a(m,"VERTEX",32),a(m,"UNIFORM",64),a(m,"STORAGE",128),a(m,"INDIRECT",256),a(m,"QUERY_RESOLVE",512),a(m,"DEBUG_DATA_MAX_LENGTH",32);function ot(r){let t=Wt[r],e=Ae(t),n=r.includes("norm"),o=!n&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:Wt[r],byteLength:e,integer:o,signed:s,normalized:n}}function Ae(r){return _e[r]}var Wt={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},_e={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Le=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Ce=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function Ot(r){return Le.some(t=>r.startsWith(t))}function jt(r){let t=Ce.exec(r);if(t){let[,e,n,o,s,i]=t;if(e){let c=`${o}${n}`,l=ot(c);return{format:e,components:e.length,srgb:s==="-srgb",unsized:i==="-unsized",webgl:i==="-webgl",...l}}}return Be(r)}var Pe={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function Be(r){let t=Pe[r];if(!t)throw new Error(`Unknown format ${r}`);return{format:t.format||"",components:t.components||t.format?.length||1,byteLength:t.bpp||1,srgb:!1,unsized:!1}}var st=class{},it=class{features;disabledFeatures;constructor(t=[],e){this.features=new Set(t),this.disabledFeatures=e||{}}*[Symbol.iterator](){yield*this.features}has(t){return!this.disabledFeatures?.[t]&&this.features.has(t)}},gt=class{get[Symbol.toStringTag](){return"Device"}constructor(t){this.props={...gt.defaultProps,...t},this.id=this.props.id||_(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=A;_lumaData={};isTextureFormatCompressed(t){return Ot(t)}loseDevice(){return!1}error(t){this.props.onError(t)}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(t){return this._createTexture(t)}createCommandEncoder(t={}){throw new Error("not implemented")}readPixelsToArrayWebGL(t,e){throw new Error("not implemented")}readPixelsToBufferWebGL(t,e){throw new Error("not implemented")}setParametersWebGL(t){throw new Error("not implemented")}getParametersWebGL(t){throw new Error("not implemented")}withParametersWebGL(t,e){throw new Error("not implemented")}clearWebGL(t){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(t){this.props.onError(t)}_getBufferProps(t){(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e={...t};return(t.usage||0)&m.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?e.indexType="uint32":t.data instanceof Uint16Array?e.indexType="uint16":f.warn("indices buffer content must be of integer type")()),e}},b=gt;a(b,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,onError:t=>f.error(t.message),gl:null,debug:Boolean(f.get("debug")),spector:Boolean(f.get("spector")),break:f.get("break")||[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},_factoryDestroyPolicy:"unused"}),a(b,"VERSION",nt);var I=new Map,at=class{static registerDevices(t){for(let e of t)I.set(e.type,e)}static getAvailableDevices(){return Array.from(I).map(t=>t.type)}static getSupportedDevices(){return Array.from(I).filter(t=>t.isSupported()).map(t=>t.type)}static setDefaultDeviceProps(t){Object.assign(at.defaultProps,t)}static async attachDevice(t){let e=Yt(t.devices)||I;if(t.handle instanceof WebGL2RenderingContext){let n=e.get("webgl");if(n)return await n.attach(t.handle)}if(t.handle===null){let n=e.get("unknown");if(n)return await n.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(t={}){t={...at.defaultProps,...t},t.gl&&(t.type="webgl");let e=Yt(t.devices)||I,n,o;switch(t.type){case"webgpu":if(n=e.get("webgpu"),n)return await n.create(t);break;case"webgl":if(o=e.get("webgl"),o)return await o.create(t);break;case"unknown":let s=e.get("unknown");if(s)return await s.create(t);break;case"best-available":if(n=e.get("webgpu"),n?.isSupported?.())return await n.create(t);if(o=e.get("webgl"),o?.isSupported?.())return await o.create(t);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(n,o){return n==="webgl"||n==="experimental-webgl"?this.originalGetContext("webgl2",o):this.originalGetContext(n,o)}}},T=at;a(T,"defaultProps",{...b.defaultProps,type:"best-available",devices:void 0}),a(T,"stats",A),a(T,"log",f);function Yt(r){if(!r||r?.length===0)return null;let t=new Map;for(let e of r)t.set(e.type,e);return t}var Me=d()&&typeof document<"u",ut=()=>Me&&document.readyState==="complete",Re={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},D=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ut()}constructor(t){if(this.props={...Re,...t},t=this.props,!d()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(t.canvas)typeof t.canvas=="string"?this.canvas=$e(t.canvas):this.canvas=t.canvas;else{let e=Ne(t),n=De(t?.container||null);n.insertBefore(e,n.firstChild),this.canvas=e,t?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&t.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(let n of e)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(t){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(t=t===void 0?this.props.useDevicePixels:t,!t||t<=0)?1:t===!0?typeof window<"u"&&window.devicePixelRatio||1:t}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let t=this.getDevicePixelRatio(),e=this.canvas;return e.parentElement?[e.clientWidth*t,e.clientHeight*t]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[t,e]=this.getPixelSize();return t/e}cssToDeviceRatio(){try{let[t]=this.getDrawingBufferSize(),{clientWidth:e}=this._canvasSizeInfo;return e?t/e:1}catch{return 1}}cssToDevicePixels(t,e=!0){let n=this.cssToDeviceRatio(),[o,s]=this.getDrawingBufferSize();return Ue(t,n,o,s,e)}setDevicePixelRatio(t,e={}){if(!this.htmlCanvas)return;let n="width"in e?e.width:this.htmlCanvas.clientWidth,o="height"in e?e.height:this.htmlCanvas.clientHeight;(!n||!o)&&(f.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,n=this.htmlCanvas.width||1,o=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==o||s.devicePixelRatio!==t){let i=t,c=Math.floor(n*i),l=Math.floor(o*i);this.htmlCanvas.width=c,this.htmlCanvas.height=l;let[g,p]=this.getDrawingBufferSize();(g!==c||p!==l)&&(i=Math.min(g/n,p/o),this.htmlCanvas.width=Math.floor(n*i),this.htmlCanvas.height=Math.floor(o*i),f.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=o,this._canvasSizeInfo.devicePixelRatio=t}}getDrawingBufferSize(){let t=this.device.gl;if(!t)throw new Error("canvas size");return[t.drawingBufferWidth,t.drawingBufferHeight]}_setAutoCreatedCanvasId(t){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=t)}};a(D,"pageLoaded",Ie());function Ie(){return ut()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function De(r){if(typeof r=="string"){let t=document.getElementById(r);if(!t&&!ut())throw new Error(`Accessing '${r}' before page was loaded`);if(!t)throw new Error(`${r} is not an HTML element`);return t}else if(r)return r;return document.body}function $e(r){let t=document.getElementById(r);if(!t&&!ut())throw new Error(`Accessing '${r}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}function Ne(r){let{width:t,height:e}=r,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=t||1,n.height=e||1,n.style.width=Number.isFinite(t)?`${t}px`:"100%",n.style.height=Number.isFinite(e)?`${e}px`:"100%",n}function Ue(r,t,e,n,o){let s=r,i=Xt(s[0],t,e),c=Zt(s[1],t,n,o),l=Xt(s[0]+1,t,e),g=l===e-1?l:l-1;l=Zt(s[1]+1,t,n,o);let p;return o?(l=l===0?l:l+1,p=c,c=l):p=l===n-1?l:l-1,{x:i,y:c,width:Math.max(g-i+1,1),height:Math.max(p-c+1,1)}}function Xt(r,t,e){return Math.min(Math.round(r*t),e-1)}function Zt(r,t,e,n){return n?Math.max(0,e-1-Math.round(r*t)):Math.min(Math.round(r*t),e-1)}var $=class extends u{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;mipLevels;updateTimestamp;static isExternalImage(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}static getExternalImageSize(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?{width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?{width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:null}isTextureLevelData(t){let e=t?.data;return ArrayBuffer.isView(e)}getTextureDataSize(t){if(!t||ArrayBuffer.isView(t))return null;if(Array.isArray(t))return this.getTextureDataSize(t[0]);if($.isExternalImage(t))return $.getExternalImageSize(t);if(t&&typeof t=="object"&&t.constructor===Object){let e=t;return{width:e.width,height:e.height}}throw new Error("texture size deduction failed")}getMipLevelCount(t,e){return Math.floor(Math.log2(Math.max(t,e)))+1}getCubeFaceDepth(t){switch(t){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(t)}}constructor(t,e){if(super(t,e,$.defaultProps),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.props.width===void 0||this.props.height===void 0){let n=this.getTextureDataSize(this.props.data);this.width=n?.width||1,this.height=n?.height||1}this.props.mipmaps&&this.props.mipLevels===void 0&&(this.props.mipLevels="pyramid"),this.mipLevels=this.props.mipLevels==="pyramid"?this.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=t.incrementTimestamp()}},h=$;a(h,"COPY_SRC",1),a(h,"COPY_DST",2),a(h,"TEXTURE",4),a(h,"STORAGE",8),a(h,"RENDER_ATTACHMENT",16),a(h,"CubeFaces",["+X","-X","+Y","-Y","+Z","-Z"]),a(h,"defaultProps",{...u.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!1,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,sampler:{},view:void 0});var yt=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(t,e){super(t,e,yt.defaultProps)}},N=yt;a(N,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var bt=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(t,e){super(t,e,bt.defaultProps)}},U=bt;a(U,"defaultProps",{...u.defaultProps,source:void 0,colorSpace:"srgb"});function Kt(r,t,e){let n="",o=t.split(/\r?\n/),s=r.slice().sort((i,c)=>i.lineNum-c.lineNum);switch(e?.showSourceCode||"no"){case"all":let i=0;for(let c=1;c<=o.length;c++)for(n+=Qt(o[c-1],c,e);s.length>i&&s[i].lineNum===c;){let l=s[i++];n+=qt(l,o,l.lineNum,{...e,inlineSource:!1})}return n;case"issues":case"no":for(let c of r)n+=qt(c,o,c.lineNum,{inlineSource:e?.showSourceCode!=="no"});return n}}function qt(r,t,e,n){if(n?.inlineSource){let o=Fe(t,e),s=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
"use strict";var __exports__=(()=>{var X=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ft=Object.prototype.hasOwnProperty;var lt=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var dt=(r,e)=>{for(var t in e)X(r,t,{get:e[t],enumerable:!0})},ht=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ut(e))!ft.call(r,n)&&n!==t&&X(r,n,{get:()=>e[n],enumerable:!(s=ct(e,n))||s.enumerable});return r};var mt=r=>ht(X({},"__esModule",{value:!0}),r);var a=(r,e,t)=>(lt(r,typeof e!="symbol"?e+"":e,t),t);var er={};dt(er,{Adapter:()=>oe,Buffer:()=>d,CanvasContext:()=>M,CommandBuffer:()=>V,CommandEncoder:()=>G,ComputePass:()=>z,ComputePipeline:()=>k,Device:()=>w,DeviceFeatures:()=>re,DeviceLimits:()=>te,ExternalTexture:()=>D,Framebuffer:()=>N,QuerySet:()=>Y,RenderPass:()=>H,RenderPipeline:()=>U,Resource:()=>c,Sampler:()=>F,Shader:()=>$,Texture:()=>h,TextureView:()=>I,TransformFeedback:()=>j,UniformBlock:()=>_,UniformBufferLayout:()=>P,UniformStore:()=>fe,VertexArray:()=>O,decodeShaderAttributeType:()=>ae,decodeShaderUniformType:()=>ce,decodeTextureFormat:()=>Oe,decodeVertexFormat:()=>W,getAttributeInfosFromLayouts:()=>_e,getDataTypeFromTypedArray:()=>Re,getScratchArray:()=>rt,getTypedArrayFromDataType:()=>it,getVertexFormatFromAttribute:()=>at,log:()=>l,luma:()=>Ye});function L(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var b=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=L(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(L()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var T=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:s}=e,n=this.stats[t];return n||(e instanceof b?n=e:n=new b(t,s),this.stats[t]=n),n}};var le=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new T({id:e})),this.stats.get(e)}},Z=new le;var q=globalThis,pt=globalThis.document||{},K=globalThis.process||{},gt=globalThis.console,hr=globalThis.navigator||{};function De(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}function p(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||De()}var de="4.0.7";function bt(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Q=class{constructor(e,t,s="sessionStorage"){this.storage=bt(s),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function $e(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Fe(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var J;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(J||(J={}));var xt=10;function Ne(r){return typeof r!="string"?r:(r=r.toUpperCase(),J[r]||J.WHITE)}function Ue(r,e,t){return!p&&typeof r=="string"&&(e&&(r=`\x1B[${Ne(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Ne(t)+xt}m${r}\x1B[49m`)),r}function He(r,e=["constructor"]){let t=Object.getPrototypeOf(r),s=Object.getOwnPropertyNames(t),n=r;for(let o of s){let i=n[o];typeof i=="function"&&(e.find(u=>o===u)||(n[o]=i.bind(r)))}}function C(r,e){if(!r)throw new Error(e||"Assertion failed")}function x(){let r;if(p()&&q.performance)r=q?.performance?.now?.();else if("hrtime"in K){let e=K?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var S={debug:p()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},wt={enabled:!0,level:0};function A(){}var ke={},ze={once:!0},y=class{constructor({id:e}={id:""}){this.VERSION=de,this._startTs=x(),this._deltaTs=x(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Q(`__probe-${this.id}__`,wt),this.timeStamp(`${this.id} started`),He(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((x()-this._startTs).toPrecision(10))}getDelta(){return Number((x()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,S.warn,arguments,ze)}error(e){return this._getLogFunction(0,e,S.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,S.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,S.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,S.debug||S.info,arguments,ze)}table(e,t,s){return t?this._getLogFunction(e,t,console.table||A,s&&[s],{tag:St(t)}):A}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||A)}group(e,t,s={collapsed:!1}){let n=Ge({logLevel:e,message:t,opts:s}),{collapsed:o}=s;return n.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,s={}){return this.group(e,t,Object.assign({},s,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||A)}withGroup(e,t,s){this.group(e,t)();try{s()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Ve(e)}_getLogFunction(e,t,s,n,o){if(this._shouldLog(e)){o=Ge({logLevel:e,message:t,args:n,opts:o}),s=s||o.method,C(s),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=x();let i=o.tag||o.message;if(o.once&&i)if(!ke[i])ke[i]=x();else return A;return t=Tt(this.id,o.message,o),s.bind(console,t,...o.args)}return A}};y.VERSION=de;function Ve(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return C(Number.isFinite(e)&&e>=0),e}function Ge(r){let{logLevel:e,message:t}=r;r.logLevel=Ve(e);let s=r.args?Array.from(r.args):[];for(;s.length&&s.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&s.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return C(n==="string"||n==="object"),Object.assign(r,{args:s},r.opts)}function Tt(r,e,t){if(typeof e=="string"){let s=t.time?Fe($e(t.total)):"";e=t.time?`${r}: ${s} ${e}`:`${r}: ${e}`,e=Ue(e,t.color,t.background)}return e}function St(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var Ur=new y({id:"@probe.gl/log"});var l=new y({id:"luma.gl"});var he={};function v(r="id"){he[r]=he[r]||1;let e=he[r]++;return`${r}-${e}`}var c=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,s){if(!e)throw new Error("no device");this._device=e,this.props=At(t,s);let n=this.props.id!=="undefined"?this.props.id:v(this[Symbol.toStringTag]);this.props.id=n,this.id=n,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let s=this._device.statsManager.getStats("Resource Counts");s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};a(c,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function At(r,e){let t={...e};for(let s in r)r[s]!==void 0&&(t[s]=r[s]);return t}var B=class extends c{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let s={...t};(t.usage||0)&B.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?s.indexType="uint32":t.data instanceof Uint16Array&&(s.indexType="uint16")),super(e,s,B.defaultProps),this.usage=t.usage||0,this.indexType=s.indexType,this.updateTimestamp=e.incrementTimestamp()}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,s){let n=ArrayBuffer.isView(e)?e.buffer:e,o=Math.min(e?e.byteLength:s,B.DEBUG_DATA_MAX_LENGTH);n===null?this.debugData=new ArrayBuffer(o):t===0&&s===n.byteLength?this.debugData=n.slice(0,o):this.debugData=n.slice(t,t+o)}},d=B;a(d,"defaultProps",{...c.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),a(d,"MAP_READ",1),a(d,"MAP_WRITE",2),a(d,"COPY_SRC",4),a(d,"COPY_DST",8),a(d,"INDEX",16),a(d,"VERTEX",32),a(d,"UNIFORM",64),a(d,"STORAGE",128),a(d,"INDIRECT",256),a(d,"QUERY_RESOLVE",512),a(d,"DEBUG_DATA_MAX_LENGTH",32);function ee(r){let e=We[r],t=vt(e),s=r.includes("norm"),n=!s&&!r.startsWith("float"),o=r.startsWith("s");return{dataType:We[r],byteLength:t,integer:n,signed:o,normalized:s}}function vt(r){return Et[r]}var We={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Et={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Pt=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],_t=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;function me(r){return Pt.some(e=>r.startsWith(e))}function Oe(r){let e=_t.exec(r);if(e){let[,t,s,n,o,i]=e;if(r){let u=`${n}${s}`,f=ee(u),m={channels:t,components:t.length,bitsPerChannel:f.byteLength*8,bytesPerPixel:f.byteLength*t.length,dataType:f.dataType,integer:f.integer,signed:f.signed,normalized:f.normalized};return i==="-webgl"&&(m.webgl=!0),o==="-srgb"&&(m.srgb=!0),m}}return Ct(r)}var Lt={"rgba4unorm-webgl":{channels:"rgba",bytesPerPixel:2,packed:!0},"rgb565unorm-webgl":{channels:"rgb",bytesPerPixel:2,packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bytesPerPixel:2,packed:!0},rgb9e5ufloat:{channels:"rgb",bytesPerPixel:4,packed:!0},rg11b10ufloat:{channels:"rgb",bytesPerPixel:4,packed:!0},rgb10a2unorm:{channels:"rgba",bytesPerPixel:4,packed:!0},"rgb10a2uint-webgl":{channels:"rgba",bytesPerPixel:4,packed:!0},stencil8:{components:1,bytesPerPixel:1,a:"stencil",dataType:"uint8"},depth16unorm:{components:1,bytesPerPixel:2,a:"depth",dataType:"uint16"},depth24plus:{components:1,bytesPerPixel:3,a:"depth",dataType:"uint32"},depth32float:{components:1,bytesPerPixel:4,a:"depth",dataType:"float32"},"depth24plus-stencil8":{components:2,bytesPerPixel:4,a:"depth-stencil",packed:!0},"depth32float-stencil8":{components:2,bytesPerPixel:4,a:"depth-stencil",packed:!0}};function Ct(r){if(me(r)){let s={channels:"rgb",components:3,bytesPerPixel:1,srgb:!1,compressed:!0},n=Bt(r);return n&&(s.blockWidth=n.blockWidth,s.blockHeight=n.blockHeight),s}let e=Lt[r];if(!e)throw new Error(`Unknown format ${r}`);let t={...e,channels:e.channels||"",components:e.components||e.channels?.length||1,bytesPerPixel:e.bytesPerPixel||1,srgb:!1};return e.packed&&(t.packed=e.packed),t}function Bt(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,s,n]=t;return{blockWidth:Number(s),blockHeight:Number(n)}}return null}var te=class{},re=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},pe=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...pe.defaultProps,...e},this.id=this.props.id||v(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Z;_lumaData={};isTextureFormatCompressed(e){return me(e)}loseDevice(){return!1}error(e){this.props.onError(e)}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};return(e.usage||0)&d.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":l.warn("indices buffer content must be of integer type")()),t}},w=pe;a(w,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,onError:e=>l.error(e.message),gl:null,debug:Boolean(l.get("debug")),break:l.get("break")||[],debugWithSpectorJS:void 0,spectorUrl:void 0,initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},_factoryDestroyPolicy:"unused"});var Mt="set luma.log.level=1 (or higher) to trace rendering",je="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ne=class{stats=Z;log=l;VERSION="9.1.0-alpha.9";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw l.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),l.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");l.error("This version of luma.gl has already been initialized")()}l.log(1,`${this.VERSION} - ${Mt}`)(),globalThis.luma=this}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this.getAdapterMap(e);return Array.from(t).map(([,s])=>s).filter(s=>s.isSupported?.()).map(s=>s.type)}getBestAvailableAdapter(e=[]){let t=this.getAdapterMap(e);return t.get("webgpu")?.isSupported?.()?"webgpu":t.get("webgl")?.isSupported?.()?"webgl":null}setDefaultDeviceProps(e){Object.assign(ne.defaultProps,e)}async createDevice(e={}){e={...ne.defaultProps,...e};let t=this.getAdapterMap(e.adapters),s=e.type||"";s==="best-available"&&(s=this.getBestAvailableAdapter(e.adapters)||s);let i=await(this.getAdapterMap(e.adapters)||t).get(s)?.create?.(e);if(i)return i;throw new Error(je)}async attachDevice(e){let t=this.getAdapterMap(e.adapters),s="";e.handle instanceof WebGL2RenderingContext&&(s="webgl"),e.handle===null&&(s="unknown");let o=await t.get(s)?.attach?.(null);if(o)return o;throw new Error(je)}enforceWebGL2(e=!0,t=[]){let n=this.getAdapterMap(t).get("webgl");n||l.warn("enforceWebGL2: webgl adapter not found")(),n?.enforceWebGL2?.(e)}getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let s of e)t.set(s.type,s);return t}registerDevices(e){l.warn("luma.registerDevices() is deprecated, use luma.registerAdapters() instead");for(let t of e){let s=t.adapter;s&&this.preregisteredAdapters.set(s.type,s)}}},se=ne;a(se,"defaultProps",{...w.defaultProps,type:"best-available",adapters:void 0});var Ye=new se;var oe=class{};var Rt=p()&&typeof document<"u",ie=()=>Rt&&document.readyState==="complete",It={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},M=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ie()}constructor(e){if(this.props={...It,...e},e=this.props,!p()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Ft(e.canvas):this.canvas=e.canvas;else{let t=Nt(e),s=$t(e?.container||null);s.insertBefore(t,s.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(t=>{for(let s of t)s.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:t}=this._canvasSizeInfo;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){let s=this.cssToDeviceRatio(),[n,o]=this.getDrawingBufferSize();return Ut(e,s,n,o,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let s="width"in t?t.width:this.htmlCanvas.clientWidth,n="height"in t?t.height:this.htmlCanvas.clientHeight;(!s||!n)&&(l.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,s=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);let o=this._canvasSizeInfo;if(o.clientWidth!==s||o.clientHeight!==n||o.devicePixelRatio!==e){let i=e,u=Math.floor(s*i),f=Math.floor(n*i);this.htmlCanvas.width=u,this.htmlCanvas.height=f;let[m,g]=this.getDrawingBufferSize();(m!==u||g!==f)&&(i=Math.min(m/s,g/n),this.htmlCanvas.width=Math.floor(s*i),this.htmlCanvas.height=Math.floor(n*i),l.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=s,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};a(M,"pageLoaded",Dt());function Dt(){return ie()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function $t(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e&&!ie())throw new Error(`Accessing '${r}' before page was loaded`);if(!e)throw new Error(`${r} is not an HTML element`);return e}else if(r)return r;return document.body}function Ft(r){let e=document.getElementById(r);if(!e&&!ie())throw new Error(`Accessing '${r}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function Nt(r){let{width:e,height:t}=r,s=document.createElement("canvas");return s.id="lumagl-auto-created-canvas",s.width=e||1,s.height=t||1,s.style.width=Number.isFinite(e)?`${e}px`:"100%",s.style.height=Number.isFinite(t)?`${t}px`:"100%",s}function Ut(r,e,t,s,n){let o=r,i=Xe(o[0],e,t),u=Ze(o[1],e,s,n),f=Xe(o[0]+1,e,t),m=f===t-1?f:f-1;f=Ze(o[1]+1,e,s,n);let g;return n?(f=f===0?f:f+1,g=u,u=f):g=f===s-1?f:f-1,{x:i,y:u,width:Math.max(m-i+1,1),height:Math.max(g-u+1,1)}}function Xe(r,e,t){return Math.min(Math.round(r*e),t-1)}function Ze(r,e,t,s){return s?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var R=class extends c{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;mipLevels;updateTimestamp;static isExternalImage(e){return typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof VideoFrame<"u"&&e instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}static getExternalImageSize(e){if(typeof ImageData<"u"&&e instanceof ImageData||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if(typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if(typeof VideoFrame<"u"&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw new Error("Unknown image type")}isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(R.isExternalImage(e))return R.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let s=Object.values(e)[0];return{width:s.width,height:s.height}}throw new Error("texture size deduction failed")}getMipLevelCount(e,t){return Math.floor(Math.log2(Math.max(e,t)))+1}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}constructor(e,t){if(super(e,t,R.defaultProps),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.props.width===void 0||this.props.height===void 0){let s=this.getTextureDataSize(this.props.data);this.width=s?.width||1,this.height=s?.height||1}this.props.mipmaps&&this.props.mipLevels===void 0&&(this.props.mipLevels="pyramid"),this.mipLevels=this.props.mipLevels==="pyramid"?this.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=e.incrementTimestamp()}},h=R;a(h,"COPY_SRC",1),a(h,"COPY_DST",2),a(h,"TEXTURE",4),a(h,"STORAGE",8),a(h,"RENDER_ATTACHMENT",16),a(h,"CubeFaces",["+X","-X","+Y","-Y","+Z","-Z"]),a(h,"defaultProps",{...c.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!1,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,sampler:{},view:void 0});var ge=class extends c{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,ge.defaultProps)}},I=ge;a(I,"defaultProps",{...c.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var ye=class extends c{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,ye.defaultProps)}},D=ye;a(D,"defaultProps",{...c.defaultProps,source:void 0,colorSpace:"srgb"});function Ke(r,e,t){let s="",n=e.split(/\r?\n/),o=r.slice().sort((i,u)=>i.lineNum-u.lineNum);switch(t?.showSourceCode||"no"){case"all":let i=0;for(let u=1;u<=n.length;u++)for(s+=Qe(n[u-1],u,t);o.length>i&&o[i].lineNum===u;){let f=o[i++];s+=qe(f,n,f.lineNum,{...t,inlineSource:!1})}return s;case"issues":case"no":for(let u of r)s+=qe(u,n,u.lineNum,{inlineSource:t?.showSourceCode!=="no"});return s}}function qe(r,e,t,s){if(s?.inlineSource){let n=Ht(e,t),o=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
`:"";return` | ||
${o}${s}${r.type.toUpperCase()}: ${r.message} | ||
${n}${o}${r.type.toUpperCase()}: ${r.message} | ||
`}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Fe(r,t,e){let n="";for(let o=t-2;o<=t;o++){let s=r[o-1];s!==void 0&&(n+=Qt(s,t,e))}return n}function Qt(r,t,e){let n=e?.html?ze(r):r;return`${He(String(t),4)}: ${n}${e?.html?"<br/>":` | ||
`}`}function He(r,t){let e="";for(let n=r.length;n<t;++n)e+=" ";return e+r}function ze(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var wt=class extends u{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(t,e){super(t,{id:Ge(e),...e},wt.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(t=this.props.debug){switch(t){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let e=await this.getCompilationInfo();this.props.debug==="warnings"&&e?.length===0||this._displayShaderLog(e)}_displayShaderLog(t){if(typeof document>"u"||!document?.createElement)return;let e=Jt(this.source),n=`${this.stage} ${e}`,o=Kt(t,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(o+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${s}</pre></code>`);let i=document.createElement("Button");i.innerHTML=` | ||
<h1>Shader Compilation Error in ${n}</h1><br /><br /> | ||
`}return s?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Ht(r,e,t){let s="";for(let n=e-2;n<=e;n++){let o=r[n-1];o!==void 0&&(s+=Qe(o,e,t))}return s}function Qe(r,e,t){let s=t?.html?zt(r):r;return`${kt(String(e),4)}: ${s}${t?.html?"<br/>":` | ||
`}`}function kt(r,e){let t="";for(let s=r.length;s<e;++s)t+=" ";return t+r}function zt(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var be=class extends c{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Gt(t),...t},be.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();this.props.debug==="warnings"&&t?.length===0||this._displayShaderLog(t)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let t=Je(this.source),s=`${this.stage} ${t}`,n=Ke(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource();o&&(n+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);let i=document.createElement("Button");i.innerHTML=` | ||
<h1>Shader Compilation Error in ${s}</h1><br /><br /> | ||
<code style="user-select:text;"><pre> | ||
${o} | ||
</pre></code>`,i.style.top="10px",i.style.left="10px",i.style.position="absolute",i.style.zIndex="9999",i.style.width="100%",i.style.textAlign="left",document.body.appendChild(i),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),i.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},F=wt;a(F,"defaultProps",{...u.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function Ge(r){return Jt(r.source)||r.id||_(`unnamed ${r.stage}-shader`)}function Jt(r,t="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:t}var xt=class extends u{get[Symbol.toStringTag](){return"Sampler"}constructor(t,e){super(t,e,xt.defaultProps)}},H=xt;a(H,"defaultProps",{...u.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var Tt=class extends u{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(t,e={}){super(t,e,Tt.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(t){let e=!t;if(t){let[n,o]=Array.isArray(t)?t:[t.width,t.height];e=e||o!==this.height||n!==this.width,this.width=n,this.height=o}e&&(f.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(e=>{if(typeof e=="string"){let n=this.createColorTexture(e);return this.attachResource(n),n.view}return e instanceof h?e.view:e});let t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){let e=this.createDepthStencilTexture(t);this.attachResource(e),this.depthStencilAttachment=e.view}else t instanceof h?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t){return this.device.createTexture({id:"color-attachment",usage:h.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}createDepthStencilTexture(t){return this.device.createTexture({id:"depth-stencil-attachment",usage:h.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,e){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let o=this.device._createTexture({...this.colorAttachments[n].texture.props,width:t,height:e});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=o.view,this.attachResource(o.view)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.texture.props,width:t,height:e});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}}},z=Tt;a(z,"defaultProps",{...u.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var St=class extends u{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(t,e){super(t,e,St.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(t){throw new Error("Use uniform blocks")}},G=St;a(G,"defaultProps",{...u.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var vt=class extends u{get[Symbol.toStringTag](){return"RenderPass"}constructor(t,e){super(t,e,vt.defaultProps)}},k=vt;a(k,"defaultProps",{...u.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Et=class extends u{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(t,e){super(t,e,Et.defaultProps),this.shaderLayout=e.shaderLayout}},V=Et;a(V,"defaultProps",{...u.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var At=class extends u{get[Symbol.toStringTag](){return"ComputePass"}constructor(t,e){super(t,e,At.defaultProps)}},W=At;a(W,"defaultProps",{...u.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var _t=class extends u{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(t,e){super(t,e,_t.defaultProps)}},O=_t;a(O,"defaultProps",{...u.defaultProps,measureExecutionTime:void 0});var Lt=class extends u{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(t,e){super(t,e,Lt.defaultProps)}},j=Lt;a(j,"defaultProps",{...u.defaultProps});function ct(r){let[t,e]=Ve[r],n=t==="i32"||t==="u32",o=t!=="u32",s=We[t]*e,i=ke(t,e);return{dataType:t,components:e,defaultVertexFormat:i,byteLength:s,integer:n,signed:o}}function ke(r,t){let e;switch(r){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return t===1?e:`${e}x${t}`}var Ve={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},We={f32:4,f16:2,i32:4,u32:4};function Y(r){let t;r.endsWith("-webgl")&&(r.replace("-webgl",""),t=!0);let[e,n]=r.split("x"),o=e,s=n?parseInt(n):1,i=ot(o),c={type:o,components:s,byteLength:i.byteLength*s,integer:i.integer,signed:i.signed,normalized:i.normalized};return t&&(c.webglOnly=!0),c}function Ct(r,t){let e={};for(let n of r.attributes){let o=Oe(r,t,n.name);o&&(e[n.name]=o)}return e}function te(r,t,e=16){let n=Ct(r,t),o=new Array(e).fill(null);for(let s of Object.values(n))o[s.location]=s;return o}function Oe(r,t,e){let n=je(r,e),o=Ye(t,e);if(!n)return null;let s=ct(n.type),i=o?.vertexFormat||s.defaultVertexFormat,c=Y(i);return{attributeName:o?.attributeName||n.name,bufferName:o?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:i,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:s.integer,stepMode:o?.stepMode||n.stepMode||"vertex",byteOffset:o?.byteOffset||0,byteStride:o?.byteStride||0}}function je(r,t){let e=r.attributes.find(n=>n.name===t);return e||f.warn(`shader layout attribute "${t}" not present in shader`),e||null}function Ye(r,t){Xe(r);let e=Ze(r,t);return e||(e=qe(r,t),e)?e:(f.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function Xe(r){for(let t of r)(t.attributes&&t.format||!t.attributes&&!t.format)&&f.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Ze(r,t){for(let e of r)if(e.format&&e.name===t)return{attributeName:e.name,bufferName:t,stepMode:e.stepMode,vertexFormat:e.format,byteOffset:0,byteStride:e.byteStride||0};return null}function qe(r,t){for(let e of r){let n=e.byteStride;if(typeof e.byteStride!="number")for(let s of e.attributes||[]){let i=Y(s.format);n+=i.byteLength}let o=e.attributes?.find(s=>s.attribute===t);if(o)return{attributeName:o.attribute,bufferName:e.name,stepMode:e.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:n}}return null}var Pt=class extends u{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,e){super(t,e,Pt.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null);let{shaderLayout:n,bufferLayout:o}=e.renderPipeline||{};if(!n||!o)throw new Error("VertexArray");this.attributeInfos=te(n,o,this.maxVertexAttributes)}setConstantWebGL(t,e){throw new Error("constant attributes not supported")}},X=Pt;a(X,"defaultProps",{...u.defaultProps,renderPipeline:null});var Bt=class extends u{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,e){super(t,e,Bt.defaultProps)}},Z=Bt;a(Z,"defaultProps",{...u.defaultProps,layout:void 0,buffers:{}});var Mt=class extends u{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,e){super(t,e,Mt.defaultProps)}},q=Mt;a(q,"defaultProps",{...u.defaultProps,type:void 0,count:void 0});var Ke={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function ft(r){return Ke[r]}function ee(r,t){switch(t){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}var lt;function K(r){return(!lt||lt.byteLength<r)&&(lt=new ArrayBuffer(r)),lt}function re(r,t){let e=K(r.BYTES_PER_ELEMENT*t);return new r(e,0,t)}function Qe(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function L(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Qe(r)}var ne=1024,C=class{layout={};byteLength;constructor(t){let e=0;for(let[o,s]of Object.entries(t)){let i=ft(s),{type:c,components:l}=i;e=ee(e,l);let g=e;e+=l,this.layout[o]={type:c,size:l,offset:g}}e+=(4-e%4)%4;let n=e*4;this.byteLength=Math.max(n,ne)}getData(t){let e=Math.max(this.byteLength,ne),n=K(e),o={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)};for(let[s,i]of Object.entries(t)){let c=this.layout[s];if(!c){f.warn(`Supplied uniform value ${s} not present in uniform block layout`)();continue}let{type:l,size:g,offset:p}=c,It=o[l];if(g===1){if(typeof i!="number"&&typeof i!="boolean"){f.warn(`Supplied value for single component uniform ${s} is not a number: ${i}`)();continue}It[p]=Number(i)}else{if(!L(i)){f.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${i}`)();continue}It.set(i,p)}}return new Uint8Array(n)}has(t){return Boolean(this.layout[t])}get(t){return this.layout[t]}};function oe(r,t,e=16){if(r!==t)return!1;let n=r,o=t;if(!L(n))return!1;if(L(o)&&n.length===o.length){for(let s=0;s<n.length;++s)if(o[s]!==n[s])return!1}return!0}function se(r){return L(r)?r.slice():r}var P=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(t){if(this.name=t?.name||"unnamed",t?.name&&t?.shaderLayout){let e=t?.shaderLayout.bindings?.find(o=>o.type==="uniform"&&o.name===t?.name);if(!e)throw new Error(t?.name);let n=e;for(let o of n.uniforms||[])this.bindingLayout[o.name]=o}}setUniforms(t){for(let[e,n]of Object.entries(t))this._setUniform(e,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${e}=${n}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,e){oe(this.uniforms[t],e)||(this.uniforms[t]=se(e),this.modifiedUniforms[t]=!0,this.modified=!0)}};var mt=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(t){for(let[e,n]of Object.entries(t)){let o=e,s=new C(n.uniformTypes||{});this.uniformBufferLayouts.set(o,s);let i=new P({name:e});i.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(o,i)}}destroy(){for(let t of this.uniformBuffers.values())t.destroy()}setUniforms(t){for(let[e,n]of Object.entries(t))this.uniformBlocks.get(e)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(t){return this.uniformBufferLayouts.get(t)?.byteLength||0}getUniformBufferData(t){let e=this.uniformBlocks.get(t)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(t)?.getData(e)}createUniformBuffer(t,e,n){n&&this.setUniforms(n);let o=this.getUniformBufferByteLength(e),s=t.createBuffer({usage:m.UNIFORM|m.COPY_DST,byteLength:o}),i=this.getUniformBufferData(e);return s.write(i),s}getManagedUniformBuffer(t,e){if(!this.uniformBuffers.get(e)){let n=this.getUniformBufferByteLength(e),o=t.createBuffer({usage:m.UNIFORM|m.COPY_DST,byteLength:n});this.uniformBuffers.set(e,o)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let t=!1;for(let e of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(e);t||=n}return t&&f.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(t){let e=this.uniformBlocks.get(t),n=this.uniformBuffers.get(t),o=!1;if(n&&e?.needsRedraw){o||=e.needsRedraw;let s=this.getUniformBufferData(t);this.uniformBuffers.get(t)?.write(s);let c=this.uniformBlocks.get(t)?.getAllUniforms();f.log(4,`Writing to uniform buffer ${String(t)}`,s,c)()}return o}};function Rt(r){let t=ArrayBuffer.isView(r)?r.constructor:r;switch(t){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(t.constructor.name)}}function ie(r){switch(r){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(r)}}function ae(r,t,e){if(!t||t>4)throw new Error(`size ${t}`);let n=t,o=Rt(r);if(o==="uint8"||o==="sint8"){if(n===1||n===3)throw new Error(`size: ${t}`);return e&&(o=o.replace("int","norm")),`${o}x${n}`}if(o==="uint16"||o==="sint16"){if(n===1||n===3)throw new Error(`size: ${t}`);return e&&(o=o.replace("int","norm")),`${o}x${n}`}return n===1?o:`${o}x${n}`}var Je=r=>`${r}`;return de(tr);})(); | ||
${n} | ||
</pre></code>`,i.style.top="10px",i.style.left="10px",i.style.position="absolute",i.style.zIndex="9999",i.style.width="100%",i.style.textAlign="left",document.body.appendChild(i),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),i.onclick=()=>{let f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}},$=be;a($,"defaultProps",{...c.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function Gt(r){return Je(r.source)||r.id||v(`unnamed ${r.stage}-shader`)}function Je(r,e="unnamed"){let s=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return s?s[1]:e}var xe=class extends c{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,xe.defaultProps)}},F=xe;a(F,"defaultProps",{...c.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var we=class extends c{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,we.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){let[s,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||s!==this.width,this.width=s,this.height=n}t&&(l.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(t=>{if(typeof t=="string"){let s=this.createColorTexture(t);return this.attachResource(s),s.view}return t instanceof h?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof h?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let s=0;s<this.colorAttachments.length;++s)if(this.colorAttachments[s]){let n=this.device._createTexture({...this.colorAttachments[s].texture.props,width:e,height:t});this.destroyAttachedResource(this.colorAttachments[s]),this.colorAttachments[s]=n.view,this.attachResource(n.view)}if(this.depthStencilAttachment){let s=this.device._createTexture({...this.depthStencilAttachment.texture.props,width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=s.view,this.attachResource(s)}}},N=we;a(N,"defaultProps",{...c.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var Te=class extends c{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,Te.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},U=Te;a(U,"defaultProps",{...c.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var Se=class extends c{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t,Se.defaultProps)}},H=Se;a(H,"defaultProps",{...c.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ae=class extends c{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,Ae.defaultProps),this.shaderLayout=t.shaderLayout}},k=Ae;a(k,"defaultProps",{...c.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var ve=class extends c{get[Symbol.toStringTag](){return"ComputePass"}constructor(e,t){super(e,t,ve.defaultProps)}},z=ve;a(z,"defaultProps",{...c.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Ee=class extends c{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Ee.defaultProps)}},G=Ee;a(G,"defaultProps",{...c.defaultProps,measureExecutionTime:void 0});var Pe=class extends c{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Pe.defaultProps)}},V=Pe;a(V,"defaultProps",{...c.defaultProps});function ae(r){let[e,t]=Wt[r],s=e==="i32"||e==="u32",n=e!=="u32",o=Ot[e]*t,i=Vt(e,t);return{dataType:e,components:t,defaultVertexFormat:i,byteLength:o,integer:s,signed:n}}function Vt(r,e){let t;switch(r){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?t:`${t}x${e}`}var Wt={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Ot={f32:4,f16:2,i32:4,u32:4};function W(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,s]=r.split("x"),n=t,o=s?parseInt(s):1,i=ee(n),u={type:n,components:o,byteLength:i.byteLength*o,integer:i.integer,signed:i.signed,normalized:i.normalized};return e&&(u.webglOnly=!0),u}function _e(r,e){let t={};for(let s of r.attributes){let n=jt(r,e,s.name);n&&(t[s.name]=n)}return t}function et(r,e,t=16){let s=_e(r,e),n=new Array(t).fill(null);for(let o of Object.values(s))n[o.location]=o;return n}function jt(r,e,t){let s=Yt(r,t),n=Xt(e,t);if(!s)return null;let o=ae(s.type),i=n?.vertexFormat||o.defaultVertexFormat,u=W(i);return{attributeName:n?.attributeName||s.name,bufferName:n?.bufferName||s.name,location:s.location,shaderType:s.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:i,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:o.integer,stepMode:n?.stepMode||s.stepMode||"vertex",byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function Yt(r,e){let t=r.attributes.find(s=>s.name===e);return t||l.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Xt(r,e){Zt(r);let t=qt(r,e);return t||(t=Kt(r,e),t)?t:(l.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Zt(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&l.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function qt(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Kt(r,e){for(let t of r){let s=t.byteStride;if(typeof t.byteStride!="number")for(let o of t.attributes||[]){let i=W(o.format);s+=i.byteLength}let n=t.attributes?.find(o=>o.attribute===e);if(n)return{attributeName:n.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:s}}return null}var Le=class extends c{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Le.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null);let{shaderLayout:s,bufferLayout:n}=t.renderPipeline||{};if(!s||!n)throw new Error("VertexArray");this.attributeInfos=et(s,n,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}},O=Le;a(O,"defaultProps",{...c.defaultProps,renderPipeline:null});var Ce=class extends c{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Ce.defaultProps)}},j=Ce;a(j,"defaultProps",{...c.defaultProps,layout:void 0,buffers:{}});var Be=class extends c{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Be.defaultProps)}},Y=Be;a(Y,"defaultProps",{...c.defaultProps,type:void 0,count:void 0});var Qt={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function ce(r){return Qt[r]}function tt(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}var ue;function Me(r){return(!ue||ue.byteLength<r)&&(ue=new ArrayBuffer(r)),ue}function rt(r,e){let t=Me(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Jt(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function E(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Jt(r)}var st=1024,P=class{layout={};byteLength;constructor(e){let t=0;for(let[n,o]of Object.entries(e)){let i=ce(o),{type:u,components:f}=i;t=tt(t,f);let m=t;t+=f,this.layout[n]={type:u,size:f,offset:m}}t+=(4-t%4)%4;let s=t*4;this.byteLength=Math.max(s,st)}getData(e){let t=Math.max(this.byteLength,st),s=Me(t),n={i32:new Int32Array(s),u32:new Uint32Array(s),f32:new Float32Array(s),f16:new Uint16Array(s)};for(let[o,i]of Object.entries(e)){let u=this.layout[o];if(!u){l.warn(`Supplied uniform value ${o} not present in uniform block layout`)();continue}let{type:f,size:m,offset:g}=u,Ie=n[f];if(m===1){if(typeof i!="number"&&typeof i!="boolean"){l.warn(`Supplied value for single component uniform ${o} is not a number: ${i}`)();continue}Ie[g]=Number(i)}else{if(!E(i)){l.warn(`Supplied value for multi component / array uniform ${o} is not a numeric array: ${i}`)();continue}Ie.set(i,g)}}return new Uint8Array(s)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function nt(r,e,t=16){if(r!==e)return!1;let s=r,n=e;if(!E(s))return!1;if(E(n)&&s.length===n.length){for(let o=0;o<s.length;++o)if(n[o]!==s[o])return!1}return!0}function ot(r){return E(r)?r.slice():r}var _=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(n=>n.type==="uniform"&&n.name===e?.name);if(!t)throw new Error(e?.name);let s=t;for(let n of s.uniforms||[])this.bindingLayout[n.name]=n}}setUniforms(e){for(let[t,s]of Object.entries(e))this._setUniform(t,s),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${s}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){nt(this.uniforms[e],t)||(this.uniforms[e]=ot(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var fe=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,s]of Object.entries(e)){let n=t,o=new P(s.uniformTypes||{});this.uniformBufferLayouts.set(n,o);let i=new _({name:t});i.setUniforms(s.defaultUniforms||{}),this.uniformBlocks.set(n,i)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,s]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(t)}createUniformBuffer(e,t,s){s&&this.setUniforms(s);let n=this.getUniformBufferByteLength(t),o=e.createBuffer({usage:d.UNIFORM|d.COPY_DST,byteLength:n}),i=this.getUniformBufferData(t);return o.write(i),o}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let s=this.getUniformBufferByteLength(t),n=e.createBuffer({usage:d.UNIFORM|d.COPY_DST,byteLength:s});this.uniformBuffers.set(t,n)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let s=this.updateUniformBuffer(t);e||=s}return e&&l.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),s=this.uniformBuffers.get(e),n=!1;if(s&&t?.needsRedraw){n||=t.needsRedraw;let o=this.getUniformBufferData(e);this.uniformBuffers.get(e)?.write(o);let u=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,o,u)()}return n}};function Re(r){let e=ArrayBuffer.isView(r)?r.constructor:r;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function it(r){switch(r){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(r)}}function at(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let s=e,n=Re(r);if(n==="uint8"||n==="sint8"){if(s===1||s===3)throw new Error(`size: ${e}`);return t&&(n=n.replace("int","norm")),`${n}x${s}`}if(n==="uint16"||n==="sint16"){if(s===1||s===3)throw new Error(`size: ${e}`);return t&&(n=n.replace("int","norm")),`${n}x${s}`}return s===1?n:`${n}x${s}`}return mt(er);})(); | ||
return __exports__; | ||
}); |
import { TextureFormat } from "./texture-formats.js"; | ||
import { VertexType } from "./vertex-formats.js"; | ||
export type DecodedTextureFormat = { | ||
format: 'r' | 'rg' | 'rgb' | 'rgba'; | ||
/** String describing which channels this texture has */ | ||
channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra'; | ||
/** Number of components (corresponds to channels string) */ | ||
components: 1 | 2 | 3 | 4; | ||
/** What is the data type of each component */ | ||
dataType?: VertexType; | ||
srgb: boolean; | ||
webgl: boolean; | ||
unsized: boolean; | ||
byteLength: number; | ||
/** If this is a packed data type */ | ||
packed?: boolean; | ||
/** Number of bytes per pixel */ | ||
bytesPerPixel?: number; | ||
/** Number of bits per channel (may be unreliable for packed formats) */ | ||
bitsPerChannel: number; | ||
/** Depth stencil formats */ | ||
a?: 'depth' | 'stencil' | 'depth-stencil'; | ||
/** SRGB texture format? */ | ||
srgb?: boolean; | ||
/** WebGL specific texture format? */ | ||
webgl?: boolean; | ||
/** Is this an integer or floating point format? */ | ||
integer: boolean; | ||
/** Is this a signed or unsigned format? */ | ||
signed: boolean; | ||
/** Is this a normalized integer format? */ | ||
normalized: boolean; | ||
/** Is this a compressed texture format */ | ||
compressed?: boolean; | ||
/** Block size for ASTC formats (texture must be a multiple) */ | ||
blockWidth?: number; | ||
/** Block size for ASTC formats (texture must be a multiple) */ | ||
blockHeight?: number; | ||
}; | ||
@@ -15,0 +35,0 @@ /** |
@@ -9,3 +9,3 @@ // luma.gl | ||
]; | ||
const REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/; | ||
const REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
/** | ||
@@ -23,15 +23,24 @@ * Returns true if a texture format is GPU compressed | ||
if (matches) { | ||
const [, format, length, type, srgb, suffix] = matches; | ||
const [, channels, length, type, srgb, suffix] = matches; | ||
if (format) { | ||
const dataType = `${type}${length}`; | ||
const decodedType = decodeVertexType(dataType); | ||
return { | ||
format: format, | ||
components: format.length, | ||
// dataType - overwritten by decodedType | ||
srgb: srgb === '-srgb', | ||
unsized: suffix === '-unsized', | ||
webgl: suffix === '-webgl', | ||
...decodedType | ||
const info = { | ||
channels: channels, | ||
components: channels.length, | ||
bitsPerChannel: decodedType.byteLength * 8, | ||
bytesPerPixel: decodedType.byteLength * channels.length, | ||
dataType: decodedType.dataType, | ||
integer: decodedType.integer, | ||
signed: decodedType.signed, | ||
normalized: decodedType.normalized | ||
}; | ||
if (suffix === '-webgl') { | ||
info.webgl = true; | ||
} | ||
// dataType - overwritten by decodedType | ||
if (srgb === '-srgb') { | ||
info.srgb = true; | ||
} | ||
return info; | ||
} | ||
@@ -44,22 +53,35 @@ } | ||
// Packed 16 bit formats | ||
'rgba4unorm-webgl': { format: 'rgba', bpp: 2 }, | ||
'rgb565unorm-webgl': { format: 'rgb', bpp: 2 }, | ||
'rgb5a1unorm-webgl': { format: 'rgba', bbp: 2 }, | ||
'rgba4unorm-webgl': { channels: 'rgba', bytesPerPixel: 2, packed: true }, | ||
'rgb565unorm-webgl': { channels: 'rgb', bytesPerPixel: 2, packed: true }, | ||
'rgb5a1unorm-webgl': { channels: 'rgba', bytesPerPixel: 2, packed: true }, | ||
// Packed 32 bit formats | ||
rgb9e5ufloat: { format: 'rgb', bbp: 4 }, | ||
rg11b10ufloat: { format: 'rgb', bbp: 4 }, | ||
rgb10a2unorm: { format: 'rgba', bbp: 4 }, | ||
'rgb10a2uint-webgl': { format: 'rgba', bbp: 4 }, | ||
rgb9e5ufloat: { channels: 'rgb', bytesPerPixel: 4, packed: true }, | ||
rg11b10ufloat: { channels: 'rgb', bytesPerPixel: 4, packed: true }, | ||
rgb10a2unorm: { channels: 'rgba', bytesPerPixel: 4, packed: true }, | ||
'rgb10a2uint-webgl': { channels: 'rgba', bytesPerPixel: 4, packed: true }, | ||
// Depth/stencil | ||
stencil8: { components: 1, bpp: 1, a: 'stencil' }, | ||
depth16unorm: { components: 1, bpp: 2, a: 'depth' }, | ||
depth24plus: { components: 1, bpp: 3, a: 'depth' }, | ||
depth32float: { components: 1, bpp: 4, a: 'depth' }, | ||
'depth24plus-stencil8': { components: 2, bpp: 4, a: 'depth-stencil' }, | ||
// "depth24unorm-stencil8" feature | ||
'depth24unorm-stencil8': { components: 2, bpp: 4, a: 'depth-stencil' }, | ||
stencil8: { components: 1, bytesPerPixel: 1, a: 'stencil', dataType: 'uint8' }, | ||
depth16unorm: { components: 1, bytesPerPixel: 2, a: 'depth', dataType: 'uint16' }, | ||
depth24plus: { components: 1, bytesPerPixel: 3, a: 'depth', dataType: 'uint32' }, | ||
depth32float: { components: 1, bytesPerPixel: 4, a: 'depth', dataType: 'float32' }, | ||
'depth24plus-stencil8': { components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true }, | ||
// "depth32float-stencil8" feature | ||
'depth32float-stencil8': { components: 2, bpp: 4, a: 'depth-stencil' } | ||
'depth32float-stencil8': { components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true } | ||
}; | ||
function decodeNonStandardFormat(format) { | ||
if (isTextureFormatCompressed(format)) { | ||
const info = { | ||
channels: 'rgb', | ||
components: 3, | ||
bytesPerPixel: 1, | ||
srgb: false, | ||
compressed: true | ||
}; | ||
const blockSize = getCompressedTextureBlockSize(format); | ||
if (blockSize) { | ||
info.blockWidth = blockSize.blockWidth; | ||
info.blockHeight = blockSize.blockHeight; | ||
} | ||
return info; | ||
} | ||
const data = EXCEPTIONS[format]; | ||
@@ -69,10 +91,24 @@ if (!data) { | ||
} | ||
return { | ||
format: data.format || '', | ||
components: data.components || data.format?.length || 1, | ||
byteLength: data.bpp || 1, | ||
srgb: false, | ||
unsized: false | ||
const info = { | ||
...data, | ||
channels: data.channels || '', | ||
components: data.components || data.channels?.length || 1, | ||
bytesPerPixel: data.bytesPerPixel || 1, | ||
srgb: false | ||
}; | ||
if (data.packed) { | ||
info.packed = data.packed; | ||
} | ||
return info; | ||
} | ||
/** Parses ASTC block widths from format string */ | ||
function getCompressedTextureBlockSize(format) { | ||
const REGEX = /.*-(\d+)x(\d+)-.*/; | ||
const matches = REGEX.exec(format); | ||
if (matches) { | ||
const [, blockWidth, blockHeight] = matches; | ||
return { blockWidth: Number(blockWidth), blockHeight: Number(blockHeight) }; | ||
} | ||
return null; | ||
} | ||
/* | ||
@@ -79,0 +115,0 @@ 'r8unorm': {s: "float"}, // ✓ ✓ ✓ }, |
/** Texture formats */ | ||
export type TextureFormat = ColorTextureFormat | DepthStencilTextureFormat; | ||
/** Depth and stencil texture formats */ | ||
export type DepthStencilTextureFormat = 'stencil8' | 'depth16unorm' | 'depth24plus' | 'depth24plus-stencil8' | 'depth32float' | 'depth24unorm-stencil8' | 'depth32float-stencil8'; | ||
export type DepthStencilTextureFormat = 'stencil8' | 'depth16unorm' | 'depth24plus' | 'depth24plus-stencil8' | 'depth32float' | 'depth32float-stencil8'; | ||
/** Texture formats for color attachments */ | ||
export type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat | UnsizedColorTextureFormat; | ||
export type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat; | ||
export type WebGPUColorTextureFormat = 'r8unorm' | 'r8snorm' | 'r8uint' | 'r8sint' | 'r16uint' | 'r16sint' | 'r16float' | 'rg8unorm' | 'rg8snorm' | 'rg8uint' | 'rg8sint' | 'r32uint' | 'r32sint' | 'r32float' | 'rg16uint' | 'rg16sint' | 'rg16float' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgb9e5ufloat' | 'rgb10a2unorm' | 'rg11b10ufloat' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bc1-rgba-unorm' | 'bc1-rgba-unorm-srgb' | 'bc2-rgba-unorm' | 'bc2-rgba-unorm-srgb' | 'bc3-rgba-unorm' | 'bc3-rgba-unorm-srgb' | 'bc4-r-unorm' | 'bc4-r-snorm' | 'bc5-rg-unorm' | 'bc5-rg-snorm' | 'bc6h-rgb-ufloat' | 'bc6h-rgb-float' | 'bc7-rgba-unorm' | 'bc7-rgba-unorm-srgb' | 'etc2-rgb8unorm' | 'etc2-rgb8unorm-srgb' | 'etc2-rgb8a1unorm' | 'etc2-rgb8a1unorm-srgb' | 'etc2-rgba8unorm' | 'etc2-rgba8unorm-srgb' | 'eac-r11unorm' | 'eac-r11snorm' | 'eac-rg11unorm' | 'eac-rg11snorm' | 'astc-4x4-unorm' | 'astc-4x4-unorm-srgb' | 'astc-5x4-unorm' | 'astc-5x4-unorm-srgb' | 'astc-5x5-unorm' | 'astc-5x5-unorm-srgb' | 'astc-6x5-unorm' | 'astc-6x5-unorm-srgb' | 'astc-6x6-unorm' | 'astc-6x6-unorm-srgb' | 'astc-8x5-unorm' | 'astc-8x5-unorm-srgb' | 'astc-8x6-unorm' | 'astc-8x6-unorm-srgb' | 'astc-8x8-unorm' | 'astc-8x8-unorm-srgb' | 'astc-10x5-unorm' | 'astc-10x5-unorm-srgb' | 'astc-10x6-unorm' | 'astc-10x6-unorm-srgb' | 'astc-10x8-unorm' | 'astc-10x8-unorm-srgb' | 'astc-10x10-unorm' | 'astc-10x10-unorm-srgb' | 'astc-12x10-unorm' | 'astc-12x10-unorm-srgb' | 'astc-12x12-unorm' | 'astc-12x12-unorm-srgb'; | ||
/** Unsized texture formats (the only formats supported by WebGL1) */ | ||
export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized'; | ||
/** Sized formats in WebGL 2 that are not (yet?) supported by WebGPU */ | ||
export type WebGL2ColorTextureFormat = 'r16unorm-webgl' | 'r16snorm-webgl' | 'rgba4unorm-webgl' | 'rgb565unorm-webgl' | 'rgb5a1unorm-webgl' | 'rgb8unorm-webgl' | 'rgb8snorm-webgl' | 'rg16unorm-webgl' | 'rg16snorm-webgl' | 'rgb10a2uint-webgl' | 'rgb16unorm-webgl' | 'rgb16snorm-webgl' | 'rgba16unorm-webgl' | 'rgba16snorm-webgl' | 'rgb32float-webgl' | 'bc1-rgb-unorm-webgl' | 'bc1-rgb-unorm-srgb-webgl' | 'pvrtc-rgb4unorm-webgl' | 'pvrtc-rgba4unorm-webgl' | 'pvrtc-rbg2unorm-webgl' | 'pvrtc-rgba2unorm-webgl' | 'etc1-rbg-unorm-webgl' | 'atc-rgb-unorm-webgl' | 'atc-rgba-unorm-webgl' | 'atc-rgbai-unorm-webgl'; | ||
//# sourceMappingURL=texture-formats.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export { VERSION } from "./init.js"; | ||
export { luma } from "./adapter/luma.js"; | ||
export { Adapter } from "./adapter/adapter.js"; | ||
export type { DeviceProps, DeviceInfo, DeviceFeature } from "./adapter/device.js"; | ||
@@ -65,9 +65,7 @@ export { Device, DeviceFeatures, DeviceLimits } from "./adapter/device.js"; | ||
export type { StatsManager } from "./utils/stats-manager.js"; | ||
/** GLSL syntax highlighting: glsl`...` Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal */ | ||
export declare const glsl: (x: TemplateStringsArray) => string; | ||
export type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from "./adapter/resources/command-encoder.js"; | ||
export type { AttributeInfo } from "./adapter-utils/get-attribute-from-layouts.js"; | ||
export { getAttributeInfosFromLayouts } from "./adapter-utils/get-attribute-from-layouts.js"; | ||
export { getScratchArrayBuffer, getScratchArray } from "./utils/array-utils-flat.js"; | ||
export { getScratchArray } from "./utils/array-utils-flat.js"; | ||
export { log } from "./utils/log.js"; | ||
//# sourceMappingURL=index.d.ts.map |
// luma.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
export { VERSION } from "./init.js"; | ||
// MAIN API ACCESS POINT | ||
export { luma } from "./adapter/luma.js"; | ||
// ADAPTER (DEVICE AND GPU RESOURCE INTERFACES) | ||
export { Adapter } from "./adapter/adapter.js"; | ||
export { Device, DeviceFeatures, DeviceLimits } from "./adapter/device.js"; | ||
@@ -38,7 +39,5 @@ export { CanvasContext } from "./adapter/canvas-context.js"; | ||
export { getVertexFormatFromAttribute } from "./gpu-type-utils/vertex-format-from-attribute.js"; | ||
/** GLSL syntax highlighting: glsl`...` Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal */ | ||
export const glsl = (x) => `${x}`; | ||
export { getAttributeInfosFromLayouts } from "./adapter-utils/get-attribute-from-layouts.js"; | ||
export { getScratchArrayBuffer, getScratchArray } from "./utils/array-utils-flat.js"; | ||
export { getScratchArray } from "./utils/array-utils-flat.js"; | ||
// INTERNAL UTILS - for use in other luma.gl modules only | ||
export { log } from "./utils/log.js"; |
{ | ||
"name": "@luma.gl/core", | ||
"version": "9.1.0-alpha.2", | ||
"version": "9.1.0-alpha.9", | ||
"description": "The luma.gl core Device API", | ||
@@ -49,3 +49,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "cb258afdefd2d5712d2decca35c746dd9d77a03e" | ||
"gitHead": "ff05b21269181dbb782ba7c8c1546900288ee6a1" | ||
} |
@@ -5,3 +5,2 @@ // luma.gl | ||
import {VERSION} from '../init'; | ||
import {StatsManager, lumaStats} from '../utils/stats-manager'; | ||
@@ -150,3 +149,2 @@ import {log} from '../utils/log'; | ||
| 'shader-f16' | ||
| 'depth24unorm-stencil8' | ||
| 'depth32float-stencil8' | ||
@@ -232,4 +230,7 @@ | 'rg11b10ufloat-renderable' // Is the rg11b10ufloat texture format renderable? | ||
break?: string[]; | ||
/** WebGL: Initialize the SpectorJS WebGL debugger */ | ||
spector?: boolean; | ||
debugWithSpectorJS?: boolean; | ||
/** SpectorJS URL. Override if CDN is down or different SpectorJS version is desired */ | ||
spectorUrl?: string; | ||
@@ -248,2 +249,13 @@ // EXPERIMENTAL SETTINGS | ||
/** | ||
* Create and attach devices for a specific backend. Currently static methods on each device | ||
*/ | ||
export interface DeviceFactory { | ||
// new (props: DeviceProps): Device; Constructor isn't used | ||
type: string; | ||
isSupported(): boolean; | ||
create(props: DeviceProps): Promise<Device>; | ||
attach?(handle: unknown): Device; | ||
} | ||
/** | ||
* WebGPU Device/WebGL context abstraction | ||
@@ -275,5 +287,8 @@ */ | ||
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance) | ||
spector: Boolean(log.get('spector')), // Initialize the SpectorJS WebGL debugger | ||
break: (log.get('break') as string[]) || [], | ||
// WebGL specific debugging | ||
debugWithSpectorJS: undefined!, | ||
spectorUrl: undefined!, | ||
// TODO - Change these after confirming things work as expected | ||
@@ -291,4 +306,2 @@ initalizeFeatures: true, | ||
static VERSION = VERSION; | ||
constructor(props: DeviceProps) { | ||
@@ -295,0 +308,0 @@ this.props = {...Device.defaultProps, ...props}; |
@@ -8,2 +8,3 @@ // luma.gl | ||
import {Device} from './device'; | ||
import {Adapter} from './adapter'; | ||
import {StatsManager} from '../utils/stats-manager'; | ||
@@ -13,4 +14,12 @@ import {lumaStats} from '../utils/stats-manager'; | ||
const deviceMap = new Map<string, typeof Device>(); | ||
declare global { | ||
// eslint-disable-next-line no-var | ||
var luma: Luma; | ||
} | ||
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering'; | ||
const ERROR_MESSAGE = | ||
'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'; | ||
/** Properties for creating a new device */ | ||
@@ -20,3 +29,3 @@ export type CreateDeviceProps = DeviceProps & { | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
devices?: any[]; | ||
adapters?: Adapter[]; | ||
}; | ||
@@ -27,4 +36,5 @@ | ||
/** Externally created WebGL context or WebGPU device */ | ||
handle: WebGL2RenderingContext; // | GPUDevice; | ||
devices?: any[]; | ||
handle: unknown; // WebGL2RenderingContext | GPUDevice | null; | ||
/** List of adapters. Will also search any pre-registered adapterss */ | ||
adapters?: Adapter[]; | ||
}; | ||
@@ -34,53 +44,116 @@ | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL devices (controls application bundle size) | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export class luma { | ||
export class Luma { | ||
static defaultProps: Required<CreateDeviceProps> = { | ||
...Device.defaultProps, | ||
type: 'best-available', | ||
devices: undefined! | ||
adapters: undefined! | ||
}; | ||
/** Global stats for all devices */ | ||
static stats: StatsManager = lumaStats; | ||
readonly stats: StatsManager = lumaStats; | ||
/** Global log */ | ||
static log: Log = log; | ||
/** | ||
* Global log | ||
* | ||
* Assign luma.log.level in console to control logging: \ | ||
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs | ||
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`; | ||
*/ | ||
readonly log: Log = log; | ||
static registerDevices(deviceClasses: any[] /* : typeof Device */): void { | ||
for (const deviceClass of deviceClasses) { | ||
deviceMap.set(deviceClass.type, deviceClass); | ||
/** Version of luma.gl */ | ||
readonly VERSION: string = | ||
// Version detection using build plugin | ||
// @ts-expect-error no-undef | ||
typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'running from source'; | ||
spector: unknown; | ||
protected preregisteredAdapters = new Map<string, Adapter>(); | ||
constructor() { | ||
if (globalThis.luma) { | ||
if (globalThis.luma.VERSION !== this.VERSION) { | ||
log.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(); | ||
log.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)(); | ||
throw new Error(`luma.gl - multiple versions detected: see console log`); | ||
} | ||
log.error('This version of luma.gl has already been initialized')(); | ||
} | ||
log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)(); | ||
globalThis.luma = this; | ||
} | ||
static getAvailableDevices(): string[] { | ||
// @ts-expect-error | ||
return Array.from(deviceMap).map(Device => Device.type); | ||
registerAdapters(adapters: Adapter[]): void { | ||
for (const deviceClass of adapters) { | ||
this.preregisteredAdapters.set(deviceClass.type, deviceClass); | ||
} | ||
} | ||
static getSupportedDevices(): string[] { | ||
return ( | ||
Array.from(deviceMap) | ||
// @ts-expect-error | ||
.filter(Device => Device.isSupported()) | ||
// @ts-expect-error | ||
.map(Device => Device.type) | ||
); | ||
/** Get type strings for supported Devices */ | ||
getSupportedAdapters(adapters: Adapter[] = []): string[] { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
return Array.from(adapterMap) | ||
.map(([, adapter]) => adapter) | ||
.filter(adapter => adapter.isSupported?.()) | ||
.map(adapter => adapter.type); | ||
} | ||
static setDefaultDeviceProps(props: CreateDeviceProps): void { | ||
Object.assign(luma.defaultProps, props); | ||
/** Get type strings for best available Device */ | ||
getBestAvailableAdapter(adapters: Adapter[] = []): 'webgpu' | 'webgl' | null { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
if (adapterMap.get('webgpu')?.isSupported?.()) { | ||
return 'webgpu'; | ||
} | ||
if (adapterMap.get('webgl')?.isSupported?.()) { | ||
return 'webgl'; | ||
} | ||
return null; | ||
} | ||
setDefaultDeviceProps(props: CreateDeviceProps): void { | ||
Object.assign(Luma.defaultProps, props); | ||
} | ||
/** Creates a device. Asynchronously. */ | ||
async createDevice(props: CreateDeviceProps = {}): Promise<Device> { | ||
props = {...Luma.defaultProps, ...props}; | ||
// Should be handled by attach device | ||
// if (props.gl) { | ||
// props.type = 'webgl'; | ||
// } | ||
const adapterMap = this.getAdapterMap(props.adapters); | ||
let type: string = props.type || ''; | ||
if (type === 'best-available') { | ||
type = this.getBestAvailableAdapter(props.adapters) || type; | ||
} | ||
const adapters = this.getAdapterMap(props.adapters) || adapterMap; | ||
const adapter = adapters.get(type); | ||
const device = await adapter?.create?.(props); | ||
if (device) { | ||
return device; | ||
} | ||
throw new Error(ERROR_MESSAGE); | ||
} | ||
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */ | ||
static async attachDevice(props: AttachDeviceProps): Promise<Device> { | ||
const devices = getDeviceMap(props.devices) || deviceMap; | ||
async attachDevice(props: AttachDeviceProps): Promise<Device> { | ||
const adapters = this.getAdapterMap(props.adapters); | ||
// WebGL | ||
let type = ''; | ||
if (props.handle instanceof WebGL2RenderingContext) { | ||
const WebGLDevice = devices.get('webgl') as any; | ||
if (WebGLDevice) { | ||
return (await WebGLDevice.attach(props.handle)) as Device; | ||
} | ||
type = 'webgl'; | ||
} | ||
@@ -90,3 +163,3 @@ | ||
// if (props.handle instanceof GPUDevice) { | ||
// const WebGPUDevice = devices.get('webgpu') as any; | ||
// const WebGPUDevice = adapters.get('webgpu') as any; | ||
// if (WebGPUDevice) { | ||
@@ -99,99 +172,55 @@ // return (await WebGPUDevice.attach(props.handle)) as Device; | ||
if (props.handle === null) { | ||
const UnknownDevice = devices.get('unknown') as any; | ||
if (UnknownDevice) { | ||
return (await UnknownDevice.attach(null)) as Device; | ||
} | ||
type = 'unknown'; | ||
} | ||
throw new Error( | ||
'Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.' | ||
); | ||
} | ||
/** Creates a device. Asynchronously. */ | ||
static async createDevice(props: CreateDeviceProps = {}): Promise<Device> { | ||
props = {...luma.defaultProps, ...props}; | ||
if (props.gl) { | ||
props.type = 'webgl'; | ||
const adapter = adapters.get(type); | ||
const device = await adapter?.attach?.(null); | ||
if (device) { | ||
return device; | ||
} | ||
const devices = getDeviceMap(props.devices) || deviceMap; | ||
throw new Error(ERROR_MESSAGE); | ||
} | ||
let WebGPUDevice; | ||
let WebGLDevice; | ||
switch (props.type) { | ||
case 'webgpu': | ||
WebGPUDevice = devices.get('webgpu') as any; | ||
if (WebGPUDevice) { | ||
return await WebGPUDevice.create(props); | ||
} | ||
break; | ||
case 'webgl': | ||
WebGLDevice = devices.get('webgl') as any; | ||
if (WebGLDevice) { | ||
return await WebGLDevice.create(props); | ||
} | ||
break; | ||
case 'unknown': | ||
const UnknownDevice = devices.get('unknown') as any; | ||
if (UnknownDevice) { | ||
return await UnknownDevice.create(props); | ||
} | ||
break; | ||
case 'best-available': | ||
WebGPUDevice = devices.get('webgpu') as any; | ||
if (WebGPUDevice?.isSupported?.()) { | ||
return await WebGPUDevice.create(props); | ||
} | ||
WebGLDevice = devices.get('webgl') as any; | ||
if (WebGLDevice?.isSupported?.()) { | ||
return await WebGLDevice.create(props); | ||
} | ||
break; | ||
/** | ||
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility. | ||
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts. | ||
*/ | ||
enforceWebGL2(enforce: boolean = true, adapters: Adapter[] = []): void { | ||
const adapterMap = this.getAdapterMap(adapters); | ||
const webgl2Adapter = adapterMap.get('webgl'); | ||
if (!webgl2Adapter) { | ||
log.warn('enforceWebGL2: webgl adapter not found')(); | ||
} | ||
throw new Error( | ||
'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.' | ||
); | ||
(webgl2Adapter as any)?.enforceWebGL2?.(enforce); | ||
} | ||
static enforceWebGL2(enforce: boolean = true): void { | ||
const prototype = HTMLCanvasElement.prototype as any; | ||
if (!enforce && prototype.originalGetContext) { | ||
// Reset the original getContext function | ||
prototype.getContext = prototype.originalGetContext; | ||
prototype.originalGetContext = undefined; | ||
return; | ||
/** Convert a list of adapters to a map */ | ||
protected getAdapterMap(adapters: Adapter[] = []): Map<string, Adapter> { | ||
const map = new Map(this.preregisteredAdapters); | ||
for (const adapter of adapters) { | ||
map.set(adapter.type, adapter); | ||
} | ||
return map; | ||
} | ||
// Store the original getContext function | ||
prototype.originalGetContext = prototype.getContext; | ||
// DEPRECATED | ||
// Override the getContext function | ||
prototype.getContext = function (contextId: string, options?: WebGLContextAttributes) { | ||
// Attempt to force WebGL2 for all WebGL1 contexts | ||
if (contextId === 'webgl' || contextId === 'experimental-webgl') { | ||
return this.originalGetContext('webgl2', options); | ||
/** @deprecated Use registerAdapters */ | ||
registerDevices(deviceClasses: any[]): void { | ||
log.warn('luma.registerDevices() is deprecated, use luma.registerAdapters() instead'); | ||
for (const deviceClass of deviceClasses) { | ||
const adapter = deviceClass.adapter as Adapter; | ||
if (adapter) { | ||
this.preregisteredAdapters.set(adapter.type, adapter); | ||
} | ||
// For any other type, return the original context | ||
return this.originalGetContext(contextId, options); | ||
}; | ||
} | ||
} | ||
} | ||
/** Convert a list of devices to a map */ | ||
function getDeviceMap( | ||
deviceClasses?: any[] /* : typeof Device */ | ||
): Map<string, typeof Device> | null { | ||
if (!deviceClasses || deviceClasses?.length === 0) { | ||
return null; | ||
} | ||
const map = new Map<string, typeof Device>(); | ||
for (const deviceClass of deviceClasses) { | ||
// assert(deviceClass.type && deviceClass.isSupported && deviceClass.create); | ||
map.set(deviceClass.type, deviceClass); | ||
} | ||
return map; | ||
} | ||
/** | ||
* Entry point to the luma.gl GPU abstraction | ||
* Register WebGPU and/or WebGL adapters (controls application bundle size) | ||
* Run-time selection of the first available Device | ||
*/ | ||
export const luma = new Luma(); |
@@ -48,10 +48,12 @@ // luma.gl | ||
* Built-in data types that can be used to initialize textures | ||
* @note WebGL supports OffscreenCanvas but seems WebGPU does not? | ||
* @note ImageData can be used for 8 bit data via Uint8ClampedArray | ||
*/ | ||
export type ExternalImage = | ||
| ImageBitmap | ||
| ImageData | ||
| ImageBitmap | ||
| HTMLImageElement | ||
| HTMLVideoElement | ||
| HTMLCanvasElement; | ||
| VideoFrame | ||
| HTMLCanvasElement | ||
| OffscreenCanvas; | ||
@@ -188,4 +190,6 @@ export type TextureLevelSource = TextureLevelData | ExternalImage; | ||
(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 HTMLVideoElement !== 'undefined' && data instanceof HTMLVideoElement) | ||
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas) | ||
); | ||
@@ -195,7 +199,8 @@ } | ||
/** Determine size (width and height) of provided image data */ | ||
static getExternalImageSize(data: ExternalImage): {width: number; height: number} | null { | ||
static getExternalImageSize(data: ExternalImage): {width: number; height: number} { | ||
if ( | ||
(typeof ImageData !== 'undefined' && data instanceof ImageData) || | ||
(typeof ImageBitmap !== 'undefined' && data instanceof ImageBitmap) || | ||
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement) | ||
(typeof HTMLCanvasElement !== 'undefined' && data instanceof HTMLCanvasElement) || | ||
(typeof OffscreenCanvas !== 'undefined' && data instanceof OffscreenCanvas) | ||
) { | ||
@@ -210,3 +215,7 @@ return {width: data.width, height: data.height}; | ||
} | ||
return null; | ||
if (typeof VideoFrame !== 'undefined' && data instanceof VideoFrame) { | ||
// TODO: is this the right choice for width and height? | ||
return {width: data.displayWidth, height: data.displayHeight}; | ||
} | ||
throw new Error('Unknown image type'); | ||
} | ||
@@ -238,3 +247,4 @@ | ||
if (data && typeof data === 'object' && data.constructor === Object) { | ||
const untypedData = data as unknown as Record<string, number>; | ||
const textureDataArray = Object.values(data) as Texture2DData[]; | ||
const untypedData = textureDataArray[0] as any; | ||
return {width: untypedData.width, height: untypedData.height}; | ||
@@ -241,0 +251,0 @@ } |
@@ -145,2 +145,5 @@ // luma.gl | ||
export type ColorParameters = { | ||
/** Enable blending */ | ||
blend?: boolean; | ||
/** Defines the operation used to calculate the values written to the target attachment components. */ | ||
@@ -233,2 +236,3 @@ blendColorOperation?: BlendOperation; | ||
// Color and blend parameters | ||
blend: false, | ||
@@ -235,0 +239,0 @@ blendColorOperation: 'add', |
@@ -14,15 +14,36 @@ // luma.gl | ||
const REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/; | ||
const REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
export type DecodedTextureFormat = { | ||
format: 'r' | 'rg' | 'rgb' | 'rgba'; | ||
/** String describing which channels this texture has */ | ||
channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra'; | ||
/** Number of components (corresponds to channels string) */ | ||
components: 1 | 2 | 3 | 4; | ||
/** What is the data type of each component */ | ||
dataType?: VertexType; | ||
srgb: boolean; | ||
webgl: boolean; | ||
unsized: boolean; | ||
byteLength: number; | ||
/** If this is a packed data type */ | ||
packed?: boolean; | ||
/** Number of bytes per pixel */ | ||
bytesPerPixel?: number; | ||
/** Number of bits per channel (may be unreliable for packed formats) */ | ||
bitsPerChannel: number; | ||
/** Depth stencil formats */ | ||
a?: 'depth' | 'stencil' | 'depth-stencil'; | ||
/** SRGB texture format? */ | ||
srgb?: boolean; | ||
/** WebGL specific texture format? */ | ||
webgl?: boolean; | ||
/** Is this an integer or floating point format? */ | ||
integer: boolean; | ||
/** Is this a signed or unsigned format? */ | ||
signed: boolean; | ||
/** Is this a normalized integer format? */ | ||
normalized: boolean; | ||
/** Is this a compressed texture format */ | ||
compressed?: boolean; | ||
/** Block size for ASTC formats (texture must be a multiple) */ | ||
blockWidth?: number; | ||
/** Block size for ASTC formats (texture must be a multiple) */ | ||
blockHeight?: number; | ||
/** */ | ||
}; | ||
@@ -43,15 +64,24 @@ | ||
if (matches) { | ||
const [, format, length, type, srgb, suffix] = matches; | ||
const [, channels, length, type, srgb, suffix] = matches; | ||
if (format) { | ||
const dataType = `${type}${length}` as VertexType; | ||
const decodedType = decodeVertexType(dataType); | ||
return { | ||
format: format as 'r' | 'rg' | 'rgb' | 'rgba', | ||
components: format.length as 1 | 2 | 3 | 4, | ||
// dataType - overwritten by decodedType | ||
srgb: srgb === '-srgb', | ||
unsized: suffix === '-unsized', | ||
webgl: suffix === '-webgl', | ||
...decodedType | ||
const info: DecodedTextureFormat = { | ||
channels: channels as 'r' | 'rg' | 'rgb' | 'rgba', | ||
components: channels.length as 1 | 2 | 3 | 4, | ||
bitsPerChannel: decodedType.byteLength * 8, | ||
bytesPerPixel: decodedType.byteLength * channels.length, | ||
dataType: decodedType.dataType, | ||
integer: decodedType.integer, | ||
signed: decodedType.signed, | ||
normalized: decodedType.normalized | ||
}; | ||
if (suffix === '-webgl') { | ||
info.webgl = true; | ||
} | ||
// dataType - overwritten by decodedType | ||
if (srgb === '-srgb') { | ||
info.srgb = true; | ||
} | ||
return info; | ||
} | ||
@@ -65,25 +95,38 @@ } | ||
const EXCEPTIONS: Partial<Record<TextureFormat, any>> = { | ||
const EXCEPTIONS: Partial<Record<TextureFormat, Partial<DecodedTextureFormat>>> = { | ||
// Packed 16 bit formats | ||
'rgba4unorm-webgl': {format: 'rgba', bpp: 2}, | ||
'rgb565unorm-webgl': {format: 'rgb', bpp: 2}, | ||
'rgb5a1unorm-webgl': {format: 'rgba', bbp: 2}, | ||
'rgba4unorm-webgl': {channels: 'rgba', bytesPerPixel: 2, packed: true}, | ||
'rgb565unorm-webgl': {channels: 'rgb', bytesPerPixel: 2, packed: true}, | ||
'rgb5a1unorm-webgl': {channels: 'rgba', bytesPerPixel: 2, packed: true}, | ||
// Packed 32 bit formats | ||
rgb9e5ufloat: {format: 'rgb', bbp: 4}, | ||
rg11b10ufloat: {format: 'rgb', bbp: 4}, | ||
rgb10a2unorm: {format: 'rgba', bbp: 4}, | ||
'rgb10a2uint-webgl': {format: 'rgba', bbp: 4}, | ||
rgb9e5ufloat: {channels: 'rgb', bytesPerPixel: 4, packed: true}, | ||
rg11b10ufloat: {channels: 'rgb', bytesPerPixel: 4, packed: true}, | ||
rgb10a2unorm: {channels: 'rgba', bytesPerPixel: 4, packed: true}, | ||
'rgb10a2uint-webgl': {channels: 'rgba', bytesPerPixel: 4, packed: true}, | ||
// Depth/stencil | ||
stencil8: {components: 1, bpp: 1, a: 'stencil'}, | ||
depth16unorm: {components: 1, bpp: 2, a: 'depth'}, | ||
depth24plus: {components: 1, bpp: 3, a: 'depth'}, | ||
depth32float: {components: 1, bpp: 4, a: 'depth'}, | ||
'depth24plus-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'}, | ||
// "depth24unorm-stencil8" feature | ||
'depth24unorm-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'}, | ||
stencil8: {components: 1, bytesPerPixel: 1, a: 'stencil', dataType: 'uint8'}, | ||
depth16unorm: {components: 1, bytesPerPixel: 2, a: 'depth', dataType: 'uint16'}, | ||
depth24plus: {components: 1, bytesPerPixel: 3, a: 'depth', dataType: 'uint32'}, | ||
depth32float: {components: 1, bytesPerPixel: 4, a: 'depth', dataType: 'float32'}, | ||
'depth24plus-stencil8': {components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true}, | ||
// "depth32float-stencil8" feature | ||
'depth32float-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'} | ||
'depth32float-stencil8': {components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true} | ||
}; | ||
function decodeNonStandardFormat(format: TextureFormat): DecodedTextureFormat { | ||
if (isTextureFormatCompressed(format)) { | ||
const info: DecodedTextureFormat = { | ||
channels: 'rgb', | ||
components: 3, | ||
bytesPerPixel: 1, | ||
srgb: false, | ||
compressed: true | ||
} as DecodedTextureFormat; | ||
const blockSize = getCompressedTextureBlockSize(format); | ||
if (blockSize) { | ||
info.blockWidth = blockSize.blockWidth; | ||
info.blockHeight = blockSize.blockHeight; | ||
} | ||
return info; | ||
} | ||
const data = EXCEPTIONS[format]; | ||
@@ -93,11 +136,28 @@ if (!data) { | ||
} | ||
return { | ||
format: data.format || '', | ||
components: data.components || data.format?.length || 1, | ||
byteLength: data.bpp || 1, | ||
srgb: false, | ||
unsized: false | ||
const info: DecodedTextureFormat = { | ||
...data, | ||
channels: data.channels || '', | ||
components: data.components || data.channels?.length || 1, | ||
bytesPerPixel: data.bytesPerPixel || 1, | ||
srgb: false | ||
} as DecodedTextureFormat; | ||
if (data.packed) { | ||
info.packed = data.packed; | ||
} | ||
return info; | ||
} | ||
/** Parses ASTC block widths from format string */ | ||
function getCompressedTextureBlockSize( | ||
format: string | ||
): {blockWidth: number; blockHeight: number} | null { | ||
const REGEX = /.*-(\d+)x(\d+)-.*/; | ||
const matches = REGEX.exec(format); | ||
if (matches) { | ||
const [, blockWidth, blockHeight] = matches; | ||
return {blockWidth: Number(blockWidth), blockHeight: Number(blockHeight)}; | ||
} | ||
return null; | ||
} | ||
/* | ||
@@ -104,0 +164,0 @@ 'r8unorm': {s: "float"}, // ✓ ✓ ✓ }, |
@@ -15,4 +15,2 @@ // luma.gl | ||
| 'depth32float' | ||
// device.features.has('depth24unorm-stencil8') | ||
| 'depth24unorm-stencil8' | ||
// device.features.has('depth32float-stencil8') | ||
@@ -22,6 +20,3 @@ | 'depth32float-stencil8'; | ||
/** Texture formats for color attachments */ | ||
export type ColorTextureFormat = | ||
| WebGPUColorTextureFormat | ||
| WebGL2ColorTextureFormat | ||
| UnsizedColorTextureFormat; | ||
export type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat; | ||
@@ -108,2 +103,3 @@ export type WebGPUColorTextureFormat = | ||
// supported by the device/user agent and enabled in requestDevice. | ||
// Textures must be multiple of block size (encoded in format string). | ||
| 'astc-4x4-unorm' | ||
@@ -138,9 +134,2 @@ | 'astc-4x4-unorm-srgb' | ||
/** Unsized texture formats (the only formats supported by WebGL1) */ | ||
export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized'; | ||
// 'r8unorm-unsized' | | ||
// 'ra8unorm-unsized' | | ||
// 'rgb8unorm-srgb-unsized' | | ||
// 'rgba8unorm-srgb-unsized' | ||
/** Sized formats in WebGL 2 that are not (yet?) supported by WebGPU */ | ||
@@ -147,0 +136,0 @@ export type WebGL2ColorTextureFormat = |
@@ -5,4 +5,2 @@ // luma.gl | ||
export {VERSION} from './init'; | ||
// MAIN API ACCESS POINT | ||
@@ -12,2 +10,4 @@ export {luma} from './adapter/luma'; | ||
// ADAPTER (DEVICE AND GPU RESOURCE INTERFACES) | ||
export {Adapter} from './adapter/adapter'; | ||
export type {DeviceProps, DeviceInfo, DeviceFeature} from './adapter/device'; | ||
@@ -161,4 +161,2 @@ export {Device, DeviceFeatures, DeviceLimits} from './adapter/device'; | ||
export type {StatsManager} from './utils/stats-manager'; // TODO - should this be moved to probe.gl? | ||
/** GLSL syntax highlighting: glsl`...` Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal */ | ||
export const glsl = (x: TemplateStringsArray) => `${x}`; | ||
@@ -176,5 +174,5 @@ // ADAPTER UTILS - for implementing Device adapters (@luma.gl/webgl and @luma.gl/webgpu) | ||
export {getAttributeInfosFromLayouts} from './adapter-utils/get-attribute-from-layouts'; | ||
export {getScratchArrayBuffer, getScratchArray} from './utils/array-utils-flat'; | ||
export {getScratchArray} from './utils/array-utils-flat'; | ||
// INTERNAL UTILS - for use in other luma.gl modules only | ||
export {log} from './utils/log'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
860884
15573