Giter Club home page Giter Club logo

mathbox's Introduction

MathBox

Presentation-quality WebGL math graphing

MathBox

MathBox is a library for rendering presentation-quality math diagrams in a browser using WebGL. Built on top of Three.js and ShaderGraph, it provides a clean API to visualize mathematical relationships and animate them declaratively.

MathBox is used through its JS-based DOM.

For background, see the article series on Acko.net.

Demos:

Presentations:

Note: this repo uses submodules, clone it with --recursive or do a git submodule update --init after cloning.


Installation

  • via npm:

    npm install mathbox
  • or CDN:

    <script
      type="text/javascript"
      src="https://cdn.jsdelivr.net/npm/mathbox@latest/build/bundle/mathbox.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/mathbox@latest/build/mathbox.css"
    />

Open the included /examples to see more demos.


Docs & Help

See:

Join us in the MathBox Google Group or #mathbox on Freenode.


Basic Usage

Construct a MathBox instance using the provided mathBox() constructor:

import { mathBox } from "mathbox";
import "mathbox/mathbox.css";

const mathbox = mathBox(options);

const three = mathbox.three;
// three.renderer, three.scene, three.camera

See threestrap for all available options. e.g. To spawn inside a specific element, do:

const element = document.querySelector("#my-thing");
const mathbox = MathBox.mathBox({ element: element });

On initialization, it returns a MathBox API object, wrapping the MathBox <root/>. You can spawn new nodes:

<cartesian
  range={[
    [-2, 2],
    [-1, 1],
    [-1, 1],
  ]}
  scale={[2, 1, 1]}
>
  <axis axis={1} />
  <axis axis={2} />
</cartesian>

via

const view = mathbox
  .cartesian({
    range: [
      [-2, 2],
      [-1, 1],
      [-1, 1],
    ],
    scale: [2, 1, 1],
  })
  .axis({
    axis: 1,
  })
  .axis({
    axis: 2,
  });

You can select objects using .select() and a CSS-like selector to get a jQuery-like selection:

mathbox.select("cartesian > axis");

Use .print(), .inspect() and .debug() to show information about a selection.


Related Projects


MathBox and ShaderGraph (c) Steven Wittens 2013-2022. MIT License.

Libraries and 3rd party shaders (c) their respective authors.

mathbox's People

Contributors

unconed avatar christopherchudzicki avatar mgold avatar sritchie avatar jamescrook avatar jroper18 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.