Skip to content

Commit

Permalink
Examples: Clean up. (#28540)
Browse files Browse the repository at this point in the history
* Examples: Clean up.

* remove useless code
  • Loading branch information
linbingquan authored Jun 3, 2024
1 parent c7e4ed5 commit c94a3c6
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions examples/webxr_xr_dragging_custom_depth.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
for ( let i = 0; i < 50; i ++ ) {

const geometry = geometries[ Math.floor( Math.random() * geometries.length ) ];
const material = new THREE.ShaderMaterial({
const material = new THREE.ShaderMaterial( {

vertexShader: `
vertexShader: /* glsl */`
varying vec3 vNormal;
varying vec2 vUv;
void main() {
Expand All @@ -104,7 +104,7 @@
}
`,

fragmentShader: `
fragmentShader: /* glsl */`
uniform vec3 diffuseColor;
uniform float roughness;
uniform float metalness;
Expand Down Expand Up @@ -223,7 +223,7 @@

uniforms: {

diffuseColor: { value: new THREE.Color( Math.random() * 0xffffff) },
diffuseColor: { value: new THREE.Color( Math.random() * 0xffffff ) },
roughness: { value: 0.7 },
metalness: { value: 0.0 },
emissive: { value: 0.0 },
Expand All @@ -233,7 +233,7 @@

}

});
} );

const object = new THREE.Mesh( geometry, material );

Expand Down Expand Up @@ -418,30 +418,28 @@

function render() {

if (renderer.xr.hasDepthSensing() && ! isDepthSupplied) {
if ( renderer.xr.hasDepthSensing() && ! isDepthSupplied ) {

group.children.forEach(child => {
group.children.forEach( child => {

child.material.uniforms.depthColor.value = renderer.xr.getDepthTexture();
child.material.uniforms.depthWidth.value = 1680;
child.material.uniforms.depthHeight.value = 1760;
child.material.uniforms.NeedUpdate = true;

isDepthSupplied = true;

});
} );

} else if (! renderer.xr.hasDepthSensing() && isDepthSupplied) {
} else if ( ! renderer.xr.hasDepthSensing() && isDepthSupplied ) {

group.children.forEach(child => {
group.children.forEach( child => {

child.material.uniforms.depthWidth.value = 0;
child.material.uniforms.depthHeight.value = 0;
child.material.uniforms.NeedUpdate = true;

isDepthSupplied = false;

});
} );

}

Expand Down

0 comments on commit c94a3c6

Please sign in to comment.