0

Good evening. I am export two models from Blender 2.79 to three.js.

Scene: link

Shadows work. Objects reflect the world around them but do not reflect among themselves.

Scene code:

        function init() {
            camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1000 );
            camera.position.set( 0, -8, 2 );
                            // envmap
            var path = '/textures/sky_glTF/pisa/'; // ADD "/"
            var format = '.png';
            var envMap = new THREE.CubeTextureLoader().load( [
                path + 'px' + format, path + 'nx' + format,
                path + 'py' + format, path + 'ny' + format,
                path + 'pz' + format, path + 'nz' + format
            ] );
            scene = new THREE.Scene();
            scene.background = envMap;



                         //MR -  YES mirror
            var loader = new THREE.GLTFLoader();
            loader.load( '/gltf/1.gltf', function ( gltf ) {

                gltf.scene.traverse( function ( node ) {

                    if ( node.isMesh || node.isLight ) node.castShadow = true;
                    if ( node.isMesh || node.isLight ) node.receiveShadow = true;

                } );

                       gltf.scene.traverse( function ( child ) {

                    if ( child.isMesh ) {

                        child.material.envMap = envMap;
                    }

                } );
                gltf.scene.position.x = 0;
                gltf.scene.position.y = 0;
                gltf.scene.position.z = 0;

                       scene.add( gltf.scene );

            } );
                         //MR -  YES mirror
            var loader = new THREE.GLTFLoader();
            loader.load( '/gltf/2.gltf', function ( gltf2 ) {

                gltf2.scene.traverse( function ( node ) {

                    if ( node.isMesh || node.isLight ) node.castShadow = true;
                    if ( node.isMesh || node.isLight ) node.receiveShadow = true;

                } );

                gltf2.scene.traverse( function ( child ) {

                    if ( child.isMesh ) {

                        child.material.envMap = envMap;

                    }

                } );
                    gltf2.scene.position.x = 0;
                    gltf2.scene.position.y = 0;
                    gltf2.scene.position.z = 0;

                    scene.add( gltf2.scene );

            } );

How to implement reflections between objects?

What part of the code do you still have to show for a complete answer to my question?

Helder Sepulveda
  • 15,500
  • 4
  • 29
  • 56

0 Answers0