Skip to content

Commit

Permalink
Merge pull request #2 from seflless/seflless/cylinders-with-linear-gr…
Browse files Browse the repository at this point in the history
…adients

Render Cylinders using Linear Gradients and Fewer Shapes
  • Loading branch information
seflless authored Oct 16, 2023
2 parents d70709e + 0ae0b4d commit e43f7a5
Show file tree
Hide file tree
Showing 22 changed files with 1,700 additions and 1,036 deletions.
947 changes: 947 additions & 0 deletions docs/cylinders.tldr

Large diffs are not rendered by default.

475 changes: 12 additions & 463 deletions docs/overview.tldr → docs/spheres.tldr

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./renderer/Scene";
export * from "./renderer/Viewport";
export * from "./renderer/Renderer";
export * from "./renderer/DebugRenderer";
export * from "./colors/Color";
export * from "./lighting/DirectionalLight";
export * from "./lighting/LightingModel";
Expand All @@ -13,6 +14,5 @@ export * from "./shapes/Cylinder";
export * from "./shapes/Sphere";
export * from "./meshes/Mesh";
export * from "./meshes/BoxMesh";
export * from "./meshes/CylinderMesh";
export * from "./math/Vector3";
export * from "./math/Matrix4x4";
20 changes: 13 additions & 7 deletions src/math/Matrix4x4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Matrix4x4 {
copyPosition(matrix: Matrix4x4): Matrix4x4;
getTranslation(): Vector3;
getScale(): Vector3;
extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4x4;
extractBasis(xAxis?: Vector3, yAxis?: Vector3, zAxis?: Vector3): Matrix4x4;
extractRotation(): Matrix4x4;
lookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix4x4;

Expand Down Expand Up @@ -313,13 +313,19 @@ const Matrix4x4Proto = {

extractBasis(
this: Matrix4x4,
xAxis: Vector3,
yAxis: Vector3,
zAxis: Vector3
xAxis?: Vector3,
yAxis?: Vector3,
zAxis?: Vector3
) {
setVector3FromMatrixElements(xAxis, this.elements, 0);
setVector3FromMatrixElements(yAxis, this.elements, 4);
setVector3FromMatrixElements(zAxis, this.elements, 8);
if (xAxis !== undefined) {
setVector3FromMatrixElements(xAxis, this.elements, 0);
}
if (yAxis !== undefined) {
setVector3FromMatrixElements(yAxis, this.elements, 4);
}
if (zAxis !== undefined) {
setVector3FromMatrixElements(zAxis, this.elements, 8);
}

return this;
},
Expand Down
18 changes: 18 additions & 0 deletions src/math/Vector3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export interface Vector3 {
y: number;
z: number;
set(vec: Vector3): Vector3;
setX(x: number): Vector3;
setY(y: number): Vector3;
setZ(z: number): Vector3;
add(vec: Vector3): Vector3;
subtract(vec: Vector3): Vector3;
multiply(scalar: number): Vector3;
Expand All @@ -26,6 +29,21 @@ const Vector3Proto = {
return this;
},

setX(this: Vector3, x: number): Vector3 {
this.x = x;
return this;
},

setY(this: Vector3, y: number): Vector3 {
this.y = y;
return this;
},

setZ(this: Vector3, z: number): Vector3 {
this.z = z;
return this;
},

/**
* Adds a vector to this vector, mutating it in place. It
* returns this vector, so that API chaining is possible (ie: `v.add(v2).add(v3)`)
Expand Down
20 changes: 0 additions & 20 deletions src/meshes/CylinderMesh.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/react/Axii.txt

This file was deleted.

124 changes: 0 additions & 124 deletions src/react/Box.txt

This file was deleted.

109 changes: 0 additions & 109 deletions src/react/Cylinder.txt

This file was deleted.

Loading

0 comments on commit e43f7a5

Please sign in to comment.