gpt4 book ai didi

swift - 具有透明度的闪烁 SCNTube

转载 作者:搜寻专家 更新时间:2023-10-31 22:39:47 25 4
gpt4 key购买 nike

已更新

我使用以下 Material 创建了一些 SCNTube:

let radius: CGFloat = 0.3
let height: CGFloat = 0.5
let color: UIColor = UIColor(red:0.17, green:0.62, blue:0.76, alpha:1.0)

let geometryTube = SCNTube(innerRadius: (radius - 0.1), outerRadius: radius, height: height)
let matOuter = SCNMaterial()
matOuter.diffuse.contents = color
matOuter.transparency = 0.1
let matInner = SCNMaterial()
matInner.diffuse.contents = color
matInner.transparency = 0.6
let matTop = SCNMaterial()
matTop.diffuse.contents = color
geometryTube.materials = [matOuter, matInner, matTop]

for index in 0...20 {
let node = SCNNode(geometry: geometryTube)
node.position = SCNVector3(1.0 + Double(index), -1.0, 0.0);
sceneView.scene.rootNode.addChildNode(node)
}

灯管闪烁的角度取决于角度。

最佳答案

materials 属性设计为每个geometry 都有一个material - 而您要为一个几何体分配三种 Material .这些都是重叠的,scenekit 必须决定在每个点渲染什么。

编辑:我的回答(以上)是错误的 - 我不会删除它,而是添加 this强调我错的原因:

If a geometry has the same number of materials as it has geometry elements, the material index corresponds to the element index. For geometries with fewer materials than elements, SceneKit determines the material index for each element by calculating the index of that element modulo the number of materials. For example, in a geometry with six elements and three materials, SceneKit renders the element at index 5 using the material at index 5 % 3 = 2.

很抱歉对您的问题没有帮助。

关于swift - 具有透明度的闪烁 SCNTube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49324471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com