Code Monkey home page Code Monkey logo

three-glow-mesh's Introduction

๐ŸŒŸ Three Glow Mesh

Create glow mesh with any ThreeJS geometry.

three-glow-mesh is based off the awesome work by stemkoski. The original idea and motivation is laid out by the author in this link.

Install

npm install three-glow-mesh

Note that three-glow-mesh requires three >= 0.102.0 as a peer dependency.

Use

Import createGlowMesh and supply any ThreeJS geometry and a valid options object.

Here is an example of a common way to create a glow mesh:

import { Mesh, Renderer, Scene } from 'three';
import { createGlowMesh, defaultOptions } from './three-glow-mesh';

const originalMesh = new Mesh(...);

// We can optionally import and overwrite the defaultOptions
const options = {
  ...defaultOptions,
  backside: true,
  coefficient: 0.5,
  color: 'gold',
  size: 2,
  power: 1
};
// You can reference the original mesh geometry or provide a custom one.
const glowMesh = createGlowMesh(originalMesh.geometry, options);
// You can add the glow mesh to any ThreeJS object (e.g. camera, scene),
// but it is common practice to just add and associate it with the original mesh.
originalMesh.add(glowMesh);

// three boilerplate (this is pseudocode)
const scene = new Scene();
const renderer = new WebGLRenderer({antialias: true});
scene.add(mesh);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
renderer.render(scene, camera);

Examples

In the following Codesandbox instances, edit the options variables to experiment with glow effects! You can test various values of coefficient, color, power using this tool.

Basic Example

basic-example

Globe Example

typescript-example

three-glow-mesh's People

Contributors

chrisrzhou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.