diff --git a/examples/screenshots/webgl_loader_usdz.jpg b/examples/screenshots/webgl_loader_usdz.jpg index 99d5137493fb8..6fb1061f11afe 100644 Binary files a/examples/screenshots/webgl_loader_usdz.jpg and b/examples/screenshots/webgl_loader_usdz.jpg differ diff --git a/examples/webgl_loader_usdz.html b/examples/webgl_loader_usdz.html index a6459e466baea..89b9c85fc10f1 100644 --- a/examples/webgl_loader_usdz.html +++ b/examples/webgl_loader_usdz.html @@ -34,6 +34,7 @@ import * as THREE from 'three'; import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; + import { RGBELoader } from 'three/addons/loaders/RGBELoader.js'; import { USDZLoader } from 'three/addons/loaders/USDZLoader.js'; let camera, scene, renderer; @@ -41,39 +42,50 @@ init(); animate(); - function init() { + async function init() { camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 100 ); - camera.position.set( 0, 0.75, - 1 ); + camera.position.set( 0, 0.75, - 1.5 ); scene = new THREE.Scene(); - scene.background = new THREE.Color( 0xeeeeee ); - scene.add( new THREE.GridHelper( 2, 4, 0xc1c1c1, 0x8d8d8d ) ); - - const light = new THREE.DirectionalLight( 0xffffff, 3 ); - light.position.set( 1, 1, 1 ); - scene.add( light ); - - const light2 = new THREE.HemisphereLight( 0xffffff, 0xc1c1c1, 3 ); - scene.add( light2 ); - - // renderer renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); + renderer.toneMapping = THREE.ACESFilmicToneMapping; + renderer.toneMappingExposure = 2.0; document.body.appendChild( renderer.domElement ); const controls = new OrbitControls( camera, renderer.domElement ); controls.minDistance = 1; controls.maxDistance = 8; + // controls.target.y = 15; + // controls.update(); + + const rgbeLoader = new RGBELoader() + .setPath( 'textures/equirectangular/' ); + + const usdzLoader = new USDZLoader() + .setPath( 'models/usdz/' ); + + const [ texture, model ] = await Promise.all( [ + rgbeLoader.loadAsync( 'venice_sunset_1k.hdr' ), + usdzLoader.loadAsync( 'saeukkang.usdz' ), + ] ); + + // environment + + texture.mapping = THREE.EquirectangularReflectionMapping; - const loader = new USDZLoader(); - loader.load( 'models/usdz/saeukkang.usdz', function ( usd ) { + scene.background = texture; + scene.backgroundBlurriness = 0.5; + scene.environment = texture; - scene.add( usd ); + // model - } ); + model.position.y = 0.25; + model.position.z = - 0.25; + scene.add( model ); window.addEventListener( 'resize', onWindowResize );