Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDEA] WebAnimations compatibility: observe changes to motor-html element CSS transform, then apply to scene graph? #42

Closed
trusktr opened this issue Jun 26, 2016 · 1 comment

Comments

@trusktr
Copy link
Member

trusktr commented Jun 26, 2016

We can use MutationObserver (or something else?) to observe changes to a <motor-node> or <motor-scene> element's CSS transform style property, then we can apply those changes to the element's corresponding scene graph Node.

This would make it possible to use the WebAnimations API on motor-html elements to make changes to the scene graph.

A neat side-effect of this would be that WebAnimations could then be used to animate WebGL things simply by animating the transforms on the motor-html elements, once we introduce "mixed mode" (the term coined by Famous back when the project was open source).

Caveats:

  • How would we synchronize with Motor's animation loop? Maybe in the doucmentation we just encourage developers to use the WebAnimations API inside of a Motor render task (Motor.addRenderTask()). Changes observed by MutationObserver would be synchronous, and would be applied before Motor API modifications. This would mean that it is possible to animate a rotation with WebAnimations, and animate a position using Motor API. If trying to animate position both with WebAnimations and Motor API, then the result would be silly: what I believe would happen is that the WebAnimation position would apply, then the Motor API position would apply, effectively overriding the WebAnimation changes. I am not sure if/when WebAnimations fire inside of a requeatAnimationFrame. Need to experiment...
@trusktr trusktr changed the title [IDEA] Observe changes to CSS transform, apply to scene graph. [IDEA] WebAnimations compatibility: observe changes to motor-html element CSS transform, then apply to scene graph. Jun 26, 2016
@trusktr trusktr changed the title [IDEA] WebAnimations compatibility: observe changes to motor-html element CSS transform, then apply to scene graph. [IDEA] WebAnimations compatibility: observe changes to motor-html element CSS transform, then apply to scene graph? Jul 6, 2017
@trusktr
Copy link
Member Author

trusktr commented Dec 21, 2021

This is no longer a good idea. WebAnimations is simply designed for CSS rendering, and trying to use it for animating anything besides CSS properties is not possible.

(Use Tween.js instead, which I'm maintaining, and is generic for animating any sort of number, which you can then apply to CSS properties, or to something else like WebGL properties )

@trusktr trusktr closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant