three打造逼真的夜晚灯光照射照耀光晕光环效果代码
代码语言:html
所属分类:三维
代码描述:three打造逼真的夜晚灯光照射照耀光晕光环效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body{background-image:starfield(3,30);background-repeat:repeat;background-size:400px 400px;background-color:#000;margin:0;overflow:hidden;padding:0} </style> </head> <body> <div id="container"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.84.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/xRingGeometry.js"></script> <script > /** * @file * The main scene. */ /** * Define constants. */ const TEXTURE_PATH = '//repo.bfw.wiki/bfwrepo/images/xring/'; /** * Set our global variables. */ var camera, scene, renderer, effect, controls, element, container, rotationPoint; var textureFlare0; var textureFlare2; var textureFlare3; document.addEventListener( 'mousemove', onDocumentMouseMove, false ); init(); animate(); /** * Initializer function. */ function init() { // Build the container container = document.createElement( 'div' ); document.body.appendChild( container ); // Create the scene. scene = new THREE.Scene(); // Create a rotation point. rotationPoint = new THREE.Object3D(); rotationPoint.position.set( 0, 0, 1000 ); scene.add(rotationPoint); // Create the camera. camera = new THREE.PerspectiveCamera( 50, // Angle window.innerWidth / window.innerHeight, // Aspect Ratio. 1, // Near view. 23000 // Far view. ); rotationPoint.add( camera ); // Build the renderer. renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } ); element = renderer.domElement; renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMap.enabled; container.appendChild( element ); // Build the controls. controls = new THREE.OrbitControls( camera, element ); controls.enablePan = true; controls.enableZoom = true; controls.maxDistance = 4000; controls.minDistance = 1000; controls.target.copy( new THREE.Vector3( 0, 0, -100 ) ); function setOrientationControls(e) { if (!e.alpha) { return; } controls = new THREE.DeviceOrientationControls( camera ); controls.connect(); window.removeEventListener('deviceorientation', setOrientationControls, true); } window.addEventListener('deviceorientation', setOrientationControls, true); // Ambient lights var ambient = new THREE.AmbientLight( 0x222222 ); scene.add( ambient ); // The sun. var light = new THREE.PointLight( 0xffffff, 1, 10000, 0 ); light.position.set( -8000, 0, 0 ); scene.add( light ); // Add the skymap. addSkybox(); // Add the sun. createSun(-11600, 0, 0); // Create a lensflare effect. createLensflare(-11400, 0, 0); // Add the sun. createSun(-11600, 4000, 5500); // Create a lensflare effect. createLensflare(-11400, 4000, 5500); // Add the sun. createSun(11600, 0, 0); // Create a lensflare effect. createLensflare(11400, 0, 0); // Add the sun. createSun(11600, -4000, 5500); // Create a lensflare effect. createLensflare(11400, -4000, 5500); // Add the sun. createSun(0, 0, -11600); // Create a lensflare effect. createLensflare(0, 0, -11400); // Add the sun. createSun(5500, 4000, -11600); // Create a lensflare effect. createLensflare(5500, 4000, -11400); // Add the sun. createSun(0, 0, 11600); // Create a lensflare effect. createLensflare(0, 0, 11400); // Add the sun. createSun(11600, 0, 11600); // Create a lensflare effect. createLensflare(11400, 0, 11400); // Add the sun. createSun(11600, 0, -11600); // Create a lensflare effect. createLensflare(11400, 0, -11400); // Add the sun. createSun(-11600, 0, -11600); // Create a lensflare effect. createLensflare(-11400, 0, -11400); // Add the sun. createSun(-11600, 0, 11600); // Create a lensflare effect. createLensflare(-11400, 0, 11400); // Add the sun. createSun(0, -11600, 0); // Create a lensflare effect. createLens.........完整代码请登录后点击上方下载按钮下载查看
网友评论0