警告信息 ·Warn Info· ▶ 在线运行案例案例合集三维可视化功能案例threehub.cn开源仓库github地址https://github.com/z2586300277/three-cesium-examples400个案例代码:网盘链接你将学到什么ShaderMaterial 自定义着色器实现核心视觉效果OrbitControls 相机轨道交互glTF/Draco 模型加载与优化效果说明本案例演示警告信息效果基于 WebGL 实现「警告信息」可视化效果附完整可运行源码核心用到 ShaderMaterial、OrbitControls、glTF/Draco。建议先打开文首在线案例查看动态画面再对照下方源码逐步理解。核心概念Scene / Camera / WebGLRenderer构成最小渲染闭环大场景可开logarithmicDepthBuffer缓解 Z-fighting。ShaderMaterial通过uniforms 自定义 GLSL 控制逐像素/逐点效果透明粒子常配合depthTest: false。OrbitControls提供轨道旋转/缩放开启enableDamping后需在 animate 中controls.update()。实现步骤搭建 Scene、PerspectiveCamera、WebGLRenderer挂载 canvas 并处理resize异步加载模型 / 3D Tiles / GeoJSON 等资源并加入 scene 或 entities定义 uniforms / onBeforeCompile 或 ShaderMaterial编写 GLSL 与材质参数创建 OrbitControls及 Raycaster 等交互控件若源码包含在requestAnimationFrame循环中更新状态并 renderCesium 为viewer.render或自动渲染代码要点import * as THREE from three;import { OrbitControls } from three/addons/controls/OrbitControls.js; import { GLTFLoader } from three/addons/loaders/GLTFLoader.js;const { innerWidth, innerHeight } window; const aspect innerWidth / innerHeight;class Base { constructor() { this.init(); this.main(); } main() { const geometry new THREE.PlaneGeometry(10, 10, 10, 10); const material new THREE.ShaderMaterial({ side: THREE.DoubleSide, transparent: true, uniforms: { uTime: this.elapsedTime, }, vertexShader:varying vec2 vUv; void main() { vUv uv; gl_Position projectionMatrixmodelViewMatrixvec4(position,1.0); }, fragmentShader:varying vec2 vUv; uniform float uTime;void main(){ vec3 color vec3(1.0,0.0,0.0);vec2 center vec2(0.5,0.5);float dis distance(vUv,center);float p 6.0;float r fract(disp - uTime)/3. step(0.99, fract(disp - uTime)); if(dis 0.5 ){ r 0.0; }gl_FragColor vec4(color,r); }, }); const mesh new THREE.Mesh(geometry, material); mesh.rotation.x Math.PI / 2; this.scene.add(mesh); } init() { this.clock new THREE.Clock();this.loader new GLTFLoader();this.renderer new THREE.WebGLRenderer({ antialias: true, logarithmicDepthBuffer: true, }); this.renderer.setPixelRatio(window.devicePixelRatio); this.renderer.setSize(innerWidth, innerHeight); this.renderer.setAnimationLoop(this.animate.bind(this)); document.body.appendChild(this.renderer.domElement);this.camera new THREE.PerspectiveCamera(60, aspect, 0.01, 10000); this.camera.position.set(5, 5, 5);this.scene new THREE.Scene();this.controls new OrbitControls(this.camera, this.renderer.domElement);this.elapsedTime { value: 0 };const grid new THREE.GridHelper(100); this.scene.add(grid);const light new THREE.AmbientLight(0xffffff, 0.5); this.scene.add(light); } animate() { this.elapsedTime.value this.clock.getElapsedTime(); this.controls.update(); this.renderer.render(this.scene, this.camera); } } new Base();完整源码GitHub小结本文提供警告信息完整 Three.js 源码与在线 Demo建议先运行案例再改 uniform/参数做二次实验更多 Three.js 实战案例见 three-cesium-examples 合集 与 GitHub 开源仓库