Skip to content

Commit

Permalink
fix: cut plane should not be clickable, just the axis widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim5aad committed Feb 5, 2024
1 parent a3b2e38 commit 41091b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/plugins/ClippingPlane/interactive-clipping-plane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class InteractiveClippingPlane implements IPlugin {
private arrowColour = [1.0, 0.0, 0.0, 1.0];
private horizontalColour = [0.0, 1.0, 0.0, 1.0];
private verticalColour = [0.0, 0.0, 1.0, 1.0];
private planeColour = [0.5, 0.5, 0.5, 0.3];
private planeColour = [0.5, 0.5, 0.5, 0.05];
private currentInteraction: number = -1;

private program: WebGLProgram;
Expand Down Expand Up @@ -537,8 +537,7 @@ export class InteractiveClippingPlane implements IPlugin {
mat4.fromRotationTranslation(this.transformation, yRoration, translation);
}
const proj = vec3.fromValues(normal[0], normal[1], 0);
const angle = vec3.angle(normal, proj);
if (angle < tolerance) {
if (vec3.angle(normal, proj) < tolerance) {
const translation = mat4.getTranslation(vec3.create(), this.transformation);
const roration = quat.rotateZ(quat.create(), quat.create(), Math.atan2(proj[1], proj[0]));
mat4.fromRotationTranslation(this.transformation, roration, translation);
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ClippingPlane/vshader.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ void main(void) {
bool ignoreVec = false;
if (uColorCoding > 0.5 && uColorCoding <= 1.0)
{
ignoreVec = aId == 4.0;
vColor = getIdColor(aId);
}
else if (uColorCoding < -0.5)
{
ignoreVec = aId == 4.0;
vColor = getIdColor(1000010.0);
}
else
{
if(uSelectedId == aId)
{
vColor = uHoverPickColour;
vColor = aColour;
}
else
{
Expand All @@ -57,7 +59,7 @@ void main(void) {
if(aId != 4.0){ // hide other controls but leave the plane
ignoreVec = true;
}
else
else if(uSelectedId != 4.0)
vColor = getTransparentColor(aColour, 1.5);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ClippingPlane/vshader.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const vshader = "attribute highp vec3 aVertex;\nattribute highp vec4 aColour;\nattribute highp float aId;\n\n\nuniform mat4 uMvMatrix;\nuniform mat4 uPMatrix;\n\n\nuniform mediump float uColorCoding; \nuniform mediump float uSelectedId;\n\n\nuniform vec4 uHoverPickColour;\n\n\nvarying vec4 vColor;\n\nvec4 getIdColor(float id){\n float product = floor(id + 0.5);\n float B = floor(product / (256.0*256.0));\n float G = floor((product - B * 256.0*256.0) / 256.0);\n float R = mod(product, 256.0);\n return vec4(R / 255.0, G / 255.0, B / 255.0, 1.0);\n}\n\nvec4 getTransparentColor(vec4 color, float transparency){\n mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, transparency);\n return aMat4 * color;\n}\n\n\nvoid main(void) {\n\n bool ignoreVec = false;\n if (uColorCoding > 0.5 && uColorCoding <= 1.0)\n {\n vColor = getIdColor(aId);\n }\n else if (uColorCoding < -0.5)\n {\n vColor = getIdColor(1000010.0);\n }\n else\n { \n if(uSelectedId == aId)\n { \n vColor = uHoverPickColour; \n }\n else\n {\n if(uSelectedId > 0.0) \n {\n if(aId != 4.0){ \n ignoreVec = true;\n }\n else\n vColor = getTransparentColor(aColour, 1.5);\n }\n else \n vColor = aColour;\n }\n }\n\n if(!ignoreVec)\n {\n gl_Position = uPMatrix * uMvMatrix * vec4(aVertex, 1.0);\n }\n\n}"
export const vshader = "attribute highp vec3 aVertex;\r\nattribute highp vec4 aColour;\r\nattribute highp float aId;\r\n\r\n\r\nuniform mat4 uMvMatrix;\r\nuniform mat4 uPMatrix;\r\n\r\n\r\nuniform mediump float uColorCoding; \r\nuniform mediump float uSelectedId;\r\n\r\n\r\nuniform vec4 uHoverPickColour;\r\n\r\n\r\nvarying vec4 vColor;\r\n\r\nvec4 getIdColor(float id){\r\n float product = floor(id + 0.5);\r\n float B = floor(product / (256.0*256.0));\r\n float G = floor((product - B * 256.0*256.0) / 256.0);\r\n float R = mod(product, 256.0);\r\n return vec4(R / 255.0, G / 255.0, B / 255.0, 1.0);\r\n}\r\n\r\nvec4 getTransparentColor(vec4 color, float transparency){\r\n mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0,\r\n 0.0, 1.0, 0.0, 0.0,\r\n 0.0, 0.0, 1.0, 0.0,\r\n 0.0, 0.0, 0.0, transparency);\r\n return aMat4 * color;\r\n}\r\n\r\n\r\nvoid main(void) {\r\n\r\n bool ignoreVec = false;\r\n if (uColorCoding > 0.5 && uColorCoding <= 1.0)\r\n {\r\n ignoreVec = aId == 4.0;\r\n vColor = getIdColor(aId);\r\n }\r\n else if (uColorCoding < -0.5)\r\n {\r\n ignoreVec = aId == 4.0;\r\n vColor = getIdColor(1000010.0);\r\n }\r\n else\r\n { \r\n if(uSelectedId == aId)\r\n { \r\n vColor = aColour; \r\n }\r\n else\r\n {\r\n if(uSelectedId > 0.0) \r\n {\r\n if(aId != 4.0){ \r\n ignoreVec = true;\r\n }\r\n else if(uSelectedId != 4.0) \r\n vColor = getTransparentColor(aColour, 1.5);\r\n }\r\n else \r\n vColor = aColour;\r\n }\r\n }\r\n\r\n if(!ignoreVec)\r\n {\r\n gl_Position = uPMatrix * uMvMatrix * vec4(aVertex, 1.0);\r\n }\r\n\r\n}"

0 comments on commit 41091b6

Please sign in to comment.