Skip to content

A visualization of a 3D vector space that renders a wireframe object from a text input.

Notifications You must be signed in to change notification settings

erzloh/Wireframe-Viewer

Repository files navigation

Wireframe Viewer

Visualize 3D wireframes in a simple, interactive viewer.

Description of GIF

I made this project alongside my learning of Linear Algebra to put into practice what I learned from theory. For those interested in the topic, I can't recommend enough the Essence of Linear Algebra video series from 3Blue1Brown.

I already did a similar program written in C as a school project (cf. 42-FdF). This time, it's written only in pure JavaScript, HTML, and CSS.

Try the thing!

You can try the project here!

Features

  • Render wireframes from 2D heightmaps
  • Real-time rotation
  • Orthographic projection
  • Interactive user interface with rotate and scale functionality
  • Compatible on mobiles
  • Neat UI/UX

Code Overview

The application consists of the following main classes:

  • VectorSpace: An environment that houses vectors, points, cubes, and wireframes.
  • Vec3: A 3-dimensional vector with various vector operations.
  • Mat3: A 3x3 matrix with matrix operations.
  • Vector: Represents an object with an end vertex.
  • Point: Represents a single point in space.
  • Cube: A cube defined by its origin and radius.
  • Wireframe: A collection of vertices and edges created from a 2D map string.

Example of Heightmaps

Input:

0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0 10 10  0  0 10 10  0  0  0 10 10 10 10 10  0  0  0
0  0 10 10  0  0 10 10  0  0  0  0  0  0  0 10 10  0  0
0  0 10 10  0  0 10 10  0  0  0  0  0  0  0 10 10  0  0
0  0 10 10 10 10 10 10  0  0  0  0 10 10 10 10  0  0  0
0  0  0 10 10 10 10 10  0  0  0 10 10  0  0  0  0  0  0
0  0  0  0  0  0 10 10  0  0  0 10 10  0  0  0  0  0  0
0  0  0  0  0  0 10 10  0  0  0 10 10 10 10 10 10  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

Output: スクリーンショット 2023-09-28 8 57 27

Input:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 5 6 7 8 8 8 7 6 5 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 5 6 7 7 7 7 7 6 5 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 5 6 6 6 6 6 6 6 5 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 4 4 4 4 4 4 4 4 4 4 4 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 1 0 0 0 0 0
0 0 0 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: スクリーンショット 2023-09-28 8 54 37

About

A visualization of a 3D vector space that renders a wireframe object from a text input.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published