A simple ray tracer written in javascript.
A quick note, these test applications runs faster on firefox (than chrome).
- ensure
const isMultiThreadingEnabled = false
onindex.js
then openindex.html
- ensure
const isMultiThreadingEnabled = true
onindex.js
then openindex.html
classDiagram
class Vecotr3 {
Int x
Int y
Int z
Vector3 scale(Int scalar)
Vector3 plus(Vecotr3 other)
Vector3 minus(Vecotr3 other)
Vector3 normalized()
Int dot(Vector3 other)
Vector lerp(Vector3 start, Vector3 end, Int t)
}
class Shape {
Vector3 center
Material material
}
class Sphere {
Int radius
}
class Disk {
Int radius
}
class Scene {
Vector3 camera
}
class ProjectionPlane {
Int width
Int height
Canvas canvas
Void createCanvas()
Void putPixel(Int x, Int y, Color color)
Void render(Element element)
}
RayTracing --> Scene
Scene "1" --> "*" Shape
Scene "1" --> "1" ProjectionPlane
Scene "1" --> "*" Light
Sphere --|> Shape
Disk --|> Shape
-
Optimize rendering system
- use Web Workers
- use
Möller–Trumbore intersection algorithm
-
Animation
- Rotate Camera
- move camera position
- move light position
- add *-Control (ScaleControl, RotateControl, TransitionControl)
-
Rendering based 3D Objects
- Render Disk
- Render Plan 2D
- Render Cube
- add BufferShape based on Polygone
- add BufferShape based on Triangle