add texture to 3D Cylinder

This commit is contained in:
Niko Jochim 2020-05-15 17:13:39 +02:00
parent f5b147259a
commit 6c61b97d2c
9 changed files with 60 additions and 2 deletions

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "logo_kante.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "logo_kante-1.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "logo_kante-2.jpg",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "logo_no_background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "logo_no_background-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "logo_no_background-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -39,9 +39,21 @@ class MenuScene: SKScene {
let scnScene: SCNScene = {
let scnScene = SCNScene()
let cylinder = SCNCylinder(radius: 120, height: 30)
let cylinder = SCNCylinder(radius: 250, height: 50)
let material = SCNMaterial()
let material2 = SCNMaterial()
material.diffuse.contents = UIImage(named: "logo_no_background")
material2.diffuse.contents = UIImage(named: "logo_kante")
cylinder.materials = [material2,material,material]
let cylinderNode = SCNNode(geometry: cylinder)
cylinderNode.eulerAngles = SCNVector3(x: Float(CGFloat.pi / 2), y: 0, z: Float(CGFloat.pi / 2))
let action = SCNAction.rotateBy(x: CGFloat(GLKMathDegreesToRadians(360)), y:0 , z: 0, duration: 8)
let forever = SCNAction.repeatForever(action)
cylinderNode.runAction(forever)
@ -49,7 +61,7 @@ class MenuScene: SKScene {
return scnScene
}()
let node = SK3DNode(viewportSize: CGSize(width: 300, height: 300))
let node = SK3DNode(viewportSize: CGSize(width: 250, height: 250))
node.scnScene = scnScene
node.position = CGPoint(x: midX, y: midY + 200)