Commit Graph

101 Commits

Author SHA1 Message Date
rewin bb9bd4e9f4 Merge branch 'main' into update-version 2024-03-27 22:56:50 +03:00
Lee-Orr 7cea820d78 Auto keyframe/scrubbing/snapping (#107)
Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-03-27 15:22:14 -04:00
Lee-Orr 9b2f1636c3 Move release profile to opt-level 3 (#110)
Co-authored-by: rewin <rewin1996@gmail.com>
2024-03-27 22:19:59 +03:00
rewin d63709c578 . 2024-03-27 20:27:27 +03:00
Danny McGee 21a6cb42fe Fix some issues causing input jank (#106)
This PR fixes two issues that can cause a degraded user experience under
certain conditions:

### Focus-stealing

When focus lands on the `document.body`, it's typically bad for
accessibility and a sign of improper input handling. This generally
occurs when the currently-focused element is removed from the DOM. In
our particular case, it also prevents the Bevy application from
correctly handling keyboard events.

Previously, the problem of `document.body` focus had been fixed by
checking the `document.activeElement` every frame, and redirecting focus
to the Bevy canvas whenever it landed on the `document.body`. However,
when running in an iframe embedded on https://fakeyou.com, our
application will report `document.body` as the `document.activeElement`
whenever the parent application has focus, effectively stealing focus
from the parent application and making it impossible for the user to,
e.g., interact with text fields in the parent app.

This PR removes that focus-stealing behavior. Instead, we should
properly implement the ARIA specifications for any elements that may
disappear from the DOM so that user focus is managed in a precise and
predictable way. That will be addressed in follow-up PRs.

### "Stuck" input states

In certain circumstances, the browser window hosting our application may
lose focus while certain keys/buttons are held down which are bound to
long-running actions in the Bevy application, like camera manipulation.
When that occurs, Bevy is unable to detect when the bound keys/buttons
are released, causing the input state to become "stuck" reading those
keys/buttons as being pressed.

As a workaround, this PR introduces a listener for "blur" events on the
`window`, which dispatches synthetic "keyup"/"pointerup" events to the
Bevy canvas for all affected keyboard keys and mouse buttons.
2024-03-26 19:36:47 -04:00
rewin f581bcd49a Its compilimg 2024-03-26 21:16:22 +03:00
Danny McGee daabc4d562 Fix rotation inspector (#104)
This PR updates the Transform > Rotation section of the Entity Inspector
to display Euler angles in degrees instead of the vector component of
the input quaternion.

Additionally, this updates the `studio/ui/inspector` module to add a
special-case function for updating the selected entity's rotation from
the inspector in a way that's consistent with the behavior of the
rotation gizmo.

### Known Issues

The values displayed for the angles in the inspector are not always
intuitive, especially while actively manipulating them. To some extent
this is just the nature of Euler angles (e.g., Unreal Engine exhibits
similar issues), but I suspect there's room for improvement of our
implementation (e.g., Unreal's rotation display is typically _more_ sane
than ours).

Regardless, fixing this requires a firmer grasp of the math than I
possess, so a fix for this issue is not currently planned.
2024-03-26 14:07:09 -04:00
Lee-Orr f28b7602fb Fix for animation desyncronization bug
Issue turned out to be that in some circumstances, the `group_by` iterator will create multiple groups for a single key - and sometimes those groups can be empty. This lead to situations where an animation track will end up empty until enough changed to re-shuffle things in the query iterator.
The fix is switching to `into_group_map_by` - which will put all grouped items into a hashmap instead, ensuring no duplicate keys.
2024-03-25 16:14:57 -04:00
Danny McGee 0d4072c806 Inspector editing (#96)
This PR adds Material component inspection to the frontend Entity
Inspector, and adds functional editing capabilities for the Transform
and Material inspectors.

### Changes
* Added a `ScalarFieldElement` for numeric form fields, with a hybrid
slider/text-input UX inspired by Blender, Unreal Engine, etc.
* Added `MaterialInspectorElement` for inspecting the Bevy
`StandardMaterial` component
* Wired up the `TransformInspectorElement` and
`MaterialInspectorElement` to apply changes made in the UI to the Bevy
scene
* Refactored the `studio/ui/inspector` module to output `Result::Err`s
to the dev console
* Refactored the `studio/interaction/selection` module to use only the
`Selection` resource, removing the redundant `Selected` component which
added some unnecessary complexity. This fixes #39
* Fixed primitive shapes not receiving a selection outline when selected

### To-Do

These tasks will be addressed in a forthcoming PR:

* The **Transform** > **Rotation** section in the inspector is still not
displaying sensible values. Currently it's just displaying the raw
quaternion `xyz` vector rather than displaying the orientation in
human-readable terms (e.g., as Euler angles).
* We're currently ignoring the Primitive Shape component, which would
allow the user to configure some additional geometric properties of the
shape or replace it with a different one.

---------

Co-authored-by: rewin <rewin1996@gmail.com>
2024-03-22 18:53:28 -04:00
Lee-Orr c890665e16 - avoid updating seek time from UI if source of seek time is studio, … (#102)
…to avoid re-processing timeline info

- move generating animation to first thing in a frame, and notifying
about timeline changes to last, to ensure that it happens before the
time updates
- re-generate the animation tweens whenever you start playing or
manually seek a new time in the timeline to prevent inconsistencies
2024-03-22 17:09:58 -04:00
Lee-Orr 11dc7c7945 add a minimum length of 3 seconds to animations in headless mode (#100) 2024-03-22 13:12:40 -04:00
Danny McGee 97a4aa5716 Auto-play animations in imported scenes (#91)
This PR adds a system to find animation clips in imported glTF scenes
and auto-play them on their associated entities.

The new system runs only in "Viewer" mode, for the purposes of
previewing a scene import on its Storyteller.ai Media File page. In
"Editor" mode, we will eventually expose animation clips to the user
through some other mechanism (TDB -- needs design work, grooming,
etc.).
2024-03-21 22:40:04 -04:00
Lee-Orr 67a12e42e2 Timeline Saving/Loading, Cameras, and Headless Playback (#98) 2024-03-21 20:35:25 -04:00
Lee-Orr 10759af963 save and load keyframe data (#97) 2024-03-21 15:20:50 -04:00
Brandon Thomas 116079fc48 simplify conditional compilation and fix bug 2024-03-21 00:06:11 -04:00
Brandon Thomas ba97339b1b conditional compilation of async compat (#95)
Problems with the previous code:

- `async-compat` is necessary for headless mode (cli server rendering)
to load remote scenes from the API without blowing up. Without it, the
code complains about the lack of a Tokio runtime.

- Unfortunately, `async-compat` doesn't work with WASM and the entire
web build is broken by its presence.

This change introduces conditional compilation so `async-compat` is only
leveraged in headless mode.
2024-03-20 22:36:28 -04:00
Lee-Orr 89487e5889 Headless remote assets issues (#94)
Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-03-20 21:45:09 -04:00
Lee-Orr 0eff115eb5 Animation Timeline Initial (#88)
This PR adds an initial animation timeline.

---------

Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-03-20 20:53:24 -04:00
rewin 2c6affce55 Fixing skybox problems 2024-03-19 21:49:22 +03:00
rewin 4c532fd32c Fix bugs 2024-03-18 21:58:48 +03:00
rewin d9175ca8d8 Its compile 2024-03-15 22:39:16 +03:00
rewin 96e15921ae fmt 2024-03-15 21:45:14 +03:00
rewin d8c837fa1b All stuff beside lerp and screenshot 2024-03-15 21:37:48 +03:00
rewin 98f1398b9f Some more bugs fixed 2024-03-15 20:04:38 +03:00
Brooks Palin 17b0e14dc8 fixed some issues, included a quick hack
The first three-ish frames of rendering are gray. We fixed this by not recording the first 3 frames and then adding 3 frames to the render.
2024-03-14 21:02:57 -06:00
Brooks Palin b9abf1d82f Composite Mode Camera Motions (#86)
This PR adds the camera motions to the composite mode. There are
currently 4 camera motion modes: `Orbit`, `Static`, `Pan`, `Zoom`. They
are accessed by using the `--camera-motion [motion]` argument. For
example, if I want to render a scene with an orbiting motion, I would do
the following:

`studio-headless scene --camera-motion orbit scene.ron `

Some things to note:
- The argument `--orbit` no longer is there. It has been deprecated!
- Currently the speed is hard coded. This can be set as a command arg
later.
- This only works with scenes, as this is intended for the `sample-room`
scene. May not work great for other scenes

Let me know if there is anything that I can fix!
2024-03-14 21:57:20 -04:00
rewin dbf512bb0c first step to 0.13 2024-03-14 23:15:30 +03:00
rewin 75dcd9b8d9 Set correct library versions 2024-03-14 20:48:57 +03:00
rewin 550a92eec1 Inspect for StandartMaterial (#76)
Allow to render StandartMaterial color and change in uniform way as
another components


![image](https://github.com/storytold/storyteller-bevy/assets/10954133/bf2fc91a-642e-40b6-99d3-a18c06dc156a)



![image](https://github.com/storytold/storyteller-bevy/assets/10954133/8534b82d-ed55-4714-8888-257db50c5e0f)
2024-03-07 21:03:42 +03:00
Brooks Palin 9aaf15287a Scaling Gizmo (#72)
This PR adds the Scaling Gizmo to the StoryTeller Engine.

Features
- Objects can now be scaled by Axis or Plane

Limitations
- Currently there is no implementation for combining the scale gizmo
with any of the other gizmo. This should be amended with further PRs.

Let me know if there is anything that I missed!

---------

Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-03-05 16:16:01 -07:00
rewin add1e79fea Logic for inspector field muts (#73)
Allow to send change events from typescript to bevy

Example (test)
```rust
CHANGE_FROM_UI.write_message(UpdateField {
    component: "bevy_transform::components::transform::Transform".to_string(),
    reflect_path: ".translation.x".to_string(),
    value: 0.to_string(),
});
```

Function for typescript
```rust
#[wasm_bindgen(js_name = changeValue)]
pub fn change_value(msg: String) {
    let Ok(msg) = serde_json::from_str::<UpdateField>(&msg) else {
        error!("Failed to parse message: {}", msg);
        return;
    };
    CHANGE_FROM_UI.write_message(msg);
}

```
2024-03-05 22:28:46 +03:00
Danny McGee 9875ea7cca Progress bar for scene loading (#71) 2024-03-04 14:39:48 -05:00
rewin 3a27f3b881 Blocking buttons (#69)
![image](https://github.com/storytold/storyteller-bevy/assets/10954133/6c963b6c-6551-4379-854e-9f3f57cb173d)

---------

Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-03-04 21:33:44 +03:00
Danny McGee 1f2bd9a6ae Fix pipeline fails (#70)
* Removes some unused imports causing linter to fail
* Removes a redundant `InitAsset` variant that was accidentally included
  in #57
2024-03-01 20:30:05 -05:00
Brooks Palin e79a7d4f4c Orbit Options (#67) 2024-03-01 00:51:12 -05:00
Brooks Palin 5cb23f0607 Headless mode Orbit (#66) 2024-03-01 00:20:32 -05:00
Brooks Palin a2b2946678 Headless Mode fixes for the Backend (#65)
This PR brings some fixes that are needed for the backend to render
scenes.
2024-02-29 21:47:42 -07:00
Danny McGee 3413810773 Small batch of misc enhancements (#64)
This PR cherry-picks some improvements from #63 that are general-purpose
and not specifically related to IK.

* Some logic has been added to `AppElement` to track the currently
  selected Scene Element
* `disabled` property has been added to `ButtonElement`, with custom
  styling and accessibility features
* Tagging entities with their `SceneElement` type has been made more
  robust and reliable (previously, it was possible for all entities to
  appear in the hierarchy as "Generic" elements depending on the order of
  system execution)

Additionally:

* Forces the Netlify CI pipeline to always used the latest stable Rust
  version
2024-02-29 15:42:49 -05:00
rewin ae88696213 Inspector: component view part (#55)
This PR allow to send entity components data to typescript with
inspector-dom event

Event data

![image](https://github.com/storytold/storyteller-bevy/assets/10954133/f4b5a88e-0a8d-4d56-ade2-d0102a6c08f7)

Component register example

![image](https://github.com/storytold/storyteller-bevy/assets/10954133/f9480f0a-a657-4445-a0d4-0984e2f69900)

Read event example

![image](https://github.com/storytold/storyteller-bevy/assets/10954133/2b6480f0-d1fb-42f1-bd6e-dfbc3d4676a2)


This PR is the first step of new inspector backend logic
Next parts is:
- Allow to edit components fields 
- Allow to show asset data (like show Handle<StandartMaterial> data)
- Allow to edit asset fields
2024-02-29 23:17:51 +03:00
Danny McGee f31cf35da1 More Image Generator stuff (#59)
YOLO
2024-02-28 15:52:01 -05:00
Danny McGee 61fa16bdba Expose skeletal joints to frontend hierarchy (#56)
This PR exposes skeletal joint entities to the frontend hierarchy,
allowing the user to pose rigged models by selecting the joints and
transforming them.

Additionally, entity-type information (e.g., Mesh, Skeleton, Bone,
Light, etc.) has been added to the data structure passed to the
frontend, which is rendered with icons in the tree view.
2024-02-28 15:47:26 -05:00
Brooks Palin 343919a9f5 Allow Skybox to take a Color (#57)
This PR Adds the ability to set the color of the skybox using the URL
parameters.

- Now you can pass a color's hexadecimal number (without the #) in the
  skybox parameter, and that will set the skybox to that color.
2024-02-28 00:11:37 -05:00
Danny McGee c788bcf6b7 Refactor Studio entry-points (#54)
This PR heavily refactors the entry-point functions in
`studio/src/lib.rs` to simplify and consolidate. Additionally, the
frontend application should now be configurable as expected with any
valid combination of the following URL parameters:

* `objectId` : A pre-bundled library object to load (e.g., "couch.gltf")
* `bvh` : Any resolvable path to a BVH animation with a MocapNET
skeleton (e.g., "mocap/shuffle.bvh")
* `mixamo` : Any resolvable path to a glTF animation with the Mixamo
skeleton (e.g., "mocap/hip-hop-dancing.gltf")
* `sceneImport` : Any resolvable path to an arbitrary glTF scene
(untested, but should theoretically work)
* `scene` : Any resolvable path to a previously saved Storyteller Studio
scene in `*.scn.ron` format
* `skybox` : The ID of a pre-bundled skybox asset. Valid options are:
  - "gum_trees_4k"
  - "kloofenfal_28d_misty_4k"
  - "meadow_4k"
  - "promenade_de_vidy_4k"
  - "scythian_tombs_4k"
  - "test_scene" (this is the default if not specified)
* `mode` : One of "studio" or "viewer" (the default if not specified)

"Validity" rules are as follows:

* `objectId`, `bvh`, `mixamo`, `sceneImport` and `scene` are mutually
exclusive
* `skybox` is not supported for `scene` (the skybox should be saved and
loaded as part of the scene description, though this is not currently
working)
* Both `mode` options are valid for all other parameters
2024-02-27 10:22:00 -07:00
Brooks Palin d51eec52c3 Bootstrap Image Generator application (#53)
This PR begins scaffolding the Stable Diffusion Turbo application (title
TBD), which is a separate frontend for Storyteller Engine which focuses
on image generation.

### Design Overview

* The application renders a "split-screen" view, with Storyteller Studio
  on the left, and the Stable Diffusion Turbo output on the right
* When changes are made in the Studio editor:
  - A screenshot is taken from the Bevy application
  - Screenshot is piped into Stable Diffusion Turbo model
  - Model output is rendered to the screen
* This all happens in as close to real-time as possible

### Work completed in this PR

* The `studio-frontend` project has been (somewhat crudely) refactored
  to split most of its components into reusable libraries
  - `studio-ui` is a use-case-agnostic design system library for core UI
    components. These are "dumb" components which are controlled
    via `@property` inputs and send `CustomEvent`s in response to user
    input.
  - `studio-frontend` is a collection of reusable Storyteller Studio
    widgets. These are "smart" components which depend on
    `@storyteller/studio` directly, manage their own state, and require very
    little configuration or styling. They are designed to be drop-in
    building blocks that can be reused between various frontends.
* The new application has been bootstrapped as `image-generator-demo`
  - Currently, this simply grabs screenshots from the Bevy application and
    renders those screenshots on the right side of the split-screen view. A
    future PR will wire up to the Storyteller.ai backend to pipe these
    screenshots through Stable Diffusion Turbo, and render that model's
    output instead.

### Testing

* Install dependencies as described in the repo's README
* Run `npx nx serve image-generator-demo`
* Open [localhost:4200](http://localhost:4200) in your browser
  - Use the camera controller in the left side of the view to manipulate
    the Bevy scene
  - Verify the right side of the view updates with a fresh screenshot at a
    rate of ~5 fps
* Toggle the "Realtime Capture" checkbox
  - Verify the right side view no longer updates while the user is
    actively manipulating the editor
  - This should allow the app to run smoother on lower-spec hardware

---------

Co-authored-by: Danny McGee <dannymcgee@gmail.com>
2024-02-26 17:13:07 -05:00
Danny McGee 7b06d48c5d Scene storage backend integration (#51)
This PR adds Storyteller.ai API integration for saving and loading
Storyteller Studio scenes to/from the backend.

### Known issues
* The skybox is not currently stored in the serialized scene format
2024-02-23 22:04:06 -05:00
Danny McGee 6ca2a992e5 Storyteller.ai API integration (#49)
This PR integrates asset retrieval from the Storyteller.ai back-end API,
and begins implementing long-term scene saving and storage.

### Media retrieval
Instead of fetching raw asset URLs, going forward, media files from
remote sources (e.g., in URL parameters) should be specified with a path
like the following:
```
remote://<token>.<filetype>
```
where
* `token` is a media token (e.g., "m_70b77neq9jsgmy5v31mekzchcbd223")
* `filetype` is a file extension appropriate for the type of file being
  fetched (e.g., "gltf")

The `remote` protocol will be recognized by a [custom asset
reader](https://github.com/storytold/storyteller-bevy/blob/70726db111f6ccafd47feb055c5546540fef1786/studio/src/remote/reader.rs)
which will retrieve the file by calling a Storyteller API endpoint.

### Scene storage
Additionally, this PR begins laying the groundwork for
storing/retrieving Bevy scenes to/from the backend instead of solely
in-memory. This work is still incomplete -- as of this PR, a button has
been added to the web UI allowing the user to download the scene
file locally for testing/debugging purposes.

### Test URL
Media retrieval from the backend can be tested by [visiting this
URL](https://deploy-preview-49--storyteller-studio.netlify.app/?mode=viewer&mixamo=remote://m_70b77neq9jsgmy5v31mekzchcbd223.gltf)
in Chrome with the `--disable-web-security` flag (to bypass CORS errors)
2024-02-23 21:05:32 -05:00
Brandon Thomas fffcb38ec6 Emit build dependency versions (#52) 2024-02-23 20:52:59 -05:00
Brooks Palin 3258292980 Adding Mixamo Animations to Studio Headless (#50)
This PR adds the ability to render out mixamo animations from the
headless mode. In addition to that, there were some bugs that have been
managed and some readability changes. Let me know if you have any
questions!
2024-02-23 14:18:20 -07:00
Danny McGee bc975779d7 Animation Editor UI (#20)
This PR adds a WIP timeline UI for animating elements in the scene.

### Implemented Features

* The timeline can be panned with MMB and zoomed with Ctrl + Mouse Wheel
* The timeline can be "scrubbed" by dragging the red "play-head" with
  LMB
* The timeline sidebar (displaying the list of tracks) can be resized by
  dragging on the edge of the sidebar
* Keyframes can be added by pressing the "Add Keyframe" CTA in the UI
* Keyframes can be selected for editing by clicking the diamond-shaped
  markers in the timeline
* Selected entities (including but not limited to keyframes) can be
  deleted by pressing the "Delete" key
* Keyframes can be moved temporally by dragging the diamond-shaped
  markers in the timeline

### Known issues

* Zooming the timeline in too far results in a soft-lock
* When zooming the timeline, the "transform origin" is currently
  centered on the `00:00` timestamp. For ease of use, it should center on
  the mouse cursor position instead.
* The timeline track-list is currently hard-coded to list the Camera and
  Camera Target. Clicking on these entries currently serves no useful
  purpose and may result in a crash.
* Keyframe markers in the timeline are not currently associated with
  entries in the track-list and simply appear vertically centered in the
  timeline view.
* Added keyframes currently record the position and orientation of the
  scene camera when added, and are rendered in the world with debug
  visualizations, but serve no useful purpose. Some design work is needed
  (both user-experience and architectural) to decide on a workflow for
  actually animating scene elements.
* Entity deletion cannot currently be undone/redone
2024-02-22 14:21:02 -05:00
Brooks Palin 628dea812f Removed Grid and Fixed Ending Frames (#47)
This PR Removes the gridlines from headless renders and Removes useless
frames from the end of headless renders. Really small PR. Let me know
what you think!
2024-02-22 10:14:45 -07:00