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

GroundedSkybox: Fix UVs being flipped #27500

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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