Search code examples
javajava-3d

Why do we need Canvas in Java 3D?


I'm a bit new to Java 3D and I'm trying to clarify everything for myself. I created an app at start and didn't use Canvas3D. But later I needed to interact with a mouse and found tips and tutorials only using Canvas3D class. So do we really need canvas in 3D apps or there's another way to catch the mouse coordinates?


Solution

  • Class Canvas3D

    "The Canvas3D class provides a drawing canvas for 3D rendering. It is used either for on-screen rendering or off-screen rendering. Canvas3D is an extension of the AWT Canvas class that users may further subclass to implement additional functionality."

    "The Canvas3D object extends the Canvas object to include 3D-related information such as the size of the canvas in pixels, the Canvas3D's location, also in pixels, within a Screen3D object, and whether or not the canvas has stereo enabled."

    "Because all Canvas3D objects contain a reference to a Screen3D object and because Screen3D objects define the size of a pixel in physical units, Java 3D can convert a Canvas3D size in pixels to a physical world size in meters. It can also determine the Canvas3D's position and orientation in the physical world."

    As far as I am aware of, it is not possible to do any java3d visualisation if not inside a Canvas3D