Hubs-Foundation / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubsfoundation.org
Mozilla Public License 2.0
2.13k stars 1.41k forks source link

Media frame object alignment and scale #6377

Closed rawnsley closed 11 months ago

rawnsley commented 1 year ago

This PR introduces greater control over how objects are snapped into media frames including:

  1. The option to keep the object's current scale.
  2. The option to align with the axis boundaries when the object does not exactly fill the space.

The canonical example would be a board game like chess with irregular sized pieces. Large media frames obscure the board making it hard to place pieces, resizing the pieces to fit the frame will make pawns the same size as kings, and centering the objects within the frame will make some of them float above the board. While it is possible to edit the objects themselves to "hack" around these limitations, it is complicated and not entirely solvable.

Screenshot 2023-11-17 at 15 41 24

This PR expects extra parameters from the companion Blender exporter add-on PR.

The media-frame code was slightly refactored for clarity, including the addition postfixes to some variables indicating their type (obj, eid, etc...). The code has different paths for video objects and for "new loader" imports, all of which were considered.

A test scene was created to demonstrate and explore the various combinations of situations, which can be accessed here:

The best way to understand this PR is probably to grab the code and load this scene. Some text is included to explain the intention of each section. Some of it is designed to test edge cases such as scaled frames, frames on spawned objects, etc...

rawnsley commented 11 months ago

@keianhzo I've pushed the linter fixes now and thanks taking on the merge with your other changes - much appreciated.