mirror of
				https://github.com/jiawanlong/Cesium-Examples.git
				synced 2025-11-04 01:04:17 +00:00 
			
		
		
		
	
		
			
	
	
		
			65 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			65 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<!--********************************************************************
							 | 
						|||
| 
								 | 
							
								* by jiawanlong
							 | 
						|||
| 
								 | 
							
								*********************************************************************-->
							 | 
						|||
| 
								 | 
							
								<!DOCTYPE html>
							 | 
						|||
| 
								 | 
							
								<html>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								<head>
							 | 
						|||
| 
								 | 
							
								    <meta charset="UTF-8" />
							 | 
						|||
| 
								 | 
							
								    <style>
							 | 
						|||
| 
								 | 
							
								        * {
							 | 
						|||
| 
								 | 
							
								            margin: 0;
							 | 
						|||
| 
								 | 
							
								            padding: 0;
							 | 
						|||
| 
								 | 
							
								            overflow: hidden;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    </style>
							 | 
						|||
| 
								 | 
							
								</head>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								<body>
							 | 
						|||
| 
								 | 
							
								    <div id="webgl" style="margin-top: 200px;margin-left: 100px;"></div>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    <script type="importmap">
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            "imports": {
							 | 
						|||
| 
								 | 
							
								                "three": "./../../three/build/three.module.js"
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    </script>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    <script type="module">
							 | 
						|||
| 
								 | 
							
								        import * as THREE from 'three';
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        // X:红色方向
							 | 
						|||
| 
								 | 
							
								        // Y:绿色方向
							 | 
						|||
| 
								 | 
							
								        // Z:蓝色方向
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        // 场景
							 | 
						|||
| 
								 | 
							
								        const scene = new THREE.Scene();// 创建场景
							 | 
						|||
| 
								 | 
							
								        const geometry = new THREE.BoxGeometry(100, 50, 10); //几何体
							 | 
						|||
| 
								 | 
							
								        const material = new THREE.MeshBasicMaterial({ color: 0xff0000 }); //材质 
							 | 
						|||
| 
								 | 
							
								        const mesh = new THREE.Mesh(geometry, material); //网格模型
							 | 
						|||
| 
								 | 
							
								        mesh.position.set(0, 10, 0); //网格模型位置
							 | 
						|||
| 
								 | 
							
								        scene.add(mesh);  //场景添加网格模型
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        // AxesHelper
							 | 
						|||
| 
								 | 
							
								        const axesHelper = new THREE.AxesHelper(150);
							 | 
						|||
| 
								 | 
							
								        scene.add(axesHelper);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        // 相机
							 | 
						|||
| 
								 | 
							
								        const camera = new THREE.PerspectiveCamera();  //相机
							 | 
						|||
| 
								 | 
							
								        camera.position.set(200, 200, 200); //相机位置
							 | 
						|||
| 
								 | 
							
								        camera.lookAt(0, 10, 0);   //相机观察位置
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        // 渲染器
							 | 
						|||
| 
								 | 
							
								        const renderer = new THREE.WebGLRenderer(); // 创建渲染器
							 | 
						|||
| 
								 | 
							
								        renderer.setSize(800, 500); //渲染区域
							 | 
						|||
| 
								 | 
							
								        renderer.render(scene, camera); //执行渲染
							 | 
						|||
| 
								 | 
							
								        document.getElementById('webgl').appendChild(renderer.domElement);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    </script>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								</body>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								</html>
							 |