Skip to content

Commit

Permalink
Examples: Use PBR material in webxr_ar_lighting again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Jan 11, 2022
1 parent 604a911 commit 48427de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 2 additions & 0 deletions examples/jsm/webxr/XREstimatedLight.js
Expand Up @@ -69,6 +69,8 @@ class SessionLightProbe {

textureProperties.__webglTexture = cubeMap;

this.xrLight.environment.needsPMREMUpdate = true;

}

}
Expand Down
Binary file modified examples/screenshots/webxr_ar_lighting.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 9 additions & 19 deletions examples/webxr_ar_lighting.html
Expand Up @@ -36,7 +36,8 @@

camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 20 );

const defaultLight = new THREE.AmbientLight( 0xffffff );
const defaultLight = new THREE.HemisphereLight( 0xffffff, 0xbbbbff, 1 );
defaultLight.position.set( 0.5, 1, 0.25 );
scene.add( defaultLight );

//
Expand Down Expand Up @@ -76,7 +77,7 @@
scene.remove( xrLight );

// Revert back to the default environment.
updateEnvironment( defaultEnvironment );
scene.environment = defaultEnvironment;

} );

Expand All @@ -90,7 +91,7 @@

defaultEnvironment = texture;

updateEnvironment( defaultEnvironment );
scene.environment = defaultEnvironment;

} );

Expand All @@ -105,16 +106,17 @@
const ballGroup = new THREE.Group();
ballGroup.position.z = - 2;

const rows = 1;
const cols = 4;
const rows = 3;
const cols = 3;

for ( let i = 0; i < rows; i ++ ) {

for ( let j = 0; j < cols; j ++ ) {

const ballMaterial = new THREE.MeshPhongMaterial( {
const ballMaterial = new THREE.MeshStandardMaterial( {
color: 0xdddddd,
reflectivity: j / cols
roughness: i / rows,
metalness: j / cols
} );
const ballMesh = new THREE.Mesh( ballGeometry, ballMaterial );
ballMesh.position.set( ( i + 0.5 - rows * 0.5 ) * 0.4, ( j + 0.5 - cols * 0.5 ) * 0.4, 0 );
Expand Down Expand Up @@ -168,18 +170,6 @@

}

function updateEnvironment( envMap ) {

scene.traverse( function ( object ) {

if ( object.isMesh ) object.material.envMap = envMap;


} );

}


</script>
</body>
</html>

0 comments on commit 48427de

Please sign in to comment.