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;
|
deviceURL = dev.imageURL;
|
||||||
loadDeviceImage(dev);
|
loadDeviceImage(dev);
|
||||||
}
|
}
|
||||||
} else if (deviceImage) {
|
} else {
|
||||||
SPACE.world.remove(deviceImage);
|
clearDeviceTexture();
|
||||||
deviceImage = null;
|
|
||||||
deviceURL = null;
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log({error:e, device:code, devicename});
|
console.log({error:e, device:code, devicename});
|
||||||
|
|
@ -757,12 +755,25 @@
|
||||||
API.event.settings();
|
API.event.settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadDeviceImage(dev) {
|
function clearDeviceTexture() {
|
||||||
new THREE.TextureLoader().load(dev.imageURL, texture => {
|
|
||||||
if (deviceImage) {
|
if (deviceImage) {
|
||||||
SPACE.world.remove(deviceImage);
|
SPACE.world.remove(deviceImage);
|
||||||
deviceImage = null;
|
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) {
|
if (!texture) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -803,7 +814,6 @@
|
||||||
mesh.position.y = pos.y;
|
mesh.position.y = pos.y;
|
||||||
}
|
}
|
||||||
SPACE.world.add(deviceImage = mesh);
|
SPACE.world.add(deviceImage = mesh);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDeviceName() {
|
function updateDeviceName() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue