update to new API re instance

This commit is contained in:
Nick Fisher
2022-12-05 17:52:37 +08:00
parent 4d90ba677b
commit bd96d12777

View File

@@ -25,7 +25,7 @@ SceneAsset *SceneAssetLoader::fromGltf(const char *uri,
// Parse the glTF file and create Filament entities. // Parse the glTF file and create Filament entities.
Log("Creating asset from JSON"); Log("Creating asset from JSON");
FilamentAsset *asset = FilamentAsset *asset =
_assetLoader->createAssetFromJson((uint8_t *)rbuf.data, rbuf.size); _assetLoader->createAsset((uint8_t *)rbuf.data, rbuf.size);
Log("Created asset from JSON"); Log("Created asset from JSON");
if (!asset) { if (!asset) {
@@ -64,7 +64,10 @@ SceneAsset *SceneAssetLoader::fromGltf(const char *uri,
rm.setCulling(inst, false); rm.setCulling(inst, false);
} }
asset->getAnimator()->updateBoneMatrices(); FilamentInstance* inst = asset->getInstance();
inst->getAnimator()->updateBoneMatrices();
inst->recomputeBoundingBoxes();
_scene->addEntities(asset->getEntities(), asset->getEntityCount()); _scene->addEntities(asset->getEntities(), asset->getEntityCount());
@@ -80,7 +83,7 @@ SceneAsset *SceneAssetLoader::fromGlb(const char *uri) {
ResourceBuffer rbuf = _loadResource(uri); ResourceBuffer rbuf = _loadResource(uri);
FilamentAsset *asset = _assetLoader->createAssetFromBinary( FilamentAsset *asset = _assetLoader->createAsset(
(const uint8_t *)rbuf.data, rbuf.size); (const uint8_t *)rbuf.data, rbuf.size);
if (!asset) { if (!asset) {
@@ -110,7 +113,10 @@ SceneAsset *SceneAssetLoader::fromGlb(const char *uri) {
rm.setCulling(inst, true); rm.setCulling(inst, true);
} }
asset->getAnimator()->updateBoneMatrices(); FilamentInstance* inst = asset->getInstance();
inst->getAnimator()->updateBoneMatrices();
inst->recomputeBoundingBoxes();
asset->releaseSourceData(); asset->releaseSourceData();
Log("Source data released."); Log("Source data released.");