further decompose device image loading
This commit is contained in:
parent
69e4db9ee6
commit
a341def747
1 changed files with 60 additions and 50 deletions
|
|
@ -741,10 +741,8 @@
|
|||
deviceURL = dev.imageURL;
|
||||
loadDeviceImage(dev);
|
||||
}
|
||||
} else if (deviceImage) {
|
||||
SPACE.world.remove(deviceImage);
|
||||
deviceImage = null;
|
||||
deviceURL = null;
|
||||
} else {
|
||||
clearDeviceTexture();
|
||||
}
|
||||
} catch (e) {
|
||||
console.log({error:e, device:code, devicename});
|
||||
|
|
@ -757,12 +755,25 @@
|
|||
API.event.settings();
|
||||
}
|
||||
|
||||
function loadDeviceImage(dev) {
|
||||
new THREE.TextureLoader().load(dev.imageURL, texture => {
|
||||
function clearDeviceTexture() {
|
||||
if (deviceImage) {
|
||||
SPACE.world.remove(deviceImage);
|
||||
deviceImage = null;
|
||||
}
|
||||
}
|
||||
|
||||
function loadDeviceImage(dev, url) {
|
||||
new THREE.TextureLoader().load(url || dev.imageURL, texture => {
|
||||
loadDeviceTexture(dev, texture);
|
||||
}, inc => {
|
||||
console.log({load_inc: inc});
|
||||
}, error => {
|
||||
console.log({load_error: error});
|
||||
});
|
||||
}
|
||||
|
||||
function loadDeviceTexture(dev, texture) {
|
||||
clearDeviceTexture();
|
||||
if (!texture) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -803,7 +814,6 @@
|
|||
mesh.position.y = pos.y;
|
||||
}
|
||||
SPACE.world.add(deviceImage = mesh);
|
||||
});
|
||||
}
|
||||
|
||||
function updateDeviceName() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue