Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NEXT_UNIQUE_ID int
Functions ¶
Types ¶
type Coordinates ¶
type Coordinates struct {
// Face is a reference to the Face that is being rendered.
// The reference is retained so it can be checked for the Dirty flag.
// When the Dirty flag is set, the rendering needs to be regenerated.
Face *Face
// Model to World space transformation
Model matrix.Matrix
WorldSpace struct {
Points point.Points
Barycenter point.Point
Normal point.Point
}
// World to View space transformation
Projection matrix.Matrix
InViewFrustum bool
// View to Screen space transformation
Viewport matrix.Matrix
ScreenSpace struct {
Points point.Points
Barycenter point.Point
Normal point.Point
}
}
Coordinates contains the transformed and projected points of a face as well as a reference back to the original face.
Once initialized, the object will have a constant memory footprint down to `Number` primitives. Also, we compare each transform and projection to prevent unnecessary re-computation.
If you need to force a re-computation, mark the face as 'dirty'.
func (*Coordinates) MaybeUpdate ¶
type Face ¶
type Face struct {
// Points contain a list of vertices of the planar polygon that defines the
// outline of the face.
Points point.Points
// Id holds a unique identifier for the face.
// We store a unique Id for every face so we can look them up quickly
// with the render face cache.
Id int
// ShowBackfaces when set to true will override backface culling, which is useful if your
// material is transparent. See comment in Scene.
ShowBackfaces bool
// FillMaterial may be a Material object which defines the color and
// finish of the object and are rendered using the scene's shader.
// If not material is set a Material(C.gray) will be used.
FillMaterial *shader.Material
// StrokeMaterial may be a Material object that defines the color when
// an object is stroked. By default no stroke material will be set.
StrokeMaterial *shader.Material
// Dirty flag can be set to force the Coordinates generated from the face to
// be regenerated.
Dirty bool
// Options is a map of additional options that can be specified for a face.
// The option with key "stroke-width" is passed in the style map parameter to
// PathPainter.Stroke() call.
// The keys "font" and "anchor" are passed in as keys "font" and "text-anchor" in
// the style map parameter to TextPainter.FillText() call.
Options map[string]string
}
Face is a defined as a planar object in 3D space. These paths don't necessarily need to be convex, but they should be non-degenerate.
func FaceWith ¶
FaceWith takes a slice of points and uses it in constructing a face. The array backing this points slice is integrated into the face.
func (*Face) Coordinates ¶
func (face *Face) Coordinates(model, projection, viewport matrix.Matrix) Coordinates
type Faces ¶
type Faces []Face
func (Faces) SetColorFrom ¶
SetColorFrom sets a color on every face by reading it from the passed in colors.Source.
func (Faces) SetShowBackfaces ¶
SetShowBackfaces will set the ShowBackfaces bool on the faces.
func (Faces) SetStrokeWidth ¶
SetStrokeWidth sets the supplied stroke-width option on each face
type Facets ¶
type Facets []Facet
func (Facets) FacesWith ¶
FacesWith creates faces from points and facets. A facet is a list of indexes into the list of points. Note that a point referenced in multiple facets will be inserted into multiple faces. Because of this points shared by multiple faces will be transformed multiple times instead of only once.