CATransform3DScale expecting CATransform3D struct not SCNMatrix4

给你一囗甜甜゛ 提交于 2019-12-11 11:37:27

问题


I am trying to put some 3D text in my app, but I need to scale it, here is the code I'm trying to use:

SCNText *text = [SCNText textWithString:@"Some Text" extrusionDepth:4.f];
 SCNNode *textNode = [SCNNode nodeWithGeometry:text];
 textNode.position = SCNVector3Make(-1, 5, 0);
 textNode.transform = CATransform3DScale(textNode.transform, .1f, .1f, .1f);
 [root addChildNode:textNode];

and I get a

CATransform3DScale expecting CATransform3D struct not SCNMatrix4 or something of the sort. If I don't transform, the text takes up most of the screen. Any ideas? Thanks


回答1:


on OS X SCNMatrix4 is a typedef of CATransform3D (and thus you can use CoreAnimation utils) but that's not true on iOS. Have a look at SceenKitTypes.h, it exposes functions that match the ones of CA such as SCNMatrix4Scale.

Also it's strange that the text appears too big in your screen. The default font size is rather small and you must almost always change the geometry's font size for it to fit well in your scene (changing the font size is better than scaling because the discretization of the glyph changes and lead to smoother curves). Is that text the only thing in your scene?



来源:https://stackoverflow.com/questions/26263605/catransform3dscale-expecting-catransform3d-struct-not-scnmatrix4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!