Cra*_*xIt 2 javascript webgl-globe
我正在玩WebGL Globe(http://globe.chromeexperiments.com/),并希望能够用新数据"刷新"它,然后将其设置为新状态.库中提供的示例无济于事,因为它们在页面加载时立即加载数据系列,但我想动态加载新数据(比方说,每30秒)
使用new重复执行以下操作data只会附加地更新globe的数据,因此当新数据进入时,条形图会在地球上"叠加":
globe.addData(data, {format: 'magnitude'});
globe.createPoints();
globe.animate();
Run Code Online (Sandbox Code Playgroud)
似乎没有一种明显的方法可以使用内置API减去/清除/重置地球仪的数据(然后设置动画到新的数据状态).这很容易吗?
我想到了.在您globe.js添加以下行:
function createPoints() {
...
this.points.name = "lines"; // Add this line
scene.add(this.points);
}
}
// Create this function
function removeAllPoints() {
scene.remove(scene.getObjectByName("lines"));
}
// Near the bottom of the code
this.addData = addData;
this.removeAllPoints = removeAllPoints; // Add this line
this.createPoints = createPoints;
this.renderer = renderer;
this.scene = scene;
Run Code Online (Sandbox Code Playgroud)
现在您可以简单地执行以下操作:
TWEEN.start();
globe.removeAllPoints();
globe.addData(data, {format: 'magnitude', name: 'results', animated: false});
globe.createPoints();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
651 次 |
| 最近记录: |