spacekit开源3D空间可视化Javascript库

码农爱code 2019-09-18 17:42:43

简介

Spacekit是一个用于创建交互式3D空间可视化的JavaScript库 - 无论是地球/月球系统,太阳系还是其他系统。MIT协议,版本号0.0.1, Github Star 158+, 比较小众的项目,Github 官网地址:

https://github.com/typpo/spacekit

酷炫效果图

spacekit开源3D空间可视化Javascript库
spacekit开源3D空间可视化Javascript库
spacekit开源3D空间可视化Javascript库
spacekit开源3D空间可视化Javascript库
spacekit开源3D空间可视化Javascript库

快速上手

  • html
<div id="main-container"></div>
<script src="https://typpo.github.io/spacekit/src/lib/three.r98.min.js"></script>
<script src="https://typpo.github.io/spacekit/src/lib/TrackballControls.js"></script>
<script src="https://typpo.github.io/spacekit/build/spacekit.js"></script>
  • javascript
const viz = new Spacekit.Simulation(document.getElementById('main-container'), {
basePath: 'https://typpo.github.io/spacekit/src',
});
// Create a background using Yale Bright Star Catalog data.
viz.createStars();
// Create our first object - the sun - using a preset space object.
viz.createObject('sun', Spacekit.SpaceObjectPresets.SUN);
// Then add some planets
viz.createObject('mercury', Spacekit.SpaceObjectPresets.MERCURY);
viz.createObject('venus', Spacekit.SpaceObjectPresets.VENUS);
viz.createObject('earth', Spacekit.SpaceObjectPresets.EARTH);
viz.createObject('mars', Spacekit.SpaceObjectPresets.MARS);
viz.createObject('jupiter', Spacekit.SpaceObjectPresets.JUPITER);
viz.createObject('saturn', Spacekit.SpaceObjectPresets.SATURN);
viz.createObject('uranus', Spacekit.SpaceObjectPresets.URANUS);
viz.createObject('neptune', Spacekit.SpaceObjectPresets.NEPTUNE);
const roadster = viz.createObject('spaceman', {
labelText: 'Tesla Roadster',
ephem: new Spacekit.Ephem({
// These parameters define orbit shape.
a: 1.324870564730606E+00,
e: 2.557785995665682E-01,
i: 1.077550722804860E+00,

// These parameters define the orientation of the orbit.
om: 3.170946964325638E+02,
w: 1.774865822248395E+02,
ma: 1.764302192487955E+02,

// Where the object is in its orbit.
epoch: 2458426.500000000,
}, 'deg'),
});

result:

spacekit开源3D空间可视化Javascript库

总结

spacekit是一款可以画流星雨,古老的地球等等非常酷炫的3D效果图的开源3D引擎,感兴趣的朋友,可以自行到官网了解起来。