- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 SCNNode,我正在使用此方法将 .dae 文件中的几何图形应用到它:
func addNode(gridPosition: SCNVector3, row: Int, gamePlaneHeight: Float, sceneArray: [ObjectInfo]) -> SCNNode {
// Create a material using the model_texture.tga image
let carMaterial = SCNMaterial()
carMaterial.diffuse.contents = UIImage(named: "assets.scnassets/Textures/model_texture.tga")
carMaterial.locksAmbientWithDiffuse = false
// Create a clone of the Car node of the carScene - you need a clone because you need to add many cars
var carNode: SCNNode!
let randomNumb = AppDelegate().randRange(0, upper: sceneArray.count - 1)
let selectedObject = sceneArray[randomNumb]
carNode = selectedObject.objectscene.rootNode.childNodeWithName(selectedObject.objectname, recursively: false)!.clone() as SCNNode
carNode.scale = SCNVector3(0.5, 0.5, AppDelegate().randomBetweenNumbers(0.8, secondNum: 2.2))
carNode.name = selectedObject.objectname
carNode.position = gridPosition
carNode.position.y = carNode.position.y + gamePlaneHeight
// Set the material
carNode.geometry?.firstMaterial = carMaterial
return carNode
}
该方法大部分时间有效,但偶尔会在线上崩溃
carNode.geometry?.firstMaterial = carMaterial
错误
fatal error: unexpectedly found nil while unwrapping an Optional value
warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.
我不明白为什么,因为大多数时候它都有效。
最佳答案
carNode
是从 selectedObject.objectname
构建的。如果场景中不存在 selectedObject.objectname
,则 childNodeWithName
将返回 nil
。因为 carNode
是一个隐式展开的可选项,Swift 将尝试展开 nil
并崩溃。
您应该使 carNode
可选(var carNode: SCNNode?
)或添加测试,例如 if carNode == nil { ... }
并尝试调试您的输入 (selectedObject
) 是什么以及它为什么不正确。
关于ios - 设置 SCNNode 几何属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36073353/
我想知道是否可以将简单的位图转换为几何对象 最佳答案 是的,您可以使用跟踪。 Potrace是一个开源的位图到矢量跟踪器库。 然而,位图追踪并不完美。对于高质量的矢量图像,line tracer 一般
这类似于this question,但是却相反。 我有两个地理位置(纬度,经度)A和B。假设它们相距40海里。我想计算在A和B之间的直线上,从A点起10海里处的坐标。数学(我每天使用的其他一些数学),
我想计算一个点到由 2 个点定义的直线的距离。 我正在使用 javascript,这就是我使用维基百科得出的结论:https://en.wikipedia.org/wiki/Distance_from
我对 boost::geomentry 有疑问。 #include #include #include #include int main(){ typedef boost::geometry
我有一个问题。我想将四边形与四边形相交。 int main(){ typedef boost::geometry::model::point_xy TBoostPoint; typedef b
我无法在 OpleGL 中获得正确的转换。 我有 point3D - P(X,Y,Z) 和投影矩阵 M,它等于 K*(R|T) 其中 K - 相机标定矩阵 (R|T)——点(物)坐标系变换(R——旋转
我想做一个凸面(由一些直线或圆弧组成)围绕它的几何中心(Cx,Cy)旋转。同时凸面两侧有两个圆(由半径给出:R 和左中心:(Lx,Cy),右中心:(Rx,Cy))。表示与几何(Cy) X 轴相同的圆心
我有一个 DrawingVisual表示路径的元素,该路径的几何描述由此 syntax : "m106,59.3c0-1.98,0,0-4.95,0.989-3.96,0.989-13.8,3.96-
如何将我自己的数据集转换为可供 pytorch 几何图形神经网络使用的数据集? 所有教程都使用已转换为 pytorch 可用的现有数据集。例如,如果我有自己的点云数据集,我如何使用它来训练图神经网络的
我正在使用 PyQt5 和 OpenCV。我想创建一个读取视频帧并执行橡皮筋拉伸(stretch)以生成几何图形的类,该几何图形将由不同的类用于裁剪视频流(此示例中不包括第二类)。 在此示例中,从网络
我们有两个 (PostgreSQL 9.2) 表。第一城市: loc_id | integer | not null name | character
我有一张 table : create table if not exists places( id bigserial not null constraint places_pkey primary
我在 postgresql 中有一个带有 PostGIS geometry(point, 4326) 列(位置,使用 SRID 4326)的表,我有一个使用 SQL Alchemy 更新表(其余列)的
我开始使用 c++11 并尝试使用 boost geometry 运行一些示例代码 #include #include #include #include BOOST_GEOMETRY_REG
我有一个存储为 csv 文件的数据框,其中一列是多边形对象。但是,此列存储为字符串而不是 GeoPandas 几何对象。如何将此列转换为 Geopandas 几何对象以便执行地理分析? 这是我的数据的
我从两台相同品牌的相机拍摄的两张图像相距一定距离,拍摄相同的场景。我想计算两个相机之间的真实世界旋转和平移。为了实现这一点,我首先提取了两个图像的 SIFT 特征并匹配它们。 我现在有了基本矩阵以及单
我目前正在使用 boost 几何/空间索引库,以便对 3d 边界框执行范围查询。例如,我能够获得与查询边界框重叠的所有边界框的列表。 文档 ( http://www.boost.org/doc/lib
boost::geometry::model::point 将点的维度作为编译时参数。例如, typedef bg::model::point point; 有没有什么方法可以在运行时指定维度,比如说
我一直在寻找一种在 three.js 中将 uv 映射添加到我的自定义几何体的方法。我找到了这样做的方法,但我找到的解决方案都没有用。谁能解释一下 uv-mapping 的工作原理以及如何正确使用它?
在我的应用程序中,用户可以使用 iPhone 的 GPS 定义足球场的三个角落,方法是一个接一个地走到角落,然后点击按钮。这很好用,我可以在屏幕上绘制生成的矩形,类似于它在 Google map 中的
我是一名优秀的程序员,十分优秀!