How to use three-nebula - 10 common examples

To help you get started, we’ve selected a few three-nebula examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creativelifeform / three-nebula / website / components / Examples / SpriteRendererPointZone / init.js View on Github external
const createEmitter = (color1, color2) => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(4, 16), new Span(0.01)))
    .addInitializers([
      new Position(new PointZone(0, 0)),
      new Mass(1),
      new Radius(6, 12),
      new Life(3),
      new RadialVelocity(45, new Vector3D(0, 1, 0), 180),
    ])
    .addBehaviours([
      new Alpha(1, 0),
      new Scale(0.3, 0.6),
      new Color(color1, color2),
    ])
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / EightDiagrams / init.js View on Github external
const createEmitter = ({ colorA, colorB, camera, renderer }) => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(5, 7), new Span(0.01, 0.02)))
    .setInitializers([
      new Mass(1),
      new Life(2),
      new Body(createSprite()),
      new Radius(80),
      new RadialVelocity(200, new Vector3D(0, 0, -1), 0),
    ])
    .setBehaviours([
      new Alpha(1, 0),
      new Color(colorA, colorB),
      new Scale(1, 0.5),
      new CrossZone(new ScreenZone(camera, renderer), 'dead'),
      new Force(0, 0, -20),
    ])
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / MeshRendererCollision / init.js View on Github external
const createEmitter = () => {
  const emitter = new Emitter();
  const sphere = new THREE.Mesh(
    new THREE.SphereGeometry(100, 24, 24),
    new THREE.MeshStandardMaterial({
      color: 0x2170ce,
      metalness: 0.5,
      wireframe: true,
    })
  );

  return emitter
    .setRate(new Rate(new Span(2, 5), new Span(0.5, 1)))
    .addInitializers([
      new Mass(1),
      new Radius(100),
      new Life(10, 20),
      new Body(sphere),
      new RadialVelocity(new Span(300, 500), new Vector3D(0, 1, 0), 30),
    ])
    .addBehaviours([new Scale(1), new Gravity(3), new Collision(emitter)])
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / CustomRenderer / init.js View on Github external
const createEmitter = zone => {
  const emitter = new Emitter();

  emitter
    .setRate(new Rate(new Span(4, 8), new Span(0.2, 0.5)))
    .addInitializers([
      new Mass(1),
      new Radius(100),
      new Life(2, 4),
      new RadialVelocity(400, new Vector3D(0, 1, 0), 60),
    ])
    .addBehaviours([
      new Rotate('random', 'random'),
      new Scale(1, 0.1),
      new Gravity(6),
      new CrossZone(zone, 'bound'),
      new Color(0xff0000, 'random', Infinity, ease.easeOutQuart),
    ])
    .setPosition({ x: 0, y: 0 })
    .emit();
github creativelifeform / three-nebula / website / components / Examples / MeshRenderer / init.js View on Github external
const createEmitter = ({ position, body }) => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(5, 10), new Span(0.1, 0.25)))
    .addInitializers([
      new Mass(1),
      new Radius(10),
      new Life(2, 4),
      new Body(body),
      new Position(new BoxZone(100)),
      new RadialVelocity(200, new Vector3D(0, 1, 1), 30),
    ])
    .addBehaviours([
      new Rotate('random', 'random'),
      new Scale(1, 0.1),
      new Gravity(3),
    ])
    .setPosition(position)
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / SpriteRendererSnow / init.js View on Github external
const createEmitter = (camera, renderer) => {
  const emitter = new Emitter();
  const position = new Position();

  position.addZone(new BoxZone(2500, 10, 2500));

  return emitter
    .setRate(new Rate(new Span(34, 48), new Span(0.2, 0.5)))
    .addInitializers([
      new Mass(1),
      new Radius(new Span(10, 20)),
      position,
      new Life(5, 10),
      new Body(createSnow()),
      new RadialVelocity(0, new Vector3D(0, -1, 0), 90),
    ])
    .addBehaviours([
      new RandomDrift(10, 1, 10, 0.05),
      new Rotate('random', 'random'),
      new Gravity(2),
      new CrossZone(new ScreenZone(camera, renderer, 20, '234'), 'dead'),
    ])
    .setPosition({ y: 800 })
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / SpriteRendererSnow / init.js View on Github external
const createEmitter = (camera, renderer) => {
  const emitter = new Emitter();
  const position = new Position();

  position.addZone(new BoxZone(2500, 10, 2500));

  return emitter
    .setRate(new Rate(new Span(34, 48), new Span(0.2, 0.5)))
    .addInitializers([
      new Mass(1),
      new Radius(new Span(10, 20)),
      position,
      new Life(5, 10),
      new Body(createSnow()),
      new RadialVelocity(0, new Vector3D(0, -1, 0), 90),
    ])
    .addBehaviours([
      new RandomDrift(10, 1, 10, 0.05),
      new Rotate('random', 'random'),
      new Gravity(2),
      new CrossZone(new ScreenZone(camera, renderer, 20, '234'), 'dead'),
    ])
    .setPosition({ y: 800 })
    .emit();
github creativelifeform / three-nebula / website / components / Examples / SpriteRendererGravity / init.js View on Github external
const createEmitter = () => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(10, 15), new Span(0.05, 0.1)))
    .addInitializers([
      new Body(createSprite()),
      new Mass(1),
      new Life(1, 3),
      new Position(new SphereZone(20)),
      new RadialVelocity(new Span(500, 800), new Vector3D(0, 1, 0), 30),
    ])
    .addBehaviours([
      new RandomDrift(10, 10, 10, 0.05),
      new Scale(new Span(2, 3.5), 0),
      new Gravity(6),
      new Color('#FF0026', ['#ffff00', '#ffff11'], Infinity, ease.easeOutSine),
    ])
    .setPosition({ x: 0, y: -150 })
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / MeshZone / init.js View on Github external
const createEmitter = async mesh => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(11, 15), new Span(0.02)))
    .addInitializers([
      new Position(new MeshZone(mesh, 200, THREE.Geometry)),
      new Mass(1),
      new Radius(1, 3),
      new Life(1.5),
      new Body(createSprite()),
    ])
    .addBehaviours([
      new RandomDrift(2, 2, 2),
      new Gravity(0),
      new Color(['#00aeff', '#0fa954', '#54396e', '#e61d5f']),
      new Color('random'),
    ])
    .setPosition({ x: 0, y: 0 })
    .emit();
};
github creativelifeform / three-nebula / website / components / Examples / SpriteRendererPointZone / init.js View on Github external
const createEmitter = (color1, color2) => {
  const emitter = new Emitter();

  return emitter
    .setRate(new Rate(new Span(4, 16), new Span(0.01)))
    .addInitializers([
      new Position(new PointZone(0, 0)),
      new Mass(1),
      new Radius(6, 12),
      new Life(3),
      new RadialVelocity(45, new Vector3D(0, 1, 0), 180),
    ])
    .addBehaviours([
      new Alpha(1, 0),
      new Scale(0.3, 0.6),
      new Color(color1, color2),
    ])
    .emit();