@luma.gl/engine 9.0.17 → 9.1.0-alpha.10
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/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +3 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +3 -0
- package/dist/animation-loop/animation-loop.d.ts +1 -1
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +5 -4
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +3 -0
- package/dist/animation-loop/make-animation-loop.js +1 -1
- package/dist/animation-loop/request-animation-frame.d.ts +3 -0
- package/dist/animation-loop/request-animation-frame.d.ts.map +1 -0
- package/dist/animation-loop/request-animation-frame.js +16 -0
- package/dist/application-utils/load-file.d.ts +22 -0
- package/dist/application-utils/load-file.d.ts.map +1 -0
- package/dist/application-utils/load-file.js +42 -0
- package/dist/application-utils/random.d.ts +3 -0
- package/dist/application-utils/random.d.ts.map +1 -0
- package/dist/application-utils/random.js +16 -0
- package/dist/async-texture/async-texture.d.ts +50 -0
- package/dist/async-texture/async-texture.d.ts.map +1 -0
- package/dist/async-texture/async-texture.js +83 -0
- package/dist/computation.d.ts +4 -3
- package/dist/computation.d.ts.map +1 -1
- package/dist/computation.js +14 -6
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
- package/dist/debug/copy-texture-to-image.js +4 -1
- package/dist/debug/debug-framebuffer.d.ts.map +1 -1
- package/dist/debug/debug-framebuffer.js +17 -12
- package/dist/debug/pixel-data-utils.d.ts +1 -1
- package/dist/dist.dev.js +728 -555
- package/dist/dist.min.js +57 -41
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +4 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +4 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +4 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +4 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +4 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +4 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +4 -1
- package/dist/geometry/geometry-table.d.ts +2 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +3 -1
- package/dist/geometry/geometry.d.ts +5 -4
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +9 -5
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +18 -6
- package/dist/geometry/gpu-table.js +3 -0
- package/dist/index.cjs +514 -258
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +10 -7
- package/dist/lib/pipeline-factory.d.ts +3 -2
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +12 -8
- package/dist/lib/shader-factory.d.ts +3 -2
- package/dist/lib/shader-factory.d.ts.map +1 -1
- package/dist/lib/shader-factory.js +11 -4
- package/dist/model/model.d.ts +10 -6
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +64 -8
- package/dist/model/split-uniforms-and-bindings.d.ts +9 -0
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -0
- package/dist/model/split-uniforms-and-bindings.js +20 -0
- package/dist/scenegraph/group-node.d.ts +1 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +3 -0
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +6 -3
- package/dist/scenegraph/scenegraph-node.d.ts +5 -6
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +11 -8
- package/dist/shader-inputs.d.ts +21 -8
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +11 -6
- package/dist/transform/buffer-transform.d.ts.map +1 -1
- package/dist/transform/buffer-transform.js +8 -2
- package/dist/transform/texture-transform.d.ts +2 -2
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +1 -0
- package/dist/utils/deep-equal.d.ts +9 -0
- package/dist/utils/deep-equal.d.ts.map +1 -0
- package/dist/utils/deep-equal.js +50 -0
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +14 -0
- package/package.json +7 -6
- package/src/animation/key-frames.ts +4 -0
- package/src/animation-loop/animation-loop-template.ts +4 -0
- package/src/animation-loop/animation-loop.ts +6 -4
- package/src/animation-loop/animation-props.ts +4 -0
- package/src/animation-loop/make-animation-loop.ts +1 -1
- package/src/animation-loop/request-animation-frame.ts +19 -0
- package/src/application-utils/load-file.ts +51 -0
- package/src/application-utils/random.ts +18 -0
- package/src/async-texture/async-texture.ts +146 -0
- package/src/computation.ts +17 -9
- package/src/debug/copy-texture-to-image.ts +4 -1
- package/src/debug/debug-framebuffer.ts +18 -12
- package/src/debug/pixel-data-utils.ts +1 -1
- package/src/geometries/cone-geometry.ts +5 -1
- package/src/geometries/cube-geometry.ts +5 -1
- package/src/geometries/cylinder-geometry.ts +5 -1
- package/src/geometries/ico-sphere-geometry.ts +5 -1
- package/src/geometries/plane-geometry.ts +5 -1
- package/src/geometries/sphere-geometry.ts +5 -1
- package/src/geometries/truncated-cone-geometry.ts +5 -1
- package/src/geometry/geometry-table.ts +2 -1
- package/src/geometry/geometry-utils.ts +3 -1
- package/src/geometry/geometry.ts +16 -19
- package/src/geometry/gpu-geometry.ts +20 -14
- package/src/geometry/gpu-table.ts +4 -0
- package/src/index.ts +16 -0
- package/src/lib/clip-space.ts +6 -2
- package/src/lib/pipeline-factory.ts +17 -16
- package/src/lib/shader-factory.ts +13 -6
- package/src/model/model.ts +70 -17
- package/src/model/split-uniforms-and-bindings.ts +31 -0
- package/src/scenegraph/group-node.ts +4 -0
- package/src/scenegraph/model-node.ts +9 -5
- package/src/scenegraph/scenegraph-node.ts +17 -13
- package/src/shader-inputs.ts +47 -18
- package/src/transform/buffer-transform.ts +8 -9
- package/src/transform/texture-transform.ts +2 -1
- package/src/utils/deep-equal.ts +51 -0
- package/src/utils/uid.ts +16 -0
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,13 @@ export type { SphereGeometryProps } from "./geometries/sphere-geometry.js";
|
|
|
37
37
|
export { SphereGeometry } from "./geometries/sphere-geometry.js";
|
|
38
38
|
export type { TruncatedConeGeometryProps } from "./geometries/truncated-cone-geometry.js";
|
|
39
39
|
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
40
|
+
export { makeRandomGenerator } from "./application-utils/random.js";
|
|
41
|
+
export { setPathPrefix, loadImage, loadImageBitmap } from "./application-utils/load-file.js";
|
|
42
|
+
export type { ShaderModuleInputs } from "./shader-inputs.js";
|
|
40
43
|
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
41
44
|
export type { ComputationProps } from "./computation.js";
|
|
42
45
|
export { Computation } from "./computation.js";
|
|
46
|
+
export { requestAnimationFrame, cancelAnimationFrame } from "./animation-loop/request-animation-frame.js";
|
|
47
|
+
export type { AsyncTextureProps } from "./async-texture/async-texture.js";
|
|
48
|
+
export { AsyncTexture } from "./async-texture/async-texture.js";
|
|
43
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,QAAQ,EAAC,gCAA6B;AAC9C,OAAO,EAAC,SAAS,EAAC,kCAA+B;AACjD,YAAY,EAAC,cAAc,EAAC,4CAAyC;AAErE,OAAO,EAAC,qBAAqB,EAAC,oDAAiD;AAE/E,YAAY,EAAC,kBAAkB,EAAC,2CAAwC;AACxE,OAAO,EAAC,aAAa,EAAC,2CAAwC;AAE9D,YAAY,EAAC,sBAAsB,EAAC,gDAA6C;AACjF,OAAO,EAAC,iBAAiB,EAAC,gDAA6C;AAEvE,YAAY,EAAC,UAAU,EAAC,yBAAsB;AAC9C,OAAO,EAAC,KAAK,EAAC,yBAAsB;AAGpC,YAAY,EAAC,oBAAoB,EAAC,wCAAqC;AACvE,OAAO,EAAC,eAAe,EAAC,wCAAqC;AAC7D,YAAY,EAAC,qBAAqB,EAAC,yCAAsC;AACzE,OAAO,EAAC,gBAAgB,EAAC,yCAAsC;AAE/D,OAAO,EAAC,eAAe,EAAC,kCAA+B;AACvD,OAAO,EAAC,aAAa,EAAC,gCAA6B;AAGnD,OAAO,EAAC,SAAS,EAAC,4BAAyB;AAG3C,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,OAAO,EAAC,SAAS,EAAC,mCAAgC;AAClD,YAAY,EAAC,cAAc,EAAC,mCAAgC;AAC5D,OAAO,EAAC,SAAS,EAAC,mCAAgC;AAGlD,YAAY,EAAC,aAAa,EAAE,iBAAiB,EAAC,+BAA4B;AAC1E,OAAO,EAAC,QAAQ,EAAC,+BAA4B;AAC7C,YAAY,EAAC,gBAAgB,EAAC,mCAAgC;AAC9D,OAAO,EAAC,WAAW,EAAC,mCAAgC;AAGpD,YAAY,EAAC,iBAAiB,EAAC,sCAAmC;AAClE,OAAO,EAAC,YAAY,EAAC,sCAAmC;AACxD,YAAY,EAAC,iBAAiB,EAAC,sCAAmC;AAClE,OAAO,EAAC,YAAY,EAAC,sCAAmC;AACxD,YAAY,EAAC,qBAAqB,EAAC,0CAAuC;AAC1E,OAAO,EAAC,gBAAgB,EAAC,0CAAuC;AAChE,YAAY,EAAC,sBAAsB,EAAC,4CAAyC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,4CAAyC;AACnE,YAAY,EAAC,kBAAkB,EAAC,uCAAoC;AACpE,OAAO,EAAC,aAAa,EAAC,uCAAoC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,wCAAqC;AACtE,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,YAAY,EAAC,0BAA0B,EAAC,gDAA6C;AACrF,OAAO,EAAC,qBAAqB,EAAC,gDAA6C;AAG3E,OAAO,EAAC,mBAAmB,EAAC,sCAAmC;AAC/D,OAAO,EAAC,aAAa,EAAE,SAAS,EAAE,eAAe,EAAC,yCAAsC;AAGxF,YAAY,EAAC,kBAAkB,EAAC,2BAAwB;AACxD,OAAO,EAAC,YAAY,IAAI,aAAa,EAAC,2BAAwB;AAC9D,YAAY,EAAC,gBAAgB,EAAC,yBAAsB;AACpD,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAC1C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,oDAAiD;AAElD,YAAY,EAAC,iBAAiB,EAAC,yCAAsC;AACrE,OAAO,EAAC,YAAY,EAAC,yCAAsC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
// luma.gl Engine API
|
|
2
5
|
// Animation
|
|
3
6
|
export { Timeline } from "./animation/timeline.js";
|
|
@@ -25,6 +28,10 @@ export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
|
|
|
25
28
|
export { PlaneGeometry } from "./geometries/plane-geometry.js";
|
|
26
29
|
export { SphereGeometry } from "./geometries/sphere-geometry.js";
|
|
27
30
|
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
28
|
-
//
|
|
31
|
+
// Application Utilities
|
|
32
|
+
export { makeRandomGenerator } from "./application-utils/random.js";
|
|
33
|
+
export { setPathPrefix, loadImage, loadImageBitmap } from "./application-utils/load-file.js";
|
|
29
34
|
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
30
35
|
export { Computation } from "./computation.js";
|
|
36
|
+
export { requestAnimationFrame, cancelAnimationFrame } from "./animation-loop/request-animation-frame.js";
|
|
37
|
+
export { AsyncTexture } from "./async-texture/async-texture.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,0BAAuB;AAwBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,aAAa,GAAG,UAAU,CAAC;CAkBtF"}
|
package/dist/lib/clip-space.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
3
4
|
import { Model } from "../model/model.js";
|
|
4
5
|
import { Geometry } from "../geometry/geometry.js";
|
|
5
|
-
const CLIPSPACE_VERTEX_SHADER = `\
|
|
6
|
+
const CLIPSPACE_VERTEX_SHADER = /* glsl */ `\
|
|
6
7
|
#version 300 es
|
|
7
8
|
in vec2 aClipSpacePosition;
|
|
8
9
|
in vec2 aTexCoord;
|
|
9
10
|
in vec2 aCoordinate;
|
|
11
|
+
|
|
10
12
|
out vec2 position;
|
|
11
13
|
out vec2 coordinate;
|
|
12
14
|
out vec2 uv;
|
|
15
|
+
|
|
13
16
|
void main(void) {
|
|
14
|
-
gl_Position = vec4(aClipSpacePosition, 0., 1.);
|
|
15
|
-
position = aClipSpacePosition;
|
|
16
|
-
coordinate = aCoordinate;
|
|
17
|
-
uv = aTexCoord;
|
|
17
|
+
gl_Position = vec4(aClipSpacePosition, 0., 1.);
|
|
18
|
+
position = aClipSpacePosition;
|
|
19
|
+
coordinate = aCoordinate;
|
|
20
|
+
uv = aTexCoord;
|
|
18
21
|
}
|
|
19
22
|
`;
|
|
20
23
|
/* eslint-disable indent, no-multi-spaces */
|
|
@@ -6,13 +6,14 @@ export type PipelineFactoryProps = RenderPipelineProps;
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class PipelineFactory {
|
|
8
8
|
static defaultProps: Required<PipelineFactoryProps>;
|
|
9
|
+
/** Get the singleton default pipeline factory for the specified device */
|
|
10
|
+
static getDefaultPipelineFactory(device: Device): PipelineFactory;
|
|
9
11
|
readonly device: Device;
|
|
12
|
+
readonly destroyPolicy: 'unused' | 'never';
|
|
10
13
|
private _hashCounter;
|
|
11
14
|
private readonly _hashes;
|
|
12
15
|
private readonly _renderPipelineCache;
|
|
13
16
|
private readonly _computePipelineCache;
|
|
14
|
-
/** Get the singleton default pipeline factory for the specified device */
|
|
15
|
-
static getDefaultPipelineFactory(device: Device): PipelineFactory;
|
|
16
17
|
constructor(device: Device);
|
|
17
18
|
/** Return a RenderPipeline matching props. Reuses a similar pipeline if already created. */
|
|
18
19
|
createRenderPipeline(props: RenderPipelineProps): RenderPipeline;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","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AAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,QAAQ;CAMjB"}
|
|
@@ -7,19 +7,21 @@ import { RenderPipeline, ComputePipeline } from '@luma.gl/core';
|
|
|
7
7
|
*/
|
|
8
8
|
export class PipelineFactory {
|
|
9
9
|
static defaultProps = { ...RenderPipeline.defaultProps };
|
|
10
|
-
device;
|
|
11
|
-
_hashCounter = 0;
|
|
12
|
-
_hashes = {};
|
|
13
|
-
_renderPipelineCache = {};
|
|
14
|
-
_computePipelineCache = {};
|
|
15
10
|
/** Get the singleton default pipeline factory for the specified device */
|
|
16
11
|
static getDefaultPipelineFactory(device) {
|
|
17
12
|
device._lumaData.defaultPipelineFactory =
|
|
18
13
|
device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
|
|
19
14
|
return device._lumaData.defaultPipelineFactory;
|
|
20
15
|
}
|
|
16
|
+
device;
|
|
17
|
+
destroyPolicy;
|
|
18
|
+
_hashCounter = 0;
|
|
19
|
+
_hashes = {};
|
|
20
|
+
_renderPipelineCache = {};
|
|
21
|
+
_computePipelineCache = {};
|
|
21
22
|
constructor(device) {
|
|
22
23
|
this.device = device;
|
|
24
|
+
this.destroyPolicy = device.props._factoryDestroyPolicy;
|
|
23
25
|
}
|
|
24
26
|
/** Return a RenderPipeline matching props. Reuses a similar pipeline if already created. */
|
|
25
27
|
createRenderPipeline(props) {
|
|
@@ -55,8 +57,10 @@ export class PipelineFactory {
|
|
|
55
57
|
const cache = pipeline instanceof ComputePipeline ? this._computePipelineCache : this._renderPipelineCache;
|
|
56
58
|
cache[hash].useCount--;
|
|
57
59
|
if (cache[hash].useCount === 0) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (this.destroyPolicy === 'unused') {
|
|
61
|
+
cache[hash].pipeline.destroy();
|
|
62
|
+
delete cache[hash];
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
// PRIVATE
|
|
@@ -66,7 +70,7 @@ export class PipelineFactory {
|
|
|
66
70
|
}
|
|
67
71
|
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
68
72
|
_hashRenderPipeline(props) {
|
|
69
|
-
const vsHash = this._getHash(props.vs.source);
|
|
73
|
+
const vsHash = props.vs ? this._getHash(props.vs.source) : 0;
|
|
70
74
|
const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
|
|
71
75
|
// WebGL specific
|
|
72
76
|
// const {varyings = [], bufferMode = {}} = props;
|
|
@@ -2,10 +2,11 @@ import { Device, Shader, ShaderProps } from '@luma.gl/core';
|
|
|
2
2
|
/** Manages a cached pool of Shaders for reuse. */
|
|
3
3
|
export declare class ShaderFactory {
|
|
4
4
|
static readonly defaultProps: Required<ShaderProps>;
|
|
5
|
-
readonly device: Device;
|
|
6
|
-
private readonly _cache;
|
|
7
5
|
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
8
6
|
static getDefaultShaderFactory(device: Device): ShaderFactory;
|
|
7
|
+
readonly device: Device;
|
|
8
|
+
readonly destroyPolicy: 'unused' | 'never';
|
|
9
|
+
private readonly _cache;
|
|
9
10
|
/** @internal */
|
|
10
11
|
constructor(device: Device);
|
|
11
12
|
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-factory.d.ts","sourceRoot":"","sources":["../../src/lib/shader-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader-factory.d.ts","sourceRoot":"","sources":["../../src/lib/shader-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1D,kDAAkD;AAClD,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAA4B;IAE/E,iGAAiG;IACjG,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK7D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0D;IAEjF,gBAAgB;gBACJ,MAAM,EAAE,MAAM;IAK1B,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAgBxC,wFAAwF;IACxF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAgB7B,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { Shader } from '@luma.gl/core';
|
|
2
5
|
/** Manages a cached pool of Shaders for reuse. */
|
|
3
6
|
export class ShaderFactory {
|
|
4
7
|
static defaultProps = { ...Shader.defaultProps };
|
|
5
|
-
device;
|
|
6
|
-
_cache = {};
|
|
7
8
|
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
8
9
|
static getDefaultShaderFactory(device) {
|
|
9
10
|
device._lumaData.defaultShaderFactory ||= new ShaderFactory(device);
|
|
10
11
|
return device._lumaData.defaultShaderFactory;
|
|
11
12
|
}
|
|
13
|
+
device;
|
|
14
|
+
destroyPolicy;
|
|
15
|
+
_cache = {};
|
|
12
16
|
/** @internal */
|
|
13
17
|
constructor(device) {
|
|
14
18
|
this.device = device;
|
|
19
|
+
this.destroyPolicy = device.props._factoryDestroyPolicy;
|
|
15
20
|
}
|
|
16
21
|
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
17
22
|
createShader(props) {
|
|
@@ -34,8 +39,10 @@ export class ShaderFactory {
|
|
|
34
39
|
if (cacheEntry) {
|
|
35
40
|
cacheEntry.useCount--;
|
|
36
41
|
if (cacheEntry.useCount === 0) {
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
if (this.destroyPolicy === 'unused') {
|
|
43
|
+
delete this._cache[key];
|
|
44
|
+
cacheEntry.shader.destroy();
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
}
|
package/dist/model/model.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { TypedArray
|
|
1
|
+
import type { TypedArray } from '@math.gl/types';
|
|
2
|
+
import type { RenderPipelineProps, RenderPipelineParameters } from '@luma.gl/core';
|
|
2
3
|
import type { BufferLayout, VertexArray, TransformFeedback } from '@luma.gl/core';
|
|
3
4
|
import type { AttributeInfo, Binding, UniformValue, PrimitiveTopology } from '@luma.gl/core';
|
|
4
5
|
import { Device, Buffer } from '@luma.gl/core';
|
|
@@ -7,10 +8,11 @@ import type { ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
|
|
|
7
8
|
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
8
9
|
import type { Geometry } from "../geometry/geometry.js";
|
|
9
10
|
import { GPUGeometry } from "../geometry/gpu-geometry.js";
|
|
10
|
-
import { ShaderInputs } from "../shader-inputs.js";
|
|
11
11
|
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
12
12
|
import { ShaderFactory } from "../lib/shader-factory.js";
|
|
13
|
-
|
|
13
|
+
import { ShaderInputs } from "../shader-inputs.js";
|
|
14
|
+
import { AsyncTexture } from "../async-texture/async-texture.js";
|
|
15
|
+
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindings'> & {
|
|
14
16
|
source?: string;
|
|
15
17
|
vs: string | null;
|
|
16
18
|
fs: string | null;
|
|
@@ -21,7 +23,7 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
21
23
|
/** Shader inputs, used to generated uniform buffers and bindings */
|
|
22
24
|
shaderInputs?: ShaderInputs;
|
|
23
25
|
/** Bindings */
|
|
24
|
-
bindings?: Record<string, Binding>;
|
|
26
|
+
bindings?: Record<string, Binding | AsyncTexture>;
|
|
25
27
|
/** Parameters that are built into the pipeline */
|
|
26
28
|
parameters?: RenderPipelineParameters;
|
|
27
29
|
/** Geometry */
|
|
@@ -92,7 +94,7 @@ export declare class Model {
|
|
|
92
94
|
/** Constant-valued attributes */
|
|
93
95
|
constantAttributes: Record<string, TypedArray>;
|
|
94
96
|
/** Bindings (textures, samplers, uniform buffers) */
|
|
95
|
-
bindings: Record<string, Binding>;
|
|
97
|
+
bindings: Record<string, Binding | AsyncTexture>;
|
|
96
98
|
/** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/
|
|
97
99
|
uniforms: Record<string, UniformValue>;
|
|
98
100
|
/**
|
|
@@ -164,7 +166,7 @@ export declare class Model {
|
|
|
164
166
|
/**
|
|
165
167
|
* Sets bindings (textures, samplers, uniform buffers)
|
|
166
168
|
*/
|
|
167
|
-
setBindings(bindings: Record<string, Binding>): void;
|
|
169
|
+
setBindings(bindings: Record<string, Binding | AsyncTexture>): void;
|
|
168
170
|
/**
|
|
169
171
|
* Updates optional transform feedback. WebGL only.
|
|
170
172
|
*/
|
|
@@ -202,6 +204,8 @@ export declare class Model {
|
|
|
202
204
|
* @deprecated Updates shader module settings (which results in uniforms being set)
|
|
203
205
|
*/
|
|
204
206
|
updateModuleSettings(props: Record<string, any>): void;
|
|
207
|
+
/** Get texture / texture view from any async textures */
|
|
208
|
+
_getBindings(): Record<string, Binding>;
|
|
205
209
|
/** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
|
|
206
210
|
_getBindingsUpdateTimestamp(): number;
|
|
207
211
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAA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AAE,QAAQ,EAAE,GAAG,GAAG,MAAM;CAMlF;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS5D"}
|
package/dist/model/model.js
CHANGED
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { Buffer, Texture, TextureView, Sampler } from '@luma.gl/core';
|
|
5
5
|
import { RenderPipeline, UniformStore } from '@luma.gl/core';
|
|
6
|
-
import { log
|
|
6
|
+
import { log } from '@luma.gl/core';
|
|
7
7
|
import { getTypedArrayFromDataType, getAttributeInfosFromLayouts } from '@luma.gl/core';
|
|
8
8
|
import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
|
|
9
9
|
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
10
|
-
import { ShaderInputs } from "../shader-inputs.js";
|
|
11
10
|
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
12
11
|
import { ShaderFactory } from "../lib/shader-factory.js";
|
|
13
12
|
import { getDebugTableForShaderLayout } from "../debug/debug-shader-layout.js";
|
|
14
13
|
import { debugFramebuffer } from "../debug/debug-framebuffer.js";
|
|
14
|
+
import { deepEqual } from "../utils/deep-equal.js";
|
|
15
|
+
import { uid } from "../utils/uid.js";
|
|
16
|
+
import { splitUniformsAndBindings } from "./split-uniforms-and-bindings.js";
|
|
17
|
+
import { ShaderInputs } from "../shader-inputs.js";
|
|
18
|
+
// import type {AsyncTextureProps} from '../async-texture/async-texture';
|
|
19
|
+
import { AsyncTexture } from "../async-texture/async-texture.js";
|
|
15
20
|
const LOG_DRAW_PRIORITY = 2;
|
|
16
21
|
const LOG_DRAW_TIMEOUT = 10000;
|
|
17
22
|
/**
|
|
@@ -25,7 +30,7 @@ const LOG_DRAW_TIMEOUT = 10000;
|
|
|
25
30
|
export class Model {
|
|
26
31
|
static defaultProps = {
|
|
27
32
|
...RenderPipeline.defaultProps,
|
|
28
|
-
source:
|
|
33
|
+
source: undefined,
|
|
29
34
|
vs: null,
|
|
30
35
|
fs: null,
|
|
31
36
|
id: 'unnamed',
|
|
@@ -52,8 +57,11 @@ export class Model {
|
|
|
52
57
|
};
|
|
53
58
|
device;
|
|
54
59
|
id;
|
|
60
|
+
// @ts-expect-error assigned in function called from constructor
|
|
55
61
|
source;
|
|
62
|
+
// @ts-expect-error assigned in function called from constructor
|
|
56
63
|
vs;
|
|
64
|
+
// @ts-expect-error assigned in function called from constructor
|
|
57
65
|
fs;
|
|
58
66
|
pipelineFactory;
|
|
59
67
|
shaderFactory;
|
|
@@ -93,7 +101,9 @@ export class Model {
|
|
|
93
101
|
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
94
102
|
pipeline;
|
|
95
103
|
/** ShaderInputs instance */
|
|
104
|
+
// @ts-expect-error Assigned in function called by constructor
|
|
96
105
|
shaderInputs;
|
|
106
|
+
// @ts-expect-error Assigned in function called by constructor
|
|
97
107
|
_uniformStore;
|
|
98
108
|
_attributeInfos = {};
|
|
99
109
|
_gpuGeometry = null;
|
|
@@ -116,7 +126,9 @@ export class Model {
|
|
|
116
126
|
// Setup shader assembler
|
|
117
127
|
const platformInfo = getPlatformInfo(device);
|
|
118
128
|
// Extract modules from shader inputs if not supplied
|
|
119
|
-
const modules =
|
|
129
|
+
const modules =
|
|
130
|
+
// @ts-expect-error shaderInputs is assigned in setShaderInputs above.
|
|
131
|
+
(this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];
|
|
120
132
|
const isWebGPU = this.device.type === 'webgpu';
|
|
121
133
|
// WebGPU
|
|
122
134
|
// TODO - hack to support unified WGSL shader
|
|
@@ -124,23 +136,25 @@ export class Model {
|
|
|
124
136
|
if (isWebGPU && this.props.source) {
|
|
125
137
|
// WGSL
|
|
126
138
|
this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source);
|
|
127
|
-
const { source, getUniforms } = this.props.shaderAssembler.
|
|
139
|
+
const { source, getUniforms } = this.props.shaderAssembler.assembleWGSLShader({
|
|
128
140
|
platformInfo,
|
|
129
141
|
...this.props,
|
|
130
142
|
modules
|
|
131
143
|
});
|
|
132
144
|
this.source = source;
|
|
145
|
+
// @ts-expect-error
|
|
133
146
|
this._getModuleUniforms = getUniforms;
|
|
134
147
|
}
|
|
135
148
|
else {
|
|
136
149
|
// GLSL
|
|
137
|
-
const { vs, fs, getUniforms } = this.props.shaderAssembler.
|
|
150
|
+
const { vs, fs, getUniforms } = this.props.shaderAssembler.assembleGLSLShaderPair({
|
|
138
151
|
platformInfo,
|
|
139
152
|
...this.props,
|
|
140
153
|
modules
|
|
141
154
|
});
|
|
142
155
|
this.vs = vs;
|
|
143
156
|
this.fs = fs;
|
|
157
|
+
// @ts-expect-error
|
|
144
158
|
this._getModuleUniforms = getUniforms;
|
|
145
159
|
}
|
|
146
160
|
this.vertexCount = this.props.vertexCount;
|
|
@@ -245,7 +259,11 @@ export class Model {
|
|
|
245
259
|
this.pipeline = this._updatePipeline();
|
|
246
260
|
// Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
|
|
247
261
|
// Any caching needs to be done inside the pipeline functions
|
|
248
|
-
this
|
|
262
|
+
// TODO this is a busy initialized check for all bindings every frame
|
|
263
|
+
const syncBindings = this._getBindings();
|
|
264
|
+
this.pipeline.setBindings(syncBindings, {
|
|
265
|
+
disableWarnings: this.props.disableWarnings
|
|
266
|
+
});
|
|
249
267
|
if (!isObjectEmpty(this.uniforms)) {
|
|
250
268
|
this.pipeline.setUniformsWebGL(this.uniforms);
|
|
251
269
|
}
|
|
@@ -478,6 +496,21 @@ export class Model {
|
|
|
478
496
|
this.setNeedsRedraw('moduleSettings');
|
|
479
497
|
}
|
|
480
498
|
// Internal methods
|
|
499
|
+
/** Get texture / texture view from any async textures */
|
|
500
|
+
_getBindings() {
|
|
501
|
+
// Extract actual textures from async textures. If not loaded, null
|
|
502
|
+
return Object.entries(this.bindings).reduce((acc, [name, binding]) => {
|
|
503
|
+
if (binding instanceof AsyncTexture) {
|
|
504
|
+
if (binding.isReady) {
|
|
505
|
+
acc[name] = binding.texture;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
acc[name] = binding;
|
|
510
|
+
}
|
|
511
|
+
return acc;
|
|
512
|
+
}, {});
|
|
513
|
+
}
|
|
481
514
|
/** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
|
|
482
515
|
_getBindingsUpdateTimestamp() {
|
|
483
516
|
let timestamp = 0;
|
|
@@ -488,6 +521,12 @@ export class Model {
|
|
|
488
521
|
else if (binding instanceof Buffer || binding instanceof Texture) {
|
|
489
522
|
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
490
523
|
}
|
|
524
|
+
else if (binding instanceof AsyncTexture) {
|
|
525
|
+
timestamp = binding.texture
|
|
526
|
+
? Math.max(timestamp, binding.texture.updateTimestamp)
|
|
527
|
+
: // The texture will become available in the future
|
|
528
|
+
Infinity;
|
|
529
|
+
}
|
|
491
530
|
else if (!(binding instanceof Sampler)) {
|
|
492
531
|
timestamp = Math.max(timestamp, binding.buffer.updateTimestamp);
|
|
493
532
|
}
|
|
@@ -554,6 +593,9 @@ export class Model {
|
|
|
554
593
|
bufferLayout: this.bufferLayout,
|
|
555
594
|
topology: this.topology,
|
|
556
595
|
parameters: this.parameters,
|
|
596
|
+
// TODO - why set bindings here when we reset them every frame?
|
|
597
|
+
// Should we expose a BindGroup abstraction?
|
|
598
|
+
bindings: this._getBindings(),
|
|
557
599
|
vs,
|
|
558
600
|
fs
|
|
559
601
|
});
|
|
@@ -615,10 +657,13 @@ export class Model {
|
|
|
615
657
|
_getAttributeDebugTable() {
|
|
616
658
|
const table = {};
|
|
617
659
|
for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
|
|
660
|
+
const values = this.vertexArray.attributes[attributeInfo.location];
|
|
618
661
|
table[attributeInfo.location] = {
|
|
619
662
|
name,
|
|
620
663
|
type: attributeInfo.shaderType,
|
|
621
|
-
values:
|
|
664
|
+
values: values
|
|
665
|
+
? this._getBufferOrConstantValues(values, attributeInfo.bufferDataType)
|
|
666
|
+
: 'null'
|
|
622
667
|
};
|
|
623
668
|
}
|
|
624
669
|
if (this.vertexArray.indexBuffer) {
|
|
@@ -673,3 +718,14 @@ function getAttributeNames(bufferLayout) {
|
|
|
673
718
|
? bufferLayout.attributes?.map(layout => layout.attribute)
|
|
674
719
|
: [bufferLayout.name];
|
|
675
720
|
}
|
|
721
|
+
/** Returns true if given object is empty, false otherwise. */
|
|
722
|
+
function isObjectEmpty(obj) {
|
|
723
|
+
let isEmpty = true;
|
|
724
|
+
// @ts-ignore key is unused
|
|
725
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
726
|
+
for (const key in obj) {
|
|
727
|
+
isEmpty = false;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
return isEmpty;
|
|
731
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UniformValue, Binding } from '@luma.gl/core';
|
|
2
|
+
export declare function isUniformValue(value: unknown): value is UniformValue;
|
|
3
|
+
type UniformsAndBindings = {
|
|
4
|
+
bindings: Record<string, Binding>;
|
|
5
|
+
uniforms: Record<string, UniformValue>;
|
|
6
|
+
};
|
|
7
|
+
export declare function splitUniformsAndBindings(uniforms: Record<string, Binding | UniformValue>): UniformsAndBindings;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=split-uniforms-and-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-uniforms-and-bindings.d.ts","sourceRoot":"","sources":["../../src/model/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,GAC/C,mBAAmB,CAYrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { isNumericArray } from '@math.gl/types';
|
|
5
|
+
export function isUniformValue(value) {
|
|
6
|
+
return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
|
|
7
|
+
}
|
|
8
|
+
export function splitUniformsAndBindings(uniforms) {
|
|
9
|
+
const result = { bindings: {}, uniforms: {} };
|
|
10
|
+
Object.keys(uniforms).forEach(name => {
|
|
11
|
+
const uniform = uniforms[name];
|
|
12
|
+
if (isUniformValue(uniform)) {
|
|
13
|
+
result.uniforms[name] = uniform;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
result.bindings[name] = uniform;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -15,7 +15,7 @@ export declare class GroupNode extends ScenegraphNode {
|
|
|
15
15
|
traverse(visitor: (node: ScenegraphNode, context: {
|
|
16
16
|
worldMatrix: Matrix4;
|
|
17
17
|
}) => void, { worldMatrix }?: {
|
|
18
|
-
worldMatrix?: Matrix4;
|
|
18
|
+
worldMatrix?: Matrix4 | undefined;
|
|
19
19
|
}): void;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=group-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,6BAA0B;AAEtE,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAC;AAEF,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,EAAE,cAAc,EAAE,CAAC;gBAEf,QAAQ,EAAE,cAAc,EAAE;gBAC1B,KAAK,CAAC,EAAE,cAAc;IAazB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAmCxC,OAAO,IAAI,IAAI;IAOxB,GAAG,CAAC,GAAG,QAAQ,EAAE,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,IAAI;IAW7D,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IASnC,SAAS,IAAI,IAAI;IAKjB,QAAQ,CACN,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,EACxE,EAAC,WAA2B,EAAC;;KAAK;CAYrC"}
|
|
@@ -11,8 +11,8 @@ export declare class ModelNode extends ScenegraphNode {
|
|
|
11
11
|
bounds: [number[], number[]] | null;
|
|
12
12
|
managedResources: any[];
|
|
13
13
|
constructor(props: ModelNodeProps);
|
|
14
|
-
getBounds(): [number[], number[]] | null;
|
|
15
14
|
destroy(): void;
|
|
16
|
-
|
|
15
|
+
getBounds(): [number[], number[]] | null;
|
|
16
|
+
draw(renderPass: RenderPass): boolean;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=model-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,6BAA0B;AACtE,OAAO,EAAC,KAAK,EAAC,0BAAuB;AAErC,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/B,CAAC;AAEF,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAQ;IAC3C,gBAAgB,EAAE,GAAG,EAAE,CAAC;gBAOZ,KAAK,EAAE,cAAc;IAUxB,OAAO,IAAI,IAAI;IAUf,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAKjD,IAAI,CAAC,UAAU,EAAE,UAAU;CAI5B"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
2
5
|
export class ModelNode extends ScenegraphNode {
|
|
3
6
|
model;
|
|
@@ -15,9 +18,6 @@ export class ModelNode extends ScenegraphNode {
|
|
|
15
18
|
this.bounds = props.bounds || null;
|
|
16
19
|
this.setProps(props);
|
|
17
20
|
}
|
|
18
|
-
getBounds() {
|
|
19
|
-
return this.bounds;
|
|
20
|
-
}
|
|
21
21
|
destroy() {
|
|
22
22
|
if (this.model) {
|
|
23
23
|
this.model.destroy();
|
|
@@ -27,6 +27,9 @@ export class ModelNode extends ScenegraphNode {
|
|
|
27
27
|
this.managedResources.forEach(resource => resource.destroy());
|
|
28
28
|
this.managedResources = [];
|
|
29
29
|
}
|
|
30
|
+
getBounds() {
|
|
31
|
+
return this.bounds;
|
|
32
|
+
}
|
|
30
33
|
// Expose model methods
|
|
31
34
|
draw(renderPass) {
|
|
32
35
|
// Return value indicates if something was actually drawn
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
1
|
+
import { Vector3, Matrix4, NumericArray } from '@math.gl/core';
|
|
3
2
|
/** Properties for creating a new Scenegraph */
|
|
4
3
|
export type ScenegraphNodeProps = {
|
|
5
4
|
id?: string;
|
|
6
5
|
/** whether to display the object at all */
|
|
7
6
|
display?: boolean;
|
|
8
|
-
matrix?:
|
|
9
|
-
position?:
|
|
10
|
-
rotation?:
|
|
11
|
-
scale?:
|
|
7
|
+
matrix?: NumericArray;
|
|
8
|
+
position?: NumericArray;
|
|
9
|
+
rotation?: NumericArray;
|
|
10
|
+
scale?: NumericArray;
|
|
12
11
|
update?: boolean;
|
|
13
12
|
};
|
|
14
13
|
export declare class ScenegraphNode {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenegraph-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scenegraph-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAG7D,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EA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