function init() {
projector = new THREE.Projector(), objects = [];
megalit = new THREE.Object3D();
container = document.createElement( 'div' );
document.body.appendChild( container );
var info = document.createElement( 'div' );
info.style.position = 'absolute';
info.style.top = '10px';
info.style.width = '100%';
info.style.textAlign = 'center';
info.innerHTML = 'Drag to spin the cube';
container.appendChild( info );
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.y = 150;
camera.position.z = 500;
scene = new THREE.Scene();
var menu = "Подарки";
var menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 60 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 120, -10* Math.sin(text.rotation.y));
var text1=text;
var menu = "Счет";
menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 60 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 95, -10* Math.sin(text.rotation.y));
var text2 = text;
var menu = "Выход";
var menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 60 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 70, -10* Math.sin(text.rotation.y));
var text3 = text;
var menu = "Новое сообщение";
var menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 180 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 120, -10* Math.sin(text.rotation.y));
var text4 = text;
var menu = "Список сообщений";
var menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 180 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 95, -10* Math.sin(text.rotation.y));
var text5 = text;
var menu;
if (M_J=1){
menu = "Фаваритки";
}
else{
menu = "Фавориты";
}
var menu_text = new THREE.TextGeometry( menu, {
size: 14,
height: 5,
curveSegments: 2,
font: "arial"
});
menu_text.computeBoundingBox();
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
var text = new THREE.Mesh( menu_text, textMaterial );
text.rotation.y = 180 * Math.PI/180;
text.position.set(10* Math.cos(text.rotation.y), 70, 10* Math.sin(text.rotation.y));
var text6 = text;
// Cube
var geometry = new THREE.CubeGeometry( 110, 300, 5 );
var material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, opacity: 0.5, transparent: true });
cube1 = new THREE.Mesh( geometry, material );
cube1.rotation.y = 120 * Math.PI/180;
cube1.position.set(-50* Math.cos(cube1.rotation.y), 0, 50* Math.sin(cube1.rotation.y));
var material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, opacity: 0.5, transparent: true });
cube2 = new THREE.Mesh( geometry, material );
cube2.rotation.y = 240 * Math.PI/180;
cube2.position.set(-50* Math.cos(cube2.rotation.y), 0, 50* Math.sin(cube2.rotation.y));
var material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, opacity: 0.5, transparent: true });
cube3 = new THREE.Mesh( geometry, material );
cube3.rotation.y = 360 * Math.PI/180;
cube3.position.set(-50* Math.cos(cube3.rotation.y), 0, 50* Math.sin(cube3.rotation.y));
// для прорисовки
megalit.add(cube1);
megalit.add(cube2);
megalit.add(cube3);
megalit.add(text1);
megalit.add(text2);
megalit.add(text3);
megalit.add(text4);
megalit.add(text5);
megalit.add(text6);
// добавление текста
scene.add( megalit );
// для выбора
objects.push(cube1);
objects.push(cube2);
objects.push(cube3);
objects.push(text1);
objects.push(text2);
objects.push(text3);
objects.push(text4);
objects.push(text5);
objects.push(text6);
|