@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.
Files changed (171) hide show
  1. package/LICENSE +3 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +6 -27
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +9 -9
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +18 -49
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -31
  11. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  12. package/dist/{lib → animation-loop}/animation-loop.js +115 -199
  13. package/dist/animation-loop/animation-loop.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +6 -7
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js.map +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  19. package/dist/animation-loop/make-animation-loop.js +28 -0
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.d.ts +23 -0
  22. package/dist/animation-loop/render-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/render-loop.js +7 -0
  24. package/dist/animation-loop/render-loop.js.map +1 -0
  25. package/dist/dist.dev.js +7064 -0
  26. package/dist/geometries/cone-geometry.d.ts +1 -1
  27. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/cone-geometry.js +6 -5
  29. package/dist/geometries/cone-geometry.js.map +1 -1
  30. package/dist/geometries/cube-geometry.d.ts +2 -2
  31. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cube-geometry.js +15 -8
  33. package/dist/geometries/cube-geometry.js.map +1 -1
  34. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  35. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  36. package/dist/geometries/cylinder-geometry.js +6 -5
  37. package/dist/geometries/cylinder-geometry.js.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  39. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  40. package/dist/geometries/ico-sphere-geometry.js +10 -19
  41. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  42. package/dist/geometries/plane-geometry.d.ts +2 -2
  43. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  44. package/dist/geometries/plane-geometry.js +14 -23
  45. package/dist/geometries/plane-geometry.js.map +1 -1
  46. package/dist/geometries/sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/sphere-geometry.js +9 -13
  49. package/dist/geometries/sphere-geometry.js.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  51. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  52. package/dist/geometries/truncated-cone-geometry.js +9 -25
  53. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  54. package/dist/geometry/geometry-table.d.ts +2 -2
  55. package/dist/geometry/geometry-table.d.ts.map +1 -1
  56. package/dist/geometry/geometry-table.js.map +1 -1
  57. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  58. package/dist/geometry/geometry-utils.js +0 -9
  59. package/dist/geometry/geometry-utils.js.map +1 -1
  60. package/dist/geometry/geometry.d.ts +50 -59
  61. package/dist/geometry/geometry.d.ts.map +1 -1
  62. package/dist/geometry/geometry.js +32 -97
  63. package/dist/geometry/geometry.js.map +1 -1
  64. package/dist/geometry/gpu-geometry.d.ts +37 -0
  65. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  66. package/dist/geometry/gpu-geometry.js +107 -0
  67. package/dist/geometry/gpu-geometry.js.map +1 -0
  68. package/dist/geometry/gpu-table.d.ts +1 -0
  69. package/dist/geometry/gpu-table.d.ts.map +1 -0
  70. package/dist/geometry/gpu-table.js +2 -0
  71. package/dist/geometry/gpu-table.js.map +1 -0
  72. package/dist/index.cjs +2959 -0
  73. package/dist/index.d.ts +26 -9
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +23 -13
  76. package/dist/index.js.map +1 -1
  77. package/dist/lib/clip-space.d.ts +8 -0
  78. package/dist/lib/clip-space.d.ts.map +1 -1
  79. package/dist/lib/clip-space.js +47 -0
  80. package/dist/lib/clip-space.js.map +1 -1
  81. package/dist/lib/pipeline-factory.d.ts +12 -40
  82. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  83. package/dist/lib/pipeline-factory.js +50 -148
  84. package/dist/lib/pipeline-factory.js.map +1 -1
  85. package/dist/model/model.d.ts +192 -0
  86. package/dist/model/model.d.ts.map +1 -0
  87. package/dist/model/model.js +312 -0
  88. package/dist/model/model.js.map +1 -0
  89. package/dist/scenegraph/group-node.d.ts +21 -0
  90. package/dist/scenegraph/group-node.d.ts.map +1 -0
  91. package/dist/scenegraph/group-node.js +94 -0
  92. package/dist/scenegraph/group-node.js.map +1 -0
  93. package/dist/scenegraph/model-node.d.ts +18 -0
  94. package/dist/scenegraph/model-node.d.ts.map +1 -0
  95. package/dist/scenegraph/model-node.js +28 -0
  96. package/dist/scenegraph/model-node.js.map +1 -0
  97. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  98. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  99. package/dist/scenegraph/scenegraph-node.js +141 -0
  100. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  101. package/dist/shader-inputs.d.ts +62 -0
  102. package/dist/shader-inputs.d.ts.map +1 -0
  103. package/dist/shader-inputs.js +49 -0
  104. package/dist/shader-inputs.js.map +1 -0
  105. package/dist/transform/buffer-transform.d.ts +35 -0
  106. package/dist/transform/buffer-transform.d.ts.map +1 -0
  107. package/dist/transform/buffer-transform.js +62 -0
  108. package/dist/transform/buffer-transform.js.map +1 -0
  109. package/dist/transform/texture-transform.d.ts +57 -0
  110. package/dist/transform/texture-transform.d.ts.map +1 -0
  111. package/dist/transform/texture-transform.js +122 -0
  112. package/dist/transform/texture-transform.js.map +1 -0
  113. package/dist.min.js +286 -0
  114. package/package.json +21 -12
  115. package/src/animation/timeline.ts +16 -15
  116. package/src/{lib → animation-loop}/animation-loop.ts +120 -107
  117. package/src/{lib → animation-loop}/animation-props.ts +5 -5
  118. package/src/animation-loop/make-animation-loop.ts +44 -0
  119. package/src/animation-loop/render-loop.ts +23 -0
  120. package/src/geometries/cone-geometry.ts +1 -1
  121. package/src/geometries/cube-geometry.ts +6 -3
  122. package/src/geometries/cylinder-geometry.ts +2 -2
  123. package/src/geometries/ico-sphere-geometry.ts +7 -6
  124. package/src/geometries/plane-geometry.ts +5 -4
  125. package/src/geometries/sphere-geometry.ts +4 -3
  126. package/src/geometries/truncated-cone-geometry.ts +4 -13
  127. package/src/geometry/geometry-table.ts +1 -1
  128. package/src/geometry/geometry-utils.ts +3 -3
  129. package/src/geometry/geometry.ts +79 -119
  130. package/src/geometry/gpu-geometry.ts +124 -0
  131. package/src/geometry/gpu-table.ts +41 -0
  132. package/src/index.ts +38 -12
  133. package/src/lib/clip-space.ts +22 -21
  134. package/src/lib/pipeline-factory.ts +60 -168
  135. package/src/model/model.ts +549 -0
  136. package/src/scenegraph/group-node.ts +103 -0
  137. package/src/scenegraph/model-node.ts +50 -0
  138. package/src/scenegraph/scenegraph-node.ts +204 -0
  139. package/src/shader-inputs.ts +132 -0
  140. package/src/transform/buffer-transform.ts +94 -0
  141. package/src/transform/texture-transform.ts +169 -0
  142. package/dist/bundle.d.ts +0 -2
  143. package/dist/bundle.d.ts.map +0 -1
  144. package/dist/bundle.js +0 -5
  145. package/dist/bundle.js.map +0 -1
  146. package/dist/geometry/primitive-utils.d.ts +0 -1
  147. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  148. package/dist/geometry/primitive-utils.js +0 -2
  149. package/dist/geometry/primitive-utils.js.map +0 -1
  150. package/dist/lib/animation-loop.d.ts.map +0 -1
  151. package/dist/lib/animation-loop.js.map +0 -1
  152. package/dist/lib/animation-props.d.ts.map +0 -1
  153. package/dist/lib/animation-props.js.map +0 -1
  154. package/dist/lib/model-utils.d.ts +0 -5
  155. package/dist/lib/model-utils.d.ts.map +0 -1
  156. package/dist/lib/model-utils.js +0 -45
  157. package/dist/lib/model-utils.js.map +0 -1
  158. package/dist/lib/model.d.ts +0 -41
  159. package/dist/lib/model.d.ts.map +0 -1
  160. package/dist/lib/model.js +0 -176
  161. package/dist/lib/model.js.map +0 -1
  162. package/dist/lib/render-loop.d.ts +0 -14
  163. package/dist/lib/render-loop.d.ts.map +0 -1
  164. package/dist/lib/render-loop.js +0 -49
  165. package/dist/lib/render-loop.js.map +0 -1
  166. package/src/bundle.ts +0 -4
  167. package/src/geometry/primitive-utils.ts +0 -30
  168. package/src/lib/model-utils.ts +0 -124
  169. package/src/lib/model.ts +0 -179
  170. package/src/lib/render-loop.ts +0 -58
  171. /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
- }
@@ -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