The aim of the project is to create a lightweight 3D library with a very low level of complexity
|
A computer program that is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility.
THREE.PlaneGeometry
Represent plane as normal vector and offset
ax + by + cz + d = 0
Use function to create 2 planes
backPlaneEquation = getPlaneEquation(clippingPlane, -planeOffset);
frontPlaneEquation = getPlaneEquation(clippingPlane, planeOffset);
Which gets you something that looks like this
Vertex Shader: Vertex position → fragment shader
varying vec4 vertexPosition;
void main() {
vertexPosition = vec4(position, 1.0);
...
}
Fragment Shader: Check if vertex is in between planes
if (dot(frontPlane, vertexPosition) >= 0.0 && dot(backPlane, vertexPosition) < 0.0) {
// Vertex is between planes, display it differently
} else {
// Vertex is not between planes, display it normally
}