@luma.gl/engine 9.0.0-alpha.5 → 9.0.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +9 -9
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -31
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +115 -199
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +6 -7
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/animation-loop/render-loop.d.ts +23 -0
- package/dist/animation-loop/render-loop.d.ts.map +1 -0
- package/dist/animation-loop/render-loop.js +7 -0
- package/dist/animation-loop/render-loop.js.map +1 -0
- package/dist/dist.dev.js +7064 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +15 -8
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +50 -59
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +32 -97
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +107 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +2959 -0
- package/dist/index.d.ts +26 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -40
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +50 -148
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +192 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +312 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +62 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +49 -0
- package/dist/shader-inputs.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +62 -0
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +286 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +16 -15
- package/src/{lib → animation-loop}/animation-loop.ts +120 -107
- package/src/{lib → animation-loop}/animation-props.ts +5 -5
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/animation-loop/render-loop.ts +23 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +6 -3
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +7 -6
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +79 -119
- package/src/geometry/gpu-geometry.ts +124 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +38 -12
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +60 -168
- package/src/model/model.ts +549 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +132 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -176
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -179
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/src/lib/model.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type {Device, Buffer, RenderPipelineProps, RenderPass, Binding} from '@luma.gl/api';
|
|
2
|
-
import {RenderPipeline, Shader, cast} from '@luma.gl/api';
|
|
3
|
-
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
|
-
import type Geometry from '../geometry/geometry';
|
|
5
|
-
import {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';
|
|
6
|
-
import PipelineFactory from './pipeline-factory';
|
|
7
|
-
|
|
8
|
-
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
9
|
-
// Model also accepts a string
|
|
10
|
-
vs?: {glsl?: string; wgsl?: string} | string;
|
|
11
|
-
fs?: {glsl?: string; wgsl?: string} | string;
|
|
12
|
-
modules?: ShaderModule[];
|
|
13
|
-
moduleSettings?: Record<string, Record<string, any>>;
|
|
14
|
-
geometry?: Geometry;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const DEFAULT_MODEL_PROPS: Required<ModelProps> = {
|
|
18
|
-
...RenderPipeline._DEFAULT_PROPS,
|
|
19
|
-
vs: undefined,
|
|
20
|
-
fs: undefined,
|
|
21
|
-
id: 'unnamed',
|
|
22
|
-
handle: undefined,
|
|
23
|
-
userData: {},
|
|
24
|
-
modules: [],
|
|
25
|
-
moduleSettings: {},
|
|
26
|
-
geometry: undefined
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/** v9 API */
|
|
30
|
-
export default class Model {
|
|
31
|
-
readonly device: Device;
|
|
32
|
-
readonly pipeline: RenderPipeline;
|
|
33
|
-
readonly id: string;
|
|
34
|
-
readonly vs: string;
|
|
35
|
-
readonly fs: string | undefined;
|
|
36
|
-
readonly topology: string;
|
|
37
|
-
readonly vertexCount;
|
|
38
|
-
props: Required<ModelProps>;
|
|
39
|
-
|
|
40
|
-
private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;
|
|
41
|
-
|
|
42
|
-
constructor(device: Device, props: ModelProps) {
|
|
43
|
-
this.props = {...DEFAULT_MODEL_PROPS, ...props};
|
|
44
|
-
props = this.props;
|
|
45
|
-
this.id = props.id;
|
|
46
|
-
this.device = device;
|
|
47
|
-
|
|
48
|
-
// Create the pipeline
|
|
49
|
-
this.vs = getShaderSource(this.device, props.vs);
|
|
50
|
-
if (props.fs) {
|
|
51
|
-
this.fs = getShaderSource(this.device, props.fs);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.vertexCount = this.props.vertexCount;
|
|
55
|
-
this.topology = this.props.topology;
|
|
56
|
-
|
|
57
|
-
if (this.props.geometry) {
|
|
58
|
-
this.vertexCount = this.props.geometry.vertexCount;
|
|
59
|
-
this.topology = this.props.geometry.topology;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const {renderPipeline, getUniforms} = PipelineFactory.getDefaultPipelineFactory(this.device).createRenderPipeline({
|
|
63
|
-
...this.props,
|
|
64
|
-
vs: this.vs,
|
|
65
|
-
fs: this.fs,
|
|
66
|
-
topology: this.topology,
|
|
67
|
-
parameters: props.parameters,
|
|
68
|
-
// Geometry in the vertex shader!
|
|
69
|
-
// @ts-expect-error
|
|
70
|
-
layout: props.layout
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
this.pipeline = renderPipeline;
|
|
74
|
-
this._getModuleUniforms = getUniforms;
|
|
75
|
-
|
|
76
|
-
if (this.props.geometry) {
|
|
77
|
-
this._setGeometry(this.props.geometry);
|
|
78
|
-
}
|
|
79
|
-
this.setUniforms(this._getModuleUniforms()) // Get all default module uniforms
|
|
80
|
-
this.setProps(this.props);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
destroy(): void {
|
|
84
|
-
this.pipeline.destroy();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
draw(renderPass?: RenderPass): this {
|
|
88
|
-
this.pipeline.draw({
|
|
89
|
-
renderPass,
|
|
90
|
-
vertexCount: this.vertexCount,
|
|
91
|
-
instanceCount: this.props.instanceCount
|
|
92
|
-
});
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
setProps(props: ModelProps): this {
|
|
97
|
-
if (props.indices) {
|
|
98
|
-
this.setIndexBuffer(props.indices);
|
|
99
|
-
}
|
|
100
|
-
if (props.attributes) {
|
|
101
|
-
this.setAttributes(props.attributes);
|
|
102
|
-
}
|
|
103
|
-
if (props.bindings) {
|
|
104
|
-
this.setBindings(props.bindings);
|
|
105
|
-
}
|
|
106
|
-
if (props.uniforms) {
|
|
107
|
-
this.setUniforms(props.uniforms);
|
|
108
|
-
}
|
|
109
|
-
if (props.moduleSettings) {
|
|
110
|
-
this.updateModuleSettings(props.moduleSettings);
|
|
111
|
-
}
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
updateModuleSettings(props: Record<string, any>): this {
|
|
116
|
-
const uniforms = this._getModuleUniforms(props);
|
|
117
|
-
this.setUniforms(uniforms);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
setIndexBuffer(indices: Buffer): this {
|
|
122
|
-
this.pipeline.setIndexBuffer(indices);
|
|
123
|
-
// this._indices = indices;
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
setAttributes(attributes: Record<string, Buffer>): this {
|
|
128
|
-
this.pipeline.setAttributes(attributes);
|
|
129
|
-
Object.assign(this.props.attributes, attributes);
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Set the bindings */
|
|
134
|
-
setBindings(bindings: Record<string, Binding>): this {
|
|
135
|
-
this.pipeline.setBindings(bindings);
|
|
136
|
-
Object.assign(this.props.bindings, bindings);
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
setUniforms(uniforms: Record<string, any>): this {
|
|
141
|
-
this.pipeline.setUniforms(uniforms);
|
|
142
|
-
Object.assign(this.props.uniforms, uniforms);
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
_setGeometry(geometry: Geometry): void {
|
|
147
|
-
// this._deleteGeometryBuffers();
|
|
148
|
-
|
|
149
|
-
const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);
|
|
150
|
-
this.setAttributes(geometryBuffers);
|
|
151
|
-
|
|
152
|
-
const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);
|
|
153
|
-
if (indexBuffer) {
|
|
154
|
-
this.setIndexBuffer(indexBuffer);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** Create a shader from the different overloads */
|
|
160
|
-
function getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {
|
|
161
|
-
// TODO - detect WGSL/GLSL and throw an error if not supported
|
|
162
|
-
if (typeof shader === 'string') {
|
|
163
|
-
return shader;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
switch (device.info.type) {
|
|
167
|
-
case 'webgpu':
|
|
168
|
-
if (shader?.wgsl) {
|
|
169
|
-
return shader.wgsl;
|
|
170
|
-
}
|
|
171
|
-
throw new Error('WebGPU does not support GLSL shaders');
|
|
172
|
-
|
|
173
|
-
default:
|
|
174
|
-
if (shader?.glsl) {
|
|
175
|
-
return shader.glsl;
|
|
176
|
-
}
|
|
177
|
-
throw new Error('WebGL does not support WGSL shaders');
|
|
178
|
-
}
|
|
179
|
-
}
|
package/src/lib/render-loop.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type {DeviceProps} from '@luma.gl/api';
|
|
2
|
-
import type {AnimationProps} from '../lib/animation-props';
|
|
3
|
-
import AnimationLoop from './animation-loop';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Minimal animation loop that initializes models in constructor
|
|
7
|
-
* Simplifying type management
|
|
8
|
-
* v9 API
|
|
9
|
-
*/
|
|
10
|
-
export abstract class RenderLoop {
|
|
11
|
-
constructor(animationProps?: AnimationProps) {}
|
|
12
|
-
|
|
13
|
-
/** Instantiates and runs the render loop */
|
|
14
|
-
static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop {
|
|
15
|
-
// Create an animation loop;
|
|
16
|
-
const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);
|
|
17
|
-
|
|
18
|
-
// Start the loop automatically
|
|
19
|
-
// animationLoop.start();
|
|
20
|
-
|
|
21
|
-
return animationLoop;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Instantiates the RenderLoop once the device is created */
|
|
26
|
-
class SyncInitAnimationLoop extends AnimationLoop {
|
|
27
|
-
RenderLoopConstructor: typeof RenderLoop;
|
|
28
|
-
renderLoop: RenderLoop;
|
|
29
|
-
|
|
30
|
-
getInfo() {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
return this.RenderLoopConstructor.info;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
constructor(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps) {
|
|
36
|
-
super({deviceProps});
|
|
37
|
-
this.RenderLoopConstructor = RenderLoopConstructor;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
onInitialize(animationProps: AnimationProps) {
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
this.renderLoop = new this.RenderLoopConstructor(animationProps);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
onRender(animationProps: AnimationProps) {
|
|
46
|
-
// @ts-expect-error API still TBD
|
|
47
|
-
this.renderLoop?.onRender?.(animationProps);
|
|
48
|
-
// @ts-expect-error API still TBD
|
|
49
|
-
this.renderLoop?.frame?.(animationProps);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
onFinalize(animationProps: AnimationProps) {
|
|
53
|
-
// @ts-expect-error API still TBD
|
|
54
|
-
this.renderLoop?.onFinalize?.(animationProps);
|
|
55
|
-
// @ts-expect-error API still TBD
|
|
56
|
-
this.renderLoop?.destroy?.(animationProps);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
File without changes
|