根据本文,我已经在SceneKit中成功构建并显示了自定义几何图形(立方体)
现在,我想将每个面孔的颜色设置为不同的颜色。我发现这篇文章应该这样做
不幸的是,我似乎无法将立方体表面的颜色设置为特定颜色。例如,如果我将所有顶点的颜色都设置为 Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 7.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.4.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.3.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.2.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.0.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.0.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 7.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- Installation request for phpunit/phpunit ^7.0 -> satisfiable by phpunit/phpunit[7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.4.0, 7.4.1, 7.4.2, 7.4.3, 7.4.4, 7.4.5, 7.5.0, 7.5.1, 7.5.x-dev].
,则我希望所有的面都是红色的,但是,它们都是绿色的。将颜色设置为SCNVector3(x:1,y:0,z:0)
会使面孔变黑。这是相关代码
SCNVector3(x:0,y:1,z:0)
有人知道为什么它不起作用吗?
答案 0 :(得分:0)
您必须为每个面创建具有不同颜色的材质。
例如:
let material1 = SCNMaterial()
material1.diffuse.contents = NSColor.whiteColor()
let material2 = SCNMaterial()
material2.diffuse.contents = NSColor.greenColor()
let material3 = SCNMaterial()
material3.diffuse.contents = NSColor.redColor()
let material4 = SCNMaterial()
material4.diffuse.contents = NSColor.blackColor()
let material5 = SCNMaterial()
material5.diffuse.contents = NSColor.blueColor()
let material6 = SCNMaterial()
material6.diffuse.contents = NSColor.whiteColor()
geometry.materials = [material1,material2,material3,material4,material5,material6]