three实现三维山地沙盘群山丘陵山峰山峦效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维山地沙盘群山丘陵山峰山峦效果代码
代码标签: three 三维 山地 沙盘 群山 丘陵 山峰 山峦
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <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-color: #bfd1e5; color: #61443e; } a { color: #a06851; } </style> </head> <body> <div id="container"></div> <!-- Import maps polyfill --> <!-- Remove this when import maps will be widely supported --> <script async type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.3.6.js"></script> <script type="importmap"> { "imports": { "three": "//repo.bfw.wiki/bfwtool/build/three.module.js" } } </script> <script type="module"> import * as THREE from 'three'; import Stats from '//repo.bfw.wiki/bfwtool/examples/jsm/libs/stats.module.js'; import { OrbitControls } from '//repo.bfw.wiki/bfwtool/examples/jsm/controls/OrbitControls.js'; import { ImprovedNoise } from '//repo.bfw.wiki/bfwtool/examples/jsm/math/ImprovedNoise.js'; let container, stats; let camera, controls, scene, renderer; let mesh, texture; const worldWidth = 256, worldDepth = 256, worldHalfWidth = worldWidth / 2, worldHalfDepth = worldDepth / 2; let helper; const raycaster = new THREE.Raycaster(); const pointer = new THREE.Vector2(); init(); animate(); function init() { container = document.getElementById( 'container' ); container.innerHTML = ''; renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); scene = new THREE.Scene(); scene.background = new THREE.Color( 0xbfd1e5 ); camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 10, 20000 ); controls = new OrbitControls( camera, renderer.domElement ); controls.minDistance = 1000; controls.maxDistance = 10000; controls.maxPolarAngle = Math.PI / 2; /.........完整代码请登录后点击上方下载按钮下载查看
网友评论0