pixi.js
    Preparing search index...

    Class CubeTextureAdvanced

    A cube texture that can be bound to shaders (samplerCube / texture_cube).

    This is a lightweight wrapper around a CubeTextureSource.

    Load 6 images and create a cube texture (paths are just examples):

    import { Assets, CubeTexture } from 'pixi.js';

    await Assets.load([
    'px.png', 'nx.png',
    'py.png', 'ny.png',
    'pz.png', 'nz.png',
    ]);

    // IMPORTANT: string ids must already be in the cache (e.g. after Assets.load)
    const cube = CubeTexture.from({
    faces: {
    right: 'px.png', // +X
    left: 'nx.png', // -X
    top: 'py.png', // +Y
    bottom: 'ny.png', // -Y
    front: 'pz.png', // +Z
    back: 'nz.png', // -Z
    },
    label: 'skybox',
    });

    Bind to a shader (resources differ between WebGL and WebGPU, but the cube texture binding stays the same):

    const shader = Shader.from({
    gl: { fragment: `uniform samplerCube uCube;` },
    gpu: { fragment: { source: `@group(0) @binding(0) var uCube : texture_cube<f32>;` } },
    resources: {
    uCube: cube.source,
    uSampler: cube.source.style,
    },
    });

    Hierarchy

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    destroyed: boolean = false

    Has the texture been destroyed?

    label?: string

    Optional label for debugging.

    The underlying cube texture source.

    uid: number = ...

    unique id for this cube texture

    Methods

    • Destroy this CubeTexture.

      Parameters

      Returns void

    • Convenience factory for creating a cube texture from a CubeTextureSource.

      Parameters

      • options: CubeTextureSource

        A cube texture source.

      • OptionalskipCache: boolean

        Unused for this overload.

      Returns CubeTexture

    • Convenience factory for creating a cube texture from 6 face inputs.

      Face inputs are converted to Texture via Texture.from. This does not load resources; string ids must already be present in the cache (e.g. after Assets.load).

      Parameters

      • options: CubeTextureFromOptions

        Options including the 6 face inputs.

      • OptionalskipCache: boolean

        Skip caching the resulting CubeTexture when all faces are string ids.

      Returns CubeTexture

      const cube = CubeTexture.from({
      faces: {
      right: 'px.png',
      left: 'nx.png',
      top: 'py.png',
      bottom: 'ny.png',
      front: 'pz.png',
      back: 'nz.png',
      },
      });