three实现彩色点粒子构建的正方体三维效果代码
代码语言:html
所属分类:三维
代码描述:three实现彩色点粒子构建的正方体三维效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @layer demo.support { * { box-sizing: border-box; margin: 0; } html { block-size: 100%; color-scheme: dark light; } body { min-block-size: 100%; font-family: system-ui, sans-serif; } } </style> </head> <body > <div id="container"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.145.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.145.js"></script> <script type="module"> // slightly modified from https://huemint.com let container, camera, scene, renderer, controls, aspect, points; function init(colors_rgb) { container = document.getElementById('container'); camera = new THREE.PerspectiveCamera( 20, window.innerWidth / window.innerHeight, 5, 30000); aspect = window.innerWidth / window.innerHeight; camera.position.y = -1500; camera.position.x = -1500; camera.position.z = 1500; camera.up.set(0, 0, 1); scene = new THREE.Scene(); scene.background = new THREE.Color(0x000000); const particles = 500000; const geometry = new THREE.BufferGeometry(); const positions = []; const colors = []; const color = new THREE.Color(); for (var i = 0; i < colors_rgb.length; i++) { positions.push(-(colors_rgb[i][0] - 255), -(colors_rgb[i][1] -.........完整代码请登录后点击上方下载按钮下载查看
网友评论0