如何仅使用画布制作旋转对象(球体、盒子等)
我想仅使用画布制作一个旋转对象(球体、盒子等)。但我找不到教程。如果您看到某个地方或解释如何做,请提供帮助。
像这个示例一样,只是没有任何效果
I'd like to make a rotating object (sphere, box, etc.) using only the canvas. But I can't find a tutorial. Help If you saw somewhere or explain how to do it.
Like this example, only without any effects
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
希望你喜欢数学。如果您愿意编写一些代码,则始终可以在 2D 平面上实现 3D 效果。
一些可能会有所帮助的资源:
计算机图形学简介
并寻求帮助数学,
线性代数书
Hope you like math. 3D effects can always be achieved on a 2D plane if you are willing to write some code.
Some resources that will probably help:
An Intro to Computer Graphics
and for help with the math,
A Book on Linear Algebra
嗯,理论上很简单。一种方法是设置一个计时器,然后当它触发时,清除画布并重新绘制球体,框出任何东西。为了使其更快,您可以覆盖画布的一个区域而不是整个区域。您还可以获取 png 精灵并在画布上移动它们。
我通过尝试 pajamas canvas 包装器进入了这个东西,这意味着你可以用 python 编码,然后将其编译成 js,这对我来说更友好。
http://pyjs.org/examples/gwtcanvas/output/GWTCanvasDemo.html
请注意,该演示有点不完整,但如果您执行 git pull,示例代码确实可以很好地编译和运行。
Ah well it's pretty simple in theory. One way is to just set up a timer and then when it fires, clear the canvas and redraw your sphere, box whatever. To make it faster you can cover over a region of the canvas instead of the whole thing. Also you can get png sprites and move them about on the canvas.
I got into this stuff by trying out the pyjamas canvas wrapper, which means you can code in python and then compile it into js, which to me is a lot friendlier.
http://pyjs.org/examples/gwtcanvas/output/GWTCanvasDemo.html
NB the demo is slightly borken but the example code does compile and run perfectly well if you do a git pull.