1.4.3 • Published 2 years ago

marcher.js v1.4.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

A library for writing raymarching code in JavaScript.

ma

Install

npm i marcher.js

Usage

import * as marcher from "marcher.js";

// create Marcher object
const mar = new marcher.Marcher({
  antialias: false,
});

// create SDF material
const mat = new marcher.SDFMaterial();
// add a black color material
mat.addColorMaterial("1.0", 0, 0, 0);
// use SDF material
mar.setMaterial(mat);

// create SDF map function
const map = new marcher.SDFMapFunction();

// create a layer
const layer = new marcher.SDFLayer();

// create a box SDF
const box = new marcher.BoxSDF({
  sdfVarName: "d1",
});
// add box SDF to the layer
layer.addPrimitive(box);
// make round corners for box SDF
box.round(0.1);

// add layer to the map function
map.addLayer(layer);

// use the map function
mar.setMapFunction(map);

// then you get the whole raymarching fragment shader
// just paste it into the shadertoy and see the magic
// https://www.shadertoy.com/new
console.log(mar.fragmentShader);

Features

  • Write raymarching code in JavaScript (fully customizable)
  • Zero dependency
  • Fully typed
  • Shadertoy support

Essentials

Basic

ma

Demo: https://codesandbox.io/s/basic-uxqbgh?file=/src/app.ts

Primitive

ma

Demo: https://codesandbox.io/s/primitive-zcuy2q?file=/src/app.ts

Boolean

ma

Demo: https://codesandbox.io/s/boolean-13qfo4?file=/src/app.ts

Polygon

ma

Demo: https://codesandbox.io/s/polygon-6ipxc1?file=/src/app.ts

Triangle

ma

Demo: https://codesandbox.io/s/triangle-qrrbpe?file=/src/app.ts

Bezier

ma

Demo: https://codesandbox.io/s/bezier-syd12e?file=/src/app.ts

Uberprim

ma

Demo: https://codesandbox.io/s/uberprim-wtj8y0?file=/src/app.ts

MagicaCSG

ma

Demo: https://codesandbox.io/s/magicacsg-g8ls17?file=/src/app.ts

Gyroid

ma

Demo: https://codesandbox.io/s/gyroid-i36q79?file=/src/app.ts

Examples

CSG

ma

Demo: https://codesandbox.io/s/csg-kmuzzi?file=/src/app.ts

Poke Ball

ma

Demo: https://codesandbox.io/s/poke-ball-j7bwy7?file=/src/app.ts

API

Just TypeScript and you get it :)

Author

👤 alphardex

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

1.3.7

2 years ago

1.2.8

2 years ago

1.3.6

2 years ago

1.2.7

2 years ago

1.3.5

2 years ago

1.2.6

2 years ago

1.4.3

2 years ago

1.3.4

2 years ago

1.4.2

2 years ago

1.3.3

2 years ago

1.4.1

2 years ago

1.3.2

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago