@vitessce/gl 2.0.3-beta.0 → 3.0.0
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-36830437.js +11 -0
- package/dist/index-d34ff949.js +120610 -0
- package/dist/index.js +33 -16
- package/dist/jpeg-a66190dc.js +838 -0
- package/dist/lerc-21af7ec8.js +2004 -0
- package/dist/lzw-76194936.js +126 -0
- package/dist/packbits-bf7850c4.js +28 -0
- package/dist/pako.esm-68f84e2a.js +4022 -0
- package/dist/raw-05d82ade.js +10 -0
- package/dist/webimage-1ceac06a.js +30 -0
- package/dist-tsc/BitmaskLayer.d.ts +74 -0
- package/dist-tsc/BitmaskLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/BitmaskLayer.js +14 -4
- package/dist-tsc/HeatmapBitmapLayer.d.ts +93 -0
- package/dist-tsc/HeatmapBitmapLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/HeatmapBitmapLayer.js +3 -3
- package/dist-tsc/HeatmapCompositeTextLayer.d.ts +11 -0
- package/dist-tsc/HeatmapCompositeTextLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/HeatmapCompositeTextLayer.js +1 -1
- package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts +93 -0
- package/dist-tsc/PaddedExpressionHeatmapBitmapLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/PaddedExpressionHeatmapBitmapLayer.js +3 -3
- package/dist-tsc/PixelatedBitmapLayer.d.ts +10 -0
- package/dist-tsc/PixelatedBitmapLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/PixelatedBitmapLayer.js +1 -1
- package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts +62 -0
- package/dist-tsc/ScaledExpressionExtension/ScaledExpressionExtension.d.ts.map +1 -0
- package/{dist → dist-tsc}/ScaledExpressionExtension/ScaledExpressionExtension.js +2 -2
- package/dist-tsc/ScaledExpressionExtension/index.d.ts +3 -0
- package/dist-tsc/ScaledExpressionExtension/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/ScaledExpressionExtension/index.js +1 -1
- package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts +17 -0
- package/dist-tsc/ScaledExpressionExtension/shader-module.d.ts.map +1 -0
- package/{dist → dist-tsc}/ScaledExpressionExtension/shader-module.js +1 -1
- package/dist-tsc/SelectionExtension/SelectionExtension.d.ts +18 -0
- package/dist-tsc/SelectionExtension/SelectionExtension.d.ts.map +1 -0
- package/{dist → dist-tsc}/SelectionExtension/SelectionExtension.js +1 -1
- 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/SelectionLayer.d.ts +15 -0
- package/dist-tsc/SelectionLayer.d.ts.map +1 -0
- package/{dist → dist-tsc}/SelectionLayer.js +1 -11
- package/dist-tsc/bitmask-layer-shaders.d.ts +3 -0
- package/dist-tsc/bitmask-layer-shaders.d.ts.map +1 -0
- package/{dist → dist-tsc}/bitmask-layer-shaders.js +1 -1
- package/dist-tsc/constants.d.ts +8 -0
- package/dist-tsc/constants.d.ts.map +1 -0
- package/dist-tsc/deck.d.ts +2 -0
- package/dist-tsc/deck.d.ts.map +1 -0
- package/dist-tsc/glsl/index.d.ts +2 -0
- package/dist-tsc/glsl/index.d.ts.map +1 -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 → dist-tsc}/heatmap-bitmap-layer-shaders.js +1 -1
- package/dist-tsc/heatmap-constants.d.ts +20 -0
- package/dist-tsc/heatmap-constants.d.ts.map +1 -0
- package/dist-tsc/index.d.ts +14 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +19 -0
- package/dist-tsc/luma.d.ts +2 -0
- package/dist-tsc/luma.d.ts.map +1 -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 → dist-tsc}/padded-expression-heatmap-bitmap-layer-shaders.js +1 -1
- package/dist-tsc/selection-utils.d.ts +19 -0
- package/dist-tsc/selection-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/selection-utils.js +1 -1
- package/dist-tsc/viv.d.ts +2 -0
- package/dist-tsc/viv.d.ts.map +1 -0
- package/package.json +16 -7
- package/src/BitmaskLayer.js +175 -0
- package/src/HeatmapBitmapLayer.js +144 -0
- package/src/HeatmapCompositeTextLayer.js +156 -0
- package/src/PaddedExpressionHeatmapBitmapLayer.js +154 -0
- package/src/PixelatedBitmapLayer.js +30 -0
- package/src/ScaledExpressionExtension/ScaledExpressionExtension.js +117 -0
- package/src/ScaledExpressionExtension/index.js +3 -0
- package/src/ScaledExpressionExtension/shader-module.js +35 -0
- package/src/SelectionExtension/SelectionExtension.js +34 -0
- package/src/SelectionExtension/index.js +3 -0
- package/src/SelectionExtension/shader-module.js +22 -0
- package/src/SelectionLayer.js +187 -0
- package/src/bitmask-layer-shaders.js +92 -0
- package/src/constants.js +13 -0
- package/src/deck.js +4 -0
- package/src/glsl/README.md +8 -0
- package/src/glsl/colormaps.in.glsl +15 -0
- package/src/glsl/index.js +341 -0
- package/src/heatmap-bitmap-layer-shaders.js +111 -0
- package/src/heatmap-constants.js +30 -0
- package/src/index.js +36 -0
- package/src/luma.js +2 -0
- package/src/padded-expression-heatmap-bitmap-layer-shaders.js +145 -0
- package/src/selection-utils.js +109 -0
- package/src/viv.js +20 -0
- package/dist/SelectionExtension/index.js +0 -2
- package/dist/layer-controller.js +0 -109
- package/dist/spatial.js +0 -281
- package/dist/spatial.test.js +0 -8
- /package/{dist → dist-tsc}/SelectionExtension/shader-module.js +0 -0
- /package/{dist → dist-tsc}/constants.js +0 -0
- /package/{dist → dist-tsc}/deck.js +0 -0
- /package/{dist → dist-tsc}/glsl/index.js +0 -0
- /package/{dist → dist-tsc}/heatmap-constants.js +0 -0
- /package/{dist → dist-tsc}/luma.js +0 -0
- /package/{dist → dist-tsc}/viv.js +0 -0
|
@@ -11,17 +11,9 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
|
|
|
11
11
|
import { ScatterplotLayer } from '@deck.gl/layers';
|
|
12
12
|
import { SELECTION_TYPE } from 'nebula.gl';
|
|
13
13
|
import { EditableGeoJsonLayer } from '@nebula.gl/layers';
|
|
14
|
-
import {
|
|
14
|
+
import { DrawPolygonByDraggingMode, ViewMode } from '@nebula.gl/edit-modes';
|
|
15
15
|
const EDIT_TYPE_ADD = 'addFeature';
|
|
16
16
|
const EDIT_TYPE_CLEAR = 'clearFeatures';
|
|
17
|
-
// Customize the click handlers for the rectangle and polygon tools,
|
|
18
|
-
// so that clicking triggers the `onEdit` callback.
|
|
19
|
-
class ClickableDrawRectangleMode extends DrawRectangleMode {
|
|
20
|
-
// eslint-disable-next-line class-methods-use-this
|
|
21
|
-
handleClick(event, props) {
|
|
22
|
-
props.onEdit({ editType: EDIT_TYPE_CLEAR });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
17
|
class ClickableDrawPolygonByDraggingMode extends DrawPolygonByDraggingMode {
|
|
26
18
|
// eslint-disable-next-line class-methods-use-this
|
|
27
19
|
handleClick(event, props) {
|
|
@@ -29,11 +21,9 @@ class ClickableDrawPolygonByDraggingMode extends DrawPolygonByDraggingMode {
|
|
|
29
21
|
}
|
|
30
22
|
}
|
|
31
23
|
const MODE_MAP = {
|
|
32
|
-
[SELECTION_TYPE.RECTANGLE]: ClickableDrawRectangleMode,
|
|
33
24
|
[SELECTION_TYPE.POLYGON]: ClickableDrawPolygonByDraggingMode,
|
|
34
25
|
};
|
|
35
26
|
const defaultProps = {
|
|
36
|
-
selectionType: SELECTION_TYPE.RECTANGLE,
|
|
37
27
|
layerIds: [],
|
|
38
28
|
onSelect: () => { },
|
|
39
29
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const vs: "\n#define SHADER_NAME bitmask-layer-vertex-shader\n\nattribute vec2 texCoords;\nattribute vec3 positions;\nattribute vec3 positions64Low;\nattribute vec3 instancePickingColors;\n\nvarying vec2 vTexCoord;\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = instancePickingColors;\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n vTexCoord = texCoords;\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n";
|
|
2
|
+
export const fs: string;
|
|
3
|
+
//# sourceMappingURL=bitmask-layer-shaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitmask-layer-shaders.d.ts","sourceRoot":"","sources":["../src/bitmask-layer-shaders.js"],"names":[],"mappings":"AAEA,0mBAoBE;AAEF,wBAmEE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const GLSL_COLORMAPS: string[];
|
|
2
|
+
export const GLSL_COLORMAP_DEFAULT: "plasma";
|
|
3
|
+
export const COLORMAP_SHADER_PLACEHOLDER: "COLORMAP_FUNC";
|
|
4
|
+
export namespace DEFAULT_GL_OPTIONS {
|
|
5
|
+
const webgl2: boolean;
|
|
6
|
+
}
|
|
7
|
+
export { SELECTION_TYPE } from "nebula.gl";
|
|
8
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.js"],"names":[],"mappings":"AAEA,sCAIE;AACF,6CAA8C;AAC9C,0DAA2D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deck.d.ts","sourceRoot":"","sources":["../src/deck.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const colormaps: "#define GLSLIFY 1\nvec4 plasma (float x_4) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0.050980392156862744,0.03137254901960784,0.5294117647058824,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.29411764705882354,0.011764705882352941,0.6313725490196078,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.49019607843137253,0.011764705882352941,0.6588235294117647,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.6588235294117647,0.13333333333333333,0.5882352941176471,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0.796078431372549,0.27450980392156865,0.4745098039215686,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0.8980392156862745,0.4196078431372549,0.36470588235294116,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0.9725490196078431,0.5803921568627451,0.2549019607843137,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.9921568627450981,0.7647058823529411,0.1568627450980392,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.9411764705882353,0.9764705882352941,0.12941176470588237,1);\n float a0 = smoothstep(e0,e1,x_4);\n float a1 = smoothstep(e1,e2,x_4);\n float a2 = smoothstep(e2,e3,x_4);\n float a3 = smoothstep(e3,e4,x_4);\n float a4 = smoothstep(e4,e5,x_4);\n float a5 = smoothstep(e5,e6,x_4);\n float a6 = smoothstep(e6,e7,x_4);\n float a7 = smoothstep(e7,e8,x_4);\n return max(mix(v0,v1,a0)*step(e0,x_4)*step(x_4,e1),\n max(mix(v1,v2,a1)*step(e1,x_4)*step(x_4,e2),\n max(mix(v2,v3,a2)*step(e2,x_4)*step(x_4,e3),\n max(mix(v3,v4,a3)*step(e3,x_4)*step(x_4,e4),\n max(mix(v4,v5,a4)*step(e4,x_4)*step(x_4,e5),\n max(mix(v5,v6,a5)*step(e5,x_4)*step(x_4,e6),\n max(mix(v6,v7,a6)*step(e6,x_4)*step(x_4,e7),mix(v7,v8,a7)*step(e7,x_4)*step(x_4,e8)\n )))))));\n}\n\nvec4 viridis (float x_1) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0.26666666666666666,0.00392156862745098,0.32941176470588235,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.2784313725490196,0.17254901960784313,0.47843137254901963,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.23137254901960785,0.3176470588235294,0.5450980392156862,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.17254901960784313,0.44313725490196076,0.5568627450980392,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0.12941176470588237,0.5647058823529412,0.5529411764705883,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0.15294117647058825,0.6784313725490196,0.5058823529411764,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0.3607843137254902,0.7843137254901961,0.38823529411764707,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.6666666666666666,0.8627450980392157,0.19607843137254902,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.9921568627450981,0.9058823529411765,0.1450980392156863,1);\n float a0 = smoothstep(e0,e1,x_1);\n float a1 = smoothstep(e1,e2,x_1);\n float a2 = smoothstep(e2,e3,x_1);\n float a3 = smoothstep(e3,e4,x_1);\n float a4 = smoothstep(e4,e5,x_1);\n float a5 = smoothstep(e5,e6,x_1);\n float a6 = smoothstep(e6,e7,x_1);\n float a7 = smoothstep(e7,e8,x_1);\n return max(mix(v0,v1,a0)*step(e0,x_1)*step(x_1,e1),\n max(mix(v1,v2,a1)*step(e1,x_1)*step(x_1,e2),\n max(mix(v2,v3,a2)*step(e2,x_1)*step(x_1,e3),\n max(mix(v3,v4,a3)*step(e3,x_1)*step(x_1,e4),\n max(mix(v4,v5,a4)*step(e4,x_1)*step(x_1,e5),\n max(mix(v5,v6,a5)*step(e5,x_1)*step(x_1,e6),\n max(mix(v6,v7,a6)*step(e6,x_1)*step(x_1,e7),mix(v7,v8,a7)*step(e7,x_1)*step(x_1,e8)\n )))))));\n}\n\nvec4 greys (float x_10) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0,1);\n const float e1 = 1.0;\n const vec4 v1 = vec4(1,1,1,1);\n float a0 = smoothstep(e0,e1,x_10);\n return mix(v0,v1,a0)*step(e0,x_10)*step(x_10,e1);\n}\n\nvec4 magma (float x_7) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0.01568627450980392,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.10980392156862745,0.06274509803921569,0.26666666666666666,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.30980392156862746,0.07058823529411765,0.4823529411764706,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.5058823529411764,0.1450980392156863,0.5058823529411764,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0.7098039215686275,0.21176470588235294,0.47843137254901963,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0.8980392156862745,0.3137254901960784,0.39215686274509803,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0.984313725490196,0.5294117647058824,0.3803921568627451,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.996078431372549,0.7607843137254902,0.5294117647058824,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.9882352941176471,0.9921568627450981,0.7490196078431373,1);\n float a0 = smoothstep(e0,e1,x_7);\n float a1 = smoothstep(e1,e2,x_7);\n float a2 = smoothstep(e2,e3,x_7);\n float a3 = smoothstep(e3,e4,x_7);\n float a4 = smoothstep(e4,e5,x_7);\n float a5 = smoothstep(e5,e6,x_7);\n float a6 = smoothstep(e6,e7,x_7);\n float a7 = smoothstep(e7,e8,x_7);\n return max(mix(v0,v1,a0)*step(e0,x_7)*step(x_7,e1),\n max(mix(v1,v2,a1)*step(e1,x_7)*step(x_7,e2),\n max(mix(v2,v3,a2)*step(e2,x_7)*step(x_7,e3),\n max(mix(v3,v4,a3)*step(e3,x_7)*step(x_7,e4),\n max(mix(v4,v5,a4)*step(e4,x_7)*step(x_7,e5),\n max(mix(v5,v6,a5)*step(e5,x_7)*step(x_7,e6),\n max(mix(v6,v7,a6)*step(e6,x_7)*step(x_7,e7),mix(v7,v8,a7)*step(e7,x_7)*step(x_7,e8)\n )))))));\n}\n\nvec4 jet (float x_8) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0.5137254901960784,1);\n const float e1 = 0.125;\n const vec4 v1 = vec4(0,0.23529411764705882,0.6666666666666666,1);\n const float e2 = 0.375;\n const vec4 v2 = vec4(0.0196078431372549,1,1,1);\n const float e3 = 0.625;\n const vec4 v3 = vec4(1,1,0,1);\n const float e4 = 0.875;\n const vec4 v4 = vec4(0.9803921568627451,0,0,1);\n const float e5 = 1.0;\n const vec4 v5 = vec4(0.5019607843137255,0,0,1);\n float a0 = smoothstep(e0,e1,x_8);\n float a1 = smoothstep(e1,e2,x_8);\n float a2 = smoothstep(e2,e3,x_8);\n float a3 = smoothstep(e3,e4,x_8);\n float a4 = smoothstep(e4,e5,x_8);\n return max(mix(v0,v1,a0)*step(e0,x_8)*step(x_8,e1),\n max(mix(v1,v2,a1)*step(e1,x_8)*step(x_8,e2),\n max(mix(v2,v3,a2)*step(e2,x_8)*step(x_8,e3),\n max(mix(v3,v4,a3)*step(e3,x_8)*step(x_8,e4),mix(v4,v5,a4)*step(e4,x_8)*step(x_8,e5)\n ))));\n}\n\nvec4 bone (float x_11) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0,1);\n const float e1 = 0.376;\n const vec4 v1 = vec4(0.32941176470588235,0.32941176470588235,0.4549019607843137,1);\n const float e2 = 0.753;\n const vec4 v2 = vec4(0.6627450980392157,0.7843137254901961,0.7843137254901961,1);\n const float e3 = 1.0;\n const vec4 v3 = vec4(1,1,1,1);\n float a0 = smoothstep(e0,e1,x_11);\n float a1 = smoothstep(e1,e2,x_11);\n float a2 = smoothstep(e2,e3,x_11);\n return max(mix(v0,v1,a0)*step(e0,x_11)*step(x_11,e1),\n max(mix(v1,v2,a1)*step(e1,x_11)*step(x_11,e2),mix(v2,v3,a2)*step(e2,x_11)*step(x_11,e3)\n ));\n}\n\nvec4 copper (float x_6) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0,1);\n const float e1 = 0.804;\n const vec4 v1 = vec4(1,0.6274509803921569,0.4,1);\n const float e2 = 1.0;\n const vec4 v2 = vec4(1,0.7803921568627451,0.4980392156862745,1);\n float a0 = smoothstep(e0,e1,x_6);\n float a1 = smoothstep(e1,e2,x_6);\n return max(mix(v0,v1,a0)*step(e0,x_6)*step(x_6,e1),mix(v1,v2,a1)*step(e1,x_6)*step(x_6,e2)\n );\n}\n\nvec4 density (float x_5) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0.21176470588235294,0.054901960784313725,0.1411764705882353,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.34901960784313724,0.09019607843137255,0.3137254901960784,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.43137254901960786,0.17647058823529413,0.5176470588235295,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.47058823529411764,0.30196078431372547,0.6980392156862745,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0.47058823529411764,0.44313725490196076,0.8352941176470589,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0.45098039215686275,0.592156862745098,0.8941176470588236,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0.5254901960784314,0.7254901960784313,0.8901960784313725,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.6941176470588235,0.8392156862745098,0.8901960784313725,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.9019607843137255,0.9450980392156862,0.9450980392156862,1);\n float a0 = smoothstep(e0,e1,x_5);\n float a1 = smoothstep(e1,e2,x_5);\n float a2 = smoothstep(e2,e3,x_5);\n float a3 = smoothstep(e3,e4,x_5);\n float a4 = smoothstep(e4,e5,x_5);\n float a5 = smoothstep(e5,e6,x_5);\n float a6 = smoothstep(e6,e7,x_5);\n float a7 = smoothstep(e7,e8,x_5);\n return max(mix(v0,v1,a0)*step(e0,x_5)*step(x_5,e1),\n max(mix(v1,v2,a1)*step(e1,x_5)*step(x_5,e2),\n max(mix(v2,v3,a2)*step(e2,x_5)*step(x_5,e3),\n max(mix(v3,v4,a3)*step(e3,x_5)*step(x_5,e4),\n max(mix(v4,v5,a4)*step(e4,x_5)*step(x_5,e5),\n max(mix(v5,v6,a5)*step(e5,x_5)*step(x_5,e6),\n max(mix(v6,v7,a6)*step(e6,x_5)*step(x_5,e7),mix(v7,v8,a7)*step(e7,x_5)*step(x_5,e8)\n )))))));\n}\n\nvec4 inferno (float x_3) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0.01568627450980392,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.12156862745098039,0.047058823529411764,0.2823529411764706,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.3333333333333333,0.058823529411764705,0.42745098039215684,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.5333333333333333,0.13333333333333333,0.41568627450980394,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0.7294117647058823,0.21176470588235294,0.3333333333333333,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0.8901960784313725,0.34901960784313724,0.2,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0.9764705882352941,0.5490196078431373,0.0392156862745098,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.9764705882352941,0.788235294117647,0.19607843137254902,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.9882352941176471,1,0.6431372549019608,1);\n float a0 = smoothstep(e0,e1,x_3);\n float a1 = smoothstep(e1,e2,x_3);\n float a2 = smoothstep(e2,e3,x_3);\n float a3 = smoothstep(e3,e4,x_3);\n float a4 = smoothstep(e4,e5,x_3);\n float a5 = smoothstep(e5,e6,x_3);\n float a6 = smoothstep(e6,e7,x_3);\n float a7 = smoothstep(e7,e8,x_3);\n return max(mix(v0,v1,a0)*step(e0,x_3)*step(x_3,e1),\n max(mix(v1,v2,a1)*step(e1,x_3)*step(x_3,e2),\n max(mix(v2,v3,a2)*step(e2,x_3)*step(x_3,e3),\n max(mix(v3,v4,a3)*step(e3,x_3)*step(x_3,e4),\n max(mix(v4,v5,a4)*step(e4,x_3)*step(x_3,e5),\n max(mix(v5,v6,a5)*step(e5,x_3)*step(x_3,e6),\n max(mix(v6,v7,a6)*step(e6,x_3)*step(x_3,e7),mix(v7,v8,a7)*step(e7,x_3)*step(x_3,e8)\n )))))));\n}\n\nvec4 cool (float x_2) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0.49019607843137253,0,0.7019607843137254,1);\n const float e1 = 0.13;\n const vec4 v1 = vec4(0.4549019607843137,0,0.8549019607843137,1);\n const float e2 = 0.25;\n const vec4 v2 = vec4(0.3843137254901961,0.2901960784313726,0.9294117647058824,1);\n const float e3 = 0.38;\n const vec4 v3 = vec4(0.26666666666666666,0.5725490196078431,0.9058823529411765,1);\n const float e4 = 0.5;\n const vec4 v4 = vec4(0,0.8,0.7725490196078432,1);\n const float e5 = 0.63;\n const vec4 v5 = vec4(0,0.9686274509803922,0.5725490196078431,1);\n const float e6 = 0.75;\n const vec4 v6 = vec4(0,1,0.34509803921568627,1);\n const float e7 = 0.88;\n const vec4 v7 = vec4(0.1568627450980392,1,0.03137254901960784,1);\n const float e8 = 1.0;\n const vec4 v8 = vec4(0.5764705882352941,1,0,1);\n float a0 = smoothstep(e0,e1,x_2);\n float a1 = smoothstep(e1,e2,x_2);\n float a2 = smoothstep(e2,e3,x_2);\n float a3 = smoothstep(e3,e4,x_2);\n float a4 = smoothstep(e4,e5,x_2);\n float a5 = smoothstep(e5,e6,x_2);\n float a6 = smoothstep(e6,e7,x_2);\n float a7 = smoothstep(e7,e8,x_2);\n return max(mix(v0,v1,a0)*step(e0,x_2)*step(x_2,e1),\n max(mix(v1,v2,a1)*step(e1,x_2)*step(x_2,e2),\n max(mix(v2,v3,a2)*step(e2,x_2)*step(x_2,e3),\n max(mix(v3,v4,a3)*step(e3,x_2)*step(x_2,e4),\n max(mix(v4,v5,a4)*step(e4,x_2)*step(x_2,e5),\n max(mix(v5,v6,a5)*step(e5,x_2)*step(x_2,e6),\n max(mix(v6,v7,a6)*step(e6,x_2)*step(x_2,e7),mix(v7,v8,a7)*step(e7,x_2)*step(x_2,e8)\n )))))));\n}\n\nvec4 hot (float x_0) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,0,1);\n const float e1 = 0.3;\n const vec4 v1 = vec4(0.9019607843137255,0,0,1);\n const float e2 = 0.6;\n const vec4 v2 = vec4(1,0.8235294117647058,0,1);\n const float e3 = 1.0;\n const vec4 v3 = vec4(1,1,1,1);\n float a0 = smoothstep(e0,e1,x_0);\n float a1 = smoothstep(e1,e2,x_0);\n float a2 = smoothstep(e2,e3,x_0);\n return max(mix(v0,v1,a0)*step(e0,x_0)*step(x_0,e1),\n max(mix(v1,v2,a1)*step(e1,x_0)*step(x_0,e2),mix(v2,v3,a2)*step(e2,x_0)*step(x_0,e3)\n ));\n}\n\nvec4 spring (float x_14) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(1,0,1,1);\n const float e1 = 1.0;\n const vec4 v1 = vec4(1,1,0,1);\n float a0 = smoothstep(e0,e1,x_14);\n return mix(v0,v1,a0)*step(e0,x_14)*step(x_14,e1);\n}\n\nvec4 summer (float x_9) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0.5019607843137255,0.4,1);\n const float e1 = 1.0;\n const vec4 v1 = vec4(1,1,0.4,1);\n float a0 = smoothstep(e0,e1,x_9);\n return mix(v0,v1,a0)*step(e0,x_9)*step(x_9,e1);\n}\n\nvec4 autumn (float x_13) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(1,0,0,1);\n const float e1 = 1.0;\n const vec4 v1 = vec4(1,1,0,1);\n float a0 = smoothstep(e0,e1,x_13);\n return mix(v0,v1,a0)*step(e0,x_13)*step(x_13,e1);\n}\n\nvec4 winter (float x_12) {\n const float e0 = 0.0;\n const vec4 v0 = vec4(0,0,1,1);\n const float e1 = 1.0;\n const vec4 v1 = vec4(0,1,0.5019607843137255,1);\n float a0 = smoothstep(e0,e1,x_12);\n return mix(v0,v1,a0)*step(e0,x_12)*step(x_12,e1);\n}\n";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/glsl/index.js"],"names":[],"mappings":"AACA,itbAmVE"}
|
|
@@ -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,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,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":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Selection Layers
|
|
2
|
+
export { getSelectionLayers } from './selection-utils.js';
|
|
3
|
+
// Heatmap Layers
|
|
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
|
+
// Layer extensions
|
|
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":""}
|
|
@@ -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,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COORDINATE_SYSTEM } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
2
|
import { DataFilterExtension } from '@deck.gl/extensions'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
|
-
import SelectionLayer from './SelectionLayer';
|
|
3
|
+
import SelectionLayer from './SelectionLayer.js';
|
|
4
4
|
/**
|
|
5
5
|
* Convert a DeckGL layer ID to a "base" layer ID for selection.
|
|
6
6
|
* @param {string} layerId The layer ID to convert.
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/gl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
11
12
|
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
13
|
-
"
|
|
14
|
+
"src",
|
|
15
|
+
"dist",
|
|
16
|
+
"dist-tsc"
|
|
14
17
|
],
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@deck.gl/aggregation-layers": "~8.8.6",
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"@deck.gl/layers": "~8.8.6",
|
|
21
24
|
"@deck.gl/mesh-layers": "~8.8.6",
|
|
22
25
|
"@deck.gl/react": "~8.8.6",
|
|
23
|
-
"@hms-dbmi/viv": "~0.13.
|
|
26
|
+
"@hms-dbmi/viv": "~0.13.7",
|
|
24
27
|
"@loaders.gl/3d-tiles": "^3.0.0",
|
|
25
28
|
"@loaders.gl/core": "^3.0.0",
|
|
26
29
|
"@loaders.gl/images": "^3.0.0",
|
|
@@ -44,19 +47,25 @@
|
|
|
44
47
|
"@turf/helpers": "^6.5.0",
|
|
45
48
|
"deck.gl": "~8.8.6",
|
|
46
49
|
"glslify": "^7.0.0",
|
|
47
|
-
"lodash": "^4.17.21",
|
|
50
|
+
"lodash-es": "^4.17.21",
|
|
48
51
|
"math.gl": "^3.5.6",
|
|
49
52
|
"mathjs": "^9.2.0",
|
|
50
53
|
"nebula.gl": "0.23.8",
|
|
51
|
-
"@vitessce/utils": "
|
|
54
|
+
"@vitessce/utils": "3.0.0"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"glsl-colormap": "^1.0.1"
|
|
55
58
|
},
|
|
56
59
|
"scripts": {
|
|
57
|
-
"
|
|
58
|
-
"build": "tsc",
|
|
60
|
+
"bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
|
|
59
61
|
"test": "pnpm exec vitest --run -r ../../ --dir .",
|
|
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
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import GL from '@luma.gl/constants'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
|
+
import { project32, picking } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
|
+
import { Texture2D, isWebGL2 } from '@luma.gl/core';
|
|
4
|
+
import { XRLayer } from '@hms-dbmi/viv';
|
|
5
|
+
import { fs, vs } from './bitmask-layer-shaders.js';
|
|
6
|
+
import {
|
|
7
|
+
GLSL_COLORMAPS,
|
|
8
|
+
GLSL_COLORMAP_DEFAULT,
|
|
9
|
+
COLORMAP_SHADER_PLACEHOLDER,
|
|
10
|
+
} from './constants.js';
|
|
11
|
+
|
|
12
|
+
function padWithDefault(arr, defaultValue, padWidth) {
|
|
13
|
+
const newArr = [...arr];
|
|
14
|
+
for (let i = 0; i < padWidth; i += 1) {
|
|
15
|
+
newArr.push(defaultValue);
|
|
16
|
+
}
|
|
17
|
+
return newArr;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultProps = {
|
|
21
|
+
hoveredCell: { type: 'number', value: null, compare: true },
|
|
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 },
|
|
28
|
+
colormap: { type: 'string', value: GLSL_COLORMAP_DEFAULT, compare: true },
|
|
29
|
+
// Same as with cellColorData, we do not want to deep-compare expressionData.
|
|
30
|
+
expressionData: { type: 'object', value: null, compare: 0 },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A BitmapLayer that performs aggregation in the fragment shader,
|
|
35
|
+
* and renders its texture from a Uint8Array rather than an ImageData.
|
|
36
|
+
*/
|
|
37
|
+
export default class BitmaskLayer extends XRLayer {
|
|
38
|
+
// eslint-disable-next-line class-methods-use-this
|
|
39
|
+
getShaders() {
|
|
40
|
+
const { colormap } = this.props;
|
|
41
|
+
return {
|
|
42
|
+
fs,
|
|
43
|
+
vs,
|
|
44
|
+
modules: [project32, picking],
|
|
45
|
+
defines: {
|
|
46
|
+
[COLORMAP_SHADER_PLACEHOLDER]: GLSL_COLORMAPS.includes(colormap)
|
|
47
|
+
? colormap
|
|
48
|
+
: GLSL_COLORMAP_DEFAULT,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
updateState({ props, oldProps, changeFlags }) {
|
|
54
|
+
super.updateState({ props, oldProps, changeFlags });
|
|
55
|
+
// Check the cellColorData to determine whether
|
|
56
|
+
// to update the texture.
|
|
57
|
+
if (props.cellColorData !== oldProps.cellColorData) {
|
|
58
|
+
this.setColorTexture();
|
|
59
|
+
}
|
|
60
|
+
// Check the expressionData to determine whether
|
|
61
|
+
// to update the texture.
|
|
62
|
+
if (props.expressionData !== oldProps.expressionData) {
|
|
63
|
+
const { expressionData, cellTexHeight, cellTexWidth } = this.props;
|
|
64
|
+
const expressionTex = this.dataToTexture(
|
|
65
|
+
expressionData,
|
|
66
|
+
cellTexWidth,
|
|
67
|
+
cellTexHeight,
|
|
68
|
+
);
|
|
69
|
+
this.setState({ expressionTex });
|
|
70
|
+
}
|
|
71
|
+
if (props.colormap !== oldProps.colormap) {
|
|
72
|
+
const { gl } = this.context;
|
|
73
|
+
if (this.state.model) {
|
|
74
|
+
this.state.model.delete();
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
77
|
+
this.setState({ model: this._getModel(gl) });
|
|
78
|
+
|
|
79
|
+
this.getAttributeManager().invalidateAll();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setColorTexture() {
|
|
84
|
+
const {
|
|
85
|
+
cellColorData: data,
|
|
86
|
+
cellTexHeight: height,
|
|
87
|
+
cellTexWidth: width,
|
|
88
|
+
} = this.props;
|
|
89
|
+
const colorTex = new Texture2D(this.context.gl, {
|
|
90
|
+
width,
|
|
91
|
+
height,
|
|
92
|
+
// Only use Float32 so we don't have to write two shaders
|
|
93
|
+
data,
|
|
94
|
+
// we don't want or need mimaps
|
|
95
|
+
mipmaps: false,
|
|
96
|
+
parameters: {
|
|
97
|
+
// NEAREST for integer data
|
|
98
|
+
[GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
|
|
99
|
+
[GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
|
|
100
|
+
// CLAMP_TO_EDGE to remove tile artifacts
|
|
101
|
+
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
102
|
+
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
|
|
103
|
+
},
|
|
104
|
+
format: GL.RGB,
|
|
105
|
+
dataFormat: GL.RGB,
|
|
106
|
+
type: GL.UNSIGNED_BYTE,
|
|
107
|
+
});
|
|
108
|
+
this.setState({ colorTex });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
draw(opts) {
|
|
112
|
+
const { uniforms } = opts;
|
|
113
|
+
const {
|
|
114
|
+
channelsVisible,
|
|
115
|
+
hoveredCell,
|
|
116
|
+
colorScaleLo,
|
|
117
|
+
colorScaleHi,
|
|
118
|
+
isExpressionMode,
|
|
119
|
+
} = this.props;
|
|
120
|
+
const {
|
|
121
|
+
textures, model, colorTex, expressionTex,
|
|
122
|
+
} = this.state;
|
|
123
|
+
// Render the image
|
|
124
|
+
if (textures && model && colorTex) {
|
|
125
|
+
model
|
|
126
|
+
.setUniforms(
|
|
127
|
+
Object.assign({}, uniforms, {
|
|
128
|
+
hovered: hoveredCell || 0,
|
|
129
|
+
colorTex,
|
|
130
|
+
expressionTex,
|
|
131
|
+
colorTexHeight: colorTex.height,
|
|
132
|
+
colorTexWidth: colorTex.width,
|
|
133
|
+
channelsVisible: padWithDefault(
|
|
134
|
+
channelsVisible,
|
|
135
|
+
false,
|
|
136
|
+
// There are six texture entries on the shaders
|
|
137
|
+
6 - channelsVisible.length,
|
|
138
|
+
),
|
|
139
|
+
uColorScaleRange: [colorScaleLo, colorScaleHi],
|
|
140
|
+
uIsExpressionMode: isExpressionMode,
|
|
141
|
+
...textures,
|
|
142
|
+
}),
|
|
143
|
+
)
|
|
144
|
+
.draw();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* This function creates textures from the data
|
|
150
|
+
*/
|
|
151
|
+
dataToTexture(data, width, height) {
|
|
152
|
+
const isWebGL2On = isWebGL2(this.context.gl);
|
|
153
|
+
return new Texture2D(this.context.gl, {
|
|
154
|
+
width,
|
|
155
|
+
height,
|
|
156
|
+
// Only use Float32 so we don't have to write two shaders
|
|
157
|
+
data: new Float32Array(data),
|
|
158
|
+
// we don't want or need mimaps
|
|
159
|
+
mipmaps: false,
|
|
160
|
+
parameters: {
|
|
161
|
+
// NEAREST for integer data
|
|
162
|
+
[GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
|
|
163
|
+
[GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
|
|
164
|
+
// CLAMP_TO_EDGE to remove tile artifacts
|
|
165
|
+
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
166
|
+
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
|
|
167
|
+
},
|
|
168
|
+
format: isWebGL2On ? GL.R32F : GL.LUMINANCE,
|
|
169
|
+
dataFormat: isWebGL2On ? GL.RED : GL.LUMINANCE,
|
|
170
|
+
type: GL.FLOAT,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
BitmaskLayer.layerName = 'BitmaskLayer';
|
|
175
|
+
BitmaskLayer.defaultProps = defaultProps;
|