com.orsoncharts.graphics3d

## Class World

- java.lang.Object
- - com.orsoncharts.graphics3d.World

-     public class World
      extends java.lang.Object

  A world is a model containing a collection of objects in 3D space and a direction vector for the sunlight. A viewing point (`ViewPoint3D`) is specified externally. Objects in the world are assigned to a partition, providing the ability to group objects.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_PARTITION_KEY` The default partition key.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `World()` Creates a new empty world.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(Object3D object)` Adds an object to the world in the default partition.
    `void` | `add(java.lang.String partition, Object3D object)` Adds an object to a specific partition.
    `void` | `addAll(java.util.Collection<Object3D> objects)` Adds a collection of objects to the world (in the default partition).
    `Point3D[]` | `calculateEyeCoordinates(ViewPoint3D vp)` Returns an array containing the vertices for all objects in this world, transformed to eye coordinates.
    `java.awt.geom.Point2D[]` | `calculateProjectedPoints(ViewPoint3D vp, double d)` Calculates the projected points in 2D-space for all the vertices of the objects in the world.
    `void` | `clear(java.lang.String partitionKey)` Clears any objects belonging to the specified partition.
    `java.util.List<Face>` | `getFaces()` Fetches the faces for all the objects in this world, updating the offset to match the current position.
    `java.util.List<Object3D>` | `getObjects()` Returns a newly created list containing all the objects in the world model.
    `double` | `getSunX()` Returns the x-component of the sunlight vector.
    `double` | `getSunY()` Returns the y-component of the sunlight vector.
    `double` | `getSunZ()` Returns the z-component of the sunlight vector.
    `int` | `getVertexCount()` Returns the total number of vertices for all objects in this world.
    `void` | `setSunSource(double x, double y, double z)` Sets the light source point.
    `void` | `setSunSource(Point3D p)` Sets the light source point.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_PARTITION_KEY

          public static final java.lang.String DEFAULT_PARTITION_KEY

      The default partition key. All objects in the world are added with a partition key. There always exists at least one partition (the default partition).
      Since:
        1.2
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### World

          public World()

      Creates a new empty world.

  - ### Method Detail

    - #### getSunX

          public double getSunX()

      Returns the x-component of the sunlight vector.
      Returns:
        The x-component of the sunlight vector.

    - #### getSunY

          public double getSunY()

      Returns the y-component of the sunlight vector.
      Returns:
        The y-component of the sunlight vector.

    - #### getSunZ

          public double getSunZ()

      Returns the z-component of the sunlight vector.
      Returns:
        The z-component of the sunlight vector.

    - #### setSunSource

          public final void setSunSource(double x,
                                         double y,
                                         double z)

      Sets the light source point.
      Parameters:
        `x` - the x-coordinate.
        `y` - the y-coordinate.
        `z` - the z-coordinate.
      Since:
        1.2

    - #### setSunSource

          public final void setSunSource(Point3D p)

      Sets the light source point.
      Parameters:
        `p` - the point (`null` not permitted).
      Since:
        1.2

    - #### add

          public void add(Object3D object)

      Adds an object to the world in the default partition.
      Parameters:
        `object` - the object (`null` not permitted).

    - #### add

          public void add(java.lang.String partition,
                          Object3D object)

      Adds an object to a specific partition.
      Parameters:
        `partition` - the partition (`null` not permitted).
        `object` - the object (`null` not permitted).
      Since:
        1.2

    - #### addAll

          public void addAll(java.util.Collection<Object3D> objects)

      Adds a collection of objects to the world (in the default partition).
      Parameters:
        `objects` - the objects (`null` not permitted).

    - #### clear

          public void clear(java.lang.String partitionKey)

      Clears any objects belonging to the specified partition.
      Parameters:
        `partitionKey` - the partition key (`null` not permitted).
      Since:
        1.2

    - #### getVertexCount

          public int getVertexCount()

      Returns the total number of vertices for all objects in this world.
      Returns:
        The total number of vertices.

    - #### calculateEyeCoordinates

          public Point3D[] calculateEyeCoordinates(ViewPoint3D vp)

      Returns an array containing the vertices for all objects in this world, transformed to eye coordinates.
      Parameters:
        `vp` - the view point (`null` not permitted).
      Returns:
        The eye coordinates.

    - #### calculateProjectedPoints

          public java.awt.geom.Point2D[] calculateProjectedPoints(ViewPoint3D vp,
                                                                  double d)

      Calculates the projected points in 2D-space for all the vertices of the objects in the world.
      Parameters:
        `vp` - the view point (`null` not permitted).
        `d` - the distance.
      Returns:
        The projected points.

    - #### getFaces

          public java.util.List<Face> getFaces()

      Fetches the faces for all the objects in this world, updating the offset to match the current position.
      Returns:
        A list of faces.

    - #### getObjects

          public java.util.List<Object3D> getObjects()

      Returns a newly created list containing all the objects in the world model.
      Returns:
        The list of objects.
      Since:
        1.2