首页 技术 正文
技术 2022年11月14日
0 收藏 865 点赞 4,154 浏览 2908 个字
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - level-of-details</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background:#000;
color:#fff;
padding:0;
margin:0;
font-weight: bold;
overflow:hidden;
}#info {
position: absolute;
top: 0px; width: 100%;
color: #ffffff;
padding: 5px;
font-family: Monospace;
font-size: 13px;
text-align: center;
z-index:100;
}a { color:red }</style>
</head><body>
<div id="info">
<a href="http://threejs.org" rel="external nofollow" target="_blank">three.js</a> - level-of-details WebGL example
</div><script src="../build/three.js"></script><script src="js/controls/FlyControls.js"></script><script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script><script>if ( ! Detector.webgl ) Detector.addGetWebGLMessage();var container, stats;var camera, scene, renderer;var geometry, objects;var controls, clock = new THREE.Clock();init();
animate();function init() {container = document.createElement( 'div' );
document.body.appendChild( container );camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 15000 );
camera.position.z = 1000;controls = new THREE.FlyControls( camera );
controls.movementSpeed = 1000;
controls.rollSpeed = Math.PI / 10;scene = new THREE.Scene();
scene.fog = new THREE.Fog( 0x000000, 1, 15000 );
scene.autoUpdate = false;var light = new THREE.PointLight( 0xff2200 );
light.position.set( 0, 0, 0 );
scene.add( light );var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0, 0, 1 ).normalize();
scene.add( light );var geometry = [[ new THREE.IcosahedronGeometry( 100, 4 ), 50 ],
[ new THREE.IcosahedronGeometry( 100, 3 ), 300 ],
[ new THREE.IcosahedronGeometry( 100, 2 ), 1000 ],
[ new THREE.IcosahedronGeometry( 100, 1 ), 2000 ],
[ new THREE.IcosahedronGeometry( 100, 0 ), 8000 ]];var material = new THREE.MeshLambertMaterial( { color: 0xffffff, wireframe: true } );var i, j, mesh, lod;for ( j = 0; j < 1000; j ++ ) {lod = new THREE.LOD();for ( i = 0; i < geometry.length; i ++ ) {mesh = new THREE.Mesh( geometry[ i ][ 0 ], material );
mesh.scale.set( 1.5, 1.5, 1.5 );
mesh.updateMatrix();
mesh.matrixAutoUpdate = false;
lod.addLevel( mesh, geometry[ i ][ 1 ] );}lod.position.x = 10000 * ( 0.5 - Math.random() );
lod.position.y = 7500 * ( 0.5 - Math.random() );
lod.position.z = 10000 * ( 0.5 - Math.random() );
lod.updateMatrix();
lod.matrixAutoUpdate = false;
scene.add( lod );}renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.sortObjects = false;
container.appendChild( renderer.domElement );//window.addEventListener( 'resize', onWindowResize, false );}function onWindowResize() {camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();renderer.setSize( window.innerWidth, window.innerHeight );}function animate() {requestAnimationFrame( animate );
render();}function render() {controls.update( clock.getDelta() );scene.updateMatrixWorld();
scene.traverse( function ( object ) {if ( object instanceof THREE.LOD ) {object.update( camera );}} );renderer.render( scene, camera );}</script></body>
</html>

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,556
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898