initializeStaticResources static method

Future<void> initializeStaticResources()

Prepares the rendering resources, such as textures and shaders, that are used to display models in this Scene.

This method ensures all necessary resources are loaded and ready to be used in the rendering pipeline. If the initialization fails, the resources are reset, and the scene will not be marked as ready to render.

Returns a Future that completes when the initialization is finished.

Implementation

static Future<void> initializeStaticResources() {
  if (_initializeStaticResources != null) {
    return _initializeStaticResources!;
  }
  _initializeStaticResources = Material.initializeStaticResources()
      .onError((e, stacktrace) {
        log(
          'Failed to initialize static Flutter Scene resources',
          error: e,
          stackTrace: stacktrace,
        );
        _initializeStaticResources = null;
      })
      .then((_) {
        _readyToRender = true;
      });
  return _initializeStaticResources!;
}