Skip to content

Instantly share code, notes, and snippets.

@BABAK0T0
Created March 1, 2021 22:33
Show Gist options
  • Save BABAK0T0/bebfe378476ea19bb4bcceb2a6dbc90c to your computer and use it in GitHub Desktop.
Save BABAK0T0/bebfe378476ea19bb4bcceb2a6dbc90c to your computer and use it in GitHub Desktop.

Revisions

  1. BABAK0T0 created this gist Mar 1, 2021.
    22 changes: 22 additions & 0 deletions Environment-map.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    /**
    * The environment map is like an image of what's surrounding the scene.
    * You can use it to add reflection or refraction to your objects.
    * It can also be used as lighting information.
    **/

    const material = new THREE.MeshStandardMaterial();
    material.metalness = 0.7;
    material.roughness = 0.2;

    const cubeTextureLoader = new THREE.CubeTextureLoader();

    const environmentMapTexture = cubeTextureLoader.load([
    '/textures/environmentMaps/0/px.jpg',
    '/textures/environmentMaps/0/nx.jpg',
    '/textures/environmentMaps/0/py.jpg',
    '/textures/environmentMaps/0/ny.jpg',
    '/textures/environmentMaps/0/pz.jpg',
    '/textures/environmentMaps/0/nz.jpg'
    ]);

    material.envMap = environmentMapTexture;