Fetches an effect JSON from url, resolves linked sources, and parses it. Free the effect
with disposeEffect.
Loads many effects in parallel for battle / level preload. Phase 1 fetches every effect JSON (optionally concurrency-limited); phase 2 resolves all linked geometries/images across the pack together so shared asset urls hit the fetch cache once; phase 3 parses.
Optionaloptions: QuarksBatchLoadOptions & { continueOnError?: false }Loads many effects in parallel for battle / level preload. Phase 1 fetches every effect JSON (optionally concurrency-limited); phase 2 resolves all linked geometries/images across the pack together so shared asset urls hit the fetch cache once; phase 3 parses.
Resolves linked geometry / image urls (via resolveResources) then parses. Use when
the effect JSON is already in hand (File, CDN payload, editor import). json is an
EffectDocumentJSON as parsed from its file; anything else throws
QuarksFormatError, and a part of the wrong kind warns. json itself is
left as it was, so the same document can be loaded again, into another scene or with
another base url.
OptionalbaseUrl: stringSame two-phase batch as loadAll, but effect JSON is already in memory (asset pack,
IndexedDB, editor). Entries may be bare JSON or { json, baseUrl }.
Optionaloptions: QuarksBatchLoadOptions & { continueOnError?: false }Same two-phase batch as loadAll, but effect JSON is already in memory (asset pack,
IndexedDB, editor). Entries may be bare JSON or { json, baseUrl }.
Builds the node tree of an effect document whose linked files are already inline (see
loadFromJSON). baseUrl is joined to relative image urls. Parts the loader cannot
read warn and take their defaults; a document with no object throws
QuarksFormatError. Free the effect with disposeEffect.
Inlines external geometry files and rewrites relative image urls through the loader's
QuarksResourceResolver, in place on json. Each document is resolved once:
geometries already inlined and image urls this method already rewrote are left alone, so
loading the same document again does not join its base url twice. Failures warn and leave
the entry as is.
StaticclearForgets the textures, geometries, and in-flight JSON fetches shared between loads into
scene (see QuarksLoaderOptions.shareResources). Effects already loaded keep
theirs; the next load creates new ones. Textures are not disposed — they may still be in use.
StaticdisposeDisposes an effect a loader built: its nodes and systems, the materials made for it, and
each texture it uses once no other loaded effect uses it (textures are shared per scene,
see QuarksLoaderOptions.shareResources). Copies made with
QuarksUtil.instantiate hold the textures too, so disposing the source effect leaves them
drawing. The same happens when the root is disposed any other way (root.dispose(), its
parent's dispose, the scene's). The materials and textures are freed even when other code
was handed them; give that code its own. For a root the loader did not build, this is
root.dispose().
StaticjoinJoins baseUrl with a relative url; leaves data/blob/absolute/root-absolute urls alone.
StaticresolveInlines geometries that an export wrote to their own file ({uuid, type: 'QuarksGeometry', url}). Prefer load, loadFromJSON, or resolveResources — those use
the loader's resolver and fetch cache. Kept for callers that already have a custom
loadGeometry and no QuarksLoader instance.
StaticresolveSame as instance resolveResources, but usable without constructing a loader (e.g.
editor import that only prepares JSON). Pass scene to share the per-scene fetch cache.
Like it, resolves each document once. A geometry file that fails to load goes to
onResourceError (default: a console warning) and keeps its link.
Loads effects saved as JSON into a scene: fetches the document and the geometry and image files it links, builds the nodes, particle systems, textures and materials, and returns the root. Add the systems to a BatchedRenderer with QuarksUtil.addToBatchRenderer to draw them, and free the effect with QuarksLoader.disposeEffect.
Example