Class UI3dContext

All Implemented Interfaces:
UILayer, UITabFocus, LXLoopTask, LXSerializable
Direct Known Subclasses:
UIPreviewWindow

public class UI3dContext extends UIObject implements LXSerializable, UILayer, UITabFocus
This is a layer that contains a 3d scene with a camera. Mouse movements control the camera, and the scene can contain components.
  • Field Details

  • Constructor Details

    • UI3dContext

      protected UI3dContext(UI ui, float x, float y, float w, float h)
  • Method Details

    • addMovementListener

      public final void addMovementListener(UI3dContext.MovementListener listener)
    • removeMovementListener

      public final void removeMovementListener(UI3dContext.MovementListener listener)
    • dispose

      public void dispose()
      Overrides:
      dispose in class UIObject
    • getX

      public float getX()
      Overrides:
      getX in class UIObject
    • getY

      public float getY()
      Overrides:
      getY in class UIObject
    • getWidth

      public float getWidth()
      Specified by:
      getWidth in class UIObject
    • getHeight

      public float getHeight()
      Specified by:
      getHeight in class UIObject
    • setPosition

      public UI3dContext setPosition(float x, float y)
    • setSize

      public UI3dContext setSize(float width, float height)
    • setRect

      public UI3dContext setRect(float x, float y, float width, float height)
    • addComponent

      public final UI3dContext addComponent(UI3dComponent component)
      Adds a component to the layer
      Parameters:
      component - Component
      Returns:
      this
    • removeComponent

      public final UI3dContext removeComponent(UI3dComponent component)
      Removes a component from the layer
      Parameters:
      component - Component
      Returns:
      this
    • clearCamera

      public UI3dContext clearCamera(int index)
      Clears the camera stored at the given index
      Parameters:
      index - Camera index to clear
      Returns:
      this
    • setCamera

      public UI3dContext setCamera(int index)
      Sets the cue position index of the camera
      Parameters:
      index - Camera index
      Returns:
      this
    • setRadius

      public UI3dContext setRadius(float radius)
      Set radius of the camera
      Parameters:
      radius - Camera radius
      Returns:
      this
    • setPerspective

      public UI3dContext setPerspective(float perspective)
      Sets perspective angle of the camera in degrees
      Parameters:
      perspective - Angle in degrees
      Returns:
      this
    • setCameraVelocity

      public UI3dContext setCameraVelocity(float cameraVelocity)
      Sets the camera's maximum zoom speed
      Parameters:
      cameraVelocity - Max units/per second radius may change by
      Returns:
      this
    • setCameraAcceleration

      public UI3dContext setCameraAcceleration(float cameraAcceleration)
      Set's the camera's zoom acceleration, 0 is infinite
      Parameters:
      cameraAcceleration - Acceleration for camera
      Returns:
      this
    • setRotationVelocity

      public UI3dContext setRotationVelocity(float rotationVelocity)
      Sets the camera's maximum rotation speed
      Parameters:
      rotationVelocity - Max radians/per second viewing angle may change by
      Returns:
      this
    • setRotationAcceleration

      public UI3dContext setRotationAcceleration(float rotationAcceleration)
      Set's the camera's rotational acceleration, 0 is infinite
      Parameters:
      rotationAcceleration - Acceleration of camera rotation
      Returns:
      this
    • setTheta

      public UI3dContext setTheta(double theta)
      Set the theta angle of viewing
      Parameters:
      theta - Angle about the y axis
      Returns:
      this
    • setPhi

      public UI3dContext setPhi(float phi)
      Set the phi angle of viewing
      Parameters:
      phi - Angle about the y axis
      Returns:
      this
    • setRadiusBounds

      public UI3dContext setRadiusBounds(float minRadius, float maxRadius)
      Sets bounds on the radius
      Parameters:
      minRadius - Minimum camera radius
      maxRadius - Maximum camera radius
      Returns:
      this
    • setMinRadius

      public UI3dContext setMinRadius(float minRadius)
      Set minimum radius
      Parameters:
      minRadius - Minimum camera radius
      Returns:
      this
    • setMaxRadius

      public UI3dContext setMaxRadius(float maxRadius)
      Set maximum radius
      Parameters:
      maxRadius - Maximum camera radius
      Returns:
      this
    • setCenter

      public UI3dContext setCenter(float x, float y, float z)
      Sets the center of the scene, only respected in ZOOM mode
      Parameters:
      x - X-coordinate
      y - Y-coordinate
      z - Z-coordinate
      Returns:
      this
    • getCenter

      public org.joml.Vector3f getCenter()
      Gets the center position of the scene
      Returns:
      center of scene
    • getEye

      public org.joml.Vector3f getEye()
      Gets the latest computed eye position
      Returns:
      eye position
    • draw

      public final void draw(UI ui, View view)
      Specified by:
      draw in interface UILayer
    • getViewMatrix

      public org.joml.Matrix4f getViewMatrix()
    • getProjectionMatrix

      public org.joml.Matrix4f getProjectionMatrix()
    • onMousePressed

      protected void onMousePressed(MouseEvent mouseEvent, float mx, float my)
      Description copied from class: UIEventHandler
      Subclasses override to receive mouse events
      Overrides:
      onMousePressed in class UIEventHandler
      Parameters:
      mouseEvent - Mouse event
      mx - x-coordinate
      my - y-coordinate
    • onMouseDragged

      protected void onMouseDragged(MouseEvent mouseEvent, float mx, float my, float dx, float dy)
      Description copied from class: UIEventHandler
      Subclasses override to receive mouse events
      Overrides:
      onMouseDragged in class UIEventHandler
      Parameters:
      mouseEvent - Mouse event
      mx - x-coordinate
      my - y-coordinate
      dx - movement in x
      dy - movement in y
    • onMouseScroll

      protected void onMouseScroll(MouseEvent mouseEvent, float mx, float my, float dx, float dy)
      Description copied from class: UIEventHandler
      Subclasses override to receive mouse events
      Overrides:
      onMouseScroll in class UIEventHandler
      Parameters:
      mouseEvent - Mouse event
      mx - x-coordinate
      my - y-coordinate
      dx - Amount of horizontal scroll
      dy - Amount of vertical scroll
    • onKeyPressed

      protected void onKeyPressed(KeyEvent keyEvent, char keyChar, int keyCode)
      Description copied from class: UIEventHandler
      Subclasses override to receive key events
      Overrides:
      onKeyPressed in class UIEventHandler
      Parameters:
      keyEvent - Key event
      keyChar - Key character
      keyCode - Key code value
    • save

      public void save(LX lx, JsonObject object)
      Description copied from interface: LXSerializable
      Serializes this instance into the JSON object
      Specified by:
      save in interface LXSerializable
      Parameters:
      lx - LX instance
      object - Object to serialize into
    • load

      public void load(LX lx, JsonObject object)
      Description copied from interface: LXSerializable
      Restores this instance from a JSON object
      Specified by:
      load in interface LXSerializable
      Parameters:
      lx - LX instance
      object - Object to deserialize