@luma.gl/core
Advanced tools
Comparing version 9.1.0-alpha.15 to 9.1.0-alpha.16
@@ -47,4 +47,5 @@ // luma.gl | ||
} | ||
const color = message.type === 'error' ? 'red' : '#8B4000'; // dark orange | ||
return options?.html | ||
? `<div class='luma-compiler-log-error' style="color:red;"><b> ${message.type.toUpperCase()}: ${message.message}</b></div>` | ||
? `<div class='luma-compiler-log-error' style="color:${color};"><b> ${message.type.toUpperCase()}: ${message.message}</b></div>` | ||
: `${message.type.toUpperCase()}: ${message.message}`; | ||
@@ -51,0 +52,0 @@ } |
@@ -6,20 +6,20 @@ import type { Device } from "./device.js"; | ||
export type CanvasContextProps = { | ||
/** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */ | ||
/** If a canvas not supplied, one will be created and added to the DOM. If a string, a canvas with that id will be looked up in the DOM */ | ||
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; | ||
/** If new canvas is created, it will be created in the specified container, otherwise appended to body */ | ||
/** If new canvas is created, it will be created in the specified container, otherwise is appended as a child of document.body */ | ||
container?: HTMLElement | string | null; | ||
/** Width in pixels of the canvas */ | ||
/** Width in pixels of the canvas - used when creating a new canvas */ | ||
width?: number; | ||
/** Height in pixels of the canvas */ | ||
/** Height in pixels of the canvas - used when creating a new canvas */ | ||
height?: number; | ||
/** Visibility (only used if new canvas is created). */ | ||
visible?: boolean; | ||
/** Whether to apply a device pixels scale factor (`true` uses browser DPI) */ | ||
useDevicePixels?: boolean | number; | ||
/** Whether to track resizes (if not ) */ | ||
/** Whether to track window resizes */ | ||
autoResize?: boolean; | ||
/** Visibility (only used if new canvas is created). */ | ||
visible?: boolean; | ||
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */ | ||
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#alphamode */ | ||
alphaMode?: 'opaque' | 'premultiplied'; | ||
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#colorspace */ | ||
colorSpace?: 'srgb'; | ||
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */ | ||
alphaMode?: 'opaque' | 'premultiplied'; | ||
}; | ||
@@ -34,2 +34,3 @@ /** | ||
export declare abstract class CanvasContext { | ||
static defaultProps: Required<CanvasContextProps>; | ||
abstract readonly device: Device; | ||
@@ -55,11 +56,2 @@ readonly id: string; | ||
}; | ||
/** Check if the DOM is loaded */ | ||
static get isPageLoaded(): boolean; | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded: Promise<void>; | ||
constructor(props?: CanvasContextProps); | ||
@@ -66,0 +58,0 @@ /** Returns a framebuffer with properly resized current 'swap chain' textures */ |
@@ -6,15 +6,2 @@ // luma.gl | ||
import { log } from "../utils/log.js"; | ||
const isPage = isBrowser() && typeof document !== 'undefined'; | ||
const isPageLoaded = () => isPage && document.readyState === 'complete'; | ||
const DEFAULT_CANVAS_CONTEXT_PROPS = { | ||
canvas: null, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
useDevicePixels: true, | ||
autoResize: true, | ||
container: null, | ||
visible: true, | ||
colorSpace: 'srgb', | ||
alphaMode: 'opaque' | ||
}; | ||
/** | ||
@@ -28,2 +15,13 @@ * Manages a canvas. Supports both HTML or offscreen canvas | ||
export class CanvasContext { | ||
static defaultProps = { | ||
canvas: null, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
useDevicePixels: true, | ||
autoResize: true, | ||
container: null, | ||
visible: true, | ||
alphaMode: 'opaque', | ||
colorSpace: 'srgb' | ||
}; | ||
id; | ||
@@ -40,15 +38,4 @@ props; | ||
_canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 }; | ||
/** Check if the DOM is loaded */ | ||
static get isPageLoaded() { | ||
return isPageLoaded(); | ||
} | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded = getPageLoadPromise(); | ||
constructor(props) { | ||
this.props = { ...DEFAULT_CANVAS_CONTEXT_PROPS, ...props }; | ||
this.props = { ...CanvasContext.defaultProps, ...props }; | ||
props = this.props; | ||
@@ -239,17 +226,5 @@ if (!isBrowser()) { | ||
// HELPER FUNCTIONS | ||
/** Returns a promise that resolves when the page is loaded */ | ||
function getPageLoadPromise() { | ||
if (isPageLoaded() || typeof window === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
return new Promise(resolve => { | ||
window.addEventListener('load', () => resolve()); | ||
}); | ||
} | ||
function getContainer(container) { | ||
if (typeof container === 'string') { | ||
const element = document.getElementById(container); | ||
if (!element && !isPageLoaded()) { | ||
throw new Error(`Accessing '${container}' before page was loaded`); | ||
} | ||
if (!element) { | ||
@@ -268,5 +243,2 @@ throw new Error(`${container} is not an HTML element`); | ||
const canvas = document.getElementById(canvasId); | ||
if (!canvas && !isPageLoaded()) { | ||
throw new Error(`Accessing '${canvasId}' before page was loaded`); | ||
} | ||
if (!(canvas instanceof HTMLCanvasElement)) { | ||
@@ -273,0 +245,0 @@ throw new Error('Object is not a canvas element'); |
@@ -119,29 +119,46 @@ import { StatsManager } from "../utils/stats-manager.js"; | ||
export type DeviceProps = { | ||
/** string id for debugging. Stored on the object, used in logging and set on underlying GPU objects when feasible. */ | ||
id?: string; | ||
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; | ||
container?: HTMLElement | string | null; | ||
width?: number /** width is only used when creating a new canvas */; | ||
height?: number /** height is only used when creating a new canvas */; | ||
/** Request a Device with the highest limits supported by platform. WebGPU: devices can be created with minimal limits. */ | ||
requestMaxLimits?: boolean; | ||
/** Properties for creating a default canvas context */ | ||
createCanvasContext?: CanvasContextProps | true; | ||
/** Control which type of GPU is preferred on systems with both integrated and discrete GPU. Defaults to "high-performance" / discrete GPU. */ | ||
powerPreference?: 'default' | 'high-performance' | 'low-power'; | ||
/** Hints that device creation should fail if no hardware GPU is available (if the system performance is "low"). */ | ||
failIfMajorPerformanceCaveat?: boolean; | ||
/** Error handling */ | ||
onError?: (error: Error) => unknown; | ||
gl?: WebGL2RenderingContext | null; | ||
/** WebGL: Instrument WebGL2RenderingContext (at the expense of performance) */ | ||
debug?: boolean; | ||
/** Break on WebGL functions matching these strings */ | ||
break?: string[]; | ||
/** WebGL: Initialize the SpectorJS WebGL debugger */ | ||
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 */ | ||
manageState?: boolean; | ||
/** Initialize all features on startup */ | ||
initalizeFeatures?: boolean; | ||
/** WebGL specific: Properties passed through to WebGL2RenderingContext creation: `canvas.getContext('webgl2', props.webgl)` */ | ||
webgl?: WebGLContextProps; | ||
/** Show shader source in browser? The default is`'error'`, meaning that logs are shown when shader compilation has errors */ | ||
debugShaders?: 'never' | 'errors' | 'warnings' | 'always'; | ||
/** Renders a small version of updated Framebuffers into the primary canvas context. Can be set in console luma.log.set('debug-framebuffers', true) */ | ||
debugFramebuffers?: boolean; | ||
/** WebGL specific - Trace WebGL calls (instruments WebGL2RenderingContext at the expense of performance). Can be set in console luma.log.set('debug-webgl', true) */ | ||
debugWebGL?: boolean; | ||
/** WebGL specific - Initialize the SpectorJS WebGL debugger. Can be set in console luma.log.set('debug-spectorjs', true) */ | ||
debugSpectorJS?: boolean; | ||
/** WebGL specific - SpectorJS URL. Override if CDN is down or different SpectorJS version is desired. */ | ||
debugSpectorJSUrl?: string; | ||
/** WebGPU specific - Request a Device with the highest limits supported by platform. On WebGPU devices can be created with minimal limits. */ | ||
_requestMaxLimits?: boolean; | ||
/** Disable specific features */ | ||
disabledFeatures?: Partial<Record<DeviceFeature, boolean>>; | ||
_disabledFeatures?: Partial<Record<DeviceFeature, boolean>>; | ||
/** WebGL specific - Initialize all features on startup */ | ||
_initializeFeatures?: boolean; | ||
/** Never destroy cached shaders and pipelines */ | ||
_factoryDestroyPolicy?: 'unused' | 'never'; | ||
/** @deprecated Internal, Do not use directly! Use `luma.attachDevice()` to attach to pre-created contexts/devices. */ | ||
_handle?: unknown; | ||
}; | ||
/** WebGL independent copy of WebGLContextAttributes */ | ||
type WebGLContextProps = { | ||
alpha?: boolean; | ||
desynchronized?: boolean; | ||
antialias?: boolean; | ||
depth?: boolean; | ||
failIfMajorPerformanceCaveat?: boolean; | ||
powerPreference?: 'default' | 'high-performance' | 'low-power'; | ||
premultipliedAlpha?: boolean; | ||
preserveDrawingBuffer?: boolean; | ||
}; | ||
/** | ||
@@ -175,2 +192,4 @@ * Create and attach devices for a specific backend. Currently static methods on each device | ||
readonly statsManager: StatsManager; | ||
/** An abstract timestamp used for change tracking */ | ||
timestamp: number; | ||
/** Used by other luma.gl modules to store data on the device */ | ||
@@ -213,3 +232,3 @@ _lumaData: { | ||
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */ | ||
getCanvasContext(): CanvasContext; | ||
getDefaultCanvasContext(): CanvasContext; | ||
/** Creates a new CanvasContext (WebGPU only) */ | ||
@@ -245,2 +264,8 @@ abstract createCanvasContext(props?: CanvasContextProps): CanvasContext; | ||
createCommandEncoder(props?: CommandEncoderProps): CommandEncoder; | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp(): number; | ||
/** Report unhandled device errors */ | ||
onError(error: Error): void; | ||
/** @deprecated Use getDefaultCanvasContext() */ | ||
getCanvasContext(): CanvasContext; | ||
/** @deprecated - will be removed - should use command encoder */ | ||
@@ -283,10 +308,6 @@ readPixelsToArrayWebGL(source: Framebuffer | Texture, options?: { | ||
resetWebGL(): void; | ||
timestamp: number; | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp(): number; | ||
/** Report unhandled device errors */ | ||
onError(error: Error): void; | ||
protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps; | ||
/** Subclasses use this to support .createBuffer() overloads */ | ||
protected _normalizeBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps; | ||
} | ||
export {}; | ||
//# sourceMappingURL=device.d.ts.map |
@@ -33,29 +33,23 @@ // luma.gl | ||
id: null, | ||
canvas: null, | ||
container: null, | ||
manageState: true, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
requestMaxLimits: true, | ||
powerPreference: 'high-performance', | ||
failIfMajorPerformanceCaveat: false, | ||
createCanvasContext: undefined, | ||
// Callbacks | ||
onError: (error) => log.error(error.message), | ||
gl: null, | ||
// alpha: undefined, | ||
// depth: undefined, | ||
// stencil: undefined, | ||
// antialias: undefined, | ||
// premultipliedAlpha: undefined, | ||
// preserveDrawingBuffer: undefined, | ||
// failIfMajorPerformanceCaveat: undefined | ||
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance) | ||
break: log.get('break') || [], | ||
// WebGL specific debugging | ||
debugWithSpectorJS: undefined, | ||
spectorUrl: undefined, | ||
_factoryDestroyPolicy: 'unused', | ||
// TODO - Change these after confirming things work as expected | ||
initalizeFeatures: true, | ||
disabledFeatures: { | ||
_initializeFeatures: true, | ||
_disabledFeatures: { | ||
'compilation-status-async-webgl': true | ||
}, | ||
_factoryDestroyPolicy: 'unused' | ||
_requestMaxLimits: true, | ||
// WebGL specific | ||
webgl: {}, | ||
debugShaders: log.get('debug-shaders') || undefined, | ||
debugFramebuffers: Boolean(log.get('debug-framebuffers')), | ||
debugWebGL: Boolean(log.get('debug-webgl')), | ||
debugSpectorJS: undefined, // Note: log setting is queried by the spector.js code | ||
debugSpectorJSUrl: undefined, | ||
// INTERNAL | ||
_handle: undefined | ||
}; | ||
@@ -77,2 +71,4 @@ get [Symbol.toStringTag]() { | ||
statsManager = lumaStats; | ||
/** An abstract timestamp used for change tracking */ | ||
timestamp = 0; | ||
/** Used by other luma.gl modules to store data on the device */ | ||
@@ -97,5 +93,5 @@ _lumaData = {}; | ||
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */ | ||
getCanvasContext() { | ||
getDefaultCanvasContext() { | ||
if (!this.canvasContext) { | ||
throw new Error('Device has no CanvasContext'); | ||
throw new Error('Device has no default CanvasContext. See props.createCanvasContext'); | ||
} | ||
@@ -107,2 +103,16 @@ return this.canvasContext; | ||
} | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp() { | ||
return this.timestamp++; | ||
} | ||
// Error Handling | ||
/** Report unhandled device errors */ | ||
onError(error) { | ||
this.props.onError(error); | ||
} | ||
// DEPRECATED METHODS | ||
/** @deprecated Use getDefaultCanvasContext() */ | ||
getCanvasContext() { | ||
return this.getDefaultCanvasContext(); | ||
} | ||
// WebGL specific HACKS - enables app to remove webgl import | ||
@@ -138,14 +148,5 @@ // Use until we have a better way to handle these | ||
} | ||
timestamp = 0; | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp() { | ||
return this.timestamp++; | ||
} | ||
// Error Handling | ||
/** Report unhandled device errors */ | ||
onError(error) { | ||
this.props.onError(error); | ||
} | ||
// IMPLEMENTATION | ||
_getBufferProps(props) { | ||
/** Subclasses use this to support .createBuffer() overloads */ | ||
_normalizeBufferProps(props) { | ||
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) { | ||
@@ -152,0 +153,0 @@ props = { data: props }; |
@@ -10,14 +10,16 @@ import type { Log } from '@probe.gl/log'; | ||
/** Properties for creating a new device */ | ||
export type CreateDeviceProps = DeviceProps & { | ||
export type CreateDeviceProps = { | ||
/** Selects the type of device. `best-available` uses webgpu if available, then webgl. */ | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
/** List of adapters. Will also search any pre-registered adapters */ | ||
adapters?: Adapter[]; | ||
}; | ||
} & DeviceProps; | ||
/** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */ | ||
export type AttachDeviceProps = DeviceProps & { | ||
export type AttachDeviceProps = { | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
/** Externally created WebGL context or WebGPU device */ | ||
handle: unknown; | ||
/** List of adapters. Will also search any pre-registered adapterss */ | ||
/** List of adapters. Will also search any pre-registered adapters */ | ||
adapters?: Adapter[]; | ||
}; | ||
} & DeviceProps; | ||
/** | ||
@@ -30,2 +32,9 @@ * Entry point to the luma.gl GPU abstraction | ||
static defaultProps: Required<CreateDeviceProps>; | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded: Promise<void>; | ||
/** Global stats for all devices */ | ||
@@ -32,0 +41,0 @@ readonly stats: StatsManager; |
// luma.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
import { isBrowser } from '@probe.gl/env'; | ||
import { Device } from "./device.js"; | ||
import { lumaStats } from "../utils/stats-manager.js"; | ||
import { log } from "../utils/log.js"; | ||
const isPage = isBrowser() && typeof document !== 'undefined'; | ||
const isPageLoaded = () => isPage && document.readyState === 'complete'; | ||
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering'; | ||
@@ -20,2 +23,11 @@ const ERROR_MESSAGE = 'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.'; | ||
}; | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded = getPageLoadPromise().then(() => { | ||
log.probe(2, 'DOM is loaded')(); | ||
}); | ||
/** Global stats for all devices */ | ||
@@ -35,3 +47,3 @@ stats = lumaStats; | ||
// @ts-expect-error no-undef | ||
typeof "9.1.0-alpha.15" !== 'undefined' ? "9.1.0-alpha.15" : 'running from source'; | ||
typeof "9.1.0-alpha.16" !== 'undefined' ? "9.1.0-alpha.16" : 'running from source'; | ||
spector; | ||
@@ -85,2 +97,5 @@ preregisteredAdapters = new Map(); | ||
// } | ||
if (props.createCanvasContext) { | ||
await Luma.pageLoaded; | ||
} | ||
const adapterMap = this.getAdapterMap(props.adapters); | ||
@@ -107,2 +122,5 @@ let type = props.type || ''; | ||
} | ||
if (props.createCanvasContext) { | ||
await Luma.pageLoaded; | ||
} | ||
// TODO - WebGPU does not yet have a stable API | ||
@@ -164,1 +182,11 @@ // if (props.handle instanceof GPUDevice) { | ||
export const luma = new Luma(); | ||
// HELPER FUNCTIONS | ||
/** Returns a promise that resolves when the page is loaded */ | ||
function getPageLoadPromise() { | ||
if (isPageLoaded() || typeof window === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
return new Promise(resolve => { | ||
window.addEventListener('load', () => resolve()); | ||
}); | ||
} |
@@ -42,5 +42,12 @@ import type { Device } from "../device.js"; | ||
abstract byteLength: number; | ||
/** "Time" of last update */ | ||
/** "Time" of last update, can be used to check if redraw is needed */ | ||
updateTimestamp: number; | ||
constructor(device: Device, props: BufferProps); | ||
/** | ||
* Create a copy of this Buffer with new byteLength, with same props but of the specified size. | ||
* @note Does not copy contents of the cloned Buffer. | ||
*/ | ||
clone(props: { | ||
byteLength: number; | ||
}): Buffer; | ||
/** Write data to buffer */ | ||
@@ -47,0 +54,0 @@ abstract write(data: ArrayBufferView, byteOffset?: number): void; |
@@ -38,3 +38,3 @@ // luma.gl | ||
indexType; | ||
/** "Time" of last update */ | ||
/** "Time" of last update, can be used to check if redraw is needed */ | ||
updateTimestamp; | ||
@@ -52,4 +52,6 @@ constructor(device, props) { | ||
} | ||
// Remove data from props before storing, we don't want to hold on to a big chunk of memory | ||
delete deducedProps.data; | ||
super(device, deducedProps, Buffer.defaultProps); | ||
this.usage = props.usage || 0; | ||
this.usage = deducedProps.usage || 0; | ||
this.indexType = deducedProps.indexType; | ||
@@ -59,2 +61,9 @@ // TODO - perhaps this should be set on async write completion? | ||
} | ||
/** | ||
* Create a copy of this Buffer with new byteLength, with same props but of the specified size. | ||
* @note Does not copy contents of the cloned Buffer. | ||
*/ | ||
clone(props) { | ||
return this.device.createBuffer({ ...this.props, ...props }); | ||
} | ||
/** Read data synchronously. @note WebGL2 only */ | ||
@@ -61,0 +70,0 @@ readSyncWebGL(byteOffset, byteLength) { |
@@ -25,5 +25,5 @@ import { Device } from "../device.js"; | ||
export type CopyBufferToBufferOptions = { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
sourceOffset?: number; | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
destinationOffset?: number; | ||
@@ -33,5 +33,5 @@ size: number; | ||
export type CopyBufferToTextureOptions = { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
byteOffset?: number; | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
mipLevel?: number; | ||
@@ -46,3 +46,3 @@ origin?: [number, number, number] | number[]; | ||
/** Texture to copy to/from. */ | ||
source: Texture; | ||
sourceTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -61,3 +61,3 @@ mipLevel?: number; | ||
/** Destination buffer */ | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */ | ||
@@ -79,3 +79,3 @@ byteOffset?: number; | ||
/** Texture to copy to/from. */ | ||
source: Texture; | ||
sourceTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -88,3 +88,3 @@ mipLevel?: number; | ||
/** Texture to copy to/from. */ | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -91,0 +91,0 @@ destinationMipLevel?: number; |
@@ -29,4 +29,13 @@ import type { ColorTextureFormat, DepthStencilTextureFormat, TextureFormat } from "../../gpu-type-utils/texture-formats.js"; | ||
/** | ||
* Create a copy of this framebuffer with new attached textures, with same props but of the specified size. | ||
* @note Does not copy contents of the attached textures. | ||
*/ | ||
clone(size?: { | ||
width: number; | ||
height: number; | ||
}): Framebuffer; | ||
/** | ||
* Resizes all attachments | ||
* @note resize() destroys existing textures (if size has changed). | ||
* @deprecated Use framebuffer.clone() | ||
*/ | ||
@@ -33,0 +42,0 @@ resize(size: { |
@@ -31,2 +31,11 @@ // luma.gl | ||
} | ||
/** | ||
* Create a copy of this framebuffer with new attached textures, with same props but of the specified size. | ||
* @note Does not copy contents of the attached textures. | ||
*/ | ||
clone(size) { | ||
const colorAttachments = this.colorAttachments.map(colorAttachment => colorAttachment.texture.clone(size)); | ||
const depthStencilAttachment = this.depthStencilAttachment && this.depthStencilAttachment.texture.clone(size); | ||
return this.device.createFramebuffer({ ...this.props, colorAttachments, depthStencilAttachment }); | ||
} | ||
resize(size) { | ||
@@ -110,3 +119,3 @@ let updateSize = !size; | ||
if (this.colorAttachments[i]) { | ||
const resizedTexture = this.colorAttachments[i].texture.createResizedTexture({ | ||
const resizedTexture = this.colorAttachments[i].texture.clone({ | ||
width, | ||
@@ -121,3 +130,3 @@ height | ||
if (this.depthStencilAttachment) { | ||
const resizedTexture = this.depthStencilAttachment.texture.createResizedTexture({ | ||
const resizedTexture = this.depthStencilAttachment.texture.clone({ | ||
width, | ||
@@ -124,0 +133,0 @@ height |
@@ -20,5 +20,5 @@ // luma.gl | ||
parameters: undefined, | ||
clearColor: [0, 0, 0, 0], | ||
clearDepth: 1, | ||
clearStencil: 0, | ||
clearColor: false, | ||
clearDepth: false, | ||
clearStencil: false, | ||
depthReadOnly: false, | ||
@@ -25,0 +25,0 @@ stencilReadOnly: false, |
@@ -18,4 +18,4 @@ import type { Device } from "../device.js"; | ||
entryPoint?: string; | ||
/** Show shader source in browser? */ | ||
debug?: 'never' | 'errors' | 'warnings' | 'always'; | ||
/** Show shader source in browser? Overrides the device.props.debugShaders setting */ | ||
debugShaders?: 'never' | 'errors' | 'warnings' | 'always'; | ||
}; | ||
@@ -37,2 +37,3 @@ /** | ||
constructor(device: Device, props: ShaderProps); | ||
abstract get asyncCompilationStatus(): Promise<'pending' | 'success' | 'error'>; | ||
/** Get compiler log asynchronously */ | ||
@@ -45,3 +46,3 @@ abstract getCompilationInfo(): Promise<readonly CompilerMessage[]>; | ||
/** In browser logging of errors */ | ||
debugShader(trigger?: "never" | "always" | "errors" | "warnings"): Promise<void>; | ||
debugShader(): Promise<void>; | ||
/** | ||
@@ -48,0 +49,0 @@ * In-browser UI logging of errors |
@@ -20,3 +20,3 @@ // luma.gl | ||
entryPoint: 'main', | ||
debug: 'errors' | ||
debugShaders: undefined | ||
}; | ||
@@ -34,2 +34,3 @@ get [Symbol.toStringTag]() { | ||
constructor(device, props) { | ||
props = { ...props, debugShaders: props.debugShaders || device.props.debugShaders || 'errors' }; | ||
super(device, { id: getShaderIdFromProps(props), ...props }, Shader.defaultProps); | ||
@@ -49,3 +50,4 @@ this.stage = this.props.stage; | ||
/** In browser logging of errors */ | ||
async debugShader(trigger = this.props.debug) { | ||
async debugShader() { | ||
const trigger = this.props.debugShaders; | ||
switch (trigger) { | ||
@@ -65,3 +67,3 @@ case 'never': | ||
const messages = await this.getCompilationInfo(); | ||
if (this.props.debug === 'warnings' && messages?.length === 0) { | ||
if (trigger === 'warnings' && messages?.length === 0) { | ||
return; | ||
@@ -68,0 +70,0 @@ } |
@@ -185,8 +185,7 @@ import type { Device } from "../device.js"; | ||
/** | ||
* Create a new texture with the same parameters but a different size | ||
* | ||
* Create a new texture with the same parameters and optionally, a different size | ||
* @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size. | ||
* @note Does not copy contents of the texture | ||
*/ | ||
createResizedTexture(size: { | ||
clone(size?: { | ||
width: number; | ||
@@ -193,0 +192,0 @@ height: number; |
@@ -155,8 +155,7 @@ // luma.gl | ||
/** | ||
* Create a new texture with the same parameters but a different size | ||
* | ||
* Create a new texture with the same parameters and optionally, a different size | ||
* @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size. | ||
* @note Does not copy contents of the texture | ||
*/ | ||
createResizedTexture(size) { | ||
clone(size) { | ||
return this.device.createTexture({ ...this.props, ...size }); | ||
@@ -163,0 +162,0 @@ } |
@@ -7,13 +7,13 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['luma'] = factory();})(globalThis, function () { | ||
"use strict";var __exports__=(()=>{var Z=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ft=Object.prototype.hasOwnProperty;var lt=(r,e,t)=>e in r?Z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var dt=(r,e)=>{for(var t in e)Z(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&&Z(r,n,{get:()=>e[n],enumerable:!(s=ct(e,n))||s.enumerable});return r};var mt=r=>ht(Z({},"__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:()=>I,CommandBuffer:()=>W,CommandEncoder:()=>V,ComputePass:()=>G,ComputePipeline:()=>k,Device:()=>T,DeviceFeatures:()=>se,DeviceLimits:()=>re,ExternalTexture:()=>$,Framebuffer:()=>U,QuerySet:()=>X,RenderPass:()=>z,RenderPipeline:()=>H,Resource:()=>c,Sampler:()=>N,Shader:()=>F,Texture:()=>h,TextureView:()=>D,TransformFeedback:()=>Y,UniformBlock:()=>L,UniformBufferLayout:()=>_,UniformStore:()=>le,VertexArray:()=>j,decodeShaderAttributeType:()=>ce,decodeShaderUniformType:()=>ue,decodeTextureFormat:()=>Oe,decodeVertexFormat:()=>O,getAttributeInfosFromLayouts:()=>Le,getDataTypeFromTypedArray:()=>Ie,getScratchArray:()=>rt,getTypedArrayFromDataType:()=>ot,getVertexFormatFromAttribute:()=>at,log:()=>l,luma:()=>Ye});function M(){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 x=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=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 S=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 x?n=e:n=new x(t,s),this.stats[t]=n),n}};var de=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new S({id:e})),this.stats.get(e)}},q=new de;var K=globalThis,pt=globalThis.document||{},Q=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 he="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 J=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 ee;(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"})(ee||(ee={}));var xt=10;function Ne(r){return typeof r!="string"?r:(r=r.toUpperCase(),ee[r]||ee.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 i of s){let o=n[i];typeof o=="function"&&(e.find(u=>i===u)||(n[i]=o.bind(r)))}}function B(r,e){if(!r)throw new Error(e||"Assertion failed")}function w(){let r;if(p()&&K.performance)r=K?.performance?.now?.();else if("hrtime"in Q){let e=Q?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var A={debug:p()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},wt={enabled:!0,level:0};function v(){}var ze={},ke={once:!0},y=class{constructor({id:e}={id:""}){this.VERSION=he,this._startTs=w(),this._deltaTs=w(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new J(`__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((w()-this._startTs).toPrecision(10))}getDelta(){return Number((w()-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,A.warn,arguments,ke)}error(e){return this._getLogFunction(0,e,A.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,A.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,A.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,A.debug||A.info,arguments,ke)}table(e,t,s){return t?this._getLogFunction(e,t,console.table||v,s&&[s],{tag:St(t)}):v}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||v)}group(e,t,s={collapsed:!1}){let n=Ge({logLevel:e,message:t,opts:s}),{collapsed:i}=s;return n.method=(i?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||v)}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,i){if(this._shouldLog(e)){i=Ge({logLevel:e,message:t,args:n,opts:i}),s=s||i.method,B(s),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=w();let o=i.tag||i.message;if(i.once&&o)if(!ze[o])ze[o]=w();else return v;return t=Tt(this.id,i.message,i),s.bind(console,t,...i.args)}return v}};y.VERSION=he;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 B(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 B(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 me={};function E(r="id"){me[r]=me[r]||1;let e=me[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:E(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 R=class extends c{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let s={...t};(t.usage||0)&R.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?s.indexType="uint32":t.data instanceof Uint16Array&&(s.indexType="uint16")),super(e,s,R.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,i=Math.min(e?e.byteLength:s,R.DEBUG_DATA_MAX_LENGTH);n===null?this.debugData=new ArrayBuffer(i):t===0&&s===n.byteLength?this.debugData=n.slice(0,i):this.debugData=n.slice(t,t+i)}},d=R;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 te(r){let e=We[r],t=vt(e),s=r.includes("norm"),n=!s&&!r.startsWith("float"),i=r.startsWith("s");return{dataType:We[r],byteLength:t,integer:n,signed:i,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 pe(r){return Pt.some(e=>r.startsWith(e))}function Oe(r){let e=_t.exec(r);if(e){let[,t,s,n,i,o]=e;if(r){let u=`${n}${s}`,f=te(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 o==="-webgl"&&(m.webgl=!0),i==="-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(pe(r)){let s={channels:"rgb",components:3,bytesPerPixel:1,srgb:!1,compressed:!0},n=Mt(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 Mt(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,s,n]=t;return{blockWidth:Number(s),blockHeight:Number(n)}}return null}var re=class{},se=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)}},ge=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...ge.defaultProps,...e},this.id=this.props.id||E(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=q;_lumaData={};isTextureFormatCompressed(e){return pe(e)}loseDevice(){return!1}error(e){this.props.onError(e)}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}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}},T=ge;a(T,"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 Bt="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.",ie=class{stats=q;log=l;VERSION="9.1.0-alpha.15";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} - ${Bt}`)(),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(ie.defaultProps,e)}async createDevice(e={}){e={...ie.defaultProps,...e};let t=this.getAdapterMap(e.adapters),s=e.type||"";s==="best-available"&&(s=this.getBestAvailableAdapter(e.adapters)||s);let o=await(this.getAdapterMap(e.adapters)||t).get(s)?.create?.(e);if(o)return o;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 i=await t.get(s)?.attach?.(null);if(i)return i;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)}}},ne=ie;a(ne,"defaultProps",{...T.defaultProps,type:"best-available",adapters:void 0});var Ye=new ne;var oe=class{};var Rt=p()&&typeof document<"u",ae=()=>Rt&&document.readyState==="complete",It={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},I=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ae()}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,i]=this.getDrawingBufferSize();return Ut(e,s,n,i,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 i=this._canvasSizeInfo;if(i.clientWidth!==s||i.clientHeight!==n||i.devicePixelRatio!==e){let o=e,u=Math.floor(s*o),f=Math.floor(n*o);if(this.htmlCanvas.width=u,this.htmlCanvas.height=f,this.device.gl){let[g,C]=this.getDrawingBufferSize();(g!==u||C!==f)&&(o=Math.min(g/s,C/n),this.htmlCanvas.width=Math.floor(s*o),this.htmlCanvas.height=Math.floor(n*o),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(I,"pageLoaded",Dt());function Dt(){return ae()||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&&!ae())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&&!ae())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 i=r,o=Xe(i[0],e,t),u=Ze(i[1],e,s,n),f=Xe(i[0]+1,e,t),m=f===t-1?f:f-1;f=Ze(i[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:o,y:u,width:Math.max(m-o+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 b=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")}static isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}static getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return b.getTextureDataSize(e[0]);if(b.isExternalImage(e))return b.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")}static getMipLevelCount(e,t){return Math.floor(Math.log2(Math.max(e,t)))+1}static 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,b.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=b.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"?b.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=e.incrementTimestamp()}createResizedTexture(e){return this.device.createTexture({...this.props,...e})}static _fixProps(e){let t={...e},{width:s,height:n}=t;return typeof s=="number"&&(t.width=Math.max(1,Math.ceil(s))),typeof n=="number"&&(t.height=Math.max(1,Math.ceil(n))),t}},h=b;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}),a(h,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1});var ye=class extends c{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,ye.defaultProps)}},D=ye;a(D,"defaultProps",{...c.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var be=class extends c{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,be.defaultProps)}},$=be;a($,"defaultProps",{...c.defaultProps,source:void 0,colorSpace:"srgb"});function Ke(r,e,t){let s="",n=e.split(/\r?\n/),i=r.slice().sort((o,u)=>o.lineNum-u.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let u=1;u<=n.length;u++)for(s+=Qe(n[u-1],u,t);i.length>o&&i[o].lineNum===u;){let f=i[o++];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),i=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
"use strict";var __exports__=(()=>{var K=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ft=Object.prototype.hasOwnProperty;var lt=(r,e,t)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var dt=(r,e)=>{for(var t in e)K(r,t,{get:e[t],enumerable:!0})},ht=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ut(e))!ft.call(r,s)&&s!==t&&K(r,s,{get:()=>e[s],enumerable:!(n=ct(e,s))||n.enumerable});return r};var mt=r=>ht(K({},"__esModule",{value:!0}),r);var a=(r,e,t)=>(lt(r,typeof e!="symbol"?e+"":e,t),t);var er={};dt(er,{Adapter:()=>ie,Buffer:()=>d,CanvasContext:()=>$,CommandBuffer:()=>j,CommandEncoder:()=>O,ComputePass:()=>W,ComputePipeline:()=>V,Device:()=>S,DeviceFeatures:()=>oe,DeviceLimits:()=>se,ExternalTexture:()=>N,Framebuffer:()=>z,QuerySet:()=>q,RenderPass:()=>G,RenderPipeline:()=>k,Resource:()=>c,Sampler:()=>H,Shader:()=>U,Texture:()=>h,TextureView:()=>F,TransformFeedback:()=>Z,UniformBlock:()=>L,UniformBufferLayout:()=>_,UniformStore:()=>fe,VertexArray:()=>X,decodeShaderAttributeType:()=>ae,decodeShaderUniformType:()=>ce,decodeTextureFormat:()=>Oe,decodeVertexFormat:()=>Y,getAttributeInfosFromLayouts:()=>_e,getDataTypeFromTypedArray:()=>Ie,getScratchArray:()=>rt,getTypedArrayFromDataType:()=>it,getVertexFormatFromAttribute:()=>at,log:()=>l,luma:()=>Ye});var J=globalThis,pt=globalThis.document||{},Q=globalThis.process||{},gt=globalThis.console,rr=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 m(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||De()}var le="4.0.7";function B(){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 x=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=B(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(B()-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:n}=e,s=this.stats[t];return s||(e instanceof x?s=e:s=new x(t,n),this.stats[t]=s),s}};var de=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)}},ee=new de;function bt(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var te=class{constructor(e,t,n="sessionStorage"){this.storage=bt(n),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 re;(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"})(re||(re={}));var xt=10;function Ne(r){return typeof r!="string"?r:(r=r.toUpperCase(),re[r]||re.WHITE)}function Ue(r,e,t){return!m&&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),n=Object.getOwnPropertyNames(t),s=r;for(let o of n){let i=s[o];typeof i=="function"&&(e.find(u=>o===u)||(s[o]=i.bind(r)))}}function R(r,e){if(!r)throw new Error(e||"Assertion failed")}function w(){let r;if(m()&&J.performance)r=J?.performance?.now?.();else if("hrtime"in Q){let e=Q?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var v={debug:m()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},wt={enabled:!0,level:0};function A(){}var ze={},ke={once:!0},y=class{constructor({id:e}={id:""}){this.VERSION=le,this._startTs=w(),this._deltaTs=w(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new te(`__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((w()-this._startTs).toPrecision(10))}getDelta(){return Number((w()-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,v.warn,arguments,ke)}error(e){return this._getLogFunction(0,e,v.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,v.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,v.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,v.debug||v.info,arguments,ke)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||A,n&&[n],{tag:Tt(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,n={collapsed:!1}){let s=Ge({logLevel:e,message:t,opts:n}),{collapsed:o}=n;return s.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||A)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Ve(e)}_getLogFunction(e,t,n,s,o){if(this._shouldLog(e)){o=Ge({logLevel:e,message:t,args:s,opts:o}),n=n||o.method,R(n),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=w();let i=o.tag||o.message;if(o.once&&i)if(!ze[i])ze[i]=w();else return A;return t=St(this.id,o.message,o),n.bind(console,t,...o.args)}return A}};y.VERSION=le;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 R(Number.isFinite(e)&&e>=0),e}function Ge(r){let{logLevel:e,message:t}=r;r.logLevel=Ve(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return R(s==="string"||s==="object"),Object.assign(r,{args:n},r.opts)}function St(r,e,t){if(typeof e=="string"){let n=t.time?Fe($e(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=Ue(e,t.color,t.background)}return e}function Tt(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 E(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,n){if(!e)throw new Error("no device");this._device=e,this.props=vt(t,n);let s=this.props.id!=="undefined"?this.props.id:E(this[Symbol.toStringTag]);this.props.id=s,this.id=s,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 n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.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 vt(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var I=class extends c{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&I.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,I.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let s=ArrayBuffer.isView(e)?e.buffer:e,o=Math.min(e?e.byteLength:n,I.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(o):t===0&&n===s.byteLength?this.debugData=s.slice(0,o):this.debugData=s.slice(t,t+o)}},d=I;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 ne(r){let e=We[r],t=At(e),n=r.includes("norm"),s=!n&&!r.startsWith("float"),o=r.startsWith("s");return{dataType:We[r],byteLength:t,integer:s,signed:o,normalized:n}}function At(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"],Ct=/^(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=Ct.exec(r);if(e){let[,t,n,s,o,i]=e;if(r){let u=`${s}${n}`,f=ne(u),p={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"&&(p.webgl=!0),o==="-srgb"&&(p.srgb=!0),p}}return Lt(r)}var _t={"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 Lt(r){if(me(r)){let n={channels:"rgb",components:3,bytesPerPixel:1,srgb:!1,compressed:!0},s=Mt(r);return s&&(n.blockWidth=s.blockWidth,n.blockHeight=s.blockHeight),n}let e=_t[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 Mt(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,s]=t;return{blockWidth:Number(n),blockHeight:Number(s)}}return null}var se=class{},oe=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||E(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=ee;timestamp=0;_lumaData={};isTextureFormatCompressed(e){return me(e)}loseDevice(){return!1}error(e){this.props.onError(e)}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createCommandEncoder(e={}){throw new Error("not implemented")}incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}getCanvasContext(){return this.getDefaultCanvasContext()}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")}_normalizeBufferProps(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}},S=pe;a(S,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,onError:e=>l.error(e.message),_factoryDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_requestMaxLimits:!0,webgl:{},debugShaders:l.get("debug-shaders")||void 0,debugFramebuffers:Boolean(l.get("debug-framebuffers")),debugWebGL:Boolean(l.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_handle:void 0});var Bt=m()&&typeof document<"u",Rt=()=>Bt&&document.readyState==="complete",It="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.",P=class{stats=ee;log=l;VERSION="9.1.0-alpha.16";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} - ${It}`)(),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(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapter(e=[]){let t=this.getAdapterMap(e);return t.get("webgpu")?.isSupported?.()?"webgpu":t.get("webgl")?.isSupported?.()?"webgl":null}setDefaultDeviceProps(e){Object.assign(P.defaultProps,e)}async createDevice(e={}){e={...P.defaultProps,...e},e.createCanvasContext&&await P.pageLoaded;let t=this.getAdapterMap(e.adapters),n=e.type||"";n==="best-available"&&(n=this.getBestAvailableAdapter(e.adapters)||n);let i=await(this.getAdapterMap(e.adapters)||t).get(n)?.create?.(e);if(i)return i;throw new Error(je)}async attachDevice(e){let t=this.getAdapterMap(e.adapters),n="";e.handle instanceof WebGL2RenderingContext&&(n="webgl"),e.createCanvasContext&&await P.pageLoaded,e.handle===null&&(n="unknown");let o=await t.get(n)?.attach?.(null);if(o)return o;throw new Error(je)}enforceWebGL2(e=!0,t=[]){let s=this.getAdapterMap(t).get("webgl");s||l.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}registerDevices(e){l.warn("luma.registerDevices() is deprecated, use luma.registerAdapters() instead");for(let t of e){let n=t.adapter;n&&this.preregisteredAdapters.set(n.type,n)}}},D=P;a(D,"defaultProps",{...S.defaultProps,type:"best-available",adapters:void 0}),a(D,"pageLoaded",Dt().then(()=>{l.probe(2,"DOM is loaded")()}));var Ye=new D;function Dt(){return Rt()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}var ie=class{};var ge=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};constructor(e){if(this.props={...ge.defaultProps,...e},e=this.props,!m()){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),n=$t(e?.container||null);n.insertBefore(t,n.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 n of t)n.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 n=this.cssToDeviceRatio(),[s,o]=this.getDrawingBufferSize();return Ut(e,n,s,o,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let n="width"in t?t.width:this.htmlCanvas.clientWidth,s="height"in t?t.height:this.htmlCanvas.clientHeight;(!n||!s)&&(l.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,s=this.htmlCanvas.height||1);let o=this._canvasSizeInfo;if(o.clientWidth!==n||o.clientHeight!==s||o.devicePixelRatio!==e){let i=e,u=Math.floor(n*i),f=Math.floor(s*i);if(this.htmlCanvas.width=u,this.htmlCanvas.height=f,this.device.gl){let[g,M]=this.getDrawingBufferSize();(g!==u||M!==f)&&(i=Math.min(g/n,M/s),this.htmlCanvas.width=Math.floor(n*i),this.htmlCanvas.height=Math.floor(s*i),l.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=s,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)}},$=ge;a($,"defaultProps",{canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb"});function $t(r){if(typeof r=="string"){let e=document.getElementById(r);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 instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function Nt(r){let{width:e,height:t}=r,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",n}function Ut(r,e,t,n,s){let o=r,i=Xe(o[0],e,t),u=Ze(o[1],e,n,s),f=Xe(o[0]+1,e,t),p=f===t-1?f:f-1;f=Ze(o[1]+1,e,n,s);let g;return s?(f=f===0?f:f+1,g=u,u=f):g=f===n-1?f:f-1,{x:i,y:u,width:Math.max(p-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,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var b=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")}static isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}static getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return b.getTextureDataSize(e[0]);if(b.isExternalImage(e))return b.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let n=Object.values(e)[0];return{width:n.width,height:n.height}}throw new Error("texture size deduction failed")}static getMipLevelCount(e,t){return Math.floor(Math.log2(Math.max(e,t)))+1}static 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,b.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=b.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"?b.getMipLevelCount(this.width,this.height):this.props.mipLevels||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}static _fixProps(e){let t={...e},{width:n,height:s}=t;return typeof n=="number"&&(t.width=Math.max(1,Math.ceil(n))),typeof s=="number"&&(t.height=Math.max(1,Math.ceil(s))),t}},h=b;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}),a(h,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1});var ye=class extends c{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,ye.defaultProps)}},F=ye;a(F,"defaultProps",{...c.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var be=class extends c{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(e,t){super(e,t,be.defaultProps)}},N=be;a(N,"defaultProps",{...c.defaultProps,source:void 0,colorSpace:"srgb"});function Ke(r,e,t){let n="",s=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<=s.length;u++)for(n+=Je(s[u-1],u,t);o.length>i&&o[i].lineNum===u;){let f=o[i++];n+=qe(f,s,f.lineNum,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let u of r)n+=qe(u,s,u.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function qe(r,e,t,n){if(n?.inlineSource){let o=Ht(e,t),i=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
`:"";return` | ||
${n}${i}${r.type.toUpperCase()}: ${r.message} | ||
${o}${i}${r.type.toUpperCase()}: ${r.message} | ||
`}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 i=r[n-1];i!==void 0&&(s+=Qe(i,e,t))}return s}function Qe(r,e,t){let s=t?.html?kt(r):r;return`${zt(String(e),4)}: ${s}${t?.html?"<br/>":` | ||
`}`}function zt(r,e){let t="";for(let s=r.length;s<e;++s)t+=" ";return t+r}function kt(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var xe=class extends c{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Gt(t),...t},xe.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}),i=this.getTranslatedSource();i&&(n+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${i}</pre></code>`);let o=document.createElement("Button");o.innerHTML=` | ||
<h1>Shader Compilation Error in ${s}</h1><br /><br /> | ||
`}let s=r.type==="error"?"red":"#8B4000";return n?.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Ht(r,e,t){let n="";for(let s=e-2;s<=e;s++){let o=r[s-1];o!==void 0&&(n+=Je(o,e,t))}return n}function Je(r,e,t){let n=t?.html?kt(r):r;return`${zt(String(e),4)}: ${n}${t?.html?"<br/>":` | ||
`}`}function zt(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function kt(r){return r.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var xe=class extends c{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:Gt(t),...t},xe.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();e==="warnings"&&t?.length===0||this._displayShaderLog(t)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let t=Qe(this.source),n=`${this.stage} ${t}`,s=Ke(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource();o&&(s+=`<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 ${n}</h1><br /><br /> | ||
<code style="user-select:text;"><pre> | ||
${n} | ||
</pre></code>`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),o.onclick=()=>{let f=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(f)}}},F=xe;a(F,"defaultProps",{...c.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function Gt(r){return Je(r.source)||r.id||E(`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 we=class extends c{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,we.defaultProps)}},N=we;a(N,"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 Te=class extends c{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,Te.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,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,t){for(let s=0;s<this.colorAttachments.length;++s)if(this.colorAttachments[s]){let n=this.colorAttachments[s].texture.createResizedTexture({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[s]),this.colorAttachments[s]=n.view,this.attachResource(n.view)}if(this.depthStencilAttachment){let s=this.depthStencilAttachment.texture.createResizedTexture({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=s.view,this.attachResource(s)}this.updateAttachments()}},U=Te;a(U,"defaultProps",{...c.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var Se=class extends c{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,Se.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},H=Se;a(H,"defaultProps",{...c.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var Ae=class extends c{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t,Ae.defaultProps)}},z=Ae;a(z,"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 ve=class extends c{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,ve.defaultProps),this.shaderLayout=t.shaderLayout}},k=ve;a(k,"defaultProps",{...c.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var Ee=class extends c{get[Symbol.toStringTag](){return"ComputePass"}constructor(e,t){super(e,t,Ee.defaultProps)}},G=Ee;a(G,"defaultProps",{...c.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Pe=class extends c{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Pe.defaultProps)}},V=Pe;a(V,"defaultProps",{...c.defaultProps,measureExecutionTime:void 0});var _e=class extends c{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,_e.defaultProps)}},W=_e;a(W,"defaultProps",{...c.defaultProps});function ce(r){let[e,t]=Wt[r],s=e==="i32"||e==="u32",n=e!=="u32",i=Ot[e]*t,o=Vt(e,t);return{dataType:e,components:t,defaultVertexFormat:o,byteLength:i,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 O(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,s]=r.split("x"),n=t,i=s?parseInt(s):1,o=te(n),u={type:n,components:i,byteLength:o.byteLength*i,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(u.webglOnly=!0),u}function Le(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=Le(r,e),n=new Array(t).fill(null);for(let i of Object.values(s))n[i.location]=i;return n}function jt(r,e,t){let s=Yt(r,t),n=Xt(e,t);if(!s)return null;let i=ce(s.type),o=n?.vertexFormat||i.defaultVertexFormat,u=O(o);return{attributeName:n?.attributeName||s.name,bufferName:n?.bufferName||s.name,location:s.location,shaderType:s.type,shaderDataType:i.dataType,shaderComponents:i.components,vertexFormat:o,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:i.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 i of t.attributes||[]){let o=O(i.format);s+=o.byteLength}let n=t.attributes?.find(i=>i.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 Ce=class extends c{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Ce.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")}},j=Ce;a(j,"defaultProps",{...c.defaultProps,renderPipeline:null});var Me=class extends c{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Me.defaultProps)}},Y=Me;a(Y,"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)}},X=Be;a(X,"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 ue(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 fe;function Re(r){return(!fe||fe.byteLength<r)&&(fe=new ArrayBuffer(r)),fe}function rt(r,e){let t=Re(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Jt(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function P(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Jt(r)}var st=1024,_=class{layout={};byteLength;constructor(e){let t=0;for(let[n,i]of Object.entries(e)){let o=ue(i),{type:u,components:f}=o;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=Re(t),n={i32:new Int32Array(s),u32:new Uint32Array(s),f32:new Float32Array(s),f16:new Uint16Array(s)};for(let[i,o]of Object.entries(e)){let u=this.layout[i];if(!u){l.warn(`Supplied uniform value ${i} not present in uniform block layout`)();continue}let{type:f,size:m,offset:g}=u,C=n[f];if(m===1){if(typeof o!="number"&&typeof o!="boolean"){l.warn(`Supplied value for single component uniform ${i} is not a number: ${o}`)();continue}C[g]=Number(o)}else{if(!P(o)){l.warn(`Supplied value for multi component / array uniform ${i} is not a numeric array: ${o}`)();continue}C.set(o,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(!P(s))return!1;if(P(n)&&s.length===n.length){for(let i=0;i<s.length;++i)if(n[i]!==s[i])return!1}return!0}function it(r){return P(r)?r.slice():r}var L=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]=it(t),this.modifiedUniforms[e]=!0,this.modified=!0)}};var le=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,s]of Object.entries(e)){let n=t,i=new _(s.uniformTypes||{});this.uniformBufferLayouts.set(n,i);let o=new L({name:t});o.setUniforms(s.defaultUniforms||{}),this.uniformBlocks.set(n,o)}}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),i=e.createBuffer({usage:d.UNIFORM|d.COPY_DST,byteLength:n}),o=this.getUniformBufferData(t);return i.write(o),i}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 i=this.getUniformBufferData(e);this.uniformBuffers.get(e)?.write(i);let u=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,i,u)()}return n}};function Ie(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 ot(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=Ie(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);})(); | ||
${s} | ||
</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)}}},U=xe;a(U,"defaultProps",{...c.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function Gt(r){return Qe(r.source)||r.id||E(`unnamed ${r.stage}-shader`)}function Qe(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}var we=class extends c{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,we.defaultProps)}},H=we;a(H,"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 Se=class extends c{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,Se.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(s=>s.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,s]=Array.isArray(e)?e:[e.width,e.height];t=t||s!==this.height||n!==this.width,this.width=n,this.height=s}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 n=this.createColorTexture(t);return this.attachResource(n),n.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,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:h.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let s=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},z=Se;a(z,"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")}},k=Te;a(k,"defaultProps",{...c.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var ve=class extends c{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t,ve.defaultProps)}},G=ve;a(G,"defaultProps",{...c.defaultProps,framebuffer:null,parameters:void 0,clearColor:!1,clearDepth:!1,clearStencil:!1,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}},V=Ae;a(V,"defaultProps",{...c.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var Ee=class extends c{get[Symbol.toStringTag](){return"ComputePass"}constructor(e,t){super(e,t,Ee.defaultProps)}},W=Ee;a(W,"defaultProps",{...c.defaultProps,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var Pe=class extends c{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,Pe.defaultProps)}},O=Pe;a(O,"defaultProps",{...c.defaultProps,measureExecutionTime:void 0});var Ce=class extends c{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,Ce.defaultProps)}},j=Ce;a(j,"defaultProps",{...c.defaultProps});function ae(r){let[e,t]=Wt[r],n=e==="i32"||e==="u32",s=e!=="u32",o=Ot[e]*t,i=Vt(e,t);return{dataType:e,components:t,defaultVertexFormat:i,byteLength:o,integer:n,signed:s}}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 Y(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),s=t,o=n?parseInt(n):1,i=ne(s),u={type:s,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 n of r.attributes){let s=jt(r,e,n.name);s&&(t[n.name]=s)}return t}function et(r,e,t=16){let n=_e(r,e),s=new Array(t).fill(null);for(let o of Object.values(n))s[o.location]=o;return s}function jt(r,e,t){let n=Yt(r,t),s=Xt(e,t);if(!n)return null;let o=ae(n.type),i=s?.vertexFormat||o.defaultVertexFormat,u=Y(i);return{attributeName:s?.attributeName||n.name,bufferName:s?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:i,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:o.integer,stepMode:s?.stepMode||n.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function Yt(r,e){let t=r.attributes.find(n=>n.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 n=t.byteStride;if(typeof t.byteStride!="number")for(let o of t.attributes||[]){let i=Y(o.format);n+=i.byteLength}let s=t.attributes?.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:n}}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:n,bufferLayout:s}=t.renderPipeline||{};if(!n||!s)throw new Error("VertexArray");this.attributeInfos=et(n,s,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}},X=Le;a(X,"defaultProps",{...c.defaultProps,renderPipeline:null});var Me=class extends c{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Me.defaultProps)}},Z=Me;a(Z,"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)}},q=Be;a(q,"defaultProps",{...c.defaultProps,type:void 0,count:void 0});var Jt={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 Jt[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 Re(r){return(!ue||ue.byteLength<r)&&(ue=new ArrayBuffer(r)),ue}function rt(r,e){let t=Re(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Qt(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function C(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Qt(r)}var nt=1024,_=class{layout={};byteLength;constructor(e){let t=0;for(let[s,o]of Object.entries(e)){let i=ce(o),{type:u,components:f}=i;t=tt(t,f);let p=t;t+=f,this.layout[s]={type:u,size:f,offset:p}}t+=(4-t%4)%4;let n=t*4;this.byteLength=Math.max(n,nt)}getData(e){let t=Math.max(this.byteLength,nt),n=Re(t),s={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)};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:p,offset:g}=u,M=s[f];if(p===1){if(typeof i!="number"&&typeof i!="boolean"){l.warn(`Supplied value for single component uniform ${o} is not a number: ${i}`)();continue}M[g]=Number(i)}else{if(!C(i)){l.warn(`Supplied value for multi component / array uniform ${o} is not a numeric array: ${i}`)();continue}M.set(i,g)}}return new Uint8Array(n)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function st(r,e,t=16){if(r!==e)return!1;let n=r,s=e;if(!C(n))return!1;if(C(s)&&n.length===s.length){for(let o=0;o<n.length;++o)if(s[o]!==n[o])return!1}return!0}function ot(r){return C(r)?r.slice():r}var L=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(s=>s.type==="uniform"&&s.name===e?.name);if(!t)throw new Error(e?.name);let n=t;for(let s of n.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){st(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,n]of Object.entries(e)){let s=t,o=new _(n.uniformTypes||{});this.uniformBufferLayouts.set(s,o);let i=new L({name:t});i.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,i)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(n);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,n){n&&this.setUniforms(n);let s=this.getUniformBufferByteLength(t),o=e.createBuffer({usage:d.UNIFORM|d.COPY_DST,byteLength:s}),i=this.getUniformBufferData(t);return o.write(i),o}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:d.UNIFORM|d.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&l.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),s=!1;if(n&&t?.needsRedraw){s||=t.needsRedraw;let o=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(o);let i=this.uniformBlocks.get(e)?.getAllUniforms();l.log(4,`Writing to uniform buffer ${String(e)}`,o,i)()}return s}};function Ie(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 n=e,s=Ie(r);if(s==="uint8"||s==="sint8"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(s=s.replace("int","norm")),`${s}x${n}`}if(s==="uint16"||s==="sint16"){if(n===1||n===3)throw new Error(`size: ${e}`);return t&&(s=s.replace("int","norm")),`${s}x${n}`}return n===1?s:`${s}x${n}`}return mt(er);})(); | ||
return __exports__; | ||
}); |
@@ -9,3 +9,3 @@ // luma.gl | ||
]; | ||
const REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
const RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
/** | ||
@@ -21,3 +21,3 @@ * Returns true if a texture format is GPU compressed | ||
export function decodeTextureFormat(format) { | ||
const matches = REGEX.exec(format); | ||
const matches = RGB_FORMAT_REGEX.exec(format); | ||
if (matches) { | ||
@@ -24,0 +24,0 @@ const [, channels, length, type, srgb, suffix] = matches; |
@@ -0,1 +1,2 @@ | ||
export type { AttachDeviceProps, CreateDeviceProps } from "./adapter/luma.js"; | ||
export { luma } from "./adapter/luma.js"; | ||
@@ -2,0 +3,0 @@ export { Adapter } from "./adapter/adapter.js"; |
// luma.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
// MAIN API ACCESS POINT | ||
export { luma } from "./adapter/luma.js"; | ||
@@ -6,0 +5,0 @@ // ADAPTER (DEVICE AND GPU RESOURCE INTERFACES) |
@@ -20,3 +20,3 @@ // luma.gl | ||
if (props?.name && props?.shaderLayout) { | ||
const binding = props?.shaderLayout.bindings?.find(binding => binding.type === 'uniform' && binding.name === props?.name); | ||
const binding = props?.shaderLayout.bindings?.find(binding_ => binding_.type === 'uniform' && binding_.name === props?.name); | ||
if (!binding) { | ||
@@ -23,0 +23,0 @@ throw new Error(props?.name); |
@@ -113,3 +113,3 @@ // luma.gl | ||
const uniformBlock = this.uniformBlocks.get(uniformBufferName); | ||
const uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
let uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
let reason = false; | ||
@@ -120,3 +120,3 @@ if (uniformBuffer && uniformBlock?.needsRedraw) { | ||
const uniformBufferData = this.getUniformBufferData(uniformBufferName); | ||
const uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
uniformBuffer?.write(uniformBufferData); | ||
@@ -123,0 +123,0 @@ // logging - TODO - don't query the values unnecessarily |
{ | ||
"name": "@luma.gl/core", | ||
"version": "9.1.0-alpha.15", | ||
"version": "9.1.0-alpha.16", | ||
"description": "The luma.gl core Device API", | ||
@@ -49,3 +49,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "41af576ca655cb749a5567cf903f9e9242793c77" | ||
"gitHead": "39eec40d12c826548b636c057fdb8572adfe611f" | ||
} |
@@ -70,4 +70,5 @@ // luma.gl | ||
} | ||
const color = message.type === 'error' ? 'red' : '#8B4000'; // dark orange | ||
return options?.html | ||
? `<div class='luma-compiler-log-error' style="color:red;"><b> ${message.type.toUpperCase()}: ${ | ||
? `<div class='luma-compiler-log-error' style="color:${color};"><b> ${message.type.toUpperCase()}: ${ | ||
message.message | ||
@@ -74,0 +75,0 @@ }</b></div>` |
@@ -11,39 +11,24 @@ // luma.gl | ||
const isPage: boolean = isBrowser() && typeof document !== 'undefined'; | ||
const isPageLoaded: () => boolean = () => isPage && document.readyState === 'complete'; | ||
/** Properties for a CanvasContext */ | ||
export type CanvasContextProps = { | ||
/** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */ | ||
/** If a canvas not supplied, one will be created and added to the DOM. If a string, a canvas with that id will be looked up in the DOM */ | ||
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; | ||
/** If new canvas is created, it will be created in the specified container, otherwise appended to body */ | ||
/** If new canvas is created, it will be created in the specified container, otherwise is appended as a child of document.body */ | ||
container?: HTMLElement | string | null; | ||
/** Width in pixels of the canvas */ | ||
/** Width in pixels of the canvas - used when creating a new canvas */ | ||
width?: number; | ||
/** Height in pixels of the canvas */ | ||
/** Height in pixels of the canvas - used when creating a new canvas */ | ||
height?: number; | ||
/** Visibility (only used if new canvas is created). */ | ||
visible?: boolean; | ||
/** Whether to apply a device pixels scale factor (`true` uses browser DPI) */ | ||
useDevicePixels?: boolean | number; | ||
/** Whether to track resizes (if not ) */ | ||
/** Whether to track window resizes */ | ||
autoResize?: boolean; | ||
/** Visibility (only used if new canvas is created). */ | ||
visible?: boolean; | ||
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */ | ||
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#alphamode */ | ||
alphaMode?: 'opaque' | 'premultiplied'; | ||
/** https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#colorspace */ | ||
colorSpace?: 'srgb'; // GPUPredefinedColorSpace | ||
/** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */ | ||
alphaMode?: 'opaque' | 'premultiplied'; | ||
}; | ||
const DEFAULT_CANVAS_CONTEXT_PROPS: Required<CanvasContextProps> = { | ||
canvas: null, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
useDevicePixels: true, | ||
autoResize: true, | ||
container: null, | ||
visible: true, | ||
colorSpace: 'srgb', | ||
alphaMode: 'opaque' | ||
}; | ||
/** | ||
@@ -57,2 +42,14 @@ * Manages a canvas. Supports both HTML or offscreen canvas | ||
export abstract class CanvasContext { | ||
static defaultProps: Required<CanvasContextProps> = { | ||
canvas: null, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
useDevicePixels: true, | ||
autoResize: true, | ||
container: null, | ||
visible: true, | ||
alphaMode: 'opaque', | ||
colorSpace: 'srgb' | ||
}; | ||
abstract readonly device: Device; | ||
@@ -79,17 +76,4 @@ readonly id: string; | ||
/** Check if the DOM is loaded */ | ||
static get isPageLoaded(): boolean { | ||
return isPageLoaded(); | ||
} | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded: Promise<void> = getPageLoadPromise(); | ||
constructor(props?: CanvasContextProps) { | ||
this.props = {...DEFAULT_CANVAS_CONTEXT_PROPS, ...props}; | ||
this.props = {...CanvasContext.defaultProps, ...props}; | ||
props = this.props; | ||
@@ -334,18 +318,5 @@ | ||
/** Returns a promise that resolves when the page is loaded */ | ||
function getPageLoadPromise(): Promise<void> { | ||
if (isPageLoaded() || typeof window === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
return new Promise(resolve => { | ||
window.addEventListener('load', () => resolve()); | ||
}); | ||
} | ||
function getContainer(container: HTMLElement | string | null): HTMLElement { | ||
if (typeof container === 'string') { | ||
const element = document.getElementById(container); | ||
if (!element && !isPageLoaded()) { | ||
throw new Error(`Accessing '${container}' before page was loaded`); | ||
} | ||
if (!element) { | ||
@@ -364,5 +335,2 @@ throw new Error(`${container} is not an HTML element`); | ||
const canvas = document.getElementById(canvasId); | ||
if (!canvas && !isPageLoaded()) { | ||
throw new Error(`Accessing '${canvasId}' before page was loaded`); | ||
} | ||
if (!(canvas instanceof HTMLCanvasElement)) { | ||
@@ -369,0 +337,0 @@ throw new Error('Object is not a canvas element'); |
@@ -197,50 +197,56 @@ // luma.gl | ||
export type DeviceProps = { | ||
/** string id for debugging. Stored on the object, used in logging and set on underlying GPU objects when feasible. */ | ||
id?: string; | ||
// Common parameters | ||
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; // A canvas element or a canvas string id | ||
container?: HTMLElement | string | null; | ||
width?: number /** width is only used when creating a new canvas */; | ||
height?: number /** height is only used when creating a new canvas */; | ||
/** Request a Device with the highest limits supported by platform. WebGPU: devices can be created with minimal limits. */ | ||
requestMaxLimits?: boolean; | ||
// WebGLContext PARAMETERS - Can only be set on context creation... | ||
// alpha?: boolean; // Default render target has an alpha buffer. | ||
// depth?: boolean; // Default render target has a depth buffer of at least 16 bits. | ||
// stencil?: boolean; // Default render target has a stencil buffer of at least 8 bits. | ||
// antialias?: boolean; // Boolean that indicates whether or not to perform anti-aliasing. | ||
// premultipliedAlpha?: boolean; // Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha. | ||
// preserveDrawingBuffer?: boolean; // Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten | ||
// failIfMajorPerformanceCaveat?: boolean; // Do not create if the system performance is low. | ||
/** Properties for creating a default canvas context */ | ||
createCanvasContext?: CanvasContextProps | true; | ||
/** Control which type of GPU is preferred on systems with both integrated and discrete GPU. Defaults to "high-performance" / discrete GPU. */ | ||
powerPreference?: 'default' | 'high-performance' | 'low-power'; | ||
/** Hints that device creation should fail if no hardware GPU is available (if the system performance is "low"). */ | ||
failIfMajorPerformanceCaveat?: boolean; | ||
/** Error handling */ | ||
onError?: (error: Error) => unknown; | ||
// @deprecated Attach to existing context. Rename to handle? Use Device.attach? | ||
gl?: WebGL2RenderingContext | null; | ||
/** WebGL specific: Properties passed through to WebGL2RenderingContext creation: `canvas.getContext('webgl2', props.webgl)` */ | ||
webgl?: WebGLContextProps; | ||
// DEBUG SETTINGS | ||
/** WebGL: Instrument WebGL2RenderingContext (at the expense of performance) */ | ||
debug?: boolean; | ||
/** Break on WebGL functions matching these strings */ | ||
break?: string[]; | ||
/** WebGL: Initialize the SpectorJS WebGL debugger */ | ||
debugWithSpectorJS?: boolean; | ||
/** SpectorJS URL. Override if CDN is down or different SpectorJS version is desired */ | ||
spectorUrl?: string; | ||
/** Show shader source in browser? The default is`'error'`, meaning that logs are shown when shader compilation has errors */ | ||
debugShaders?: 'never' | 'errors' | 'warnings' | 'always'; | ||
/** Renders a small version of updated Framebuffers into the primary canvas context. Can be set in console luma.log.set('debug-framebuffers', true) */ | ||
debugFramebuffers?: boolean; | ||
/** WebGL specific - Trace WebGL calls (instruments WebGL2RenderingContext at the expense of performance). Can be set in console luma.log.set('debug-webgl', true) */ | ||
debugWebGL?: boolean; | ||
/** WebGL specific - Initialize the SpectorJS WebGL debugger. Can be set in console luma.log.set('debug-spectorjs', true) */ | ||
debugSpectorJS?: boolean; | ||
/** WebGL specific - SpectorJS URL. Override if CDN is down or different SpectorJS version is desired. */ | ||
debugSpectorJSUrl?: string; | ||
// EXPERIMENTAL SETTINGS | ||
/** Set to false to disable WebGL state management instrumentation: TODO- Unclear if still supported / useful */ | ||
manageState?: boolean; | ||
/** Initialize all features on startup */ | ||
initalizeFeatures?: boolean; | ||
// EXPERIMENTAL SETTINGS - subject to change | ||
/** WebGPU specific - Request a Device with the highest limits supported by platform. On WebGPU devices can be created with minimal limits. */ | ||
_requestMaxLimits?: boolean; | ||
/** Disable specific features */ | ||
disabledFeatures?: Partial<Record<DeviceFeature, boolean>>; | ||
_disabledFeatures?: Partial<Record<DeviceFeature, boolean>>; | ||
/** WebGL specific - Initialize all features on startup */ | ||
_initializeFeatures?: boolean; | ||
/** Never destroy cached shaders and pipelines */ | ||
_factoryDestroyPolicy?: 'unused' | 'never'; | ||
/** @deprecated Internal, Do not use directly! Use `luma.attachDevice()` to attach to pre-created contexts/devices. */ | ||
_handle?: unknown; // WebGL2RenderingContext | GPUDevice | null; | ||
}; | ||
/** WebGL independent copy of WebGLContextAttributes */ | ||
type WebGLContextProps = { | ||
alpha?: boolean; // indicates if the canvas contains an alpha buffer. | ||
desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop | ||
antialias?: boolean; // indicates whether or not to perform anti-aliasing. | ||
depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits. | ||
failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available. | ||
powerPreference?: 'default' | 'high-performance' | 'low-power'; | ||
premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha. | ||
preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author. | ||
}; | ||
/** | ||
@@ -263,8 +269,5 @@ * Create and attach devices for a specific backend. Currently static methods on each device | ||
id: null!, | ||
canvas: null, | ||
container: null, | ||
manageState: true, | ||
width: 800, // width are height are only used by headless gl | ||
height: 600, | ||
requestMaxLimits: true, | ||
powerPreference: 'high-performance', | ||
failIfMajorPerformanceCaveat: false, | ||
createCanvasContext: undefined!, | ||
@@ -274,25 +277,21 @@ // Callbacks | ||
gl: null, | ||
_factoryDestroyPolicy: 'unused', | ||
// TODO - Change these after confirming things work as expected | ||
_initializeFeatures: true, | ||
_disabledFeatures: { | ||
'compilation-status-async-webgl': true | ||
}, | ||
_requestMaxLimits: true, | ||
// alpha: undefined, | ||
// depth: undefined, | ||
// stencil: undefined, | ||
// antialias: undefined, | ||
// premultipliedAlpha: undefined, | ||
// preserveDrawingBuffer: undefined, | ||
// failIfMajorPerformanceCaveat: undefined | ||
// WebGL specific | ||
webgl: {}, | ||
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance) | ||
break: (log.get('break') as string[]) || [], | ||
debugShaders: log.get('debug-shaders') || undefined!, | ||
debugFramebuffers: Boolean(log.get('debug-framebuffers')), | ||
debugWebGL: Boolean(log.get('debug-webgl')), | ||
debugSpectorJS: undefined!, // Note: log setting is queried by the spector.js code | ||
debugSpectorJSUrl: undefined!, | ||
// WebGL specific debugging | ||
debugWithSpectorJS: undefined!, | ||
spectorUrl: undefined!, | ||
// TODO - Change these after confirming things work as expected | ||
initalizeFeatures: true, | ||
disabledFeatures: { | ||
'compilation-status-async-webgl': true | ||
}, | ||
_factoryDestroyPolicy: 'unused' | ||
// INTERNAL | ||
_handle: undefined! | ||
}; | ||
@@ -319,2 +318,4 @@ | ||
readonly statsManager: StatsManager = lumaStats; | ||
/** An abstract timestamp used for change tracking */ | ||
timestamp: number = 0; | ||
@@ -377,5 +378,5 @@ /** Used by other luma.gl modules to store data on the device */ | ||
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */ | ||
getCanvasContext(): CanvasContext { | ||
getDefaultCanvasContext(): CanvasContext { | ||
if (!this.canvasContext) { | ||
throw new Error('Device has no CanvasContext'); | ||
throw new Error('Device has no default CanvasContext. See props.createCanvasContext'); | ||
} | ||
@@ -435,2 +436,21 @@ return this.canvasContext; | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp(): number { | ||
return this.timestamp++; | ||
} | ||
// Error Handling | ||
/** Report unhandled device errors */ | ||
onError(error: Error) { | ||
this.props.onError(error); | ||
} | ||
// DEPRECATED METHODS | ||
/** @deprecated Use getDefaultCanvasContext() */ | ||
getCanvasContext(): CanvasContext { | ||
return this.getDefaultCanvasContext(); | ||
} | ||
// WebGL specific HACKS - enables app to remove webgl import | ||
@@ -500,19 +520,6 @@ // Use until we have a better way to handle these | ||
timestamp: number = 0; | ||
/** A monotonic counter for tracking buffer and texture updates */ | ||
incrementTimestamp(): number { | ||
return this.timestamp++; | ||
} | ||
// Error Handling | ||
/** Report unhandled device errors */ | ||
onError(error: Error) { | ||
this.props.onError(error); | ||
} | ||
// IMPLEMENTATION | ||
protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps { | ||
/** Subclasses use this to support .createBuffer() overloads */ | ||
protected _normalizeBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps { | ||
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) { | ||
@@ -519,0 +526,0 @@ props = {data: props}; |
@@ -6,2 +6,3 @@ // luma.gl | ||
import type {Log} from '@probe.gl/log'; | ||
import {isBrowser} from '@probe.gl/env'; | ||
import type {DeviceProps} from './device'; | ||
@@ -13,2 +14,5 @@ import {Device} from './device'; | ||
const isPage: boolean = isBrowser() && typeof document !== 'undefined'; | ||
const isPageLoaded: () => boolean = () => isPage && document.readyState === 'complete'; | ||
declare global { | ||
@@ -25,15 +29,17 @@ // eslint-disable-next-line no-var | ||
/** Properties for creating a new device */ | ||
export type CreateDeviceProps = DeviceProps & { | ||
export type CreateDeviceProps = { | ||
/** Selects the type of device. `best-available` uses webgpu if available, then webgl. */ | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
/** List of adapters. Will also search any pre-registered adapters */ | ||
adapters?: Adapter[]; | ||
}; | ||
} & DeviceProps; | ||
/** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */ | ||
export type AttachDeviceProps = DeviceProps & { | ||
export type AttachDeviceProps = { | ||
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available'; | ||
/** Externally created WebGL context or WebGPU device */ | ||
handle: unknown; // WebGL2RenderingContext | GPUDevice | null; | ||
/** List of adapters. Will also search any pre-registered adapterss */ | ||
/** List of adapters. Will also search any pre-registered adapters */ | ||
adapters?: Adapter[]; | ||
}; | ||
} & DeviceProps; | ||
@@ -52,2 +58,12 @@ /** | ||
/** | ||
* Get a 'lazy' promise that resolves when the DOM is loaded. | ||
* @note Since there may be limitations on number of `load` event listeners, | ||
* it is recommended avoid calling this function until actually needed. | ||
* I.e. don't call it until you know that you will be looking up a string in the DOM. | ||
*/ | ||
static pageLoaded: Promise<void> = getPageLoadPromise().then(() => { | ||
log.probe(2, 'DOM is loaded')(); | ||
}); | ||
/** Global stats for all devices */ | ||
@@ -131,2 +147,6 @@ readonly stats: StatsManager = lumaStats; | ||
if (props.createCanvasContext) { | ||
await Luma.pageLoaded; | ||
} | ||
const adapterMap = this.getAdapterMap(props.adapters); | ||
@@ -160,2 +180,6 @@ | ||
if (props.createCanvasContext) { | ||
await Luma.pageLoaded; | ||
} | ||
// TODO - WebGPU does not yet have a stable API | ||
@@ -225,1 +249,13 @@ // if (props.handle instanceof GPUDevice) { | ||
export const luma = new Luma(); | ||
// HELPER FUNCTIONS | ||
/** Returns a promise that resolves when the page is loaded */ | ||
function getPageLoadPromise(): Promise<void> { | ||
if (isPageLoaded() || typeof window === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
return new Promise(resolve => { | ||
window.addEventListener('load', () => resolve()); | ||
}); | ||
} |
@@ -64,3 +64,3 @@ // luma.gl | ||
abstract byteLength: number; | ||
/** "Time" of last update */ | ||
/** "Time" of last update, can be used to check if redraw is needed */ | ||
updateTimestamp: number; | ||
@@ -80,6 +80,10 @@ | ||
// Remove data from props before storing, we don't want to hold on to a big chunk of memory | ||
delete deducedProps.data; | ||
super(device, deducedProps, Buffer.defaultProps); | ||
this.usage = props.usage || 0; | ||
this.usage = deducedProps.usage || 0; | ||
this.indexType = deducedProps.indexType; | ||
// TODO - perhaps this should be set on async write completion? | ||
@@ -89,4 +93,13 @@ this.updateTimestamp = device.incrementTimestamp(); | ||
/** | ||
* Create a copy of this Buffer with new byteLength, with same props but of the specified size. | ||
* @note Does not copy contents of the cloned Buffer. | ||
*/ | ||
clone(props: {byteLength: number}): Buffer { | ||
return this.device.createBuffer({...this.props, ...props}); | ||
} | ||
/** Write data to buffer */ | ||
abstract write(data: ArrayBufferView, byteOffset?: number): void; | ||
/** Read data asynchronously */ | ||
@@ -104,2 +117,3 @@ abstract readAsync(byteOffset?: number, byteLength?: number): Promise<Uint8Array>; | ||
static DEBUG_DATA_MAX_LENGTH = 32; | ||
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */ | ||
@@ -106,0 +120,0 @@ debugData: ArrayBuffer = new ArrayBuffer(0); |
@@ -33,5 +33,5 @@ // luma.gl | ||
export type CopyBufferToBufferOptions = { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
sourceOffset?: number; | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
destinationOffset?: number; | ||
@@ -42,5 +42,5 @@ size: number; | ||
export type CopyBufferToTextureOptions = { | ||
source: Buffer; | ||
sourceBuffer: Buffer; | ||
byteOffset?: number; | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
mipLevel?: number; // = 0; | ||
@@ -56,3 +56,3 @@ origin?: [number, number, number] | number[]; | ||
/** Texture to copy to/from. */ | ||
source: Texture; | ||
sourceTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -73,3 +73,3 @@ mipLevel?: number; | ||
/** Destination buffer */ | ||
destination: Buffer; | ||
destinationBuffer: Buffer; | ||
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */ | ||
@@ -92,3 +92,3 @@ byteOffset?: number; | ||
/** Texture to copy to/from. */ | ||
source: Texture; | ||
sourceTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -102,3 +102,3 @@ mipLevel?: number; | ||
/** Texture to copy to/from. */ | ||
destination: Texture; | ||
destinationTexture: Texture; | ||
/** Mip-map level of the texture to copy to/from. (Default 0) */ | ||
@@ -105,0 +105,0 @@ destinationMipLevel?: number; |
@@ -56,4 +56,20 @@ // luma.gl | ||
/** | ||
* Create a copy of this framebuffer with new attached textures, with same props but of the specified size. | ||
* @note Does not copy contents of the attached textures. | ||
*/ | ||
clone(size?: {width: number; height: number}): Framebuffer { | ||
const colorAttachments = this.colorAttachments.map(colorAttachment => | ||
colorAttachment.texture.clone(size) | ||
); | ||
const depthStencilAttachment = | ||
this.depthStencilAttachment && this.depthStencilAttachment.texture.clone(size); | ||
return this.device.createFramebuffer({...this.props, colorAttachments, depthStencilAttachment}); | ||
} | ||
/** | ||
* Resizes all attachments | ||
* @note resize() destroys existing textures (if size has changed). | ||
* @deprecated Use framebuffer.clone() | ||
*/ | ||
@@ -145,3 +161,3 @@ resize(size: {width: number; height: number}): void; | ||
if (this.colorAttachments[i]) { | ||
const resizedTexture = this.colorAttachments[i].texture.createResizedTexture({ | ||
const resizedTexture = this.colorAttachments[i].texture.clone({ | ||
width, | ||
@@ -157,3 +173,3 @@ height | ||
if (this.depthStencilAttachment) { | ||
const resizedTexture = this.depthStencilAttachment.texture.createResizedTexture({ | ||
const resizedTexture = this.depthStencilAttachment.texture.clone({ | ||
width, | ||
@@ -160,0 +176,0 @@ height |
@@ -62,5 +62,5 @@ // luma.gl | ||
parameters: undefined!, | ||
clearColor: [0, 0, 0, 0], | ||
clearDepth: 1, | ||
clearStencil: 0, | ||
clearColor: false, | ||
clearDepth: false, | ||
clearStencil: false, | ||
depthReadOnly: false, | ||
@@ -67,0 +67,0 @@ stencilReadOnly: false, |
@@ -26,4 +26,4 @@ // luma.gl | ||
entryPoint?: string; | ||
/** Show shader source in browser? */ | ||
debug?: 'never' | 'errors' | 'warnings' | 'always'; | ||
/** Show shader source in browser? Overrides the device.props.debugShaders setting */ | ||
debugShaders?: 'never' | 'errors' | 'warnings' | 'always'; | ||
}; | ||
@@ -43,3 +43,3 @@ | ||
entryPoint: 'main', | ||
debug: 'errors' | ||
debugShaders: undefined! | ||
}; | ||
@@ -60,2 +60,3 @@ | ||
constructor(device: Device, props: ShaderProps) { | ||
props = {...props, debugShaders: props.debugShaders || device.props.debugShaders || 'errors'}; | ||
super(device, {id: getShaderIdFromProps(props), ...props}, Shader.defaultProps); | ||
@@ -66,2 +67,4 @@ this.stage = this.props.stage; | ||
abstract get asyncCompilationStatus(): Promise<'pending' | 'success' | 'error'>; | ||
/** Get compiler log asynchronously */ | ||
@@ -83,3 +86,4 @@ abstract getCompilationInfo(): Promise<readonly CompilerMessage[]>; | ||
/** In browser logging of errors */ | ||
async debugShader(trigger = this.props.debug): Promise<void> { | ||
async debugShader(): Promise<void> { | ||
const trigger = this.props.debugShaders; | ||
switch (trigger) { | ||
@@ -100,3 +104,3 @@ case 'never': | ||
const messages = await this.getCompilationInfo(); | ||
if (this.props.debug === 'warnings' && messages?.length === 0) { | ||
if (trigger === 'warnings' && messages?.length === 0) { | ||
return; | ||
@@ -103,0 +107,0 @@ } |
@@ -346,8 +346,7 @@ // luma.gl | ||
/** | ||
* Create a new texture with the same parameters but a different size | ||
* | ||
* Create a new texture with the same parameters and optionally, a different size | ||
* @note Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size. | ||
* @note Does not copy contents of the texture | ||
*/ | ||
createResizedTexture(size: {width: number; height: number}): Texture { | ||
clone(size?: {width: number; height: number}): Texture { | ||
return this.device.createTexture({...this.props, ...size}); | ||
@@ -354,0 +353,0 @@ } |
@@ -14,3 +14,3 @@ // luma.gl | ||
const REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
const RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/; | ||
@@ -62,3 +62,3 @@ export type DecodedTextureFormat = { | ||
export function decodeTextureFormat(format: TextureFormat): DecodedTextureFormat { | ||
const matches = REGEX.exec(format as string); | ||
const matches = RGB_FORMAT_REGEX.exec(format as string); | ||
if (matches) { | ||
@@ -65,0 +65,0 @@ const [, channels, length, type, srgb, suffix] = matches; |
@@ -6,2 +6,3 @@ // luma.gl | ||
// MAIN API ACCESS POINT | ||
export type {AttachDeviceProps, CreateDeviceProps} from './adapter/luma'; | ||
export {luma} from './adapter/luma'; | ||
@@ -8,0 +9,0 @@ |
@@ -40,3 +40,3 @@ // luma.gl | ||
const binding = props?.shaderLayout.bindings?.find( | ||
binding => binding.type === 'uniform' && binding.name === props?.name | ||
binding_ => binding_.type === 'uniform' && binding_.name === props?.name | ||
); | ||
@@ -43,0 +43,0 @@ if (!binding) { |
@@ -156,3 +156,3 @@ // luma.gl | ||
const uniformBlock = this.uniformBlocks.get(uniformBufferName); | ||
const uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
let uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
@@ -165,3 +165,3 @@ let reason: false | string = false; | ||
const uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
uniformBuffer = this.uniformBuffers.get(uniformBufferName); | ||
uniformBuffer?.write(uniformBufferData); | ||
@@ -168,0 +168,0 @@ |
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
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
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
885319
15956