Wait globe to load world.jpg before display it
This commit is contained in:
parent
5af32f21fd
commit
a3bba8c14c
2 changed files with 47 additions and 39 deletions
|
@ -351,22 +351,25 @@ class Sidebar extends Class
|
|||
|
||||
|
||||
displayGlobe: =>
|
||||
wrapper.ws.cmd "sidebarGetPeers", [], (globe_data) =>
|
||||
if @globe
|
||||
@globe.scene.remove(@globe.points)
|
||||
@globe.addData( globe_data, {format: 'magnitude', name: "hello", animated: false} )
|
||||
@globe.createPoints()
|
||||
else
|
||||
try
|
||||
@globe = new DAT.Globe( @tag.find(".globe")[0], {"imgDir": "/uimedia/globe/"} )
|
||||
@globe.addData( globe_data, {format: 'magnitude', name: "hello"} )
|
||||
img = new Image();
|
||||
img.src = "/uimedia/globe/world.jpg";
|
||||
img.onload = =>
|
||||
wrapper.ws.cmd "sidebarGetPeers", [], (globe_data) =>
|
||||
if @globe
|
||||
@globe.scene.remove(@globe.points)
|
||||
@globe.addData( globe_data, {format: 'magnitude', name: "hello", animated: false} )
|
||||
@globe.createPoints()
|
||||
@globe.animate()
|
||||
catch e
|
||||
console.log "WebGL error", e
|
||||
@tag.find(".globe").addClass("error").text("WebGL not supported")
|
||||
else
|
||||
try
|
||||
@globe = new DAT.Globe( @tag.find(".globe")[0], {"imgDir": "/uimedia/globe/"} )
|
||||
@globe.addData( globe_data, {format: 'magnitude', name: "hello"} )
|
||||
@globe.createPoints()
|
||||
@globe.animate()
|
||||
catch e
|
||||
console.log "WebGL error", e
|
||||
@tag.find(".globe").addClass("error").text("WebGL not supported")
|
||||
|
||||
@tag.find(".globe").removeClass("loading")
|
||||
@tag.find(".globe").removeClass("loading")
|
||||
|
||||
|
||||
unloadGlobe: =>
|
||||
|
|
|
@ -601,37 +601,42 @@ window.initScrollable = function () {
|
|||
};
|
||||
|
||||
Sidebar.prototype.displayGlobe = function() {
|
||||
return wrapper.ws.cmd("sidebarGetPeers", [], (function(_this) {
|
||||
return function(globe_data) {
|
||||
var e;
|
||||
if (_this.globe) {
|
||||
_this.globe.scene.remove(_this.globe.points);
|
||||
_this.globe.addData(globe_data, {
|
||||
format: 'magnitude',
|
||||
name: "hello",
|
||||
animated: false
|
||||
});
|
||||
_this.globe.createPoints();
|
||||
} else {
|
||||
try {
|
||||
_this.globe = new DAT.Globe(_this.tag.find(".globe")[0], {
|
||||
"imgDir": "/uimedia/globe/"
|
||||
});
|
||||
var img;
|
||||
img = new Image();
|
||||
img.src = "/uimedia/globe/world.jpg";
|
||||
return img.onload = (function(_this) {
|
||||
return function() {
|
||||
return wrapper.ws.cmd("sidebarGetPeers", [], function(globe_data) {
|
||||
var e;
|
||||
if (_this.globe) {
|
||||
_this.globe.scene.remove(_this.globe.points);
|
||||
_this.globe.addData(globe_data, {
|
||||
format: 'magnitude',
|
||||
name: "hello"
|
||||
name: "hello",
|
||||
animated: false
|
||||
});
|
||||
_this.globe.createPoints();
|
||||
_this.globe.animate();
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
console.log("WebGL error", e);
|
||||
_this.tag.find(".globe").addClass("error").text("WebGL not supported");
|
||||
} else {
|
||||
try {
|
||||
_this.globe = new DAT.Globe(_this.tag.find(".globe")[0], {
|
||||
"imgDir": "/uimedia/globe/"
|
||||
});
|
||||
_this.globe.addData(globe_data, {
|
||||
format: 'magnitude',
|
||||
name: "hello"
|
||||
});
|
||||
_this.globe.createPoints();
|
||||
_this.globe.animate();
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
console.log("WebGL error", e);
|
||||
_this.tag.find(".globe").addClass("error").text("WebGL not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
return _this.tag.find(".globe").removeClass("loading");
|
||||
return _this.tag.find(".globe").removeClass("loading");
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
})(this);
|
||||
};
|
||||
|
||||
Sidebar.prototype.unloadGlobe = function() {
|
||||
|
|
Loading…
Reference in a new issue