Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var group = new THREE.Object3D();
- var materials = [];
- var side = new THREE.ImageUtils.loadTexture("textures/box_sides.png");
- // side.wrapS = side.wrapT = THREE.RepeatWrapping;
- var sideMat = new THREE.MeshPhongMaterial({
- emissive: 0x000000,
- color: 0x555555,
- specular: 0x000000,
- map: side
- });
- materials.push(sideMat);
- materials.push(sideMat);
- materials.push(sideMat);
- materials.push(sideMat);
- var top = new THREE.ImageUtils.loadTexture("textures/box_top.png");
- top.wrapS = top.wrapT = THREE.RepeatWrapping;
- top.repeat.set(1,1);
- materials.push(new THREE.MeshPhongMaterial({
- emissive: 0x000000,
- color: 0x555555,
- specular: 0x333333,
- map: top
- }));
- var bottom = new THREE.ImageUtils.loadTexture("textures/box_bottom.png");
- materials.push(new THREE.MeshPhongMaterial({
- emissive: 0x000000,
- color: 0x555555,
- specular: 0x000000,
- map: bottom
- }));
- var cubeGeo = new THREE.CubeGeometry(width,height,depth,1,1,1, materials);
- // rotate texture on sides
- cubeGeo.faceVertexUvs[0][0] = [];
- cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(0,1));
- cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][0].push(new THREE.Vector2(0,0));
- cubeGeo.faceVertexUvs[0][1] = [];
- cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(1,0));
- cubeGeo.faceVertexUvs[0][1].push(new THREE.Vector2(0,0));
- cubeGeo.faceVertexUvs[0][2] = [];
- cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(1,0));
- cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(0,0));
- cubeGeo.faceVertexUvs[0][2].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][3] = [];
- cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(0,0));
- cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(0,1));
- cubeGeo.faceVertexUvs[0][3].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][4] = [];
- cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(1,0));
- cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][4].push(new THREE.Vector2(0,0));
- cubeGeo.faceVertexUvs[0][5] = [];
- cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(0,1));
- cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(1,1));
- cubeGeo.faceVertexUvs[0][5].push(new THREE.Vector2(1,0));
- var mesh = new THREE.Mesh(cubeGeo, new THREE.MeshFaceMaterial(materials));
- mesh.position.set( x, y-(depth/2), z );
- mesh.rotation.x = - Math.PI/2;
- mesh.scale.set( scale, scale, scale );
- mesh.receiveShadow = true;
- group.add(mesh);
- // Base of the plateau
- var texture = THREE.ImageUtils.loadTexture( "textures/stone.jpg" );
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
- texture.repeat.set( 2, 2 );
- var base_material = new THREE.MeshPhongMaterial( {color: 0xFFFFFF, map: texture, transparent: false} );
- // var base = new THREE.CubeGeometry(500,1000,500,10,10,10);
- // var baseobject = new THREE.Mesh(base, base_material);
- var baseobject = new THREE.Mesh( new THREE.CylinderGeometry( 200, 100 , 1000, 20, 5, true ), base_material);
- baseobject.position.set( x, y-depth-500, z );
- baseobject.scale.set(scale,scale,scale);
- group.add(baseobject);
- this.mesh = group;
- scene.add(group);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement