Hi,
I copied/pasted the html+javascript code of this example in the ‘assets’ folder of my Android app.
When the Android app is launched, I open webgl_loader_gltf.html in a webview ; everything works like a charm (the 3D view is displayed, possibility to zoom/rotate/scale/translate the model).
In this working version of my Android app, the code of webgl_loader_gltf.html is unchanged compared to the Github version of this sample, that is to say:
const loader = new GLTFLoader().setPath( 'models/gltf/DamagedHelmet/glTF/' );
loader.load( 'DamagedHelmet.gltf', function ( gltf ) {...
Now, instead of displaying the helmet of the example, I want to load a gltf file that is generated at runtime in my app. This file is located here on my smartphone disk:
file:///storage/emulated/0/Android/data/com.example.webgltest/files/www/examples/models/gltf/DamagedHelmet/glTF/runtimemodel.gltf
If I change the code of webgl_loader_gltf.html like this :
const loader = new GLTFLoader().setPath( 'file:///storage/emulated/0/Android/data/com.example.webgltest/files/www/examples/models/gltf/DamagedHelmet/glTF/' );
loader.load( 'runtimemodel.gltf', function ( gltf ) {...
I get the following error at runtime:
"Fetch API cannot load file:///storage/emulated/0/Android/data/com.example.webgltest/files/www/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf.
URL scheme "file" is not supported.",
source:https://appassets.androidplatform.net/assets/www/build/three.module.js
So, I am unable to get a file stored on my disk in the folder dedicated to my app. Seems that ‘file:///’ is not understood by javascript (quite understandable…).
Any idea how to solve this issue ? Would it work better if my html + javascript code were hosted on a distant server and not ran locally in the assets folder ?
Thanks for your help.