Package limn.render3d.scene
Class Scene3D
java.lang.Object
limn.render3d.scene.Scene3D
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA mesh to draw, paired with its composed world transform. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUniform light applied everywhere, in linear scene-referred units.background(Vec4 color) Colour the target is cleared to; a zero w leaves the viewport transparent.bounds()World-space bounds of every mesh in the graph, orAabb.EMPTYwhen it holds none.castShadows(boolean on) Enables directional shadow mapping, fitted automatically to the visible bounds.voiddebugBounds(DebugDraw out, Vec4 color) Emits every mesh node's world-space AABB (exactly the boxes frustum culling tests) intoout.voiddispose()Releases every GPU resource this scene holds (each distinctGpuMeshand PBR base-colorGpuTexturereachable from the node tree, plus every resource registered viaowns(limn.render3d.GpuMesh)) and empties the node tree.environment(Environment environment) Sets the image-based lighting environment (baking its irradiance once);nulldisables.exposure(float exposure) Scales scene light before the display transform;1leaves it as authored.lights()Every light in the graph, transformed into world space.intTotal mesh nodes in the graph (for culling diagnostics/tests).Registers a GPU resource as owned by this scene, sodispose()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).owns(GpuTexture texture) voidrender(RenderPass pass, Camera camera, float aspect) Draws the whole graph intopass.root()The root node; everything drawn hangs off it.visibleMeshes(Camera camera, float aspect) Mesh instances that survive frustum culling forcameraataspect.
-
Constructor Details
-
Scene3D
public Scene3D()
-
-
Method Details
-
root
The root node; everything drawn hangs off it. -
ambient
Uniform light applied everywhere, in linear scene-referred units. -
exposure
Scales scene light before the display transform;1leaves it as authored. -
background
Colour the target is cleared to; a zero w leaves the viewport transparent. -
castShadows
Enables directional shadow mapping, fitted automatically to the visible bounds. -
environment
Sets the image-based lighting environment (baking its irradiance once);nulldisables. -
owns
Registers a GPU resource as owned by this scene, sodispose()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
-
dispose
public void dispose()Releases every GPU resource this scene holds (each distinctGpuMeshand PBR base-colorGpuTexturereachable from the node tree, plus every resource registered viaowns(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 viaScene.disposeLater(Runnable)(which is whatViewport3D.onDisposedoes). 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
Mesh instances that survive frustum culling forcameraataspect. -
lights
Every light in the graph, transformed into world space. -
bounds
World-space bounds of every mesh in the graph, orAabb.EMPTYwhen 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
Emits every mesh node's world-space AABB (exactly the boxes frustum culling tests) intoout. Call from a render callback alongsiderender(limn.render3d.RenderPass, limn.render3d.Camera, float), beforeout.flush(pass). -
render
Draws the whole graph intopass.aspectis the viewport's width/height, which the camera needs and does not own.
-