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 = this.cache.get(cacheKey);
// print(" GLTFParse.getDependency type: ${type} index: ${index} ");
if (dependency == null) {
switch (type) {
case 'scene':
dependency = await this.loadScene(index);
break;
case 'node':
dependency = await this.loadNode(index);
break;
case 'mesh':
dependency = await this._invokeOne((ext) async {
return ext.loadMesh != null ? await ext.loadMesh(index) : null;
});
break;
case 'accessor':
dependency = await this.loadAccessor(index);
break;
case 'bufferView':
dependency = await this._invokeOne((ext) async {
return ext.loadBufferView != null
? await ext.loadBufferView(index)
: null;
});
break;
case 'buffer':
dependency = await this.loadBuffer(index);
break;
case 'material':
dependency = await this._invokeOne((ext) async {
return ext.loadMaterial != null
? await ext.loadMaterial(index)
: null;
});
break;
case 'texture':
dependency = await this._invokeOne((ext) async {
return ext.loadTexture != null
? await ext.loadTexture(index)
: null;
});
break;
case 'skin':
dependency = await this.loadSkin(index);
break;
case 'animation':
dependency = await this.loadAnimation(index);
break;
case 'camera':
dependency = await this.loadCamera(index);
break;
default:
throw ('GLTFParser getDependency Unknown type: ${type}');
}
this.cache.add(cacheKey, dependency);
}
return dependency;
}