Edit clone's variable in Scenekit











up vote
0
down vote

favorite












I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".



Here is my complete code :



@objc func createInfoPanels(climName: String) -> SCNNode {

let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!

let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear

let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4

let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear

let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0

let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1

skScene.addChild(rectangle)
skScene.addChild(labelNode)

let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene

planeGeometry.materials = [panelMaterial]

climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]

return planeNode

}


Thanks in advance for your help!










share|improve this question






















  • where is clone function?
    – Simone Pistecchia
    22 hours ago















up vote
0
down vote

favorite












I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".



Here is my complete code :



@objc func createInfoPanels(climName: String) -> SCNNode {

let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!

let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear

let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4

let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear

let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0

let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1

skScene.addChild(rectangle)
skScene.addChild(labelNode)

let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene

planeGeometry.materials = [panelMaterial]

climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]

return planeNode

}


Thanks in advance for your help!










share|improve this question






















  • where is clone function?
    – Simone Pistecchia
    22 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".



Here is my complete code :



@objc func createInfoPanels(climName: String) -> SCNNode {

let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!

let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear

let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4

let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear

let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0

let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1

skScene.addChild(rectangle)
skScene.addChild(labelNode)

let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene

planeGeometry.materials = [panelMaterial]

climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]

return planeNode

}


Thanks in advance for your help!










share|improve this question













I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".



Here is my complete code :



@objc func createInfoPanels(climName: String) -> SCNNode {

let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!

let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear

let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4

let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear

let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0

let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1

skScene.addChild(rectangle)
skScene.addChild(labelNode)

let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene

planeGeometry.materials = [panelMaterial]

climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]

return planeNode

}


Thanks in advance for your help!







swift sprite-kit clone scenekit






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Silvering

129113




129113












  • where is clone function?
    – Simone Pistecchia
    22 hours ago


















  • where is clone function?
    – Simone Pistecchia
    22 hours ago
















where is clone function?
– Simone Pistecchia
22 hours ago




where is clone function?
– Simone Pistecchia
22 hours ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373190%2fedit-clones-variable-in-scenekit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373190%2fedit-clones-variable-in-scenekit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]