Gio.js 是一个开源库,用于使用 Three.js 构建的 Web 3D 地球数据可视化。Gio.js的不同之处在于,使用 Gio.js 以声明性方式自定义 3D 数据可视化模型、添加您自己的数据并将其集成到您自己的现代 Web 应用程序中非常简单。
该库的灵感来自Michael Chang开发的武器贸易可视化项目,并在Google Ideas INFO 2012期间展示。使用 Gio.js,可以轻松重现这个出色的数据可视化模型,并将其集成到 Web 应用程序中。
[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
包括三个.js依赖项:
<script src="three.min.js"></script>
包括本地 Gio.js 库
<script src="gio.min.js"></script>
或通过 CDN
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/giojs@2.2.1/build/gio.min.js"></script>
npm install giojs --save
yarn add giojs
在 html 中包含“three.min.js”和“gio.min.js”后,创建一个来渲染 3D Gio 地球仪:(Gio.js 的用法在微信小游戏中略有不同,请查看此演示以了解更多信息)div
<!DOCTYPE HTML>
<html>
<head>
<!-- include three.min.js library-->
<script src="three.min.js"></script>
<!-- include gio.min.js library-->
<script src="gio.min.js"></script>
</head>
<body>
<!-- container to draw 3D Gio globe-->
<div id="globalArea"></div>
</body>
</html>
要初始化和渲染 3D Gio 地球仪,请执行以下操作:
<script>
// get the container to hold the IO globe
var container = document.getElementById( "globalArea" );
// create controller for the IO globe, input the container as the parameter
var controller = new GIO.Controller( container );
/**
* use addData() API to add the the data to the controller
* know more about data format, check out documentation about data: http://giojs.org/html/docs/dataIntro.html
* we provide sample data for test, get sample data from: https://github.com/syt123450/giojs/blob/master/examples/data/sampleData.json
*/
controller.addData( data );
// call the init() API to show the IO globe in the browser
controller.init();
</script>
Gio.js 有许多代表性的演示来展示如何使用 Gio.js,主要有三个示例资源:
有一个游乐场(游乐场链接)供开发人员玩Gio.js并导出Gio.js参数。
Gio.js 有许多 API 演示,这些演示收集在示例文件夹中。克隆 Gio.js 存储库,在自己的环境中尝试它们~
[/hidecontent]