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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
castPickRay
(Point2D canvasPosition, Box area) createMesh
(Shape3D shape, ColorRGB color) void
drawBackground
(ColorRGB color) void
drawCircle
(Primitive graphic, Circle circle, Transform globalTransform) void
drawLight
(Light light, Transform3D globalTransform) void
void
drawMesh
(Mesh mesh, Transform3D globalTransform) void
drawPolygon
(Primitive graphic, Polygon polygon, Transform globalTransform) void
void
drawSegmentedLine
(Primitive graphic, SegmentedLine line, Transform globalTransform) void
drawSprite
(Sprite sprite, Transform globalTransform) void
void
finalize3D
(Stage stage) Called after all 3D nodes on the stage have been visited, but before the 2D nodes are visited.int
int
void
init
(SceneContext context) void
onNodeAdded
(Group parent, StageNode3D node) void
onNodeRemoved
(Group parent, StageNode3D node) void
prepareStage
(Stage stage) Prepares visiting the stage.boolean
Indicates whether this visitor should visit all graphics, or only graphics that are currently visible.void
visitContainer
(Container container, Transform globalTransform) void
visitGroup
(Group group, Transform3D globalTransform) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.stage.StageSubscriber
onNodeAdded, onNodeRemoved
Methods inherited from interface nl.colorize.multimedialib.stage.StageVisitor
finalize2D
Methods inherited from interface nl.colorize.multimedialib.renderer.teavm.TeaGraphics
getDevicePixelRatio
-
Constructor Details
-
ThreeGraphics
public ThreeGraphics()
-
-
Method Details
-
init
- Specified by:
init
in interfaceTeaGraphics
-
getDisplayWidth
public int getDisplayWidth()- Specified by:
getDisplayWidth
in interfaceTeaGraphics
-
getDisplayHeight
public int getDisplayHeight()- Specified by:
getDisplayHeight
in interfaceTeaGraphics
-
onNodeAdded
- Specified by:
onNodeAdded
in interfaceStageSubscriber
-
onNodeRemoved
- Specified by:
onNodeRemoved
in interfaceStageSubscriber
-
prepareStage
Description copied from interface:StageVisitor
Prepares 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:
prepareStage
in interfaceStageVisitor
-
shouldVisitAllNodes
public boolean shouldVisitAllNodes()Description copied from interface:StageVisitor
Indicates whether this visitor should visit all graphics, or only graphics that are currently visible.- Specified by:
shouldVisitAllNodes
in interfaceStageVisitor
-
visitContainer
- Specified by:
visitContainer
in interfaceStageVisitor
-
drawBackground
- Specified by:
drawBackground
in interfaceStageVisitor
-
drawSprite
- Specified by:
drawSprite
in interfaceStageVisitor
-
drawLine
- Specified by:
drawLine
in interfaceStageVisitor
-
drawSegmentedLine
- Specified by:
drawSegmentedLine
in interfaceStageVisitor
-
drawRect
- Specified by:
drawRect
in interfaceStageVisitor
-
drawCircle
- Specified by:
drawCircle
in interfaceStageVisitor
-
drawPolygon
- Specified by:
drawPolygon
in interfaceStageVisitor
-
drawText
- Specified by:
drawText
in interfaceStageVisitor
-
visitGroup
- Specified by:
visitGroup
in interfaceStageVisitor
-
drawMesh
- Specified by:
drawMesh
in interfaceStageVisitor
-
drawLight
- Specified by:
drawLight
in interfaceStageVisitor
-
createMesh
- Specified by:
createMesh
in interfaceTeaGraphics
-
project
- Specified by:
project
in interfaceTeaGraphics
-
castPickRay
- Specified by:
castPickRay
in interfaceTeaGraphics
-
finalize3D
Description copied from interface:StageVisitor
Called 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:
finalize3D
in interfaceStageVisitor
-
getGraphicsMode
- Specified by:
getGraphicsMode
in interfaceTeaGraphics
-