The THREEi addon is used to create indexed geometries for implicit surfaces and forms with holes.
The addon contains the sphere with holes. See also Triangulation sphere with holes
Update: August 8th
Added a version with limitation for infinite surfaces (e.g. cylinders) or cut surfaces by a limitation of the coordinate. It requires more code and execution effort, it is internal realised as an additional function. Description adjusted here.
Update: September 24th
Cylinder with holes was added to the addon. See also Triangulation cylinder with holes
Update: October 7th
Another variant of the sphere with holes was added. The rough side length of the triangles is to be indicated as with the cylinder. This allows the shapes to be joined together exactly.
Update: October 18th
The algorithm for the sphere with holes previously contained no check whether the current front overlaps. In very many cases with few holes this is not a problem. But it can lead to errors in more complicated cases!
The overlap check has been completed.
The older, simpler and less expensive version of the sphere with holes was saved separately: THREEi_ONLY_SphereWithSomeHoles.js
Update 07th February 2020
InnerGeometry, combines sphere, cylinder and other - with holes
examples
THREEi.js/InnerGeometryTHREEi_01.html at master · hofk/THREEi.js · GitHub
THREEi.js/InnerGeometryTHREEi_02.html at master · hofk/THREEi.js · GitHub
Algorithm based on E. Hartmann.
The algorithm was originally implemented in Pascal and visualized with POV-Ray.
The implementation of the algorithm with three.js/JavaScript deviates from the template in some places.
de: https://www2.mathematik.tu-darmstadt.de/~ehartmann/cdg0/cdg0n.pdf
en:
https://www2.mathematik.tu-darmstadt.de/~ehartmann/cdgen0104.pdf
siehe / see
de: Implizite Fläche – Wikipedia
en:
The addon THREEi.js capsules in the section … ImplicitSurface - Triangulation … the functions
function triangulation( isf, dx, dy, dz, xs, ys, zs, d, e, fc, pc )
function triangulationBounds( isf, dx, dy, dz, xs, ys, zs, d, e, fc, pc, b )
These can be copied and directly integrated into your own projects.
The implicit surfaces are defined in separate js files. See examples folder.
EXAMPLE
// Example: implicit surface genus2:
const isf = ( x, y, z ) => ( 2*y*( y*y - 3*x*x )*( 1 - z*z ) + ( x*x + y*y )*( x*x + y*y ) - ( 9*z*z - 1 )*( 1 - z*z ) );// IMPLICIT SURFACE Function
const dx = ( x, y, z ) => ( -12*x*y*( 1 - z*z ) + 4*x*( x*x + y*y ) );// PARTIAL DERIVATE to x
const dy = ( x, y, z ) => ( 6*( y*y - x*x )*( 1 - z*z ) + 4*y*( x*x + y*y ) );// PARTIAL DERIVATE to y
const dz = ( x, y, z ) => ( -4*y*( y*y - 3*x*x )*z + 36*z*z*z - 20*z );// PARTIAL DERIVATE to z
const xs = 0; // x START POINT
const ys = 3; // y START POINT
const zs = 0; // z START POINT
const e = 0.001; // epsilon
const d = 0.08; // rough edge length of triangles
There are two variants for calling the function in the THREEi addon.
const g = new THREE.BufferGeometry( );
g.createImplicitSurface = THREEi.createImplicitSurface;
// use version (A) with opt for infinite surfaces such as cylinders and cones or for cuts
/*opt optional object, all properties also optional
{
fc: faces //( max. number of triangles )
pc: positions // ( max. number of points )
b: bounds // array [ xMax, xMin, yMax, yMin, zMax, zMin ]
}
*/
// (A) parameters from implicitSurface example.js, with object of optional parameters, contains bounds
g.createImplicitSurface( isf, dx, dy, dz, xs, ys, zs, d, e, opt );
// (B) parameters from implicitSurface example.js with some default values
//g.createImplicitSurface( isf, dx, dy, dz, xs, ys, zs, d, e );
Try it out: http://sandbox.threejs.hofk.de/ last section
or directly http://sandboxthreei.threejs.hofk.de/