spacekit模拟太阳系行星运行3D空间可视化示例代码

代码语言:html

所属分类:三维

代码描述:spacekit模拟太阳系行星运行3D空间可视化示例代码

代码标签: spacekit 模拟 太阳系 行星 运行 3D 空间 可视化 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

<style>
html,body,#main-container {
  width: 100%;
  height: 100%;
  background-color: white;
  padding: 0;
  margin: 0;
}
</style>

  
  
  
</head>

<body translate="no">
  <div id="main-container"></div>
<script src="//repo.bfw.wiki/bfwrepo/js/spaceki/lib/three.r98.min.js"></script>
<script src="//repo.bfw.wiki/bfwrepo/js/spaceki/lib/TrackballControls.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/spacekit.js"></script>
      <script >
const viz = new Spacekit.Simulation(document.getElementById('main-container'), { basePath: '//repo.bfw.wiki/bfwrepo/js/spacekit' });


// Create a starry 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 iss = viz.createObject('iss', {
  labelText: 'iss',
  ephem: new Spacekit.Ephem({
    // These parameters define orbit shape.
    a: 1.324870564730606E+00,
    e: 0,
    i: 52,

    // 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') });


const test = viz.createObject('test', {
  labelText: 'test',
  ephem: new Spacekit.Ephem({
    // These parameters define orbit shape.
    a: 2,
    e: .3,
    i: 87,

    // 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') });


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') });

viz.createObject('EJ', {
  labelText: 'the yeet planet',
  ephem: new Spacekit.Ephem({
    a: 3,
    e: 0.3,
    i: 21,
    om: 3.170946964325638E+02,
    w: 1.774865822248395E+02,
    ma: 1.764302192487955E+02,
    epoch: 2458426.500000000.........完整代码请登录后点击上方下载按钮下载查看

网友评论0