[英]What is the proper way to update a Geometry surface in iOS SceneKit?
我知道你可以在第一次将球体或平面添加到场景时通过这样的方式将球体或平面的表面设置为图像。
UIImage image = UIImage.FromFile("firstimage.jpg");
Sphere.FirstMaterial.Diffuse.Contents = image;
但是,当您想要在用户操作上更新它时...就像点击按钮一样。 现在我做这样的事情。
UIImage newImage = UIImage.FromFile("secondimage.jpg");
//digs through the scnview and the scene, into it's child nodes, finds the geometry and replaces the image
mySCNView.Scene.RootNode.ChildNodes[0].Geometry.FirstMaterial.Diffuse.Contents = newImage;
但这看起来有点乱,实际上需要2到3秒才能完成。 我并不特别担心数组索引硬编码。
有没有更有效的方式来进行这种更新?
PS我为一些有趣的代码行道歉,这实际上是用Xamarin.iOS编写的,但是可以随意在Swift或C中回答,我会做翻译。
听起来你的瓶颈是将图像传输到GPU上。 那么预加载怎么样? 在需要之前实例化材料。 然后在用户操作时将其交换出来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.