mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-27 04:48:11 +08:00
TS Revert (1) (#2402)
* revert all commits to before Typescript migration * update compat workflow to match latest deps (#2335) * update compat workflow to match latest deps * attempt to debug * attempt to debug * remove debugging code * typo * update deps to match desktop (#2340) * fix: don't run lint with `--fix` on push tests (#2273) * fix: don't run lint with `--fix` on push tests * npx Co-authored-by: maniarathi <mani.arathi@gmail.com> Co-authored-by: Madison Dunitz <madison.dunitz@chanzuckerberg.com> * rename X_approx_distribution to X_approximate_distribution (#2337) * Correctly handle non-finite numbers in heuristic determination of X distribution (#2342) * handle non-finites explicitly * improve and test edge case handling for distribution estimation * revert debugging changes * code readability * clean up type inferencing (#2332) * unit tests for 64 bit conversion * clean up type handling * type inference tests * more type inference fixes * use schema to determine user intent for data typing * stop using deprecated API * fbs type encoding test * add missing test * add more tests * correctly infer X type for CXG adaptor * lint * fix typo * ts migration * cleanup from PR review * lint * PR review changes * remove unused packages from client (#2359) * remove unused packages from client * add missing peer dep * fix: disable FE auth testing on compatibility tests (#2377) * update: release process (#2277) Co-authored-by: maniarathi <mani.arathi@gmail.com> * fix: remove spaces in param setup (#2380) * delete deploy workflow (#2396) * undo reformatting which now does not pass lint * fix snapshots which changed due to npm dep changes * add missing quoting to snapshot * another snapshot typo fix * TS Revert (2) - replay PR #2347 and #2354 (#2403) * replay edits from PR 2347 * TS Revert (3) - replay edits in PR #2327 (#2404) * replay edits in PR 2327 * TS Revert (4) - replay PR #2355 (#2405) * replay edits in PR 2355 * add additional babel config * reformat with new prettier config Co-authored-by: Severiano Badajoz <sbadajoz@chanzuckerberg.com> Co-authored-by: maniarathi <mani.arathi@gmail.com> Co-authored-by: Madison Dunitz <madison.dunitz@chanzuckerberg.com>
This commit is contained in:
co-authored by
maniarathi
Madison Dunitz
Severiano Badajoz
parent
295590a7c6
commit
eaae6df5e3
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Utility code for WebGL shaders
|
||||
*/
|
||||
|
||||
/*
|
||||
PointFlags:
|
||||
Point flags are used in graph & scatter plots.
|
||||
|
||||
We want a bitmask-like flag structure, but due to webgl limitations
|
||||
must emulate it with floats.
|
||||
|
||||
Supported flags are:
|
||||
|
||||
selected: the point is currently selected
|
||||
highlight: the point is currently highlighted
|
||||
background: the point is background information
|
||||
*/
|
||||
|
||||
// for JS
|
||||
export const flagSelected = 1;
|
||||
export const flagBackground = 2;
|
||||
export const flagHighlight = 4;
|
||||
|
||||
// for GLSL
|
||||
export const glPointFlags = `
|
||||
|
||||
const float flagSelected = 1.;
|
||||
const float flagBackground = 2.;
|
||||
const float flagHighlight = 4.;
|
||||
|
||||
bool isLowBitSet(float f) {
|
||||
f = mod(f, 2.);
|
||||
return (f > 0.9 && f <= 1.1);
|
||||
}
|
||||
|
||||
float shiftRightOne(float f) {
|
||||
return floor(f / 2.);
|
||||
}
|
||||
|
||||
void getFlags(in float flag,
|
||||
out bool isBackground,
|
||||
out bool isSelected,
|
||||
out bool isHighlight) {
|
||||
isSelected = isLowBitSet(flag);
|
||||
flag = shiftRightOne(flag);
|
||||
isBackground = isLowBitSet(flag);
|
||||
flag = shiftRightOne(flag);
|
||||
isHighlight = isLowBitSet(flag);
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
/*
|
||||
Point Size:
|
||||
Calculate point size for scatter plot based upon pseudo density.
|
||||
|
||||
Current approach: linear scaling of point size, clamped to [1,10],
|
||||
between two points that are based on empirical testing.
|
||||
|
||||
- 1M points on a 500x500 canvas: 1M/(500*500) -> 0.5
|
||||
- 1000 points on a 1440x1440 canvas: 1000/(1440*1440) -> 5
|
||||
|
||||
The domain is pseudo density (numPoints / minViewportDimension^2)
|
||||
The range is web gl point size.
|
||||
*/
|
||||
|
||||
// configuration
|
||||
const domain = [1000000 / (500 * 500), 1000 / (1440 * 1440)];
|
||||
const range = [0.5, 5];
|
||||
|
||||
// derived from configuration
|
||||
const scale = (range[1] - range[0]) / (domain[1] - domain[0]);
|
||||
const offset = scale * -domain[0] + range[0];
|
||||
|
||||
export const glPointSize = `
|
||||
float pointSize(float nPoints, float minViewportDimension, bool isSelected, bool isHighlight) {
|
||||
float density = nPoints / (minViewportDimension * minViewportDimension);
|
||||
float pointSize = (${scale.toFixed(4)}*density) + ${offset.toFixed(4)};
|
||||
pointSize = clamp(pointSize,
|
||||
${range[0].toFixed(4)},
|
||||
${range[1].toFixed(4)});
|
||||
|
||||
if (isHighlight) return 2. * pointSize;
|
||||
if (isSelected) return pointSize;
|
||||
return pointSize / 3.;
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user