Documentation ¶
Overview ¶
Package nodes loads the Blackjack Luau scripts and makes them available for building up BJK AST trees with a simple connection API. See: https://github.com/setzer22/blackjack
Index ¶
- Constants
- Variables
- func AboutEq(a, b float64) bool
- func GenXform(normal, tangent, tr Vec3) *mat4.T
- func Rotation(from, to Vec3) quaternion.T
- func Vec3Dot(v1, v2 Vec3) float64
- func Vec3RotateAroundAxis(angle float64) func(v1, v2 Vec3) Vec3
- type Builder
- func (b *Builder) AddNode(name string, args ...string) *Builder
- func (b *Builder) Build() (*ast.BJK, error)
- func (b *Builder) Connect(from, to string) *Builder
- func (b *Builder) Input(inputName, connectTo string) *Builder
- func (b *Builder) MergeMesh(name string) *Builder
- func (b *Builder) NewGroup(fullName string, fn func(b *Builder) *Builder, args ...string) *Builder
- func (b *Builder) Output(connectFrom, outputName string) *Builder
- type BuilderFunc
- type Client
- func (c *Client) Close()
- func (c *Client) Eval(design *ast.BJK) (*Mesh, error)
- func (c *Client) GetScalar(design *ast.BJK, nodeName string) (float64, error)
- func (c *Client) NewBuilder() *Builder
- func (c *Client) ToObj(design *ast.BJK, filename string) error
- func (c *Client) ToSTL(design *ast.BJK, filename string, swapYZ bool) error
- type FaceT
- type Mesh
- func NewLine(v1, v2 *Vec3, numSegs int) *Mesh
- func NewLineFromPoints(pts []Vec3) *Mesh
- func NewMesh() *Mesh
- func NewMeshFromExtrudeAlongCurve(backbone, crossSection *Mesh, flip int) *Mesh
- func NewMeshFromLineWithNormals(points, normals, tangents []Vec3) *Mesh
- func NewMeshFromPolygons(verts []Vec3, faces []FaceT) *Mesh
- func NewPolygonFromPoints(pts []Vec3) *Mesh
- func ObjStrToMesh(objData string) (*Mesh, error)
- func STLToMesh(filename string, swapYZ bool) (*Mesh, error)
- func (m *Mesh) AddFace(verts []Vec3) FaceT
- func (m *Mesh) AddVert(v Vec3) VertIndexT
- func (m *Mesh) CalcFaceNormal(face FaceT) Vec3
- func (m *Mesh) LerpAlongCurve(t float64) *Vec3
- func (dst *Mesh) Merge(src *Mesh)
- func (m *Mesh) ToLVal(ls *lua.LState) lua.LValue
- func (m *Mesh) WriteObj(filename string) error
- func (m *Mesh) WriteSTL(filename string, swapYZ bool) error
- type SelectionExpression
- type Vec3
- func (v *Vec3) AboutEq(otherVec Vec3) bool
- func (v *Vec3) AboutZero() bool
- func (v1 Vec3) Add(v2 Vec3) Vec3
- func (v1 Vec3) Cross(v2 Vec3) Vec3
- func (v Vec3) Length() float64
- func (v Vec3) MulScalar(f float64) Vec3
- func (v Vec3) Negated() Vec3
- func (v *Vec3) Normalize()
- func (v Vec3) Normalized() Vec3
- func (v Vec3) String() string
- func (v1 Vec3) Sub(v2 Vec3) Vec3
- func (v Vec3) Xform(xform *mat4.T) Vec3
- type VertIndexT
Constants ¶
const (
// Epsilon is a small number used for comparing float64s.
Epsilon = 1e-5
)
Variables ¶
var ( // GenerateGoldenFilesPrefix is used only to generate testdata files to ensure // that Merge experiences no regressions on known, good merges. GenerateGoldenFilesPrefix string )
Functions ¶
func GenXform ¶
GenXform represents a rotation (defined by the normal and tangent vectors) about the origin, then translating it by tr into place. func GenXform(normal, tangent, tr Vec3) *Xform {
func Rotation ¶
func Rotation(from, to Vec3) quaternion.T
Rotation calculates the rotation between two normalized vectors. From: https://physicsforgames.blogspot.com/2010/03/quaternion-tricks.html
func Vec3RotateAroundAxis ¶
Vec3RotateAroundAxis, given an angle in radians, returns a function that operates on two Vec3s to rotate a point around an axis by the given angle.
Types ¶
type Builder ¶
type Builder struct { Nodes map[string]*ast.Node NodeOrder []string Groups map[string]*Builder ExternalParameters ast.ExternalParameters InputsAlreadyConnected map[string]string CheckUnusedGroupInputs bool // contains filtered or unexported fields }
Builder represents a BJK builder.
func (*Builder) AddNode ¶
AddNode adds a new node to the design with the optional args. A nodes's name always starts with the type of node that it is, whether it is a built-in type like 'MakeScalar' or a new group like 'CoilPair'. The type is followed by a dot ('.') then one or more optional (but recommended) label(s). A node generated from an instance of a Group uses the node's name, a dot, then the group's full name. When referring to inputs or outputs of a node, its full name is followed by a dot then the name of the input or output port. For example, "Helix.wire-1" or "Helix.wire-1.CoilPair.coils-1-2.start_angle".
func (*Builder) Input ¶
Input is used within a group to connect one of its inputs to an internal input. It can only be used within a group.
func (*Builder) MergeMesh ¶
MergeMesh creates a new 'MergeMeshes' node if necessary to combine the last mesh with this current mesh. Typically, a design will end with a `MergeMesh` before the call to `Build` such that it is the last (and therefore "active") node in the graph network.
func (*Builder) NewGroup ¶
NewGroup creates a new group of nodes and connections that can then later be instantiated one or more times to make a more complex design. If the fullName includes a dot ('.') and an instance name, then the creation of the group is immediately followed by a call to `AddNode` using that same group and instance name. Otherwise, if no dot is included, the `fullName` will be used as the name of the group.
type BuilderFunc ¶
BuilderFunc is a func used to build up a design.
type Client ¶
Client represents all the known nodes in Blackjack from its Luau bindings.
func New ¶
New creates a new instance of nodes.Client. blackjackRepoPath is either the absolute path to the Blackjack repo or is the relative-to-$HOME-dir path of the repo.
func (*Client) Eval ¶
Eval "evaluates" a BJK design using lua and returns a Mesh if one was generated.
func (*Client) NewBuilder ¶
NewBuilder returns a new BJK Builder.
type Mesh ¶
type Mesh struct { // Do not manually add to Verts. Use AddVert instead. Verts []Vec3 Normals []Vec3 // optional - per-vert normals Tangents []Vec3 // optional - per-vert tangents Faces []FaceT // optional - when used, Normals and Tangents are unused. // contains filtered or unexported fields }
Mesh represents a mesh of points, edges, and faces.
func NewLineFromPoints ¶
NewLineFromPoints creates a new mesh with only verts.
func NewMeshFromExtrudeAlongCurve ¶
NewMeshFromExtrudeAlongCurve creates a new mesh by extruding the crossSection along the backbone. Note that extrude along curve in Blackjack does not make a face at the start or end of the curve.
func NewMeshFromLineWithNormals ¶
NewMeshFromLineWithNormals creates a new mesh from points, normals, and tangents.
func NewMeshFromPolygons ¶
NewMeshFromPolygons creates a new mesh from points.
func NewPolygonFromPoints ¶
NewPolygonFromPoints creates a new mesh from points.
func ObjStrToMesh ¶
ObjStrToMesh converts a simple Wavefront obj file (passed as a string) to a Mesh. Note that it only supports the bare minimum verts and faces.
See: https://en.wikipedia.org/wiki/Wavefront_.obj_file
It always swaps Y and Z because Blackjack is always Y-up and Blender is always Z-up. It also reverses every face order to preserve the normals correctly.
func (*Mesh) AddFace ¶
AddFace adds a face to a mesh and returns its FaceT. Note that some lua code could create a face where an edge has two vert indices are identical. AddFace prevents that from happening.
func (*Mesh) AddVert ¶
func (m *Mesh) AddVert(v Vec3) VertIndexT
AddVert adds a vertex to a mesh (reusing existing vertices if possible) and returns its VertIndexT.
func (*Mesh) CalcFaceNormal ¶
CalcFaceNormal calculates the normal of a face.
func (*Mesh) LerpAlongCurve ¶
LerpAlongCurve returns a Vec3 representing the percentage t (0 to 1) along a curve (the points in the mesh). It caches the length of the curve segments upon first use for later speedup.
type SelectionExpression ¶
type SelectionExpression string
SelectionExpression represents a selection of vertices, edges, or faces.
type Vec3 ¶
Vec3 represents a point in 3D space.
func (Vec3) MulScalar ¶
MulScalar multiplies a Vec3 by a scalar value and returns a new vector. v is not altered.
Source Files ¶
- assert.go
- builder.go
- cut-neighbors.go
- eval.go
- groups.go
- list.go
- manifold.go
- merge-intersect-faces.go
- merge-non-manifold-src.go
- merge-two-edges.go
- merge-two-manifolds.go
- merge-two-manis-one-face.go
- merge-two-many-edges.go
- merge-two-non-manifolds.go
- merge-two-non-many-edges.go
- merge.go
- mesh.go
- native-math.go
- nodes.go
- ops.go
- primitives.go
- selection-expression.go
- stl.go
- vector.go
- wavefront-obj.go