Gaëtan Renaudeau f8e462233d internal refactoring. fixes https://github.com/gre/gl-react/issues/134
the texture loader system was externalized into a set of libs webgltexture-loader*
2017-09-05 17:15:15 +02:00

32 lines
705 B
JavaScript

import { loadAsset } from "webgltexture-loader-expo/lib/ExponentTextureLoader";
export default function GLImage() {
console.warn("Usage of gl-react-expo Image is deprecated");
if (!(this instanceof GLImage))
throw new Error(
"Failed to construct 'Image': Please use the 'new' operator."
);
this.onload = null;
this._src = null;
}
GLImage.prototype = {
//$FlowFixMe
get src() {
return this._src;
},
//$FlowFixMe
set src(src) {
if (this._src === src) return;
delete this.localUri;
this._src = src;
if (src) {
loadAsset(src).then(({ localUri }) => {
this.localUri = localUri;
if (this.onload) this.onload();
});
}
}
};