-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
Clipping mask problem with Canvas renderer #494
Comments
By the way, SVG renderer is not viable for me because it does not seem to be capable of drawing radial gradients. I need radial gradients to create the corners of my drop shadows. |
Are you comfortable sharing the source code or creating a more minimal reproduction case? I can try to dig into this. |
Thanks. I've attached a minimal reproduction case. Right now, the file has the following from lines 98 to 103:
But if you add these directly to "two" instead of to mainGroup, then the red square disappears (with the canvas renderer). Like this:
|
The issue appears to be that in the SVG and canvas renderers, transforming a group also transforms its mask, even though the mask is not a child of the group. This seems to have been the case since masks were first implemented. @jonobr1, is this the intended behavior for masks? |
Sounds like you've identified the issue. But just to be sure that it is addressed fully I have made a small update to the reproduction code to be 100% that I've fully reproduced the problem. I've added a green square to the masked area that should pan into view after the arrow is clicked, but fails to do so in svg/canvas renderers. |
There are a couple other issues you mentioned:
Can you provide test cases for these as well? |
No worries. I have updated the code to include these things. I have added 3 shapes to the right-hand side of the screen: two with gradients, and one with a normal fill. The gradients have one stop with an opacity of 0.5, and when using the SVG renderer this causes the gradient in the large circle to be semi-transparent. You can see that it is semi-transparent because it allows the blue square behind it to be visible. But the other renderers do not allow it to be semi-transparent: the blue square is hidden. However, the second problem (with radial gradients) only occurs when the circle with the radial gradient is in the same group as a rectangle with a linear gradient. When in SVG rendering mode, the every circle with a radial gradient will disappear completely if a rectangle with a linear gradient is added. Remove the rectangle gradient from the group to bring the circle back. |
Thanks for posting these issues @juxtapus and for following up @adroitwhiz. Re: masks, I'll confirm today which one is the intended behavior. I love the idea of having a matrix on the documentation to outline the known differences between renderers. Yes, SVG is the only renderer that can do semitransparent gradients, however, you can get around this by using this css directive when setting the stop's color:
|
First response, I'll respond to the clipping mask in another issue. The problem is actually not with radial gradients, but how SVG is its own node scenegraph / hierarchy. You're using the same To be honest, I think Two.js should handle this so that it is consistent between renderers.., but I'm not sure the best way to deal with that yet. |
After some playing around, the intended behavior resides with SVG and Canvas renderers. In @juxtapus's example, you wouldn't actually set the mask to I need to do a bit more poking around, but I'm also open to new ideas of implementation if you anyone feels strongly. For me, I think it's important for the transformations to be consistent, not only between renderers, but between also between masks, gradients, and images / texture because they're all treated as objects in the scenegraph without actually being traditionally added to a parent via an |
Ok thanks. I deleted my recent comment because I made an error. This way of doing things does make sense. But I think perhaps there should be a lengthier explanation (or an example) in the documentation. Its an easy mistake to make. |
Yeah, thanks for pointing it out. I agree that the transformations with masks need more work and clarity. Glad you were able to get things working! |
I am considering switching from WebGL to either Canvas or SVG renderer but I noticed that there are some unexpected differences. I was initially using WebGL, but found that as I added more elements to the screen, the frame rate would suffer noticeably. Here is a link to a video that shows this, followed by a second link that shows the clipping mask problem after I switch to a Canvas renderer.
https://www.dropbox.com/s/y7qf5wxhk9xz05z/two_js%20with%20webgl.mp4?dl=0
https://www.dropbox.com/s/gt705c60f2t1sss/two_js%20with%20canvas.mp4?dl=0
Is this a known issue? And if so, is there a list of known issues or differences between the renderers? I mean, I am aware that semi-transparencies are only available in the SVG renderer for example. It would be good if these differences were a part of the documentation, otherwise choosing a renderer seems to be an exercise in trial and error
The text was updated successfully, but these errors were encountered: