Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: CustomShape3D

[38:7] extends: MeshView

Wraps an AussomCustomShape3D (subclass of FXGL's abstract CustomShape3D) so Aussom code can build custom mesh-backed 3D shapes. CustomShape3D extends JavaFX MeshView, so the wrapper extends the fx Node base. Aussom users register an onCreateMesh callback that must return a Mesh AussomJavaObject (typically a TriangleMesh filled in from Aussom). After wiring the callback (and again whenever the inputs change) call updateMesh to apply it. Example: cs = new CustomShape3D(); cs.onCreateMesh(::buildMesh); cs.updateMesh(); cs.setPhongMaterial(redColor); public buildMesh() { m = aji.newObj("javafx.scene.shape.TriangleMesh"); // ...fill points / texCoords / faces via m... return m; } For the built-in CustomShape3D subclasses (Cuboid, Torus, Prism, Cylinder, Pyramid, Cone) the createMesh hook is internal; use those wrappers directly instead of subclassing this one.

Methods

  • CustomShape3D ()

    Creates a new AussomCustomShape3D bridge. Wire onCreateMesh and call updateMesh before adding the shape to the scene.

  • adopt (object Ajo)

    Wraps an existing AussomCustomShape3D AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AussomCustomShape3D.
    • @r A new CustomShape3D wrapper.
  • onCreateMesh (callback Cb)

    Registers the createMesh callback. The callback takes no arguments and must return a Mesh AussomJavaObject (typically a TriangleMesh). Returning null produces an empty TriangleMesh.

    • @p Cb is a callback () -> Mesh AJO.
    • @r this object
  • updateMesh ()

    Re-invokes the createMesh callback and installs the result as this shape's mesh. Call after wiring onCreateMesh and again whenever the inputs to the mesh change.

    • @r this object
  • setMaterial (object MaterialObj)

    Sets the shape's material.

    • @p MaterialObj is a Material wrapper.
    • @r this object
  • setPhongMaterial (object ColorObj)

    Sets a PhongMaterial directly from a Color.

    • @p ColorObj is a Color wrapper.
    • @r this object
  • getTranslation ()

    Returns the (x, y, z) translation as a Point3D AJO.

  • setTranslation (double X, double Y, double Z)

    Sets the (x, y, z) translation in one call.

  • getVertices ()

    Returns the mesh vertex list for direct deformation.