@quake2ts/engine 0.0.855 → 0.0.857

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5812,23 +5812,28 @@ uniform vec2 u_scroll;
5812
5812
  out vec3 v_direction;
5813
5813
 
5814
5814
  void main() {
5815
- // Transform Quake-space position/direction to GL-space direction for cubemap sampling.
5816
- // Quake Basis: X(Fwd), Y(Left), Z(Up)
5817
- // GL Basis (Cubemap): -Z(Front), -X(Left), +Y(Top)
5818
- // Mapping:
5819
- // Quake X (1,0,0) -> GL -Z (0,0,-1)
5820
- // Quake Y (0,1,0) -> GL -X (-1,0,0)
5821
- // Quake Z (0,0,1) -> GL Y (0,1,0)
5822
- vec3 dir = vec3(-a_position.y, a_position.z, -a_position.x);
5815
+ // The cube vertices (a_position) are in GL space (-1 to 1, standard OpenGL cube).
5816
+ // The viewProjection matrix expects Quake-space input (it contains Quake-to-GL transform).
5817
+ // So we must transform GL -> Quake before applying the view matrix.
5818
+ //
5819
+ // GL-to-Quake mapping (inverse of Quake-to-GL):
5820
+ // GL -Z -> Quake +X (forward)
5821
+ // GL -X -> Quake +Y (left)
5822
+ // GL +Y -> Quake +Z (up)
5823
+ // So: (gl.x, gl.y, gl.z) -> (-gl.z, -gl.x, gl.y)
5824
+ vec3 quakePos = vec3(-a_position.z, -a_position.x, a_position.y);
5825
+ vec4 pos = u_viewProjectionNoTranslation * vec4(quakePos, 1.0);
5826
+ // Force z = w to render at far plane, avoiding clipping issues
5827
+ // for triangles that intersect the camera plane
5828
+ gl_Position = pos.xyww;
5823
5829
 
5824
- // Normalize just in case, though a_position is on a cube surface.
5825
- // Actually, for a cubemap lookup, normalization isn't strictly required by the hardware
5826
- // (it grabs the vector direction), but good practice if we modify it.
5827
- dir = normalize(dir);
5830
+ // For cubemap sampling, use the original GL-space position since
5831
+ // WebGL cubemap targets (POSITIVE_X, etc.) are in GL conventions.
5832
+ vec3 dir = a_position;
5828
5833
 
5834
+ // Apply scroll offset for animated skies
5829
5835
  dir.xy += u_scroll;
5830
5836
  v_direction = dir;
5831
- gl_Position = u_viewProjectionNoTranslation * vec4(a_position, 1.0);
5832
5837
  }`;
5833
5838
  var SKYBOX_FRAGMENT_SHADER = `#version 300 es
5834
5839
  precision highp float;
@@ -5871,7 +5876,10 @@ var SkyboxPipeline = class {
5871
5876
  bind(options) {
5872
5877
  const { viewProjection, scroll, textureUnit = 0 } = options;
5873
5878
  this.program.use();
5879
+ this.gl.enable(this.gl.DEPTH_TEST);
5880
+ this.gl.depthFunc(this.gl.LEQUAL);
5874
5881
  this.gl.depthMask(false);
5882
+ this.gl.disable(this.gl.CULL_FACE);
5875
5883
  this.gl.uniformMatrix4fv(this.uniformViewProj, false, viewProjection);
5876
5884
  this.gl.uniform2f(this.uniformScroll, scroll[0], scroll[1]);
5877
5885
  this.gl.uniform1i(this.uniformSampler, textureUnit);