Skip to content

Instantly share code, notes, and snippets.

@prideout
Last active May 4, 2020 20:17
Show Gist options
  • Save prideout/fe51ca24264b271792ac51cfe522c92b to your computer and use it in GitHub Desktop.
Save prideout/fe51ca24264b271792ac51cfe522c92b to your computer and use it in GitHub Desktop.
getting-started-assets
override fun onCreate(savedInstanceState: Bundle?) {
// ...
loadGlb("DamagedHelmet")
modelViewer.scene.skybox = Skybox.Builder().build(modelViewer.engine)
}
private fun loadGlb(name: String) {
val buffer = readAsset("models/${name}.glb")
modelViewer.loadModelGlb(buffer)
modelViewer.transformToUnitCube()
}
private fun readAsset(assetName: String): ByteBuffer {
val input = assets.open(assetName)
val bytes = ByteArray(input.available())
input.read(bytes)
return ByteBuffer.wrap(bytes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment