DIR : /home/kozerus/public_html/jkwii/js/jsdoit/rotationplane/index.js
/home/kozerus/public_html/jkwii/js/jsdoit/rotationplane
var camera, scene, renderer;
var planes = [], rotations = [];
$(document).ready(function(){
init();
animate();
})
function init(){
var width = $(window).width();
var height = $(window).height();
//カメラ
camera = new THREE.Camera(75, width / height, 1, 10000);
camera.position.z = 1000;
//scene
scene = new THREE.Scene();
//object
for(var i = 0; i<20; i++){
var pos_deg = 360 / 20 * i;
var pos_rad = Math.PI * pos_deg / 180;
var material = new THREE.MeshBasicMaterial({color:Math.random() * 0xffffff, opacity:0.5, reflectivity:true});
var plane = new THREE.Mesh(new THREE.Plane(150, 150), material);
plane.position.z = 700 * Math.cos(pos_rad);
plane.position.x = - 700 * Math.sin(pos_rad);
scene.addObject(plane);
planes.push(plane);
rotations.push(pos_deg);
}
//レンダー
renderer = new THREE.CanvasRenderer();
renderer.setSize(width, height);
document.body.appendChild(renderer.domElement);
}
function animate(){
// Include examples/js/RequestAnimationFrame.js for cross-browser compatibility.
requestAnimationFrame(animate);
render();
stats.update();
}
function render(){
var _length = planes.length;
for(var i = 0; i<_length; i++){
rotations[i] += 0.1;
var pos_rad = rotations[i] * Math.PI / 180;
var plane = planes[i];
plane.position.z = 700 * Math.cos(pos_rad);
plane.position.x = - 700 * Math.sin(pos_rad);
}
//mesh.rotation.x += 0.01;
//mesh.rotation.y += 0.02;
renderer.render(scene, camera);
}
//
koh5_pano
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer