@luma.gl/engine 9.1.0-alpha.13 → 9.1.0-alpha.15
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-loop/animation-loop.d.ts +2 -0
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +19 -2
- package/dist/animation-loop/make-animation-loop.d.ts +5 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +1 -1
- package/dist/async-texture/async-texture.d.ts +10 -0
- package/dist/async-texture/async-texture.d.ts.map +1 -1
- package/dist/async-texture/async-texture.js +14 -0
- package/dist/compute/buffer-transform.d.ts +41 -0
- package/dist/compute/buffer-transform.d.ts.map +1 -0
- package/dist/{transform → compute}/buffer-transform.js +18 -12
- package/dist/{computation.d.ts → compute/computation.d.ts} +3 -3
- package/dist/compute/computation.d.ts.map +1 -0
- package/dist/{computation.js → compute/computation.js} +4 -4
- package/dist/compute/swap.d.ts +22 -0
- package/dist/compute/swap.d.ts.map +1 -0
- package/dist/compute/swap.js +30 -0
- package/dist/{transform → compute}/texture-transform.d.ts +0 -6
- package/dist/compute/texture-transform.d.ts.map +1 -0
- package/dist/{transform → compute}/texture-transform.js +0 -12
- package/dist/debug/debug-framebuffer.js +1 -1
- package/dist/dist.dev.js +152 -31
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +155 -26
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/lib/clip-space.d.ts +2 -2
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +3 -3
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +2 -1
- package/dist/modules/picking/picking-manager.d.ts +27 -0
- package/dist/modules/picking/picking-manager.d.ts.map +1 -0
- package/dist/modules/picking/picking-manager.js +75 -0
- package/package.json +4 -4
- package/src/animation-loop/animation-loop.ts +20 -2
- package/src/animation-loop/make-animation-loop.ts +7 -3
- package/src/async-texture/async-texture.ts +14 -5
- package/src/{transform → compute}/buffer-transform.ts +30 -14
- package/src/{computation.ts → compute/computation.ts} +4 -4
- package/src/compute/swap.ts +36 -0
- package/src/{transform → compute}/texture-transform.ts +0 -15
- package/src/debug/debug-framebuffer.ts +1 -1
- package/src/index.ts +11 -6
- package/src/lib/clip-space.ts +3 -3
- package/src/model/model.ts +2 -1
- package/src/modules/picking/picking-manager.ts +96 -0
- package/dist/computation.d.ts.map +0 -1
- package/dist/transform/buffer-transform.d.ts +0 -35
- package/dist/transform/buffer-transform.d.ts.map +0 -1
- package/dist/transform/texture-transform.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export type { MakeAnimationLoopProps } from "./animation-loop/make-animation-loo
|
|
|
8
8
|
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
9
9
|
export type { ModelProps } from "./model/model.js";
|
|
10
10
|
export { Model } from "./model/model.js";
|
|
11
|
-
export type { BufferTransformProps } from "./
|
|
12
|
-
export { BufferTransform } from "./
|
|
13
|
-
export type { TextureTransformProps } from "./
|
|
14
|
-
export { TextureTransform } from "./
|
|
11
|
+
export type { BufferTransformProps } from "./compute/buffer-transform.js";
|
|
12
|
+
export { BufferTransform } from "./compute/buffer-transform.js";
|
|
13
|
+
export type { TextureTransformProps } from "./compute/texture-transform.js";
|
|
14
|
+
export { TextureTransform } from "./compute/texture-transform.js";
|
|
15
15
|
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
16
16
|
export { ShaderFactory } from "./lib/shader-factory.js";
|
|
17
17
|
export { ClipSpace } from "./lib/clip-space.js";
|
|
@@ -41,9 +41,11 @@ export { makeRandomGenerator } from "./application-utils/random.js";
|
|
|
41
41
|
export { setPathPrefix, loadImage, loadImageBitmap } from "./application-utils/load-file.js";
|
|
42
42
|
export type { ShaderModuleInputs } from "./shader-inputs.js";
|
|
43
43
|
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
44
|
-
export
|
|
45
|
-
export {
|
|
44
|
+
export { Swap } from "./compute/swap.js";
|
|
45
|
+
export type { ComputationProps } from "./compute/computation.js";
|
|
46
|
+
export { Computation } from "./compute/computation.js";
|
|
46
47
|
export { requestAnimationFrame, cancelAnimationFrame } from "./animation-loop/request-animation-frame.js";
|
|
47
48
|
export type { AsyncTextureProps } from "./async-texture/async-texture.js";
|
|
48
49
|
export { AsyncTexture } from "./async-texture/async-texture.js";
|
|
50
|
+
export { PickingManager as _PickingManager } from "./modules/picking/picking-manager.js";
|
|
49
51
|
//# 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":"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,
|
|
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,E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Aa,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;AAE9D,OAAO,EAAC,IAAI,EAAC,0BAAuB;AACpC,YAAY,EAAC,gBAAgB,EAAC,iCAA8B;AAC5D,OAAO,EAAC,WAAW,EAAC,iCAA8B;AAElD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,oDAAiD;AAElD,YAAY,EAAC,iBAAiB,EAAC,yCAAsC;AACrE,OAAO,EAAC,YAAY,EAAC,yCAAsC;AAE3D,OAAO,EAAC,cAAc,IAAI,eAAe,EAAC,6CAA0C"}
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ export { AnimationLoopTemplate } from "./animation-loop/animation-loop-template.
|
|
|
9
9
|
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
10
10
|
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
11
11
|
export { Model } from "./model/model.js";
|
|
12
|
-
export { BufferTransform } from "./
|
|
13
|
-
export { TextureTransform } from "./
|
|
12
|
+
export { BufferTransform } from "./compute/buffer-transform.js";
|
|
13
|
+
export { TextureTransform } from "./compute/texture-transform.js";
|
|
14
14
|
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
15
15
|
export { ShaderFactory } from "./lib/shader-factory.js";
|
|
16
16
|
// Utils
|
|
@@ -32,6 +32,8 @@ export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
|
|
|
32
32
|
export { makeRandomGenerator } from "./application-utils/random.js";
|
|
33
33
|
export { setPathPrefix, loadImage, loadImageBitmap } from "./application-utils/load-file.js";
|
|
34
34
|
export { ShaderInputs as _ShaderInputs } from "./shader-inputs.js";
|
|
35
|
-
export {
|
|
35
|
+
export { Swap } from "./compute/swap.js";
|
|
36
|
+
export { Computation } from "./compute/computation.js";
|
|
36
37
|
export { requestAnimationFrame, cancelAnimationFrame } from "./animation-loop/request-animation-frame.js";
|
|
37
38
|
export { AsyncTexture } from "./async-texture/async-texture.js";
|
|
39
|
+
export { PickingManager as _PickingManager } from "./modules/picking/picking-manager.js";
|
package/dist/lib/clip-space.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Device } from '@luma.gl/core';
|
|
2
2
|
import { Model, ModelProps } from "../model/model.js";
|
|
3
3
|
/**
|
|
4
|
-
* A flat geometry that covers the "visible area" that the GPU renders.
|
|
4
|
+
* A flat geometry that covers the "visible area" / screen space that the GPU renders.
|
|
5
5
|
*/
|
|
6
6
|
export declare class ClipSpace extends Model {
|
|
7
|
-
constructor(device: Device,
|
|
7
|
+
constructor(device: Device, props: Omit<ModelProps, 'vs' | 'vertexCount' | 'geometry'>);
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=clip-space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,aAAa,GAAG,UAAU,CAAC;CAkBvF"}
|
package/dist/lib/clip-space.js
CHANGED
|
@@ -23,13 +23,13 @@ void main(void) {
|
|
|
23
23
|
/* eslint-disable indent, no-multi-spaces */
|
|
24
24
|
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
25
25
|
/**
|
|
26
|
-
* A flat geometry that covers the "visible area" that the GPU renders.
|
|
26
|
+
* A flat geometry that covers the "visible area" / screen space that the GPU renders.
|
|
27
27
|
*/
|
|
28
28
|
export class ClipSpace extends Model {
|
|
29
|
-
constructor(device,
|
|
29
|
+
constructor(device, props) {
|
|
30
30
|
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
|
|
31
31
|
super(device, {
|
|
32
|
-
...
|
|
32
|
+
...props,
|
|
33
33
|
vs: CLIPSPACE_VERTEX_SHADER,
|
|
34
34
|
vertexCount: 4,
|
|
35
35
|
geometry: new Geometry({
|
|
@@ -1 +1 @@
|
|
|
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,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EAEZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,YAAY,EACZ,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,MAAM,EAEN,MAAM,EAIN,cAAc,EACd,UAAU,EACV,YAAY,EAIb,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EA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EAAE,GAAG,CAAC,GAAG,IAAI;IAUtD,yDAAyD;IACzD,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAcvC,0FAA0F;IAC1F,2BAA2B,IAAI,MAAM;IAmBrC;;;;OAIG;IACH,sBAAsB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBtD,sCAAsC;IACtC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK7C,gCAAgC;IAChC,eAAe,IAAI,cAAc;IAyDjC,iCAAiC;IACjC,YAAY,SAAK;IACjB,QAAQ,UAAS;IAEjB,iBAAiB,IAAI,IAAI;IAazB,eAAe,IAAI,IAAI;IAwBvB,SAAS,CAAC,UAAU,SAAK;IACzB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAgB7C,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA4BlE,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM;CAMlF;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS5D"}
|
package/dist/model/model.js
CHANGED
|
@@ -641,7 +641,8 @@ export class Model {
|
|
|
641
641
|
const debugFramebuffers = log.get('framebuffer');
|
|
642
642
|
this._drawCount++;
|
|
643
643
|
// Update first 3 frames and then every 60 frames
|
|
644
|
-
if (!debugFramebuffers
|
|
644
|
+
if (!debugFramebuffers) {
|
|
645
|
+
// } || (this._drawCount++ > 3 && this._drawCount % 60)) {
|
|
645
646
|
return;
|
|
646
647
|
}
|
|
647
648
|
// TODO - display framebuffer output in debug window
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Device, Framebuffer } from '@luma.gl/core';
|
|
2
|
+
import { picking } from '@luma.gl/shadertools';
|
|
3
|
+
import { ShaderInputs } from "../../shader-inputs.js";
|
|
4
|
+
/**
|
|
5
|
+
* Helper class for using the picking module
|
|
6
|
+
*/
|
|
7
|
+
export declare class PickingManager {
|
|
8
|
+
device: Device;
|
|
9
|
+
framebuffer: Framebuffer | null;
|
|
10
|
+
shaderInputs: ShaderInputs<{
|
|
11
|
+
picking: typeof picking.props;
|
|
12
|
+
}>;
|
|
13
|
+
constructor(device: Device, shaderInputs: ShaderInputs);
|
|
14
|
+
destroy(): void;
|
|
15
|
+
getFramebuffer(): Framebuffer;
|
|
16
|
+
/** Clear highlighted / picked object */
|
|
17
|
+
clearPickState(): void;
|
|
18
|
+
/** Prepare for rendering picking colors */
|
|
19
|
+
beginRenderPass(): import("@luma.gl/core").RenderPass;
|
|
20
|
+
updatePickState(mousePosition: [number, number]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get pick position in device pixel range
|
|
23
|
+
* use the center pixel location in device pixel range
|
|
24
|
+
*/
|
|
25
|
+
getPickPosition(mousePosition: number[]): [number, number];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=picking-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picking-manager.d.ts","sourceRoot":"","sources":["../../../src/modules/picking/picking-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,+BAA4B;AAEjD;;GAEG;AACH,qBAAa,cAAc;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,GAAG,IAAI,CAAQ;IACvC,YAAY,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,OAAO,OAAO,CAAC,KAAK,CAAA;KAAC,CAAC,CAAC;gBAEhD,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY;IAKtD,OAAO;IAIP,cAAc;IAUd,wCAAwC;IACxC,cAAc;IAId,2CAA2C;IAC3C,eAAe;IAef,eAAe,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IA6B/C;;;OAGG;IACH,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAM3D"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Helper class for using the picking module
|
|
6
|
+
*/
|
|
7
|
+
export class PickingManager {
|
|
8
|
+
device;
|
|
9
|
+
framebuffer = null;
|
|
10
|
+
shaderInputs;
|
|
11
|
+
constructor(device, shaderInputs) {
|
|
12
|
+
this.device = device;
|
|
13
|
+
this.shaderInputs = shaderInputs;
|
|
14
|
+
}
|
|
15
|
+
destroy() {
|
|
16
|
+
this.framebuffer?.destroy();
|
|
17
|
+
}
|
|
18
|
+
getFramebuffer() {
|
|
19
|
+
if (!this.framebuffer) {
|
|
20
|
+
this.framebuffer = this.device.createFramebuffer({
|
|
21
|
+
colorAttachments: ['rgba8unorm'],
|
|
22
|
+
depthStencilAttachment: 'depth24plus'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return this.framebuffer;
|
|
26
|
+
}
|
|
27
|
+
/** Clear highlighted / picked object */
|
|
28
|
+
clearPickState() {
|
|
29
|
+
this.shaderInputs.setProps({ picking: { highlightedObjectColor: null } });
|
|
30
|
+
}
|
|
31
|
+
/** Prepare for rendering picking colors */
|
|
32
|
+
beginRenderPass() {
|
|
33
|
+
const framebuffer = this.getFramebuffer();
|
|
34
|
+
framebuffer.resize(this.device.getCanvasContext().getPixelSize());
|
|
35
|
+
this.shaderInputs.setProps({ picking: { isActive: true } });
|
|
36
|
+
const pickingPass = this.device.beginRenderPass({
|
|
37
|
+
framebuffer,
|
|
38
|
+
clearColor: [0, 0, 0, 0],
|
|
39
|
+
clearDepth: 1
|
|
40
|
+
});
|
|
41
|
+
return pickingPass;
|
|
42
|
+
}
|
|
43
|
+
updatePickState(mousePosition) {
|
|
44
|
+
const framebuffer = this.getFramebuffer();
|
|
45
|
+
// use the center pixel location in device pixel range
|
|
46
|
+
const [pickX, pickY] = this.getPickPosition(mousePosition);
|
|
47
|
+
// Read back
|
|
48
|
+
const color255 = this.device.readPixelsToArrayWebGL(framebuffer, {
|
|
49
|
+
sourceX: pickX,
|
|
50
|
+
sourceY: pickY,
|
|
51
|
+
sourceWidth: 1,
|
|
52
|
+
sourceHeight: 1
|
|
53
|
+
});
|
|
54
|
+
console.log(color255);
|
|
55
|
+
// Check if we have
|
|
56
|
+
let highlightedObjectColor = new Float32Array(color255).map(x => x / 255);
|
|
57
|
+
const isHighlightActive = highlightedObjectColor[0] + highlightedObjectColor[1] + highlightedObjectColor[2] > 0;
|
|
58
|
+
if (!isHighlightActive) {
|
|
59
|
+
highlightedObjectColor = null;
|
|
60
|
+
}
|
|
61
|
+
this.shaderInputs.setProps({
|
|
62
|
+
picking: { isActive: false, highlightedObjectColor }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get pick position in device pixel range
|
|
67
|
+
* use the center pixel location in device pixel range
|
|
68
|
+
*/
|
|
69
|
+
getPickPosition(mousePosition) {
|
|
70
|
+
const devicePixels = this.device.getCanvasContext().cssToDevicePixels(mousePosition);
|
|
71
|
+
const pickX = devicePixels.x + Math.floor(devicePixels.width / 2);
|
|
72
|
+
const pickY = devicePixels.y + Math.floor(devicePixels.height / 2);
|
|
73
|
+
return [pickX, pickY];
|
|
74
|
+
}
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.15",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "9.1.0-alpha.
|
|
44
|
-
"@luma.gl/shadertools": "9.1.0-alpha.
|
|
43
|
+
"@luma.gl/core": "9.1.0-alpha.14",
|
|
44
|
+
"@luma.gl/shadertools": "9.1.0-alpha.14"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@math.gl/core": "4.1.0-alpha.3",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@probe.gl/log": "^4.0.8",
|
|
50
50
|
"@probe.gl/stats": "^4.0.8"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "41af576ca655cb749a5567cf903f9e9242793c77"
|
|
53
53
|
}
|
|
@@ -77,6 +77,7 @@ export class AnimationLoop {
|
|
|
77
77
|
_nextFramePromise: Promise<AnimationLoop> | null = null;
|
|
78
78
|
_resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;
|
|
79
79
|
_cpuStartTime: number = 0;
|
|
80
|
+
_error: Error | null = null;
|
|
80
81
|
|
|
81
82
|
// _gpuTimeQuery: Query | null = null;
|
|
82
83
|
|
|
@@ -123,6 +124,23 @@ export class AnimationLoop {
|
|
|
123
124
|
this.destroy();
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
setError(error: Error): void {
|
|
128
|
+
this.props.onError(error);
|
|
129
|
+
this._error = Error();
|
|
130
|
+
const canvas = this.device?.canvasContext?.canvas;
|
|
131
|
+
if (canvas instanceof HTMLCanvasElement) {
|
|
132
|
+
const errorDiv = document.createElement('h1');
|
|
133
|
+
errorDiv.innerHTML = error.message;
|
|
134
|
+
errorDiv.style.position = 'absolute';
|
|
135
|
+
errorDiv.style.top = '20%'; // left: 50%; transform: translate(-50%, -50%);';
|
|
136
|
+
errorDiv.style.left = '10px';
|
|
137
|
+
errorDiv.style.color = 'black';
|
|
138
|
+
errorDiv.style.backgroundColor = 'red';
|
|
139
|
+
document.body.appendChild(errorDiv);
|
|
140
|
+
// canvas.style.position = 'absolute';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
126
144
|
/** Flags this animation loop as needing redraw */
|
|
127
145
|
setNeedsRedraw(reason: string): this {
|
|
128
146
|
this.needsRedraw = this.needsRedraw || reason;
|
|
@@ -189,7 +207,7 @@ export class AnimationLoop {
|
|
|
189
207
|
if (this._running) {
|
|
190
208
|
// call callback
|
|
191
209
|
// If stop is called immediately, we can end up in a state where props haven't been initialized...
|
|
192
|
-
if (this.animationProps) {
|
|
210
|
+
if (this.animationProps && !this._error) {
|
|
193
211
|
this.props.onFinalize(this.animationProps);
|
|
194
212
|
}
|
|
195
213
|
|
|
@@ -203,7 +221,7 @@ export class AnimationLoop {
|
|
|
203
221
|
|
|
204
222
|
/** Explicitly draw a frame */
|
|
205
223
|
redraw(): this {
|
|
206
|
-
if (this.device?.isLost) {
|
|
224
|
+
if (this.device?.isLost || this._error) {
|
|
207
225
|
return this;
|
|
208
226
|
}
|
|
209
227
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {luma} from '@luma.gl/core';
|
|
5
|
+
import {luma, Adapter} from '@luma.gl/core';
|
|
6
6
|
import {AnimationLoopTemplate} from './animation-loop-template';
|
|
7
7
|
import {AnimationLoop, AnimationLoopProps} from './animation-loop';
|
|
8
8
|
import type {AnimationProps} from './animation-props';
|
|
@@ -10,7 +10,10 @@ import type {AnimationProps} from './animation-props';
|
|
|
10
10
|
export type MakeAnimationLoopProps = Omit<
|
|
11
11
|
AnimationLoopProps,
|
|
12
12
|
'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'
|
|
13
|
-
|
|
13
|
+
> & {
|
|
14
|
+
/** List of adapters to use when creating the device */
|
|
15
|
+
adapters?: Adapter[];
|
|
16
|
+
};
|
|
14
17
|
|
|
15
18
|
/** Instantiates and runs the render loop */
|
|
16
19
|
export function makeAnimationLoop(
|
|
@@ -19,7 +22,8 @@ export function makeAnimationLoop(
|
|
|
19
22
|
): AnimationLoop {
|
|
20
23
|
let renderLoop: AnimationLoopTemplate | null = null;
|
|
21
24
|
|
|
22
|
-
const device =
|
|
25
|
+
const device =
|
|
26
|
+
props?.device || luma.createDevice({id: 'animation-loop', adapters: props?.adapters});
|
|
23
27
|
|
|
24
28
|
// Create an animation loop;
|
|
25
29
|
const animationLoop = new AnimationLoop({
|
|
@@ -120,11 +120,20 @@ export class AsyncTexture {
|
|
|
120
120
|
this.destroyed = true;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Textures are immutable and cannot be resized after creation,
|
|
125
|
+
* but we can create a similar texture with the same parameters but a new size.
|
|
126
|
+
* @note Does not copy contents of the texture
|
|
127
|
+
* @todo Abort pending promise and create a texture with the new size?
|
|
128
|
+
*/
|
|
129
|
+
resize(size: {width: number; height: number}): void {
|
|
130
|
+
if (!this.isReady) {
|
|
131
|
+
throw new Error('Cannot resize texture before it is ready');
|
|
132
|
+
}
|
|
133
|
+
if (this.texture) {
|
|
134
|
+
this.texture = this.texture.createResizedTexture(size);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
// HELPERS
|
|
@@ -9,28 +9,37 @@ import type {ModelProps} from '../model/model';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Properties for creating a {@link BufferTransform}
|
|
12
|
-
* @
|
|
12
|
+
* @note Only works under WebGL2.
|
|
13
13
|
*/
|
|
14
14
|
export type BufferTransformProps = Omit<ModelProps, 'fs'> & {
|
|
15
|
+
/** Optional fragment shader - normally not used in transforms */
|
|
15
16
|
fs?: ModelProps['fs']; // override as optional
|
|
17
|
+
/** A list of named outputs corresponding to shader declarations (varyings in WebGL) */
|
|
18
|
+
outputs?: string[];
|
|
19
|
+
/** @deprecated Use run({outputBuffers}) instead - Map of output buffers that the shaders will write results of computations to */
|
|
16
20
|
feedbackBuffers?: Record<string, Buffer | BufferRange>;
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
24
|
+
* Manages a WebGL program (pipeline) for buffer→buffer transforms.
|
|
25
|
+
* @note Only works under WebGL2.
|
|
22
26
|
*/
|
|
23
27
|
export class BufferTransform {
|
|
24
28
|
readonly device: Device;
|
|
25
29
|
readonly model: Model;
|
|
26
30
|
readonly transformFeedback: TransformFeedback;
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
static defaultProps: Required<BufferTransformProps> = {
|
|
33
|
+
...Model.defaultProps,
|
|
34
|
+
outputs: undefined!,
|
|
35
|
+
feedbackBuffers: undefined!
|
|
36
|
+
};
|
|
37
|
+
|
|
29
38
|
static isSupported(device: Device): boolean {
|
|
30
39
|
return device?.info?.type === 'webgl';
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
constructor(device: Device, props: BufferTransformProps =
|
|
42
|
+
constructor(device: Device, props: BufferTransformProps = BufferTransform.defaultProps) {
|
|
34
43
|
if (!BufferTransform.isSupported(device)) {
|
|
35
44
|
throw new Error('BufferTransform not yet implemented on WebGPU');
|
|
36
45
|
}
|
|
@@ -41,6 +50,7 @@ export class BufferTransform {
|
|
|
41
50
|
id: props.id || 'buffer-transform-model',
|
|
42
51
|
fs: props.fs || getPassthroughFS(),
|
|
43
52
|
topology: props.topology || 'point-list',
|
|
53
|
+
varyings: props.outputs || props.varyings,
|
|
44
54
|
...props
|
|
45
55
|
});
|
|
46
56
|
|
|
@@ -68,25 +78,31 @@ export class BufferTransform {
|
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
/** Run one transform loop. */
|
|
71
|
-
run(
|
|
81
|
+
run(
|
|
82
|
+
options?: RenderPassProps & {
|
|
83
|
+
inputBuffers?: Record<string, Buffer>;
|
|
84
|
+
outputBuffers?: Record<string, Buffer>;
|
|
85
|
+
}
|
|
86
|
+
): void {
|
|
87
|
+
if (options?.inputBuffers) {
|
|
88
|
+
this.model.setAttributes(options.inputBuffers);
|
|
89
|
+
}
|
|
90
|
+
if (options?.outputBuffers) {
|
|
91
|
+
this.transformFeedback.setBuffers(options.outputBuffers);
|
|
92
|
+
}
|
|
72
93
|
const renderPass = this.device.beginRenderPass(options);
|
|
73
94
|
this.model.draw(renderPass);
|
|
74
95
|
renderPass.end();
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
|
|
78
|
-
update(...args: any[]): void {
|
|
79
|
-
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
80
|
-
// to assist with migrating DeckGL usage.
|
|
81
|
-
// eslint-disable-next-line no-console
|
|
82
|
-
console.warn('TextureTransform#update() not implemented');
|
|
83
|
-
}
|
|
98
|
+
// DEPRECATED METHODS
|
|
84
99
|
|
|
85
|
-
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
100
|
+
/** @deprecated App knows what buffers it is passing in - Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
86
101
|
getBuffer(varyingName: string): Buffer | BufferRange | null {
|
|
87
102
|
return this.transformFeedback.getBuffer(varyingName);
|
|
88
103
|
}
|
|
89
104
|
|
|
105
|
+
/** @deprecated App knows what buffers it is passing in - Reads the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
90
106
|
readAsync(varyingName: string): Promise<Uint8Array> {
|
|
91
107
|
const result = this.getBuffer(varyingName);
|
|
92
108
|
if (!result) {
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
import type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';
|
|
16
16
|
import {ShaderAssembler, getShaderLayoutFromWGSL} from '@luma.gl/shadertools';
|
|
17
17
|
import {TypedArray, isNumericArray} from '@math.gl/types';
|
|
18
|
-
import {ShaderInputs} from '
|
|
19
|
-
import {PipelineFactory} from '
|
|
20
|
-
import {ShaderFactory} from '
|
|
21
|
-
import {uid} from '
|
|
18
|
+
import {ShaderInputs} from '../shader-inputs';
|
|
19
|
+
import {PipelineFactory} from '../lib/pipeline-factory';
|
|
20
|
+
import {ShaderFactory} from '../lib/shader-factory';
|
|
21
|
+
import {uid} from '../utils/uid';
|
|
22
22
|
// import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
|
|
23
23
|
|
|
24
24
|
const LOG_DRAW_PRIORITY = 2;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Resource} from '@luma.gl/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Helper class for working with repeated transformations / computations
|
|
9
|
+
* Primarily intended for GPU buffers `Swap<Buffer>` or textures `Swap<Texture>`)
|
|
10
|
+
* @note the two resources are expected to be structurally identical (same size, length, format, etc)
|
|
11
|
+
* @note the two resources can be destroyed by calling `destroy()`
|
|
12
|
+
*/
|
|
13
|
+
export class Swap<T extends Resource<any>> {
|
|
14
|
+
/** The current resource - usually the source for renders or computations */
|
|
15
|
+
current: T;
|
|
16
|
+
/** The next resource - usually the target/destination for transforms / computations */
|
|
17
|
+
next: T;
|
|
18
|
+
|
|
19
|
+
constructor(props: {current: T; next: T}) {
|
|
20
|
+
this.current = props.current;
|
|
21
|
+
this.next = props.next;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Destroys the two managed resources */
|
|
25
|
+
destroy() {
|
|
26
|
+
this.current?.destroy();
|
|
27
|
+
this.next?.destroy();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Make the next resource into the current resource, and reuse the current resource as the next resource */
|
|
31
|
+
swap() {
|
|
32
|
+
const current = this.current;
|
|
33
|
+
this.current = this.next;
|
|
34
|
+
this.next = current;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -8,7 +8,6 @@ import {getPassthroughFS} from '@luma.gl/shadertools';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Properties for creating a {@link TextureTransform}
|
|
11
|
-
* @deprecated
|
|
12
11
|
*/
|
|
13
12
|
export type TextureTransformProps = Omit<ModelProps, 'fs'> & {
|
|
14
13
|
fs?: ModelProps['fs']; // override as optional
|
|
@@ -92,20 +91,6 @@ export class TextureTransform {
|
|
|
92
91
|
renderPass.end();
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
/** @deprecated */
|
|
96
|
-
update(...args: any[]): void {
|
|
97
|
-
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
98
|
-
// to assist with migrating DeckGL usage.
|
|
99
|
-
// eslint-disable-next-line no-console
|
|
100
|
-
console.warn('TextureTransform#update() not implemented');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
getData({packed = false} = {}) {
|
|
104
|
-
// TODO(v9): Method should likely be removed for v9. Keeping a method stub
|
|
105
|
-
// to assist with migrating DeckGL usage.
|
|
106
|
-
throw new Error('getData() not implemented');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
94
|
getTargetTexture(): Texture {
|
|
110
95
|
const {targetTexture} = this.bindings[this.currentIndex];
|
|
111
96
|
return targetTexture;
|
|
@@ -38,7 +38,7 @@ export function debugFramebuffer(
|
|
|
38
38
|
canvas.style.position = 'absolute';
|
|
39
39
|
canvas.style.top = top; // ⚠️
|
|
40
40
|
canvas.style.left = left; // ⚠️
|
|
41
|
-
canvas.style.border = 'blue
|
|
41
|
+
canvas.style.border = 'blue 5px solid';
|
|
42
42
|
canvas.style.transform = 'scaleY(-1)';
|
|
43
43
|
document.body.appendChild(canvas);
|
|
44
44
|
|
package/src/index.ts
CHANGED
|
@@ -21,10 +21,10 @@ export type {ModelProps} from './model/model';
|
|
|
21
21
|
export {Model} from './model/model';
|
|
22
22
|
|
|
23
23
|
// Transforms
|
|
24
|
-
export type {BufferTransformProps} from './
|
|
25
|
-
export {BufferTransform} from './
|
|
26
|
-
export type {TextureTransformProps} from './
|
|
27
|
-
export {TextureTransform} from './
|
|
24
|
+
export type {BufferTransformProps} from './compute/buffer-transform';
|
|
25
|
+
export {BufferTransform} from './compute/buffer-transform';
|
|
26
|
+
export type {TextureTransformProps} from './compute/texture-transform';
|
|
27
|
+
export {TextureTransform} from './compute/texture-transform';
|
|
28
28
|
|
|
29
29
|
export {PipelineFactory} from './lib/pipeline-factory';
|
|
30
30
|
export {ShaderFactory} from './lib/shader-factory';
|
|
@@ -67,8 +67,11 @@ export {setPathPrefix, loadImage, loadImageBitmap} from './application-utils/loa
|
|
|
67
67
|
// EXPERIMENTAL
|
|
68
68
|
export type {ShaderModuleInputs} from './shader-inputs';
|
|
69
69
|
export {ShaderInputs as _ShaderInputs} from './shader-inputs';
|
|
70
|
-
|
|
71
|
-
export {
|
|
70
|
+
|
|
71
|
+
export {Swap} from './compute/swap';
|
|
72
|
+
export type {ComputationProps} from './compute/computation';
|
|
73
|
+
export {Computation} from './compute/computation';
|
|
74
|
+
|
|
72
75
|
export {
|
|
73
76
|
requestAnimationFrame,
|
|
74
77
|
cancelAnimationFrame
|
|
@@ -76,3 +79,5 @@ export {
|
|
|
76
79
|
|
|
77
80
|
export type {AsyncTextureProps} from './async-texture/async-texture';
|
|
78
81
|
export {AsyncTexture} from './async-texture/async-texture';
|
|
82
|
+
|
|
83
|
+
export {PickingManager as _PickingManager} from './modules/picking/picking-manager';
|
package/src/lib/clip-space.ts
CHANGED
|
@@ -29,14 +29,14 @@ void main(void) {
|
|
|
29
29
|
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* A flat geometry that covers the "visible area" that the GPU renders.
|
|
32
|
+
* A flat geometry that covers the "visible area" / screen space that the GPU renders.
|
|
33
33
|
*/
|
|
34
34
|
export class ClipSpace extends Model {
|
|
35
|
-
constructor(device: Device,
|
|
35
|
+
constructor(device: Device, props: Omit<ModelProps, 'vs' | 'vertexCount' | 'geometry'>) {
|
|
36
36
|
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
|
|
37
37
|
|
|
38
38
|
super(device, {
|
|
39
|
-
...
|
|
39
|
+
...props,
|
|
40
40
|
vs: CLIPSPACE_VERTEX_SHADER,
|
|
41
41
|
vertexCount: 4,
|
|
42
42
|
geometry: new Geometry({
|
package/src/model/model.ts
CHANGED
|
@@ -834,7 +834,8 @@ export class Model {
|
|
|
834
834
|
const debugFramebuffers = log.get('framebuffer');
|
|
835
835
|
this._drawCount++;
|
|
836
836
|
// Update first 3 frames and then every 60 frames
|
|
837
|
-
if (!debugFramebuffers
|
|
837
|
+
if (!debugFramebuffers) {
|
|
838
|
+
// } || (this._drawCount++ > 3 && this._drawCount % 60)) {
|
|
838
839
|
return;
|
|
839
840
|
}
|
|
840
841
|
// TODO - display framebuffer output in debug window
|