You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a project where I need to have 2 canvases. Both canvases need to use Environment based lighting. For some reason the with the WebGPURenderer only one environment works, perhaps a global state issue?
import*asTHREEfrom'three/webgpu';import{RGBELoader}from'three/examples/jsm/loaders/RGBELoader.js';import{OrbitControls}from'three/examples/jsm/controls/OrbitControls.js';asyncfunctioncreateScene(canvas,hdrPath){constscene=newTHREE.Scene();constcamera=newTHREE.PerspectiveCamera(50,1,0.1,100);camera.position.set(0,0,4);constrenderer=newTHREE.WebGPURenderer({ canvas,antialias: true});awaitrenderer.init()renderer.setSize(canvas.clientWidth,canvas.clientHeight);consthdrTexture=awaitnewRGBELoader().loadAsync(hdrPath);hdrTexture.mapping=THREE.EquirectangularReflectionMapping;scene.environment=hdrTexture;scene.background=hdrTextureconstcontrols=newOrbitControls(camera,renderer.domElement);constsphere=newTHREE.Mesh(newTHREE.SphereGeometry(0.8,32,32),newTHREE.MeshStandardMaterial({metalness: 1,roughness: 0,envMap: hdrTexture}));scene.add(sphere);functionanimate(){controls.update()sphere.rotation.y+=0.005;renderer.render(scene,camera);requestAnimationFrame(animate);}renderer.setAnimationLoop(animate)}// Create two canvasesconstcontainer=document.body;constcanvas1=document.createElement('canvas');constcanvas2=document.createElement('canvas');canvas1.width=canvas2.width=window.innerWidth/2;canvas1.height=canvas2.height=window.innerHeight;canvas1.style.position=canvas2.style.position='absolute';canvas1.style.left='0';canvas2.style.left=`${window.innerWidth/2}px`;container.appendChild(canvas1);container.appendChild(canvas2);// Load two different HDR filesawaitcreateScene(canvas1,'https://threejs.org/examples/textures/equirectangular/royal_esplanade_1k.hdr');awaitcreateScene(canvas2,'https://threejs.org/examples/textures/equirectangular/royal_esplanade_1k.hdr');
Description
I am working on a project where I need to have 2 canvases. Both canvases need to use Environment based lighting. For some reason the with the WebGPURenderer only one environment works, perhaps a global state issue?
Reproduction steps
More than one canvas, both with env maps
Code
Live example
Broken WebGPURender https://jsfiddle.net/zafrbgxd/21/
Working WebGLRenderer https://jsfiddle.net/zafrbgxd/24/
Screenshots
Version
r173
Device
Desktop
Browser
Chrome
OS
MacOS
The text was updated successfully, but these errors were encountered: