-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from saaaji/feature_transform_gizmo
gizmo added
- Loading branch information
Showing
12 changed files
with
380 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#version 300 es | ||
|
||
// precision qualifiers | ||
precision mediump float; | ||
|
||
// fragment I/O | ||
layout(location = 0) out vec4 out_color; | ||
in vec3 v_color; | ||
|
||
void main() { | ||
out_color = vec4(v_color, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#version 300 es | ||
|
||
in vec3 a_position; | ||
in vec3 a_color; | ||
|
||
uniform mat4 u_projectionMatrix; | ||
uniform mat4 u_viewMatrix; | ||
uniform mat4 u_worldMatrix; | ||
|
||
uniform int u_axis; | ||
|
||
out vec3 v_color; | ||
|
||
const float SCALE = 0.2; | ||
|
||
void main() { | ||
mat4 worldMatrix = u_worldMatrix; | ||
|
||
worldMatrix[0] = normalize(worldMatrix[0]); | ||
worldMatrix[1] = normalize(worldMatrix[1]); | ||
worldMatrix[2] = normalize(worldMatrix[2]); | ||
|
||
float depth = (u_viewMatrix * vec4(worldMatrix[3].xyz, 1)).z; | ||
depth = max(abs(depth), 1.0); | ||
vec4 position = worldMatrix * vec4(a_position * depth * SCALE, 1); | ||
|
||
if (u_axis < 0) { | ||
v_color = a_color; | ||
} else { | ||
int index = gl_VertexID / 2; | ||
if (u_axis != index) v_color = vec3(0.5); | ||
else v_color = a_color; | ||
} | ||
|
||
gl_Position = u_projectionMatrix * u_viewMatrix * position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.