|
|
@@ -1,11 +1,6 @@
|
|
|
// 导入纹理和材质模块
|
|
|
import foamTextureUrl from '../../texture/T_Waterfall_Foam.PNG';
|
|
|
-import waterNormal1Url from '../../texture/Water_1_Normal.PNG';
|
|
|
-import waterNormal2Url from '../../texture/Water_2_Normal.PNG';
|
|
|
-import waterNormal3Url from '../../texture/Water_3_Normal.PNG';
|
|
|
-import skyTextureUrl from '../../texture/sky.jpg';
|
|
|
import { createWaterFoamPrimitive } from '../../materials/WaterFoamMaterial.js';
|
|
|
-import { createStylizedWaterMaterial, destroyStylizedWaterAnimation } from '../../materials/StylizedWaterMaterial.js';
|
|
|
// 导入启闭机图标
|
|
|
import qibiijiIcon from '../../assets/images/启闭机.png';
|
|
|
|
|
|
@@ -38,12 +33,6 @@ export const JuKouSceneConfig = {
|
|
|
coordinates: '119.144345, 25.866551,24.5',
|
|
|
size: 20 // 20米x20米
|
|
|
},
|
|
|
- // 简单面片(无材质,仅用于标记位置)
|
|
|
- simplePlane: {
|
|
|
- name: '标记面片',
|
|
|
- coordinates: '119.148567, 25.871270,40.95',
|
|
|
- size: 100 // 20米x20米
|
|
|
- },
|
|
|
camera: {
|
|
|
position: [-2795169.7727823164,5012356.518227473,2783038.1732437233],
|
|
|
direction: [0.5111708396854006, 0.3975398306001059, -0.7620147345962293],
|
|
|
@@ -67,8 +56,6 @@ export class JuKouShuiZhaController {
|
|
|
this.planeEntities = []; // 所有闸门面片实体数组
|
|
|
this._planeAnimationHandlers = []; // 所有面片动画处理器
|
|
|
this._gatePlaneMap = new Map(); // gateName → { primitive, timeoutId }
|
|
|
- this._simplePlanePrimitive = null; // 简单标记面片
|
|
|
- this._simplePlaneAnimHandler = null; // 简单标记面片动画处理器
|
|
|
this.gateStates = {};
|
|
|
this.isInitialized = false;
|
|
|
this.isModelLoaded = false;
|
|
|
@@ -96,12 +83,6 @@ export class JuKouShuiZhaController {
|
|
|
try {
|
|
|
await this.loadModel();
|
|
|
this.loadPlane(); // 加载面片模型(闸门水泡沫面片)
|
|
|
- try {
|
|
|
- this.loadSimplePlane(); // 加载简单标记面片
|
|
|
- } catch (err2) {
|
|
|
- console.error('❌ loadSimplePlane 失败', err2);
|
|
|
- this.onError && this.onError('loadSimplePlane: ' + err2.message);
|
|
|
- }
|
|
|
this.isInitialized = true;
|
|
|
this.onSceneReady && this.onSceneReady(this.entity);
|
|
|
} catch (err) {
|
|
|
@@ -293,82 +274,6 @@ export class JuKouShuiZhaController {
|
|
|
console.log(`✅ 共加载 ${this.planeEntities.length} 个闸门面片, 尺寸: ${size}米×${size}米`);
|
|
|
}
|
|
|
|
|
|
- // ============================================================
|
|
|
- // 加载水面面片(使用风格化水面材质 + 法线纹理)
|
|
|
- // ============================================================
|
|
|
- loadSimplePlane() {
|
|
|
- const Cesium = window.Cesium;
|
|
|
- const cfg = JuKouSceneConfig.simplePlane;
|
|
|
- const size = cfg.size; // 20米
|
|
|
- const coords = cfg.coordinates.split(',').map(Number);
|
|
|
- const centerLon = coords[0];
|
|
|
- const centerLat = coords[1];
|
|
|
- const altitude = coords[2];
|
|
|
-
|
|
|
- // 清除之前已创建的简单面片
|
|
|
- if (this._simplePlanePrimitive) {
|
|
|
- this.viewer.scene.primitives.remove(this._simplePlanePrimitive);
|
|
|
- this._simplePlanePrimitive = null;
|
|
|
- }
|
|
|
-
|
|
|
- // 计算矩形边界
|
|
|
- const latOffset = size / 111000;
|
|
|
- const lonOffset = size / (111000 * Math.cos(centerLat * Math.PI / 180));
|
|
|
- const west = centerLon - lonOffset / 2;
|
|
|
- const east = centerLon + lonOffset / 2;
|
|
|
- const south = centerLat - latOffset / 2;
|
|
|
- const north = centerLat + latOffset / 2;
|
|
|
-
|
|
|
- const rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);
|
|
|
-
|
|
|
- // 创建矩形几何
|
|
|
- const rectangleGeometry = new Cesium.RectangleGeometry({
|
|
|
- rectangle: rectangle,
|
|
|
- height: altitude,
|
|
|
- vertexFormat: Cesium.MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat
|
|
|
- });
|
|
|
-
|
|
|
- const geometryInstance = new Cesium.GeometryInstance({
|
|
|
- geometry: rectangleGeometry
|
|
|
- });
|
|
|
-
|
|
|
- // 创建风格化水面材质(传入纹理 URL + 天空纹理)
|
|
|
- const waterMaterial = createStylizedWaterMaterial({
|
|
|
- alpha: 0.85,
|
|
|
- waveHeight: 0.6,
|
|
|
- flowSpeed: 0.5,
|
|
|
- foamIntensity: 0.25,
|
|
|
- normalMap1: waterNormal1Url,
|
|
|
- normalMap2: waterNormal2Url,
|
|
|
- normalMap3: waterNormal3Url,
|
|
|
- skyTexture: skyTextureUrl
|
|
|
- });
|
|
|
-
|
|
|
- // 创建 Primitive
|
|
|
- this._simplePlanePrimitive = this.viewer.scene.primitives.add(
|
|
|
- new Cesium.Primitive({
|
|
|
- geometryInstances: geometryInstance,
|
|
|
- appearance: new Cesium.MaterialAppearance({
|
|
|
- material: waterMaterial,
|
|
|
- flat: true,
|
|
|
- aboveGround: true
|
|
|
- }),
|
|
|
- asynchronous: false
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- // 启动动画
|
|
|
- const startTime = Date.now();
|
|
|
- this._simplePlaneAnimHandler = this.viewer.scene.preRender.addEventListener(() => {
|
|
|
- if (this._simplePlanePrimitive && waterMaterial.uniforms) {
|
|
|
- const time = (Date.now() - startTime) / 1000;
|
|
|
- waterMaterial.uniforms.uSwTime = time;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- console.log(`✅ 水面面片已创建: (${cfg.coordinates}), 尺寸: ${size}米×${size}米`);
|
|
|
- }
|
|
|
-
|
|
|
// 清除所有已创建的面片
|
|
|
_clearPlanes() {
|
|
|
// 停止所有面片动画
|
|
|
@@ -539,16 +444,6 @@ export class JuKouShuiZhaController {
|
|
|
});
|
|
|
this.planeEntities = [];
|
|
|
}
|
|
|
- // 停止简单标记面片动画
|
|
|
- if (this._simplePlaneAnimHandler) {
|
|
|
- destroyStylizedWaterAnimation(this._simplePlaneAnimHandler);
|
|
|
- this._simplePlaneAnimHandler = null;
|
|
|
- }
|
|
|
- // 移除简单标记面片
|
|
|
- if (this._simplePlanePrimitive) {
|
|
|
- this.viewer.scene.primitives.remove(this._simplePlanePrimitive);
|
|
|
- this._simplePlanePrimitive = null;
|
|
|
- }
|
|
|
|
|
|
this.entity = null;
|
|
|
this.isInitialized = false;
|