Problem/Motivation

The viewer_3d module currently loads Babylon.js libraries from external CDNs instead of using locally managed libraries through Composer. This creates potential issues for sites that:
- Need to work offline
- Have strict content security policies
- Want to use asset aggregation
- Want consistent version control of all dependencies

Additionally, there's an inconsistency in naming between the libraries.yml definition ('babylonjs') and the hook_page_attachments implementation (which attaches 'viewer_3d/babylon_js'), causing the Babylon.js libraries to never load properly.

Steps to reproduce

1. Install the viewer_3d module using Composer
2. Configure your site to use it with a 3D model
3. Observe that even though npm-asset/babylonjs is required in composer.json, the module still tries to load libraries from CDN URLs
4. Check browser console for errors due to libraries not loading correctly due to the naming mismatch

Proposed resolution

1. Update the viewer_3d.libraries.yml file to use local libraries instead of CDN URLs:
- Change 'babylonjs' to 'babylon_js' to match what's being loaded in the module
- Update paths to point to libraries installed via Composer
- Add proper dependency chain between the viewer_3d library and the babylon_js library

2. Fix the library attachment in the module file:
- Update hook_page_attachments() to attach the main module library which has the dependency
- This ensures all required dependencies are loaded in the correct order

3. Update documentation to clarify composer requirements

Remaining tasks

1. Create and test a patch that implements these changes
2. Update the README.md file with clear installation instructions
3. Create an UPGRADE.md file for users migrating from CDN to Composer-managed libraries

User interface changes

None. The user interface will remain the same, but the libraries will be loaded from local files rather than CDNs.

API changes

None. The module's API remains unchanged.

Data model changes

None. This only affects how libraries are loaded, not data storage.

Issue fork viewer_3d-3518609

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

camoa created an issue. See original summary.

camoa’s picture

Assigned: Unassigned » luisfersegura
Status: Active » Needs review

We need to ensure that we have the right libraries, and they are loaded correctly.

  • anicoto committed cb5c2b44 on 1.0.x authored by camoa
    Resolve Issue #3518609: Fix Composer integration for Babylon.js...
anicoto’s picture

Status: Needs review » Fixed

Merged

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

anicoto’s picture

Status: Fixed » Closed (fixed)