Io sono la conversione del codice Objective-C per il codice Swift e ho il seguente problema:Conversione da una struct all'altro
Il codice Objective-C è
SCNNode *textNode = [SCNNode nodeWithGeometry:text];
textNode.transform = CATransform3DInvert(self.chartNode.worldTransform);
Questo è il codice che ho convertito provato:
let textNode = SCNNode(geometry: text)
textNode.transform = CATransform3DInvert(self.chartNode.worldTransform)
Tuttavia, ottengo un errore: 'SCNMatrix4 non è convertibile in CATransform3D'
Ho realizzato che CATransform3DInvert accetta un parametro di tipo CATransform3D, mentre il parametro che ho incluso è di tipo SCNMatrix4.
Ho provato il seguente tentativo di fusione:
textNode.transform = CATransform3DInvert(CATransform3D(self.chartNode.worldTransform))
, ma questo non funziona.
Ho poi scoperto che entrambi CATransform3D e SCNMatrix4 sono entrambi le strutture e sono sicuri su come convertire da una struttura per l'altro (o anche se è possibile per la conversione tra le strutture a Swift?)
Forse c'è è un altro approccio più semplice?
Qualsiasi aiuto sarebbe apprezzato - Grazie.
appare come questa si risponde per Objective-C [qui] (http://stackoverflow.com/questions/26263605/catransform3dscale-expecting-catransform3d -struct-not-scnmatrix4), il consiglio dovrebbe essere facilmente trasferibile a Swift. –
Perché non usi 'SCNMatrix4Invert'? – rintaro
Grazie per il link. –