Class TeaRenderer

java.lang.Object
nl.colorize.multimedialib.renderer.teavm.TeaRenderer
All Implemented Interfaces:
Renderer, SceneContext

public class TeaRenderer extends Object implements Renderer, SceneContext
Renderer based on TeaVM that is transpiled to JavaScript and runs in the browser. Rendering graphics can switch between different frameworks, the requested renderer can be indicated during the build or at runtime using a URL parameter.
  • Constructor Details

    • TeaRenderer

      public TeaRenderer(TeaGraphics graphics)
      Initializes the TeaVM renderer using the specified graphics library. Applications should use one of the factory methods rather than using this constructor directly.
  • Method Details

    • start

      public void start(RenderConfig config, Scene initialScene)
      Description copied from interface: Renderer
      Starts this renderer based on the specified configuration. The renderer will initially display the specified scene.

      This method can be called from any thread. The renderer will run in its own thread, which is started by calling this method. All callback methods will be called from the renderer thread.

      Specified by:
      start in interface Renderer
    • terminate

      public void terminate()
      Description copied from interface: SceneContext
      Terminates the renderer, which will end the animation loop and quit the application.
      Specified by:
      terminate in interface SceneContext
    • createMesh

      public Mesh createMesh(Shape3D shape, ColorRGB color)
      Description copied from interface: SceneContext
      Programmatically creates a 3D polygon mesh with a solid color, based on the specified shape.
      Specified by:
      createMesh in interface SceneContext
    • project

      public Point2D project(Point3D position)
      Description copied from interface: SceneContext
      Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.
      Specified by:
      project in interface SceneContext
    • castPickRay

      public boolean castPickRay(Point2D canvasPosition, Box area)
      Description copied from interface: SceneContext
      Casts a pick ray from the specified 2D canvas position, and returns true if the pick ray intersects with the specified 3D world coordinates.
      Specified by:
      castPickRay in interface SceneContext
    • takeScreenshot

      public void takeScreenshot(File screenshotFile)
      Description copied from interface: SceneContext
      Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.
      Specified by:
      takeScreenshot in interface SceneContext
    • getRendererName

      public String getRendererName()
      Description copied from interface: SceneContext
      Returns the display name for the underlying renderer. The display name will not include the word "renderer".
      Specified by:
      getRendererName in interface SceneContext
    • isSupported

      public boolean isSupported(GraphicsMode graphicsMode)
      Specified by:
      isSupported in interface Renderer
    • getConfig

      public RenderConfig getConfig()
      Specified by:
      getConfig in interface SceneContext
    • getGraphics

      public TeaGraphics getGraphics()
    • getInput

      public TeaInputDevice getInput()
      Specified by:
      getInput in interface SceneContext
    • getMediaLoader

      public TeaMediaLoader getMediaLoader()
      Specified by:
      getMediaLoader in interface SceneContext
    • getNetwork

      public TeaNetwork getNetwork()
      Specified by:
      getNetwork in interface SceneContext
    • getSceneManager

      public SceneManager getSceneManager()
      Specified by:
      getSceneManager in interface SceneContext
    • getStage

      public Stage getStage()
      Specified by:
      getStage in interface SceneContext