使用three.js r62
grass_side = new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('assets/blocks/grass_side.png')
});
grass_top = new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('assets/blocks/grass_top.png')
});
materials = new THREE.MeshFaceMaterial([
grass_side,
grass_top
]);
cube = new THREE.CubeGeometry(30, 30, 30);
cube.faces[0].materialIndex = 0;
cube.faces[1].materialIndex = 0;
cube.faces[2].materialIndex = 0;
cube.faces[3].materialIndex = 0;
cube.faces[4].materialIndex = 1;
cube.faces[5].materialIndex = 1;
box = new THREE.Mesh(cube, materials);
scene.add(box);
我在stackoverflow的某个地方找到了这段代码,但它不起作用。我不断收到这些错误:
Uncaught TypeError: Cannot read property 'map' of undefined three.js:376
Uncaught TypeError: Cannot read property 'attributes' of undefined three.js:458