Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

ASSET_LOAD

Package @dioramajs/diorama/assets Level error

An asset request failed on the network or with an HTTP error, so its lease rejected and nothing was cached.

View as Markdown
On this page
ASSET_LOAD: cannot load {url}

Why it happens

  • An image, loaded for the image or texture type in a detached Image, fired error: a 404, a wrong path, a network error, or a CORS refusal when crossOrigin is set.
  • A fetched type such as gltf, ktx2, json or buffer got an HTTP error. The message then holds the status, such as 404 /models/lamp.glb.
  • fetch itself failed: the network is down, or a Content Security Policy or CORS refused the request. The message then reads cannot fetch {url}.
  • The URL does not parse: {url} is not a URL.
  • There is no DOM, as in server rendering. Every load then fails with no DOM to load in, without a report.

The error is reported through app.report() with the target asset:<url>, once per attempt. The lease’s ready rejects and its status becomes failed. When the last lease of a failed asset goes, the asset leaves the cache, so the next load is a new attempt.

A preload does not report a failed file, since the page loads it itself. In development it prints a warning that starts with preload of.

How to fix

  1. Open the URL from the message in the browser and check the status in the network panel.
  2. Fix the path. A relative URL resolves against document.baseURI, or against the base option of app.assets.preload().
  3. For files on another origin, make the server send Access-Control-Allow-Origin. Fetched types always request in CORS mode, and images need crossOrigin: 'anonymous' in the load options.
import type { App } from '@dioramajs/diorama'
export function cover(app: App) {
return app.assets?.load('https://cdn.example.com/cover.avif', {
type: 'texture',
crossOrigin: 'anonymous',
})
}