getDependency method
dynamic
getDependency(
- dynamic type,
- dynamic index
Requests the specified dependency asynchronously, with caching. @param {string} type @param {number} index @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
Implementation
getDependency(type, index) async {
var cacheKey = '$type:$index';
var dependency = cache.get(cacheKey);
// print(" GLTFParse.getDependency type: ${type} index: ${index} ");
if (dependency == null) {
switch (type) {
case 'scene':
dependency = await loadScene(index);
break;
case 'node':
dependency = await loadNode(index);
break;
case 'mesh':
dependency = await _invokeOne((ext) async {
return ext.loadMesh != null ? await ext.loadMesh(index) : null;
});
break;
case 'accessor':
dependency = await loadAccessor(index);
break;
case 'bufferView':
dependency = await _invokeOne((ext) async {
return ext.loadBufferView != null ? await ext.loadBufferView(index) : null;
});
break;
case 'buffer':
dependency = await loadBuffer(index);
break;
case 'material':
dependency = await _invokeOne((ext) async {
return ext.loadMaterial != null ? await ext.loadMaterial(index) : null;
});
break;
case 'texture':
dependency = await _invokeOne((ext) async {
return ext.loadTexture != null ? await ext.loadTexture(index) : null;
});
break;
case 'skin':
dependency = await loadSkin(index);
break;
case 'animation':
dependency = await loadAnimation(index);
break;
case 'camera':
dependency = await loadCamera(index);
break;
default:
throw ('GLTFParser getDependency Unknown type: $type');
}
cache.add(cacheKey, dependency);
}
return dependency;
}