aws-samples / aws-tools-for-babylonjs-editor

AWS Tools for Babylon.JS Editor is a suite of tools meant to interact with Babylon.JS Editor by utilizing the capabilities of AWS products.
Apache License 2.0
32 stars 9 forks source link

Feature: add script to host to instantiate behaviors at runtime #1

Closed JuliaABurch closed 2 years ago

JuliaABurch commented 2 years ago

Notes

This branch 1) prepares the project workspace by installing all required dependencies and copying in assets, and 2) attaches the script sumerianhost.ts to the instantiated mesh. This script sets up animations and configures the POI feature, so that the host will animate and track the scene's active camera when the "play" button is hit on the scene. An "in progress" toast UX has been additionally added.

Minor file adjustments are included - the retrieveHostAssets script now lives under tools/ instead of scripts/, and the existing Preferences class has been turned into a .ts file rather than a .tsx one (as it does not render JSX.)

Testing

Setup

In order to test this CR, the manual steps to link and install @amazon-sumerian-hosts/babylon must be followed as in the README -- not only in the plugin directory, but in the project workspace directory as well.

To test

  1. Create a new workspace, ensure plugin is installed (as per instructions in the README)
  2. Make sure @amazon-sumerian-hosts/babylon is installed in the workspace directory - this must be manually done for now (see issue #1)
  3. Use the Sumerian Hosts Tools dropdown menu to instantiate a host (who is not Fiona -- see issue #4). The host will spawn in a generic T-pose.
  4. Press the 'play' button. There will be a delay as the scene loads, up to 15 seconds, but you should be able to see the animated host once it loads.
  5. The camera can be optionally configured to map its movements to WASD - select it in the scene graph, scroll down to "keys", and map the movements to whatever configuration you choose. Then, when you play the scene, you can move the camera and see that the host tracks its movements (incorrectly - for now - see Issue #3)

For debugging purposes, View -> Webpack Logs or View -> Typescript Logs may be helpful.

Known Issues

  1. As mentioned in the testing section, this currently does not install the required library @amazon-sumerian-hosts/babylonin the project workspace. This is because @amazon-sumerian-hosts/babylon is not currently available in the npm registry -- it will need to be published and then added to this file before the plugin is made available to the public. (SIM 11207)
  2. The editor update to 4.1.0 broke some behaviors as far as loading textures in the editor -- if you save the scene and reload the project, the textures and materials will fail to load (and yet they will load as expected were the scene to be run outside of the editor.) This issue is independent of this change, and is filed as a bug to be fixed in a separate PR. (SIM 11205)
  3. It is not advisable to set rightHandCoordinateSystem to true on the scene, as the editor does not expect this flag to be true and will become almost unusable. The matrix operations used by the amazon-sumerian-hosts library to calculate POI movements will need to be fixed to work with the default left hand coordinate system. (SIM 11206)
  4. The Fiona host does not have its script attach correctly, due to some apparent strangeness with that particular gltf file and the way it defines its animations. (SIM 11208)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

JuliaABurch commented 2 years ago

Addressing @prestomation 's previous comments:

does the babylon editor have localization support?

It does not - all strings are also defined inline in English. It would be worth revisiting this when localization is supported in the editor.

Does [the characterConfig typed in the sumerianhost.ts script] come from the hosts repo? I wonder if we could type it, and eventually move it to the hosts repo. We don't need to make it typescript, we can use d.ts definition files right?

It does -- and you're right, it'd be better off defined there. I initially thought we'd have to convert to Typescript to accomplish this, but you're right that a d.ts file would work just as well. I'll work this into the next change I have to make in the SumerianHosts repo!