Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@luma.gl/api

Package Overview
Dependencies
Maintainers
7
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/api - npm Package Compare versions

Comparing version 9.0.0-alpha.16 to 9.0.0-alpha.17

dist.min.js

4

dist/adapter/canvas-context.d.ts

@@ -0,5 +1,7 @@

/// <reference types="dist" />
/// <reference types="offscreencanvas" />
import type Device from './device';
import type Framebuffer from './resources/framebuffer';
/** Properties for a CanvasContext */
export type CanvasContextProps = {
export declare type CanvasContextProps = {
/** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */

@@ -6,0 +8,0 @@ canvas?: HTMLCanvasElement | OffscreenCanvas | string | null;

@@ -1,318 +0,253 @@

// luma.gl, MIT license
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { isBrowser } from '@probe.gl/env';
import { log } from '../lib/utils/log.js';
import { log } from "../lib/utils/log.js";
const isPage = isBrowser() && typeof document !== 'undefined';
const isPageLoaded = () => isPage && document.readyState === 'complete';
const DEFAULT_CANVAS_CONTEXT_PROPS = {
canvas: null,
width: 800,
height: 600,
useDevicePixels: true,
autoResize: true,
container: null,
visible: true,
colorSpace: 'srgb',
alphaMode: 'opaque'
canvas: null,
width: 800,
height: 600,
useDevicePixels: true,
autoResize: true,
container: null,
visible: true,
colorSpace: 'srgb',
alphaMode: 'opaque'
};
/**
* Manages a canvas. Supports both HTML or offscreen canvas
* - Creates a new canvas or looks up a canvas from the DOM
* - Provides check for DOM loaded
* @todo commit(): https://github.com/w3ctag/design-reviews/issues/288
* @todo transferControlToOffscreen: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
*/
class CanvasContext {
/** Check if the DOM is loaded */
static get isPageLoaded() {
return isPageLoaded();
export default class CanvasContext {
static get isPageLoaded() {
return isPageLoaded();
}
constructor(props) {
_defineProperty(this, "device", void 0);
_defineProperty(this, "id", void 0);
_defineProperty(this, "props", void 0);
_defineProperty(this, "canvas", void 0);
_defineProperty(this, "htmlCanvas", void 0);
_defineProperty(this, "offscreenCanvas", void 0);
_defineProperty(this, "type", void 0);
_defineProperty(this, "width", 1);
_defineProperty(this, "height", 1);
_defineProperty(this, "resizeObserver", void 0);
_defineProperty(this, "_canvasSizeInfo", {
clientWidth: 0,
clientHeight: 0,
devicePixelRatio: 1
});
this.props = {
...DEFAULT_CANVAS_CONTEXT_PROPS,
...props
};
props = this.props;
if (!isBrowser()) {
this.id = 'node-canvas-context';
this.type = 'node';
this.width = this.props.width;
this.height = this.props.height;
this.canvas = null;
return;
}
constructor(props) {
this.width = 1;
this.height = 1;
/** State used by luma.gl classes: TODO - move to canvasContext*/
this._canvasSizeInfo = { clientWidth: 0, clientHeight: 0, devicePixelRatio: 1 };
this.props = { ...DEFAULT_CANVAS_CONTEXT_PROPS, ...props };
props = this.props;
if (!isBrowser()) {
this.id = 'node-canvas-context';
this.type = 'node';
this.width = this.props.width;
this.height = this.props.height;
// TODO - does this prevent app from using jsdom style polyfills?
this.canvas = null;
return;
}
if (!props.canvas) {
const canvas = createCanvas(props);
const container = getContainer(props?.container || null);
container.insertBefore(canvas, container.firstChild);
this.canvas = canvas;
if (!props?.visible) {
this.canvas.style.visibility = 'hidden';
}
}
else if (typeof props.canvas === 'string') {
this.canvas = getCanvasFromDOM(props.canvas);
}
else {
this.canvas = props.canvas;
}
if (this.canvas instanceof HTMLCanvasElement) {
this.id = this.canvas.id;
this.type = 'html-canvas';
this.htmlCanvas = this.canvas;
}
else {
this.id = 'offscreen-canvas';
this.type = 'offscreen-canvas';
this.offscreenCanvas = this.canvas;
}
// React to size changes
if (this.canvas instanceof HTMLCanvasElement && props.autoResize) {
this.resizeObserver = new ResizeObserver((entries) => {
for (const entry of entries) {
if (entry.target === this.canvas) {
this.update();
}
}
});
this.resizeObserver.observe(this.canvas);
}
if (!props.canvas) {
var _props, _props2;
const canvas = createCanvas(props);
const container = getContainer(((_props = props) === null || _props === void 0 ? void 0 : _props.container) || null);
container.insertBefore(canvas, container.firstChild);
this.canvas = canvas;
if (!((_props2 = props) !== null && _props2 !== void 0 && _props2.visible)) {
this.canvas.style.visibility = 'hidden';
}
} else if (typeof props.canvas === 'string') {
this.canvas = getCanvasFromDOM(props.canvas);
} else {
this.canvas = props.canvas;
}
/**
* Returns the current DPR, if props.useDevicePixels is true
* Device refers to physical
*/
getDevicePixelRatio(useDevicePixels) {
if (typeof OffscreenCanvas !== 'undefined' && this.canvas instanceof OffscreenCanvas) {
return 1;
}
// The param was mainly provide to support the test cases, could be removed
if (typeof useDevicePixels === 'number') {
return useDevicePixels > 0 ? useDevicePixels : 1;
}
if (typeof this.props.useDevicePixels === 'number') {
return this.props.useDevicePixels > 0 ? this.props.useDevicePixels : 1;
}
return useDevicePixels || this.props.useDevicePixels
? (typeof window !== 'undefined' && window.devicePixelRatio) || 1
: 1;
if (this.canvas instanceof HTMLCanvasElement) {
this.id = this.canvas.id;
this.type = 'html-canvas';
this.htmlCanvas = this.canvas;
} else {
this.id = 'offscreen-canvas';
this.type = 'offscreen-canvas';
this.offscreenCanvas = this.canvas;
}
/**
* Returns the size of drawing buffer in device pixels.
* @note This can be different from the 'CSS' size of a canvas, and also from the
* canvas' internal drawing buffer size (.width, .height).
* This is the size required to cover the canvas, adjusted for DPR
*/
getPixelSize() {
switch (this.type) {
case 'node':
return [this.width, this.height];
case 'offscreen-canvas':
return [this.canvas.width, this.canvas.height];
case 'html-canvas':
const dpr = this.getDevicePixelRatio();
const canvas = this.canvas;
// If not attached to DOM client size can be 0
return canvas.parentElement
? [canvas.clientWidth * dpr, canvas.clientHeight * dpr]
: [this.canvas.width, this.canvas.height];
if (this.canvas instanceof HTMLCanvasElement && props.autoResize) {
this.resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
if (entry.target === this.canvas) {
this.update();
}
}
});
this.resizeObserver.observe(this.canvas);
}
getAspect() {
const [width, height] = this.getPixelSize();
return width / height;
}
getDevicePixelRatio(useDevicePixels) {
if (typeof OffscreenCanvas !== 'undefined' && this.canvas instanceof OffscreenCanvas) {
return 1;
}
/**
* Returns multiplier need to convert CSS size to Device size
*/
cssToDeviceRatio() {
try {
// For headless gl we might have used custom width and height
// hence use cached clientWidth
const [drawingBufferWidth] = this.getDrawingBufferSize();
const { clientWidth } = this._canvasSizeInfo;
return clientWidth ? drawingBufferWidth / clientWidth : 1;
}
catch {
return 1;
}
if (typeof useDevicePixels === 'number') {
return useDevicePixels > 0 ? useDevicePixels : 1;
}
/**
* Maps CSS pixel position to device pixel position
*/
cssToDevicePixels(cssPixel, yInvert = true) {
const ratio = this.cssToDeviceRatio();
const [width, height] = this.getDrawingBufferSize();
return scalePixels(cssPixel, ratio, width, height, yInvert);
if (typeof this.props.useDevicePixels === 'number') {
return this.props.useDevicePixels > 0 ? this.props.useDevicePixels : 1;
}
/**
* Use devicePixelRatio to set canvas width and height
* @note this is a raw port of luma.gl v8 code. Might be worth a review
*/
setDevicePixelRatio(devicePixelRatio, options = {}) {
if (!this.htmlCanvas) {
return;
}
// NOTE: if options.width and options.height not used remove in v8
let clientWidth = 'width' in options ? options.width : this.htmlCanvas.clientWidth;
let clientHeight = 'height' in options ? options.height : this.htmlCanvas.clientHeight;
if (!clientWidth || !clientHeight) {
log.log(1, 'Canvas clientWidth/clientHeight is 0')();
// by forcing devicePixel ratio to 1, we do not scale canvas.width and height in each frame.
devicePixelRatio = 1;
clientWidth = this.htmlCanvas.width || 1;
clientHeight = this.htmlCanvas.height || 1;
}
const cachedSize = this._canvasSizeInfo;
// Check if canvas needs to be resized
if (cachedSize.clientWidth !== clientWidth ||
cachedSize.clientHeight !== clientHeight ||
cachedSize.devicePixelRatio !== devicePixelRatio) {
let clampedPixelRatio = devicePixelRatio;
const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
this.htmlCanvas.width = canvasWidth;
this.htmlCanvas.height = canvasHeight;
// Note: when devicePixelRatio is too high, it is possible we might hit system limit for
// drawing buffer width and hight, in those cases they get clamped and resulting aspect ration may not be maintained
// for those cases, reduce devicePixelRatio.
const [drawingBufferWidth, drawingBufferHeight] = this.getDrawingBufferSize();
if (drawingBufferWidth !== canvasWidth || drawingBufferHeight !== canvasHeight) {
clampedPixelRatio = Math.min(drawingBufferWidth / clientWidth, drawingBufferHeight / clientHeight);
this.htmlCanvas.width = Math.floor(clientWidth * clampedPixelRatio);
this.htmlCanvas.height = Math.floor(clientHeight * clampedPixelRatio);
log.warn(`Device pixel ratio clamped`)();
}
this._canvasSizeInfo.clientWidth = clientWidth;
this._canvasSizeInfo.clientHeight = clientHeight;
this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;
}
return useDevicePixels || this.props.useDevicePixels ? typeof window !== 'undefined' && window.devicePixelRatio || 1 : 1;
}
getPixelSize() {
switch (this.type) {
case 'node':
return [this.width, this.height];
case 'offscreen-canvas':
return [this.canvas.width, this.canvas.height];
case 'html-canvas':
const dpr = this.getDevicePixelRatio();
const canvas = this.canvas;
return canvas.parentElement ? [canvas.clientWidth * dpr, canvas.clientHeight * dpr] : [this.canvas.width, this.canvas.height];
default:
throw new Error(this.type);
}
// PRIVATE
/** @todo Major hack done to port the CSS methods above, base canvas context should not depend on WebGL */
getDrawingBufferSize() {
// @ts-expect-error This only works for WebGL
const gl = this.device.gl;
if (!gl) {
// use default device pixel ratio
throw new Error('canvas size');
}
return [gl.drawingBufferWidth, gl.drawingBufferHeight];
}
getAspect() {
const [width, height] = this.getPixelSize();
return width / height;
}
cssToDeviceRatio() {
try {
const [drawingBufferWidth] = this.getDrawingBufferSize();
const {
clientWidth
} = this._canvasSizeInfo;
return clientWidth ? drawingBufferWidth / clientWidth : 1;
} catch {
return 1;
}
/**
* Allows subclass constructor to override the canvas id for auto created canvases.
* This can really help when debugging DOM in apps that create multiple devices
*/
_setAutoCreatedCanvasId(id) {
if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {
this.htmlCanvas.id = id;
}
}
cssToDevicePixels(cssPixel) {
let yInvert = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
const ratio = this.cssToDeviceRatio();
const [width, height] = this.getDrawingBufferSize();
return scalePixels(cssPixel, ratio, width, height, yInvert);
}
setDevicePixelRatio(devicePixelRatio) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.htmlCanvas) {
return;
}
let clientWidth = 'width' in options ? options.width : this.htmlCanvas.clientWidth;
let clientHeight = 'height' in options ? options.height : this.htmlCanvas.clientHeight;
if (!clientWidth || !clientHeight) {
log.log(1, 'Canvas clientWidth/clientHeight is 0')();
devicePixelRatio = 1;
clientWidth = this.htmlCanvas.width || 1;
clientHeight = this.htmlCanvas.height || 1;
}
const cachedSize = this._canvasSizeInfo;
if (cachedSize.clientWidth !== clientWidth || cachedSize.clientHeight !== clientHeight || cachedSize.devicePixelRatio !== devicePixelRatio) {
let clampedPixelRatio = devicePixelRatio;
const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);
const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);
this.htmlCanvas.width = canvasWidth;
this.htmlCanvas.height = canvasHeight;
const [drawingBufferWidth, drawingBufferHeight] = this.getDrawingBufferSize();
if (drawingBufferWidth !== canvasWidth || drawingBufferHeight !== canvasHeight) {
clampedPixelRatio = Math.min(drawingBufferWidth / clientWidth, drawingBufferHeight / clientHeight);
this.htmlCanvas.width = Math.floor(clientWidth * clampedPixelRatio);
this.htmlCanvas.height = Math.floor(clientHeight * clampedPixelRatio);
log.warn('Device pixel ratio clamped')();
}
this._canvasSizeInfo.clientWidth = clientWidth;
this._canvasSizeInfo.clientHeight = clientHeight;
this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;
}
}
getDrawingBufferSize() {
const gl = this.device.gl;
if (!gl) {
throw new Error('canvas size');
}
return [gl.drawingBufferWidth, gl.drawingBufferHeight];
}
_setAutoCreatedCanvasId(id) {
var _this$htmlCanvas;
if (((_this$htmlCanvas = this.htmlCanvas) === null || _this$htmlCanvas === void 0 ? void 0 : _this$htmlCanvas.id) === 'lumagl-auto-created-canvas') {
this.htmlCanvas.id = id;
}
}
}
/**
* 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.
*/
CanvasContext.pageLoaded = getPageLoadPromise();
export default CanvasContext;
// HELPER FUNCTIONS
/** Returns a promise that resolves when the page is loaded */
_defineProperty(CanvasContext, "pageLoaded", getPageLoadPromise());
function getPageLoadPromise() {
if (isPageLoaded() || typeof window === 'undefined') {
return Promise.resolve();
}
return new Promise((resolve) => {
window.addEventListener('load', () => resolve());
});
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) {
throw new Error(`${container} is not an HTML element`);
}
return element;
if (typeof container === 'string') {
const element = document.getElementById(container);
if (!element && !isPageLoaded()) {
throw new Error("Accessing '".concat(container, "' before page was loaded"));
}
else if (container) {
return container;
if (!element) {
throw new Error("".concat(container, " is not an HTML element"));
}
return document.body;
return element;
} else if (container) {
return container;
}
return document.body;
}
/** Get a Canvas element from DOM id */
function getCanvasFromDOM(canvasId) {
const canvas = document.getElementById(canvasId);
if (!canvas && !isPageLoaded()) {
throw new Error(`Accessing '${canvasId}' before page was loaded`);
}
if (!(canvas instanceof HTMLCanvasElement)) {
throw new Error(`'${canvas}' is not a canvas element`);
}
return canvas;
const canvas = document.getElementById(canvasId);
if (!canvas && !isPageLoaded()) {
throw new Error("Accessing '".concat(canvasId, "' before page was loaded"));
}
if (!(canvas instanceof HTMLCanvasElement)) {
throw new Error("'".concat(canvas, "' is not a canvas element"));
}
return canvas;
}
/** Create a new canvas */
function createCanvas(props) {
const { width, height } = props;
const targetCanvas = document.createElement('canvas');
targetCanvas.id = 'lumagl-auto-created-canvas';
targetCanvas.width = width || 1;
targetCanvas.height = height || 1;
targetCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';
targetCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';
return targetCanvas;
const {
width,
height
} = props;
const targetCanvas = document.createElement('canvas');
targetCanvas.id = 'lumagl-auto-created-canvas';
targetCanvas.width = width || 1;
targetCanvas.height = height || 1;
targetCanvas.style.width = Number.isFinite(width) ? "".concat(width, "px") : '100%';
targetCanvas.style.height = Number.isFinite(height) ? "".concat(height, "px") : '100%';
return targetCanvas;
}
/**
*
* @param pixel
* @param ratio
* @param width
* @param height
* @param yInvert
* @returns
*/
function scalePixels(pixel, ratio, width, height, yInvert) {
const point = pixel;
const x = scaleX(point[0], ratio, width);
let y = scaleY(point[1], ratio, height, yInvert);
// Find boundaries of next pixel to provide valid range of device pixel locations
let t = scaleX(point[0] + 1, ratio, width);
// If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary
const xHigh = t === width - 1 ? t : t - 1;
t = scaleY(point[1] + 1, ratio, height, yInvert);
let yHigh;
if (yInvert) {
// If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
t = t === 0 ? t : t + 1;
// swap y and yHigh
yHigh = y;
y = t;
}
else {
// If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
yHigh = t === height - 1 ? t : t - 1;
// y remains same
}
return {
x,
y,
// when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.
width: Math.max(xHigh - x + 1, 1),
height: Math.max(yHigh - y + 1, 1)
};
const point = pixel;
const x = scaleX(point[0], ratio, width);
let y = scaleY(point[1], ratio, height, yInvert);
let t = scaleX(point[0] + 1, ratio, width);
const xHigh = t === width - 1 ? t : t - 1;
t = scaleY(point[1] + 1, ratio, height, yInvert);
let yHigh;
if (yInvert) {
t = t === 0 ? t : t + 1;
yHigh = y;
y = t;
} else {
yHigh = t === height - 1 ? t : t - 1;
}
return {
x,
y,
width: Math.max(xHigh - x + 1, 1),
height: Math.max(yHigh - y + 1, 1)
};
}
function scaleX(x, ratio, width) {
// since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
const r = Math.min(Math.round(x * ratio), width - 1);
return r;
const r = Math.min(Math.round(x * ratio), width - 1);
return r;
}
function scaleY(y, ratio, height, yInvert) {
// since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
return yInvert
? Math.max(0, height - 1 - Math.round(y * ratio))
: Math.min(Math.round(y * ratio), height - 1);
return yInvert ? Math.max(0, height - 1 - Math.round(y * ratio)) : Math.min(Math.round(y * ratio), height - 1);
}
//# sourceMappingURL=canvas-context.js.map

@@ -0,1 +1,3 @@

/// <reference types="dist" />
/// <reference types="offscreencanvas" />
import StatsManager from '../lib/utils/stats-manager';

@@ -16,3 +18,3 @@ import { TextureFormat } from './types/texture-formats';

/** Device properties */
export type DeviceProps = {
export declare type DeviceProps = {
id?: string;

@@ -32,3 +34,3 @@ type?: 'webgl' | 'webgl1' | 'webgl2' | 'webgpu' | 'best-available';

export declare const DEFAULT_DEVICE_PROPS: Required<DeviceProps>;
export type ShadingLanguage = 'glsl' | 'wgsl';
export declare type ShadingLanguage = 'glsl' | 'wgsl';
/**

@@ -39,3 +41,3 @@ * Identifies the GPU vendor and driver.

*/
export type DeviceInfo = {
export declare type DeviceInfo = {
type: 'webgl' | 'webgl2' | 'webgpu';

@@ -52,3 +54,3 @@ vendor: string;

/** Limits for a device */
export type DeviceLimits = {
export declare type DeviceLimits = {
readonly maxTextureDimension1D?: number;

@@ -81,7 +83,7 @@ readonly maxTextureDimension2D?: number;

};
export type WebGPUDeviceFeature = 'depth-clip-control' | 'depth24unorm-stencil8' | 'depth32float-stencil8' | 'timestamp-query' | 'indirect-first-instance' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc';
export type WebGLDeviceFeature = 'webgpu' | 'webgl2' | 'webgl' | 'timer-query-webgl' | 'uniform-buffers-webgl' | 'uniforms-webgl' | 'texture-filter-linear-float32-webgl' | 'texture-filter-linear-float16-webgl' | 'texture-filter-anisotropic-webgl' | 'texture-renderable-float32-webgl' | 'texture-renderable-float16-webgl' | 'texture-renderable-rgba32float-webgl' | 'texture-blend-float-webgl1' | 'texture-formats-norm16-webgl' | 'texture-formats-srgb-webgl1' | 'texture-formats-depth-webgl1' | 'texture-formats-float32-webgl1' | 'texture-formats-float16-webgl1' | 'vertex-array-object-webgl1' | 'instanced-rendering-webgl1' | 'multiple-render-targets-webgl1' | 'index-uint32-webgl1' | 'blend-minmax-webgl1' | 'glsl-frag-data' | 'glsl-frag-depth' | 'glsl-derivatives' | 'glsl-texture-lod';
type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
export declare type WebGPUDeviceFeature = 'depth-clip-control' | 'depth24unorm-stencil8' | 'depth32float-stencil8' | 'timestamp-query' | 'indirect-first-instance' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc';
export declare type WebGLDeviceFeature = 'webgpu' | 'webgl2' | 'webgl' | 'timer-query-webgl' | 'uniform-buffers-webgl' | 'uniforms-webgl' | 'texture-filter-linear-float32-webgl' | 'texture-filter-linear-float16-webgl' | 'texture-filter-anisotropic-webgl' | 'texture-renderable-float32-webgl' | 'texture-renderable-float16-webgl' | 'texture-renderable-rgba32float-webgl' | 'texture-blend-float-webgl1' | 'texture-formats-norm16-webgl' | 'texture-formats-srgb-webgl1' | 'texture-formats-depth-webgl1' | 'texture-formats-float32-webgl1' | 'texture-formats-float16-webgl1' | 'vertex-array-object-webgl1' | 'instanced-rendering-webgl1' | 'multiple-render-targets-webgl1' | 'index-uint32-webgl1' | 'blend-minmax-webgl1' | 'glsl-frag-data' | 'glsl-frag-depth' | 'glsl-derivatives' | 'glsl-texture-lod';
declare type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
/** Valid feature strings */
export type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures;
export declare type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures;
/**

@@ -92,2 +94,3 @@ * WebGPU Device/WebGL context abstraction

get [Symbol.toStringTag](): string;
static VERSION: string;
constructor(props: DeviceProps);

@@ -94,0 +97,0 @@ readonly id: string;

@@ -1,64 +0,66 @@

// luma.gl, MIT license
import { lumaStats } from '../lib/utils/stats-manager.js';
import { log } from '../lib/utils/log.js';
import { uid } from '../lib/utils/utils.js';
import Buffer from './resources/buffer.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import { VERSION } from "../init.js";
import { lumaStats } from "../lib/utils/stats-manager.js";
import { log } from "../lib/utils/log.js";
import { uid } from "../lib/utils/utils.js";
import Buffer from "./resources/buffer.js";
export const DEFAULT_DEVICE_PROPS = {
id: null,
type: 'best-available',
canvas: null,
container: null,
webgl2: true,
webgl1: true,
manageState: true,
width: 800,
height: 600,
debug: Boolean(log.get('debug')),
break: [],
// alpha: undefined,
// depth: undefined,
// stencil: undefined,
// antialias: undefined,
// premultipliedAlpha: undefined,
// preserveDrawingBuffer: undefined,
// failIfMajorPerformanceCaveat: undefined
gl: null
id: null,
type: 'best-available',
canvas: null,
container: null,
webgl2: true,
webgl1: true,
manageState: true,
width: 800,
height: 600,
debug: Boolean(log.get('debug')),
break: [],
gl: null
};
/**
* WebGPU Device/WebGL context abstraction
*/
_Symbol$toStringTag = Symbol.toStringTag;
export default class Device {
get [Symbol.toStringTag]() {
return 'Device';
get [_Symbol$toStringTag]() {
return 'Device';
}
constructor(props) {
_defineProperty(this, "id", void 0);
_defineProperty(this, "statsManager", lumaStats);
_defineProperty(this, "props", void 0);
_defineProperty(this, "userData", {});
_defineProperty(this, "info", void 0);
_defineProperty(this, "lost", void 0);
_defineProperty(this, "canvasContext", void 0);
this.props = {
...DEFAULT_DEVICE_PROPS,
...props
};
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
}
createBuffer(props) {
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
return this._createBuffer({
data: props
});
}
constructor(props) {
this.statsManager = lumaStats;
this.userData = {};
this.props = { ...DEFAULT_DEVICE_PROPS, ...props };
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
if (props.data instanceof Uint32Array) {
props.indexType = 'uint32';
} else if (props.data instanceof Uint16Array) {
props.indexType = 'uint16';
}
}
createBuffer(props) {
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
return this._createBuffer({ data: props });
}
// TODO - fragile, as this is done before we merge with default options
// inside the Buffer constructor
// Deduce indexType
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
if (props.data instanceof Uint32Array) {
props.indexType = 'uint32';
}
else if (props.data instanceof Uint16Array) {
props.indexType = 'uint16';
}
}
return this._createBuffer(props);
return this._createBuffer(props);
}
createTexture(props) {
if (props instanceof Promise || typeof props === 'string') {
props = {
data: props
};
}
createTexture(props) {
// Signature: new Texture2D(gl, url | Promise)
if (props instanceof Promise || typeof props === 'string') {
props = { data: props };
}
return this._createTexture(props);
}
return this._createTexture(props);
}
}
_defineProperty(Device, "VERSION", VERSION);
//# sourceMappingURL=device.js.map
import { TypedArray } from '../..';
import type Device from '../device';
import Resource, { ResourceProps } from './resource';
export type BufferProps = ResourceProps & {
export declare type BufferProps = ResourceProps & {
handle?: WebGLBuffer;

@@ -6,0 +6,0 @@ usage?: number;

@@ -1,43 +0,51 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_BUFFER_PROPS = {
...DEFAULT_RESOURCE_PROPS,
usage: 0,
byteLength: 0,
byteOffset: 0,
data: null,
indexType: 'uint16',
mappedAtCreation: false
...DEFAULT_RESOURCE_PROPS,
usage: 0,
byteLength: 0,
byteOffset: 0,
data: null,
indexType: 'uint16',
mappedAtCreation: false
};
/** Abstract GPU buffer */
class Buffer extends Resource {
get [Symbol.toStringTag]() { return 'Buffer'; }
constructor(device, props) {
const deducedProps = { ...props };
// Deduce indexType
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
if (props.data instanceof Uint32Array) {
deducedProps.indexType = 'uint32';
}
else if (props.data instanceof Uint16Array) {
deducedProps.indexType = 'uint16';
}
}
super(device, deducedProps, DEFAULT_BUFFER_PROPS);
_Symbol$toStringTag = Symbol.toStringTag;
export default class Buffer extends Resource {
get [_Symbol$toStringTag]() {
return 'Buffer';
}
constructor(device, props) {
const deducedProps = {
...props
};
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
if (props.data instanceof Uint32Array) {
deducedProps.indexType = 'uint32';
} else if (props.data instanceof Uint16Array) {
deducedProps.indexType = 'uint16';
}
}
write(data, byteOffset) { throw new Error('not implemented'); }
readAsync(byteOffset, byteLength) { throw new Error('not implemented'); }
// TODO - can sync read be supported in WebGPU?
getData() { throw new Error('not implemented'); }
super(device, deducedProps, DEFAULT_BUFFER_PROPS);
}
write(data, byteOffset) {
throw new Error('not implemented');
}
readAsync(byteOffset, byteLength) {
throw new Error('not implemented');
}
getData() {
throw new Error('not implemented');
}
}
// Usage Flags
Buffer.MAP_READ = 0x01;
Buffer.MAP_WRITE = 0x02;
Buffer.COPY_SRC = 0x0004;
Buffer.COPY_DST = 0x0008;
Buffer.INDEX = 0x0010;
Buffer.VERTEX = 0x0020;
Buffer.UNIFORM = 0x0040;
Buffer.STORAGE = 0x0080;
Buffer.INDIRECT = 0x0100;
Buffer.QUERY_RESOLVE = 0x0200;
export default Buffer;
_defineProperty(Buffer, "MAP_READ", 0x01);
_defineProperty(Buffer, "MAP_WRITE", 0x02);
_defineProperty(Buffer, "COPY_SRC", 0x0004);
_defineProperty(Buffer, "COPY_DST", 0x0008);
_defineProperty(Buffer, "INDEX", 0x0010);
_defineProperty(Buffer, "VERTEX", 0x0020);
_defineProperty(Buffer, "UNIFORM", 0x0040);
_defineProperty(Buffer, "STORAGE", 0x0080);
_defineProperty(Buffer, "INDIRECT", 0x0100);
_defineProperty(Buffer, "QUERY_RESOLVE", 0x0200);
//# sourceMappingURL=buffer.js.map
import Resource, { ResourceProps } from './resource';
import Buffer from './buffer';
import Texture from './texture';
export type WriteBufferOptions = {
export declare type WriteBufferOptions = {
buffer: Buffer;

@@ -11,3 +11,3 @@ bufferOffset?: number;

};
export type WriteTextureOptions = {
export declare type WriteTextureOptions = {
destination: Texture;

@@ -23,3 +23,3 @@ mipLevel?: number;

};
export type CopyBufferToBufferOptions = {
export declare type CopyBufferToBufferOptions = {
source: Buffer;

@@ -31,3 +31,3 @@ sourceOffset?: number;

};
export type CopyBufferToTextureOptions = {
export declare type CopyBufferToTextureOptions = {
destination: Texture;

@@ -43,5 +43,5 @@ mipLevel?: number;

};
export type CopyTextureToBufferOptions = {};
export type CopyTextureToTextureOptions = {};
export type CommandEncoderProps = ResourceProps & {
export declare type CopyTextureToBufferOptions = {};
export declare type CopyTextureToTextureOptions = {};
export declare type CommandEncoderProps = ResourceProps & {
measureExecutionTime?: boolean;

@@ -48,0 +48,0 @@ };

@@ -1,18 +0,16 @@

// luma.gl, MIT license
import Resource from './resource.js';
/**
* Encodes commands to queue that can be executed later
*/
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_COMMAND_ENCODER_PROPS = {
...DEFAULT_RESOURCE_PROPS
};
export default class CommandEncoder extends Resource {
get [Symbol.toStringTag]() {
return 'CommandEncoder';
}
constructor(props) {
// @ts-expect-error
super(props, DEFAULT_COMMAND_ENCODER_PROPS);
}
pushDebugGroup(groupLabel) { }
popDebugGroup() { }
insertDebugMarker(markerLabel) { }
get [Symbol.toStringTag]() {
return 'CommandEncoder';
}
constructor(props) {
super(props, DEFAULT_COMMAND_ENCODER_PROPS);
}
pushDebugGroup(groupLabel) {}
popDebugGroup() {}
insertDebugMarker(markerLabel) {}
}
;
//# sourceMappingURL=command-encoder.js.map

@@ -5,3 +5,3 @@ import Resource, { ResourceProps } from './resource';

import type Device from '../device';
export type ComputePassProps = ResourceProps & {};
export declare type ComputePassProps = ResourceProps & {};
export default abstract class ComputePass extends Resource<ComputePassProps> {

@@ -8,0 +8,0 @@ get [Symbol.toStringTag](): string;

@@ -1,9 +0,10 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
export default class ComputePass extends Resource {
get [Symbol.toStringTag]() {
return 'ComputePass';
}
constructor(device, props) {
super(device, props, DEFAULT_RESOURCE_PROPS);
}
get [Symbol.toStringTag]() {
return 'ComputePass';
}
constructor(device, props) {
super(device, props, DEFAULT_RESOURCE_PROPS);
}
}
//# sourceMappingURL=compute-pass.js.map

@@ -5,3 +5,3 @@ import { BindingLayout } from '../types/shader-layout';

import type Shader from './shader';
export type ComputePipelineProps = ResourceProps & {
export declare type ComputePipelineProps = ResourceProps & {
handle?: unknown;

@@ -8,0 +8,0 @@ cs: Shader;

@@ -1,21 +0,19 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
// @ts-expect-error
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_COMPUTE_PIPELINE_PROPS = {
...DEFAULT_RESOURCE_PROPS,
// cs: undefined,
// csEntryPoint: undefined,
csConstants: {},
layout: []
...DEFAULT_RESOURCE_PROPS,
csConstants: {},
layout: []
};
/**
*/
_Symbol$toStringTag = Symbol.toStringTag;
export default class ComputePipeline extends Resource {
get [Symbol.toStringTag]() {
return 'ComputePipeline';
}
constructor(device, props) {
super(device, props, DEFAULT_COMPUTE_PIPELINE_PROPS);
this.hash = '';
}
get [_Symbol$toStringTag]() {
return 'ComputePipeline';
}
constructor(device, props) {
super(device, props, DEFAULT_COMPUTE_PIPELINE_PROPS);
_defineProperty(this, "hash", '');
}
}
;
//# sourceMappingURL=compute-pipeline.js.map
import type Device from '../device';
import Resource, { ResourceProps } from './resource';
export type ExternalTextureProps = ResourceProps & {
export declare type ExternalTextureProps = ResourceProps & {
source: HTMLVideoElement | null;

@@ -5,0 +5,0 @@ colorSpace?: 'srgb';

@@ -1,12 +0,15 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_TEXTURE_PROPS = {
...DEFAULT_RESOURCE_PROPS,
source: null,
colorSpace: 'srgb'
...DEFAULT_RESOURCE_PROPS,
source: null,
colorSpace: 'srgb'
};
export default class Texture extends Resource {
get [Symbol.toStringTag]() { return 'ExternalTexture'; }
constructor(device, props) {
super(device, props, DEFAULT_TEXTURE_PROPS);
}
get [Symbol.toStringTag]() {
return 'ExternalTexture';
}
constructor(device, props) {
super(device, props, DEFAULT_TEXTURE_PROPS);
}
}
//# sourceMappingURL=external-texture.js.map

@@ -5,3 +5,3 @@ import type { ColorTextureFormat, DepthStencilTextureFormat } from '../types/texture-formats';

import Texture from './texture';
export type FramebufferProps = ResourceProps & {
export declare type FramebufferProps = ResourceProps & {
width?: number;

@@ -8,0 +8,0 @@ height?: number;

@@ -1,34 +0,37 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_FRAMEBUFFER_PROPS = {
...DEFAULT_RESOURCE_PROPS,
width: 1,
height: 1,
colorAttachments: [],
depthStencilAttachment: null // 'depth24plus-stencil8'
...DEFAULT_RESOURCE_PROPS,
width: 1,
height: 1,
colorAttachments: [],
depthStencilAttachment: null
};
/**
* Create new textures with correct size for all attachments.
* @note resize() destroys existing textures (if size has changed).
*/
_Symbol$toStringTag = Symbol.toStringTag;
export default class Framebuffer extends Resource {
get [Symbol.toStringTag]() { return 'Framebuffer'; }
constructor(device, props = {}) {
super(device, props, DEFAULT_FRAMEBUFFER_PROPS);
this.width = this.props.width;
this.height = this.props.height;
get [_Symbol$toStringTag]() {
return 'Framebuffer';
}
constructor(device) {
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
super(device, props, DEFAULT_FRAMEBUFFER_PROPS);
_defineProperty(this, "width", void 0);
_defineProperty(this, "height", void 0);
_defineProperty(this, "colorAttachments", void 0);
_defineProperty(this, "depthStencilAttachment", void 0);
this.width = this.props.width;
this.height = this.props.height;
}
resize(size) {
const updateSize = !size || size.height !== this.height || size.width !== this.width;
if (size) {
this.width = size === null || size === void 0 ? void 0 : size.width;
this.height = size === null || size === void 0 ? void 0 : size.height;
}
/**
* Resizes all attachments
* @note resize() destroys existing textures (if size has changed).
*/
resize(size) {
const updateSize = !size || (size.height !== this.height || size.width !== this.width);
if (size) {
this.width = size?.width;
this.height = size?.height;
}
if (updateSize) {
this._resizeAttachments(this.width, this.height);
}
if (updateSize) {
this._resizeAttachments(this.width, this.height);
}
}
}
//# sourceMappingURL=framebuffer.js.map

@@ -5,3 +5,3 @@ import type Device from '../device';

import Framebuffer from './framebuffer';
export type RenderPassProps = ResourceProps & {
export declare type RenderPassProps = ResourceProps & {
framebuffer?: Framebuffer | null;

@@ -8,0 +8,0 @@ parameters?: RenderPassParameters | null;

@@ -1,15 +0,15 @@

// import {Binding} from '../types/shader-layout.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_RENDERPASS_PROPS = {
...DEFAULT_RESOURCE_PROPS,
framebuffer: null,
parameters: null
...DEFAULT_RESOURCE_PROPS,
framebuffer: null,
parameters: null
};
export default class RenderPass extends Resource {
get [Symbol.toStringTag]() {
return 'RenderPass';
}
constructor(device, props) {
super(device, props, DEFAULT_RENDERPASS_PROPS);
}
get [Symbol.toStringTag]() {
return 'RenderPass';
}
constructor(device, props) {
super(device, props, DEFAULT_RENDERPASS_PROPS);
}
}
//# sourceMappingURL=render-pass.js.map

@@ -8,3 +8,3 @@ import type Device from '../device';

import type { default as RenderPass } from './render-pass';
export type RenderPipelineProps = ResourceProps & {
export declare type RenderPipelineProps = ResourceProps & {
/** Compiled vertex shader */

@@ -11,0 +11,0 @@ vs?: Shader | null;

@@ -1,35 +0,36 @@

// import {normalizeAttributeMap} from '../helpers/attribute-bindings.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
export const DEFAULT_RENDER_PIPELINE_PROPS = {
...DEFAULT_RESOURCE_PROPS,
vs: null,
vsEntryPoint: '',
vsConstants: {},
fs: null,
fsEntryPoint: '',
fsConstants: {},
layout: null,
topology: 'triangle-list',
// targets:
parameters: {},
bufferMap: [],
vertexCount: 0,
instanceCount: 0,
indices: null,
attributes: {},
bindings: {},
uniforms: {}
...DEFAULT_RESOURCE_PROPS,
vs: null,
vsEntryPoint: '',
vsConstants: {},
fs: null,
fsEntryPoint: '',
fsConstants: {},
layout: null,
topology: 'triangle-list',
parameters: {},
bufferMap: [],
vertexCount: 0,
instanceCount: 0,
indices: null,
attributes: {},
bindings: {},
uniforms: {}
};
/**
* A compiled and linked shader program
*/
class RenderPipeline extends Resource {
get [Symbol.toStringTag]() { return 'RenderPipeline'; }
constructor(device, props) {
super(device, props, DEFAULT_RENDER_PIPELINE_PROPS);
this.hash = '';
}
_Symbol$toStringTag = Symbol.toStringTag;
export default class RenderPipeline extends Resource {
get [_Symbol$toStringTag]() {
return 'RenderPipeline';
}
constructor(device, props) {
super(device, props, DEFAULT_RENDER_PIPELINE_PROPS);
_defineProperty(this, "hash", '');
_defineProperty(this, "vs", void 0);
_defineProperty(this, "fs", void 0);
}
}
/** Private "export" for Model class */
RenderPipeline._DEFAULT_PROPS = DEFAULT_RENDER_PIPELINE_PROPS;
export default RenderPipeline;
_defineProperty(RenderPipeline, "_DEFAULT_PROPS", DEFAULT_RENDER_PIPELINE_PROPS);
//# sourceMappingURL=render-pipeline.js.map
import type Device from '../device';
export type ResourceProps = {
export declare type ResourceProps = {
id?: string;

@@ -4,0 +4,0 @@ handle?: any;

@@ -1,95 +0,79 @@

import { uid } from '../../lib/utils/utils.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { uid } from "../../lib/utils/utils.js";
export const DEFAULT_RESOURCE_PROPS = {
id: 'undefined',
handle: undefined,
userData: {}
id: 'undefined',
handle: undefined,
userData: {}
};
/**
* Base class for GPU (WebGPU/WebGL) Resources
*/
export default class Resource {
/**
* Create a new Resource. Called from Subclass
*/
constructor(device, props, defaultProps) {
this.userData = {};
this.destroyed = false;
/** For resources that allocate GPU memory */
this.allocatedBytes = 0;
if (!device) {
throw new Error('no device');
}
this._device = device;
this.props = selectivelyMerge(props, defaultProps);
const id = this.props.id !== 'undefined' ? this.props.id : uid(this[Symbol.toStringTag]);
this.props.id = id;
this.id = id;
this.userData = this.props.userData || {};
this.addStats();
constructor(device, props, defaultProps) {
_defineProperty(this, "id", void 0);
_defineProperty(this, "props", void 0);
_defineProperty(this, "userData", {});
_defineProperty(this, "device", void 0);
_defineProperty(this, "_device", void 0);
_defineProperty(this, "destroyed", false);
_defineProperty(this, "allocatedBytes", 0);
if (!device) {
throw new Error('no device');
}
/**
* destroy can be called on any resource to release it before it is garbage collected.
*/
destroy() {
this.removeStats();
}
/** @deprecated Use destroy() */
delete() {
this.destroy();
return this;
}
toString() {
return `${this[Symbol.toStringTag] || this.constructor.name}(${this.id})`;
}
/**
* Combines a map of user props and default props, only including props from defaultProps
* @returns returns a map of overridden default props
*/
getProps() {
return this.props;
}
// PROTECTED METHODS
/** Called by resource constructor to track object creation */
addStats() {
const stats = this._device.statsManager.getStats('Resource Counts');
const name = this[Symbol.toStringTag];
stats.get('Resources Created').incrementCount();
stats.get(`${name}s Created`).incrementCount();
stats.get(`${name}s Active`).incrementCount();
}
/** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
removeStats() {
const stats = this._device.statsManager.getStats('Resource Counts');
const name = this[Symbol.toStringTag];
stats.get(`${name}s Active`).decrementCount();
}
/** Called by subclass to track memory allocations */
trackAllocatedMemory(bytes, name = this[Symbol.toStringTag]) {
const stats = this._device.statsManager.getStats('Resource Counts');
stats.get('GPU Memory').addCount(bytes);
stats.get(`${name} Memory`).addCount(bytes);
this.allocatedBytes = bytes;
}
/** Called by subclass to track memory deallocations */
trackDeallocatedMemory(name = this[Symbol.toStringTag]) {
const stats = this._device.statsManager.getStats('Resource Counts');
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
stats.get(`${name} Memory`).subtractCount(this.allocatedBytes);
this.allocatedBytes = 0;
}
this._device = device;
this.props = selectivelyMerge(props, defaultProps);
const id = this.props.id !== 'undefined' ? this.props.id : uid(this[Symbol.toStringTag]);
this.props.id = id;
this.id = id;
this.userData = this.props.userData || {};
this.addStats();
}
destroy() {
this.removeStats();
}
delete() {
this.destroy();
return this;
}
toString() {
return "".concat(this[Symbol.toStringTag] || this.constructor.name, "(").concat(this.id, ")");
}
getProps() {
return this.props;
}
addStats() {
const stats = this._device.statsManager.getStats('Resource Counts');
const name = this[Symbol.toStringTag];
stats.get('Resources Created').incrementCount();
stats.get("".concat(name, "s Created")).incrementCount();
stats.get("".concat(name, "s Active")).incrementCount();
}
removeStats() {
const stats = this._device.statsManager.getStats('Resource Counts');
const name = this[Symbol.toStringTag];
stats.get("".concat(name, "s Active")).decrementCount();
}
trackAllocatedMemory(bytes) {
let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this[Symbol.toStringTag];
const stats = this._device.statsManager.getStats('Resource Counts');
stats.get('GPU Memory').addCount(bytes);
stats.get("".concat(name, " Memory")).addCount(bytes);
this.allocatedBytes = bytes;
}
trackDeallocatedMemory() {
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this[Symbol.toStringTag];
const stats = this._device.statsManager.getStats('Resource Counts');
stats.get('GPU Memory').subtractCount(this.allocatedBytes);
stats.get("".concat(name, " Memory")).subtractCount(this.allocatedBytes);
this.allocatedBytes = 0;
}
}
/**
* Combines a map of user props and default props, only including props from defaultProps
* @param props
* @param defaultProps
* @returns returns a map of overridden default props
*/
function selectivelyMerge(props, defaultProps) {
const mergedProps = { ...defaultProps };
for (const key in props) {
if (props[key] !== undefined) {
mergedProps[key] = props[key];
}
const mergedProps = {
...defaultProps
};
for (const key in props) {
if (props[key] !== undefined) {
mergedProps[key] = props[key];
}
return mergedProps;
}
return mergedProps;
}
//# sourceMappingURL=resource.js.map
import type Device from '../device';
import { CompareFunction } from '../types/parameters';
import Resource, { ResourceProps } from './resource';
export type SamplerAddressMode = 'clamp-to-edge' | 'repeat' | 'mirror-repeat';
export type SamplerFilterMode = 'nearest' | 'linear';
export declare type SamplerAddressMode = 'clamp-to-edge' | 'repeat' | 'mirror-repeat';
export declare type SamplerFilterMode = 'nearest' | 'linear';
/**
* Properties for initializing a sampler
*/
export type SamplerProps = ResourceProps & {
export declare type SamplerProps = ResourceProps & {
type?: 'color-sampler' | 'comparison-sampler';

@@ -22,3 +22,3 @@ addressModeU?: 'clamp-to-edge' | 'repeat' | 'mirror-repeat';

};
export type SamplerParameters = Omit<SamplerProps, keyof ResourceProps>;
export declare type SamplerParameters = Omit<SamplerProps, keyof ResourceProps>;
/** Immutable Sampler object */

@@ -25,0 +25,0 @@ export default abstract class Sampler extends Resource<SamplerProps> {

@@ -1,25 +0,24 @@

// luma.gl, MIT license
import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_SAMPLER_PROPS = {
...DEFAULT_RESOURCE_PROPS,
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
...DEFAULT_RESOURCE_PROPS,
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
};
/** Immutable Sampler object */
export default class Sampler extends Resource {
get [Symbol.toStringTag]() {
return 'Sampler';
}
constructor(device, props) {
super(device, props, DEFAULT_SAMPLER_PROPS);
}
get [Symbol.toStringTag]() {
return 'Sampler';
}
constructor(device, props) {
super(device, props, DEFAULT_SAMPLER_PROPS);
}
}
//# sourceMappingURL=sampler.js.map
import type Device from '../device';
import Resource, { ResourceProps } from './resource';
export type CompilerMessageType = 'error' | 'warning' | 'info';
export type CompilerMessage = {
export declare type CompilerMessageType = 'error' | 'warning' | 'info';
export declare type CompilerMessage = {
type: CompilerMessageType;

@@ -13,3 +13,3 @@ message: string;

*/
export type ShaderProps = ResourceProps & {
export declare type ShaderProps = ResourceProps & {
stage: 'vertex' | 'fragment' | 'compute';

@@ -16,0 +16,0 @@ source: string;

@@ -1,21 +0,25 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_SHADER_PROPS = {
...DEFAULT_RESOURCE_PROPS,
stage: 'vertex',
source: '',
sourceMap: null,
language: 'glsl',
shaderType: 0
...DEFAULT_RESOURCE_PROPS,
stage: 'vertex',
source: '',
sourceMap: null,
language: 'glsl',
shaderType: 0
};
/**
* Immutable Shader object
* In WebGPU the handle can be copied between threads
*/
_Symbol$toStringTag = Symbol.toStringTag;
export default class Shader extends Resource {
get [Symbol.toStringTag]() { return 'Shader'; }
constructor(device, props) {
super(device, props, DEFAULT_SHADER_PROPS);
this.stage = this.props.stage;
this.source = this.props.source;
}
get [_Symbol$toStringTag]() {
return 'Shader';
}
constructor(device, props) {
super(device, props, DEFAULT_SHADER_PROPS);
_defineProperty(this, "stage", void 0);
_defineProperty(this, "source", void 0);
this.stage = this.props.stage;
this.source = this.props.source;
}
}
//# sourceMappingURL=shader.js.map

@@ -1,2 +0,2 @@

/// <reference types="@types/node" />
/// <reference types="node" />
import type Device from '../device';

@@ -8,6 +8,6 @@ import type { TypedArray } from '../../types';

/** Data types that can be used to initialize textures */
export type TextureData = TypedArray | ArrayBuffer | Buffer | ImageBitmap | HTMLImageElement;
export type CubeTextureData = Record<string, TextureData> | Record<string, Promise<TextureData>>;
export type ExternalTextureData = HTMLVideoElement;
export type DeprecatedWebGLTextureProps = {
export declare type TextureData = TypedArray | ArrayBuffer | Buffer | ImageBitmap | HTMLImageElement;
export declare type CubeTextureData = Record<string, TextureData> | Record<string, Promise<TextureData>>;
export declare type ExternalTextureData = HTMLVideoElement;
export declare type DeprecatedWebGLTextureProps = {
/** @deprecated use props.sampler */

@@ -31,3 +31,3 @@ parameters?: Record<number, number>;

/** Abstract Texture interface */
export type TextureProps = ResourceProps & DeprecatedWebGLTextureProps & {
export declare type TextureProps = ResourceProps & DeprecatedWebGLTextureProps & {
format?: TextureFormat | number;

@@ -47,3 +47,3 @@ dimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';

};
export type WebGPUTextureProps = ResourceProps & {
export declare type WebGPUTextureProps = ResourceProps & {
width: number;

@@ -55,3 +55,3 @@ height: number;

};
export type TextureViewProps = {
export declare type TextureViewProps = {
format: string;

@@ -58,0 +58,0 @@ dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';

@@ -1,46 +0,35 @@

import Resource, { DEFAULT_RESOURCE_PROPS } from './resource.js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
let _Symbol$toStringTag;
import Resource, { DEFAULT_RESOURCE_PROPS } from "./resource.js";
const DEFAULT_TEXTURE_PROPS = {
...DEFAULT_RESOURCE_PROPS,
data: null,
dimension: '2d',
format: 'rgba8unorm',
// width: undefined,
// height: undefined,
depth: 1,
mipmaps: true,
sampler: {},
// type: undefined,
compressed: false,
// mipLevels: 1,
usage: 0,
parameters: {},
pixelStore: {},
pixels: null,
border: 0,
recreate: false
...DEFAULT_RESOURCE_PROPS,
data: null,
dimension: '2d',
format: 'rgba8unorm',
depth: 1,
mipmaps: true,
sampler: {},
compressed: false,
usage: 0,
parameters: {},
pixelStore: {},
pixels: null,
border: 0,
recreate: false
};
// const DEFAULT_TEXTURE_PROPS: Required<TextureProps> = {
// handle: undefined,
// id: undefined,
// depth: 1,
// format: 'rgba8unorm',
// usage: GPUTextureUsage.COPY_DST
// };
/**
* Abstract Texture interface
* Texture Object
* https://gpuweb.github.io/gpuweb/#gputexture
*/
class Texture extends Resource {
get [Symbol.toStringTag]() { return 'Texture'; }
constructor(device, props) {
// @ts-expect-error
super(device, props, DEFAULT_TEXTURE_PROPS);
}
_Symbol$toStringTag = Symbol.toStringTag;
export default class Texture extends Resource {
get [_Symbol$toStringTag]() {
return 'Texture';
}
constructor(device, props) {
super(device, props, DEFAULT_TEXTURE_PROPS);
_defineProperty(this, "sampler", void 0);
}
}
Texture.COPY_SRC = 0x01;
Texture.COPY_DST = 0x02;
Texture.TEXTURE_BINDING = 0x04;
Texture.STORAGE_BINDING = 0x08;
Texture.RENDER_ATTACHMENT = 0x10;
export default Texture;
_defineProperty(Texture, "COPY_SRC", 0x01);
_defineProperty(Texture, "COPY_DST", 0x02);
_defineProperty(Texture, "TEXTURE_BINDING", 0x04);
_defineProperty(Texture, "STORAGE_BINDING", 0x08);
_defineProperty(Texture, "RENDER_ATTACHMENT", 0x10);
//# sourceMappingURL=texture.js.map

@@ -1,2 +0,2 @@

;
export {};
//# sourceMappingURL=accessor.js.map
import { DepthStencilTextureFormat } from './texture-formats';
export type CompareFunction = 'never' | 'less' | 'equal' | 'less-equal' | 'greater' | 'not-equal' | 'greater-equal' | 'always';
export type PrimitiveTopology = "point-list" | "line-list" | "line-strip" |
export declare type CompareFunction = 'never' | 'less' | 'equal' | 'less-equal' | 'greater' | 'not-equal' | 'greater-equal' | 'always';
export declare type PrimitiveTopology = 'point-list' | 'line-list' | 'line-strip' |
/** @deprecated */
'line-loop' | "triangle-list" | "triangle-strip" |
'line-loop' | 'triangle-list' | 'triangle-strip' |
/** @deprecated */
'triangle-fan';
export type IndexFormat = 'uint16' | 'uint32';
export type CullMode = 'none' | 'front' | 'back';
export type FrontFace = 'ccw' | 'cw';
type _RenderParameters = {
export declare type IndexFormat = 'uint16' | 'uint32';
export declare type CullMode = 'none' | 'front' | 'back';
export declare type FrontFace = 'ccw' | 'cw';
declare type _RenderParameters = {
cullMode?: CullMode;

@@ -19,8 +19,8 @@ frontFace?: FrontFace;

};
export type RasterizationParameters = _RenderParameters & {
export declare type RasterizationParameters = _RenderParameters & {
topology?: PrimitiveTopology;
stripIndexFormat?: IndexFormat;
};
export type StencilOperation = 'keep' | 'zero' | 'replace' | 'invert' | 'increment-clamp' | 'decrement-clamp' | 'increment-wrap' | 'decrement-wrap';
export type DepthStencilParameters = {
export declare type StencilOperation = 'keep' | 'zero' | 'replace' | 'invert' | 'increment-clamp' | 'decrement-clamp' | 'increment-wrap' | 'decrement-wrap';
export declare type DepthStencilParameters = {
depthWriteEnabled?: boolean;

@@ -36,5 +36,5 @@ depthCompare?: CompareFunction;

};
export type BlendFactor = 'zero' | 'one' | 'src-color' | 'one-minus-src-color' | 'src-alpha' | 'one-minus-src-alpha' | 'dst-color' | 'one-minus-dst-color' | 'dst-alpha' | 'one-minus-dst-alpha' | 'src-alpha-saturated' | 'blend-color' | 'one-minus-blend-color';
export type BlendOperation = 'add' | 'subtract' | 'reverse-subtract' | 'min' | 'max';
export type ColorParameters = {
export declare type BlendFactor = 'zero' | 'one' | 'src-color' | 'one-minus-src-color' | 'src-alpha' | 'one-minus-src-alpha' | 'dst-color' | 'one-minus-dst-color' | 'dst-alpha' | 'one-minus-dst-alpha' | 'src-alpha-saturated' | 'blend-color' | 'one-minus-blend-color';
export declare type BlendOperation = 'add' | 'subtract' | 'reverse-subtract' | 'min' | 'max';
export declare type ColorParameters = {
blendColorOperation?: BlendOperation;

@@ -48,3 +48,3 @@ blendColorSrcFactor?: BlendFactor;

};
export type MultisampleParameters = {
export declare type MultisampleParameters = {
sampleCount?: number;

@@ -54,3 +54,3 @@ sampleMask?: number;

};
export type RenderPassParameters = {
export declare type RenderPassParameters = {
viewport: number[];

@@ -61,6 +61,6 @@ scissorRect: number[];

};
export type RenderPipelineParameters = RasterizationParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
export type Parameters = _RenderParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
export declare type RenderPipelineParameters = RasterizationParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
export declare type Parameters = _RenderParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
export declare const DEFAULT_PARAMETERS: Required<Parameters>;
export {};
//# sourceMappingURL=parameters.d.ts.map

@@ -1,33 +0,28 @@

// export const DEFAULT_PARAMETERS: Parameters;
export const DEFAULT_PARAMETERS = {
// Rasterization Parameters
cullMode: 'none',
frontFace: 'ccw',
// Depth Parameters
depthWriteEnabled: false,
depthCompare: 'always',
depthFormat: 'depth24plus',
depthClamp: false,
depthBias: 0,
depthBiasSlopeScale: 0,
depthBiasClamp: 0,
// Stencil parameters
stencilReadMask: 0xFFFFFFFF,
stencilWriteMask: 0xFFFFFFFF,
stencilCompare: 'always',
stencilPassOperation: 'keep',
stencilFailOperation: 'keep',
stencilDepthFailOperation: 'keep',
// Multisample parameters
sampleCount: 0,
sampleMask: 0xFFFFFFFF,
sampleAlphaToCoverageEnabled: false,
// Color and blend parameters
blendColorOperation: 'add',
blendColorSrcFactor: 'one',
blendColorDstFactor: 'zero',
blendAlphaOperation: 'add',
blendAlphaSrcFactor: 'one',
blendAlphaDstFactor: 'zero',
colorMask: 0xF
cullMode: 'none',
frontFace: 'ccw',
depthWriteEnabled: false,
depthCompare: 'always',
depthFormat: 'depth24plus',
depthClamp: false,
depthBias: 0,
depthBiasSlopeScale: 0,
depthBiasClamp: 0,
stencilReadMask: 0xFFFFFFFF,
stencilWriteMask: 0xFFFFFFFF,
stencilCompare: 'always',
stencilPassOperation: 'keep',
stencilFailOperation: 'keep',
stencilDepthFailOperation: 'keep',
sampleCount: 0,
sampleMask: 0xFFFFFFFF,
sampleAlphaToCoverageEnabled: false,
blendColorOperation: 'add',
blendColorSrcFactor: 'one',
blendColorDstFactor: 'zero',
blendAlphaOperation: 'add',
blendAlphaSrcFactor: 'one',
blendAlphaDstFactor: 'zero',
colorMask: 0xF
};
//# sourceMappingURL=parameters.js.map

@@ -43,3 +43,3 @@ import { TextureFormat } from '../types/texture-formats';

*/
export type ShaderLayout = {
export declare type ShaderLayout = {
attributes: AttributeLayout[];

@@ -53,3 +53,3 @@ bindings: BindingLayout[];

/** ShaderLayout for attributes */
export type AttributeLayout = {
export declare type AttributeLayout = {
name: string;

@@ -72,5 +72,5 @@ location: number;

*/
export type BufferMapping = SingleBufferMapping | InterleavedBufferMapping;
export declare type BufferMapping = SingleBufferMapping | InterleavedBufferMapping;
/** @note Not public: not exported outside of api module */
export type SingleBufferMapping = {
export declare type SingleBufferMapping = {
/** Name of attribute to adjust */

@@ -84,3 +84,3 @@ name: string;

/** @note Not public: not exported outside of api module */
export type InterleavedBufferMapping = {
export declare type InterleavedBufferMapping = {
/** Name of buffer () */

@@ -96,3 +96,3 @@ name: string;

/** @note Not public: not exported outside of api module */
export type InterleavedAttribute = {
export declare type InterleavedAttribute = {
/** Name of buffer to map */

@@ -104,4 +104,4 @@ name?: string;

/** ShaderLayout for bindings */
export type BindingLayout = UniformBufferBindingLayout | BufferBindingLayout | TextureBindingLayout | SamplerBindingLayout | StorageTextureBindingLayout;
export type UniformBufferBindingLayout = {
export declare type BindingLayout = UniformBufferBindingLayout | BufferBindingLayout | TextureBindingLayout | SamplerBindingLayout | StorageTextureBindingLayout;
export declare type UniformBufferBindingLayout = {
type: 'uniform';

@@ -115,3 +115,3 @@ name: string;

};
export type UniformInfo = {
export declare type UniformInfo = {
name: string;

@@ -124,3 +124,3 @@ format: UniformFormat;

};
export type BufferBindingLayout = {
export declare type BufferBindingLayout = {
type: 'uniform' | 'storage' | 'read-only-storage';

@@ -133,3 +133,3 @@ name: string;

};
type TextureBindingLayout = {
declare type TextureBindingLayout = {
type: 'texture';

@@ -143,3 +143,3 @@ name: string;

};
type SamplerBindingLayout = {
declare type SamplerBindingLayout = {
type: 'sampler';

@@ -151,3 +151,3 @@ name: string;

};
type StorageTextureBindingLayout = {
declare type StorageTextureBindingLayout = {
type: 'storage';

@@ -162,3 +162,3 @@ name: string;

/** Binding value */
export type Binding = Texture | Sampler | Buffer | {
export declare type Binding = Texture | Sampler | Buffer | {
buffer: Buffer;

@@ -172,3 +172,3 @@ offset?: number;

*/
export type ProgramBindings = {
export declare type ProgramBindings = {
readonly attributes: AttributeBinding[];

@@ -180,3 +180,3 @@ readonly varyings: VaryingBinding[];

/** @deprecated Describes a varying binding for a program */
export type VaryingBinding = {
export declare type VaryingBinding = {
location: number;

@@ -187,3 +187,3 @@ name: string;

/** Describes a uniform block binding for a program */
export type UniformBlockBinding = {
export declare type UniformBlockBinding = {
location: number;

@@ -199,3 +199,3 @@ name: string;

/** Describes a uniform (sampler etc) binding for a program */
export type UniformBinding = {
export declare type UniformBinding = {
location: number;

@@ -208,3 +208,3 @@ name: string;

/** @deprecated */
export type AttributeBinding = {
export declare type AttributeBinding = {
name: string;

@@ -211,0 +211,0 @@ location: number;

export {};
//# sourceMappingURL=shader-layout.js.map
/** Texture formats */
export type TextureFormat = ColorTextureFormat | DepthStencilTextureFormat;
export declare type TextureFormat = ColorTextureFormat | DepthStencilTextureFormat;
/** Depth and stencil texture formats */
export type DepthStencilTextureFormat = 'stencil8' | 'depth16unorm' | 'depth24plus' | 'depth24plus-stencil8' | 'depth32float' | 'depth24unorm-stencil8' | 'depth32float-stencil8';
export declare type DepthStencilTextureFormat = 'stencil8' | 'depth16unorm' | 'depth24plus' | 'depth24plus-stencil8' | 'depth32float' | 'depth24unorm-stencil8' | 'depth32float-stencil8';
/** Texture formats for color attachments */
export type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat | UnsizedColorTextureFormat;
export type WebGPUColorTextureFormat = 'r8unorm' | 'r8snorm' | 'r8uint' | 'r8sint' | 'r16uint' | 'r16sint' | 'r16float' | 'rg8unorm' | 'rg8snorm' | 'rg8uint' | 'rg8sint' | 'r32uint' | 'r32sint' | 'r32float' | 'rg16uint' | 'rg16sint' | 'rg16float' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgb9e5ufloat' | 'rgb10a2unorm' | 'rg11b10ufloat' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bc1-rgba-unorm' | 'bc1-rgba-unorm-srgb' | 'bc2-rgba-unorm' | 'bc2-rgba-unorm-srgb' | 'bc3-rgba-unorm' | 'bc3-rgba-unorm-srgb' | 'bc4-r-unorm' | 'bc4-r-snorm' | 'bc5-rg-unorm' | 'bc5-rg-snorm' | 'bc6h-rgb-ufloat' | 'bc6h-rgb-float' | 'bc7-rgba-unorm' | 'bc7-rgba-unorm-srgb' | 'etc2-rgb8unorm' | 'etc2-rgb8unorm-srgb' | 'etc2-rgb8a1unorm' | 'etc2-rgb8a1unorm-srgb' | 'etc2-rgba8unorm' | 'etc2-rgba8unorm-srgb' | 'eac-r11unorm' | 'eac-r11snorm' | 'eac-rg11unorm' | 'eac-rg11snorm' | 'astc-4x4-unorm' | 'astc-4x4-unorm-srgb' | 'astc-5x4-unorm' | 'astc-5x4-unorm-srgb' | 'astc-5x5-unorm' | 'astc-5x5-unorm-srgb' | 'astc-6x5-unorm' | 'astc-6x5-unorm-srgb' | 'astc-6x6-unorm' | 'astc-6x6-unorm-srgb' | 'astc-8x5-unorm' | 'astc-8x5-unorm-srgb' | 'astc-8x6-unorm' | 'astc-8x6-unorm-srgb' | 'astc-8x8-unorm' | 'astc-8x8-unorm-srgb' | 'astc-10x5-unorm' | 'astc-10x5-unorm-srgb' | 'astc-10x6-unorm' | 'astc-10x6-unorm-srgb' | 'astc-10x8-unorm' | 'astc-10x8-unorm-srgb' | 'astc-10x10-unorm' | 'astc-10x10-unorm-srgb' | 'astc-12x10-unorm' | 'astc-12x10-unorm-srgb' | 'astc-12x12-unorm' | 'astc-12x12-unorm-srgb';
export declare type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat | UnsizedColorTextureFormat;
export declare type WebGPUColorTextureFormat = 'r8unorm' | 'r8snorm' | 'r8uint' | 'r8sint' | 'r16uint' | 'r16sint' | 'r16float' | 'rg8unorm' | 'rg8snorm' | 'rg8uint' | 'rg8sint' | 'r32uint' | 'r32sint' | 'r32float' | 'rg16uint' | 'rg16sint' | 'rg16float' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgb9e5ufloat' | 'rgb10a2unorm' | 'rg11b10ufloat' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bc1-rgba-unorm' | 'bc1-rgba-unorm-srgb' | 'bc2-rgba-unorm' | 'bc2-rgba-unorm-srgb' | 'bc3-rgba-unorm' | 'bc3-rgba-unorm-srgb' | 'bc4-r-unorm' | 'bc4-r-snorm' | 'bc5-rg-unorm' | 'bc5-rg-snorm' | 'bc6h-rgb-ufloat' | 'bc6h-rgb-float' | 'bc7-rgba-unorm' | 'bc7-rgba-unorm-srgb' | 'etc2-rgb8unorm' | 'etc2-rgb8unorm-srgb' | 'etc2-rgb8a1unorm' | 'etc2-rgb8a1unorm-srgb' | 'etc2-rgba8unorm' | 'etc2-rgba8unorm-srgb' | 'eac-r11unorm' | 'eac-r11snorm' | 'eac-rg11unorm' | 'eac-rg11snorm' | 'astc-4x4-unorm' | 'astc-4x4-unorm-srgb' | 'astc-5x4-unorm' | 'astc-5x4-unorm-srgb' | 'astc-5x5-unorm' | 'astc-5x5-unorm-srgb' | 'astc-6x5-unorm' | 'astc-6x5-unorm-srgb' | 'astc-6x6-unorm' | 'astc-6x6-unorm-srgb' | 'astc-8x5-unorm' | 'astc-8x5-unorm-srgb' | 'astc-8x6-unorm' | 'astc-8x6-unorm-srgb' | 'astc-8x8-unorm' | 'astc-8x8-unorm-srgb' | 'astc-10x5-unorm' | 'astc-10x5-unorm-srgb' | 'astc-10x6-unorm' | 'astc-10x6-unorm-srgb' | 'astc-10x8-unorm' | 'astc-10x8-unorm-srgb' | 'astc-10x10-unorm' | 'astc-10x10-unorm-srgb' | 'astc-12x10-unorm' | 'astc-12x10-unorm-srgb' | 'astc-12x12-unorm' | 'astc-12x12-unorm-srgb';
/** Unsized texture formats (the only formats supported by WebGL1) */
export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized';
export declare type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized';
/** Sized formats unique to WebGL 2. Will perhaps be added to WebGPU? */
export type WebGL2ColorTextureFormat = 'r16unorm-webgl' | 'r16snorm-webgl' | 'rgba4unorm-webgl' | 'rgb565unorm-webgl' | 'rgb5a1unorm-webgl' | 'rbg8unorm-webgl' | 'rbg8snorm-webgl' | 'rg16unorm-webgl' | 'rg16snorm-webgl' | 'rgb10a2unorm-webgl' | 'rgb16unorm-webgl' | 'rgb16snorm-webgl' | 'rgba16unorm-webgl' | 'rgba16snorm-webgl' | 'rgb32float-webgl' | 'bc1-rgb-unorm-webgl' | 'bc1-rgb-unorm-srgb-webgl' | 'pvrtc-rgb4unorm-webgl' | 'pvrtc-rgba4unorm-webgl' | 'pvrtc-rbg2unorm-webgl' | 'pvrtc-rgba2unorm-webgl' | 'etc1-rbg-unorm-webgl' | 'atc-rgb-unorm-webgl' | 'atc-rgba-unorm-webgl' | 'atc-rgbai-unorm-webgl';
export declare type WebGL2ColorTextureFormat = 'r16unorm-webgl' | 'r16snorm-webgl' | 'rgba4unorm-webgl' | 'rgb565unorm-webgl' | 'rgb5a1unorm-webgl' | 'rbg8unorm-webgl' | 'rbg8snorm-webgl' | 'rg16unorm-webgl' | 'rg16snorm-webgl' | 'rgb10a2unorm-webgl' | 'rgb16unorm-webgl' | 'rgb16snorm-webgl' | 'rgba16unorm-webgl' | 'rgba16snorm-webgl' | 'rgb32float-webgl' | 'bc1-rgb-unorm-webgl' | 'bc1-rgb-unorm-srgb-webgl' | 'pvrtc-rgb4unorm-webgl' | 'pvrtc-rgba4unorm-webgl' | 'pvrtc-rbg2unorm-webgl' | 'pvrtc-rgba2unorm-webgl' | 'etc1-rbg-unorm-webgl' | 'atc-rgb-unorm-webgl' | 'atc-rgba-unorm-webgl' | 'atc-rgbai-unorm-webgl';
//# sourceMappingURL=texture-formats.d.ts.map

@@ -1,2 +0,2 @@

// luma.gl, MIT license
export {};
//# sourceMappingURL=texture-formats.js.map
import { TextureFormat } from './texture-formats';
type BufferBindingLayout = {
declare type BufferBindingLayout = {
location?: number;

@@ -9,3 +9,3 @@ visibility: number;

};
type TextureBindingLayout = {
declare type TextureBindingLayout = {
location?: number;

@@ -17,3 +17,3 @@ visibility: number;

};
type StorageTextureBindingLayout = {
declare type StorageTextureBindingLayout = {
location?: number;

@@ -25,6 +25,6 @@ visibility: number;

};
export type BindingLayout = BufferBindingLayout | TextureBindingLayout | StorageTextureBindingLayout;
export declare type BindingLayout = BufferBindingLayout | TextureBindingLayout | StorageTextureBindingLayout;
import type Buffer from '../resources/buffer';
import type Texture from '../resources/texture';
export type Binding = Texture | Buffer | {
export declare type Binding = Texture | Buffer | {
buffer: Buffer;

@@ -34,3 +34,3 @@ offset?: number;

};
export type TextureView = {
export declare type TextureView = {
texture: WebGLTexture;

@@ -40,7 +40,7 @@ layer?: number;

};
export type ColorAttachmentOptions = {
export declare type ColorAttachmentOptions = {
clearColor?: number[];
storeOp: 'store' | 'discard';
};
export type DepthStencilAttachmentOptions = {
export declare type DepthStencilAttachmentOptions = {
depthClearValue?: number;

@@ -54,3 +54,3 @@ depthStoreOp?: 'store' | 'discard';

/** @todo */
export type ColorAttachment = ColorAttachmentOptions & {
export declare type ColorAttachment = ColorAttachmentOptions & {
texture: Texture | TextureView;

@@ -60,3 +60,3 @@ resolveTarget?: Texture;

/** @todo */
export type DepthStencilAttachment = DepthStencilAttachmentOptions & {
export declare type DepthStencilAttachment = DepthStencilAttachmentOptions & {
texture: Texture;

@@ -63,0 +63,0 @@ };

export {};
//# sourceMappingURL=types.js.map

@@ -1,3 +0,3 @@

export type UniformDataType = 'uint32' | 'sint32' | 'float32';
export type UniformFormat = 'f32' | 'i32' | 'u32' | 'vec2<f32>' | 'vec3<f32>' | 'vec4<f32>' | 'vec2<i32>' | 'vec3<i32>' | 'vec4<i32>' | 'vec2<u32>' | 'vec3<u32>' | 'vec4<u32>' | 'mat2x2<f32>' | 'mat2x3<f32>' | 'mat2x4<f32>' | 'mat3x2<f32>' | 'mat3x3<f32>' | 'mat3x4<f32>' | 'mat4x2<f32>' | 'mat4x3<f32>' | 'mat4x4<f32>';
export declare type UniformDataType = 'uint32' | 'sint32' | 'float32';
export declare type UniformFormat = 'f32' | 'i32' | 'u32' | 'vec2<f32>' | 'vec3<f32>' | 'vec4<f32>' | 'vec2<i32>' | 'vec3<i32>' | 'vec4<i32>' | 'vec2<u32>' | 'vec3<u32>' | 'vec4<u32>' | 'mat2x2<f32>' | 'mat2x3<f32>' | 'mat2x4<f32>' | 'mat3x2<f32>' | 'mat3x3<f32>' | 'mat3x4<f32>' | 'mat4x2<f32>' | 'mat4x3<f32>' | 'mat4x4<f32>';
//# sourceMappingURL=uniform-formats.d.ts.map

@@ -1,2 +0,2 @@

// luma.gl, MIT license
export {};
//# sourceMappingURL=uniform-formats.js.map

@@ -1,7 +0,7 @@

export type DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float16' | 'float32';
export declare type DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float16' | 'float32';
/** Vertex and Pixel data types. */
export type NormalizedDataType = 'uint8' | 'sint8' | 'unorm8' | 'snorm8' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'float16' | 'float32' | 'uint32' | 'sint32';
export type VertexType = NormalizedDataType;
export declare type NormalizedDataType = 'uint8' | 'sint8' | 'unorm8' | 'snorm8' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'float16' | 'float32' | 'uint32' | 'sint32';
export declare type VertexType = NormalizedDataType;
/** Attribute formats */
export type VertexFormat = 'uint8x2' | 'uint8x4' | 'sint8x2' | 'sint8x4' | 'unorm8x2' | 'unorm8x4' | 'snorm8x2' | 'snorm8x4' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4';
export declare type VertexFormat = 'uint8x2' | 'uint8x4' | 'sint8x2' | 'sint8x4' | 'unorm8x2' | 'unorm8x4' | 'snorm8x2' | 'snorm8x4' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4';
//# sourceMappingURL=vertex-formats.d.ts.map

@@ -1,2 +0,2 @@

// luma.gl, MIT license
export {};
//# sourceMappingURL=vertex-formats.js.map

@@ -1,44 +0,43 @@

/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
export function decodeVertexType(type) {
const dataType = TYPE_MAP[type];
const bytes = getDataTypeBytes(dataType);
const integer = !type.startsWith('float');
const normalized = type.includes('norm');
const signed = type.startsWith('s');
return {
dataType: TYPE_MAP[type],
byteLength: bytes,
integer,
signed,
normalized
};
const dataType = TYPE_MAP[type];
const bytes = getDataTypeBytes(dataType);
const integer = !type.startsWith('float');
const normalized = type.includes('norm');
const signed = type.startsWith('s');
return {
dataType: TYPE_MAP[type],
byteLength: bytes,
integer,
signed,
normalized
};
}
function getDataTypeBytes(type) {
const bytes = TYPE_SIZES[type];
// assert(bytes);
return bytes;
const bytes = TYPE_SIZES[type];
return bytes;
}
const TYPE_MAP = {
uint8: 'uint8',
sint8: 'sint8',
unorm8: 'uint8',
snorm8: 'sint8',
uint16: 'uint16',
sint16: 'sint16',
unorm16: 'uint16',
snorm16: 'sint16',
float16: 'float16',
float32: 'float32',
uint32: 'uint32',
sint32: 'sint32'
uint8: 'uint8',
sint8: 'sint8',
unorm8: 'uint8',
snorm8: 'sint8',
uint16: 'uint16',
sint16: 'sint16',
unorm16: 'uint16',
snorm16: 'sint16',
float16: 'float16',
float32: 'float32',
uint32: 'uint32',
sint32: 'sint32'
};
const TYPE_SIZES = {
uint8: 1,
sint8: 1,
uint16: 2,
sint16: 2,
float16: 2,
float32: 4,
uint32: 4,
sint32: 4
uint8: 1,
sint8: 1,
uint16: 2,
sint16: 2,
float16: 2,
float32: 4,
uint32: 4,
sint32: 4
};
//# sourceMappingURL=decode-data-type.js.map

@@ -1,156 +0,22 @@

import { decodeVertexType } from './decode-data-type.js';
import { decodeVertexType } from "./decode-data-type.js";
const REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
/**
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
*/
export function decodeTextureFormat(format) {
const matches = format.match(REGEX);
if (matches) {
const [, format, length, type, srgb, suffix] = matches;
if (format) {
const dataType = `${type}${length}`;
const decodedType = decodeVertexType(dataType);
return {
format,
components: 0,
// dataType - overwritten by decodedType
srgb: srgb === '-srgb',
unsized: suffix === '-unsized',
webgl: suffix === '-webgl',
...decodedType
};
}
const matches = REGEX.exec(format);
if (matches) {
const [, format, length, type, srgb, suffix] = matches;
if (format) {
const dataType = "".concat(type).concat(length);
const decodedType = decodeVertexType(dataType);
return {
format,
components: 0,
srgb: srgb === '-srgb',
unsized: suffix === '-unsized',
webgl: suffix === '-webgl',
...decodedType
};
}
throw new Error(`Unknown format ${format}`);
}
throw new Error("Unknown format ".concat(format));
}
// https://www.w3.org/TR/webgpu/#texture-format-caps
/*
const EXCEPTIONS: Record<TextureFormat, any> = {
// Packed 16 bit formats
'rgba4unorm-webgl': {format: 'rgba', bpp: 2},
'rgb565unorm-webgl': {format: 'rgb', bpp: 2},
'rgb5a1unorm-webgl': {format: 'rgba', bbp: 2},
// Packed 32 bit formats
'rgb9e5ufloat': {format: 'rgb', bbp: 4},
'rg11b10ufloat': {format: 'rgb', bbp: 4},
'rgb10a2unorm': {format: 'rgba', bbp: 4},
'rgb10a2unorm-webgl': {format: 'rgba', bbp: 4},
// Depth/stencil
'stencil8': {components: 1, bpp: 1, a: 'stencil'},
'depth16unorm': {components: 1, bpp: 2, a: 'depth'},
'depth24plus': {components: 1, bpp: 3, a: 'depth'},
'depth32float': {components: 1, bpp: 4, a: 'depth'},
'depth24plus-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'},
// "depth24unorm-stencil8" feature
'depth24unorm-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'},
// "depth32float-stencil8" feature
"depth32float-stencil8": {components: 2, bpp: 4, a: 'depth-stencil'}
};
'r8unorm': {s: "float"}, // ✓ ✓ ✓ },
'r8snorm': {s: "float"}, // ✓ },
'r8uint': {s: "uint"}, // ✓ ✓ },
'r8sint': {s: "sint"}, // ✓ ✓ },
'rg8unorm': {s: "float"}, // ✓ ✓ ✓ },
'rg8snorm': {s: "float"}, // ✓ },
'rg8uint': {s: "uint"}, // ✓ ✓ },
'rg8sint': {s: "sint"}, // ✓ ✓ },
'rgba8unorm': {s: "float"}, // ✓ ✓ ✓ ✓},
'rgba8unorm-srgb': {s: "float"}, // ✓ ✓ ✓ },
'rgba8snorm': {s: "float"}, // ✓ ✓},
'rgba8uint': {s: "uint"}, // ✓ ✓ ✓},
'rgba8sint': {s: "sint"}, // ✓ ✓ ✓},
'bgra8unorm': {s: "float"}, // ✓ ✓ ✓ },
'bgra8unorm-srgb': {s: "float"}, // ✓ ✓ ✓ },
// 16-bit per component
'r16uint': {s: "uint"}, // ✓ ✓ },
'r16sint': {s: "sint"}, // ✓ ✓ },
'r16float': {s: "float"}, // ✓ ✓ ✓ },
'rg16uint': {s: "uint"}, // ✓ ✓ },
'rg16sint': {s: "sint"}, // ✓ ✓ },
'rg16float': {s: "float"}, // ✓ ✓ ✓ },
'rgba16uint': {s: "uint"}, // ✓ ✓ ✓},
'rgba16sint': {s: "sint"}, // ✓ ✓ ✓},
'rgba16float': {s: "float"}, // ✓ ✓ ✓ ✓},
// 32-bit per component
'r32uint': {s: "uint"}, // ✓ ✓},
'r32sint': {s: "sint"}, // ✓ ✓},
'r32float': {"unfilterable-float" ✓ ✓ ✓},
'rg32uint': {s: "uint"}, // ✓ ✓},
'rg32sint': {s: "sint"}, // ✓ ✓},
'rg32float': {"unfilterable-float" ✓ ✓},
'rgba32uint': {s: "uint"}, // ✓ ✓},
'rgba32sint': {s: "sint"}, // ✓ ✓},
'rgba32float': {"unfilterable-float" ✓ ✓},
// mixed component width
'rgb10a2unorm': {s: "float"}, // ✓ ✓ ✓ }
'rg11b10ufloat': {s: "float"}, // ✓ }
// Format Bytes per texel Aspect GPUTextureSampleType Valid image copy source Valid image copy destination
'stencil8': {1 − 4 stencil "uint" ✓}
'depth16unorm': {2 depth "depth" ✓}
'depth24plus': {4 depth "depth" ✗}
'depth24plus': {stencil8 4 − 8 depth "depth" ✗}
'stencil': {s: "uint"}, // ✓}
'depth32float': {4 depth "depth" ✓ ✗}
'depth24unorm': {stencil8 4 depth "depth" ✗}
'stencil': {s: "uint"}, // ✓}
'depth32float': {stencil8}
// Format Bytes per block GPUTextureSampleType Block Size Feature
'rgb9e5ufloat': {c: 4, s: "float", bpp: 4/(1*1)},
'bc1-rgba-unorm': {c: 4. s: "float", bpp: 8/(4 * 4) f: 'texture-compression-bc'},
'bc1-rgba-unorm-srgb': {c: 4. s: "float", bpp: 8/(4 * 4) f: 'texture-compression-bc'},
'bc2-rgba-unorm': {c: 4. s: "float", bpp: 16/(4 * 4) f: 'texture-compression-bc'},
'bc2-rgba-unorm-srgb': {c: 4. s: "float", bpp: 16/(4 * 4) f: 'texture-compression-bc'},
'bc3-rgba-unorm': {c: 4. s: "float", bpp: 16/(4 * 4) f: 'texture-compression-bc'},
'bc3-rgba-unorm-srgb': {c: 4. s: "float", bpp: 16/(4 * 4) f: 'texture-compression-bc'},
'bc4-r-unorm': {c: 1. s: "float", bpp: 8/(4 * 4) f: 'texture-compression-bc'},
'bc4-r-snorm': {c: 1. s: "float", bpp: 8/(4 * 4) f: 'texture-compression-bc'},
'bc5-rg-unorm': {c: 2. s: "float", bpp: 16/(4 * 4) f: 'texture-compression-bc'},
'bc5-rg-snorm': { },
'bc6h-rgb-ufloat': { 16 },
'bc6h-rgb-float': { },
'bc7-rgba-unorm': { 16 },
'bc7-rgba-unorm-srgb': { },
'etc2-rgb8unorm': { 8 "float" 4 × 4 texture-compression-etc2 },
'etc2-rgb8unorm-srgb': { },
'etc2-rgb8a1unorm': { 8 },
'etc2-rgb8a1unorm-srgb': { },
'etc2-rgba8unorm': { 16 },
'etc2-rgba8unorm-srgb': { },
'eac-r11unorm': { 8 },
'eac-r11snorm': { },
'eac-rg11unorm': { 16 },
'eac-rg11snorm': { },
'astc-4x4-unorm': { 16 "float" 4 × 4 texture-compression-astc },
'astc-4x4-unorm-srgb': { },
'astc-5x4-unorm': { 16 5 × 4 },
'astc-5x4-unorm-srgb': { },
'astc-5x5-unorm': { 16 5 × 5 },
'astc-5x5-unorm-srgb': { },
'astc-6x5-unorm': { 16 6 × 5 },
'astc-6x5-unorm-srgb': { },
'astc-6x6-unorm': { 16 6 × 6 },
'astc-6x6-unorm-srgb': { },
'astc-8x5-unorm': { 16 8 × 5 },
'astc-8x5-unorm-srgb': { },
'astc-8x6-unorm': { 16 8 × 6 },
'astc-8x6-unorm-srgb': { },
'astc-8x8-unorm': { 16 8 × 8 },
'astc-8x8-unorm-srgb': { },
'astc-10x5-unorm': { 16 10 × 5 },
'astc-10x5-unorm-srgb': { },
'astc-10x6-unorm': { 16 10 × 6 },
'astc-10x6-unorm-srgb': { },
'astc-10x8-unorm': { 16 10 × 8 },
'astc-10x8-unorm-srgb': { },
'astc-10x10-unorm': { 16 10 × 10 },
'astc-10x10-unorm-srgb': { },
'astc-12x10-unorm': { 16 12 × 10 },
'astc-12x10-unorm-srgb': { },
'astc-12x12-unorm': { 16 },
*/
//# sourceMappingURL=decode-texture-format.js.map

@@ -1,39 +0,103 @@

import { assert } from '../../lib/utils/assert.js';
import { assert } from "../../lib/utils/assert.js";
const UNIFORM_FORMATS = {
'f32': { type: 'float32', components: 1 },
'i32': { type: 'sint32', components: 1 },
'u32': { type: 'uint32', components: 1 },
'vec2<f32>': { type: 'float32', components: 2 },
'vec3<f32>': { type: 'float32', components: 3 },
'vec4<f32>': { type: 'float32', components: 4 },
'vec2<i32>': { type: 'sint32', components: 2 },
'vec3<i32>': { type: 'sint32', components: 3 },
'vec4<i32>': { type: 'sint32', components: 4 },
'vec2<u32>': { type: 'uint32', components: 2 },
'vec3<u32>': { type: 'uint32', components: 3 },
'vec4<u32>': { type: 'uint32', components: 4 },
'mat2x2<f32>': { type: 'float32', components: 4 },
'mat2x3<f32>': { type: 'float32', components: 6 },
'mat2x4<f32>': { type: 'float32', components: 8 },
'mat3x2<f32>': { type: 'float32', components: 6 },
'mat3x3<f32>': { type: 'float32', components: 9 },
'mat3x4<f32>': { type: 'float32', components: 12 },
'mat4x2<f32>': { type: 'float32', components: 8 },
'mat4x3<f32>': { type: 'float32', components: 12 },
'mat4x4<f32>': { type: 'float32', components: 16 },
'f32': {
type: 'float32',
components: 1
},
'i32': {
type: 'sint32',
components: 1
},
'u32': {
type: 'uint32',
components: 1
},
'vec2<f32>': {
type: 'float32',
components: 2
},
'vec3<f32>': {
type: 'float32',
components: 3
},
'vec4<f32>': {
type: 'float32',
components: 4
},
'vec2<i32>': {
type: 'sint32',
components: 2
},
'vec3<i32>': {
type: 'sint32',
components: 3
},
'vec4<i32>': {
type: 'sint32',
components: 4
},
'vec2<u32>': {
type: 'uint32',
components: 2
},
'vec3<u32>': {
type: 'uint32',
components: 3
},
'vec4<u32>': {
type: 'uint32',
components: 4
},
'mat2x2<f32>': {
type: 'float32',
components: 4
},
'mat2x3<f32>': {
type: 'float32',
components: 6
},
'mat2x4<f32>': {
type: 'float32',
components: 8
},
'mat3x2<f32>': {
type: 'float32',
components: 6
},
'mat3x3<f32>': {
type: 'float32',
components: 9
},
'mat3x4<f32>': {
type: 'float32',
components: 12
},
'mat4x2<f32>': {
type: 'float32',
components: 8
},
'mat4x3<f32>': {
type: 'float32',
components: 12
},
'mat4x4<f32>': {
type: 'float32',
components: 16
}
};
/** Split a uniform format string into type and components */
export function decodeUniformFormat(format) {
const decoded = UNIFORM_FORMATS[format];
assert(format);
return decoded;
const decoded = UNIFORM_FORMATS[format];
assert(format);
return decoded;
}
/** Align offset to 1, 2 or 4 elements (4, 8 or 16 bytes) */
export function alignTo(size, count) {
// prettier-ignore
switch (count) {
case 1: return size; // Pad upwards to even multiple of 2
case 2: return size + (size % 2); // Pad upwards to even multiple of 2
default: return size + ((4 - (size % 4)) % 4); // Pad upwards to even multiple of 4
}
switch (count) {
case 1:
return size;
case 2:
return size + size % 2;
default:
return size + (4 - size % 4) % 4;
}
}
//# sourceMappingURL=decode-uniform-format.js.map

@@ -1,18 +0,16 @@

import { decodeVertexType } from './decode-data-type.js';
/**
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
*/
import { decodeVertexType } from "./decode-data-type.js";
export function decodeVertexFormat(format) {
const [type_, count] = format.split('x');
const type = type_;
const components = count ? parseInt(count) : 1;
const decodedType = decodeVertexType(type);
return {
type,
components,
byteLength: decodedType.byteLength * components,
integer: decodedType.integer,
signed: decodedType.signed,
normalized: decodedType.normalized
};
const [type_, count] = format.split('x');
const type = type_;
const components = count ? parseInt(count) : 1;
const decodedType = decodeVertexType(type);
return {
type,
components,
byteLength: decodedType.byteLength * components,
integer: decodedType.integer,
signed: decodedType.signed,
normalized: decodedType.normalized
};
}
//# sourceMappingURL=decode-vertex-format.js.map

@@ -1,2 +0,2 @@

import './init';
export { VERSION } from './init';
export { default as luma } from './lib/luma';

@@ -3,0 +3,0 @@ export type { DeviceProps, DeviceLimits, DeviceInfo, DeviceFeature } from './adapter/device';

@@ -1,45 +0,35 @@

// luma.gl, MIT license
// Initialize any global state
import './init';
// MAIN API ACCESS POINTS
export { default as luma } from './lib/luma.js';
export { default as Device } from './adapter/device.js';
export { default as CanvasContext } from './adapter/canvas-context.js';
export { default as Resource } from './adapter/resources/resource.js';
export { default as Buffer } from './adapter/resources/buffer.js';
export { default as Texture } from './adapter/resources/texture.js';
export { default as ExternalTexture } from './adapter/resources/external-texture.js';
export { default as Shader } from './adapter/resources/shader.js';
export { default as Sampler } from './adapter/resources/sampler.js';
export { default as Framebuffer } from './adapter/resources/framebuffer.js';
export { default as RenderPipeline } from './adapter/resources/render-pipeline.js';
export { default as ComputePipeline } from './adapter/resources/compute-pipeline.js';
export { default as CommandEncoder } from './adapter/resources/command-encoder.js';
export { default as RenderPass } from './adapter/resources/render-pass.js';
export { default as ComputePass } from './adapter/resources/compute-pass.js';
export { default as UniformBufferLayout } from './lib/uniform-buffer-layout.js';
export { default as UniformBlock } from './lib/uniform-block.js';
// API UTILS
export { decodeVertexFormat } from './adapter/utils/decode-vertex-format.js';
export { decodeTextureFormat } from './adapter/utils/decode-texture-format.js';
// GENERAL UTILS
export { default as StatsManager } from './lib/utils/stats-manager.js';
export { assert } from './lib/utils/assert.js';
export { cast } from './lib/utils/cast.js';
export { log } from './lib/utils/log.js';
export { uid, isPowerOfTwo, isObjectEmpty } from './lib/utils/utils.js';
export { formatValue } from './lib/utils/format-value.js';
export { stubRemovedMethods } from './lib/utils/stub-methods.js';
export { checkProps } from './lib/utils/check-props.js';
export { setPathPrefix, loadFile, loadImage, loadImageBitmap, loadScript } from './lib/utils/load-file.js';
export { getScratchArrayBuffer, getScratchArray, fillArray } from './lib/utils/array-utils-flat.js';
export { getRandom, random } from './lib/utils/random.js';
export { formatCompilerLog } from './lib/compiler-log/format-compiler-log.js';
// ENGINE - TODO/move to @luma.gl/engine once that module is webgl-independent?
export { requestAnimationFrame, cancelAnimationFrame } from './lib/request-animation-frame.js';
// SHADER HELPERS
/**
* Marks GLSL shaders for syntax highlighting: glsl`...`
* Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
*/
export const glsl = (x) => `${x}`;
export { VERSION } from "./init.js";
export { default as luma } from "./lib/luma.js";
export { default as Device } from "./adapter/device.js";
export { default as CanvasContext } from "./adapter/canvas-context.js";
export { default as Resource } from "./adapter/resources/resource.js";
export { default as Buffer } from "./adapter/resources/buffer.js";
export { default as Texture } from "./adapter/resources/texture.js";
export { default as ExternalTexture } from "./adapter/resources/external-texture.js";
export { default as Shader } from "./adapter/resources/shader.js";
export { default as Sampler } from "./adapter/resources/sampler.js";
export { default as Framebuffer } from "./adapter/resources/framebuffer.js";
export { default as RenderPipeline } from "./adapter/resources/render-pipeline.js";
export { default as ComputePipeline } from "./adapter/resources/compute-pipeline.js";
export { default as CommandEncoder } from "./adapter/resources/command-encoder.js";
export { default as RenderPass } from "./adapter/resources/render-pass.js";
export { default as ComputePass } from "./adapter/resources/compute-pass.js";
export { default as UniformBufferLayout } from "./lib/uniform-buffer-layout.js";
export { default as UniformBlock } from "./lib/uniform-block.js";
export { decodeVertexFormat } from "./adapter/utils/decode-vertex-format.js";
export { decodeTextureFormat } from "./adapter/utils/decode-texture-format.js";
export { default as StatsManager } from "./lib/utils/stats-manager.js";
export { assert } from "./lib/utils/assert.js";
export { cast } from "./lib/utils/cast.js";
export { log } from "./lib/utils/log.js";
export { uid, isPowerOfTwo, isObjectEmpty } from "./lib/utils/utils.js";
export { formatValue } from "./lib/utils/format-value.js";
export { stubRemovedMethods } from "./lib/utils/stub-methods.js";
export { checkProps } from "./lib/utils/check-props.js";
export { setPathPrefix, loadFile, loadImage, loadImageBitmap, loadScript } from "./lib/utils/load-file.js";
export { getScratchArrayBuffer, getScratchArray, fillArray } from "./lib/utils/array-utils-flat.js";
export { getRandom, random } from "./lib/utils/random.js";
export { formatCompilerLog } from "./lib/compiler-log/format-compiler-log.js";
export { requestAnimationFrame, cancelAnimationFrame } from "./lib/request-animation-frame.js";
export const glsl = x => "".concat(x);
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ import { lumaStats } from './lib/utils/stats-manager';

}
export declare const VERSION: string;
export { lumaStats };

@@ -7,0 +8,0 @@ declare const _default: any;

import { isBrowser } from '@probe.gl/env';
import { log } from './lib/utils/log.js';
import { lumaStats } from './lib/utils/stats-manager.js';
// Version detection using babel plugin
// @ts-expect-error
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source';
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
;
if (globalThis.luma && globalThis.luma.VERSION !== VERSION) {
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION}`);
}
if (!globalThis.luma) {
import { log } from "./lib/utils/log.js";
import { lumaStats } from "./lib/utils/stats-manager.js";
function init() {
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source';
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
if (globalThis.luma && globalThis.luma.VERSION !== VERSION) {
throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION, " vs ").concat(VERSION));
}
if (!globalThis.luma) {
if (isBrowser()) {
log.log(1, `luma.gl ${VERSION} - ${STARTUP_MESSAGE}`)();
log.log(1, "luma.gl ".concat(VERSION, " - ").concat(STARTUP_MESSAGE))();
}
globalThis.luma = globalThis.luma || {
VERSION,
version: VERSION,
log,
// A global stats object that various components can add information to
// E.g. see webgl/resource.js
stats: lumaStats,
VERSION,
version: VERSION,
log,
stats: lumaStats
};
}
return VERSION;
}
export const VERSION = init();
export { lumaStats };
export default globalThis.luma;
//# sourceMappingURL=init.js.map
/** WebGPU style compiler message */
export type CompilerMessage = {
export declare type CompilerMessage = {
type: 'error' | 'warning' | 'info';

@@ -4,0 +4,0 @@ message: string;

@@ -1,2 +0,2 @@

// luma.gl, MIT license
export {};
//# sourceMappingURL=compiler-message.js.map

@@ -1,47 +0,34 @@

/** @returns annotated errors or warnings */
export function formatCompilerLog(shaderLog, source, options) {
// Parse the error - note: browser and driver dependent
const lines = source.split(/\r?\n/);
let formattedLog = '';
for (const message of shaderLog) {
formattedLog += formatCompilerMessage(message, lines, message.lineNum, options);
}
return formattedLog;
const lines = source.split(/\r?\n/);
let formattedLog = '';
for (const message of shaderLog) {
formattedLog += formatCompilerMessage(message, lines, message.lineNum, options);
}
return formattedLog;
}
// Helpers
/** Format one message */
function formatCompilerMessage(message, lines, lineNum, options) {
if (options?.showSourceCode) {
// If we got error position on line add a `^^^` indicator on next line
const positionIndicator = message.linePos > 0 ? `${' '.repeat(message.linePos + 5)}^^^\n` : '';
const numberedLines = getNumberedLines(lines, lineNum);
return `\
${numberedLines}${positionIndicator}${message.type.toUpperCase()}: ${message.message}
`;
}
return `${message.type.toUpperCase()}: ${message.message}\n`;
if (options !== null && options !== void 0 && options.showSourceCode) {
const positionIndicator = message.linePos > 0 ? "".concat(' '.repeat(message.linePos + 5), "^^^\n") : '';
const numberedLines = getNumberedLines(lines, lineNum);
return "".concat(numberedLines).concat(positionIndicator).concat(message.type.toUpperCase(), ": ").concat(message.message, "\n\n");
}
return "".concat(message.type.toUpperCase(), ": ").concat(message.message, "\n");
}
function getNumberedLines(lines, lineNum) {
let numberedLines = '';
for (let line = lineNum - 2; line <= lineNum; line++) {
const sourceLine = lines[line];
if (sourceLine !== undefined) {
numberedLines += `${padLeft(String(line), 4)}: ${sourceLine}\n`;
}
let numberedLines = '';
for (let line = lineNum - 2; line <= lineNum; line++) {
const sourceLine = lines[line];
if (sourceLine !== undefined) {
numberedLines += "".concat(padLeft(String(line), 4), ": ").concat(sourceLine, "\n");
}
return numberedLines;
}
return numberedLines;
}
/**
* Pads a string with a number of spaces (space characters) to the left
* @param {String} string - string to pad
* @param {Number} digits - number of spaces to add
* @return {String} string - The padded string
*/
function padLeft(string, paddedLength) {
let result = '';
for (let i = string.length; i < paddedLength; ++i) {
result += ' ';
}
return result + string;
let result = '';
for (let i = string.length; i < paddedLength; ++i) {
result += ' ';
}
return result + string;
}
//# sourceMappingURL=format-compiler-log.js.map

@@ -1,70 +0,64 @@

// luma.gl, MIT license
import { DEFAULT_DEVICE_PROPS } from '../adapter/device.js';
import { lumaStats } from './utils/stats-manager.js';
import { log } from './utils/log.js';
import { assert } from '...js';
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { DEFAULT_DEVICE_PROPS } from "../adapter/device.js";
import { lumaStats } from "./utils/stats-manager.js";
import { log } from "./utils/log.js";
import { assert } from "../index.js";
const deviceList = new Map();
/**
* Entry point to the luma.gl GPU abstraction
* Register WebGPU and/or WebGL devices (controls application bundle size)
* Run-time selection of the first available Device
*/
class luma {
static registerDevices(deviceClasses /*: typeof Device */) {
for (const deviceClass of deviceClasses) {
assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
deviceList.set(deviceClass.type, deviceClass);
}
export default class luma {
static registerDevices(deviceClasses) {
for (const deviceClass of deviceClasses) {
assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);
deviceList.set(deviceClass.type, deviceClass);
}
static getAvailableDevices() {
// @ts-expect-error
return Array.from(deviceList).map(Device => Device.type);
}
static getAvailableDevices() {
return Array.from(deviceList).map(Device => Device.type);
}
static getSupportedDevices() {
return Array.from(deviceList).filter(Device => Device.isSupported()).map(Device => Device.type);
}
static setDefaultDeviceProps(props) {
Object.assign(DEFAULT_DEVICE_PROPS, props);
}
static async createDevice() {
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
props = {
...DEFAULT_DEVICE_PROPS,
...props
};
if (props.gl) {
props.type = 'webgl';
}
static getSupportedDevices() {
// @ts-expect-error
return Array.from(deviceList).filter(Device => Device.isSupported()).map(Device => Device.type);
}
static setDefaultDeviceProps(props) {
Object.assign(DEFAULT_DEVICE_PROPS, props);
}
/** Creates a device. Asynchronously. */
static async createDevice(props = {}) {
props = { ...DEFAULT_DEVICE_PROPS, ...props };
if (props.gl) {
props.type = 'webgl';
let Device;
switch (props.type) {
case 'webgpu':
Device = deviceList.get('webgpu');
if (Device) {
return await Device.create(props);
}
let Device;
switch (props.type) {
case 'webgpu':
Device = deviceList.get('webgpu');
if (Device) {
return await Device.create(props);
}
break;
case 'webgl':
case 'webgl1':
case 'webgl2':
Device = deviceList.get('webgl');
if (Device) {
return await Device.create(props);
}
break;
case 'best-available':
Device = deviceList.get('webgpu');
if (Device && Device.isSupported()) {
return await Device.create(props);
}
Device = deviceList.get('webgl');
if (Device && Device.isSupported()) {
return await Device.create(props);
}
break;
break;
case 'webgl':
case 'webgl1':
case 'webgl2':
Device = deviceList.get('webgl');
if (Device) {
return await Device.create(props);
}
throw new Error('No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.');
break;
case 'best-available':
Device = deviceList.get('webgpu');
if (Device && Device.isSupported()) {
return await Device.create(props);
}
Device = deviceList.get('webgl');
if (Device && Device.isSupported()) {
return await Device.create(props);
}
break;
}
throw new Error('No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.');
}
}
/** Global stats for all devices */
luma.stats = lumaStats;
/** Global log */
luma.log = log;
export default luma;
_defineProperty(luma, "stats", lumaStats);
_defineProperty(luma, "log", log);
//# sourceMappingURL=luma.js.map

@@ -1,4 +0,3 @@

/// <reference types="@types/node" />
export declare function requestAnimationFrame(callback: any): number | NodeJS.Timeout;
export declare function requestAnimationFrame(callback: (time?: any) => void): any;
export declare function cancelAnimationFrame(timerId: any): void;
//# sourceMappingURL=request-animation-frame.d.ts.map

@@ -1,13 +0,7 @@

// Node.js polyfills for requestAnimationFrame and cancelAnimationFrame
/* global window, setTimeout, clearTimeout */
/// <reference types="@types/node" />
export function requestAnimationFrame(callback) {
return typeof window !== 'undefined' && window.requestAnimationFrame
? window.requestAnimationFrame(callback)
: setTimeout(callback, 1000 / 60);
return typeof window !== 'undefined' && window.requestAnimationFrame ? window.requestAnimationFrame(callback) : setTimeout(callback, 1000 / 60);
}
export function cancelAnimationFrame(timerId) {
return typeof window !== 'undefined' && window.cancelAnimationFrame
? window.cancelAnimationFrame(timerId)
: clearTimeout(timerId);
return typeof window !== 'undefined' && window.cancelAnimationFrame ? window.cancelAnimationFrame(timerId) : clearTimeout(timerId);
}
//# sourceMappingURL=request-animation-frame.js.map

@@ -1,58 +0,50 @@

import { assert } from './utils/assert.js';
import { log } from './utils/log.js';
/** A uniform block holds a number of uniforms */
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { assert } from "./utils/assert.js";
import { log } from "./utils/log.js";
export default class UniformBlock {
constructor(layout, blockName) {
// readonly layout: UniformBufferLayout;
this.layout = {};
this.uniforms = {};
const binding = layout.bindings
.find(binding => binding.type === 'uniform' && binding.name === blockName);
if (!binding) {
throw new Error(blockName);
}
const uniformBlock = binding;
for (const uniform of uniformBlock.uniforms || []) {
this.layout[uniform.name] = uniform;
}
// TODO calculate
this.size = 256;
// Allocate three typed arrays pointing at same memory
this.data = new ArrayBuffer(this.size * 4);
this.typedArray = {
float32: new Float32Array(this.data),
sint32: new Int32Array(this.data),
uint32: new Uint32Array(this.data)
};
constructor(layout, blockName) {
_defineProperty(this, "layout", {});
_defineProperty(this, "uniforms", {});
_defineProperty(this, "size", void 0);
_defineProperty(this, "data", void 0);
_defineProperty(this, "typedArray", void 0);
const binding = layout.bindings.find(binding => binding.type === 'uniform' && binding.name === blockName);
if (!binding) {
throw new Error(blockName);
}
/** Set a map of uniforms */
setUniforms(uniforms) {
for (const [key, value] of Object.entries(uniforms)) {
if (this.layout[key] !== undefined) {
this._setValue(key, value);
}
else {
log.warn(`Unknown uniform ${key}`);
}
}
const uniformBlock = binding;
for (const uniform of uniformBlock.uniforms || []) {
this.layout[uniform.name] = uniform;
}
/** Get the current data ArrayBuffer */
getData() {
return this.data;
this.size = 256;
this.data = new ArrayBuffer(this.size * 4);
this.typedArray = {
float32: new Float32Array(this.data),
sint32: new Int32Array(this.data),
uint32: new Uint32Array(this.data)
};
}
setUniforms(uniforms) {
for (const [key, value] of Object.entries(uniforms)) {
if (this.layout[key] !== undefined) {
this._setValue(key, value);
} else {
log.warn("Unknown uniform ".concat(key));
}
}
_setValue(key, value) {
// @ts-ignore
const layout = this.layout.layout[key];
assert(layout, 'UniformLayoutStd140 illegal argument');
// @ts-ignore
const typedArray = this.typedArray[layout.type];
if (layout.size === 1) {
// single value -> just set it
typedArray[layout.offset] = value;
}
else {
// vector/matrix -> copy the supplied (typed) array, starting from offset
typedArray.set(value, layout.offset);
}
}
getData() {
return this.data;
}
_setValue(key, value) {
const layout = this.layout.layout[key];
assert(layout, 'UniformLayoutStd140 illegal argument');
const typedArray = this.typedArray[layout.type];
if (layout.size === 1) {
typedArray[layout.offset] = value;
} else {
typedArray.set(value, layout.offset);
}
}
}
//# sourceMappingURL=uniform-block.js.map

@@ -1,37 +0,35 @@

import { decodeUniformFormat, alignTo } from '../adapter/utils/decode-uniform-format.js';
// const ERR_ARGUMENT = 'UniformBufferLayout illegal argument';
/**
* Std140 layout for uniform buffers
* Supports manual listing of uniforms
* TODO - Parse shader and build a layout?
*/
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { decodeUniformFormat, alignTo } from "../adapter/utils/decode-uniform-format.js";
export default class UniformBufferLayout {
constructor(uniforms) {
this.layout = {};
this.size = 0;
// Add layout (type, size and offset) definitions for each uniform in the layout
for (const [key, uniformType] of Object.entries(uniforms)) {
const typeAndComponents = decodeUniformFormat(uniformType);
const { type, components: count } = typeAndComponents;
// First, align (bump) current offset to an even multiple of current object (1, 2, 4)
this.size = alignTo(this.size, count);
// Use the aligned size as the offset of the current uniform.
const offset = this.size;
// Then, add our object's padded size ((1, 2, multiple of 4) to the current offset
this.size += count;
this.layout[key] = { type, size: count, offset };
}
this.size += (4 - (this.size % 4)) % 4;
constructor(uniforms) {
_defineProperty(this, "layout", {});
_defineProperty(this, "size", 0);
for (const [key, uniformType] of Object.entries(uniforms)) {
const typeAndComponents = decodeUniformFormat(uniformType);
const {
type,
components: count
} = typeAndComponents;
this.size = alignTo(this.size, count);
const offset = this.size;
this.size += count;
this.layout[key] = {
type,
size: count,
offset
};
}
/** number of bytes needed for buffer allocation */
get byteLength() {
return this.size * 4;
}
has(name) {
return Boolean(this.layout[name]);
}
get(name) {
const layout = this.layout[name];
return layout;
}
this.size += (4 - this.size % 4) % 4;
}
get byteLength() {
return this.size * 4;
}
has(name) {
return Boolean(this.layout[name]);
}
get(name) {
const layout = this.layout[name];
return layout;
}
}
//# sourceMappingURL=uniform-buffer-layout.js.map

@@ -1,35 +0,36 @@

// luma.gl, MIT license
let arrayBuffer;
export function getScratchArrayBuffer(byteLength) {
if (!arrayBuffer || arrayBuffer.byteLength < byteLength) {
arrayBuffer = new ArrayBuffer(byteLength);
}
return arrayBuffer;
if (!arrayBuffer || arrayBuffer.byteLength < byteLength) {
arrayBuffer = new ArrayBuffer(byteLength);
}
return arrayBuffer;
}
export function getScratchArray(Type, length) {
const scratchArrayBuffer = getScratchArrayBuffer(Type.BYTES_PER_ELEMENT * length);
return new Type(scratchArrayBuffer, 0, length); // arrayBuffer, byteOffset, length (in elements)
const scratchArrayBuffer = getScratchArrayBuffer(Type.BYTES_PER_ELEMENT * length);
return new Type(scratchArrayBuffer, 0, length);
}
// Uses copyWithin to significantly speed up typed array value filling
export function fillArray(options) {
const { target, source, start = 0, count = 1 } = options;
const length = source.length;
const total = count * length;
let copied = 0;
for (let i = start; copied < length; copied++) {
target[i++] = source[copied];
const {
target,
source,
start = 0,
count = 1
} = options;
const length = source.length;
const total = count * length;
let copied = 0;
for (let i = start; copied < length; copied++) {
target[i++] = source[copied];
}
while (copied < total) {
if (copied < total - copied) {
target.copyWithin(start + copied, start, start + copied);
copied *= 2;
} else {
target.copyWithin(start + copied, start, start + total - copied);
copied = total;
}
while (copied < total) {
// If we have copied less than half, copy everything we got
// else copy remaining in one operation
if (copied < total - copied) {
target.copyWithin(start + copied, start, start + copied);
copied *= 2;
}
else {
target.copyWithin(start + copied, start, start + total - copied);
copied = total;
}
}
return options.target;
}
return options.target;
}
//# sourceMappingURL=array-utils-flat.js.map

@@ -1,8 +0,7 @@

// Recommendation is to ignore message but current test suite checks agains the
// message so keep it for now.
export function assert(condition, message) {
if (!condition) {
throw new Error(message || 'luma.gl: assertion failed.');
}
if (!condition) {
throw new Error(message || 'luma.gl: assertion failed.');
}
}
export default assert;
//# sourceMappingURL=assert.js.map

@@ -1,4 +0,4 @@

/** Helper for type downcasts, e.g. Buffer -> WebGPUBuffer */
export function cast(value) {
return value;
return value;
}
//# sourceMappingURL=cast.js.map

@@ -1,2 +0,2 @@

export type PropChecks = {
export declare type PropChecks = {
removedProps?: Record<string, any>;

@@ -3,0 +3,0 @@ replacedProps?: Record<string, string>;

@@ -1,33 +0,32 @@

import { log } from './log.js';
import { log } from "./log.js";
export function checkProps(className, props, propChecks) {
const { removedProps = {}, deprecatedProps = {}, replacedProps = {} } = propChecks;
// removedProps: Removed props no longer supported
// print error and link to upgrade guide
for (const propName in removedProps) {
if (propName in props) {
const replacementProp = removedProps[propName];
const replacement = replacementProp ? `${className}.${removedProps[propName]}` : 'N/A';
log.removed(`${className}.${propName}`, replacement)();
}
const {
removedProps = {},
deprecatedProps = {},
replacedProps = {}
} = propChecks;
for (const propName in removedProps) {
if (propName in props) {
const replacementProp = removedProps[propName];
const replacement = replacementProp ? "".concat(className, ".").concat(removedProps[propName]) : 'N/A';
log.removed("".concat(className, ".").concat(propName), replacement)();
}
// deprecatedProps: Deprecated props that can not be autosubstituted
// print warning and rely on caller to substitute
for (const propName in deprecatedProps) {
if (propName in props) {
const replacementProp = deprecatedProps[propName];
log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
}
}
for (const propName in deprecatedProps) {
if (propName in props) {
const replacementProp = deprecatedProps[propName];
log.deprecated("".concat(className, ".").concat(propName), "".concat(className, ".").concat(replacementProp))();
}
// replacedProps: Deprecated props that can be autosubstituted
// print warning and return updated props object
let newProps = null;
for (const [propName, replacementProp] of Object.entries(replacedProps)) {
if (propName in props) {
log.deprecated(`${className}.${propName}`, `${className}.${replacementProp}`)();
newProps = newProps || Object.assign({}, props);
newProps[replacementProp] = props[propName];
delete newProps[propName];
}
}
let newProps = null;
for (const [propName, replacementProp] of Object.entries(replacedProps)) {
if (propName in props) {
log.deprecated("".concat(className, ".").concat(propName), "".concat(className, ".").concat(replacementProp))();
newProps = newProps || Object.assign({}, props);
newProps[replacementProp] = props[propName];
delete newProps[propName];
}
return newProps || props;
}
return newProps || props;
}
//# sourceMappingURL=check-props.js.map

@@ -1,36 +0,42 @@

/** TODO @deprecated - delete when confident that probe.gl logging implements all opts */
function formatArrayValue(v, opts = {}) {
const { maxElts = 16, size = 1 } = opts;
let string = '[';
for (let i = 0; i < v.length && i < maxElts; ++i) {
if (i > 0) {
string += `,${i % size === 0 ? ' ' : ''}`;
}
string += formatValue(v[i], opts);
function formatArrayValue(v) {
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const {
maxElts = 16,
size = 1
} = opts;
let string = '[';
for (let i = 0; i < v.length && i < maxElts; ++i) {
if (i > 0) {
string += ",".concat(i % size === 0 ? ' ' : '');
}
const terminator = v.length > maxElts ? '...' : ']';
return `${string}${terminator}`;
string += formatValue(v[i], opts);
}
const terminator = v.length > maxElts ? '...' : ']';
return "".concat(string).concat(terminator);
}
/** TODO @deprecated - delete when confident that probe.gl logging implements all opts */
export function formatValue(v, opts = {}) {
const EPSILON = 1e-16;
const { isInteger = false } = opts;
if (Array.isArray(v) || ArrayBuffer.isView(v)) {
return formatArrayValue(v, opts);
}
if (typeof v !== 'number') {
return String(v);
}
if (Math.abs(v) < EPSILON) {
return isInteger ? '0' : '0.';
}
if (isInteger) {
return v.toFixed(0);
}
if (Math.abs(v) > 100 && Math.abs(v) < 10000) {
return v.toFixed(0);
}
const string = v.toPrecision(2);
const decimal = string.indexOf('.0');
return decimal === string.length - 2 ? string.slice(0, -1) : string;
export function formatValue(v) {
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const EPSILON = 1e-16;
const {
isInteger = false
} = opts;
if (Array.isArray(v) || ArrayBuffer.isView(v)) {
return formatArrayValue(v, opts);
}
if (typeof v !== 'number') {
return String(v);
}
if (Math.abs(v) < EPSILON) {
return isInteger ? '0' : '0.';
}
if (isInteger) {
return v.toFixed(0);
}
if (Math.abs(v) > 100 && Math.abs(v) < 10000) {
return v.toFixed(0);
}
const string = v.toPrecision(2);
const decimal = string.indexOf('.0');
return decimal === string.length - 2 ? string.slice(0, -1) : string;
}
//# sourceMappingURL=format-value.js.map

@@ -1,72 +0,48 @@

// luma.gl, MIT license
let pathPrefix = '';
/**
* Set a relative path prefix
*/
export function setPathPrefix(prefix) {
pathPrefix = prefix;
pathPrefix = prefix;
}
/**
* Reads raw file data. Respects setPathPrefix.
*/
export async function loadFile(url, options) {
url = url.startsWith('http') ? url : pathPrefix + url;
const dataType = options?.dataType || 'text';
const response = await fetch(url, options);
return await response[dataType]();
url = url.startsWith('http') ? url : pathPrefix + url;
const dataType = (options === null || options === void 0 ? void 0 : options.dataType) || 'text';
const response = await fetch(url, options);
return await response[dataType]();
}
/**
* Loads ImageBitmap asynchronously. Respects setPathPrefix.
* image.crossOrigin can be set via opts.crossOrigin, default to 'anonymous'
* @returns a promise tracking the load
*/
export async function loadImageBitmap(url, opts) {
const image = new Image();
image.crossOrigin = opts?.crossOrigin || 'anonymous';
image.src = url.startsWith('http') ? url : pathPrefix + url;
await image.decode();
return await createImageBitmap(image);
const image = new Image();
image.crossOrigin = (opts === null || opts === void 0 ? void 0 : opts.crossOrigin) || 'anonymous';
image.src = url.startsWith('http') ? url : pathPrefix + url;
await image.decode();
return await createImageBitmap(image);
}
/**
* Loads image asynchronously. Respects setPathPrefix.
* image.crossOrigin can be set via opts.crossOrigin, default to 'anonymous'
* @returns a promise tracking the load
* @deprecated Use `loadImageBitmap()` unless you are supporting old versions of Safari.
*/
export async function loadImage(url, opts) {
return new Promise((resolve, reject) => {
try {
const image = new Image();
image.onload = () => resolve(image);
image.onerror = () => reject(new Error(`Could not load image ${url}.`));
image.crossOrigin = opts?.crossOrigin || 'anonymous';
image.src = url.startsWith('http') ? url : pathPrefix + url;
}
catch (error) {
reject(error);
}
});
return new Promise((resolve, reject) => {
try {
const image = new Image();
image.onload = () => resolve(image);
image.onerror = () => reject(new Error("Could not load image ".concat(url, ".")));
image.crossOrigin = (opts === null || opts === void 0 ? void 0 : opts.crossOrigin) || 'anonymous';
image.src = url.startsWith('http') ? url : pathPrefix + url;
} catch (error) {
reject(error);
}
});
}
/**
* Load a script (identified by an url). When the url returns, the
* content of this file is added into a new script element, attached to the DOM (body element)
* @param scriptUrl defines the url of the script to laod
* @param scriptId defines the id of the script element
*/
export async function loadScript(scriptUrl, scriptId) {
const head = document.getElementsByTagName('head')[0];
if (!head) {
throw new Error('loadScript');
}
const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', scriptUrl);
if (scriptId) {
script.id = scriptId;
}
return new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = (error) => reject(new Error(`Unable to load script '${scriptUrl}': ${error}`));
head.appendChild(script);
});
const head = document.getElementsByTagName('head')[0];
if (!head) {
throw new Error('loadScript');
}
const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', scriptUrl);
if (scriptId) {
script.id = scriptId;
}
return new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = error => reject(new Error("Unable to load script '".concat(scriptUrl, "': ").concat(error)));
head.appendChild(script);
});
}
//# sourceMappingURL=load-file.js.map
import { Log } from '@probe.gl/log';
/** Global log instance */
export const log = new Log({ id: 'luma.gl' });
export const log = new Log({
id: 'luma.gl'
});
//# sourceMappingURL=log.js.map

@@ -1,15 +0,14 @@

/** Creates a deterministic pseudorandom number generator */
export function getRandom() {
let s = 1;
let c = 1;
return () => {
s = Math.sin(c * 17.23);
c = Math.cos(s * 27.92);
return fract(Math.abs(s * c) * 1432.71);
};
let s = 1;
let c = 1;
return () => {
s = Math.sin(c * 17.23);
c = Math.cos(s * 27.92);
return fract(Math.abs(s * c) * 1432.71);
};
}
function fract(n) {
return n - Math.floor(n);
return n - Math.floor(n);
}
/** Generates a deterministic pseudorandom number */
export const random = getRandom();
//# sourceMappingURL=random.js.map

@@ -0,20 +1,20 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Stats } from '@probe.gl/stats';
/**
* Helper class managing a collection of probe.gl stats objects
*/
export default class StatsManager {
constructor() {
this.stats = new Map();
constructor() {
_defineProperty(this, "stats", new Map());
}
getStats(name) {
return this.get(name);
}
get(name) {
if (!this.stats.has(name)) {
this.stats.set(name, new Stats({
id: name
}));
}
getStats(name) {
return this.get(name);
}
get(name) {
if (!this.stats.has(name)) {
this.stats.set(name, new Stats({ id: name }));
}
return this.stats.get(name);
}
return this.stats.get(name);
}
}
/** Global stats for all luma.gl devices */
export const lumaStats = new StatsManager();
//# sourceMappingURL=stats-manager.js.map

@@ -1,16 +0,15 @@

import { log } from './log.js';
// Install stubs for removed methods
import { log } from "./log.js";
export function stubRemovedMethods(instance, className, version, methodNames) {
const upgradeMessage = `See luma.gl ${version} Upgrade Guide at \
https://luma.gl/docs/upgrade-guide`;
const prototype = Object.getPrototypeOf(instance);
methodNames.forEach((methodName) => {
if (prototype.methodName) {
return;
}
prototype[methodName] = () => {
log.removed(`Calling removed method ${className}.${methodName}: `, upgradeMessage)();
throw new Error(methodName);
};
});
const upgradeMessage = "See luma.gl ".concat(version, " Upgrade Guide at https://luma.gl/docs/upgrade-guide");
const prototype = Object.getPrototypeOf(instance);
methodNames.forEach(methodName => {
if (prototype.methodName) {
return;
}
prototype[methodName] = () => {
log.removed("Calling removed method ".concat(className, ".").concat(methodName, ": "), upgradeMessage)();
throw new Error(methodName);
};
});
}
//# sourceMappingURL=stub-methods.js.map

@@ -1,31 +0,19 @@

// luma.gl, MIT license
const uidCounters = {};
/**
* Returns a UID.
* @param id= - Identifier base name
* @return uid
**/
export function uid(id = 'id') {
uidCounters[id] = uidCounters[id] || 1;
const count = uidCounters[id]++;
return `${id}-${count}`;
export function uid() {
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
uidCounters[id] = uidCounters[id] || 1;
const count = uidCounters[id]++;
return "".concat(id, "-").concat(count);
}
/**
* Verifies if a given number is power of two or not.
* @param n - The number to check.
* @return Returns true if the given number is power of 2, false otherwise.
**/
export function isPowerOfTwo(n) {
return (n > 0) && (n & (n - 1)) === 0;
return n > 0 && (n & n - 1) === 0;
}
/** Returns true if given object is empty, false otherwise. */
export function isObjectEmpty(obj) {
let isEmpty = true;
// @ts-ignore key is unused
// eslint-disable-next-line no-unused-vars
for (const key in obj) {
isEmpty = false;
break;
}
return isEmpty;
let isEmpty = true;
for (const key in obj) {
isEmpty = false;
break;
}
return isEmpty;
}
//# sourceMappingURL=utils.js.map
/** TypeScript type covering all typed arrays */
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
/** TypeScript type covering constructors of any of the typed arrays */
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Uint8ClampedArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
export declare type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Uint8ClampedArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
/** Keep big int arrays separate as they are still problematic, can't be indexed and don't work well on Safari */
export type BigIntTypedArray = BigInt64Array | BigUint64Array;
export declare type BigIntTypedArray = BigInt64Array | BigUint64Array;
/** type covering all typed arrays and classic arrays consisting of numbers */
export type NumberArray = number[] | TypedArray;
export type NumericArray = number[] | TypedArray;
export type BigIntOrNumberArray = NumberArray | BigIntTypedArray;
export type BigIntOrNumericArray = NumberArray | BigIntTypedArray;
export declare type NumberArray = number[] | TypedArray;
export declare type NumericArray = number[] | TypedArray;
export declare type BigIntOrNumberArray = NumberArray | BigIntTypedArray;
export declare type BigIntOrNumericArray = NumberArray | BigIntTypedArray;
/** Get the constructor type of a type */

@@ -21,3 +21,3 @@ export interface ConstructorOf<T> {

*/
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
//# sourceMappingURL=types.d.ts.map
export {};
//# sourceMappingURL=types.js.map
{
"name": "@luma.gl/api",
"version": "9.0.0-alpha.16",
"version": "9.0.0-alpha.17",
"description": "luma.gl API",
"license": "MIT",
"type": "module",
"publishConfig": {

@@ -20,7 +21,15 @@ "access": "public"

"types": "dist/index.d.ts",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"src",
"dist",
"dist.min.js",
"README.md"

@@ -30,4 +39,4 @@ ],

"scripts": {
"pre-build": "npm run build-bundle && npm run build-bundle -- --env.dev",
"build-bundle": "webpack --display=minimal --config ../../scripts/bundle.config.js"
"build-bundle": "ocular-bundle ./src/index.ts",
"pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev"
},

@@ -38,3 +47,3 @@ "dependencies": {

},
"gitHead": "697bc4ef1deff8438e2f3be51bf0bd245882106a"
"gitHead": "9385b56a95f5f53ee5f11d2ccef5b6114a527d94"
}

@@ -176,2 +176,4 @@ // luma.gl, MIT license

: [this.canvas.width, this.canvas.height];
default:
throw new Error(this.type);
}

@@ -269,3 +271,3 @@ }

log.warn(`Device pixel ratio clamped`)();
log.warn('Device pixel ratio clamped')();
}

@@ -272,0 +274,0 @@

// luma.gl, MIT license
import {VERSION} from '../init';
import StatsManager, {lumaStats} from '../lib/utils/stats-manager';

@@ -207,2 +208,4 @@ import {log} from '../lib/utils/log';

static VERSION = VERSION;
constructor(props: DeviceProps) {

@@ -209,0 +212,0 @@ this.props = {...DEFAULT_DEVICE_PROPS, ...props};

@@ -58,3 +58,3 @@ // luma.gl, MIT license

override get [Symbol.toStringTag](): string { return 'Buffer'; }
override get [Symbol.toStringTag](): string { return 'Buffer'; }

@@ -61,0 +61,0 @@ constructor(device: Device, props: BufferProps) {

// luma.gl, MIT license
import Resource, {ResourceProps} from './resource';
import Resource, {ResourceProps, DEFAULT_RESOURCE_PROPS} from './resource';
import Buffer from './buffer';

@@ -78,2 +78,6 @@ import Texture from './texture';

const DEFAULT_COMMAND_ENCODER_PROPS = {
...DEFAULT_RESOURCE_PROPS
};
/**

@@ -83,3 +87,3 @@ * Encodes commands to queue that can be executed later

export default abstract class CommandEncoder extends Resource<CommandEncoderProps> {
override get [Symbol.toStringTag](): string {
override get [Symbol.toStringTag](): string {
return 'CommandEncoder';

@@ -120,2 +124,2 @@ }

// }): void;
};
}

@@ -9,3 +9,3 @@ import Resource, {ResourceProps, DEFAULT_RESOURCE_PROPS} from './resource';

export default abstract class ComputePass extends Resource<ComputePassProps> {
override get [Symbol.toStringTag](): string {
override get [Symbol.toStringTag](): string {
return 'ComputePass';

@@ -12,0 +12,0 @@ }

@@ -27,3 +27,3 @@ //

export default abstract class ComputePipeline extends Resource<ComputePipelineProps> {
override get [Symbol.toStringTag](): string {
override get [Symbol.toStringTag](): string {
return 'ComputePipeline';

@@ -37,2 +37,2 @@ }

}
};
}

@@ -16,3 +16,3 @@ import type Device from '../device';

export default abstract class Texture extends Resource<ExternalTextureProps> {
override get [Symbol.toStringTag](): string { return 'ExternalTexture'; }
override get [Symbol.toStringTag](): string { return 'ExternalTexture'; }

@@ -19,0 +19,0 @@ constructor(device: Device, props: ExternalTextureProps) {

@@ -26,4 +26,4 @@ import type {ColorTextureFormat, DepthStencilTextureFormat} from '../types/texture-formats';

*/
export default abstract class Framebuffer extends Resource<FramebufferProps> {
override get [Symbol.toStringTag](): string { return 'Framebuffer'; }
export default abstract class Framebuffer extends Resource<FramebufferProps> {
override get [Symbol.toStringTag](): string { return 'Framebuffer'; }

@@ -30,0 +30,0 @@ /** Width of all attachments in this framebuffer */

@@ -23,3 +23,3 @@ // luma.gl, MIT license

export default abstract class RenderPass extends Resource<RenderPassProps> {
override get [Symbol.toStringTag](): string {
override get [Symbol.toStringTag](): string {
return 'RenderPass';

@@ -26,0 +26,0 @@ }

@@ -93,3 +93,3 @@ // luma.gl, MIT license

export default abstract class RenderPipeline extends Resource<RenderPipelineProps> {
override get [Symbol.toStringTag](): string { return 'RenderPipeline'; }
override get [Symbol.toStringTag](): string { return 'RenderPipeline'; }

@@ -96,0 +96,0 @@ hash: string = '';

@@ -46,3 +46,3 @@ // luma.gl, MIT license

export default abstract class Sampler extends Resource<SamplerProps> {
override get [Symbol.toStringTag](): string {
override get [Symbol.toStringTag](): string {
return 'Sampler';

@@ -49,0 +49,0 @@ }

@@ -44,3 +44,3 @@ // luma.gl, MIT license

export default abstract class Shader extends Resource<ShaderProps> {
override get [Symbol.toStringTag](): string { return 'Shader'; }
override get [Symbol.toStringTag](): string { return 'Shader'; }

@@ -47,0 +47,0 @@ readonly stage: 'vertex' | 'fragment' | 'compute';

@@ -124,3 +124,3 @@ // luma.gl, MIT license

override get [Symbol.toStringTag](): string { return 'Texture'; }
override get [Symbol.toStringTag](): string { return 'Texture'; }

@@ -127,0 +127,0 @@ constructor(device: Device, props: TextureProps) {

@@ -34,2 +34,2 @@ // luma.gl, MIT license

index?: number;
};
}

@@ -16,9 +16,9 @@ import {DepthStencilTextureFormat} from './texture-formats';

export type PrimitiveTopology =
"point-list" |
"line-list" |
"line-strip" |
'point-list' |
'line-list' |
'line-strip' |
/** @deprecated */
'line-loop' |
"triangle-list" |
"triangle-strip" |
'triangle-list' |
'triangle-strip' |
/** @deprecated */

@@ -25,0 +25,0 @@ 'triangle-fan';

@@ -22,3 +22,3 @@ import {TextureFormat} from '../types/texture-formats';

} {
const matches = (format as string).match(REGEX);
const matches = REGEX.exec((format as string));
if (matches) {

@@ -25,0 +25,0 @@ const [, format, length, type, srgb, suffix] = matches;

// luma.gl, MIT license
// Initialize any global state
import './init';
export {VERSION} from './init';
// MAIN API ACCESS POINTS

@@ -6,0 +6,0 @@ export {default as luma} from './lib/luma';

@@ -5,36 +5,47 @@ import {isBrowser} from '@probe.gl/env';

// Version detection using babel plugin
// @ts-expect-error
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source';
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
// Assign luma.log.level in console to control logging: \
// 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
// luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
declare global {
// eslint-disable-next-line no-var
var luma: any
};
if (globalThis.luma && globalThis.luma.VERSION !== VERSION) {
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION}`);
}
if (!globalThis.luma) {
if (isBrowser()) {
log.log(1, `luma.gl ${VERSION} - ${STARTUP_MESSAGE}`)();
/**
* By adding the result of init() to Device.VERSION we guarantee it will be called
* @returns version
*/
function init(): string {
// Version detection using babel plugin
// @ts-expect-error
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'untranspiled source';
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
// Assign luma.log.level in console to control logging: \
// 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
// luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
if (globalThis.luma && globalThis.luma.VERSION !== VERSION) {
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION}`);
}
globalThis.luma = globalThis.luma || {
VERSION,
version: VERSION,
log,
if (!globalThis.luma) {
if (isBrowser()) {
log.log(1, `luma.gl ${VERSION} - ${STARTUP_MESSAGE}`)();
}
// A global stats object that various components can add information to
// E.g. see webgl/resource.js
stats: lumaStats,
};
globalThis.luma = globalThis.luma || {
VERSION,
version: VERSION,
log,
// A global stats object that various components can add information to
// E.g. see webgl/resource.js
stats: lumaStats,
};
}
return VERSION;
}
export const VERSION = init();
export {lumaStats};
export default globalThis.luma;

@@ -25,3 +25,3 @@ // luma.gl, MIT license

static registerDevices(deviceClasses: any[] /*: typeof Device */): void {
static registerDevices(deviceClasses: any[] /* : typeof Device */): void {
for (const deviceClass of deviceClasses) {

@@ -28,0 +28,0 @@ assert(deviceClass.type && deviceClass.isSupported && deviceClass.create);

// Node.js polyfills for requestAnimationFrame and cancelAnimationFrame
/* global window, setTimeout, clearTimeout */
/// <reference types="@types/node" />
export function requestAnimationFrame(callback: any): number | NodeJS.Timeout {
// / <reference types="@types/node" />
export function requestAnimationFrame(callback: (time?: any) => void): any {
return typeof window !== 'undefined' && window.requestAnimationFrame

@@ -7,0 +7,0 @@ ? window.requestAnimationFrame(callback)

@@ -26,3 +26,3 @@ // luma.gl, MIT license

for (let i = start; copied < length; copied++) {
target[i++] = source[copied] as number;
target[i++] = source[copied] ;
}

@@ -29,0 +29,0 @@

@@ -29,3 +29,3 @@ // luma.gl, MIT license

// @ts-ignore key is unused
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const key in obj) {

@@ -32,0 +32,0 @@ isEmpty = false;

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 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 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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc