Class Scene3D

java.lang.Object
limn.render3d.scene.Scene3D

public final class Scene3D extends Object
A retained 3D scene: a Node tree plus scene-wide ambient/exposure and an optional background. render(limn.render3d.RenderPass, limn.render3d.Camera, float) traverses the tree, composes world transforms, adds every LightNode's (transformed) light, frustum-culls MeshNodes against the camera and issues their draws into the imperative RenderPass, so it layers on top of the 2D composite pipeline unchanged. A declarative scene renders identically to the equivalent imperative draws.
  • Constructor Details

    • Scene3D

      public Scene3D()
  • Method Details

    • root

      public Node root()
      The root node; everything drawn hangs off it.
    • ambient

      public Scene3D ambient(Vec3 color)
      Uniform light applied everywhere, in linear scene-referred units.
    • exposure

      public Scene3D exposure(float exposure)
      Scales scene light before the display transform; 1 leaves it as authored.
    • background

      public Scene3D background(Vec4 color)
      Colour the target is cleared to; a zero w leaves the viewport transparent.
    • castShadows

      public Scene3D castShadows(boolean on)
      Enables directional shadow mapping, fitted automatically to the visible bounds.
    • environment

      public Scene3D environment(Environment environment)
      Sets the image-based lighting environment (baking its irradiance once); null disables.
    • owns

      public Scene3D owns(GpuMesh mesh)
      Registers a GPU resource as owned by this scene, so dispose() releases it even when no node references it (a texture whose material was never assigned to a mesh, a mesh removed from the tree before disposal). Builders that upload resources for a scene (e.g. GltfModel.toScene3D) register every upload here; tree-reachable duplicates are released once.
    • owns

      public Scene3D owns(GpuTexture texture)
    • dispose

      public void dispose()
      Releases every GPU resource this scene holds (each distinct GpuMesh and PBR base-color GpuTexture reachable from the node tree, plus every resource registered via owns(limn.render3d.GpuMesh)) and empties the node tree. Call it once the scene will no longer be drawn; like every GPU release it must run on the UI thread with the owning GL context current: inside a render frame, or deferred via Scene.disposeLater(Runnable) (which is what Viewport3D.onDispose does). Calling it twice is a no-op. Do not dispose a scene whose meshes/textures are shared with another scene that is still drawn.
    • visibleMeshes

      public List<Scene3D.MeshInstance> visibleMeshes(Camera camera, float aspect)
      Mesh instances that survive frustum culling for camera at aspect.
    • lights

      public List<Light> lights()
      Every light in the graph, transformed into world space.
    • bounds

      public Aabb bounds()
      World-space bounds of every mesh in the graph, or Aabb.EMPTY when it holds none. Walks the whole graph and refreshes the cached world matrices, so it is a setup-time call rather than a per-frame one: frame a camera with it once, or after the content changes.
    • meshCount

      public int meshCount()
      Total mesh nodes in the graph (for culling diagnostics/tests).
    • debugBounds

      public void debugBounds(DebugDraw out, Vec4 color)
      Emits every mesh node's world-space AABB (exactly the boxes frustum culling tests) into out. Call from a render callback alongside render(limn.render3d.RenderPass, limn.render3d.Camera, float), before out.flush(pass).
    • render

      public void render(RenderPass pass, Camera camera, float aspect)
      Draws the whole graph into pass. aspect is the viewport's width/height, which the camera needs and does not own.