JSFL - Element.rotation 为 NaN
我正在用 JSFL 编写一个导出器,将 Flash 动画导出为可以在自定义播放器中重播的格式。导出器基本上遍历时间线和每个关键帧处的所有元素,并写出有关元素的信息,包括其位置、旋转、比例等。
我在获取某些元素的旋转时遇到问题,它出来了作为 NaN。最常见的原因是元素被翻转(修改->变换->水平翻转),尽管我认为在其他情况下也可能发生这种情况。到目前为止,如果 someElement.rotation 为 NaN,我已经通过写出 someElement.skewX 而不是 someElement.rotation 来解决这个问题(请参阅 这里是我的一些相关代码,它也尝试检测是否翻转已经发生)。
到目前为止,这是有效的,因为在这些情况下 skewX 值与我期望的旋转值相同。但现在我希望导出器能够处理倾斜和旋转的导出元素,因此我确实需要为旋转提供适当的值。如何从 Flash 中提取正确的旋转值?我可以做些什么来从矩阵中获取旋转值,或者首先阻止旋转为 NaN 吗?
I'm writing an exporter in JSFL, to export Flash animations into a format that can be replayed in a custom player. The exporter basically iterates through the timeline and through all the elements at each keyframe, and writes out information about the element, including its position, rotation, scale, etc.
I have a problem with getting the rotation out of certain elements, it comes out as NaN. The most common cause of this is if an element has been flipped (Modify->Transform->Flip Horizontal), although I think it can happen in other circumstances as well. Up until now I've got around the problem by writing out someElement.skewX instead of someElement.rotation if someElement.rotation is NaN (See here for some of my related code, which also tries to detect if flipping has occurred).
This has worked so far because in those cases the skewX value is the same as the value I'd expect for the rotation. But now I want the exporter to be able to handle exporting elements which are skewed as well as rotated, so I really need to have proper values for the rotation. How can I extract proper rotation values from Flash? Is there something I can do to get rotation values out of the matrix, or to stop rotation from being NaN in the first place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一种从对象矩阵获取旋转角度的方法。
我不确定这会考虑到物体是否倾斜。
从旋转矩阵中提取角度 (inkscapeforum.com)
I found a way to get the rotation angle from the object's matrix.
I am not sure this takes into account if the object is skewed.
extract angle from rotation matrix (inkscapeforum.com)