Class ThreeGraphics
java.lang.Object
nl.colorize.multimedialib.renderer.teavm.ThreeGraphics
- All Implemented Interfaces:
TeaGraphics,StageSubscriber,StageVisitor
Uses the Three.js JavaScript library to
render 3D graphics. This requires the browser to support WebGL.
Three.js does not support 2D graphics very well, so when using both 2D and
3D graphics, the 2D part is delegated to a separate canvas overlay that is
displayed on top of the 3D graphics. Updating the 2D graphics overlay is
then delegated to HtmlCanvasGraphics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancastPickRay(Point2D canvasPosition, Box area) createMesh(Shape3D shape, ColorRGB color) voiddrawBackground(ColorRGB color) voiddrawCircle(Primitive graphic, Circle circle, Transform globalTransform) voiddrawLight(Light light, Transform3D globalTransform) voidvoiddrawMesh(Mesh mesh, Transform3D globalTransform) voiddrawPolygon(Primitive graphic, Polygon polygon, Transform globalTransform) voidvoiddrawSegmentedLine(Primitive graphic, SegmentedLine line, Transform globalTransform) voiddrawSprite(Sprite sprite, Transform globalTransform) voidvoidfinalize3D(Stage stage) Called after all 3D nodes on the stage have been visited, but before the 2D nodes are visited.intintvoidinit(SceneContext context) voidonNodeAdded(Group parent, StageNode3D node) voidonNodeRemoved(Group parent, StageNode3D node) voidprepareStage(Stage stage) Prepares visiting the stage.booleanIndicates whether this visitor should visit all graphics, or only graphics that are currently visible.voidvisitContainer(Container container, Transform globalTransform) voidvisitGroup(Group group, Transform3D globalTransform) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nl.colorize.multimedialib.stage.StageSubscriber
onNodeAdded, onNodeRemovedMethods inherited from interface nl.colorize.multimedialib.stage.StageVisitor
finalize2DMethods inherited from interface nl.colorize.multimedialib.renderer.teavm.TeaGraphics
getDevicePixelRatio
-
Constructor Details
-
ThreeGraphics
public ThreeGraphics()
-
-
Method Details
-
init
- Specified by:
initin interfaceTeaGraphics
-
getDisplayWidth
public int getDisplayWidth()- Specified by:
getDisplayWidthin interfaceTeaGraphics
-
getDisplayHeight
public int getDisplayHeight()- Specified by:
getDisplayHeightin interfaceTeaGraphics
-
onNodeAdded
- Specified by:
onNodeAddedin interfaceStageSubscriber
-
onNodeRemoved
- Specified by:
onNodeRemovedin interfaceStageSubscriber
-
prepareStage
Description copied from interface:StageVisitorPrepares visiting the stage. This method is called before any of the stage's graphics are visited. It can be used to add initialization logic that should be performed before any graphics can be drawn.- Specified by:
prepareStagein interfaceStageVisitor
-
shouldVisitAllNodes
public boolean shouldVisitAllNodes()Description copied from interface:StageVisitorIndicates whether this visitor should visit all graphics, or only graphics that are currently visible.- Specified by:
shouldVisitAllNodesin interfaceStageVisitor
-
visitContainer
- Specified by:
visitContainerin interfaceStageVisitor
-
drawBackground
- Specified by:
drawBackgroundin interfaceStageVisitor
-
drawSprite
- Specified by:
drawSpritein interfaceStageVisitor
-
drawLine
- Specified by:
drawLinein interfaceStageVisitor
-
drawSegmentedLine
- Specified by:
drawSegmentedLinein interfaceStageVisitor
-
drawRect
- Specified by:
drawRectin interfaceStageVisitor
-
drawCircle
- Specified by:
drawCirclein interfaceStageVisitor
-
drawPolygon
- Specified by:
drawPolygonin interfaceStageVisitor
-
drawText
- Specified by:
drawTextin interfaceStageVisitor
-
visitGroup
- Specified by:
visitGroupin interfaceStageVisitor
-
drawMesh
- Specified by:
drawMeshin interfaceStageVisitor
-
drawLight
- Specified by:
drawLightin interfaceStageVisitor
-
createMesh
- Specified by:
createMeshin interfaceTeaGraphics
-
project
- Specified by:
projectin interfaceTeaGraphics
-
castPickRay
- Specified by:
castPickRayin interfaceTeaGraphics
-
finalize3D
Description copied from interface:StageVisitorCalled after all 3D nodes on the stage have been visited, but before the 2D nodes are visited. This allows renders that support both 2D and 3D graphics to switch from rendering 3D graphics to rendering 2D graphics. This is an optional method, the default implementation is empty.- Specified by:
finalize3Din interfaceStageVisitor
-
getGraphicsMode
- Specified by:
getGraphicsModein interfaceTeaGraphics
-