SkyCube
The SkyCube class renders a skybox using a cube mesh with inverted normals (back face rendering), providing an environment map background. It’s similar to SkySphere but uses a cube geometry instead of sphere.
Constructor
Section titled “Constructor”constructor(renderer: Renderer)Creates an uninitialized sky cube. All fields start as null.
Properties
Section titled “Properties”renderer
Section titled “renderer”Reference to the owning Renderer.
texture | null
Section titled “texture | null”The cube map texture. Set via the texture setter (only after initialization) or during load().
material
Section titled “material”The internal Material with albedo texture linked to the sky cube texture. Created during load().
shader
Section titled “shader”The active sky cube shader. Set via load() or defaults to SkyCubeShader.
polyListRenderer
Section titled “polyListRenderer”Lazy-initialized polygon list renderer containing a cube geometry (1x1x1). The cull face is set to PolyListCullFace.FRONT for back-face rendering
renderState
Section titled “renderState”The render state generated by updateRenderState(). Used internally to draw the sky cube.
Methods
Section titled “Methods”load(cubemapTexture: Texture, Shader?, shaderParams?) : Promise<void>
Section titled “load(cubemapTexture: Texture, Shader?, shaderParams?) : Promise<void>”Initializes the sky cube with a cubemap texture.
await skyCube.load(myCubemapTexture);await skyCube.load(myCubemapTexture, MyCustomSkyShader, [param1]);texture (setter)
Section titled “texture (setter)”Sets/changes the sky cube texture after initialization. Throws if called before load():
skyCube.texture = newSkyCubemap; // Only after load() completesupdateRenderState({ viewMatrix, projectionMatrix }) : RenderState
Section titled “updateRenderState({ viewMatrix, projectionMatrix }) : RenderState”Creates or updates the render state with rotated view matrix and specified projection. The rotation is extracted from the view matrix to keep the sky cube aligned with camera orientation:
const rs = skyCube.updateRenderState({ viewMatrix: camera.viewMatrix, projectionMatrix: camera.projectionMatrix});draw()
Section titled “draw()”Throws Error: calling base implementation of SkyCube. This method must be overridden by a subclass.
destroy()
Section titled “destroy()”Cleans up all resources: shader, texture, poly list renderer, material.
Usage Pattern
Section titled “Usage Pattern”const skyCube = new SkyCube(renderer);await skyCube.load(myCubemapTexture);// Integrate with scene renderer's render loop manually or via subclass