Three.js MeshPhongMaterial纹理

时间:2017-05-07 20:39:51

标签: javascript three.js textures

我试图将三个js纹理添加到MeshPhongMaterial,但出于某种原因,我只是得到一个点亮的黑盒子。我已经坚持了一段时间,似乎无法弄明白。

//Creates the cube and lighting effect
    function initCube() {
    var loader = new THREE.TextureLoader();
    var texture1 = loader.load("brick.jpg");
    cubeTexture = loader.load

     cube = new THREE.Mesh(new THREE.BoxGeometry(3,3,3), new 
    THREE.MeshPhongMaterial({color:0xffffff, map:texture1}));
    scene.add(cube);

    cube.scale.set(0.5, 0.5, 0.5); 
    cube.position.x =  0;

    //Adds light
    cubeLight = new THREE.PointLight(0xFF0000 , 30, 1);
    cube.add(cubeLight);
    cubeLight.position.set(-0.5,-1,0); 
    scene.add(cubeLight);
    cubeLight.power =100;


    map.cubeLight = {
        light: cubeLight,
        added: true
    }

    //Adds second light
     cubeLight2 = new THREE.PointLight(0x6600ff , 1, 1);
    cube.add(cubeLight2);
    cubeLight2.position.set(0,1,0); 
    scene.add(cubeLight2);
    cubeLight2.power =100;

    map.cubeLight2 = {
        light: cubeLight2,
        added: true
    }

    }

0 个答案:

没有答案