A repro would really help to better understand what is happening as well as if you use babylon native or react native ?
cc @BabylonNative
I am trying load to local GLTB in my react native project. Itâs working in Android debug build, but GLTF model is not loading in âRelease Buildâ.
I am converting my local model file path into âhttpâ uri using resolveAssetSource.
In degub, file path is coming correct âhttpâ format, but in release mode file path coming like âAssets_3DModels_basic_sci-fi_crate_screne1.gltfâ
Do you how to get file path in âhttpâ format in android release mode.
Is there any way to load model in android release build?
I shared my code below
import resolveAssetSource from âreact-native/Libraries/Image/resolveAssetSourceâ;
const sceneGLBUri = resolveAssetSource(ââŚ/âŚ/Assets/3DModels/basic_sci-fi_crate/scene1.gltfâ).uri;
const { meshes, animationGroups } = await SceneLoader.ImportMeshAsync(
ââ,
sceneGLBUri,
ââ,
scene
);
Maybe this discussion helps you, it is including your case with Android Release mode:
opened 12:55PM - 01 Mar 21 UTC
enhancement
Hi!
First of all, thanks for the great work for all maintainers.
I've ju⌠st started using this library in my project for rendering `.glb` files.
When the `.glb` file is served from a local static server, `SceneLoader.ImportMeshAsync` and other similar methods used for importing assets, such as `Append`, `AppendAsync`, etc.. work perfectly. However, when the file is not requested over HTTP, but rather the local path is provided to the above stated methods, the app just crashes without any easily traceable error (I wasn't looking so hard for the error, but it didn't appear in the terminal of the packager). Maybe it's my uneducatedness but from the documentation available [here](https://doc.babylonjs.com/divingDeeper/importers/loadingFileTypes), I expected the import to work with just a local path.
I was able to solve the issue by using `expo-asset` to load the `.glb` file instead and provide a local uri, and then passing that local uri to Babylon, described in the below way:
```ts
import '@babylonjs/loaders';
import { Asset } from 'expo-asset';
import { SceneLoader, ... } from '@babylonjs/core';
const [{ localUri }] = await Asset.loadAsync(
require('/assets/3d/tesla-high.glb')
);
const { meshes } = await SceneLoader.ImportMeshAsync(
'',
localUri as string,
'',
scene
);
```
However, I'd expect the library to do something similar internally, making the user to be able to only provide a path to a local `.glb` file and it load it without issues. If this work is purposefully left for the user, it would be nice to have it stated in the main documentation, since I think it's quite a common use-case.
This is how it is implemented in Space Pirates via require(âŚ):
var envCube = CubeTexture.CreateFromPrefilteredData(envUri, scene, ".env");
envCube.name = "environment";
envCube.gammaSpace = false;
envCube.rotationY = 1.977;
scene.environmentTexture = envCube;
// glow
const glowLayer = new GlowLayer("glowLayer", scene);
glowLayer.intensity = 0.5;
const sceneGLBUri = resolveAssetSource(require('./assets/nativeStaticScene.glb')).uri;
SceneLoader.AppendAsync("", sceneGLBUri, scene).then(() => {
const starsGLBUri = resolveAssetSource(require('./assets/starsGeo.glb')).uri;
SceneLoader.AppendAsync("", starsGLBUri, scene).then(() => {
const starfield = scene.getMeshByName("starsGeo");
starfield.scaling = new Vector3(4500, 4500, 4500);
setStarfield(starfield);
const starsShader = require('./assets/starfieldShader.json');
const starsPanoramaUri = resolveAssetSource(require('./assets/starfield_panorama_texture.jpg')).uri;
var starsShaderMaterial = new NodeMaterial("starsShader", scene);
I have tried exo-assest Gltf is working debug mode, itâs not working in release mode.
but glb working fine both debug and release mode.
Hi @sebavan @Takemura Do you have idea about babylon js apps in playstore. using gltf models.
Cedric
October 19, 2022, 2:55pm
8
Yes, itâs a known issueâŚstill on the radar with no ETA yet.
2 Likes
Cedric
November 7, 2022, 1:38pm
10
No, sorry. Still on my radar though.
1 Like
Just to check, any update/fixes on this? Right now Iâm using React Native 0.72.3 and @babylonjs /react-native 1.6.3. But the model is not showing on Android release mode. Itâs working on Debug mode.
I also tried using .glb file and assign the path to {uri: "assets/model.glb"}
instead of using require("./model.glb)
but it is still not showing.
Cedric
September 26, 2023, 8:51am
12
1 Like
@Cedric any updates on the workarounds?
Cedric
October 11, 2023, 6:36am
14
no new update. did you try those provided in the github issue?
oh I havent tried them all. just checked, will try them out. thanks Cedric!
1 Like