const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 10000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Create particle variables
const particleCount = 1000;
const particles = new THREE.Geometry();
const pMaterial = new THREE.ParticleBasicMaterial({
color: 'red',
size: 20
});
// Generate individual particles
for (let p = 0; p < particleCount; p++) {
const pX = Math.random() * 500 - 250;
const pY = Math.random() * 500 - 250;
const pZ = Math.random() * 500 - 250;
const particle = new THREE.Vertex(
new THREE.Vector3(pX, pY, pZ)
);
particles.vertices.push(particle);
}
// Instantiate the particle system
const particleSystem = new THREE.ParticleSystem(
particles,
pMaterial);
// Add the particle system to the scene
scene.add(particleSystem);
function render() {
particleSystem.rotation.y += 0.01;
renderer.render(scene, camera);
requestAnimationFrame(render);
}
render();
{/*Currently, when running the code, all I see is a black canvas element on the page with no visible results.*/}