Skip to content

mihailik/three-g

Repository files navigation

THREE-g — galaxy primitives for playing with THREE.js

Generates a mesh of light spots in 3D space, extremely efficiently.

const m = massSpotMesh({
  spots: [...Array(4000)].map(() => ({
  x: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
  y: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
  z: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
  mass: Math.random() * 0.01,
  rgb: new THREE.Color().setHSL(-Math.sqrt(Math.sqrt(Math.random())) + 1, 1, 0.3).getHex()
  }))
});

Live demo: https://raw.githack.com/mihailik/three-g/refs/heads/main/index.html

Live demo of rotating green cube

Mesh parameters

  • spots particles that may have coordinates, colour and mass
  • get if metrics of the spots are stored elsewhere, you can provide them via this callback

License

MIT   Oleg Mihailik's face Oleg Mihailik

About

THREE.js galaxy primitives

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published