I have a gltf file which exist in firebase storage folders and related textures are also located in that folders. I want to load that object into my view .
I tried get download url of gltf file from firebase and pass it it GLTFLoader. But model was not loaded to view. Console error shows could not load textures files. I tried with this ,
this.storage.ref('3D-Models/' + folderNo + '/sphere.gltf').getDownloadURL().subscribe((url) => {
const loader = new GLTFLoader()
loader.load(
url,
(gltf) => {
gltf.scene.traverse( ( child ) => {
if ( child instanceof THREE.Mesh ) {
console.log(child.material.metalness)
if(child.material.metalness){
child.material.envMap = texture;
}
}
} );
var parent = gltf.scene;
var box = new THREE.Box3().setFromObject(parent)
var center = box.getCenter(new THREE.Vector3())
var size = box.getSize(new THREE.Vector3())
var maxAxis = Math.max(size.x,size.y,size.z)
parent.scale.multiplyScalar(1/maxAxis)
box.setFromObject(parent);
box.getCenter(center)
box.getSize(size)
parent.position.copy(center).multiplyScalar(-1)
scene.add(gltf.scene)
},
(xhr) => {
console.log((xhr.loaded / xhr.total) * 100 + '% loaded')
},
(error) => {
console.log(error)
}
)
},
err => {
console.log('error : ' + JSON.stringify(err))
});
If anyone can help me how to load gltf file from firebase storage