Skip to content
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

Gizmo clipping plane fix #7045

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/extras/gizmo/gizmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ class Gizmo extends EventHandler {
* @private
*/
_getSelection(x, y) {
const start = this._camera.screenToWorld(x, y, this._camera.nearClip);
const end = this._camera.screenToWorld(x, y, this._camera.farClip);
const start = this._camera.entity.getPosition();
const end = this._camera.screenToWorld(x, y, this._camera.farClip - this._camera.nearClip);
const dir = end.clone().sub(start).normalize();

const selection = [];
Expand Down
5 changes: 2 additions & 3 deletions src/extras/gizmo/shape/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@ const shaderDesc = {
attribute vec3 vertex_position;
attribute vec4 vertex_color;
varying vec4 vColor;
varying vec2 vZW;
uniform mat4 matrix_model;
uniform mat4 matrix_viewProjection;
void main(void) {
gl_Position = matrix_viewProjection * matrix_model * vec4(vertex_position, 1.0);
gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w)) * sign(gl_Position.z);
kpal81xd marked this conversation as resolved.
Show resolved Hide resolved
vColor = vertex_color;
}
`,
fragmentCode: /* glsl */`
precision highp float;
varying vec4 vColor;
varying vec2 vZW;
void main(void) {
gl_FragColor = vec4(gammaCorrectOutput(decodeGamma(vColor)), vColor.w);
gl_FragDepth = gl_FragCoord.z;
}
`
};
Expand Down Expand Up @@ -301,6 +299,7 @@ class Shape {
const meshInstances = [];
for (let i = 0; i < meshes.length; i++) {
const mi = new MeshInstance(meshes[i], material);
mi.cull = false;
meshInstances.push(mi);
this.meshInstances.push(mi);
}
Expand Down