나는 모든 예제를 실제로 시도했지만 웹 검색은 몇 시간 동안했지만 작동하지 못했습니다! THREE.js 입자 시스템의 단일 입자에 액세스
는 그래서 단순히 다음과 같이 떨어지는 눈 시뮬레이션 작은 입자 시스템 구현하려고 : http://www.aerotwist.com/tutorials/creating-particles-with-three-js/을하지만 난 단지 전체에 액세스 할 수 있습니다. 내가 그것을 회전시킬 수 있다는 것을 의미하지만 꼭지점을 반복하려고하면 전체 애니메이션이 딸꾹질을 얻고 있습니다! 나는 정말로 여기에서 약간의 도움에 감사 할 것이다!
var partikelGeo = new THREE.Geometry();
var partikelMaterial = new THREE.ParticleBasicMaterial({
color:0xffffff,
size: 10,
map: THREE.ImageUtils.loadTexture('snowflake2.png'),
blending: THREE.AdditiveBlending,
transparent:true
});
var partikelAnzahl = 3500;
for (var p = 0; p < partikelAnzahl; p++) {
var pX = Math.random() * 1000 -500;
var pY = Math.random() * 1000 -500;
var pZ = Math.random() * 1000 -500;
var partikel = new THREE.Vertex(new THREE.Vector3(pX,pY,pZ));
partikel.velocity = new THREE.Vector3(0,-Math.random(),0);
partikelGeo.vertices.push(partikel);
}
var partikelSystem = new THREE.ParticleSystem(partikelGeo, partikelMaterial);
partikelSystem.sortParticles = true;
scene.add(partikelSystem);
-> 마우스 클릭
var frame = 0;
function animate(){
// request new frame
requestAnimationFrame(function(){
animate();
});
// render
render();
}
animate();
var check = 0;
onmousedown = function(){
if (check) {
check = 0;
}else{
check = 1;
}
}
function render() {
if (check) {
clickDo();
}
camera.lookAt(new THREE.Vector3(0,0,0));
renderer.render(scene,camera);
}
function clickDo() {
frame++;
partikelSystem.rotation.y += 0.01;
var pCount = partikelAnzahl;
while(pCount--) {
// get the particle
var particle =
partikelGeo.vertices[pCount];
// check if we need to reset
if(particle.position.y < -200) {
particle.position.y = 200;
particle.velocity.y = 0;
}
// update the velocity with
// a splat of randomniz
particle.velocity.y -=
Math.random() * .1;
// and the position
particle.position.addSelf(
particle.velocity);
}
// flag to the particle system
// that we've changed its vertices.
partikelSystem.
geometry.
__dirtyVertices = true;
}
에 & 애니메이션을 렌더링
라
: -> 입자 시스템 설정: -
여기
는 핵심 부품이다
이 입자에 무엇을 원하는가 : 당신이 첨가제의 혼합을 사용할 때 난 그냥 시도하지 귀하의 입자를 정렬하는 것이 좋습니다까요? 일반적으로이 목적을 위해 쉐이더를 사용해야합니다 (여기 튜토리얼 http://www.aerotwist.com/tutorials/an-introduction-to-shaders-part-1/). 하지만 단순히 입자의 위치를 바꾸고 싶다면 좌표계를 변경하고 좌표를 바꾼 다음 플래그를 설정하십시오 partikelGeo.verticesNeedUpdate를 true로 설정하십시오 (이전 버전 인 three.js에서는 partikelGeo.__ dirtyVertices = true라고 생각합니다).). – dIsoVi