Код загрузки одной модели есть, но не пойму как загрузить несколько 1.dae, 2.dae, 3.dae и т.п.
код:
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var container;
var camera, scene, renderer, objects;
var dae, skin;
var windowHalfX = window.innerWidth ;
var windowHalfY = window.innerHeight ;
var mouseX = 0, mouseY = 0;
var loader = new THREE.ColladaLoader();
loader.options.convertUpAxis = true;
loader.load( '1.dae', function ( collada ) {
dae = collada.scene;
skin = collada.skins[ 0 ];
dae.scale.x = dae.scale.y = dae.scale.z = 1.100;
dae.updateMatrix();
init();
animate();
});
function init() {
container = document.createElement( 'div');
document.getElementById("viewport").appendChild( container );
camera = new THREE.OrthographicCamera( 800 / - 30, 800/ 30, 600 / 30, 600 / - 30, - 500, 1000 );
camera.position.x = 0;
camera.position.y = 0;
camera.position.z = 0;
scene = new THREE.Scene();
// Grid
var size = 10, step = 1;
var geometry = new THREE.Geometry();
for ( var i = - size; i <= size; i += step ) {
geometry.vertices.push( new THREE.Vector3( - size, 0, i ) );
geometry.vertices.push( new THREE.Vector3( size, 0, i ) );
geometry.vertices.push( new THREE.Vector3( i, 0, - size ) );
geometry.vertices.push( new THREE.Vector3( i, 0, size ) );
}
var material = new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } );
var line = new THREE.Line( geometry, material );
line.type = THREE.LinePieces;
scene.add( line );
scene.add( dae );
scene.add( new THREE.AmbientLight( 0xcccccc ) );
renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize( 800, 600 );
container.appendChild( renderer.domElement );
document.getElementById("viewport").addEventListener( 'mousemove', onDocumentMouseMove, false );
}
function onDocumentMouseMove( event ) {
mouseX = ( event.clientX );
mouseY = ( event.clientY );
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
var timer = Date.now() * 0.0004;
dae.position.x = 0;
dae.position.y = 0;
dae.position.z = 0;
//dae.rotation.y = -mouseY/90;
camera.rotation.x = -90;
renderer.render( scene, camera );
}