Class SceneAssets

java.lang.Object
com.victorvalentim.zividomelive.SceneAssets

public final class SceneAssets extends Object
Processing-friendly, typed assets scoped to one scene activation.

Images, shaders, and shapes are created only on the bound render thread. The default loaders keep borrowed Processing objects and release their Java references at scene disposal.

Use these synchronous asset operations during Scene.setupScene() or another known render-thread callback, not inside background tasks or recurring hot paths.

API stability: Advanced Stable.

Since:
2.0.0
  • Method Details

    • loadImage

      public processing.core.PImage loadImage(String path)
      Loads an image once using a sketch-relative or absolute Processing image path.
      Parameters:
      path - non-blank Processing image path, also used as the activation cache key
      Returns:
      loaded image, or null when Processing cannot load it
    • loadShader

      public processing.opengl.PShader loadShader(String fragmentPath)
      Loads a fragment shader once.
      Parameters:
      fragmentPath - non-blank Processing fragment shader path and cache key
      Returns:
      loaded shader, or null when Processing cannot load it
    • loadShader

      public processing.opengl.PShader loadShader(String key, String fragmentPath, String vertexPath)
      Loads a fragment/vertex shader pair once.
      Parameters:
      key - non-blank activation cache key
      fragmentPath - Processing fragment shader path
      vertexPath - Processing vertex shader path
      Returns:
      loaded shader, or null when Processing cannot load it
    • getOrCreateShape

      public processing.core.PShape getOrCreateShape(String key, Supplier<? extends processing.core.PShape> factory)
      Creates a retained shape once on the render thread.
      Parameters:
      key - non-blank activation cache key
      factory - retained shape factory invoked only when the key is absent
      Returns:
      cached or newly created shape
    • cacheShape

      public processing.core.PShape cacheShape(String key, processing.core.PShape shape)
      Stores or replaces one borrowed retained shape.
      Parameters:
      key - non-blank activation cache key
      shape - borrowed retained Processing shape
      Returns:
      the supplied shape
    • removeShapesByPrefix

      public int removeShapesByPrefix(String prefix)
      Invalidates retained shapes whose keys start with the supplied prefix.
      Parameters:
      prefix - key prefix used to select retained shapes; an empty prefix removes all
      Returns:
      number of removed shapes