Socket
Socket
Sign inDemoInstall

@luma.gl/engine

Package Overview
Dependencies
7
Maintainers
7
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.0-alpha.46 to 9.0.0-alpha.47

LICENSE

8

dist/geometry/gpu-geometry.js

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

import { Buffer, uid, assert } from '@luma.gl/core';
import { Buffer, uid, assert, getVertexFormatFromAttribute } from '@luma.gl/core';
export class GPUGeometry {

@@ -90,5 +90,9 @@ constructor(props) {

});
const {
value,
size
} = attribute;
bufferLayout.push({
name,
format: `float32x${attribute.size}`
format: getVertexFormatFromAttribute(value, size)
});

@@ -95,0 +99,0 @@ }

@@ -39,2 +39,4 @@ import type { TypedArray, RenderPipelineProps, RenderPipelineParameters, BufferLayout, VertexArray, AttributeInfo, TransformFeedback } from '@luma.gl/core';

constantAttributes?: Record<string, TypedArray>;
/** @internal For use with {@link TransformFeedback}, WebGL 2 only. */
varyings?: string[];
transformFeedback?: TransformFeedback;

@@ -41,0 +43,0 @@ /** Mapped uniforms for shadertool modules */

@@ -264,2 +264,3 @@ import { RenderPipeline, log, uid, deepEqual, splitUniformsAndBindings } from '@luma.gl/core';

constantAttributes: {},
varyings: [],
pipelineFactory: undefined,

@@ -266,0 +267,0 @@ transformFeedback: undefined,

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

import { Device, Buffer, Texture, Framebuffer } from '@luma.gl/core';
import { GLParameters } from '@luma.gl/constants';
type TransformFeedback = any;
import { Device, Buffer, BufferRange, Framebuffer, TransformFeedback, PrimitiveTopology, RenderPassParameters, BufferLayout } from '@luma.gl/core';
import { ShaderModule } from '@luma.gl/shadertools';
import { Model } from '../model/model';
/** Properties for creating Transforms */

@@ -8,26 +8,15 @@ export type TransformProps = {

vs?: string;
elementCount?: number;
fs?: string;
vertexCount?: number;
sourceBuffers?: Record<string, Buffer>;
feedbackBuffers?: Record<string, string | Buffer | {
buffer: Buffer;
byteOffset?: number;
}>;
feedbackBuffers?: Record<string, Buffer | BufferRange>;
varyings?: string[];
feedbackMap?: Record<string, string>;
modules?: object[];
modules?: ShaderModule[];
attributes?: Record<string, any>;
bufferLayout?: BufferLayout[];
uniforms?: Record<string, any>;
defines?: Record<string, any>;
parameters?: GLParameters;
discard?: boolean;
isIndexed?: boolean;
inject?: Record<string, string>;
drawMode?: number;
framebuffer?: Framebuffer;
_sourceTextures?: Record<string, Texture>;
_targetTexture?: string | Texture;
_targetTextureVarying?: string;
_swapTexture?: string | null;
_fs?: string;
fs?: string;
topology?: PrimitiveTopology;
};

@@ -37,26 +26,8 @@ /** Options that can be provided when running a Transform */

framebuffer?: Framebuffer;
clearRenderTarget?: boolean;
/** @deprecated Use uniform buffers for portability. */
uniforms?: Record<string, any>;
parameters?: Record<string, any>;
parameters?: RenderPassParameters;
discard?: boolean;
};
/** Options that control drawing a Transform. Used by subclasses to return draw parameters */
export type TransformDrawOptions = {
attributes?: Record<string, any>;
framebuffer?: any;
uniforms?: object;
discard?: boolean;
parameters?: object;
transformFeedback?: any;
};
export type TransformBinding = {
sourceBuffers: Record<string, Buffer>;
sourceTextures: Record<string, Texture>;
feedbackBuffers?: Record<string, Buffer | {
buffer: Buffer;
}>;
transformFeedback?: TransformFeedback;
framebuffer?: Framebuffer;
targetTexture?: Texture;
};
/**

@@ -66,16 +37,11 @@ * Takes source and target buffers/textures and sets up the pipeline

export declare class Transform {
/**
* Check if Transforms are supported (they are not under WebGL1)
* @todo differentiate writing to buffer vs not
*/
static isSupported(device: Device | WebGLRenderingContext): boolean;
readonly device: Device;
readonly gl: WebGL2RenderingContext;
elementCount: number;
readonly model: Model;
readonly transformFeedback: TransformFeedback;
/** @deprecated Use device feature test. */
static isSupported(device: Device): boolean;
elementIDBuffer: Buffer | null;
constructor(device: Device | WebGLRenderingContext, props?: TransformProps);
/** Delete owned resources. */
constructor(device: Device, props?: TransformProps);
/** Destroy owned resources. */
destroy(): void;
/** @deprecated Use destroy*() */
delete(): void;
/** Run one transform loop. */

@@ -85,5 +51,9 @@ run(options?: TransformRunOptions): void;

swap(): void;
/** Return Buffer object for given varying name. */
getBuffer(varyingName: string): Buffer | null;
/** Return data either from Buffer or from Texture */
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
getBuffer(varyingName: string): Buffer | BufferRange | null;
readAsync(varyingName: string): Promise<Uint8Array>;
/**
* Return data either from Buffer or from Texture.
* @deprecated Prefer {@link readAsync}.
*/
getData(options?: {

@@ -98,6 +68,3 @@ packed?: boolean;

_updateModelProps(props: TransformProps): TransformProps;
_buildResourceTransforms(props: TransformProps): void;
_updateDrawOptions(options: TransformRunOptions): TransformDrawOptions;
}
export {};
//# sourceMappingURL=transform.d.ts.map

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

import { Buffer, assert } from '@luma.gl/core';
import { getShaderInfo, getPassthroughFS } from '@luma.gl/shadertools';
import { Model } from "../model/model.js";
export class Transform {
static isSupported(device) {
return false;
return device.features.has('transform-feedback-webgl2');
}

@@ -8,42 +11,81 @@ constructor(device) {

this.device = void 0;
this.gl = void 0;
this.elementCount = 0;
this.model = void 0;
this.transformFeedback = void 0;
this.elementIDBuffer = null;
assert(device.features.has('transform-feedback-webgl2'), 'Device must support transform feedback');
this.device = device;
this.model = new Model(this.device, {
vs: props.vs,
fs: props.fs || getPassthroughFS({
version: getShaderInfo(props.vs).version
}),
id: props.id || 'transform-model',
varyings: props.varyings,
attributes: props.attributes,
bufferLayout: props.bufferLayout,
topology: props.topology || 'point-list',
vertexCount: props.vertexCount,
defines: props.defines,
modules: props.modules
});
this.transformFeedback = this.device.createTransformFeedback({
layout: this.model.pipeline.shaderLayout,
buffers: props.feedbackBuffers
});
this.model.setTransformFeedback(this.transformFeedback);
Object.seal(this);
}
destroy() {}
delete() {
this.destroy();
destroy() {
if (this.model) {
this.model.destroy();
}
}
run(options) {
const {
clearRenderTarget = true
framebuffer,
parameters,
discard,
uniforms
} = options || {};
const updatedOpts = this._updateDrawOptions(options);
if (clearRenderTarget && updatedOpts.framebuffer) {}
const renderPass = this.device.beginRenderPass({
framebuffer,
parameters,
discard
});
if (uniforms) this.model.setUniforms(uniforms);
this.model.draw(renderPass);
renderPass.end();
}
swap() {}
swap() {
throw new Error('Not implemented');
}
getBuffer(varyingName) {
return null;
return this.transformFeedback.getBuffer(varyingName);
}
readAsync(varyingName) {
const result = this.getBuffer(varyingName);
if (result instanceof Buffer) {
return result.readAsync();
}
const {
buffer,
byteOffset = 0,
byteLength = buffer.byteLength
} = result;
return buffer.readAsync(byteOffset, byteLength);
}
getData() {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
throw new Error('Not implemented');
}
getFramebuffer() {
return null;
throw new Error('Not implemented');
}
update(props) {}
update(props) {
throw new Error('Not implemented');
}
_updateModelProps(props) {
const updatedProps = {
...props
};
return updatedProps;
throw new Error('Not implemented');
}
_buildResourceTransforms(props) {}
_updateDrawOptions(options) {
const updatedOpts = {
...options
};
return updatedOpts;
}
}
//# sourceMappingURL=transform.js.map
{
"name": "@luma.gl/engine",
"version": "9.0.0-alpha.46",
"version": "9.0.0-alpha.47",
"description": "WebGL2 Components for High Performance Rendering and Computation",

@@ -43,5 +43,5 @@ "type": "module",

"@babel/runtime": "^7.0.0",
"@luma.gl/constants": "9.0.0-alpha.46",
"@luma.gl/core": "9.0.0-alpha.46",
"@luma.gl/shadertools": "9.0.0-alpha.46",
"@luma.gl/constants": "9.0.0-alpha.47",
"@luma.gl/core": "9.0.0-alpha.47",
"@luma.gl/shadertools": "9.0.0-alpha.47",
"@math.gl/core": "^4.0.0",

@@ -51,3 +51,3 @@ "@probe.gl/log": "^4.0.2",

},
"gitHead": "c1e0602fd739f8d08e6532034a02e8cf658e188a"
"gitHead": "7c6e28518021f98c7d0739f5cbdac386144206a1"
}
import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';
import {Device, Buffer, uid, assert} from '@luma.gl/core';
import {Device, Buffer, uid, assert, getVertexFormatFromAttribute} from '@luma.gl/core';
import type {Geometry} from '../geometry/geometry';

@@ -117,3 +117,4 @@

attributes[name] = device.createBuffer({data: attribute.value, id: `${attributeName}-buffer`});
bufferLayout.push({name, format: `float32x${attribute.size as 2 | 3 | 4}`});
const {value, size} = attribute;
bufferLayout.push({name, format: getVertexFormatFromAttribute(value, size)});
}

@@ -120,0 +121,0 @@

@@ -63,2 +63,5 @@ // luma.gl, MIT license

/** @internal For use with {@link TransformFeedback}, WebGL 2 only. */
varyings?: string[];
transformFeedback?: TransformFeedback;

@@ -93,2 +96,3 @@

constantAttributes: {},
varyings: [],

@@ -95,0 +99,0 @@ pipelineFactory: undefined!,

@@ -1,18 +0,11 @@

// luma.gl, MIT license
// Copyright (c) vis.gl contributors
import {Device, Buffer, Texture, Framebuffer} from '@luma.gl/core';
import {GLParameters} from '@luma.gl/constants';
// import {getShaderInfo, getPassthroughFS} from '@luma.gl/shadertools';
// import {GL} from '@luma.gl/constants';
// import {Model} from '../model/model';
import {Device, Buffer, BufferRange, Framebuffer, TransformFeedback, assert, PrimitiveTopology, RenderPassParameters, BufferLayout} from '@luma.gl/core';
import {getShaderInfo, getPassthroughFS, ShaderModule} from '@luma.gl/shadertools';
import {Model} from '../model/model';
// import {AccessorObject} from '@luma.gl/webgl';
// import {default as TransformFeedback} from '../classic/transform-feedback';
// import BufferTransform from './buffer-transform';
// import TextureTransform from './texture-transform';
type TransformFeedback = any;
/** Properties for creating Transforms */

@@ -22,23 +15,24 @@ export type TransformProps = {

vs?: string;
elementCount?: number;
fs?: string;
vertexCount?: number;
sourceBuffers?: Record<string, Buffer>;
feedbackBuffers?: Record<string, string | Buffer | {buffer: Buffer; byteOffset?: number}>;
feedbackBuffers?: Record<string, Buffer | BufferRange>;
varyings?: string[];
feedbackMap?: Record<string, string>;
modules?: object[]; // TODO use ShaderModule type
modules?: ShaderModule[];
attributes?: Record<string, any>;
bufferLayout?: BufferLayout[];
uniforms?: Record<string, any>;
defines?: Record<string, any>
parameters?: GLParameters;
// parameters?: GLParameters;
discard?: boolean;
isIndexed?: boolean;
inject?: Record<string, string>;
drawMode?: number;
framebuffer?: Framebuffer;
_sourceTextures?: Record<string, Texture>;
_targetTexture?: string | Texture;
_targetTextureVarying?: string;
_swapTexture?: string | null;
_fs?: string;
fs?: string;
// isIndexed?: boolean;
// inject?: Record<string, string>;
topology?: PrimitiveTopology;
// framebuffer?: Framebuffer;
// _sourceTextures?: Record<string, Texture>;
// _targetTexture?: string | Texture;
// _targetTextureVarying?: string;
// _swapTexture?: string | null;
// _fs?: string;
};

@@ -49,5 +43,6 @@

framebuffer?: Framebuffer;
clearRenderTarget?: boolean;
// clearRenderTarget?: boolean;
/** @deprecated Use uniform buffers for portability. */
uniforms?: Record<string, any>;
parameters?: Record<string, any>;
parameters?: RenderPassParameters;
discard?: boolean;

@@ -57,19 +52,19 @@ };

/** Options that control drawing a Transform. Used by subclasses to return draw parameters */
export type TransformDrawOptions = {
attributes?: Record<string, any>;
framebuffer?: any;
uniforms?: object;
discard?: boolean;
parameters?: object;
transformFeedback?: any;
};
// export type TransformDrawOptions = {
// attributes?: Record<string, any>;
// framebuffer?: any;
// uniforms?: object;
// discard?: boolean;
// parameters?: object;
// transformFeedback?: TransformFeedback;
// };
export type TransformBinding = {
sourceBuffers: Record<string, Buffer>;
sourceTextures: Record<string, Texture>;
feedbackBuffers?: Record<string, Buffer | {buffer: Buffer}>;
transformFeedback?: TransformFeedback;
framebuffer?: Framebuffer;
targetTexture?: Texture;
};
// export type TransformBinding = {
// sourceBuffers: Record<string, Buffer>;
// sourceTextures: Record<string, Texture>;
// feedbackBuffers?: Record<string, Buffer | BufferRange>;
// transformFeedback?: TransformFeedback;
// framebuffer?: Framebuffer;
// targetTexture?: Texture;
// };

@@ -80,20 +75,11 @@ /**

export class Transform {
/**
* Check if Transforms are supported (they are not under WebGL1)
* @todo differentiate writing to buffer vs not
*/
static isSupported(device: Device | WebGLRenderingContext): boolean {
// try {
// const webglDevice = WebGLDevice.attach(device);
// return webglDevice.isWebGL2;
// } catch {
// return false;
// }
return false;
readonly device: Device;
readonly model: Model;
readonly transformFeedback: TransformFeedback;
/** @deprecated Use device feature test. */
static isSupported(device: Device): boolean {
return device.features.has('transform-feedback-webgl2');
}
readonly device: Device;
readonly gl: WebGL2RenderingContext;
// model: Model;
elementCount = 0;
// bufferTransform: BufferTransform | null = null;

@@ -103,31 +89,43 @@ // textureTransform: TextureTransform | null = null;

constructor(device: Device | WebGLRenderingContext, props: TransformProps = {}) {
/*
this.device = WebGLDevice.attach(device);
// TODO assert webgl2?
this.gl = this.device.gl2;
this._buildResourceTransforms(props);
constructor(device: Device, props: TransformProps = {}) {
assert(device.features.has('transform-feedback-webgl2'), 'Device must support transform feedback');
props = this._updateModelProps(props);
// @ts-expect-error TODO this is valid type error for params
this.device = device;
// this._buildResourceTransforms(props);
// props = this._updateModelProps(props);
this.model = new Model(this.device, {
...props,
vs: props.vs,
fs: props.fs || getPassthroughFS({version: getShaderInfo(props.vs).version}),
id: props.id || 'transform-model',
drawMode: props.drawMode || GL.POINTS,
vertexCount: props.elementCount
varyings: props.varyings,
attributes: props.attributes,
bufferLayout: props.bufferLayout,
topology: props.topology || 'point-list',
vertexCount: props.vertexCount,
defines: props.defines,
modules: props.modules,
});
this.transformFeedback = this.device.createTransformFeedback({
layout: this.model.pipeline.shaderLayout,
buffers: props.feedbackBuffers,
});
this.model.setTransformFeedback(this.transformFeedback);
// if (this.bufferTransform) {
// this.bufferTransform.setupResources({model: this.model});
// }
Object.seal(this);
*/
}
/** Delete owned resources. */
/** Destroy owned resources. */
destroy(): void {
// if (this.model) {
// this.model.destroy();
// }
if (this.model) {
this.model.destroy();
}
// if (this.bufferTransform) {

@@ -141,18 +139,17 @@ // this.bufferTransform.destroy();

/** @deprecated Use destroy*() */
delete(): void {
this.destroy();
}
/** Run one transform loop. */
run(options?: TransformRunOptions): void {
const {clearRenderTarget = true} = options || {};
const {framebuffer, parameters, discard, uniforms} = options || {};
// const {clearRenderTarget = true} = options || {};
const updatedOpts = this._updateDrawOptions(options);
// const updatedOpts = this._updateDrawOptions(options);
if (clearRenderTarget && updatedOpts.framebuffer) {
// clear(this.device, {framebuffer: updatedOpts.framebuffer, color: true});
}
// if (clearRenderTarget && updatedOpts.framebuffer) {
// clear(this.device, {framebuffer: updatedOpts.framebuffer, color: true});
// }
// this.model.transform(updatedOpts);
const renderPass = this.device.beginRenderPass({framebuffer, parameters, discard});
if (uniforms) this.model.setUniforms(uniforms);
this.model.draw(renderPass);
renderPass.end();
}

@@ -168,11 +165,23 @@

// assert(swapped, 'Nothing to swap');
throw new Error('Not implemented');
}
/** Return Buffer object for given varying name. */
getBuffer(varyingName: string): Buffer | null {
// return this.bufferTransform && this.bufferTransform.getBuffer(varyingName);
return null;
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
getBuffer(varyingName: string): Buffer | BufferRange | null {
return this.transformFeedback.getBuffer(varyingName);
}
/** Return data either from Buffer or from Texture */
readAsync(varyingName: string): Promise<Uint8Array> {
const result = this.getBuffer(varyingName);
if (result instanceof Buffer) {
return result.readAsync();
}
const {buffer, byteOffset = 0, byteLength = buffer.byteLength} = result;
return buffer.readAsync(byteOffset, byteLength);
}
/**
* Return data either from Buffer or from Texture.
* @deprecated Prefer {@link readAsync}.
*/
getData(options: {packed?: boolean; varyingName?: string} = {}) {

@@ -187,2 +196,3 @@ // const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean);

// return null;
throw new Error('Not implemented');
}

@@ -193,3 +203,3 @@

// return this.textureTransform?.getFramebuffer() || null;
return null;
throw new Error('Not implemented');
}

@@ -206,2 +216,3 @@

// }
throw new Error('Not implemented');
}

@@ -212,3 +223,3 @@

_updateModelProps(props: TransformProps): TransformProps {
const updatedProps: TransformProps = {...props};
// const updatedProps: TransformProps = {...props};
// const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean) ;

@@ -218,26 +229,27 @@ // for (const resourceTransform of resourceTransforms) {

// }
return updatedProps;
// return updatedProps;
throw new Error('Not implemented');
}
_buildResourceTransforms(props: TransformProps) {
// if (canCreateBufferTransform(props)) {
// this.bufferTransform = new BufferTransform(this.device, props);
// }
// if (canCreateTextureTransform(props)) {
// this.textureTransform = new TextureTransform(this.device, props);
// }
// assert(
// this.bufferTransform || this.textureTransform,
// 'must provide source/feedback buffers or source/target textures'
// );
}
// _buildResourceTransforms(props: TransformProps) {
// if (canCreateBufferTransform(props)) {
// this.bufferTransform = new BufferTransform(this.device, props);
// }
// if (canCreateTextureTransform(props)) {
// this.textureTransform = new TextureTransform(this.device, props);
// }
// assert(
// this.bufferTransform || this.textureTransform,
// 'must provide source/feedback buffers or source/target textures'
// );
// }
_updateDrawOptions(options: TransformRunOptions): TransformDrawOptions {
const updatedOpts = {...options};
// const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean) ;
// for (const resourceTransform of resourceTransforms) {
// updatedOpts = Object.assign(updatedOpts, resourceTransform.getDrawOptions(updatedOpts));
// }
return updatedOpts;
}
// _updateDrawOptions(options: TransformRunOptions): TransformDrawOptions {
// const updatedOpts = {...options};
// const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean) ;
// for (const resourceTransform of resourceTransforms) {
// updatedOpts = Object.assign(updatedOpts, resourceTransform.getDrawOptions(updatedOpts));
// }
// return updatedOpts;
// }
}

@@ -244,0 +256,0 @@

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

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc