bekas var;
zarah var;
var camera;
var scene;
var renderer;
var mouseX = 0;
var mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
zarah var = [];
var particleImage = new Image();//THREE.ImageUtils.loadTexture( "img/ParticleSmoke.png" );
particleImage.src = 'images/ParticleSmoke.png';
fungsi init() {
bekas = document.createElement('div');
document.body.appendChild(bekas);
kamera = THREE.PerspectiveCamera(75, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
camera.position.z = 1000;
pemandangan = THREE.Scene();
scene.add(kamera);
renderer = THREE.CanvasRenderer();
renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
var bahan = TIGA.Bahan Asas Zarah baharu( { peta: TIGA. Tekstur baharu (Imej zarah) } );
untuk (var i = 0; i < 500; i ) {
zarah = Zarah3D( bahan baharu);
zarah.kedudukan.x = Math.rawak() * 2000 - 1000;
zarah.kedudukan.y = Math.rawak() * 2000 - 1000;
zarah .position.z = Math.random() * 2000 - 1000;
particle.scale.x = particle.scale.y = 1;
scene.add( particle );
zarah. tolak(zarah);
}
container.appendChild( renderer.domElement );
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', on🎜falseTouch);
setInterval( gelung, 1000 / 60 );
}
fungsi padaDocumentMouseMove( acara ) {
mouseX = event.clientX - windowHalfX;
mouseY = event.clientY - windowHalfY;
}
fungsi padaDocumentTouchStart( acara ) {
jika ( event.touches.length == 1 ) {
event.preventDefault();
mouseX = event.touches[ 0 ].pageX - windowHalfX;
mouseY = event.touches[ 0 ].pageY - windowHalfY;
}
}
fungsi padaDocumentTouchMove( acara ) {
jika ( event.touches.length == 1 ) {
event.preventDefault();
mouseX = event.touches[ 0 ].pageX - windowHalfX;
mouseY = event.touches[ 0 ].pageY - windowHalfY;
}
}
//
gelung fungsi() {
untuk(var i = 0; i
zarah var = zarah[i];
particle.updatePhysics();
dengan(kedudukan zarah)
{
jika(y<-1000) y =2000;
jika(x>1000) x-=2000;
lain jika(x<-1000) x =2000;
jika(z>1000) z-=2000;
lain jika(z<-1000) z =2000;
}
}
camera.position.x = ( mouseX - camera.position.x ) * 0.05;
camera.position.y = ( - mouseY - camera.position.y ) * 0.05;
camera.lookAt(scene.position);
renderer.render( pemandangan, kamera );
}