Skip to content

fix: "Incorrect 2D axes rendering with vertical scaling #1957" #1971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 131 additions & 108 deletions typescript/packages/subsurface-viewer/src/layers/axes2d/axes2DLayer.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default `\
#version 300 es
#define SHADER_NAME graph-layer-fragment-shader
#define SHADER_NAME axes2d-layer-fragment-shader

precision highp float;

Expand Down Expand Up @@ -32,6 +32,5 @@ void main(void) {
float b = x * text_b + (1.0 - x) * bg_b;

fragColor = vec4(r, g, b, 1.0);
return;
}
`;
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
export default `\
#version 300 es
#define SHADER_NAME graph-layer-axis-vertex-shader
#define SHADER_NAME axes2d-layer-vertex-shader

precision highp float;

in vec3 positions;
in vec3 positions;

in vec2 vTexCoord;
out vec2 _vTexCoord;

uniform mat4 projectionMatrix;

void main(void) {
_vTexCoord = vTexCoord;

vec3 position_commonspace = positions; // These positions are in view space.
gl_Position = projectionMatrix * vec4(position_commonspace, 1.0); // From viewspace to clip
vec3 position_commonspace = project_position(positions);
gl_Position = project_common_position_to_clipspace(vec4(position_commonspace, 1.0));
}
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default `\
#version 300 es
#define SHADER_NAME axes2d-layer-fragment-shader
#define SHADER_NAME axes2dlayer-line-fragment-shader

precision highp float;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default `\
#version 300 es
#define SHADER_NAME axes2d-layer-vertex-shader
#define SHADER_NAME axes2dlayer-line-vertex-shader

precision highp float;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ const SQUARE = {
type: "Polygon",
coordinates: [
[
[-5, -5],
[-5, 5],
[5, 5],
[5, 1500],
[1500, 1500],
[1500, 5],
[5, 5],
[5, -5],
[-5, -5],
],
],
},
Expand Down Expand Up @@ -528,10 +528,11 @@ export const AddLayer: StoryObj<typeof SubsurfaceViewer> = {
const ScaleYComponent = ({ verticalScale }: { verticalScale: number }) => {
const viewerProps: SubsurfaceViewerProps = {
id: "ScaleY",
bounds: [-1000, -1000, 3000, 3000],
bounds: [-10, -10, 10, 10],
layers: [
new Axes2DLayer({
id: "axes",
backgroundColor: [0, 155, 155],
}),
new GeoJsonLayer({
...customLayerWithPolygonDataProps,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ export const customLayerWithPolygonDataProps: GeoJsonLayerProps = {
],
},
},
getLineWidth: 20,
lineWidthMinPixels: 2,
getLineColor: [0, 255, 255],
getFillColor: [0, 255, 0],
opacity: 0.3,
getLineWidth: 1,
lineWidthMinPixels: 1,
lineWidthMaxPixels: 1,
getLineColor: [0, 0, 0],
getFillColor: [255, 255, 0],
opacity: 1.0,
};

export const customLayerWithPolygonData = {
Expand Down