three实现飞机在地球上空飞行绘制五大洲线框动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现飞机在地球上空飞行绘制五大洲线框动画效果代码
代码标签: 在 地球 上空 飞行 绘制 五大洲 线框 动画 效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { margin: 0; overflow: hidden; background: radial-gradient(circle, #039be5 20%, #01334b 120%); } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/perlin-min.js"></script> <script type="module"> import * as THREE from "https://cdn.skypack.dev/three@0.132.2"; import { TrackballControls } from "https://cdn.skypack.dev/three@0.132.2/examples/jsm/controls/TrackballControls.js"; import { OBJLoader } from "https://cdn.skypack.dev/three@0.132.2/examples/jsm/loaders/OBJLoader.js"; import { MeshSurfaceSampler } from "https://cdn.skypack.dev/three@0.132.2/examples/jsm/math/MeshSurfaceSampler.js"; console.clear(); window.THREE = THREE; const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); camera.position.z = 250; camera.position.y = 100; const controls = new TrackballControls(camera, renderer.domElement); controls.noPan = true; controls.maxDistance = 600; controls.minDistance = 150; controls.rotateSpeed = 2; const group = new THREE.Group(); scene.add(group); group.rotation.y = 2; let subgroups = []; let airplane = new THREE.Group(); new OBJLoader().load("//repo.bfw.wiki/bfwrepo/threemodel/Airplane_model2.obj", (obj) => { airplane = obj; const mat = new THREE.MeshPhongMaterial({ emissive: 0xffffff, emissiveIntensity: 0.3 }); airplane.children.forEach(child => { child.geometry.scale(0.013, 0.013, 0.013); child.geometry.translate(0, 122, 0); child.material = mat; }); let angles = [0.3, 1.3, 2.14, 2.6]; let speeds = [0.008, 0.01, 0.014, 0.02]; let rotations = [0, 2.6, 1.5, 4]; for (let i = 0; i <4; i++) { const g = new THREE.Group(); g.speed = speeds[i]; subgroups.push(g); group.add(g); const g2 = new THREE.Group(); let _airplane = airplane.clone(); g.add(g2); g2.add(_airplane); g2.rotation.x = rotations[i]; g.rotation.y = angles[i]; // Reverse airplane rotation g.reverse = i < 2; if (i < 2) { _airplane.children[0].geometry = airplane.children[0].geometry.clone().rotateY(Math.PI); } } }); let sampler = []; let earth = null; let paths = []; new OBJLoader().load( "//repo.bfw.wiki/bfwrepo/threemodel/NOVELO_EARTH.obj", (obj) => { earth = obj.children[0]; earth.geometry.scale(0.35, 0.35, 0.35); earth.geometry.trans.........完整代码请登录后点击上方下载按钮下载查看
网友评论0