Вот как советовали изменил код.
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();
// Cube
var geometry = new THREE.CubeGeometry( 100, 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 });
// вот этот код когда удолял все работало
->
var geometry = new THREE.CubeGeometry( 100, 200, 5);
var Texture = new THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' );
var material = new THREE.MeshBasicMaterial( { map: Texture } );
->
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 = new THREE.Object3D();
megalit.add(cube1);
megalit.add(cube2);
megalit.add(cube3);
projector = new THREE.Projector(), objects = [];
objects.push(cube1);
objects.push(cube2);
objects.push(cube3);
scene.add( megalit );
// Plane
var geometry = new THREE.PlaneGeometry( 200, 200 );
geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );
var material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, opacity: 0.5, transparent: true } );
//plane = new THREE.Mesh( geometry, material );
//scene.add( plane );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
var PI2 = Math.PI * 2;
particleMaterial = new THREE.SpriteCanvasMaterial( {
color: 0x000000,
program: function ( context ) {
context.beginPath();
context.arc( 0, 0, 0.5, 0, PI2, true );
context.fill();
}
});
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
//
function onDocumentMouseDown( event ) {
event.preventDefault();
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'mouseup', onDocumentMouseUp, false );
document.addEventListener( 'mouseout', onDocumentMouseOut, false );
mouseXOnMouseDown = event.clientX - windowHalfX;
targetRotationOnMouseDown = targetRotation;
//event.preventDefault();// установка примитивов по умолчания
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );// прямой вектор
projector.unprojectVector( vector, camera );//прожектор камеры
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );//Класс Raycaster создан на основе класса Ray и обеспечивает обнаружение пересечения 3D-объектов.
var intersects = raycaster.intersectObjects( objects );//объект проверямый на пересечение с вектором
if ( intersects.length > 0 ) {//количество объектов
intersects[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );//цвет материала объекта
//var particle = new THREE.Sprite( particleMaterial );//создание точки
//particle.position = intersects[ 0 ].point;// присвоение координат точке
//particle.scale.x = particle.scale.y = 16;//диаметр точки
//scene.add( particle );//добавление на сцену точки
}
}
function onDocumentMouseMove( event ) {
mouseX = event.clientX - windowHalfX;
if(mouseX>mouseX1){
phi=phi+0.05
}
else{
phi=phi-0.05;
}
mouseX1=mouseX;
targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
megalit.rotation.y = phi;
}
function onDocumentMouseUp( event ) {
document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
}
function onDocumentMouseOut( event ) {
document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
}
function onDocumentTouchStart( event ) {
if ( event.touches.length === 1 ) {
event.preventDefault();
mouseXOnMouseDown = event.touches[ 0 ].pageX - windowHalfX;
targetRotationOnMouseDown = targetRotation;
}
}
function onDocumentTouchMove( event ) {
if ( event.touches.length === 1 ) {
event.preventDefault();
mouseX = event.touches[ 0 ].pageX - windowHalfX;
targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.05;
}
}
//
function animate() {
requestAnimationFrame( animate );
render();
stats.update();
}
function render() {
renderer.render( scene, camera );
}
</script>
</body>
</html>
но как только добавил текстуру
var geometry = new THREE.CubeGeometry( 100, 200, 5);
var Texture = new THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' );
var material = new THREE.MeshBasicMaterial( { map: Texture } );
просходит ошибка библиотеки.