简体   繁体   English

使用javascript / css3 / canvas对图像/ 3D /精灵进行动画处理

[英]Animating image/3D/sprite with javascript/css3/canvas

Kind of a dilemma here. 这里有点两难。 I am making a mobile version of a website, that has some interactive things more specifically I have this object in 3D that you can spin, I was using papervision in Flash but now I need to do this differently since there is no flash in mobile and I feel I am on thin ice. 我正在制作一个网站的移动版本,其中包含一些交互性的内容,更具体地讲,我具有可旋转的3D对象,我在Flash中使用papervision,但由于在移动设备中没有Flash,我觉得自己在冰上。

I was thinking of exporting a 360 degree spin @ 30 FPS using a PNG sequence with alpha channel, and then simply stiching them together into a sprite, then using this as a background in CSS and using background-position to then "simulate" an animation. 我当时正在考虑使用带有Alpha通道的PNG序列导出360度旋转@ 30 FPS,然后将它们一起拼接成精灵,然后将其用作CSS中的背景,然后使用background-position来“模拟”动画。

That or simply switch source image very rapidly, or somehow using "canvas" maybe, the thing is I am not sure if this will produce completely subpar performance? 那或者只是非常快速地切换源图像,或者以某种方式使用“画布”,问题是我不确定这是否会产生完全低于标准的性能吗? I mean switching the background-position or image source file @ 30 FPS is that even possible? 我的意思是甚至可以以30 FPS切换背景位置或图像源文件吗? Would it be smooth, or is this simply something that is not feasible todo yet? 会不会很顺利,或者这仅仅是尚不可行的事情? Keep in mind it's just one single 3D object that needs to spin based on user input, not any other interactive elements. 请记住,这只是一个需要根据用户输入旋转的3D对象,而不是任何其他交互式元素。

So is sprite the way togo or canvas or something cool I havent even heard of? 那么精灵是走还是帆布的方式,或者我什至没有听说过的很酷的东西? Thanks everyone in advance! 提前谢谢大家!

If I was making a mobile version of a website, I would strip it of most of the graphics and definitely of all the animated gifs, flash, etc. -- people using mobile phones for browsing the web are usually not after the multimedia experience -- they just need some information quickly and use a suboptimal device with poor bandwidth and even worse display and performance to get it. 如果我制作的是网站的移动版本,则将剥夺大多数图形以及所有动画gif,flash等的图形。使用手机浏览Web的人们通常不会拥有多媒体体验, -他们只需要快速获取一些信息,并使用带宽欠佳,显示和性能甚至更差的次佳设备来获取它。 Don't make it even harder for them. 不要让他们更难。

On the other hand, I found that using a background image with all the frames of animation in it, and manipulating the background-position from javascript is a fine way of making small animated sprites, for example for a simple javascript game for mobile phones :) 另一方面,我发现使用包含所有动画帧的背景图像,并从javascript处理background-position是制作小型动画图片的一种好方法,例如,用于手机的简单javascript游戏: )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM