Shape

Shape

A representation of a 3D geometric shape. It should not be confused with Three.js Shape class. It is more an analogue of the class BufferGeometry in Three.js.

Constructor

(abstract) new Shape(isom)

Source:

Constructor.

Parameters:
Name Type Description
isom Isometry

the position of the shape

Classes

Shape

Members

_absoluteIsom :Isometry

Source:

Isometry defining the absolute position of the shape (taking into account the position of the parent) The actual value is computed the first time absoluteIsom is called. If the object is moving, the updates should be made by the developer.

Type:

_absoluteIsomInv :Isometry

Source:

Inverse of the absolute isometry

Type:

absoluteIsom :Isometry

Source:

If the shape is part of an advanced shape, the underlying isometry is a position relative to the parent shape. absoluteIsom, on the contrary return the isometry encoding the absolute position

Type:

absoluteIsomInv :Isometry

Source:

Return the inverse of absoluteIsom

Type:

hasUVMap :boolean

Source:

Says whether the shape comes with a UV map. Default is false If true, the shape should implement the method glslUVMap.

Type:
  • boolean

isAdvancedShape :boolean

Source:

Says whether the shape is a basic shape, that it is not build on top of other shapes.

Type:
  • boolean

isBasicShape :boolean

Source:

Says whether the shape is a basic shape, that it is not build on top of other shapes.

Type:
  • boolean

isGlobal :boolean

Source:

Says whether the shape is global. True if global, false otherwise.

Type:
  • boolean

isLocal :boolean

Source:

Says whether the shape is local. True if local, false otherwise.

Type:
  • boolean

isom :Isometry

Source:

Isometry defining the position of the shape (relative to any potential parent)

Type:

isomInv :Isometry

Source:

Inverse of the isometry

Type:

isShape :boolean

Source:

Says that the object inherits from Shape

Type:
  • boolean

parent :Shape

Source:

Parent of the shape (if this shape is part of an advanced shape)

Type:

Methods

glslGradient() → {string}

Source:

Return the chunk of GLSL code corresponding to the gradient field. The default computation approximates numerically the gradient. This function can be overwritten for an explicit computation. If so, the gradient function on the GLSL side should have the following signature RelVector {{name}}_gradient(RelVector v) It takes the vector obtained when we hit the shape and render the normal to the shape at this point.

Returns:
Type
string

glslInstance() → {string}

Source:

Compile all the function directly related to the object (e.g. sdf, gradient, etc).

Returns:
Type
string

(abstract) glslSDF() → {string}

Source:

Return the chunk of GLSL code corresponding to the signed distance function. The SDF on the GLSL side should have the following signature float {{name}}_sdf(RelVector v) It takes a vector, corresponding the position and direction of the geodesic we are following and return an under-estimation of the distance from this position to the shape along this geodesic.

Returns:
Type
string

glslUVMap()

Source:

Return the chunk of GLSL code corresponding to the UV map The UV map on the GLSL side should have the signature vec2 {{name}}_uvMap(RelVector v) It takes the vector obtained when we hit the shape and render the UV coordinates at this point.

updateAbsoluteIsom()

Source:
To Do:
  • include an ascending / bidirectional mode ? The descending update should be done individually in each advanced shape.

  • factorize the code at the level of AdvancedShape ? How to not have two copies of the children (one at the level of AdvancedShape, one at the level of UnionShape, for instance)?

Recompute the absolute isometry from the current data The update is "descending", updating a shape will updates the children but not the parents.

updateData()

Source:

The shape may contains data which depends on the isometry (like the center of a ball) This method can be overlaoded to update all these data when needed