Giter VIP home page Giter VIP logo

cubecubed's Introduction

Cubecubed - A Math Visualization Library

A mathematical visualization library for playing dynamic animations right on your favorite browser.
โ€ข Producing animations with eye-soothing graphical effects.
โ€ข Built with "simple and intuitive" philosophy in mind.

Imagine ๐Ÿ’ก โ†’ Launch ๐Ÿš€ โ†’ Watch ๐Ÿฟ


Chaotic Particles

๐Ÿ’ค Name Explanation

Imagine that a 3D cube is multiplied by itself two times โ€” That's it!

๐Ÿ’Ž Core Features

  • Animation engine: Flexible and well-organized animations handling. You don't need to explicitly manipulate time for each animation, as it is controlled behind the scene.

  • Video exports: Export any scene to video files.

  • 2D and 3D rendering: Cubecubed produces high-performance animations with eye-soothing graphical effects. At its core, the library utilizes the powerful SVG manipulation abilities of D3.js, along with the marvelous 3D graphical system of three.js to create a visual representation of math concepts.

๐Ÿš€ Getting Started

Setup

Getting started with Cubecubed is easily easy, you can run this command to initialiize a workspace.

# `ccw` stands for `create cubecubed workspace`
$ npx ccw my-workspace

Develop

Now you will see the animations in action!

$ npm run dev

See this Quick Start page for detailed information.

๐Ÿ—’๏ธ Notes

Cubecubed is made for everyone!

Whether you are students, teachers, researchers, or someone who is curious about mathematics, you can use Cubecubed or any visualization tools out there to go on exploring the mystical beauty of the science.

Inspiration

Cubecubed exists for a reason. Check out this article to figure it out.

The project is deeply inspired by Manim - an animation engine for explanatory math videos. However, it is not a port or a re-implementation of the engine. Since its first commit on December 1, 2021, Cubecubed has been thriving with upcoming features and friendly community.

GUI version of Cubecubed

Cubedbook is built on top of Cubecubed to provide a user-friendly GUI environment. If you're not comfortable with programming, Cubedbook is an option for you.

Footnote

Cubecubed believes the best way to learn and discover math is through the combining process of visualizations and deductive reasoning. If we write math on paper, why don't we write it on a computer?

โ˜„๏ธ Contributing

Cubecubed welcomes all contributors! Whether you have great feature ideas in mind or recognize bugs, feel free to contribute to the project. But first, please read these contributing guidelines and check the issues and pull requests tabs to prevent any duplications.

๐Ÿฅณ Contributors

Big thanks to all of these awesome people.

โ„๏ธ License

This project is cubed under MIT license.

cubecubed's People

Contributors

haocheng6 avatar imaphatduc avatar marvin-j97 avatar nyabkun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cubecubed's Issues

Vectors are not drawn at the correct coordinates

image

What it should look like:

image

import {
  Axes,
  Group,
  Scene,
  DrawAxes,
  Vector,
  Vector2,
  COLOR,
  Create
} from "../src/index";

/// This variable keeps track of the time goes by during the animations
/// We'll use this to control time, so don't forget to include it to your code
/// In this example, the scene has only one group, so we don't need `elapsed`
let elapsed = 0;

function graphingFunctions() {
  const scene = new Scene("graphing-functions");
  const group = new Group("graphing-group", scene);

  const axes = new Axes({
    group: group,
    CONFIG: {
      xRange: [-5, 5],
      yRange: [-5, 5],
      hasNums: true,
    },
  }).render();
  group.play([new DrawAxes(axes)]);

  const vector = new Vector({
    group,
    startPoint: new Vector2(1, 0),
    endPoint: new Vector2(1, 1),
    CONFIG: {
      lineColor: COLOR.TEAL_1,
    },
  }).render();

  group.play([new Create({ cubicon: vector })]);
}

graphingFunctions();

'CreatePlaneShape' is not exported by index.ts, but is used by example.js

Describe the bug
example.js uses 'CreatePlaneShape', while it's not being exported by index.ts.

To Reproduce
I set up the CCW (npx ccw) and ran the dev server (npm run dev), then in the browser console there is an error.

Your browser
Chrome.

Can you make a guess?
'CreateShape' is exported by index.ts, so maybe that's the correct function? It worked after I changed all mentions of 'CreatePlaneShape' to 'CreateShape'

Expected behavior
The example page showing an example.

[bug] - Recorder doesnt let me select the tab where cubecubed is running

Describe the bug
When I run my scene in "http://localhost:5173/", the browser asks me to select a tab to record, but doesnt show "http://localhost:5173/".

To Reproduce
I added the recorder:

import { Recorder} from "cubecubed";
function drawShapes() {
    const recorder = new Recorder(scene);
    recorder.start();

    // rest of the example code in drawShapes()

    return scene.sceneElapsed;
}
drawShapes();

to the example (example.js) that came with "npx ccw"

Your browser
I tried Chrome and Edge

Can you make a guess?
No idea

Expected behavior
To let me record my scene. Would it be possible to just export as video without having to record the screen?

Screenshots
image

[bug] - Windows Installation: cp vs copy

Describe the bug
Initialisation of cubecubed workspace on Windows fails upon attempting to use a cp command (which does not exist with the default cmd.exe shell).

To Reproduce
npx ccw hello_world

Can you make a guess?
Line 49 of ccw.js needs changing. Need to detect which operating system is running, and if it's Windows, use PowerShell to execute commands. Alternatively, change the cp to copy if the OS is Windows.

Expected behavior
Not to get an error, like the one below:

PS C:\Users\Nik\Documents\Rockets\Animations\cubecubed> npx cubecubed hellocube
npx: installed 101 in 5.869s
package.json file not detected. Creating...
? Do you want to install vite to run local server? Yes
Initializing Cubecubed workspace...
Installing vite...
Tip: Execute `npm run dev` to run a local dev server.
'cp' is not recognized as an internal or external command,
operable program or batch file.
child_process.js:866
    throw err;
    ^

Error: Command failed: cp cubecubed/assets/svg/favicon.svg ./
'cp' is not recognized as an internal or external command,
operable program or batch file.

Cannot Translate, Rotate vectors

const v1 = new Vector({
    group: vectors,
    endPoint: new Vector2(3, 2),
    CONFIG: {
      lineColor: COLOR.TEAL_1,
    }
  });

  const v2 = new Vector({
    group: vectors,
    startPoint: new Vector2(0, 0,),
    endPoint: new Vector2(-1, 2),
    CONFIG: {
      lineColor: COLOR.RED_1,
    }
  });

vectors.play([new Create({ cubicon: v1 })]);
vectors.play([new Create({ cubicon: v2 })]);

vectors.play([
    new Translate({
      cubicon: v2,
      vector: v1.endPoint,
    })
  ])

Changing src/animations/translate.ts:39 from cubicon.svgWrapper to cubicon.stroke fixes it but isn't really a fix.
Same for Rotate

Expected result

lincomb

[bug] - MathText rendering upside down.

Describe the bug
MathText objects render upside down.

To Reproduce
Run the code in the texvector.js example on Windows, after initialising a new workspace with npx ccw <name> with vite enabled.

I've also experienced this in other scenes I made myself.

Your browser
Reproduced on Chrome, Edge. This is may be an OS-dependent error.

Can you make a guess?
The MathTex cubicon, I suppose?

Expected behavior
It should be the correct way up.

Screenshots
image

[bug] - Extreme delay on interactive

Describe the bug
If I hook up a rotate animation to onClick, it has an extreme delay

To Reproduce
My code (I edited example.js that can with npx ccw):

import {
    COLOR,
    CreateShape,
    DrawGrid,
    Grid,
    Group,
    Rotate,
    Scene,
    Square,
    VectorShape,
    Vector2,
    CreateVectorShape,
} from "cubecubed";

import $ from 'jquery'

// By convention, first-class functions represent `scenes`,
// and each function inside it represents a `group`.
function drawShapes() {
    const scene = new Scene("draw-shapes-scene");
    (() => {
        const group = new Group("squares", scene);

        const square1 = new Square({
            group: group,
            sideLength: 2,
            CONFIG: {
                strokeColor: COLOR.PINK_1,
            },
        }).render();

        const square2 = new Square({
            group: group,
            sideLength: 2,
            CONFIG: {
                strokeColor: COLOR.PINK_1,
            },
        }).render();

        group.play([new CreateShape({ cubicon: square1 })]);

        group.play([
            new CreateShape({ cubicon: square2 }),
            new Rotate({ cubicon: square1, degree: 45 }),
        ]);
    })();

    (() => {
        const group = new Group("vectors", scene);
        
        const vector = new VectorShape({
            group: group,
            endPoint: new Vector2(4, 4),
            CONFIG: {
                lineColor: COLOR.TEAL_1,
            },
        }).render();

        group.play([new CreateVectorShape({ cubicon: vector })]);

            $(() => {
                $('#cubecubed').on('click', (e => {
                    console.time('interactive')
                    group.play([new Rotate({cubicon: vector, degree: 45})])
                    console.timeEnd('interactive')
                }))
            })
        })();

        (() => {
            const group = new Group("plane-grid-group", scene);

            const grid = new Grid({ group: group }).render();

            group.play([new DrawGrid({ cubicon: grid })]);
        })();
}

drawShapes();

Your browser
Chrome and Edge

Can you make a guess?
Maybe it looks at .play() that was executed previously and adds the delay incorrectly?

Expected behavior
The vector rotating immediately

I can't record it right now, (I might a bit later) but if you look in Inspector, the svg rotate values do not change until ~7 seconds pass

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.