I'd like to present the canvas as a cylindrical cone, which you can spin like a wheel in both directions. Is this at all possible with JS/CSS3?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
The HTML-Canvas is in the actual state only 2D, but the ThreeJS framework seems to be a pretty good solution for 3d-rendering within the canvas-element.
You should take a look at this new CSS3 feature: the Custom filters / CSS shaders.
Here are some really nice presentations made which describe the whole thing better than I could do (how to enable it on Chrome, how to start, how it works, etc):
Basically, if you're already familiar with shaders and CSS3 transforms, it's all done...
Advantages
Inconvenients
Example
To answer your more-precise requirements (canvas as a cylindrical cone), I made this small example: http://aldream.net/various/css-shader-demo/cylindricalConeTransformDemo.html. Hover above the canvas to make it wrap into a cone.
It doesn't spin, I just applied a simple transition effect I took from one example in the articles given above, but you should get the idea.
The vertex shader and fragment shader used can be found here:
Simplified & commented Code
EDIT : I'm actually not sure if you're asking for a cone or a cylinder, but the difference is small here. If you want the 2nd, you modify the computeCylindricalConePosition() function in the vertex-shader, evaluating p.x and p.y like this instead:
I hope it helps. I will try to develop my answer once I clarify some points.