@luma.gl/engine 9.0.0-beta.5 → 9.0.0-beta.6
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/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +3 -3
- package/dist/animation-loop/animation-loop-template.d.ts +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +3 -1
- package/dist/animation-loop/animation-loop.d.ts +2 -2
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +14 -6
- package/dist/animation-loop/animation-props.d.ts +2 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts +2 -2
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +4 -2
- 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 +0 -1
- package/dist/debug/pixel-data-utils.d.ts.map +1 -1
- package/dist/debug/pixel-data-utils.js +2 -1
- package/dist/dist.dev.js +210 -121
- 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 +1 -1
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +16 -14
- 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 +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +1 -1
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +2 -2
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +3 -0
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +3 -0
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/index.cjs +171 -89
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +41 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/lib/clip-space.d.ts +1 -1
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +3 -3
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +3 -0
- package/dist/lib/shader-factory.d.ts +17 -0
- package/dist/lib/shader-factory.d.ts.map +1 -0
- package/dist/lib/shader-factory.js +44 -0
- package/dist/model/model.d.ts +20 -8
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +52 -26
- 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 +10 -5
- 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 +2 -2
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +3 -0
- package/dist/transform/buffer-transform.d.ts +1 -1
- package/dist/transform/buffer-transform.d.ts.map +1 -1
- package/dist/transform/buffer-transform.js +7 -6
- package/dist/transform/texture-transform.d.ts +1 -1
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +10 -8
- package/dist.min.js +2 -2
- package/package.json +2 -2
- package/src/animation/timeline.ts +20 -20
- package/src/animation-loop/animation-loop-template.ts +10 -8
- package/src/animation-loop/animation-loop.ts +20 -10
- package/src/animation-loop/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +17 -8
- package/src/debug/copy-texture-to-image.ts +8 -6
- package/src/debug/debug-framebuffer.ts +16 -3
- package/src/debug/debug-shader-layout.ts +1 -1
- package/src/debug/pixel-data-utils.ts +3 -6
- package/src/geometries/cube-geometry.ts +17 -13
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometries/plane-geometry.ts +1 -1
- package/src/geometries/sphere-geometry.ts +1 -1
- package/src/geometries/truncated-cone-geometry.ts +2 -1
- package/src/geometry/geometry-table.ts +9 -6
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +9 -6
- package/src/geometry/gpu-geometry.ts +14 -6
- package/src/index.ts +1 -0
- package/src/lib/clip-space.ts +14 -18
- package/src/lib/pipeline-factory.ts +4 -1
- package/src/lib/shader-factory.ts +55 -0
- package/src/model/model.ts +70 -38
- package/src/scenegraph/group-node.ts +14 -10
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +2 -2
- package/src/shader-inputs.ts +19 -12
- package/src/transform/buffer-transform.ts +15 -7
- package/src/transform/texture-transform.ts +14 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
export { Timeline } from
|
|
2
|
-
export { KeyFrames } from
|
|
3
|
-
export type { AnimationProps } from
|
|
4
|
-
export { AnimationLoopTemplate } from
|
|
5
|
-
export type { AnimationLoopProps } from
|
|
6
|
-
export { AnimationLoop } from
|
|
7
|
-
export type { MakeAnimationLoopProps } from
|
|
8
|
-
export { makeAnimationLoop } from
|
|
9
|
-
export type { ModelProps } from
|
|
10
|
-
export { Model } from
|
|
11
|
-
export type { BufferTransformProps } from
|
|
12
|
-
export { BufferTransform } from
|
|
13
|
-
export type { TextureTransformProps } from
|
|
14
|
-
export { TextureTransform } from
|
|
15
|
-
export { PipelineFactory } from
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export {
|
|
23
|
-
export
|
|
24
|
-
export {
|
|
25
|
-
export
|
|
26
|
-
export {
|
|
27
|
-
export
|
|
28
|
-
export {
|
|
29
|
-
export
|
|
30
|
-
export {
|
|
31
|
-
export
|
|
32
|
-
export {
|
|
33
|
-
export
|
|
34
|
-
export {
|
|
35
|
-
export
|
|
36
|
-
export {
|
|
37
|
-
export
|
|
38
|
-
export {
|
|
39
|
-
export
|
|
40
|
-
export {
|
|
1
|
+
export { Timeline } from "./animation/timeline.js";
|
|
2
|
+
export { KeyFrames } from "./animation/key-frames.js";
|
|
3
|
+
export type { AnimationProps } from "./animation-loop/animation-props.js";
|
|
4
|
+
export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.js";
|
|
5
|
+
export type { AnimationLoopProps } from "./animation-loop/animation-loop.js";
|
|
6
|
+
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
7
|
+
export type { MakeAnimationLoopProps } from "./animation-loop/make-animation-loop.js";
|
|
8
|
+
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
9
|
+
export type { ModelProps } from "./model/model.js";
|
|
10
|
+
export { Model } from "./model/model.js";
|
|
11
|
+
export type { BufferTransformProps } from "./transform/buffer-transform.js";
|
|
12
|
+
export { BufferTransform } from "./transform/buffer-transform.js";
|
|
13
|
+
export type { TextureTransformProps } from "./transform/texture-transform.js";
|
|
14
|
+
export { TextureTransform } from "./transform/texture-transform.js";
|
|
15
|
+
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
16
|
+
export { ShaderFactory } from "./lib/shader-factory.js";
|
|
17
|
+
export { ClipSpace } from "./lib/clip-space.js";
|
|
18
|
+
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
|
|
19
|
+
export { GroupNode } from "./scenegraph/group-node.js";
|
|
20
|
+
export type { ModelNodeProps } from "./scenegraph/model-node.js";
|
|
21
|
+
export { ModelNode } from "./scenegraph/model-node.js";
|
|
22
|
+
export type { GeometryProps } from "./geometry/geometry.js";
|
|
23
|
+
export { Geometry } from "./geometry/geometry.js";
|
|
24
|
+
export type { GPUGeometryProps } from "./geometry/gpu-geometry.js";
|
|
25
|
+
export { GPUGeometry } from "./geometry/gpu-geometry.js";
|
|
26
|
+
export type { ConeGeometryProps } from "./geometries/cone-geometry.js";
|
|
27
|
+
export { ConeGeometry } from "./geometries/cone-geometry.js";
|
|
28
|
+
export type { CubeGeometryProps } from "./geometries/cube-geometry.js";
|
|
29
|
+
export { CubeGeometry } from "./geometries/cube-geometry.js";
|
|
30
|
+
export type { CylinderGeometryProps } from "./geometries/cylinder-geometry.js";
|
|
31
|
+
export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
|
|
32
|
+
export type { IcoSphereGeometryProps } from "./geometries/ico-sphere-geometry.js";
|
|
33
|
+
export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
|
|
34
|
+
export type { PlaneGeometryProps } from "./geometries/plane-geometry.js";
|
|
35
|
+
export { PlaneGeometry } from "./geometries/plane-geometry.js";
|
|
36
|
+
export type { SphereGeometryProps } from "./geometries/sphere-geometry.js";
|
|
37
|
+
export { SphereGeometry } from "./geometries/sphere-geometry.js";
|
|
38
|
+
export type { TruncatedConeGeometryProps } from "./geometries/truncated-cone-geometry.js";
|
|
39
|
+
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
40
|
+
export type { ShaderModuleInputs } from "./shader-inputs.js";
|
|
41
|
+
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
41
42
|
//# 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":"AAGA,OAAO,EAAC,QAAQ,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,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,EAAC,+BAA4B;AACvD,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,YAAY,EAAC,kBAAkB,EAAC,2BAAwB;AACxD,OAAO,EAAC,YAAY,IAAI,aAAa,EAAC,2BAAwB"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
// luma.gl Engine API
|
|
2
2
|
// Animation
|
|
3
|
-
export { Timeline } from
|
|
4
|
-
export { KeyFrames } from
|
|
5
|
-
export { AnimationLoopTemplate } from
|
|
6
|
-
export { AnimationLoop } from
|
|
7
|
-
export { makeAnimationLoop } from
|
|
8
|
-
export { Model } from
|
|
9
|
-
export { BufferTransform } from
|
|
10
|
-
export { TextureTransform } from
|
|
11
|
-
export { PipelineFactory } from
|
|
3
|
+
export { Timeline } from "./animation/timeline.js";
|
|
4
|
+
export { KeyFrames } from "./animation/key-frames.js";
|
|
5
|
+
export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.js";
|
|
6
|
+
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
7
|
+
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
8
|
+
export { Model } from "./model/model.js";
|
|
9
|
+
export { BufferTransform } from "./transform/buffer-transform.js";
|
|
10
|
+
export { TextureTransform } from "./transform/texture-transform.js";
|
|
11
|
+
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
12
|
+
export { ShaderFactory } from "./lib/shader-factory.js";
|
|
12
13
|
// Utils
|
|
13
|
-
export { ClipSpace } from
|
|
14
|
+
export { ClipSpace } from "./lib/clip-space.js";
|
|
14
15
|
// Scenegraph Core nodes
|
|
15
|
-
export { ScenegraphNode } from
|
|
16
|
-
export { GroupNode } from
|
|
17
|
-
export { ModelNode } from
|
|
18
|
-
export { Geometry } from
|
|
19
|
-
export { GPUGeometry } from
|
|
20
|
-
export { ConeGeometry } from
|
|
21
|
-
export { CubeGeometry } from
|
|
22
|
-
export { CylinderGeometry } from
|
|
23
|
-
export { IcoSphereGeometry } from
|
|
24
|
-
export { PlaneGeometry } from
|
|
25
|
-
export { SphereGeometry } from
|
|
26
|
-
export { TruncatedConeGeometry } from
|
|
27
|
-
export { ShaderInputs as _ShaderInputs } from
|
|
16
|
+
export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
|
|
17
|
+
export { GroupNode } from "./scenegraph/group-node.js";
|
|
18
|
+
export { ModelNode } from "./scenegraph/model-node.js";
|
|
19
|
+
export { Geometry } from "./geometry/geometry.js";
|
|
20
|
+
export { GPUGeometry } from "./geometry/gpu-geometry.js";
|
|
21
|
+
export { ConeGeometry } from "./geometries/cone-geometry.js";
|
|
22
|
+
export { CubeGeometry } from "./geometries/cube-geometry.js";
|
|
23
|
+
export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
|
|
24
|
+
export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
|
|
25
|
+
export { PlaneGeometry } from "./geometries/plane-geometry.js";
|
|
26
|
+
export { SphereGeometry } from "./geometries/sphere-geometry.js";
|
|
27
|
+
export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
28
|
+
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
package/dist/lib/clip-space.d.ts
CHANGED
|
@@ -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":"AACA,OAAO,EAAC,MAAM,EAAO,MAAM,eAAe,CAAC;AAC3C,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,7 +1,7 @@
|
|
|
1
1
|
// ClipSpace
|
|
2
2
|
import { glsl } from '@luma.gl/core';
|
|
3
|
-
import { Model } from
|
|
4
|
-
import { Geometry } from
|
|
3
|
+
import { Model } from "../model/model.js";
|
|
4
|
+
import { Geometry } from "../geometry/geometry.js";
|
|
5
5
|
const CLIPSPACE_VERTEX_SHADER = glsl `\
|
|
6
6
|
#version 300 es
|
|
7
7
|
in vec2 aClipSpacePosition;
|
|
@@ -26,7 +26,7 @@ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
|
26
26
|
*/
|
|
27
27
|
export class ClipSpace extends Model {
|
|
28
28
|
constructor(device, opts) {
|
|
29
|
-
const TEX_COORDS = POSITIONS.map(
|
|
29
|
+
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
|
|
30
30
|
super(device, {
|
|
31
31
|
...opts,
|
|
32
32
|
vs: CLIPSPACE_VERTEX_SHADER,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEvD;;GAEG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAoC;IAEvF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;gBAMrD,MAAM,EAAE,MAAM;IAI1B,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc;IAkBnE,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAYvC,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,QAAQ;CAMjB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Device, Shader, ShaderProps } from '@luma.gl/core';
|
|
2
|
+
/** Manages a cached pool of Shaders for reuse. */
|
|
3
|
+
export declare class ShaderFactory {
|
|
4
|
+
static readonly defaultProps: Required<ShaderProps>;
|
|
5
|
+
readonly device: Device;
|
|
6
|
+
private readonly _cache;
|
|
7
|
+
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
8
|
+
static getDefaultShaderFactory(device: Device): ShaderFactory;
|
|
9
|
+
/** @internal */
|
|
10
|
+
constructor(device: Device);
|
|
11
|
+
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
12
|
+
createShader(props: ShaderProps): Shader;
|
|
13
|
+
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
14
|
+
release(shader: Shader): void;
|
|
15
|
+
private _hashShader;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=shader-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-factory.d.ts","sourceRoot":"","sources":["../../src/lib/shader-factory.ts"],"names":[],"mappings":"AAAA,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,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0D;IAEjF,iGAAiG;IACjG,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK7D,gBAAgB;gBACJ,MAAM,EAAE,MAAM;IAI1B,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAgBxC,wFAAwF;IACxF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAY7B,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Shader } from '@luma.gl/core';
|
|
2
|
+
/** Manages a cached pool of Shaders for reuse. */
|
|
3
|
+
export class ShaderFactory {
|
|
4
|
+
static defaultProps = { ...Shader.defaultProps };
|
|
5
|
+
device;
|
|
6
|
+
_cache = {};
|
|
7
|
+
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
8
|
+
static getDefaultShaderFactory(device) {
|
|
9
|
+
device._lumaData.defaultShaderFactory ||= new ShaderFactory(device);
|
|
10
|
+
return device._lumaData.defaultShaderFactory;
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
constructor(device) {
|
|
14
|
+
this.device = device;
|
|
15
|
+
}
|
|
16
|
+
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
17
|
+
createShader(props) {
|
|
18
|
+
const key = this._hashShader(props);
|
|
19
|
+
let cacheEntry = this._cache[key];
|
|
20
|
+
if (!cacheEntry) {
|
|
21
|
+
const shader = this.device.createShader({
|
|
22
|
+
...props,
|
|
23
|
+
id: props.id ? `${props.id}-cached` : undefined
|
|
24
|
+
});
|
|
25
|
+
this._cache[key] = cacheEntry = { shader, useCount: 0 };
|
|
26
|
+
}
|
|
27
|
+
cacheEntry.useCount++;
|
|
28
|
+
return cacheEntry.shader;
|
|
29
|
+
}
|
|
30
|
+
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
31
|
+
release(shader) {
|
|
32
|
+
const key = this._hashShader(shader);
|
|
33
|
+
const cacheEntry = this._cache[key];
|
|
34
|
+
cacheEntry.useCount--;
|
|
35
|
+
if (cacheEntry.useCount === 0) {
|
|
36
|
+
delete this._cache[key];
|
|
37
|
+
cacheEntry.shader.destroy();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// PRIVATE
|
|
41
|
+
_hashShader(value) {
|
|
42
|
+
return `${value.stage}:${value.source}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/model/model.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { TypedArray
|
|
1
|
+
import type { TypedArray } from '@luma.gl/core';
|
|
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, RenderPipeline, RenderPass, UniformStore } from '@luma.gl/core';
|
|
5
6
|
import type { ShaderModule, PlatformInfo } from '@luma.gl/shadertools';
|
|
6
7
|
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
7
|
-
import { ShaderInputs } from
|
|
8
|
-
import type { Geometry } from
|
|
9
|
-
import { GPUGeometry } from
|
|
10
|
-
import { PipelineFactory } from
|
|
8
|
+
import { ShaderInputs } from "../shader-inputs.js";
|
|
9
|
+
import type { Geometry } from "../geometry/geometry.js";
|
|
10
|
+
import { GPUGeometry } from "../geometry/gpu-geometry.js";
|
|
11
|
+
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
12
|
+
import { ShaderFactory } from "../lib/shader-factory.js";
|
|
11
13
|
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
12
14
|
source?: string;
|
|
13
15
|
vs: {
|
|
@@ -24,8 +26,10 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
24
26
|
defines?: Record<string, string | number | boolean>;
|
|
25
27
|
/** Shader inputs, used to generated uniform buffers and bindings */
|
|
26
28
|
shaderInputs?: ShaderInputs;
|
|
27
|
-
/**
|
|
29
|
+
/** Factory used to create a {@link RenderPipeline}. Defaults to {@link Device} default factory. */
|
|
28
30
|
pipelineFactory?: PipelineFactory;
|
|
31
|
+
/** Factory used to create a {@link Shader}. Defaults to {@link Device} default factory. */
|
|
32
|
+
shaderFactory?: ShaderFactory;
|
|
29
33
|
/** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */
|
|
30
34
|
shaderAssembler?: ShaderAssembler;
|
|
31
35
|
/** Parameters that are built into the pipeline */
|
|
@@ -41,11 +45,15 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
41
45
|
attributes?: Record<string, Buffer>;
|
|
42
46
|
/** */
|
|
43
47
|
constantAttributes?: Record<string, TypedArray>;
|
|
48
|
+
/** Some applications intentionally supply unused attributes */
|
|
49
|
+
ignoreUnknownAttributes?: boolean;
|
|
44
50
|
/** @internal For use with {@link TransformFeedback}, WebGL only. */
|
|
45
51
|
varyings?: string[];
|
|
46
52
|
transformFeedback?: TransformFeedback;
|
|
47
53
|
/** Mapped uniforms for shadertool modules */
|
|
48
54
|
moduleSettings?: Record<string, Record<string, any>>;
|
|
55
|
+
/** Show shader source in browser? */
|
|
56
|
+
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
|
|
49
57
|
};
|
|
50
58
|
/**
|
|
51
59
|
* v9 Model API
|
|
@@ -62,6 +70,7 @@ export declare class Model {
|
|
|
62
70
|
readonly vs: string;
|
|
63
71
|
readonly fs: string;
|
|
64
72
|
readonly pipelineFactory: PipelineFactory;
|
|
73
|
+
readonly shaderFactory: ShaderFactory;
|
|
65
74
|
userData: {
|
|
66
75
|
[key: string]: any;
|
|
67
76
|
};
|
|
@@ -103,6 +112,7 @@ export declare class Model {
|
|
|
103
112
|
_gpuGeometry: GPUGeometry | null;
|
|
104
113
|
private _getModuleUniforms;
|
|
105
114
|
private props;
|
|
115
|
+
private _destroyed;
|
|
106
116
|
constructor(device: Device, props: ModelProps);
|
|
107
117
|
destroy(): void;
|
|
108
118
|
predraw(): void;
|
|
@@ -126,7 +136,7 @@ export declare class Model {
|
|
|
126
136
|
setTopology(topology: PrimitiveTopology): void;
|
|
127
137
|
/**
|
|
128
138
|
* Updates the buffer layout.
|
|
129
|
-
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
139
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
130
140
|
*/
|
|
131
141
|
setBufferLayout(bufferLayout: BufferLayout[]): void;
|
|
132
142
|
/**
|
|
@@ -179,7 +189,9 @@ export declare class Model {
|
|
|
179
189
|
* Sets attributes (buffers)
|
|
180
190
|
* @note Overrides any attributes previously set with the same name
|
|
181
191
|
*/
|
|
182
|
-
setAttributes(buffers: Record<string, Buffer>,
|
|
192
|
+
setAttributes(buffers: Record<string, Buffer>, options?: {
|
|
193
|
+
ignoreUnknownAttributes?: boolean;
|
|
194
|
+
}): void;
|
|
183
195
|
/**
|
|
184
196
|
* Sets constant attributes
|
|
185
197
|
* @note Overrides any attributes previously set with the same name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAgB,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAChG,OAAO,KAAK,EAAS,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAGvF,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAA0B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAC9C,OAAO,KAAK,EAAC,QAAQ,EAAC,gCAA6B;AACnD,OAAO,EAAC,WAAW,EAAkB,oCAAiC;AACtE,OAAO,EAAC,eAAe,EAAC,mCAAgC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAOpD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACnD,EAAE,EAAE;QAAC,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: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
|
-
import { Buffer, RenderPipeline, UniformStore
|
|
4
|
+
import { Buffer, RenderPipeline, UniformStore } from '@luma.gl/core';
|
|
4
5
|
import { log, uid, deepEqual, splitUniformsAndBindings, isNumberArray } from '@luma.gl/core';
|
|
5
|
-
import { getAttributeInfosFromLayouts } from '@luma.gl/core';
|
|
6
|
+
import { getTypedArrayFromDataType, getAttributeInfosFromLayouts } from '@luma.gl/core';
|
|
6
7
|
import { ShaderAssembler, getShaderLayoutFromWGSL } from '@luma.gl/shadertools';
|
|
7
|
-
import { ShaderInputs } from
|
|
8
|
-
import { makeGPUGeometry } from
|
|
9
|
-
import { PipelineFactory } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { ShaderInputs } from "../shader-inputs.js";
|
|
9
|
+
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
10
|
+
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
11
|
+
import { ShaderFactory } from "../lib/shader-factory.js";
|
|
12
|
+
import { getDebugTableForShaderLayout } from "../debug/debug-shader-layout.js";
|
|
13
|
+
import { debugFramebuffer } from "../debug/debug-framebuffer.js";
|
|
12
14
|
const LOG_DRAW_PRIORITY = 2;
|
|
13
15
|
const LOG_DRAW_TIMEOUT = 10000;
|
|
14
16
|
/**
|
|
@@ -38,14 +40,18 @@ export class Model {
|
|
|
38
40
|
varyings: [],
|
|
39
41
|
shaderInputs: undefined,
|
|
40
42
|
pipelineFactory: undefined,
|
|
43
|
+
shaderFactory: undefined,
|
|
41
44
|
transformFeedback: undefined,
|
|
42
|
-
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()
|
|
45
|
+
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
|
|
46
|
+
debugShaders: undefined,
|
|
47
|
+
ignoreUnknownAttributes: undefined
|
|
43
48
|
};
|
|
44
49
|
device;
|
|
45
50
|
id;
|
|
46
51
|
vs;
|
|
47
52
|
fs;
|
|
48
53
|
pipelineFactory;
|
|
54
|
+
shaderFactory;
|
|
49
55
|
userData = {};
|
|
50
56
|
// Fixed properties (change can trigger pipeline rebuild)
|
|
51
57
|
/** The render pipeline GPU parameters, depth testing etc */
|
|
@@ -87,6 +93,7 @@ export class Model {
|
|
|
87
93
|
_gpuGeometry = null;
|
|
88
94
|
_getModuleUniforms;
|
|
89
95
|
props;
|
|
96
|
+
_destroyed = false;
|
|
90
97
|
constructor(device, props) {
|
|
91
98
|
this.props = { ...Model.defaultProps, ...props };
|
|
92
99
|
props = this.props;
|
|
@@ -133,6 +140,7 @@ export class Model {
|
|
|
133
140
|
}
|
|
134
141
|
this.pipelineFactory =
|
|
135
142
|
props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
143
|
+
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
136
144
|
// Create the pipeline
|
|
137
145
|
// @note order is important
|
|
138
146
|
this.pipeline = this._updatePipeline();
|
|
@@ -158,7 +166,9 @@ export class Model {
|
|
|
158
166
|
this.setIndexBuffer(props.indexBuffer);
|
|
159
167
|
}
|
|
160
168
|
if (props.attributes) {
|
|
161
|
-
this.setAttributes(props.attributes
|
|
169
|
+
this.setAttributes(props.attributes, {
|
|
170
|
+
ignoreUnknownAttributes: props.ignoreUnknownAttributes
|
|
171
|
+
});
|
|
162
172
|
}
|
|
163
173
|
if (props.constantAttributes) {
|
|
164
174
|
this.setConstantAttributes(props.constantAttributes);
|
|
@@ -176,14 +186,17 @@ export class Model {
|
|
|
176
186
|
if (props.transformFeedback) {
|
|
177
187
|
this.transformFeedback = props.transformFeedback;
|
|
178
188
|
}
|
|
179
|
-
// TODO - restore?
|
|
180
|
-
// this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms
|
|
181
189
|
// Catch any access to non-standard props
|
|
182
190
|
Object.seal(this);
|
|
183
191
|
}
|
|
184
192
|
destroy() {
|
|
193
|
+
if (this._destroyed)
|
|
194
|
+
return;
|
|
185
195
|
this.pipelineFactory.release(this.pipeline);
|
|
196
|
+
this.shaderFactory.release(this.pipeline.vs);
|
|
197
|
+
this.shaderFactory.release(this.pipeline.fs);
|
|
186
198
|
this._uniformStore.destroy();
|
|
199
|
+
this._destroyed = true;
|
|
187
200
|
}
|
|
188
201
|
// Draw call
|
|
189
202
|
predraw() {
|
|
@@ -200,9 +213,11 @@ export class Model {
|
|
|
200
213
|
// Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
|
|
201
214
|
// Any caching needs to be done inside the pipeline functions
|
|
202
215
|
this.pipeline.setBindings(this.bindings);
|
|
203
|
-
this.pipeline.
|
|
216
|
+
this.pipeline.setUniformsWebGL(this.uniforms);
|
|
204
217
|
const { indexBuffer } = this.vertexArray;
|
|
205
|
-
const indexCount = indexBuffer
|
|
218
|
+
const indexCount = indexBuffer
|
|
219
|
+
? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)
|
|
220
|
+
: undefined;
|
|
206
221
|
this.pipeline.draw({
|
|
207
222
|
renderPass,
|
|
208
223
|
vertexArray: this.vertexArray,
|
|
@@ -249,8 +264,8 @@ export class Model {
|
|
|
249
264
|
// TODO - delete previous geometry?
|
|
250
265
|
this.vertexCount = gpuGeometry.vertexCount;
|
|
251
266
|
this.setIndexBuffer(gpuGeometry.indices);
|
|
252
|
-
this.setAttributes(gpuGeometry.attributes,
|
|
253
|
-
this.setAttributes(attributes);
|
|
267
|
+
this.setAttributes(gpuGeometry.attributes, { ignoreUnknownAttributes: true });
|
|
268
|
+
this.setAttributes(attributes, { ignoreUnknownAttributes: this.props.ignoreUnknownAttributes });
|
|
254
269
|
}
|
|
255
270
|
/**
|
|
256
271
|
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
@@ -264,7 +279,7 @@ export class Model {
|
|
|
264
279
|
}
|
|
265
280
|
/**
|
|
266
281
|
* Updates the buffer layout.
|
|
267
|
-
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
282
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
268
283
|
*/
|
|
269
284
|
setBufferLayout(bufferLayout) {
|
|
270
285
|
this.bufferLayout = this._gpuGeometry
|
|
@@ -360,7 +375,7 @@ export class Model {
|
|
|
360
375
|
* @returns self for chaining
|
|
361
376
|
*/
|
|
362
377
|
setUniforms(uniforms) {
|
|
363
|
-
this.pipeline.
|
|
378
|
+
this.pipeline.setUniformsWebGL(uniforms);
|
|
364
379
|
Object.assign(this.uniforms, uniforms);
|
|
365
380
|
}
|
|
366
381
|
/**
|
|
@@ -380,7 +395,7 @@ export class Model {
|
|
|
380
395
|
* Sets attributes (buffers)
|
|
381
396
|
* @note Overrides any attributes previously set with the same name
|
|
382
397
|
*/
|
|
383
|
-
setAttributes(buffers,
|
|
398
|
+
setAttributes(buffers, options) {
|
|
384
399
|
if (buffers.indices) {
|
|
385
400
|
log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
|
|
386
401
|
}
|
|
@@ -400,7 +415,7 @@ export class Model {
|
|
|
400
415
|
set = true;
|
|
401
416
|
}
|
|
402
417
|
}
|
|
403
|
-
if (!set &&
|
|
418
|
+
if (!set && (options?.ignoreUnknownAttributes || this.props.ignoreUnknownAttributes)) {
|
|
404
419
|
log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
|
|
405
420
|
}
|
|
406
421
|
}
|
|
@@ -417,7 +432,7 @@ export class Model {
|
|
|
417
432
|
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
418
433
|
const attributeInfo = this._attributeInfos[attributeName];
|
|
419
434
|
if (attributeInfo) {
|
|
420
|
-
this.vertexArray.
|
|
435
|
+
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
421
436
|
}
|
|
422
437
|
else {
|
|
423
438
|
log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
@@ -429,20 +444,26 @@ export class Model {
|
|
|
429
444
|
}
|
|
430
445
|
_updatePipeline() {
|
|
431
446
|
if (this._pipelineNeedsUpdate) {
|
|
447
|
+
let prevShaderVs = null;
|
|
448
|
+
let prevShaderFs = null;
|
|
432
449
|
if (this.pipeline) {
|
|
433
450
|
log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
451
|
+
prevShaderVs = this.pipeline.vs;
|
|
452
|
+
prevShaderFs = this.pipeline.fs;
|
|
434
453
|
}
|
|
435
454
|
this._pipelineNeedsUpdate = false;
|
|
436
|
-
const vs = this.
|
|
455
|
+
const vs = this.shaderFactory.createShader({
|
|
437
456
|
id: `${this.id}-vertex`,
|
|
438
457
|
stage: 'vertex',
|
|
439
|
-
source: this.vs
|
|
458
|
+
source: this.vs,
|
|
459
|
+
debug: this.props.debugShaders
|
|
440
460
|
});
|
|
441
461
|
const fs = this.fs
|
|
442
|
-
? this.
|
|
462
|
+
? this.shaderFactory.createShader({
|
|
443
463
|
id: `${this.id}-fragment`,
|
|
444
464
|
stage: 'fragment',
|
|
445
|
-
source: this.fs
|
|
465
|
+
source: this.fs,
|
|
466
|
+
debug: this.props.debugShaders
|
|
446
467
|
})
|
|
447
468
|
: null;
|
|
448
469
|
this.pipeline = this.pipelineFactory.createRenderPipeline({
|
|
@@ -454,6 +475,10 @@ export class Model {
|
|
|
454
475
|
fs
|
|
455
476
|
});
|
|
456
477
|
this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
|
|
478
|
+
if (prevShaderVs)
|
|
479
|
+
this.shaderFactory.release(prevShaderVs);
|
|
480
|
+
if (prevShaderFs)
|
|
481
|
+
this.shaderFactory.release(prevShaderFs);
|
|
457
482
|
}
|
|
458
483
|
return this.pipeline;
|
|
459
484
|
}
|
|
@@ -494,7 +519,7 @@ export class Model {
|
|
|
494
519
|
const debugFramebuffers = log.get('framebuffer');
|
|
495
520
|
this._drawCount++;
|
|
496
521
|
// Update first 3 frames and then every 60 frames
|
|
497
|
-
if (!debugFramebuffers || (
|
|
522
|
+
if (!debugFramebuffers || (this._drawCount++ > 3 && this._drawCount % 60)) {
|
|
498
523
|
return;
|
|
499
524
|
}
|
|
500
525
|
// TODO - display framebuffer output in debug window
|
|
@@ -555,6 +580,7 @@ export function getPlatformInfo(device) {
|
|
|
555
580
|
shaderLanguage: device.info.shadingLanguage,
|
|
556
581
|
shaderLanguageVersion: device.info.shadingLanguageVersion,
|
|
557
582
|
gpu: device.info.gpu,
|
|
583
|
+
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
|
|
558
584
|
features: device.features
|
|
559
585
|
};
|
|
560
586
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Matrix4 } from '@math.gl/core';
|
|
2
|
-
import { ScenegraphNode, ScenegraphNodeProps } from
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from "./scenegraph-node.js";
|
|
3
3
|
export type GroupNodeProps = ScenegraphNodeProps & {
|
|
4
4
|
children?: ScenegraphNode[];
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,
|
|
1
|
+
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAAA,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"}
|