Last active
May 4, 2020 20:17
-
-
Save prideout/fe51ca24264b271792ac51cfe522c92b to your computer and use it in GitHub Desktop.
getting-started-assets
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
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