ggwzrd / threejs-galaxy

Three.js Galaxy generator

Home Page:https://wzrd.mk/galaxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Milkyway Galaxy

threejs-galaxy

DeepScan grade GitHub last commit npm bundle size npm NPM

This project is heavily inspired by Yuri Artiukh's video [aka @akella] in which he explained the math and architecture behing the website viverse.com [outdated].

I decided to make a module out of this since everyone should be able to generate their own galaxies and the creative possibilities are infinite. 👨‍🚀

Check a few example that I have created on wzrd.mk/galaxy

I do not provide the textures of the particles and stars to ensure that all galaxies are unique. You can find a basic example in /assets

Install

npm

  npm install threejs-galaxy

yarn

  yarn add threejs-galaxy

Getting started

All you need to generate a galaxy is the snippet below.

import Galaxy from 'threejs-galaxy'

import particleTexture from './assets/particle-example.png'

const galaxy = new Galaxy({
  canvas: document.querySelector('#c'),
  window: window,
  layers: [
    {
      color: '#FFFFFF',
      texture: particleTexture,
      count: 10000,
    },
  ]
})

galaxy.render()

In order to start the animation you will need to add the following code.

galaxy.play()

Full example can be found in examples/basic.ts

Contributing

Consult CONTRIBUTING.md to start contributing to threejs-galaxy.

Credits

Yuri Artiukh [aka @akella]

License

The MIT License (MIT)

About

Three.js Galaxy generator

https://wzrd.mk/galaxy

License:MIT License


Languages

Language:JavaScript 56.7%Language:GLSL 29.6%Language:TypeScript 12.6%Language:HTML 0.9%Language:CSS 0.3%