标签: scnsphere

多边形为原始类型的SCNGeometry

试图弄清楚如何创建一个以多边形为PrimitiveType的SCNGeometry,我的目标是添加多边形形状的节点作为球面节点的子节点,并使它看起来像MKPolygon的地图工具包,如本例所示

MK多边形

我当前的代码是:

//Take an arbitrary array of vectors
let vertices: [SCNVector3] = [
SCNVector3Make(-0.1304485, 0.551937, 0.8236193),
SCNVector3Make(0.01393811, 0.601815, 0.7985139),
SCNVector3Make(0.2971005, 0.5591929, 0.7739732),
SCNVector3Make(0.4516893, 0.5150381, 0.7285002),
SCNVector3Make(0.4629132, 0.4383712, 0.7704169),
SCNVector3Make(0.1333823, 0.5224985, 0.8421428),
SCNVector3Make(-0.1684743, 0.4694716, 0.8667254)]

//Does polygon shape require indices?
let indices: [Int] = [0,1,2,3,4,5,6]

let vertexSource = SCNGeometrySource(vertices: vertices)
let indexData = Data(bytes: indices, count: indices.count * MemoryLayout<Int>.size)

//Note!!! I get compiler error if primitiveCount is greater than 0
let element = SCNGeometryElement(data: indexData, primitiveType: .polygon, primitiveCount: 0, …
Run Code Online (Sandbox Code Playgroud)

ios scenekit swift scnnode scnsphere

4
推荐指数
1
解决办法
1915
查看次数

SceneKit:让子球体在半透明父球体内可见?

在SceneKit中,假设您要在半透明节点Parent中嵌入一个节点Child,这样Parent就像一个"笼子",您可以看到并查看Child.

具体地说,Parent表示半径为2的SCNSphere.Child是半径为1的SCNSphere,是Parent的子节点.

由于它在父母内部,因此儿童不可见.将Parent的不透明度设置为0.3或半透明的东西也会影响Child的不透明度,让您看到Child,但现在Child不再是完全不透明的.

你怎么能让孩子完全不透明,但仍可通过家长看到?

一个选项是Child一个独立节点,不再是Parent的子节点,而是手动计算将Child"inside"Parent中心所需的位置.但这需要每次父移动时手动移动Child,而当Child已经是Parent的子节点时,此移动自动发生.

有更好的方法吗?

ios scenekit scnnode scnsphere

2
推荐指数
1
解决办法
679
查看次数

标签 统计

ios ×2

scenekit ×2

scnnode ×2

scnsphere ×2

swift ×1