Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用THREE.js创建简单的粒子系统? 最后,我要做的是创建一个简单的粒子系统,它围绕着一个圆圈,中间有这个地名。粒子四处移动,最终“消失”并重新创建。我对three.js比较陌生。我已经试图找到一个解决方案,但要么所有的教程都太旧了,很多东西都改变了,要么教程不适合我想做的事情。以下是我到目前为止的情况。它创建了一个圆形,周围有像素,但我不能让它们移动。那就是我需要你们帮助的地方。谢谢 var scene = new THREE.Scene(); var VIEW_ANGLE = window.innerWidth / -2, NEAR = 0.1, FAR = 1000; var camera = new THREE.OrthographicCamera( VIEW_ANGLE, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, NEAR, FAR); // pull the camera position back camera.position.z = 300; var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth , window.innerHeight ); document.body.appendChild( renderer.domElement ); // Create the particle variables var particleCount = 1000; var particles = new THREE.Geometry(); var particle_Material = new THREE.PointsMaterial({ color: 'red', size: 1 }); var min = -10, max = 10; // Create the individual particles for (var i = 0; i < particleCount; i++) { var radius = 200; var random = Math.random(); var variance = Math.random(); var max = 10, min = -10; radius += (Math.floor(variance * (max - min + 1)) + min); var pX = radius * Math.cos(random * (2 * Math.PI)), pY = radius * Math.sin(random * (2 * Math.PI)), pZ = Math.random() * 100; var particle = new THREE.Vector3( pX,pY,pZ ); particle.velocity = new THREE.Vector3( 0, -Math.random(), 0 ); // Add the particle to the geometry particles.vertices.push(particle); } // Create the particle system var particleSystem = new THREE.Points( particles,particle_Material ); particleSystem.sortParticles = true; // Add the particle system to the scene scene.add(particleSystem); // Animation Loop function render() { requestAnimationFrame(render); var pCount = particleCount; while(pCount--) { // Get particle var particle = particles.vertices[pCount]; console.log(particle); particle.y -= Math.random(5) * 10; console.log(particle); } renderer.render(scene,camera); } render(); var scene=new THREE.scene(); var VIEW_ANGLE=window.innerWidth/-2, 接近=0.1, FAR=1000; var摄像机=新的三个正交摄像机(视角, window.innerWidth/2, window.innerHeight/2, window.innerHeight/-2, 近的 远); //将摄像头位置向后拉 摄像机位置z=300; var renderer=new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth、window.innerHeight); document.body.appendChild(renderer.doElement); //创建粒子变量 var particleCount=1000; var particles=新的3.Geometry(); var particle_Material=新的三点材质({ 颜色:“红色”, 尺码:1 }); var min=-10, 最大值=10; //创建单个粒子 对于(变量i=0;i_Javascript_Three.js_Particles_Particle System - Fatal编程技术网

Javascript 如何使用THREE.js创建简单的粒子系统? 最后,我要做的是创建一个简单的粒子系统,它围绕着一个圆圈,中间有这个地名。粒子四处移动,最终“消失”并重新创建。我对three.js比较陌生。我已经试图找到一个解决方案,但要么所有的教程都太旧了,很多东西都改变了,要么教程不适合我想做的事情。以下是我到目前为止的情况。它创建了一个圆形,周围有像素,但我不能让它们移动。那就是我需要你们帮助的地方。谢谢 var scene = new THREE.Scene(); var VIEW_ANGLE = window.innerWidth / -2, NEAR = 0.1, FAR = 1000; var camera = new THREE.OrthographicCamera( VIEW_ANGLE, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, NEAR, FAR); // pull the camera position back camera.position.z = 300; var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth , window.innerHeight ); document.body.appendChild( renderer.domElement ); // Create the particle variables var particleCount = 1000; var particles = new THREE.Geometry(); var particle_Material = new THREE.PointsMaterial({ color: 'red', size: 1 }); var min = -10, max = 10; // Create the individual particles for (var i = 0; i < particleCount; i++) { var radius = 200; var random = Math.random(); var variance = Math.random(); var max = 10, min = -10; radius += (Math.floor(variance * (max - min + 1)) + min); var pX = radius * Math.cos(random * (2 * Math.PI)), pY = radius * Math.sin(random * (2 * Math.PI)), pZ = Math.random() * 100; var particle = new THREE.Vector3( pX,pY,pZ ); particle.velocity = new THREE.Vector3( 0, -Math.random(), 0 ); // Add the particle to the geometry particles.vertices.push(particle); } // Create the particle system var particleSystem = new THREE.Points( particles,particle_Material ); particleSystem.sortParticles = true; // Add the particle system to the scene scene.add(particleSystem); // Animation Loop function render() { requestAnimationFrame(render); var pCount = particleCount; while(pCount--) { // Get particle var particle = particles.vertices[pCount]; console.log(particle); particle.y -= Math.random(5) * 10; console.log(particle); } renderer.render(scene,camera); } render(); var scene=new THREE.scene(); var VIEW_ANGLE=window.innerWidth/-2, 接近=0.1, FAR=1000; var摄像机=新的三个正交摄像机(视角, window.innerWidth/2, window.innerHeight/2, window.innerHeight/-2, 近的 远); //将摄像头位置向后拉 摄像机位置z=300; var renderer=new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth、window.innerHeight); document.body.appendChild(renderer.doElement); //创建粒子变量 var particleCount=1000; var particles=新的3.Geometry(); var particle_Material=新的三点材质({ 颜色:“红色”, 尺码:1 }); var min=-10, 最大值=10; //创建单个粒子 对于(变量i=0;i

Javascript 如何使用THREE.js创建简单的粒子系统? 最后,我要做的是创建一个简单的粒子系统,它围绕着一个圆圈,中间有这个地名。粒子四处移动,最终“消失”并重新创建。我对three.js比较陌生。我已经试图找到一个解决方案,但要么所有的教程都太旧了,很多东西都改变了,要么教程不适合我想做的事情。以下是我到目前为止的情况。它创建了一个圆形,周围有像素,但我不能让它们移动。那就是我需要你们帮助的地方。谢谢 var scene = new THREE.Scene(); var VIEW_ANGLE = window.innerWidth / -2, NEAR = 0.1, FAR = 1000; var camera = new THREE.OrthographicCamera( VIEW_ANGLE, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, NEAR, FAR); // pull the camera position back camera.position.z = 300; var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth , window.innerHeight ); document.body.appendChild( renderer.domElement ); // Create the particle variables var particleCount = 1000; var particles = new THREE.Geometry(); var particle_Material = new THREE.PointsMaterial({ color: 'red', size: 1 }); var min = -10, max = 10; // Create the individual particles for (var i = 0; i < particleCount; i++) { var radius = 200; var random = Math.random(); var variance = Math.random(); var max = 10, min = -10; radius += (Math.floor(variance * (max - min + 1)) + min); var pX = radius * Math.cos(random * (2 * Math.PI)), pY = radius * Math.sin(random * (2 * Math.PI)), pZ = Math.random() * 100; var particle = new THREE.Vector3( pX,pY,pZ ); particle.velocity = new THREE.Vector3( 0, -Math.random(), 0 ); // Add the particle to the geometry particles.vertices.push(particle); } // Create the particle system var particleSystem = new THREE.Points( particles,particle_Material ); particleSystem.sortParticles = true; // Add the particle system to the scene scene.add(particleSystem); // Animation Loop function render() { requestAnimationFrame(render); var pCount = particleCount; while(pCount--) { // Get particle var particle = particles.vertices[pCount]; console.log(particle); particle.y -= Math.random(5) * 10; console.log(particle); } renderer.render(scene,camera); } render(); var scene=new THREE.scene(); var VIEW_ANGLE=window.innerWidth/-2, 接近=0.1, FAR=1000; var摄像机=新的三个正交摄像机(视角, window.innerWidth/2, window.innerHeight/2, window.innerHeight/-2, 近的 远); //将摄像头位置向后拉 摄像机位置z=300; var renderer=new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth、window.innerHeight); document.body.appendChild(renderer.doElement); //创建粒子变量 var particleCount=1000; var particles=新的3.Geometry(); var particle_Material=新的三点材质({ 颜色:“红色”, 尺码:1 }); var min=-10, 最大值=10; //创建单个粒子 对于(变量i=0;i,javascript,three.js,particles,particle-system,Javascript,Three.js,Particles,Particle System,您可以使用 particleSystem.rotateZ(0.1); ..在渲染循环中。0.1是希望粒子系统每帧旋转的量 希望有帮助

您可以使用

particleSystem.rotateZ(0.1);
..在渲染循环中。0.1是希望粒子系统每帧旋转的量

希望有帮助