-
Notifications
You must be signed in to change notification settings - Fork 10
Description
API Bug: backgroundLoaded
event doesn't fire for environments, only for backgrounds
Description
The backgroundLoaded event documentation states it should fire for both backgrounds and environments, but it only fires for backgrounds. Environment loading completion is not detected. According to the API Documentation, the backgroundLoaded
event should fire when the background or an environment is loaded but it only seems to work for a background, not an environment. This even seems to happens in your own Sample Examples.
Expected Behavior
backgroundLoaded
event should fire when any background content is loaded (environments, background images, background colors)- This would allow developers to track complete loading progress including all background assets
Actual Behavior
backgroundLoaded
event only fires when manually changing background images- The event does not fire for environments at all, even when they're the primary background content
- This makes it unreliable for tracking loading progress of environment-based backgrounds
Steps to Reproduce
- Load a model with an environment (not just a background image/color)
- Add event listener for
backgroundLoaded
:api.addEventListener('backgroundLoaded', () => { console.log('Background loaded!'); });
- The event never fires, even though the environment is clearly loaded and visible
- Only fires when manually changing background images
Code Example
// This never fires for environments
api.addEventListener('backgroundLoaded', () => {
console.log('Background loaded - this should fire for environments too');
});
// Test different background changes - only the image change triggers the event
api.setEnvironment('studio'); // No event fired
api.setBackgroundColor('#ff0000'); // No event fired
api.setBackgroundImage('https://example.com/image.jpg'); // Event fires only after this change
This replaces the current code example section and shows that the event only fires when changing to a background image, not when setting environments or background colors.
Impact
This prevents developers from accurately tracking complete loading progress for models with environments, as the backgroundLoaded
event cannot be relied upon for environment loading. Developers must use workarounds like waiting for viewerready
to assume all background content is loaded.
Environment
- Sketchfab Viewer API v1.12.1
- Tested with models that have environments (not just background images)
- Browser: Chrome/Firefox/Safari
Additional Context
The official documentation example shows the event being used, but doesn't clarify that it only fires for background images/colors, not for environments.