three实现三维夜晚地球灯光飞行轨迹效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维夜晚地球灯光飞行轨迹效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html { background: black; height: 100%; overflow: hidden; } body { height: 100%; margin: 0; padding: 0; position: relative; z-index: 10; } canvas { -webkit-animation: in 2s cubic-bezier(0.23, 1, 0.32, 1) 0.25s backwards; animation: in 2s cubic-bezier(0.23, 1, 0.32, 1) 0.25s backwards; background: transparent; position: absolute; } @-webkit-keyframes in { from { opacity: 0; } } @keyframes in { from { opacity: 0; } } </style> </head> <body > <div id='container'></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.75.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/extras.js"></script> <script > 'use strict'; var Earth = function (el, data) { let camera, scene, renderer, composer, w, h; let lines = [], mouse = { x: 0, y: 0 }, mouseOnDown = { x: 0, y: 0 }, points = [], rotation = { x: Math.PI * 1.9, y: Math.PI / 6 }, target = { x: Math.PI * 1.9, y: Math.PI / 6 }, targetOnDown = { x: 0, y: 0 }; const center = new THREE.Vector3(0, 0, 0), clock = new THREE.Clock(), distance = 350, PI_HALF = Math.PI / 2, pointRadius = 152, radius = 150; // Shaders // https://github.com/dataarts/webgl-globe const shaders = { 'atmosphere': { uniforms: {}, vertexShader: [ 'varying vec3 vNormal;', 'void main() {', 'vNormal = normalize( normalMatrix * normal );', 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}']. join('\n'), fragmentShader: [ 'varying vec3 vNormal;', 'void main() {', 'float intensity = pow( 0.8 - dot( vNormal, vec3( 0, 0, 1.0 ) ), 3.0 );', 'gl_FragColor = vec4( 0.3, 0.4, 0.6, 0.05 ) * .........完整代码请登录后点击上方下载按钮下载查看
网友评论0