Comments (6)
It seems to be a problem with the cache calculations.
Until the fix is ready, you can set the position of the camera's scene to half the size of the view:
export default makeScene2D(function* (view) {
const camera = createRef<Camera>();
const browserRef = createRef<Img>();
view.add(
<Camera ref={camera}>
<Img ref={browserRef} src={browser} height={400} width={1000} position={[0, 0]} shadowBlur={10} shadowColor="#0004" />
</Camera>,
);
// Do this after creating the camera:
camera().scene().position(view.size().div(2));
yield* waitFor(10)
});
This should fix the issue for now.
from motion-canvas.
I faced this same issue when simply using a Rect node with shadow or opacity less than 1. The scene position trick is not enough when rotating the camera.
It can be easily reproduced by going to this example and adding a shadowBlur={1}
or a opacity={0.9}
to the Rect node. It will disappear.
from motion-canvas.
This seems to happen also with opacity animations, using the scene position fix by @aarthificial fixed the problem
from motion-canvas.
Inspired by the @aarthificial cache suggestion, I was able to fix it in my case by overriding the worldSpaceCacheBBox()
method on the Node with some filter:
@computed()
protected override worldSpaceCacheBBox(): BBox {
const viewBBox = BBox.fromSizeCentered(this.view().size()).expand(
this.view().cachePadding(),
);
const canvasBBox = BBox.fromPoints(
- ...viewBBox.transformCorners(this.view().localToWorld()),
+ ...viewBBox.transformCorners(this.localToWorld()),
);
const cacheBBox = BBox.fromPoints(
...this.cacheBBox().transformCorners(this.localToWorld()),
).pixelPerfect.expand(2);
return canvasBBox.intersection(cacheBBox);
}
At least for me, it worked. I really don't know the side effects of this change in other scenarios.
from motion-canvas.
I would love to use the camera and am curious if this is fixed.
Have had several opacity issues and rendering issues inside the boxes
from motion-canvas.
@mpaxson still not fixed sadly
I took a stab at it and it seems like making it work properly will require some major changes to our rendering logic. Most of the code assumes that the view doesn't change and things are cached based on that assumption. Unfortunately, cameras challenge this. This may need to wait for version 4 to be released.
from motion-canvas.
Related Issues (20)
- Document node's `element` property HOT 3
- Video stuttering when playing both video and animation HOT 1
- Fix reparent docs not accurate when it comes to layout
- Possibility of using Webcodecs for fast rendering HOT 3
- Video stuttering in editor/presentation mode
- Animating `Txt`'s text with emojis causes broken characters HOT 1
- Automatically set the video's speed based on the desired duration
- Tweening the number of points in a line hangs the page
- Animating a `Rect`'s `size` and `padding` simultaneously causes snapping HOT 1
- Project Selection - Project File Name Must be Different HOT 2
- `lineColor` alias for `stroke` HOT 2
- Audio appears choppy in Brave browser HOT 2
- Getting chroma_js error on Quickstart HOT 3
- Add support for programmatically playing sound effects
- LaTeX: if you isolate invisible delimiters they don't work HOT 1
- Improve documentation for Polynomials HOT 1
- `<Latex/>`'s `stroke` doesn't work
- Animating `tex` and `fontSize` of `Latex` at the same time doesn't let `fontSize` animate HOT 1
- Error to run built animations
- Question about absolutePosition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from motion-canvas.