Last active
October 20, 2021 15:01
-
-
Save levantAJ/0cbd0ea39901628c172de52f8880784f to your computer and use it in GitHub Desktop.
Create SCNNode from USDZ file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class USDZNode: SCNReferenceNode { | |
init?( | |
name: String, | |
position: SCNVector3? = nil, | |
scale: SCNVector3? = nil, | |
pivot: SCNMatrix4? = nil | |
) { | |
guard let usdzURL: URL = Bundle.main.url(forResource: name, withExtension: "usdz") else { return nil } | |
super.init(url: usdzURL) | |
if let scale: SCNVector3 = scale { | |
self.scale = scale | |
} | |
if let position: SCNVector3 = position { | |
self.position = position | |
} | |
if let pivot: SCNMatrix4 = pivot { | |
self.pivot = pivot // the billboard look's direction | |
} | |
self.load() | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment