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.