Socket
Socket
Sign inDemoInstall

@luma.gl/engine

Package Overview
Dependencies
Maintainers
7
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/engine - npm Package Compare versions

Comparing version 9.0.0-beta.5 to 9.0.0-beta.6

dist/lib/shader-factory.d.ts

2

dist/animation-loop/animation-loop-template.d.ts

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

import type { AnimationProps } from './animation-props';
import type { AnimationProps } from "./animation-props.js";
/**

@@ -3,0 +3,0 @@ * Minimal class that represents a "componentized" rendering life cycle

@@ -18,3 +18,5 @@ /**

constructor(animationProps) { }
async onInitialize(animationProps) { return null; }
async onInitialize(animationProps) {
return null;
}
}
import { Device } from '@luma.gl/core';
import { Timeline } from '../animation/timeline';
import { AnimationProps } from './animation-props';
import { Timeline } from "../animation/timeline.js";
import { AnimationProps } from "./animation-props.js";
import { Stats, Stat } from '@probe.gl/stats';

@@ -5,0 +5,0 @@ /** AnimationLoop properties */

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -10,6 +11,8 @@ import { luma } from '@luma.gl/core';

onAddHTML: () => '',
onInitialize: async () => { return null; },
onInitialize: async () => {
return null;
},
onRender: () => { },
onFinalize: () => { },
onError: (error) => console.error(error), // eslint-disable-line no-console
onError: error => console.error(error), // eslint-disable-line no-console
stats: luma.stats.get(`animation-loop-${statIdCounter++}`),

@@ -19,3 +22,3 @@ // view parameters

autoResizeViewport: false,
autoResizeDrawingBuffer: false,
autoResizeDrawingBuffer: false
};

@@ -177,3 +180,3 @@ /** Convenient animation loop */

if (!this._nextFramePromise) {
this._nextFramePromise = new Promise((resolve) => {
this._nextFramePromise = new Promise(resolve => {
this._resolveNextFrame = resolve;

@@ -381,6 +384,11 @@ });

_resizeViewport() {
// TODO can we use canvas context to code this in a portable way?
// @ts-expect-error Expose on canvasContext
if (this.props.autoResizeViewport && this.device.gl) {
// @ts-expect-error Expose canvasContext
this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);
this.device.gl.viewport(0, 0,
// @ts-expect-error Expose canvasContext
this.device.gl.drawingBufferWidth,
// @ts-expect-error Expose canvasContext
this.device.gl.drawingBufferHeight);
}

@@ -387,0 +395,0 @@ }

import { Device } from '@luma.gl/core';
import { Timeline } from '../animation/timeline';
import type { AnimationLoop } from './animation-loop';
import { Timeline } from "../animation/timeline.js";
import type { AnimationLoop } from "./animation-loop.js";
/** Properties passed to every render frame */

@@ -5,0 +5,0 @@ export type AnimationProps = {

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

import { AnimationLoopTemplate } from './animation-loop-template';
import { AnimationLoop, AnimationLoopProps } from './animation-loop';
import { AnimationLoopTemplate } from "./animation-loop-template.js";
import { AnimationLoop, AnimationLoopProps } from "./animation-loop.js";
export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;

@@ -4,0 +4,0 @@ /** Instantiates and runs the render loop */

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { luma } from '@luma.gl/core';
import { AnimationLoop } from './animation-loop';
import { AnimationLoop } from "./animation-loop.js";
/** Instantiates and runs the render loop */

@@ -5,0 +7,0 @@ export function makeAnimationLoop(AnimationLoopTemplateCtor, props) {

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -11,4 +12,3 @@ let channelHandles = 1;

lastEngineTime = -1;
constructor() {
}
constructor() { }
addChannel(props) {

@@ -15,0 +15,0 @@ const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;

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

// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { GL } from '@luma.gl/constants';
import { flipRows, scalePixels } from './pixel-data-utils';
import { flipRows, scalePixels } from "./pixel-data-utils.js";
/**

@@ -4,0 +7,0 @@ * Reads pixels from a Framebuffer or Texture object into an HTML Image

@@ -47,2 +47,1 @@ // import {copyTextureToImage} from '../debug/copy-texture-to-image';

}
;

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -3,0 +4,0 @@ /**

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

import { TruncatedConeGeometry } from './truncated-cone-geometry';
import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
export type ConeGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { TruncatedConeGeometry } from './truncated-cone-geometry';
import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
export class ConeGeometry extends TruncatedConeGeometry {

@@ -4,0 +4,0 @@ constructor(props = {}) {

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

import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export type CubeGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export class CubeGeometry extends Geometry {
constructor(props = {}) {
const { id = uid('cube-geometry'), indices = true } = props;
super(indices ? {
...props,
id,
topology: 'triangle-list',
indices: { size: 1, value: CUBE_INDICES },
attributes: { ...ATTRIBUTES, ...props.attributes }
} : {
...props,
id,
topology: 'triangle-list',
indices: undefined,
attributes: { ...NON_INDEXED_ATTRIBUTES, ...props.attributes }
});
super(indices
? {
...props,
id,
topology: 'triangle-list',
indices: { size: 1, value: CUBE_INDICES },
attributes: { ...ATTRIBUTES, ...props.attributes }
}
: {
...props,
id,
topology: 'triangle-list',
indices: undefined,
attributes: { ...NON_INDEXED_ATTRIBUTES, ...props.attributes }
});
}

@@ -20,0 +22,0 @@ }

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

import { TruncatedConeGeometry } from './truncated-cone-geometry';
import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
export type CylinderGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { TruncatedConeGeometry } from './truncated-cone-geometry';
import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
export class CylinderGeometry extends TruncatedConeGeometry {

@@ -4,0 +4,0 @@ constructor(props = {}) {

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

import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export type IcoSphereGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { Vector3 } from '@math.gl/core';
import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
/* eslint-disable comma-spacing, max-statements, complexity */

@@ -5,0 +5,0 @@ const ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];

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

import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export type PlaneGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { Geometry } from '../geometry/geometry';
import { unpackIndexedGeometry } from '../geometry/geometry-utils';
import { Geometry } from "../geometry/geometry.js";
import { unpackIndexedGeometry } from "../geometry/geometry-utils.js";
// Primitives inspired by TDL http://code.google.com/p/webglsamples/,

@@ -5,0 +5,0 @@ // copyright 2011 Google Inc. new BSD License

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

import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export type SphereGeometryProps = {

@@ -3,0 +3,0 @@ id?: string;

import { uid } from '@luma.gl/core';
import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
// Primitives inspired by TDL http://code.google.com/p/webglsamples/,

@@ -4,0 +4,0 @@ // copyright 2011 Google Inc. new BSD License

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

import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
export type TruncatedConeGeometryProps = {

@@ -3,0 +3,0 @@ topRadius?: number;

import { uid } from '@luma.gl/core';
import { Geometry } from '../geometry/geometry';
import { Geometry } from "../geometry/geometry.js";
const INDEX_OFFSETS = {

@@ -4,0 +4,0 @@ x: [2, 0, 1],

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

// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
export {};

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

// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { uid, assert } from '@luma.gl/core';

@@ -2,0 +5,0 @@ export class Geometry {

import type { PrimitiveTopology, BufferLayout } from '@luma.gl/core';
import { Device, Buffer } from '@luma.gl/core';
import type { Geometry } from '../geometry/geometry';
import type { Geometry } from "../geometry/geometry.js";
export type GPUGeometryProps = {

@@ -5,0 +5,0 @@ id?: string;

@@ -1,41 +0,42 @@

export { Timeline } from './animation/timeline';
export { KeyFrames } from './animation/key-frames';
export type { AnimationProps } from './animation-loop/animation-props';
export { AnimationLoopTemplate } from './animation-loop/animation-loop-template';
export type { AnimationLoopProps } from './animation-loop/animation-loop';
export { AnimationLoop } from './animation-loop/animation-loop';
export type { MakeAnimationLoopProps } from './animation-loop/make-animation-loop';
export { makeAnimationLoop } from './animation-loop/make-animation-loop';
export type { ModelProps } from './model/model';
export { Model } from './model/model';
export type { BufferTransformProps } from './transform/buffer-transform';
export { BufferTransform } from './transform/buffer-transform';
export type { TextureTransformProps } from './transform/texture-transform';
export { TextureTransform } from './transform/texture-transform';
export { PipelineFactory } from './lib/pipeline-factory';
export { ClipSpace } from './lib/clip-space';
export { ScenegraphNode } from './scenegraph/scenegraph-node';
export { GroupNode } from './scenegraph/group-node';
export type { ModelNodeProps } from './scenegraph/model-node';
export { ModelNode } from './scenegraph/model-node';
export type { GeometryProps } from './geometry/geometry';
export { Geometry } from './geometry/geometry';
export type { GPUGeometryProps } from './geometry/gpu-geometry';
export { GPUGeometry } from './geometry/gpu-geometry';
export type { ConeGeometryProps } from './geometries/cone-geometry';
export { ConeGeometry } from './geometries/cone-geometry';
export type { CubeGeometryProps } from './geometries/cube-geometry';
export { CubeGeometry } from './geometries/cube-geometry';
export type { CylinderGeometryProps } from './geometries/cylinder-geometry';
export { CylinderGeometry } from './geometries/cylinder-geometry';
export type { IcoSphereGeometryProps } from './geometries/ico-sphere-geometry';
export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
export type { PlaneGeometryProps } from './geometries/plane-geometry';
export { PlaneGeometry } from './geometries/plane-geometry';
export type { SphereGeometryProps } from './geometries/sphere-geometry';
export { SphereGeometry } from './geometries/sphere-geometry';
export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geometry';
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
export type { ShaderModuleInputs } from './shader-inputs';
export { ShaderInputs as _ShaderInputs } from './shader-inputs';
export { Timeline } from "./animation/timeline.js";
export { KeyFrames } from "./animation/key-frames.js";
export type { AnimationProps } from "./animation-loop/animation-props.js";
export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.js";
export type { AnimationLoopProps } from "./animation-loop/animation-loop.js";
export { AnimationLoop } from "./animation-loop/animation-loop.js";
export type { MakeAnimationLoopProps } from "./animation-loop/make-animation-loop.js";
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
export type { ModelProps } from "./model/model.js";
export { Model } from "./model/model.js";
export type { BufferTransformProps } from "./transform/buffer-transform.js";
export { BufferTransform } from "./transform/buffer-transform.js";
export type { TextureTransformProps } from "./transform/texture-transform.js";
export { TextureTransform } from "./transform/texture-transform.js";
export { PipelineFactory } from "./lib/pipeline-factory.js";
export { ShaderFactory } from "./lib/shader-factory.js";
export { ClipSpace } from "./lib/clip-space.js";
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
export { GroupNode } from "./scenegraph/group-node.js";
export type { ModelNodeProps } from "./scenegraph/model-node.js";
export { ModelNode } from "./scenegraph/model-node.js";
export type { GeometryProps } from "./geometry/geometry.js";
export { Geometry } from "./geometry/geometry.js";
export type { GPUGeometryProps } from "./geometry/gpu-geometry.js";
export { GPUGeometry } from "./geometry/gpu-geometry.js";
export type { ConeGeometryProps } from "./geometries/cone-geometry.js";
export { ConeGeometry } from "./geometries/cone-geometry.js";
export type { CubeGeometryProps } from "./geometries/cube-geometry.js";
export { CubeGeometry } from "./geometries/cube-geometry.js";
export type { CylinderGeometryProps } from "./geometries/cylinder-geometry.js";
export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
export type { IcoSphereGeometryProps } from "./geometries/ico-sphere-geometry.js";
export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
export type { PlaneGeometryProps } from "./geometries/plane-geometry.js";
export { PlaneGeometry } from "./geometries/plane-geometry.js";
export type { SphereGeometryProps } from "./geometries/sphere-geometry.js";
export { SphereGeometry } from "./geometries/sphere-geometry.js";
export type { TruncatedConeGeometryProps } from "./geometries/truncated-cone-geometry.js";
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
export type { ShaderModuleInputs } from "./shader-inputs.js";
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
//# sourceMappingURL=index.d.ts.map
// luma.gl Engine API
// Animation
export { Timeline } from './animation/timeline';
export { KeyFrames } from './animation/key-frames';
export { AnimationLoopTemplate } from './animation-loop/animation-loop-template';
export { AnimationLoop } from './animation-loop/animation-loop';
export { makeAnimationLoop } from './animation-loop/make-animation-loop';
export { Model } from './model/model';
export { BufferTransform } from './transform/buffer-transform';
export { TextureTransform } from './transform/texture-transform';
export { PipelineFactory } from './lib/pipeline-factory';
export { Timeline } from "./animation/timeline.js";
export { KeyFrames } from "./animation/key-frames.js";
export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.js";
export { AnimationLoop } from "./animation-loop/animation-loop.js";
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
export { Model } from "./model/model.js";
export { BufferTransform } from "./transform/buffer-transform.js";
export { TextureTransform } from "./transform/texture-transform.js";
export { PipelineFactory } from "./lib/pipeline-factory.js";
export { ShaderFactory } from "./lib/shader-factory.js";
// Utils
export { ClipSpace } from './lib/clip-space';
export { ClipSpace } from "./lib/clip-space.js";
// Scenegraph Core nodes
export { ScenegraphNode } from './scenegraph/scenegraph-node';
export { GroupNode } from './scenegraph/group-node';
export { ModelNode } from './scenegraph/model-node';
export { Geometry } from './geometry/geometry';
export { GPUGeometry } from './geometry/gpu-geometry';
export { ConeGeometry } from './geometries/cone-geometry';
export { CubeGeometry } from './geometries/cube-geometry';
export { CylinderGeometry } from './geometries/cylinder-geometry';
export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
export { PlaneGeometry } from './geometries/plane-geometry';
export { SphereGeometry } from './geometries/sphere-geometry';
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
export { ShaderInputs as _ShaderInputs } from './shader-inputs';
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
export { GroupNode } from "./scenegraph/group-node.js";
export { ModelNode } from "./scenegraph/model-node.js";
export { Geometry } from "./geometry/geometry.js";
export { GPUGeometry } from "./geometry/gpu-geometry.js";
export { ConeGeometry } from "./geometries/cone-geometry.js";
export { CubeGeometry } from "./geometries/cube-geometry.js";
export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
export { PlaneGeometry } from "./geometries/plane-geometry.js";
export { SphereGeometry } from "./geometries/sphere-geometry.js";
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
import { Device } from '@luma.gl/core';
import { Model, ModelProps } from '../model/model';
import { Model, ModelProps } from "../model/model.js";
/**

@@ -4,0 +4,0 @@ * A flat geometry that covers the "visible area" that the GPU renders.

// ClipSpace
import { glsl } from '@luma.gl/core';
import { Model } from '../model/model';
import { Geometry } from '../geometry/geometry';
import { Model } from "../model/model.js";
import { Geometry } from "../geometry/geometry.js";
const CLIPSPACE_VERTEX_SHADER = glsl `\

@@ -29,3 +29,3 @@ #version 300 es

constructor(device, opts) {
const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
super(device, {

@@ -32,0 +32,0 @@ ...opts,

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

// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { RenderPipeline } from '@luma.gl/core';

@@ -2,0 +5,0 @@ /**

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

import type { TypedArray, RenderPipelineProps, RenderPipelineParameters } from '@luma.gl/core';
import type { TypedArray } from '@luma.gl/core';
import type { RenderPipelineProps, RenderPipelineParameters } from '@luma.gl/core';
import type { BufferLayout, VertexArray, TransformFeedback } from '@luma.gl/core';

@@ -7,6 +8,7 @@ import type { AttributeInfo, Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';

import { ShaderAssembler } from '@luma.gl/shadertools';
import { ShaderInputs } from '../shader-inputs';
import type { Geometry } from '../geometry/geometry';
import { GPUGeometry } from '../geometry/gpu-geometry';
import { PipelineFactory } from '../lib/pipeline-factory';
import { ShaderInputs } from "../shader-inputs.js";
import type { Geometry } from "../geometry/geometry.js";
import { GPUGeometry } from "../geometry/gpu-geometry.js";
import { PipelineFactory } from "../lib/pipeline-factory.js";
import { ShaderFactory } from "../lib/shader-factory.js";
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {

@@ -28,4 +30,6 @@ source?: string;

shaderInputs?: ShaderInputs;
/** pipeline factory to use to create render pipelines. Defaults to default factory for the device */
/** Factory used to create a {@link RenderPipeline}. Defaults to {@link Device} default factory. */
pipelineFactory?: PipelineFactory;
/** Factory used to create a {@link Shader}. Defaults to {@link Device} default factory. */
shaderFactory?: ShaderFactory;
/** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */

@@ -46,2 +50,4 @@ shaderAssembler?: ShaderAssembler;

constantAttributes?: Record<string, TypedArray>;
/** Some applications intentionally supply unused attributes */
ignoreUnknownAttributes?: boolean;
/** @internal For use with {@link TransformFeedback}, WebGL only. */

@@ -52,2 +58,4 @@ varyings?: string[];

moduleSettings?: Record<string, Record<string, any>>;
/** Show shader source in browser? */
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
};

@@ -69,2 +77,3 @@ /**

readonly pipelineFactory: PipelineFactory;
readonly shaderFactory: ShaderFactory;
userData: {

@@ -111,2 +120,3 @@ [key: string]: any;

private props;
private _destroyed;
constructor(device: Device, props: ModelProps);

@@ -135,3 +145,3 @@ destroy(): void;

* Updates the buffer layout.
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
* @note Triggers a pipeline rebuild / pipeline cache fetch
*/

@@ -189,3 +199,5 @@ setBufferLayout(bufferLayout: BufferLayout[]): void;

*/
setAttributes(buffers: Record<string, Buffer>, _option?: 'ignore-unknown'): void;
setAttributes(buffers: Record<string, Buffer>, options?: {
ignoreUnknownAttributes?: boolean;
}): void;
/**

@@ -192,0 +204,0 @@ * Sets constant attributes

@@ -1,12 +0,14 @@

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { Buffer, RenderPipeline, UniformStore, getTypedArrayFromDataType } from '@luma.gl/core';
import { Buffer, RenderPipeline, UniformStore } from '@luma.gl/core';
import { log, uid, deepEqual, splitUniformsAndBindings, isNumberArray } from '@luma.gl/core';
import { getAttributeInfosFromLayouts } from '@luma.gl/core';
import { getTypedArrayFromDataType, getAttributeInfosFromLayouts } from '@luma.gl/core';
import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
import { ShaderInputs } from '../shader-inputs';
import { makeGPUGeometry } from '../geometry/gpu-geometry';
import { PipelineFactory } from '../lib/pipeline-factory';
import { getDebugTableForShaderLayout } from '../debug/debug-shader-layout';
import { debugFramebuffer } from '../debug/debug-framebuffer';
import { ShaderInputs } from "../shader-inputs.js";
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
import { PipelineFactory } from "../lib/pipeline-factory.js";
import { ShaderFactory } from "../lib/shader-factory.js";
import { getDebugTableForShaderLayout } from "../debug/debug-shader-layout.js";
import { debugFramebuffer } from "../debug/debug-framebuffer.js";
const LOG_DRAW_PRIORITY = 2;

@@ -41,4 +43,7 @@ const LOG_DRAW_TIMEOUT = 10000;

pipelineFactory: undefined,
shaderFactory: undefined,
transformFeedback: undefined,
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
debugShaders: undefined,
ignoreUnknownAttributes: undefined
};

@@ -50,2 +55,3 @@ device;

pipelineFactory;
shaderFactory;
userData = {};

@@ -92,2 +98,3 @@ // Fixed properties (change can trigger pipeline rebuild)

props;
_destroyed = false;
constructor(device, props) {

@@ -139,2 +146,3 @@ this.props = { ...Model.defaultProps, ...props };

props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
// Create the pipeline

@@ -165,3 +173,5 @@ // @note order is important

if (props.attributes) {
this.setAttributes(props.attributes);
this.setAttributes(props.attributes, {
ignoreUnknownAttributes: props.ignoreUnknownAttributes
});
}

@@ -184,4 +194,2 @@ if (props.constantAttributes) {

}
// TODO - restore?
// this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms
// Catch any access to non-standard props

@@ -191,4 +199,9 @@ Object.seal(this);

destroy() {
if (this._destroyed)
return;
this.pipelineFactory.release(this.pipeline);
this.shaderFactory.release(this.pipeline.vs);
this.shaderFactory.release(this.pipeline.fs);
this._uniformStore.destroy();
this._destroyed = true;
}

@@ -210,5 +223,7 @@ // Draw call

this.pipeline.setBindings(this.bindings);
this.pipeline.setUniforms(this.uniforms);
this.pipeline.setUniformsWebGL(this.uniforms);
const { indexBuffer } = this.vertexArray;
const indexCount = indexBuffer ? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2) : undefined;
const indexCount = indexBuffer
? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)
: undefined;
this.pipeline.draw({

@@ -260,4 +275,4 @@ renderPass,

this.setIndexBuffer(gpuGeometry.indices);
this.setAttributes(gpuGeometry.attributes, 'ignore-unknown');
this.setAttributes(attributes);
this.setAttributes(gpuGeometry.attributes, { ignoreUnknownAttributes: true });
this.setAttributes(attributes, { ignoreUnknownAttributes: this.props.ignoreUnknownAttributes });
}

@@ -276,3 +291,3 @@ /**

* Updates the buffer layout.
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
* @note Triggers a pipeline rebuild / pipeline cache fetch
*/

@@ -373,3 +388,3 @@ setBufferLayout(bufferLayout) {

setUniforms(uniforms) {
this.pipeline.setUniforms(uniforms);
this.pipeline.setUniformsWebGL(uniforms);
Object.assign(this.uniforms, uniforms);

@@ -394,3 +409,3 @@ }

*/
setAttributes(buffers, _option) {
setAttributes(buffers, options) {
if (buffers.indices) {

@@ -415,3 +430,3 @@ log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();

}
if (!set && _option !== 'ignore-unknown') {
if (!set && (options?.ignoreUnknownAttributes || this.props.ignoreUnknownAttributes)) {
log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();

@@ -433,3 +448,3 @@ }

if (attributeInfo) {
this.vertexArray.setConstant(attributeInfo.location, value);
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
}

@@ -446,16 +461,22 @@ else {

if (this._pipelineNeedsUpdate) {
let prevShaderVs = null;
let prevShaderFs = null;
if (this.pipeline) {
log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
prevShaderVs = this.pipeline.vs;
prevShaderFs = this.pipeline.fs;
}
this._pipelineNeedsUpdate = false;
const vs = this.device.createShader({
const vs = this.shaderFactory.createShader({
id: `${this.id}-vertex`,
stage: 'vertex',
source: this.vs
source: this.vs,
debug: this.props.debugShaders
});
const fs = this.fs
? this.device.createShader({
? this.shaderFactory.createShader({
id: `${this.id}-fragment`,
stage: 'fragment',
source: this.fs
source: this.fs,
debug: this.props.debugShaders
})

@@ -472,2 +493,6 @@ : null;

this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
if (prevShaderVs)
this.shaderFactory.release(prevShaderVs);
if (prevShaderFs)
this.shaderFactory.release(prevShaderFs);
}

@@ -513,3 +538,3 @@ return this.pipeline;

// Update first 3 frames and then every 60 frames
if (!debugFramebuffers || ((this._drawCount++ > 3) && (this._drawCount % 60))) {
if (!debugFramebuffers || (this._drawCount++ > 3 && this._drawCount % 60)) {
return;

@@ -575,2 +600,3 @@ }

gpu: device.info.gpu,
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
features: device.features

@@ -577,0 +603,0 @@ };

import { Matrix4 } from '@math.gl/core';
import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
export type GroupNodeProps = ScenegraphNodeProps & {

@@ -4,0 +4,0 @@ children?: ScenegraphNode[];

import { Matrix4, Vector3 } from '@math.gl/core';
import { log } from '@luma.gl/core';
import { ScenegraphNode } from './scenegraph-node';
import { ScenegraphNode } from "./scenegraph-node.js";
export class GroupNode extends ScenegraphNode {

@@ -9,3 +9,3 @@ children;

const { children = [] } = props;
log.assert(children.every((child) => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
log.assert(children.every(child => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
super(props);

@@ -15,3 +15,6 @@ this.children = children;

getBounds() {
const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
const result = [
[Infinity, Infinity, Infinity],
[-Infinity, -Infinity, -Infinity]
];
this.traverse((node, { worldMatrix }) => {

@@ -29,3 +32,5 @@ const bounds = node.getBounds();

// Test all 8 corners of the box
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1).multiply(halfSize).add(center);
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1)
.multiply(halfSize)
.add(center);
for (let i = 0; i < 3; i++) {

@@ -43,3 +48,3 @@ result[0][i] = Math.min(result[0][i], position[i]);

destroy() {
this.children.forEach((child) => child.destroy());
this.children.forEach(child => child.destroy());
this.removeAll();

@@ -46,0 +51,0 @@ super.destroy();

import { RenderPass } from '@luma.gl/core';
import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
import { Model } from '../model/model';
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
import { Model } from "../model/model.js";
export type ModelNodeProps = ScenegraphNodeProps & {

@@ -5,0 +5,0 @@ model: Model;

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

import { ScenegraphNode } from './scenegraph-node';
import { ScenegraphNode } from "./scenegraph-node.js";
export class ModelNode extends ScenegraphNode {

@@ -27,3 +27,3 @@ model;

}
this.managedResources.forEach((resource) => resource.destroy());
this.managedResources.forEach(resource => resource.destroy());
this.managedResources = [];

@@ -30,0 +30,0 @@ }

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

// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { log } from '@luma.gl/core';

@@ -2,0 +5,0 @@ // import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';

import { Device, Buffer, BufferRange, TransformFeedback, RenderPassProps } from '@luma.gl/core';
import { Model } from '../model/model';
import { Model } from "../model/model.js";
import type { ModelProps } from '..';

@@ -4,0 +4,0 @@ /**

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { Buffer, assert } from '@luma.gl/core';
import { getPassthroughFS } from '@luma.gl/shadertools';
import { Model } from '../model/model';
import { Model } from "../model/model.js";
/**

@@ -16,6 +17,6 @@ * Creates a pipeline for buffer→buffer transforms.

static isSupported(device) {
return device.features.has('transform-feedback-webgl');
return device?.info?.type === 'webgl';
}
constructor(device, props = Model.defaultProps) {
assert(device.features.has('transform-feedback-webgl'), 'Device must support transform feedback');
assert(BufferTransform.isSupported(device), 'BufferTransform not yet implemented on WebGPU');
this.device = device;

@@ -26,7 +27,7 @@ this.model = new Model(this.device, {

topology: props.topology || 'point-list',
...props,
...props
});
this.transformFeedback = this.device.createTransformFeedback({
layout: this.model.pipeline.shaderLayout,
buffers: props.feedbackBuffers,
buffers: props.feedbackBuffers
});

@@ -33,0 +34,0 @@ this.model.setTransformFeedback(this.transformFeedback);

import { Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture } from '@luma.gl/core';
import { Model, ModelProps } from '../model/model';
import { Model, ModelProps } from "../model/model.js";
/**

@@ -4,0 +4,0 @@ * Properties for creating a {@link TextureTransform}

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { Model } from '../model/model';
import { Model } from "../model/model.js";
import { getPassthroughFS } from '@luma.gl/shadertools';

@@ -26,11 +27,12 @@ const FS_OUTPUT_VARIABLE = 'transform_output';

magFilter: 'nearest',
mipmapFilter: 'nearest',
mipmapFilter: 'nearest'
});
this.model = new Model(this.device, {
id: props.id || 'texture-transform-model',
fs: props.fs || getPassthroughFS({
input: props.targetTextureVarying,
inputChannels: props.targetTextureChannels,
output: FS_OUTPUT_VARIABLE
}),
fs: props.fs ||
getPassthroughFS({
input: props.targetTextureVarying,
inputChannels: props.targetTextureChannels,
output: FS_OUTPUT_VARIABLE
}),
vertexCount: props.vertexCount, // TODO(donmccurdy): Naming?

@@ -37,0 +39,0 @@ ...props

{
"name": "@luma.gl/engine",
"version": "9.0.0-beta.5",
"version": "9.0.0-beta.6",
"description": "3D Engine Components for luma.gl",

@@ -51,3 +51,3 @@ "type": "module",

},
"gitHead": "793d3ab42f5a572b6cb603ea78aabaa73a873301"
"gitHead": "cb2f0938d03a65e3588622ac99650b14a10488b6"
}

@@ -6,12 +6,12 @@ import type {AnimationProps} from './animation-props';

* (resource construction, repeated rendering, resource destruction)
*
* @note A motivation for this class compared to the raw animation loop is
* that it simplifies TypeScript code by allowing resources to be typed unconditionally
*
* @note A motivation for this class compared to the raw animation loop is
* that it simplifies TypeScript code by allowing resources to be typed unconditionally
* since they are allocated in the constructor rather than in onInitialized
*
*
* @note Introduced in luma.gl v9
*
* @example AnimationLoopTemplate is intended to be subclassed,
*
* @example AnimationLoopTemplate is intended to be subclassed,
* but the subclass should not be instantiated directly. Instead the subclass
* (i.e. the constructor of the subclass) should be used
* (i.e. the constructor of the subclass) should be used
* as an argument to create an AnimationLoop.

@@ -21,5 +21,7 @@ */

constructor(animationProps?: AnimationProps) {}
async onInitialize(animationProps: AnimationProps): Promise<unknown> { return null; }
async onInitialize(animationProps: AnimationProps): Promise<unknown> {
return null;
}
abstract onRender(animationProps: AnimationProps): unknown;
abstract onFinalize(animationProps: AnimationProps): void;
}

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -35,3 +36,3 @@

useDevicePixels?: number | boolean;
}
};

@@ -42,6 +43,8 @@ const DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {

onAddHTML: () => '',
onInitialize: async () => { return null; },
onInitialize: async () => {
return null;
},
onRender: () => {},
onFinalize: () => {},
onError: (error) => console.error(error), // eslint-disable-line no-console
onError: error => console.error(error), // eslint-disable-line no-console

@@ -53,3 +56,3 @@ stats: luma.stats.get(`animation-loop-${statIdCounter++}`),

autoResizeViewport: false,
autoResizeDrawingBuffer: false,
autoResizeDrawingBuffer: false
};

@@ -154,3 +157,2 @@

try {
let appContext;

@@ -181,3 +183,3 @@ if (!this._initialized) {

} catch (err: unknown) {
const error = err instanceof Error ? err : new Error('Unknown error')
const error = err instanceof Error ? err : new Error('Unknown error');
this.props.onError(error);

@@ -250,3 +252,3 @@ // this._running = false; // TODO

if (!this._nextFramePromise) {
this._nextFramePromise = new Promise((resolve) => {
this._nextFramePromise = new Promise(resolve => {
this._resolveNextFrame = resolve;

@@ -470,3 +472,3 @@ });

_getSizeAndAspect(): {width: number; height: number; aspect: number} {
_getSizeAndAspect(): {width: number; height: number; aspect: number} {
if (!this.device) {

@@ -495,6 +497,14 @@ return {width: 1, height: 1, aspect: 1};

_resizeViewport(): void {
// TODO can we use canvas context to code this in a portable way?
// @ts-expect-error Expose on canvasContext
if (this.props.autoResizeViewport && this.device.gl) {
// @ts-expect-error Expose canvasContext
this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);
this.device.gl.viewport(
0,
0,
// @ts-expect-error Expose canvasContext
this.device.gl.drawingBufferWidth,
// @ts-expect-error Expose canvasContext
this.device.gl.drawingBufferHeight
);
}

@@ -501,0 +511,0 @@ }

import {Device} from '@luma.gl/core';
import {Timeline} from '../animation/timeline'
import {Timeline} from '../animation/timeline';
import type {AnimationLoop} from './animation-loop';

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

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import {luma} from '@luma.gl/core';
import {AnimationLoopTemplate} from './animation-loop-template'
import {AnimationLoop, AnimationLoopProps} from './animation-loop'
import {AnimationLoopTemplate} from './animation-loop-template';
import {AnimationLoop, AnimationLoopProps} from './animation-loop';
import type {AnimationProps} from './animation-props';
export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
export type MakeAnimationLoopProps = Omit<
AnimationLoopProps,
'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'
>;
/** Instantiates and runs the render loop */
export function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop {
export function makeAnimationLoop(
AnimationLoopTemplateCtor: typeof AnimationLoopTemplate,
props?: MakeAnimationLoopProps
): AnimationLoop {
let renderLoop: AnimationLoopTemplate | null = null;

@@ -17,3 +26,3 @@

const animationLoop = new AnimationLoop({
... props,
...props,

@@ -30,3 +39,3 @@ device,

onRender: (animationProps: AnimationProps) => renderLoop?.onRender(animationProps),
onFinalize: (animationProps: AnimationProps) => renderLoop?.onFinalize(animationProps)

@@ -40,3 +49,3 @@ });

return this.AnimationLoopTemplateCtor.info;
}
};

@@ -43,0 +52,0 @@ // Start the loop automatically

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -12,19 +13,19 @@

export type ChannelOptions = {
delay?: number
duration?: number
rate?: number
repeat?: number
}
delay?: number;
duration?: number;
rate?: number;
repeat?: number;
};
export type AnimationOptions = {
setTime: (time: number) => void
}
setTime: (time: number) => void;
};
type Channel = {
time: number
delay: number
duration: number
rate: number
repeat: number
}
type Channel = {
time: number;
delay: number;
duration: number;
rate: number;
repeat: number;
};

@@ -34,5 +35,5 @@ type Animation = {

animation: {
setTime: (time: number) => void
}
}
setTime: (time: number) => void;
};
};

@@ -49,4 +50,3 @@ let channelHandles = 1;

constructor() {
}
constructor() {}

@@ -53,0 +53,0 @@ addChannel(props: ChannelOptions): number {

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import {Texture, Framebuffer} from '@luma.gl/core';

@@ -11,3 +14,3 @@ import {GL} from '@luma.gl/constants';

export type CopyTextureToImageOptions = {
sourceAttachment?: number;
sourceAttachment?: number;
targetMaxHeight?: number;

@@ -20,5 +23,5 @@ targetImage?: HTMLImageElement;

* @todo - can we move this to @luma.gl/core?
* @param source
* @param source
* @param options options passed to copyToDataUrl
* @returns
* @returns
*/

@@ -29,3 +32,2 @@ export function copyTextureToImage(

): HTMLImageElement {
const dataUrl = copyTextureToDataUrl(source, options);

@@ -42,3 +44,3 @@ const targetImage: HTMLImageElement = options?.targetImage || new Image();

* @param source texture or framebuffer to read from
* @param options
* @param options
*/

@@ -45,0 +47,0 @@ export function copyTextureToDataUrl(

@@ -13,3 +13,17 @@ import type {Framebuffer, Texture} from '@luma.gl/core';

fbo: Framebuffer | Texture,
{id, minimap, opaque, top = '0', left = '0', rgbaScale = 1}: {id: string, minimap?: boolean; opaque?: boolean, top?: string, left?: string, rgbaScale?: number}
{
id,
minimap,
opaque,
top = '0',
left = '0',
rgbaScale = 1
}: {
id: string;
minimap?: boolean;
opaque?: boolean;
top?: string;
left?: string;
rgbaScale?: number;
}
) {

@@ -38,3 +52,2 @@ if (!canvas) {

canvas.style.height = '400px';
}

@@ -59,2 +72,2 @@

ctx.putImageData(imageData, 0, 0);
};
}

@@ -11,3 +11,3 @@ // luma.gl

* @param name app should provide the most meaningful name, usually the model or pipeline name / id.
* @returns
* @returns
*/

@@ -14,0 +14,0 @@ export function getDebugTableForShaderLayout(

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

@@ -36,7 +37,3 @@

export function scalePixels(options: {
data: TypedArray;
width: number;
height: number;
}): {
export function scalePixels(options: {data: TypedArray; width: number; height: number}): {
data: Uint8Array;

@@ -43,0 +40,0 @@ width: number;

@@ -14,15 +14,19 @@ import {uid} from '@luma.gl/core';

const {id = uid('cube-geometry'), indices = true} = props;
super(indices ? {
...props,
id,
topology: 'triangle-list',
indices: {size: 1, value: CUBE_INDICES},
attributes: {...ATTRIBUTES, ...props.attributes}
} : {
...props,
id,
topology: 'triangle-list',
indices: undefined,
attributes: {...NON_INDEXED_ATTRIBUTES, ...props.attributes}
});
super(
indices
? {
...props,
id,
topology: 'triangle-list',
indices: {size: 1, value: CUBE_INDICES},
attributes: {...ATTRIBUTES, ...props.attributes}
}
: {
...props,
id,
topology: 'triangle-list',
indices: undefined,
attributes: {...NON_INDEXED_ATTRIBUTES, ...props.attributes}
}
);
}

@@ -29,0 +33,0 @@ }

@@ -14,3 +14,3 @@ import {uid} from '@luma.gl/core';

iterations?: number;
attributes?: any
attributes?: any;
};

@@ -17,0 +17,0 @@

@@ -8,3 +8,3 @@ import {uid} from '@luma.gl/core';

radius?: number;
attributes?: any
attributes?: any;
};

@@ -11,0 +11,0 @@

@@ -9,3 +9,3 @@ import {uid} from '@luma.gl/core';

nlong?: number;
attributes?: any
attributes?: any;
};

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

@@ -39,3 +39,4 @@ import {uid} from '@luma.gl/core';

TEXCOORD_0: {size: 2, value: attributes.TEXCOORD_0},
...props.attributes}
...props.attributes
}
});

@@ -42,0 +43,0 @@ }

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type {TypedArray, VertexFormat} from '@luma.gl/core';

@@ -9,9 +12,9 @@

attributes: {
POSITION: TypedArray,
NORMAL: TypedArray,
TEXCOORD_0: TypedArray,
[key: string]: TypedArray,
POSITION: TypedArray;
NORMAL: TypedArray;
TEXCOORD_0: TypedArray;
[key: string]: TypedArray;
};
indices?: Uint16Array | Uint32Array;
topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
}
};

@@ -47,2 +47,2 @@ // import type {Geometry} from './geometry';

// const normal = new Vector3(vec1).cross(vec2).normalize();
// }
// }

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type {PrimitiveTopology, TypedArray} from '@luma.gl/core';

@@ -101,3 +104,3 @@ import {uid, assert} from '@luma.gl/core';

/**
/**
* Return an object with all attributes plus indices added as a field.

@@ -122,6 +125,6 @@ * TODO Geometry types are a mess

* target: WebGL buffer type (string or constant)
*
* @param attributes
* @param indices
* @returns
*
* @param attributes
* @param indices
* @returns
*/

@@ -128,0 +131,0 @@ _setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this {

@@ -104,3 +104,3 @@ import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';

geometry: Geometry
): {attributes: Record<string, Buffer>, bufferLayout: BufferLayout[], vertexCount: number} {
): {attributes: Record<string, Buffer>; bufferLayout: BufferLayout[]; vertexCount: number} {
const bufferLayout: BufferLayout[] = [];

@@ -113,6 +113,14 @@

switch (attributeName) {
case 'POSITION': name = 'positions'; break;
case 'NORMAL': name = 'normals'; break;
case 'TEXCOORD_0': name = 'texCoords'; break;
case 'COLOR_0': name = 'colors'; break;
case 'POSITION':
name = 'positions';
break;
case 'NORMAL':
name = 'normals';
break;
case 'TEXCOORD_0':
name = 'texCoords';
break;
case 'COLOR_0':
name = 'colors';
break;
}

@@ -124,5 +132,5 @@ attributes[name] = device.createBuffer({data: attribute.value, id: `${attributeName}-buffer`});

const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices)
const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices);
return {attributes, bufferLayout, vertexCount};
}

@@ -26,2 +26,3 @@ // luma.gl Engine API

export {PipelineFactory} from './lib/pipeline-factory';
export {ShaderFactory} from './lib/shader-factory';

@@ -28,0 +29,0 @@ // Utils

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

// ClipSpace

@@ -33,22 +32,19 @@ import {Device, glsl} from '@luma.gl/core';

constructor(device: Device, opts: Omit<ModelProps, 'vs' | 'vertexCount' | 'geometry'>) {
const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
super(
device,
{
...opts,
vs: CLIPSPACE_VERTEX_SHADER,
super(device, {
...opts,
vs: CLIPSPACE_VERTEX_SHADER,
vertexCount: 4,
geometry: new Geometry({
topology: 'triangle-strip',
vertexCount: 4,
geometry: new Geometry({
topology: 'triangle-strip',
vertexCount: 4,
attributes: {
aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},
aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},
aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}
}
})
}
);
attributes: {
aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},
aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},
aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}
}
})
});
}
}

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type {RenderPipelineProps} from '@luma.gl/core';

@@ -3,0 +6,0 @@ import {Device, RenderPipeline} from '@luma.gl/core';

@@ -1,17 +0,12 @@

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';
import type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';
import type {TypedArray} from '@luma.gl/core';
import type {DeviceFeature, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';
import type {Shader, BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';
import type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';
import {
Device,
Buffer,
RenderPipeline,
RenderPass,
UniformStore,
getTypedArrayFromDataType
} from '@luma.gl/core';
import {Device, Buffer, RenderPipeline, RenderPass, UniformStore} from '@luma.gl/core';
import {log, uid, deepEqual, splitUniformsAndBindings, isNumberArray} from '@luma.gl/core';
import {getAttributeInfosFromLayouts} from '@luma.gl/core';
import {getTypedArrayFromDataType, getAttributeInfosFromLayouts} from '@luma.gl/core';
import type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';

@@ -23,2 +18,3 @@ import {ShaderAssembler, getShaderLayoutFromWGSL} from '@luma.gl/shadertools';

import {PipelineFactory} from '../lib/pipeline-factory';
import {ShaderFactory} from '../lib/shader-factory';
import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';

@@ -34,2 +30,3 @@ import {debugFramebuffer} from '../debug/debug-framebuffer';

fs: {glsl?: string; wgsl?: string} | string | null;
/** shadertool shader modules (added to shader code) */

@@ -43,4 +40,6 @@ modules?: ShaderModule[];

shaderInputs?: ShaderInputs;
/** pipeline factory to use to create render pipelines. Defaults to default factory for the device */
/** Factory used to create a {@link RenderPipeline}. Defaults to {@link Device} default factory. */
pipelineFactory?: PipelineFactory;
/** Factory used to create a {@link Shader}. Defaults to {@link Device} default factory. */
shaderFactory?: ShaderFactory;
/** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */

@@ -65,2 +64,4 @@ shaderAssembler?: ShaderAssembler;

constantAttributes?: Record<string, TypedArray>;
/** Some applications intentionally supply unused attributes */
ignoreUnknownAttributes?: boolean;

@@ -74,2 +75,5 @@ /** @internal For use with {@link TransformFeedback}, WebGL only. */

moduleSettings?: Record<string, Record<string, any>>;
/** Show shader source in browser? */
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
};

@@ -105,4 +109,8 @@

pipelineFactory: undefined!,
shaderFactory: undefined!,
transformFeedback: undefined,
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
debugShaders: undefined,
ignoreUnknownAttributes: undefined
};

@@ -115,2 +123,3 @@

readonly pipelineFactory: PipelineFactory;
readonly shaderFactory: ShaderFactory;
userData: {[key: string]: any} = {};

@@ -170,2 +179,4 @@

private _destroyed = false;
constructor(device: Device, props: ModelProps) {

@@ -232,2 +243,3 @@ this.props = {...Model.defaultProps, ...props};

props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);

@@ -262,3 +274,5 @@ // Create the pipeline

if (props.attributes) {
this.setAttributes(props.attributes);
this.setAttributes(props.attributes, {
ignoreUnknownAttributes: props.ignoreUnknownAttributes
});
}

@@ -282,5 +296,2 @@ if (props.constantAttributes) {

// TODO - restore?
// this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms
// Catch any access to non-standard props

@@ -291,4 +302,8 @@ Object.seal(this);

destroy(): void {
if (this._destroyed) return;
this.pipelineFactory.release(this.pipeline);
this.shaderFactory.release(this.pipeline.vs);
this.shaderFactory.release(this.pipeline.fs);
this._uniformStore.destroy();
this._destroyed = true;
}

@@ -316,7 +331,9 @@

this.pipeline.setBindings(this.bindings);
this.pipeline.setUniforms(this.uniforms);
this.pipeline.setUniformsWebGL(this.uniforms);
const {indexBuffer} = this.vertexArray;
const indexCount = indexBuffer ? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2) : undefined;
const indexCount = indexBuffer
? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)
: undefined;
this.pipeline.draw({

@@ -373,4 +390,4 @@ renderPass,

this.setIndexBuffer(gpuGeometry.indices);
this.setAttributes(gpuGeometry.attributes, 'ignore-unknown');
this.setAttributes(attributes);
this.setAttributes(gpuGeometry.attributes, {ignoreUnknownAttributes: true});
this.setAttributes(attributes, {ignoreUnknownAttributes: this.props.ignoreUnknownAttributes});
}

@@ -391,3 +408,3 @@

* Updates the buffer layout.
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
* @note Triggers a pipeline rebuild / pipeline cache fetch
*/

@@ -502,3 +519,3 @@ setBufferLayout(bufferLayout: BufferLayout[]): void {

setUniforms(uniforms: Record<string, UniformValue>): void {
this.pipeline.setUniforms(uniforms);
this.pipeline.setUniformsWebGL(uniforms);
Object.assign(this.uniforms, uniforms);

@@ -526,3 +543,6 @@ }

*/
setAttributes(buffers: Record<string, Buffer>, _option?: 'ignore-unknown'): void {
setAttributes(
buffers: Record<string, Buffer>,
options?: {ignoreUnknownAttributes?: boolean}
): void {
if (buffers.indices) {

@@ -534,3 +554,5 @@ log.warn(

for (const [bufferName, buffer] of Object.entries(buffers)) {
const bufferLayout = this.bufferLayout.find(layout => getAttributeNames(layout).includes(bufferName));
const bufferLayout = this.bufferLayout.find(layout =>
getAttributeNames(layout).includes(bufferName)
);
if (!bufferLayout) {

@@ -551,3 +573,3 @@ log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();

}
if (!set && _option !== 'ignore-unknown') {
if (!set && (options?.ignoreUnknownAttributes || this.props.ignoreUnknownAttributes)) {
log.warn(

@@ -572,3 +594,3 @@ `Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`

if (attributeInfo) {
this.vertexArray.setConstant(attributeInfo.location, value);
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
} else {

@@ -588,2 +610,4 @@ log.warn(

if (this._pipelineNeedsUpdate) {
let prevShaderVs: Shader | null = null;
let prevShaderFs: Shader | null = null;
if (this.pipeline) {

@@ -594,2 +618,4 @@ log.log(

)();
prevShaderVs = this.pipeline.vs;
prevShaderFs = this.pipeline.fs;
}

@@ -599,14 +625,16 @@

const vs = this.device.createShader({
const vs = this.shaderFactory.createShader({
id: `${this.id}-vertex`,
stage: 'vertex',
source: this.vs
source: this.vs,
debug: this.props.debugShaders
});
const fs = this.fs
? this.device.createShader({
id: `${this.id}-fragment`,
stage: 'fragment',
source: this.fs
})
? this.shaderFactory.createShader({
id: `${this.id}-fragment`,
stage: 'fragment',
source: this.fs,
debug: this.props.debugShaders
})
: null;

@@ -627,2 +655,5 @@

);
if (prevShaderVs) this.shaderFactory.release(prevShaderVs);
if (prevShaderFs) this.shaderFactory.release(prevShaderFs);
}

@@ -678,3 +709,3 @@ return this.pipeline;

// Update first 3 frames and then every 60 frames
if (!debugFramebuffers || ((this._drawCount++ > 3) && (this._drawCount % 60))) {
if (!debugFramebuffers || (this._drawCount++ > 3 && this._drawCount % 60)) {
return;

@@ -749,3 +780,4 @@ }

gpu: device.info.gpu,
features: device.features
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
features: device.features as unknown as Set<DeviceFeature>
};

@@ -752,0 +784,0 @@ }

@@ -7,3 +7,3 @@ import {Matrix4, Vector3} from '@math.gl/core';

children?: ScenegraphNode[];
}
};

@@ -20,3 +20,3 @@ export class GroupNode extends ScenegraphNode {

log.assert(
children.every((child) => child instanceof ScenegraphNode),
children.every(child => child instanceof ScenegraphNode),
'every child must an instance of ScenegraphNode'

@@ -29,3 +29,6 @@ );

override getBounds(): [number[], number[]] | null {
const result: [number[], number[]] = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
const result: [number[], number[]] = [
[Infinity, Infinity, Infinity],
[-Infinity, -Infinity, -Infinity]
];

@@ -45,7 +48,5 @@ this.traverse((node, {worldMatrix}) => {

// Test all 8 corners of the box
const position = new Vector3(
v & 0b001 ? -1 : 1,
v & 0b010 ? -1 : 1,
v & 0b100 ? -1 : 1
).multiply(halfSize).add(center);
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1)
.multiply(halfSize)
.add(center);

@@ -65,3 +66,3 @@ for (let i = 0; i < 3; i++) {

override destroy(): void {
this.children.forEach((child) => child.destroy());
this.children.forEach(child => child.destroy());
this.removeAll();

@@ -97,3 +98,6 @@ super.destroy();

traverse(visitor: (node: ScenegraphNode, context: {worldMatrix: Matrix4}) => void, {worldMatrix = new Matrix4()} = {}) {
traverse(
visitor: (node: ScenegraphNode, context: {worldMatrix: Matrix4}) => void,
{worldMatrix = new Matrix4()} = {}
) {
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);

@@ -100,0 +104,0 @@

@@ -9,3 +9,3 @@ import {RenderPass} from '@luma.gl/core';

bounds?: [number[], number[]];
}
};

@@ -42,3 +42,3 @@ export class ModelNode extends ScenegraphNode {

}
this.managedResources.forEach((resource) => resource.destroy());
this.managedResources.forEach(resource => resource.destroy());
this.managedResources = [];

@@ -45,0 +45,0 @@ }

@@ -13,3 +13,3 @@ import {assert, uid, NumberArray} from '@luma.gl/core';

scale?: NumberArray;
update?: boolean
update?: boolean;
};

@@ -21,3 +21,3 @@

display = true;
display = true;
position = new Vector3();

@@ -24,0 +24,0 @@ rotation = new Vector3();

@@ -1,8 +0,10 @@

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import type {UniformValue, Texture, Sampler} from '@luma.gl/core';
import {log} from '@luma.gl/core';
// import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core';
import {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools'
import {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools';
/** Minimal ShaderModule subset, we don't need shader code etc */

@@ -43,4 +45,4 @@ export type ShaderModuleInputs<

> {
/**
* The map of modules
/**
* The map of modules
* @todo should should this include the resolved dependencies?

@@ -63,4 +65,8 @@ */

// TODO - get all dependencies from modules
const allModules =_resolveModules(Object.values(modules));
log.log(1, 'Creating ShaderInputs with modules', allModules.map(m => m.name))();
const allModules = _resolveModules(Object.values(modules));
log.log(
1,
'Creating ShaderInputs with modules',
allModules.map(m => m.name)
)();

@@ -99,4 +105,5 @@ // Store the module definitions and create storage for uniform values and binding values, per module

const oldUniforms = this.moduleUniforms[moduleName];
const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps as any;
const oldUniforms = this.moduleUniforms[moduleName];
const uniforms =
module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || (moduleProps as any);
// console.error(uniforms)

@@ -119,4 +126,4 @@ this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms};

/**
* Return the map of modules
/**
* Return the map of modules
* @todo should should this include the resolved dependencies?

@@ -143,3 +150,3 @@ */

getDebugTable(): Record<string, Record<string, unknown>> {
const table: Record<string,Record<string, unknown>> = {};
const table: Record<string, Record<string, unknown>> = {};
for (const [moduleName, module] of Object.entries(this.moduleUniforms)) {

@@ -146,0 +153,0 @@ for (const [key, value] of Object.entries(module)) {

@@ -1,8 +0,16 @@

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import {Device, Buffer, BufferRange, TransformFeedback, assert, RenderPassProps} from '@luma.gl/core';
import {
Device,
Buffer,
BufferRange,
TransformFeedback,
assert,
RenderPassProps
} from '@luma.gl/core';
import {getPassthroughFS} from '@luma.gl/shadertools';
import {Model} from '../model/model';
import type { ModelProps } from '..';
import type {ModelProps} from '..';

@@ -29,7 +37,7 @@ /**

static isSupported(device: Device): boolean {
return device.features.has('transform-feedback-webgl');
return device?.info?.type === 'webgl';
}
constructor(device: Device, props: BufferTransformProps = Model.defaultProps) {
assert(device.features.has('transform-feedback-webgl'), 'Device must support transform feedback');
assert(BufferTransform.isSupported(device), 'BufferTransform not yet implemented on WebGPU');

@@ -42,3 +50,3 @@ this.device = device;

topology: props.topology || 'point-list',
...props,
...props
});

@@ -48,3 +56,3 @@

layout: this.model.pipeline.shaderLayout,
buffers: props.feedbackBuffers,
buffers: props.feedbackBuffers
});

@@ -51,0 +59,0 @@

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

// luma.gl, MIT license
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture } from '@luma.gl/core';
import { Model, ModelProps } from '../model/model';
import { getPassthroughFS } from '@luma.gl/shadertools';
import {Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture} from '@luma.gl/core';
import {Model, ModelProps} from '../model/model';
import {getPassthroughFS} from '@luma.gl/shadertools';

@@ -27,3 +28,2 @@ /**

type TextureBinding = {

@@ -46,3 +46,3 @@ sourceBuffers: Record<string, Buffer>;

readonly sampler: Sampler;
currentIndex = 0;

@@ -62,3 +62,3 @@ samplerTextureMap: Record<string, any> | null = null;

magFilter: 'nearest',
mipmapFilter: 'nearest',
mipmapFilter: 'nearest'
});

@@ -68,7 +68,9 @@

id: props.id || 'texture-transform-model',
fs: props.fs || getPassthroughFS({
input: props.targetTextureVarying,
inputChannels: props.targetTextureChannels,
output: FS_OUTPUT_VARIABLE
}),
fs:
props.fs ||
getPassthroughFS({
input: props.targetTextureVarying,
inputChannels: props.targetTextureChannels,
output: FS_OUTPUT_VARIABLE
}),
vertexCount: props.vertexCount, // TODO(donmccurdy): Naming?

@@ -116,3 +118,2 @@ ...props

getFramebuffer(): Framebuffer {

@@ -119,0 +120,0 @@ const currentResources = this.bindings[this.currentIndex];

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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