Skip to content

Commit

Permalink
fix(examples): add envmap for PBR materials in 3d tiles loader example
Browse files Browse the repository at this point in the history
  • Loading branch information
Desplandis committed Feb 7, 2025
1 parent e75fbb8 commit 8b22591
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/3dtiles_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@
</script>

<script type="module">
import { AmbientLight } from 'three';
import {
AmbientLight,
PMREMGenerator,
} from 'three';
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
import {
zoomToLayer,
fillHTMLWithPickingInfo,
Expand Down Expand Up @@ -106,6 +110,13 @@
const light = new AmbientLight(0x404040, 40);
view.scene.add(light);

// Set the environment map for all physical materials in the scene.
// Otherwise, mesh with only diffuse colors will appear black.
const environment = new RoomEnvironment();
const pmremGenerator = new PMREMGenerator(view.renderer);
view.scene.environment = pmremGenerator.fromScene(environment).texture;
pmremGenerator.dispose();

// Setup loading screen
setupLoadingScreen(viewerDiv, view);

Expand Down

0 comments on commit 8b22591

Please sign in to comment.