A Mesh per point means thousands of draw calls. THREE.Points puts every position in one BufferGeometry and draws them in a single call.
Tilting the camera slightly with the mouse adds depth (parallax).
Thousands of points drawn in one call to create a starfield or floating dust.
import * as THREE from 'three';
const COUNT = 6000;
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(60, 1, 0.1, 100);
camera.position.z = 6;
const pos = new Float32Array(COUNT * 3), col = new Float32Array(COUNT * 3);
const c = new THREE.Color();
for (let i = 0; i < COUNT; i++) {
const r = 2 + Math.random() * 4, t = Math.random() * Math.PI * 2, p = Math.acos(2 * Math.random() - 1);
pos.set([r * Math.sin(p) * Math.cos(t), r * Math.sin(p) * Math.sin(t) * 0.4, r * Math.cos(p)], i * 3);
c.setHSL(0.6 + Math.random() * 0.25, 0.8, 0.65); col.set([c.r, c.g, c.b], i * 3);
}
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
const points = new THREE.Points(geo, new THREE.PointsMaterial({ size: 0.035, vertexColors: true, transparent: true, opacity: 0.9 }));
scene.add(points);
const mouse = { x: 0, y: 0 };
addEventListener('pointermove', e => { mouse.x = e.clientX / innerWidth - 0.5; mouse.y = e.clientY / innerHeight - 0.5; });
function resize() { renderer.setSize(innerWidth, innerHeight); camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); }
addEventListener('resize', resize); resize();
renderer.setAnimationLoop(t => {
points.rotation.y = t * 0.00008;
camera.position.x += (mouse.x * 2 - camera.position.x) * 0.05;
camera.position.y += (-mouse.y * 2 - camera.position.y) * 0.05;
camera.lookAt(0, 0, 0);
renderer.render(scene, camera);
});A Mesh per point means thousands of draw calls. THREE.Points puts every position in one BufferGeometry and draws them in a single call.
Tilting the camera slightly with the mouse adds depth (parallax).