Skip to content

Search

Tilbage
· 3 min. læsning

Shape primitives

2D and 3D primitives, bezier paths, booleans, a cloner, and text as geometry.

Ten 3D primitives and six 2D ones, bezier paths that extrude, revolve and sweep, booleans in both dimensions, a cloner, and text as geometry. Every one of them is a mesh.

  • The primitives are torus, pyramid, prism, tube and rounded cuboid, with ellipse, star and ngon in 2D. segments, rings, sides and corner_radius work on all of them.

    The primitives row

  • path2d and path3d assets extrude with a bevel, lathe, sweep along a rail, or stroke with a join, a cap and a taper.

    An arch extruded, a goblet revolved, a rail swept

    Polylines with round, miter and bevel joins, three caps, a tapered gradient, and two closed squares

  • boolean3d and boolean2d run over a node's children: union, difference, intersection. Operands stay editable, moving one recomputes, and booleans nest.

    Union, difference and intersection of a cube and a ball

  • shape2d gained ellipse, star and ngon, and boolean2d joins, cuts and intersects filled outlines. The 2D booleans run on i_overlay, in fixed-point integers, so every platform gets the same vertices.

    Ellipse, star, ngon and capsule; a rect and a circle joined, cut and intersected

  • A cloner is linear, radial or grid, and seed and random scatter the copies. A thousand copies are one draw call, custom materials included.

    A row, a ring and a scattered grid

  • kind = "text" on a mesh asset turns a word into geometry, counters kept as holes, sized in world units, sitting on its baseline.

  • Vertex colours and morph targets both survive a glTF import. A morph weight is a property, so a clip drives it as mesh/morph.<name>, and vertex colours reach a material with features = { vertex_color = true }.

    A word as a mesh, and a triangle coloured per vertex

One mesher

  • A collider fitted to a torus is a torus.
  • A ray picks the shape that is drawn.
  • Headless tests check every mesh is closed and outward-facing, with the exact volume a boolean should have.
  • Deterministic: libm for the curves, and a BSP of dot products and lerps.
  • The meshers are the engine's own: core builds the triangles, physics fits its colliders to them.
[[assets]]
id = "ring"
type = "mesh"
kind = "torus"
radius = 1.1
tube_radius = 0.28

[nodes.mesh]
source = "#ring"

[nodes.collider3d]
kind = "trimesh"
mesh = "#ring"

examples/objects has five rows, one per category, then the 2D layer. It runs in the browser. The manual and the generated asset and component references have the keys.

Er du sikker?