Skip to content

Commit

Permalink
GroundedSkybox: Fix UVs being flipped (mrdoob#27500)
Browse files Browse the repository at this point in the history
* GroundedSkybox: Fix UVs being flipped

* fix deepscan issue
  • Loading branch information
hybridherbst authored and AdaRoseCannon committed Jan 15, 2024
1 parent dca5583 commit 1f4ab52
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/jsm/objects/GroundedSkybox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BackSide, Mesh, MeshBasicMaterial, SphereGeometry, Vector3 } from 'three';
import { Mesh, MeshBasicMaterial, SphereGeometry, Vector3 } from 'three';

/**
* A ground-projected skybox. The height is how far the camera that took the photo was above the ground -
Expand All @@ -18,6 +18,7 @@ class GroundedSkybox extends Mesh {
}

const geometry = new SphereGeometry( radius, 2 * resolution, resolution );
geometry.scale( 1, 1, -1 );

const pos = geometry.getAttribute( 'position' );
const tmp = new Vector3();
Expand All @@ -40,7 +41,7 @@ class GroundedSkybox extends Mesh {

pos.needsUpdate = true;

super( geometry, new MeshBasicMaterial( { map, side: BackSide } ) );
super( geometry, new MeshBasicMaterial( { map, depthWrite: false } ) );

}

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion examples/webgl_materials_envmaps_groundprojected.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<script type="module">
import * as THREE from 'three';

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GroundedSkybox } from 'three/addons/objects/GroundedSkybox.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
Expand All @@ -39,7 +40,8 @@

const params = {
height: 15,
radius: 100
radius: 100,
enabled: true,
};

let camera, scene, renderer, skybox;
Expand Down Expand Up @@ -143,6 +145,27 @@
document.body.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize );

const gui = new GUI();

gui.add( params, 'enabled' ).name( "Grounded" ).onChange( function ( value ) {

if ( value ) {

scene.add( skybox );
scene.background = null;

}
else {

scene.remove( skybox );
scene.background = scene.environment;

}

render();

} );
gui.open();
}

function onWindowResize() {
Expand Down

0 comments on commit 1f4ab52

Please sign in to comment.