p5实现三维地球全球飞机航班飞行效果代码
代码语言:html
所属分类:三维
代码描述:p5实现三维地球全球航班飞行效果代码,放大观看会发现飞机航班在地球上空飞行动画效果。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; padding: 0; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; background: black; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.4.0.js"></script> <script > //super rough, afternoon coding //I grabbed planet labs satellites after checking out their website //https://physics.info/motion-equations/ let eph; //https://ephemerides.planet-labs.com/ let earth; //nasa image let stars; //this is not accurately placed, but it looks pretty let ephArray = []; //array for ephemeris file let pos = []; //position let vel = []; //velocity let kappa = 6.67408e-11, //gravitational constant m = 1200, //mass of satellite M = 5.97219e24, //mass of earth dt = 2, //delta t sf = 40000; //scale factor //simple propagation - spherical earth function preload() { eph = loadTable("//repo.bfw.wiki/bfwrepo/files/planetsats.csv", "csv"); earth = loadImage("//repo.bfw.wiki/bfwrepo/image/6258c8d9a5d60.png"); stars = loadImage("//repo.bfw.wiki/bfwrepo/image/6258c90784e7b.jpeg"); } function setup() { createCanvas(windowWidth, windowHeight, WEBGL); texture(earth); background(0); noStroke(); loadData(); smooth(); } function draw() { orbitControl(0.5, 0.4, 0.01); background(0); push(); texture(earth); sphere(6.378e6 / sf, 24, 50); pop(); push(); rotateY(frameCount / 10000); texture(stars); sphere(4000, 24, 50); pop(); for (let i = 0; i < pos..........完整代码请登录后点击上方下载按钮下载查看
网友评论0