0.0.1 • Published 4 years ago

three-raymarch v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

three-raymarch

Raymarching Plugin for three.js

Install

$ npm install three-raymarch

How to Use

import {
  Scene,
  Vector3,
  Color,
} from 'three';

import { 
  ObjectSpaceRaymarch,
  ObjectSpaceRaymarchStandardMaterial,
} from 'three-raymarch';

const material = new ObjectSpaceRaymarchStandardMaterial({
  getDistanceChunk: `
    float sdSphere(vec3 p, float r) {
    return length(p) - r;
    }

    float getDistance(vec3 p) {
    p = mod(p, 1.0) - 0.5;
    return sdSphere(p, 0.4);
    }`,
  size: new Vector3(2, 2, 2)
  color: new Color(0x2194ce),
  emissive: new Color(0x000000),
  roughness: 0.5,
  metalness: 0.5,
});

const raymarch = new ObjectSpaceRaymarch(material);

const scene = new Scene();
scene.add(raymarch);

Docs

https://aadebdeb.github.io/three-raymarch/docs/

Examples