@vitessce/gl 2.0.3 → 3.0.1
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/{deflate.04b04545.mjs → deflate-36830437.js} +2 -2
- package/dist/{index.9aaafdeb.mjs → index-d34ff949.js} +13285 -10710
- package/dist/index.js +33 -0
- package/dist/{jpeg.060c9bc0.mjs → jpeg-a66190dc.js} +1 -1
- package/dist/{lerc.62b02b29.mjs → lerc-21af7ec8.js} +76 -5
- package/dist/{lzw.19cdd4de.mjs → lzw-76194936.js} +1 -1
- package/dist/{packbits.03fc75de.mjs → packbits-bf7850c4.js} +1 -1
- package/dist/{pako.esm.0e57f323.mjs → pako.esm-68f84e2a.js} +97 -15
- package/dist/{raw.739ce163.mjs → raw-05d82ade.js} +1 -1
- package/dist/{webimage.4e868fb9.mjs → webimage-1ceac06a.js} +1 -1
- package/dist-tsc/BitmaskLayer.d.ts +74 -0
- package/dist-tsc/BitmaskLayer.d.ts.map +1 -0
- package/dist-tsc/BitmaskLayer.js +142 -0
- package/dist-tsc/HeatmapBitmapLayer.d.ts +93 -0
- package/dist-tsc/HeatmapBitmapLayer.d.ts.map +1 -0
- package/dist-tsc/HeatmapBitmapLayer.js +123 -0
- package/dist-tsc/HeatmapCompositeTextLayer.d.ts +11 -0
- package/dist-tsc/HeatmapCompositeTextLayer.d.ts.map +1 -0
- package/dist-tsc/HeatmapCompositeTextLayer.js +129 -0
- package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts +93 -0
- package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts.map +1 -0
- package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.js +129 -0
- package/dist-tsc/PixelatedBitmapLayer.d.ts +10 -0
- package/dist-tsc/PixelatedBitmapLayer.d.ts.map +1 -0
- package/dist-tsc/PixelatedBitmapLayer.js +26 -0
- package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts +62 -0
- package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts.map +1 -0
- package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.js +105 -0
- package/dist-tsc/ScaledExpressionExtension/index.d.ts +3 -0
- package/dist-tsc/ScaledExpressionExtension/index.d.ts.map +1 -0
- package/dist-tsc/ScaledExpressionExtension/index.js +2 -0
- package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts +17 -0
- package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts.map +1 -0
- package/dist-tsc/ScaledExpressionExtension/shader-module.js +32 -0
- package/dist-tsc/SelectionExtension/SelectionExtension.d.ts +18 -0
- package/dist-tsc/SelectionExtension/SelectionExtension.d.ts.map +1 -0
- package/dist-tsc/SelectionExtension/SelectionExtension.js +31 -0
- package/dist-tsc/SelectionExtension/index.d.ts +3 -0
- package/dist-tsc/SelectionExtension/index.d.ts.map +1 -0
- package/dist-tsc/SelectionExtension/index.js +2 -0
- package/dist-tsc/SelectionExtension/shader-module.d.ts +12 -0
- package/dist-tsc/SelectionExtension/shader-module.d.ts.map +1 -0
- package/dist-tsc/SelectionExtension/shader-module.js +20 -0
- package/dist-tsc/SelectionLayer.d.ts +15 -0
- package/dist-tsc/SelectionLayer.d.ts.map +1 -0
- package/dist-tsc/SelectionLayer.js +157 -0
- package/dist-tsc/bitmask-layer-shaders.d.ts +3 -0
- package/dist-tsc/bitmask-layer-shaders.d.ts.map +1 -0
- package/dist-tsc/bitmask-layer-shaders.js +90 -0
- package/dist-tsc/constants.d.ts +8 -0
- package/dist-tsc/constants.d.ts.map +1 -0
- package/dist-tsc/constants.js +11 -0
- package/dist-tsc/deck.d.ts +2 -0
- package/dist-tsc/deck.d.ts.map +1 -0
- package/dist-tsc/deck.js +4 -0
- package/dist-tsc/glsl/index.d.ts +2 -0
- package/dist-tsc/glsl/index.d.ts.map +1 -0
- package/dist-tsc/glsl/index.js +340 -0
- package/dist-tsc/heatmap-bitmap-layer-shaders.d.ts +13 -0
- package/dist-tsc/heatmap-bitmap-layer-shaders.d.ts.map +1 -0
- package/dist-tsc/heatmap-bitmap-layer-shaders.js +109 -0
- package/dist-tsc/heatmap-constants.d.ts +20 -0
- package/dist-tsc/heatmap-constants.d.ts.map +1 -0
- package/dist-tsc/heatmap-constants.js +27 -0
- package/dist-tsc/index.d.ts +14 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +16 -13
- package/dist-tsc/luma.d.ts +2 -0
- package/dist-tsc/luma.d.ts.map +1 -0
- package/dist-tsc/luma.js +2 -0
- package/dist-tsc/padded-expression-heatmap-bitmap-layer-shaders.d.ts +13 -0
- package/dist-tsc/padded-expression-heatmap-bitmap-layer-shaders.d.ts.map +1 -0
- package/dist-tsc/padded-expression-heatmap-bitmap-layer-shaders.js +143 -0
- package/dist-tsc/selection-utils.d.ts +19 -0
- package/dist-tsc/selection-utils.d.ts.map +1 -0
- package/dist-tsc/selection-utils.js +92 -0
- package/dist-tsc/viv.d.ts +2 -0
- package/dist-tsc/viv.d.ts.map +1 -0
- package/dist-tsc/viv.js +3 -0
- package/package.json +16 -7
- package/src/BitmaskLayer.js +14 -4
- package/src/HeatmapBitmapLayer.js +3 -3
- package/src/HeatmapCompositeTextLayer.js +1 -1
- package/src/PaddedExpressionHeatmapBitmapLayer.js +3 -3
- package/src/PixelatedBitmapLayer.js +1 -1
- package/src/ScaledExpressionExtension/ScaledExpressionExtension.js +2 -2
- package/src/ScaledExpressionExtension/index.js +1 -1
- package/src/ScaledExpressionExtension/shader-module.js +1 -1
- package/src/SelectionExtension/SelectionExtension.js +1 -1
- package/src/SelectionExtension/index.js +1 -1
- package/src/SelectionLayer.js +1 -12
- package/src/bitmask-layer-shaders.js +1 -1
- package/src/heatmap-bitmap-layer-shaders.js +1 -1
- package/src/index.js +16 -13
- package/src/padded-expression-heatmap-bitmap-layer-shaders.js +1 -1
- package/src/selection-utils.js +1 -1
- package/dist/index.mjs +0 -33
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No change to the vertex shader from the base BitmapLayer.
|
|
3
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-vertex.js
|
|
4
|
+
*/
|
|
5
|
+
export const vertexShader: "\n#define SHADER_NAME heatmap-bitmap-layer-vertex-shader\n\nattribute vec2 texCoords;\nattribute vec3 positions;\nattribute vec3 positions64Low;\n\nvarying vec2 vTexCoord;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n";
|
|
6
|
+
/**
|
|
7
|
+
* Fragment shader adapted to perform aggregation and
|
|
8
|
+
* take color scale functions + sliders into account.
|
|
9
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-fragment.js
|
|
10
|
+
* Reference: https://github.com/hms-dbmi/viv/blob/06231ae02cac1ff57ba458c71e9bc59ed2fc4f8b/src/layers/XRLayer/xr-layer-fragment-colormap.webgl1.glsl
|
|
11
|
+
*/
|
|
12
|
+
export const fragmentShader: string;
|
|
13
|
+
//# sourceMappingURL=heatmap-bitmap-layer-shaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmap-bitmap-layer-shaders.d.ts","sourceRoot":"","sources":["../src/heatmap-bitmap-layer-shaders.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,moBAwBE;AAEF;;;;;GAKG;AACH,oCAwEE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { colormaps } from './glsl/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* No change to the vertex shader from the base BitmapLayer.
|
|
4
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-vertex.js
|
|
5
|
+
*/
|
|
6
|
+
export const vertexShader = `
|
|
7
|
+
#define SHADER_NAME heatmap-bitmap-layer-vertex-shader
|
|
8
|
+
|
|
9
|
+
attribute vec2 texCoords;
|
|
10
|
+
attribute vec3 positions;
|
|
11
|
+
attribute vec3 positions64Low;
|
|
12
|
+
|
|
13
|
+
varying vec2 vTexCoord;
|
|
14
|
+
|
|
15
|
+
const vec3 pickingColor = vec3(1.0, 0.0, 0.0);
|
|
16
|
+
|
|
17
|
+
void main(void) {
|
|
18
|
+
geometry.worldPosition = positions;
|
|
19
|
+
geometry.uv = texCoords;
|
|
20
|
+
geometry.pickingColor = pickingColor;
|
|
21
|
+
|
|
22
|
+
gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
|
|
23
|
+
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
24
|
+
|
|
25
|
+
vTexCoord = texCoords;
|
|
26
|
+
|
|
27
|
+
vec4 color = vec4(0.0);
|
|
28
|
+
DECKGL_FILTER_COLOR(color, geometry);
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
/**
|
|
32
|
+
* Fragment shader adapted to perform aggregation and
|
|
33
|
+
* take color scale functions + sliders into account.
|
|
34
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-fragment.js
|
|
35
|
+
* Reference: https://github.com/hms-dbmi/viv/blob/06231ae02cac1ff57ba458c71e9bc59ed2fc4f8b/src/layers/XRLayer/xr-layer-fragment-colormap.webgl1.glsl
|
|
36
|
+
*/
|
|
37
|
+
export const fragmentShader = `
|
|
38
|
+
#define SHADER_NAME heatmap-bitmap-layer-fragment-shader
|
|
39
|
+
|
|
40
|
+
#ifdef GL_ES
|
|
41
|
+
precision mediump float;
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
${colormaps}
|
|
45
|
+
|
|
46
|
+
// The texture (GL.LUMINANCE & Uint8Array).
|
|
47
|
+
uniform sampler2D uBitmapTexture;
|
|
48
|
+
|
|
49
|
+
// What are the dimensions of the texture (width, height)?
|
|
50
|
+
uniform vec2 uTextureSize;
|
|
51
|
+
|
|
52
|
+
// How many consecutive pixels should be aggregated together along each axis?
|
|
53
|
+
uniform vec2 uAggSize;
|
|
54
|
+
|
|
55
|
+
// What are the values of the color scale sliders?
|
|
56
|
+
uniform vec2 uColorScaleRange;
|
|
57
|
+
|
|
58
|
+
// The texture coordinate, varying (interpolated between values set by the vertex shader).
|
|
59
|
+
varying vec2 vTexCoord;
|
|
60
|
+
|
|
61
|
+
void main(void) {
|
|
62
|
+
// Compute 1 pixel in texture coordinates
|
|
63
|
+
vec2 onePixel = vec2(1.0, 1.0) / uTextureSize;
|
|
64
|
+
|
|
65
|
+
vec2 viewCoord = vec2(floor(vTexCoord.x * uTextureSize.x), floor(vTexCoord.y * uTextureSize.y));
|
|
66
|
+
|
|
67
|
+
// Compute (x % aggSizeX, y % aggSizeY).
|
|
68
|
+
// These values will be the number of values to the left / above the current position to consider.
|
|
69
|
+
vec2 modAggSize = vec2(-1.0 * mod(viewCoord.x, uAggSize.x), -1.0 * mod(viewCoord.y, uAggSize.y));
|
|
70
|
+
|
|
71
|
+
// Take the sum of values along each axis.
|
|
72
|
+
float intensitySum = 0.0;
|
|
73
|
+
vec2 offsetPixels = vec2(0.0, 0.0);
|
|
74
|
+
|
|
75
|
+
for(int i = 0; i < 16; i++) {
|
|
76
|
+
// Check to break outer loop early.
|
|
77
|
+
// Uniforms cannot be used as conditions in GLSL for loops.
|
|
78
|
+
if(float(i) >= uAggSize.y) {
|
|
79
|
+
// Done in the y direction.
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
offsetPixels = vec2(offsetPixels.x, (modAggSize.y + float(i)) * onePixel.y);
|
|
84
|
+
|
|
85
|
+
for(int j = 0; j < 16; j++) {
|
|
86
|
+
// Check to break inner loop early.
|
|
87
|
+
// Uniforms cannot be used as conditions in GLSL for loops.
|
|
88
|
+
if(float(j) >= uAggSize.x) {
|
|
89
|
+
// Done in the x direction.
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
offsetPixels = vec2((modAggSize.x + float(j)) * onePixel.x, offsetPixels.y);
|
|
94
|
+
intensitySum += texture2D(uBitmapTexture, vTexCoord + offsetPixels).r;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Compute the mean value.
|
|
99
|
+
float intensityMean = intensitySum / (uAggSize.x * uAggSize.y);
|
|
100
|
+
|
|
101
|
+
// Re-scale using the color scale slider values.
|
|
102
|
+
float scaledIntensityMean = (intensityMean - uColorScaleRange[0]) / max(0.005, (uColorScaleRange[1] - uColorScaleRange[0]));
|
|
103
|
+
|
|
104
|
+
gl_FragColor = COLORMAP_FUNC(clamp(scaledIntensityMean, 0.0, 1.0));
|
|
105
|
+
|
|
106
|
+
geometry.uv = vTexCoord;
|
|
107
|
+
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const TILE_SIZE: 4096;
|
|
2
|
+
export const DATA_TEXTURE_SIZE: 4096;
|
|
3
|
+
export const MIN_ROW_AGG: 1;
|
|
4
|
+
export const MAX_ROW_AGG: 16;
|
|
5
|
+
export const COLOR_BAR_SIZE: 20;
|
|
6
|
+
export const AXIS_LABEL_TEXT_SIZE: 11;
|
|
7
|
+
export const AXIS_TITLE_TEXT_SIZE: 15;
|
|
8
|
+
export const AXIS_MIN_SIZE: 12;
|
|
9
|
+
export const AXIS_MAX_SIZE: 120;
|
|
10
|
+
export const AXIS_MARGIN: 3;
|
|
11
|
+
export const AXIS_PADDING: 10;
|
|
12
|
+
export namespace THEME_TO_TEXT_COLOR {
|
|
13
|
+
const dark: number[];
|
|
14
|
+
const light: number[];
|
|
15
|
+
}
|
|
16
|
+
export const AXIS_FONT_FAMILY: "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
17
|
+
export const PIXELATED_TEXTURE_PARAMETERS: {
|
|
18
|
+
[x: number]: number;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=heatmap-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmap-constants.d.ts","sourceRoot":"","sources":["../src/heatmap-constants.js"],"names":[],"mappings":"AAGA,6BAA8B;AAE9B,qCAAsC;AACtC,4BAA6B;AAC7B,6BAA8B;AAE9B,gCAAiC;AACjC,sCAAuC;AACvC,sCAAuC;AACvC,+BAAgC;AAChC,gCAAiC;AACjC,4BAA6B;AAC7B,8BAA+B;;;;;AAK/B,oFAAqF;AAErF;;EAOE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import GL from '@luma.gl/constants'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
|
+
// Image texture dimensions
|
|
3
|
+
export const TILE_SIZE = 4096;
|
|
4
|
+
// Reshaped data texture dimensions
|
|
5
|
+
export const DATA_TEXTURE_SIZE = 4096;
|
|
6
|
+
export const MIN_ROW_AGG = 1;
|
|
7
|
+
export const MAX_ROW_AGG = 16;
|
|
8
|
+
export const COLOR_BAR_SIZE = 20;
|
|
9
|
+
export const AXIS_LABEL_TEXT_SIZE = 11;
|
|
10
|
+
export const AXIS_TITLE_TEXT_SIZE = 15;
|
|
11
|
+
export const AXIS_MIN_SIZE = 12;
|
|
12
|
+
export const AXIS_MAX_SIZE = 120;
|
|
13
|
+
export const AXIS_MARGIN = 3;
|
|
14
|
+
export const AXIS_PADDING = 10;
|
|
15
|
+
export const THEME_TO_TEXT_COLOR = {
|
|
16
|
+
dark: [224, 224, 224],
|
|
17
|
+
light: [64, 64, 64],
|
|
18
|
+
};
|
|
19
|
+
export const AXIS_FONT_FAMILY = "-apple-system, 'Helvetica Neue', Arial, sans-serif";
|
|
20
|
+
export const PIXELATED_TEXTURE_PARAMETERS = {
|
|
21
|
+
// NEAREST for integer data to prevent interpolation.
|
|
22
|
+
[GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
|
|
23
|
+
[GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
|
|
24
|
+
// CLAMP_TO_EDGE to remove tile artifacts.
|
|
25
|
+
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
26
|
+
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
|
|
27
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { getSelectionLayers } from "./selection-utils.js";
|
|
2
|
+
export { default as HeatmapBitmapLayer } from "./HeatmapBitmapLayer.js";
|
|
3
|
+
export { default as PixelatedBitmapLayer } from "./PixelatedBitmapLayer.js";
|
|
4
|
+
export { default as HeatmapCompositeTextLayer } from "./HeatmapCompositeTextLayer.js";
|
|
5
|
+
export { default as PaddedExpressionHeatmapBitmapLayer } from "./PaddedExpressionHeatmapBitmapLayer.js";
|
|
6
|
+
export { default as ScaledExpressionExtension } from "./ScaledExpressionExtension/index.js";
|
|
7
|
+
export { default as SelectionExtension } from "./SelectionExtension/index.js";
|
|
8
|
+
export { default as BitmaskLayer } from "./BitmaskLayer.js";
|
|
9
|
+
export * as viv from "./viv.js";
|
|
10
|
+
export * as luma from "./luma.js";
|
|
11
|
+
export * as deck from "./deck.js";
|
|
12
|
+
export { GLSL_COLORMAPS, GLSL_COLORMAP_DEFAULT, DEFAULT_GL_OPTIONS, SELECTION_TYPE } from "./constants.js";
|
|
13
|
+
export { TILE_SIZE, MAX_ROW_AGG, MIN_ROW_AGG, COLOR_BAR_SIZE, AXIS_MARGIN, DATA_TEXTURE_SIZE, PIXELATED_TEXTURE_PARAMETERS, AXIS_LABEL_TEXT_SIZE, AXIS_FONT_FAMILY, AXIS_PADDING, AXIS_MIN_SIZE, AXIS_MAX_SIZE } from "./heatmap-constants.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
package/dist-tsc/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// Selection Layers
|
|
2
|
-
export { getSelectionLayers } from './selection-utils';
|
|
2
|
+
export { getSelectionLayers } from './selection-utils.js';
|
|
3
3
|
// Heatmap Layers
|
|
4
|
-
export { default as HeatmapBitmapLayer } from './HeatmapBitmapLayer';
|
|
5
|
-
export { default as PixelatedBitmapLayer } from './PixelatedBitmapLayer';
|
|
6
|
-
export { default as HeatmapCompositeTextLayer } from './HeatmapCompositeTextLayer';
|
|
7
|
-
export { default as PaddedExpressionHeatmapBitmapLayer } from './PaddedExpressionHeatmapBitmapLayer';
|
|
8
|
-
export { GLSL_COLORMAPS, GLSL_COLORMAP_DEFAULT, DEFAULT_GL_OPTIONS, SELECTION_TYPE, } from './constants';
|
|
4
|
+
export { default as HeatmapBitmapLayer } from './HeatmapBitmapLayer.js';
|
|
5
|
+
export { default as PixelatedBitmapLayer } from './PixelatedBitmapLayer.js';
|
|
6
|
+
export { default as HeatmapCompositeTextLayer } from './HeatmapCompositeTextLayer.js';
|
|
7
|
+
export { default as PaddedExpressionHeatmapBitmapLayer } from './PaddedExpressionHeatmapBitmapLayer.js';
|
|
8
|
+
export { GLSL_COLORMAPS, GLSL_COLORMAP_DEFAULT, DEFAULT_GL_OPTIONS, SELECTION_TYPE, } from './constants.js';
|
|
9
9
|
// Layer extensions
|
|
10
|
-
export { default as ScaledExpressionExtension } from './ScaledExpressionExtension';
|
|
11
|
-
export { default as SelectionExtension } from './SelectionExtension';
|
|
12
|
-
export { default as BitmaskLayer } from './BitmaskLayer';
|
|
13
|
-
export { TILE_SIZE, MAX_ROW_AGG, MIN_ROW_AGG, COLOR_BAR_SIZE, AXIS_MARGIN, DATA_TEXTURE_SIZE, PIXELATED_TEXTURE_PARAMETERS, AXIS_LABEL_TEXT_SIZE, AXIS_FONT_FAMILY, AXIS_PADDING, AXIS_MIN_SIZE, AXIS_MAX_SIZE, } from './heatmap-constants';
|
|
14
|
-
|
|
15
|
-
export * as
|
|
16
|
-
|
|
10
|
+
export { default as ScaledExpressionExtension } from './ScaledExpressionExtension/index.js';
|
|
11
|
+
export { default as SelectionExtension } from './SelectionExtension/index.js';
|
|
12
|
+
export { default as BitmaskLayer } from './BitmaskLayer.js';
|
|
13
|
+
export { TILE_SIZE, MAX_ROW_AGG, MIN_ROW_AGG, COLOR_BAR_SIZE, AXIS_MARGIN, DATA_TEXTURE_SIZE, PIXELATED_TEXTURE_PARAMETERS, AXIS_LABEL_TEXT_SIZE, AXIS_FONT_FAMILY, AXIS_PADDING, AXIS_MIN_SIZE, AXIS_MAX_SIZE, } from './heatmap-constants.js';
|
|
14
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
15
|
+
export * as viv from './viv.js';
|
|
16
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
17
|
+
export * as luma from './luma.js';
|
|
18
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
19
|
+
export * as deck from './deck.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"luma.d.ts","sourceRoot":"","sources":["../src/luma.js"],"names":[],"mappings":""}
|
package/dist-tsc/luma.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No change to the vertex shader from the base BitmapLayer.
|
|
3
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-vertex.js
|
|
4
|
+
*/
|
|
5
|
+
export const vertexShader: "\n#define SHADER_NAME heatmap-bitmap-layer-vertex-shader\n\nattribute vec2 texCoords;\nattribute vec3 positions;\nattribute vec3 positions64Low;\n\nvarying vec2 vTexCoord;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n";
|
|
6
|
+
/**
|
|
7
|
+
* Fragment shader adapted to perform aggregation and
|
|
8
|
+
* take color scale functions + sliders into account.
|
|
9
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-fragment.js
|
|
10
|
+
* Reference: https://github.com/hms-dbmi/viv/blob/06231ae02cac1ff57ba458c71e9bc59ed2fc4f8b/src/layers/XRLayer/xr-layer-fragment-colormap.webgl1.glsl
|
|
11
|
+
*/
|
|
12
|
+
export const fragmentShader: string;
|
|
13
|
+
//# sourceMappingURL=padded-expression-heatmap-bitmap-layer-shaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padded-expression-heatmap-bitmap-layer-shaders.d.ts","sourceRoot":"","sources":["../src/padded-expression-heatmap-bitmap-layer-shaders.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,moBAwBE;AAEF;;;;;GAKG;AACH,oCA0GE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { colormaps } from './glsl/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* No change to the vertex shader from the base BitmapLayer.
|
|
4
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-vertex.js
|
|
5
|
+
*/
|
|
6
|
+
export const vertexShader = `
|
|
7
|
+
#define SHADER_NAME heatmap-bitmap-layer-vertex-shader
|
|
8
|
+
|
|
9
|
+
attribute vec2 texCoords;
|
|
10
|
+
attribute vec3 positions;
|
|
11
|
+
attribute vec3 positions64Low;
|
|
12
|
+
|
|
13
|
+
varying vec2 vTexCoord;
|
|
14
|
+
|
|
15
|
+
const vec3 pickingColor = vec3(1.0, 0.0, 0.0);
|
|
16
|
+
|
|
17
|
+
void main(void) {
|
|
18
|
+
geometry.worldPosition = positions;
|
|
19
|
+
geometry.uv = texCoords;
|
|
20
|
+
geometry.pickingColor = pickingColor;
|
|
21
|
+
|
|
22
|
+
gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
|
|
23
|
+
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
24
|
+
|
|
25
|
+
vTexCoord = texCoords;
|
|
26
|
+
|
|
27
|
+
vec4 color = vec4(0.0);
|
|
28
|
+
DECKGL_FILTER_COLOR(color, geometry);
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
/**
|
|
32
|
+
* Fragment shader adapted to perform aggregation and
|
|
33
|
+
* take color scale functions + sliders into account.
|
|
34
|
+
* Reference: https://github.com/visgl/deck.gl/blob/8.2-release/modules/layers/src/bitmap-layer/bitmap-layer-fragment.js
|
|
35
|
+
* Reference: https://github.com/hms-dbmi/viv/blob/06231ae02cac1ff57ba458c71e9bc59ed2fc4f8b/src/layers/XRLayer/xr-layer-fragment-colormap.webgl1.glsl
|
|
36
|
+
*/
|
|
37
|
+
export const fragmentShader = `
|
|
38
|
+
#define SHADER_NAME heatmap-bitmap-layer-fragment-shader
|
|
39
|
+
|
|
40
|
+
#ifdef GL_ES
|
|
41
|
+
precision mediump float;
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
${colormaps}
|
|
45
|
+
|
|
46
|
+
// The texture (GL.LUMINANCE & Uint8Array).
|
|
47
|
+
uniform sampler2D uBitmapTexture;
|
|
48
|
+
|
|
49
|
+
// height x width of the data matrix (i.e x and y are flipped compared to the graphics convention)
|
|
50
|
+
uniform vec2 uOrigDataSize;
|
|
51
|
+
uniform vec2 uReshapedDataSize;
|
|
52
|
+
|
|
53
|
+
uniform vec2 tileIJ;
|
|
54
|
+
uniform vec2 dataIJ;
|
|
55
|
+
uniform vec2 numTiles;
|
|
56
|
+
|
|
57
|
+
// What are the dimensions of the texture (width, height)?
|
|
58
|
+
uniform vec2 uTextureSize;
|
|
59
|
+
|
|
60
|
+
// How many consecutive pixels should be aggregated together along each axis?
|
|
61
|
+
uniform vec2 uAggSize;
|
|
62
|
+
|
|
63
|
+
// What are the values of the color scale sliders?
|
|
64
|
+
uniform vec2 uColorScaleRange;
|
|
65
|
+
|
|
66
|
+
// The texture coordinate, varying (interpolated between values set by the vertex shader).
|
|
67
|
+
varying vec2 vTexCoord;
|
|
68
|
+
|
|
69
|
+
vec2 offsetvTexcoord(vec2 coord) {
|
|
70
|
+
float xTileToDataRatio = uTextureSize.x / uOrigDataSize.y;
|
|
71
|
+
float yTileToDataRatio = uTextureSize.y / uOrigDataSize.x;
|
|
72
|
+
vec2 vTexCoordOffset = vec2(
|
|
73
|
+
(tileIJ.y * xTileToDataRatio) + (coord.x * xTileToDataRatio),
|
|
74
|
+
(tileIJ.x * yTileToDataRatio) + ((1. - coord.y) * yTileToDataRatio)
|
|
75
|
+
);
|
|
76
|
+
return vTexCoordOffset;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
vec2 dataCoordinateFromvTexCoordOffset(vec2 vTexCoordOffset) {
|
|
80
|
+
|
|
81
|
+
// True pixel coordinate on scale of uOrigDataSize
|
|
82
|
+
vec2 viewCoord = vec2(floor(vTexCoordOffset.x * uOrigDataSize.y), floor(vTexCoordOffset.y * uOrigDataSize.x));
|
|
83
|
+
return viewCoord;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
float getIndexFromViewCoord(vec2 viewCoord) {
|
|
87
|
+
return viewCoord.y * uOrigDataSize.y + viewCoord.x;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
vec2 transformDataCoordinate(float index) {
|
|
91
|
+
float textureX = (floor( index / uReshapedDataSize.x )) / uReshapedDataSize.x;
|
|
92
|
+
float textureY = (index - (floor( index / uReshapedDataSize.x ) * uReshapedDataSize.x)) / uReshapedDataSize.y;
|
|
93
|
+
vec2 texturedCoord = vec2(textureY, textureX);
|
|
94
|
+
return texturedCoord;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void main(void) {
|
|
98
|
+
// Compute 1 pixel in texture coordinates
|
|
99
|
+
vec2 onePixel = vec2(1.0, 1.0) / uTextureSize;
|
|
100
|
+
vec2 vTexCoordOffset = offsetvTexcoord(vTexCoord);
|
|
101
|
+
vec2 viewCoordTransformed = dataCoordinateFromvTexCoordOffset(vTexCoordOffset);
|
|
102
|
+
// Compute (x % aggSizeX, y % aggSizeY).
|
|
103
|
+
// These values will be the number of values to the left / above the current position to consider.
|
|
104
|
+
vec2 modAggSize = vec2(-1.0 * mod(viewCoordTransformed.x, uAggSize.x), -1.0 * mod(viewCoordTransformed.y, uAggSize.y));
|
|
105
|
+
// Take the sum of values along each axis.
|
|
106
|
+
float intensitySum = 0.0;
|
|
107
|
+
vec2 offsetPixels = vec2(0.0, 0.0);
|
|
108
|
+
for(int i = 0; i < 16; i++) {
|
|
109
|
+
// Check to break outer loop early.
|
|
110
|
+
// Uniforms cannot be used as conditions in GLSL for loops.
|
|
111
|
+
if(float(i) >= uAggSize.y) {
|
|
112
|
+
// Done in the y direction.
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
offsetPixels = vec2(offsetPixels.x, (modAggSize.y + float(i)));
|
|
117
|
+
|
|
118
|
+
for(int j = 0; j < 16; j++) {
|
|
119
|
+
// Check to break inner loop early.
|
|
120
|
+
// Uniforms cannot be used as conditions in GLSL for loops.
|
|
121
|
+
if(float(j) >= uAggSize.x) {
|
|
122
|
+
// Done in the x direction.
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
offsetPixels = vec2((modAggSize.x + float(j)), offsetPixels.y);
|
|
126
|
+
float indexFull = getIndexFromViewCoord(viewCoordTransformed + offsetPixels);
|
|
127
|
+
float index = indexFull - (floor(indexFull / (uReshapedDataSize.x * uReshapedDataSize.y)) * (uReshapedDataSize.x * uReshapedDataSize.y));
|
|
128
|
+
vec2 vTexCoordTransformed = transformDataCoordinate(index);
|
|
129
|
+
intensitySum += texture2D(uBitmapTexture, vTexCoordTransformed).r;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Compute the mean value.
|
|
134
|
+
float intensityMean = intensitySum / (uAggSize.x * uAggSize.y);
|
|
135
|
+
// Re-scale using the color scale slider values.
|
|
136
|
+
float scaledIntensityMean = (intensityMean - uColorScaleRange[0]) / max(0.005, (uColorScaleRange[1] - uColorScaleRange[0]));
|
|
137
|
+
|
|
138
|
+
gl_FragColor = COLORMAP_FUNC(clamp(scaledIntensityMean, 0.0, 1.0));
|
|
139
|
+
|
|
140
|
+
geometry.uv = vTexCoord;
|
|
141
|
+
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construct DeckGL selection layers.
|
|
3
|
+
* @param {string} tool
|
|
4
|
+
* @param {number} zoom
|
|
5
|
+
* @param {string} cellBaseLayerId
|
|
6
|
+
* @param {function} getCellCoords
|
|
7
|
+
* @param {function} updateCellsSelection
|
|
8
|
+
* @returns {object[]} The array of DeckGL selection layers.
|
|
9
|
+
*/
|
|
10
|
+
export function getSelectionLayers(tool: string, zoom: number, layerId: any, getCellCoords: Function, obsIndex: any, updateCellsSelection: Function, cellsQuadTree: any, flipY?: boolean): object[];
|
|
11
|
+
/**
|
|
12
|
+
* Get deck.gl layer props for selection overlays.
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @returns {object} Object with two properties,
|
|
15
|
+
* overlay: overlayProps, base: baseProps,
|
|
16
|
+
* where the values are deck.gl layer props.
|
|
17
|
+
*/
|
|
18
|
+
export function overlayBaseProps(props: object): object;
|
|
19
|
+
//# sourceMappingURL=selection-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-utils.d.ts","sourceRoot":"","sources":["../src/selection-utils.js"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AACH,yCAPW,MAAM,QACN,MAAM,8HAIJ,MAAM,EAAE,CA4CpB;AAED;;;;;;GAMG;AACH,wCALW,MAAM,GACJ,MAAM,CA8BlB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { COORDINATE_SYSTEM } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
|
+
import { DataFilterExtension } from '@deck.gl/extensions'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
|
+
import SelectionLayer from './SelectionLayer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert a DeckGL layer ID to a "base" layer ID for selection.
|
|
6
|
+
* @param {string} layerId The layer ID to convert.
|
|
7
|
+
* @returns {string} The base layer ID.
|
|
8
|
+
*/
|
|
9
|
+
function getBaseLayerId(layerId) {
|
|
10
|
+
return `base-${layerId}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert a DeckGL layer ID to a "selected" layer ID for selection.
|
|
14
|
+
* @param {string} layerId The layer ID to convert.
|
|
15
|
+
* @returns {string} The base layer ID.
|
|
16
|
+
*/
|
|
17
|
+
function getSelectedLayerId(layerId) {
|
|
18
|
+
return `selected-${layerId}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Construct DeckGL selection layers.
|
|
22
|
+
* @param {string} tool
|
|
23
|
+
* @param {number} zoom
|
|
24
|
+
* @param {string} cellBaseLayerId
|
|
25
|
+
* @param {function} getCellCoords
|
|
26
|
+
* @param {function} updateCellsSelection
|
|
27
|
+
* @returns {object[]} The array of DeckGL selection layers.
|
|
28
|
+
*/
|
|
29
|
+
export function getSelectionLayers(tool, zoom, layerId, getCellCoords, obsIndex, updateCellsSelection, cellsQuadTree, flipY = false) {
|
|
30
|
+
if (!tool) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const cellBaseLayerId = getBaseLayerId(layerId);
|
|
34
|
+
const editHandlePointRadius = 5 / (zoom + 16);
|
|
35
|
+
return [new SelectionLayer({
|
|
36
|
+
id: 'selection',
|
|
37
|
+
flipY,
|
|
38
|
+
cellsQuadTree,
|
|
39
|
+
getCellCoords,
|
|
40
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
41
|
+
selectionType: tool,
|
|
42
|
+
onSelect: ({ pickingInfos }) => {
|
|
43
|
+
const cellIds = pickingInfos.map(i => obsIndex[i]);
|
|
44
|
+
if (updateCellsSelection) {
|
|
45
|
+
updateCellsSelection(cellIds);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
layerIds: [cellBaseLayerId],
|
|
49
|
+
getTentativeFillColor: () => [255, 255, 255, 95],
|
|
50
|
+
getTentativeLineColor: () => [143, 143, 143, 255],
|
|
51
|
+
getTentativeLineDashArray: () => [7, 4],
|
|
52
|
+
lineWidthMinPixels: 2,
|
|
53
|
+
lineWidthMaxPixels: 2,
|
|
54
|
+
getEditHandlePointColor: () => [0xff, 0xff, 0xff, 0xff],
|
|
55
|
+
getEditHandlePointRadius: () => editHandlePointRadius,
|
|
56
|
+
editHandlePointRadiusScale: 1,
|
|
57
|
+
editHandlePointRadiusMinPixels: editHandlePointRadius,
|
|
58
|
+
editHandlePointRadiusMaxPixels: 2 * editHandlePointRadius,
|
|
59
|
+
})];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get deck.gl layer props for selection overlays.
|
|
63
|
+
* @param {object} props
|
|
64
|
+
* @returns {object} Object with two properties,
|
|
65
|
+
* overlay: overlayProps, base: baseProps,
|
|
66
|
+
* where the values are deck.gl layer props.
|
|
67
|
+
*/
|
|
68
|
+
export function overlayBaseProps(props) {
|
|
69
|
+
const { id, getColor, data, isSelected, ...rest } = props;
|
|
70
|
+
return {
|
|
71
|
+
overlay: {
|
|
72
|
+
id: getSelectedLayerId(id),
|
|
73
|
+
getFillColor: getColor,
|
|
74
|
+
getLineColor: getColor,
|
|
75
|
+
data,
|
|
76
|
+
getFilterValue: isSelected,
|
|
77
|
+
extensions: [new DataFilterExtension({ filterSize: 1 })],
|
|
78
|
+
filterRange: [1, 1],
|
|
79
|
+
...rest,
|
|
80
|
+
},
|
|
81
|
+
base: {
|
|
82
|
+
id: getBaseLayerId(id),
|
|
83
|
+
getLineColor: getColor,
|
|
84
|
+
getFillColor: getColor,
|
|
85
|
+
// Alternatively: contrast outlines with solids:
|
|
86
|
+
// getLineColor: getColor,
|
|
87
|
+
// getFillColor: [255, 255, 255],
|
|
88
|
+
data: data.slice(),
|
|
89
|
+
...rest,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { ZarrPixelSource, loadOmeTiff, loadOmeZarr, XRLayer, getChannelStats, RENDERING_MODES, MAX_CHANNELS, getDefaultInitialViewState, ScaleBarLayer, MultiscaleImageLayer, AdditiveColormapExtension, ColorPaletteExtension, ImageLayer, VolumeLayer, AdditiveColormap3DExtensions, ColorPalette3DExtensions, DTYPE_VALUES } from "@hms-dbmi/viv";
|
|
2
|
+
//# sourceMappingURL=viv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viv.d.ts","sourceRoot":"","sources":["../src/viv.js"],"names":[],"mappings":""}
|
package/dist-tsc/viv.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ZarrPixelSource, loadOmeTiff, loadOmeZarr, XRLayer, getChannelStats, RENDERING_MODES, MAX_CHANNELS, getDefaultInitialViewState, ScaleBarLayer, MultiscaleImageLayer, AdditiveColormapExtension, ColorPaletteExtension, ImageLayer, VolumeLayer, AdditiveColormap3DExtensions, ColorPalette3DExtensions,
|
|
2
|
+
// TODO: deprecated
|
|
3
|
+
DTYPE_VALUES, } from '@hms-dbmi/viv';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/gl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
14
|
+
"src",
|
|
13
15
|
"dist",
|
|
14
|
-
"
|
|
16
|
+
"dist-tsc"
|
|
15
17
|
],
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@deck.gl/aggregation-layers": "~8.8.6",
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
"@deck.gl/layers": "~8.8.6",
|
|
22
24
|
"@deck.gl/mesh-layers": "~8.8.6",
|
|
23
25
|
"@deck.gl/react": "~8.8.6",
|
|
24
|
-
"@hms-dbmi/viv": "~0.13.
|
|
26
|
+
"@hms-dbmi/viv": "~0.13.7",
|
|
25
27
|
"@loaders.gl/3d-tiles": "^3.0.0",
|
|
26
28
|
"@loaders.gl/core": "^3.0.0",
|
|
27
29
|
"@loaders.gl/images": "^3.0.0",
|
|
@@ -45,18 +47,25 @@
|
|
|
45
47
|
"@turf/helpers": "^6.5.0",
|
|
46
48
|
"deck.gl": "~8.8.6",
|
|
47
49
|
"glslify": "^7.0.0",
|
|
48
|
-
"lodash": "^4.17.21",
|
|
50
|
+
"lodash-es": "^4.17.21",
|
|
49
51
|
"math.gl": "^3.5.6",
|
|
50
52
|
"mathjs": "^9.2.0",
|
|
51
53
|
"nebula.gl": "0.23.8",
|
|
52
|
-
"@vitessce/utils": "
|
|
54
|
+
"@vitessce/utils": "3.0.1"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"glsl-colormap": "^1.0.1"
|
|
56
58
|
},
|
|
57
59
|
"scripts": {
|
|
58
60
|
"bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
|
|
59
|
-
"test": "pnpm exec vitest --run
|
|
61
|
+
"test": "pnpm exec vitest --run",
|
|
60
62
|
"glslify": "cat src/glsl/colormaps.in.glsl | glslify > src/glsl/colormaps.out.glsl"
|
|
63
|
+
},
|
|
64
|
+
"module": "dist/index.js",
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"types": "./dist-tsc/index.d.ts",
|
|
68
|
+
"import": "./dist/index.js"
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
}
|
package/src/BitmaskLayer.js
CHANGED
|
@@ -2,12 +2,12 @@ import GL from '@luma.gl/constants'; // eslint-disable-line import/no-extraneous
|
|
|
2
2
|
import { project32, picking } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
3
|
import { Texture2D, isWebGL2 } from '@luma.gl/core';
|
|
4
4
|
import { XRLayer } from '@hms-dbmi/viv';
|
|
5
|
-
import { fs, vs } from './bitmask-layer-shaders';
|
|
5
|
+
import { fs, vs } from './bitmask-layer-shaders.js';
|
|
6
6
|
import {
|
|
7
7
|
GLSL_COLORMAPS,
|
|
8
8
|
GLSL_COLORMAP_DEFAULT,
|
|
9
9
|
COLORMAP_SHADER_PLACEHOLDER,
|
|
10
|
-
} from './constants';
|
|
10
|
+
} from './constants.js';
|
|
11
11
|
|
|
12
12
|
function padWithDefault(arr, defaultValue, padWidth) {
|
|
13
13
|
const newArr = [...arr];
|
|
@@ -19,9 +19,15 @@ function padWithDefault(arr, defaultValue, padWidth) {
|
|
|
19
19
|
|
|
20
20
|
const defaultProps = {
|
|
21
21
|
hoveredCell: { type: 'number', value: null, compare: true },
|
|
22
|
-
|
|
22
|
+
// We do not want to deep-compare cellColorData,
|
|
23
|
+
// as it is potentially a TypedArray with millions of elements.
|
|
24
|
+
// For `compare`: "if a number is supplied, indicates the maximum depth to deep-compare,
|
|
25
|
+
// where 0 is shallow comparison and -1 is infinite depth. true is equivalent to 1."
|
|
26
|
+
// Reference: https://deck.gl/docs/developer-guide/custom-layers/prop-types#array
|
|
27
|
+
cellColorData: { type: 'object', value: null, compare: 0 },
|
|
23
28
|
colormap: { type: 'string', value: GLSL_COLORMAP_DEFAULT, compare: true },
|
|
24
|
-
|
|
29
|
+
// Same as with cellColorData, we do not want to deep-compare expressionData.
|
|
30
|
+
expressionData: { type: 'object', value: null, compare: 0 },
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
/**
|
|
@@ -46,9 +52,13 @@ export default class BitmaskLayer extends XRLayer {
|
|
|
46
52
|
|
|
47
53
|
updateState({ props, oldProps, changeFlags }) {
|
|
48
54
|
super.updateState({ props, oldProps, changeFlags });
|
|
55
|
+
// Check the cellColorData to determine whether
|
|
56
|
+
// to update the texture.
|
|
49
57
|
if (props.cellColorData !== oldProps.cellColorData) {
|
|
50
58
|
this.setColorTexture();
|
|
51
59
|
}
|
|
60
|
+
// Check the expressionData to determine whether
|
|
61
|
+
// to update the texture.
|
|
52
62
|
if (props.expressionData !== oldProps.expressionData) {
|
|
53
63
|
const { expressionData, cellTexHeight, cellTexWidth } = this.props;
|
|
54
64
|
const expressionTex = this.dataToTexture(
|