Below is my snippet, For now i want to position a single particle on the sphere. How can i combine partical and sphere geometries together ? Once this is achieved i want to render particles on top of the sphere dynamically
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 500;
renderer = new THREE.WebGLRenderer();
renderer.setClearColor( 0x000000 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
scene = new THREE.Scene();
loader = new THREE.TextureLoader();
loader.load( '<%= image_path('earthmap1k.jpg') %>', function ( texture ) {
geometry = new THREE.SphereGeometry( 200, 20, 20 );
material = new THREE.MeshBasicMaterial( { map: texture, overdraw: 0.5, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
} );
function addPartical() {
var distance = 200;
ggeometry = new THREE.Geometry();
vertex = new THREE.Vector3();
theta = THREE.Math.randFloatSpread(360);
phi = THREE.Math.randFloatSpread(360);
vertex.x = distance * Math.sin(theta) * Math.cos(phi);
vertex.y = distance * Math.sin(theta) * Math.sin(phi);
vertex.z = distance * Math.cos(theta);
ggeometry.vertices.push(vertex);
particles = new THREE.Points(ggeometry, new THREE.PointsMaterial({color: 0xffffff}));
particles.boundingSphere = 50;
scene.add(particles);
};
}
function animate() {
requestAnimationFrame( animate );
addParticle();
render();
}
function render() {
renderer.render( scene, camera );
}
如果要将两个对象视为一个对象,请使用THREE.Object3D()
并对其进行操作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.