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