xy-map 1.1.23 → 1.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-map",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "雄越地图",
5
5
  "main": "xy-map.umd.min.js",
6
6
  "scripts": {
package/xy-map.common.js CHANGED
@@ -51348,12 +51348,12 @@ this.manager.itemError(url);throw err;}delete loading[url];for(let i=0,il=callba
51348
51348
  *
51349
51349
  * Sub classes have to implement the parse() method which will be used in load().
51350
51350
  */class CompressedTextureLoader extends (/* unused pure expression or super */ null && (Loader)){constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){const scope=this;const images=[];const texture=new CompressedTexture();const loader=new FileLoader(this.manager);loader.setPath(this.path);loader.setResponseType('arraybuffer');loader.setRequestHeader(this.requestHeader);loader.setWithCredentials(scope.withCredentials);let loaded=0;function loadTexture(i){loader.load(url[i],function(buffer){const texDatas=scope.parse(buffer,true);images[i]={width:texDatas.width,height:texDatas.height,format:texDatas.format,mipmaps:texDatas.mipmaps};loaded+=1;if(loaded===6){if(texDatas.mipmapCount===1)texture.minFilter=LinearFilter;texture.image=images;texture.format=texDatas.format;texture.needsUpdate=true;if(onLoad)onLoad(texture);}},onProgress,onError);}if(Array.isArray(url)){for(let i=0,il=url.length;i<il;++i){loadTexture(i);}}else{// compressed cubemap texture stored in a single DDS file
51351
- loader.load(url,function(buffer){const texDatas=scope.parse(buffer,true);if(texDatas.isCubemap){const faces=texDatas.mipmaps.length/texDatas.mipmapCount;for(let f=0;f<faces;f++){images[f]={mipmaps:[]};for(let i=0;i<texDatas.mipmapCount;i++){images[f].mipmaps.push(texDatas.mipmaps[f*texDatas.mipmapCount+i]);images[f].format=texDatas.format;images[f].width=texDatas.width;images[f].height=texDatas.height;}}texture.image=images;}else{texture.image.width=texDatas.width;texture.image.height=texDatas.height;texture.mipmaps=texDatas.mipmaps;}if(texDatas.mipmapCount===1){texture.minFilter=LinearFilter;}texture.format=texDatas.format;texture.needsUpdate=true;if(onLoad)onLoad(texture);},onProgress,onError);}return texture;}}class ImageLoader extends (/* unused pure expression or super */ null && (Loader)){constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){if(this.path!==undefined)url=this.path+url;url=this.manager.resolveURL(url);const scope=this;const cached=Cache.get(url);if(cached!==undefined){scope.manager.itemStart(url);setTimeout(function(){if(onLoad)onLoad(cached);scope.manager.itemEnd(url);},0);return cached;}const image=createElementNS('img');function onImageLoad(){removeEventListeners();Cache.add(url,this);if(onLoad)onLoad(this);scope.manager.itemEnd(url);}function onImageError(event){removeEventListeners();if(onError)onError(event);scope.manager.itemError(url);scope.manager.itemEnd(url);}function removeEventListeners(){image.removeEventListener('load',onImageLoad,false);image.removeEventListener('error',onImageError,false);}image.addEventListener('load',onImageLoad,false);image.addEventListener('error',onImageError,false);if(url.slice(0,5)!=='data:'){if(this.crossOrigin!==undefined)image.crossOrigin=this.crossOrigin;}scope.manager.itemStart(url);image.src=url;return image;}}class CubeTextureLoader extends (/* unused pure expression or super */ null && (Loader)){constructor(manager){super(manager);}load(urls,onLoad,onProgress,onError){const texture=new CubeTexture();const loader=new ImageLoader(this.manager);loader.setCrossOrigin(this.crossOrigin);loader.setPath(this.path);let loaded=0;function loadTexture(i){loader.load(urls[i],function(image){texture.images[i]=image;loaded++;if(loaded===6){texture.needsUpdate=true;if(onLoad)onLoad(texture);}},undefined,onError);}for(let i=0;i<urls.length;++i){loadTexture(i);}return texture;}}/**
51351
+ loader.load(url,function(buffer){const texDatas=scope.parse(buffer,true);if(texDatas.isCubemap){const faces=texDatas.mipmaps.length/texDatas.mipmapCount;for(let f=0;f<faces;f++){images[f]={mipmaps:[]};for(let i=0;i<texDatas.mipmapCount;i++){images[f].mipmaps.push(texDatas.mipmaps[f*texDatas.mipmapCount+i]);images[f].format=texDatas.format;images[f].width=texDatas.width;images[f].height=texDatas.height;}}texture.image=images;}else{texture.image.width=texDatas.width;texture.image.height=texDatas.height;texture.mipmaps=texDatas.mipmaps;}if(texDatas.mipmapCount===1){texture.minFilter=LinearFilter;}texture.format=texDatas.format;texture.needsUpdate=true;if(onLoad)onLoad(texture);},onProgress,onError);}return texture;}}class ImageLoader extends Loader{constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){if(this.path!==undefined)url=this.path+url;url=this.manager.resolveURL(url);const scope=this;const cached=Cache.get(url);if(cached!==undefined){scope.manager.itemStart(url);setTimeout(function(){if(onLoad)onLoad(cached);scope.manager.itemEnd(url);},0);return cached;}const image=createElementNS('img');function onImageLoad(){removeEventListeners();Cache.add(url,this);if(onLoad)onLoad(this);scope.manager.itemEnd(url);}function onImageError(event){removeEventListeners();if(onError)onError(event);scope.manager.itemError(url);scope.manager.itemEnd(url);}function removeEventListeners(){image.removeEventListener('load',onImageLoad,false);image.removeEventListener('error',onImageError,false);}image.addEventListener('load',onImageLoad,false);image.addEventListener('error',onImageError,false);if(url.slice(0,5)!=='data:'){if(this.crossOrigin!==undefined)image.crossOrigin=this.crossOrigin;}scope.manager.itemStart(url);image.src=url;return image;}}class CubeTextureLoader extends (/* unused pure expression or super */ null && (Loader)){constructor(manager){super(manager);}load(urls,onLoad,onProgress,onError){const texture=new CubeTexture();const loader=new ImageLoader(this.manager);loader.setCrossOrigin(this.crossOrigin);loader.setPath(this.path);let loaded=0;function loadTexture(i){loader.load(urls[i],function(image){texture.images[i]=image;loaded++;if(loaded===6){texture.needsUpdate=true;if(onLoad)onLoad(texture);}},undefined,onError);}for(let i=0;i<urls.length;++i){loadTexture(i);}return texture;}}/**
51352
51352
  * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)
51353
51353
  *
51354
51354
  * Sub classes have to implement the parse() method which will be used in load().
51355
51355
  */class DataTextureLoader extends Loader{constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){const scope=this;const texture=new DataTexture();const loader=new FileLoader(this.manager);loader.setResponseType('arraybuffer');loader.setRequestHeader(this.requestHeader);loader.setPath(this.path);loader.setWithCredentials(scope.withCredentials);loader.load(url,function(buffer){const texData=scope.parse(buffer);if(!texData)return;if(texData.image!==undefined){texture.image=texData.image;}else if(texData.data!==undefined){texture.image.width=texData.width;texture.image.height=texData.height;texture.image.data=texData.data;}texture.wrapS=texData.wrapS!==undefined?texData.wrapS:ClampToEdgeWrapping;texture.wrapT=texData.wrapT!==undefined?texData.wrapT:ClampToEdgeWrapping;texture.magFilter=texData.magFilter!==undefined?texData.magFilter:LinearFilter;texture.minFilter=texData.minFilter!==undefined?texData.minFilter:LinearFilter;texture.anisotropy=texData.anisotropy!==undefined?texData.anisotropy:1;if(texData.encoding!==undefined){texture.encoding=texData.encoding;}if(texData.flipY!==undefined){texture.flipY=texData.flipY;}if(texData.format!==undefined){texture.format=texData.format;}if(texData.type!==undefined){texture.type=texData.type;}if(texData.mipmaps!==undefined){texture.mipmaps=texData.mipmaps;texture.minFilter=LinearMipmapLinearFilter;// presumably...
51356
- }if(texData.mipmapCount===1){texture.minFilter=LinearFilter;}if(texData.generateMipmaps!==undefined){texture.generateMipmaps=texData.generateMipmaps;}texture.needsUpdate=true;if(onLoad)onLoad(texture,texData);},onProgress,onError);return texture;}}class TextureLoader extends (/* unused pure expression or super */ null && (Loader)){constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){const texture=new Texture();const loader=new ImageLoader(this.manager);loader.setCrossOrigin(this.crossOrigin);loader.setPath(this.path);loader.load(url,function(image){texture.image=image;texture.needsUpdate=true;if(onLoad!==undefined){onLoad(texture);}},onProgress,onError);return texture;}}class Light extends three_module_Object3D{constructor(color,intensity=1){super();this.isLight=true;this.type='Light';this.color=new Color(color);this.intensity=intensity;}dispose(){// Empty here in base class; some subclasses override.
51356
+ }if(texData.mipmapCount===1){texture.minFilter=LinearFilter;}if(texData.generateMipmaps!==undefined){texture.generateMipmaps=texData.generateMipmaps;}texture.needsUpdate=true;if(onLoad)onLoad(texture,texData);},onProgress,onError);return texture;}}class TextureLoader extends Loader{constructor(manager){super(manager);}load(url,onLoad,onProgress,onError){const texture=new Texture();const loader=new ImageLoader(this.manager);loader.setCrossOrigin(this.crossOrigin);loader.setPath(this.path);loader.load(url,function(image){texture.image=image;texture.needsUpdate=true;if(onLoad!==undefined){onLoad(texture);}},onProgress,onError);return texture;}}class Light extends three_module_Object3D{constructor(color,intensity=1){super();this.isLight=true;this.type='Light';this.color=new Color(color);this.intensity=intensity;}dispose(){// Empty here in base class; some subclasses override.
51357
51357
  }copy(source,recursive){super.copy(source,recursive);this.color.copy(source.color);this.intensity=source.intensity;return this;}toJSON(meta){const data=super.toJSON(meta);data.object.color=this.color.getHex();data.object.intensity=this.intensity;if(this.groundColor!==undefined)data.object.groundColor=this.groundColor.getHex();if(this.distance!==undefined)data.object.distance=this.distance;if(this.angle!==undefined)data.object.angle=this.angle;if(this.decay!==undefined)data.object.decay=this.decay;if(this.penumbra!==undefined)data.object.penumbra=this.penumbra;if(this.shadow!==undefined)data.object.shadow=this.shadow.toJSON();return data;}}class HemisphereLight extends (/* unused pure expression or super */ null && (Light)){constructor(skyColor,groundColor,intensity){super(skyColor,intensity);this.isHemisphereLight=true;this.type='HemisphereLight';this.position.copy(three_module_Object3D.DefaultUp);this.updateMatrix();this.groundColor=new Color(groundColor);}copy(source,recursive){super.copy(source,recursive);this.groundColor.copy(source.groundColor);return this;}}const _projScreenMatrix$1=/*@__PURE__*/new Matrix4();const _lightPositionWorld$1=/*@__PURE__*/new Vector3();const _lookTarget$1=/*@__PURE__*/new Vector3();class LightShadow{constructor(camera){this.camera=camera;this.bias=0;this.normalBias=0;this.radius=1;this.blurSamples=8;this.mapSize=new Vector2(512,512);this.map=null;this.mapPass=null;this.matrix=new Matrix4();this.autoUpdate=true;this.needsUpdate=false;this._frustum=new Frustum();this._frameExtents=new Vector2(1,1);this._viewportCount=1;this._viewports=[new Vector4(0,0,1,1)];}getViewportCount(){return this._viewportCount;}getFrustum(){return this._frustum;}updateMatrices(light){const shadowCamera=this.camera;const shadowMatrix=this.matrix;_lightPositionWorld$1.setFromMatrixPosition(light.matrixWorld);shadowCamera.position.copy(_lightPositionWorld$1);_lookTarget$1.setFromMatrixPosition(light.target.matrixWorld);shadowCamera.lookAt(_lookTarget$1);shadowCamera.updateMatrixWorld();_projScreenMatrix$1.multiplyMatrices(shadowCamera.projectionMatrix,shadowCamera.matrixWorldInverse);this._frustum.setFromProjectionMatrix(_projScreenMatrix$1);shadowMatrix.set(0.5,0.0,0.0,0.5,0.0,0.5,0.0,0.5,0.0,0.0,0.5,0.5,0.0,0.0,0.0,1.0);shadowMatrix.multiply(_projScreenMatrix$1);}getViewport(viewportIndex){return this._viewports[viewportIndex];}getFrameExtents(){return this._frameExtents;}dispose(){if(this.map){this.map.dispose();}if(this.mapPass){this.mapPass.dispose();}}copy(source){this.camera=source.camera.clone();this.bias=source.bias;this.radius=source.radius;this.mapSize.copy(source.mapSize);return this;}clone(){return new this.constructor().copy(this);}toJSON(){const object={};if(this.bias!==0)object.bias=this.bias;if(this.normalBias!==0)object.normalBias=this.normalBias;if(this.radius!==1)object.radius=this.radius;if(this.mapSize.x!==512||this.mapSize.y!==512)object.mapSize=this.mapSize.toArray();object.camera=this.camera.toJSON(false).object;delete object.camera.matrix;return object;}}class SpotLightShadow extends (/* unused pure expression or super */ null && (LightShadow)){constructor(){super(new PerspectiveCamera(50,1,0.5,500));this.isSpotLightShadow=true;this.focus=1;}updateMatrices(light){const camera=this.camera;const fov=RAD2DEG*2*light.angle*this.focus;const aspect=this.mapSize.width/this.mapSize.height;const far=light.distance||camera.far;if(fov!==camera.fov||aspect!==camera.aspect||far!==camera.far){camera.fov=fov;camera.aspect=aspect;camera.far=far;camera.updateProjectionMatrix();}super.updateMatrices(light);}copy(source){super.copy(source);this.focus=source.focus;return this;}}class SpotLight extends (/* unused pure expression or super */ null && (Light)){constructor(color,intensity,distance=0,angle=Math.PI/3,penumbra=0,decay=1){super(color,intensity);this.isSpotLight=true;this.type='SpotLight';this.position.copy(three_module_Object3D.DefaultUp);this.updateMatrix();this.target=new three_module_Object3D();this.distance=distance;this.angle=angle;this.penumbra=penumbra;this.decay=decay;// for physically correct lights, should be 2.
51358
51358
  this.map=null;this.shadow=new SpotLightShadow();}get power(){// compute the light's luminous power (in lumens) from its intensity (in candela)
51359
51359
  // by convention for a spotlight, luminous power (lm) = π * luminous intensity (cd)
@@ -54914,14 +54914,14 @@ const addLayerModel = (option, layerId = '') => {
54914
54914
  // camera = new THREE.Camera()
54915
54915
  // 场景
54916
54916
  scene = new Scene();
54917
- // scene.background = new THREE.Color('rgba(255,255,255, 0)')
54918
-
54919
- // 辅助坐标轴
54920
- // if (gui) {
54921
- // let AxesHelper = new THREE.AxesHelper(100)
54922
- // AxesHelper.position.y = opt.translate[1]
54923
- // scene.add(AxesHelper)
54924
- // }
54917
+ // scene.background = new THREE.Color(0xffffff)
54918
+ const texture = new TextureLoader().load('/img/blue.jpg');
54919
+ texture.mapping = EquirectangularRefractionMapping; // 带折射效果
54920
+ texture.wrapS = texture.wrapT = RepeatWrapping;
54921
+ console.log(texture);
54922
+ scene.scale.set(100, 100, 100);
54923
+ scene.background = texture;
54924
+ scene.environment = texture;
54925
54925
 
54926
54926
  // 创建灯光
54927
54927
  if (opt.directionalLight && opt.directionalLight.length > 0) {
@@ -55048,7 +55048,24 @@ const addLayerModel = (option, layerId = '') => {
55048
55048
  // getIntersects() // 点击事件
55049
55049
  },
55050
55050
 
55051
- render: cameraUpdate
55051
+ render: (gl, matrix) => {
55052
+ const rotationX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), modelTransform.rotateX);
55053
+ const rotationY = new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), modelTransform.rotateY);
55054
+ const rotationZ = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), modelTransform.rotateZ);
55055
+ const m = new Matrix4().fromArray(matrix);
55056
+ const l = new Matrix4().makeTranslation(modelTransform.translateX, modelTransform.translateY, modelTransform.translateZ).scale(new Vector3(modelTransform.scale, -modelTransform.scale, modelTransform.scale)).multiply(rotationX).multiply(rotationY).multiply(rotationZ);
55057
+ camera.projectionMatrix.elements = matrix;
55058
+ camera.projectionMatrix = m.multiply(l);
55059
+
55060
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping
55061
+ // renderer.toneMappingExposure = 1.5
55062
+
55063
+ renderer.resetState();
55064
+ renderer.render(scene, camera);
55065
+ // composer.render()
55066
+ labelRenderer.render(scene, camera);
55067
+ map.triggerRepaint();
55068
+ }
55052
55069
  };
55053
55070
  return customLayer;
55054
55071
  function loadHDR() {
@@ -55059,26 +55076,6 @@ const addLayerModel = (option, layerId = '') => {
55059
55076
  });
55060
55077
  }
55061
55078
 
55062
- // 渲染摄像机
55063
- function cameraUpdate(gl, matrix) {
55064
- const rotationX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), modelTransform.rotateX);
55065
- const rotationY = new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), modelTransform.rotateY);
55066
- const rotationZ = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), modelTransform.rotateZ);
55067
- const m = new Matrix4().fromArray(matrix);
55068
- const l = new Matrix4().makeTranslation(modelTransform.translateX, modelTransform.translateY, modelTransform.translateZ).scale(new Vector3(modelTransform.scale, -modelTransform.scale, modelTransform.scale)).multiply(rotationX).multiply(rotationY).multiply(rotationZ);
55069
- camera.projectionMatrix.elements = matrix;
55070
- camera.projectionMatrix = m.multiply(l);
55071
-
55072
- // renderer.toneMapping = THREE.ACESFilmicToneMapping
55073
- // renderer.toneMappingExposure = 1.5
55074
-
55075
- renderer.resetState();
55076
- renderer.render(scene, camera);
55077
- // composer.render()
55078
- labelRenderer.render(scene, camera);
55079
- map.triggerRepaint();
55080
- }
55081
-
55082
55079
  // 点击事件
55083
55080
  function getIntersects() {
55084
55081
  const container = map.getCanvas();
@@ -55118,6 +55115,495 @@ const addLayerModel = (option, layerId = '') => {
55118
55115
  }
55119
55116
  });
55120
55117
  };
55118
+ ;// CONCATENATED MODULE: ./node_modules/three/examples/jsm/objects/Water.js
55119
+
55120
+
55121
+ /**
55122
+ * Work based on :
55123
+ * https://github.com/Slayvin: Flat mirror for three.js
55124
+ * https://home.adelphi.edu/~stemkoski/ : An implementation of water shader based on the flat mirror
55125
+ * http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL
55126
+ */
55127
+
55128
+ class Water extends Mesh {
55129
+ constructor(geometry, options = {}) {
55130
+ super(geometry);
55131
+ this.isWater = true;
55132
+ const scope = this;
55133
+ const textureWidth = options.textureWidth !== undefined ? options.textureWidth : 512;
55134
+ const textureHeight = options.textureHeight !== undefined ? options.textureHeight : 512;
55135
+ const clipBias = options.clipBias !== undefined ? options.clipBias : 0.0;
55136
+ const alpha = options.alpha !== undefined ? options.alpha : 1.0;
55137
+ const time = options.time !== undefined ? options.time : 0.0;
55138
+ const normalSampler = options.waterNormals !== undefined ? options.waterNormals : null;
55139
+ const sunDirection = options.sunDirection !== undefined ? options.sunDirection : new Vector3(0.70707, 0.70707, 0.0);
55140
+ const sunColor = new Color(options.sunColor !== undefined ? options.sunColor : 0xffffff);
55141
+ const waterColor = new Color(options.waterColor !== undefined ? options.waterColor : 0x7F7F7F);
55142
+ const eye = options.eye !== undefined ? options.eye : new Vector3(0, 0, 0);
55143
+ const distortionScale = options.distortionScale !== undefined ? options.distortionScale : 20.0;
55144
+ const side = options.side !== undefined ? options.side : FrontSide;
55145
+ const fog = options.fog !== undefined ? options.fog : false;
55146
+
55147
+ //
55148
+
55149
+ const mirrorPlane = new Plane();
55150
+ const normal = new Vector3();
55151
+ const mirrorWorldPosition = new Vector3();
55152
+ const cameraWorldPosition = new Vector3();
55153
+ const rotationMatrix = new Matrix4();
55154
+ const lookAtPosition = new Vector3(0, 0, -1);
55155
+ const clipPlane = new Vector4();
55156
+ const view = new Vector3();
55157
+ const target = new Vector3();
55158
+ const q = new Vector4();
55159
+ const textureMatrix = new Matrix4();
55160
+ const mirrorCamera = new PerspectiveCamera();
55161
+ const renderTarget = new WebGLRenderTarget(textureWidth, textureHeight);
55162
+ const mirrorShader = {
55163
+ uniforms: UniformsUtils.merge([UniformsLib.fog, UniformsLib.lights, {
55164
+ 'normalSampler': {
55165
+ value: null
55166
+ },
55167
+ 'mirrorSampler': {
55168
+ value: null
55169
+ },
55170
+ 'alpha': {
55171
+ value: 1.0
55172
+ },
55173
+ 'time': {
55174
+ value: 0.0
55175
+ },
55176
+ 'size': {
55177
+ value: 1.0
55178
+ },
55179
+ 'distortionScale': {
55180
+ value: 20.0
55181
+ },
55182
+ 'textureMatrix': {
55183
+ value: new Matrix4()
55184
+ },
55185
+ 'sunColor': {
55186
+ value: new Color(0x7F7F7F)
55187
+ },
55188
+ 'sunDirection': {
55189
+ value: new Vector3(0.70707, 0.70707, 0)
55190
+ },
55191
+ 'eye': {
55192
+ value: new Vector3()
55193
+ },
55194
+ 'waterColor': {
55195
+ value: new Color(0x555555)
55196
+ }
55197
+ }]),
55198
+ vertexShader: /* glsl */`
55199
+ uniform mat4 textureMatrix;
55200
+ uniform float time;
55201
+
55202
+ varying vec4 mirrorCoord;
55203
+ varying vec4 worldPosition;
55204
+
55205
+ #include <common>
55206
+ #include <fog_pars_vertex>
55207
+ #include <shadowmap_pars_vertex>
55208
+ #include <logdepthbuf_pars_vertex>
55209
+
55210
+ void main() {
55211
+ mirrorCoord = modelMatrix * vec4( position, 1.0 );
55212
+ worldPosition = mirrorCoord.xyzw;
55213
+ mirrorCoord = textureMatrix * mirrorCoord;
55214
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
55215
+ gl_Position = projectionMatrix * mvPosition;
55216
+
55217
+ #include <beginnormal_vertex>
55218
+ #include <defaultnormal_vertex>
55219
+ #include <logdepthbuf_vertex>
55220
+ #include <fog_vertex>
55221
+ #include <shadowmap_vertex>
55222
+ }`,
55223
+ fragmentShader: /* glsl */`
55224
+ uniform sampler2D mirrorSampler;
55225
+ uniform float alpha;
55226
+ uniform float time;
55227
+ uniform float size;
55228
+ uniform float distortionScale;
55229
+ uniform sampler2D normalSampler;
55230
+ uniform vec3 sunColor;
55231
+ uniform vec3 sunDirection;
55232
+ uniform vec3 eye;
55233
+ uniform vec3 waterColor;
55234
+
55235
+ varying vec4 mirrorCoord;
55236
+ varying vec4 worldPosition;
55237
+
55238
+ vec4 getNoise( vec2 uv ) {
55239
+ vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
55240
+ vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
55241
+ vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
55242
+ vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
55243
+ vec4 noise = texture2D( normalSampler, uv0 ) +
55244
+ texture2D( normalSampler, uv1 ) +
55245
+ texture2D( normalSampler, uv2 ) +
55246
+ texture2D( normalSampler, uv3 );
55247
+ return noise * 0.5 - 1.0;
55248
+ }
55249
+
55250
+ void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
55251
+ vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
55252
+ float direction = max( 0.0, dot( eyeDirection, reflection ) );
55253
+ specularColor += pow( direction, shiny ) * sunColor * spec;
55254
+ diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
55255
+ }
55256
+
55257
+ #include <common>
55258
+ #include <packing>
55259
+ #include <bsdfs>
55260
+ #include <fog_pars_fragment>
55261
+ #include <logdepthbuf_pars_fragment>
55262
+ #include <lights_pars_begin>
55263
+ #include <shadowmap_pars_fragment>
55264
+ #include <shadowmask_pars_fragment>
55265
+
55266
+ void main() {
55267
+
55268
+ #include <logdepthbuf_fragment>
55269
+ vec4 noise = getNoise( worldPosition.xz * size );
55270
+ vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
55271
+
55272
+ vec3 diffuseLight = vec3(0.0);
55273
+ vec3 specularLight = vec3(0.0);
55274
+
55275
+ vec3 worldToEye = eye-worldPosition.xyz;
55276
+ vec3 eyeDirection = normalize( worldToEye );
55277
+ sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
55278
+
55279
+ float distance = length(worldToEye);
55280
+
55281
+ vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
55282
+ vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
55283
+
55284
+ float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
55285
+ float rf0 = 0.3;
55286
+ float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
55287
+ vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
55288
+ vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);
55289
+ vec3 outgoingLight = albedo;
55290
+ gl_FragColor = vec4( outgoingLight, alpha );
55291
+
55292
+ #include <tonemapping_fragment>
55293
+ #include <fog_fragment>
55294
+ }`
55295
+ };
55296
+ const material = new ShaderMaterial({
55297
+ fragmentShader: mirrorShader.fragmentShader,
55298
+ vertexShader: mirrorShader.vertexShader,
55299
+ uniforms: UniformsUtils.clone(mirrorShader.uniforms),
55300
+ lights: true,
55301
+ side: side,
55302
+ fog: fog
55303
+ });
55304
+ material.uniforms['mirrorSampler'].value = renderTarget.texture;
55305
+ material.uniforms['textureMatrix'].value = textureMatrix;
55306
+ material.uniforms['alpha'].value = alpha;
55307
+ material.uniforms['time'].value = time;
55308
+ material.uniforms['normalSampler'].value = normalSampler;
55309
+ material.uniforms['sunColor'].value = sunColor;
55310
+ material.uniforms['waterColor'].value = waterColor;
55311
+ material.uniforms['sunDirection'].value = sunDirection;
55312
+ material.uniforms['distortionScale'].value = distortionScale;
55313
+ material.uniforms['eye'].value = eye;
55314
+ scope.material = material;
55315
+ scope.onBeforeRender = function (renderer, scene, camera) {
55316
+ mirrorWorldPosition.setFromMatrixPosition(scope.matrixWorld);
55317
+ cameraWorldPosition.setFromMatrixPosition(camera.matrixWorld);
55318
+ rotationMatrix.extractRotation(scope.matrixWorld);
55319
+ normal.set(0, 0, 1);
55320
+ normal.applyMatrix4(rotationMatrix);
55321
+ view.subVectors(mirrorWorldPosition, cameraWorldPosition);
55322
+
55323
+ // Avoid rendering when mirror is facing away
55324
+
55325
+ if (view.dot(normal) > 0) return;
55326
+ view.reflect(normal).negate();
55327
+ view.add(mirrorWorldPosition);
55328
+ rotationMatrix.extractRotation(camera.matrixWorld);
55329
+ lookAtPosition.set(0, 0, -1);
55330
+ lookAtPosition.applyMatrix4(rotationMatrix);
55331
+ lookAtPosition.add(cameraWorldPosition);
55332
+ target.subVectors(mirrorWorldPosition, lookAtPosition);
55333
+ target.reflect(normal).negate();
55334
+ target.add(mirrorWorldPosition);
55335
+ mirrorCamera.position.copy(view);
55336
+ mirrorCamera.up.set(0, 1, 0);
55337
+ mirrorCamera.up.applyMatrix4(rotationMatrix);
55338
+ mirrorCamera.up.reflect(normal);
55339
+ mirrorCamera.lookAt(target);
55340
+ mirrorCamera.far = camera.far; // Used in WebGLBackground
55341
+
55342
+ mirrorCamera.updateMatrixWorld();
55343
+ mirrorCamera.projectionMatrix.copy(camera.projectionMatrix);
55344
+
55345
+ // Update the texture matrix
55346
+ textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
55347
+ textureMatrix.multiply(mirrorCamera.projectionMatrix);
55348
+ textureMatrix.multiply(mirrorCamera.matrixWorldInverse);
55349
+
55350
+ // Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
55351
+ // Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
55352
+ mirrorPlane.setFromNormalAndCoplanarPoint(normal, mirrorWorldPosition);
55353
+ mirrorPlane.applyMatrix4(mirrorCamera.matrixWorldInverse);
55354
+ clipPlane.set(mirrorPlane.normal.x, mirrorPlane.normal.y, mirrorPlane.normal.z, mirrorPlane.constant);
55355
+ const projectionMatrix = mirrorCamera.projectionMatrix;
55356
+ q.x = (Math.sign(clipPlane.x) + projectionMatrix.elements[8]) / projectionMatrix.elements[0];
55357
+ q.y = (Math.sign(clipPlane.y) + projectionMatrix.elements[9]) / projectionMatrix.elements[5];
55358
+ q.z = -1.0;
55359
+ q.w = (1.0 + projectionMatrix.elements[10]) / projectionMatrix.elements[14];
55360
+
55361
+ // Calculate the scaled plane vector
55362
+ clipPlane.multiplyScalar(2.0 / clipPlane.dot(q));
55363
+
55364
+ // Replacing the third row of the projection matrix
55365
+ projectionMatrix.elements[2] = clipPlane.x;
55366
+ projectionMatrix.elements[6] = clipPlane.y;
55367
+ projectionMatrix.elements[10] = clipPlane.z + 1.0 - clipBias;
55368
+ projectionMatrix.elements[14] = clipPlane.w;
55369
+ eye.setFromMatrixPosition(camera.matrixWorld);
55370
+
55371
+ // Render
55372
+
55373
+ const currentRenderTarget = renderer.getRenderTarget();
55374
+ const currentXrEnabled = renderer.xr.enabled;
55375
+ const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
55376
+ scope.visible = false;
55377
+ renderer.xr.enabled = false; // Avoid camera modification and recursion
55378
+ renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
55379
+
55380
+ renderer.setRenderTarget(renderTarget);
55381
+ renderer.state.buffers.depth.setMask(true); // make sure the depth buffer is writable so it can be properly cleared, see #18897
55382
+
55383
+ if (renderer.autoClear === false) renderer.clear();
55384
+ renderer.render(scene, mirrorCamera);
55385
+ scope.visible = true;
55386
+ renderer.xr.enabled = currentXrEnabled;
55387
+ renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
55388
+ renderer.setRenderTarget(currentRenderTarget);
55389
+
55390
+ // Restore viewport
55391
+
55392
+ const viewport = camera.viewport;
55393
+ if (viewport !== undefined) {
55394
+ renderer.state.viewport(viewport);
55395
+ }
55396
+ };
55397
+ }
55398
+ }
55399
+
55400
+ ;// CONCATENATED MODULE: ./src/package/layers/water.js
55401
+
55402
+
55403
+
55404
+
55405
+
55406
+
55407
+
55408
+
55409
+
55410
+
55411
+
55412
+ const water_defaultOptions = {
55413
+ id: 'water',
55414
+ position: [103.353557, 23.362395],
55415
+ // 位置
55416
+ hight: 0,
55417
+ // 高度
55418
+ size: [4000, 4000],
55419
+ edit: false
55420
+ };
55421
+
55422
+ /**
55423
+ * 添加水面
55424
+ */
55425
+ const addLayerWater = (option, layerId = '') => {
55426
+ return new Promise(resolve => {
55427
+ let {
55428
+ map
55429
+ } = package_map;
55430
+ let opt = Object.assign({}, water_defaultOptions, option);
55431
+ let camera = '';
55432
+ let scene = '';
55433
+ let group = '';
55434
+ let renderer = '';
55435
+ let customLayer = '';
55436
+ let waterP = '';
55437
+ // let waterTop = ''
55438
+ let waterBottom = '';
55439
+ if (hasLayer(opt.id)) {
55440
+ removeLayer(opt.id);
55441
+ }
55442
+ addWater();
55443
+ map.addLayer(customLayer, layerId);
55444
+ resolve(group);
55445
+ function addWater() {
55446
+ const modelOrigin = opt.position; // 中心点
55447
+ const modelAltitude = opt.height; // 高度
55448
+ const modelRotate = [Math.PI / 2, 0, 0];
55449
+ const modelAsMercatorCoordinate = mapbox_gl_default().MercatorCoordinate.fromLngLat(modelOrigin, modelAltitude);
55450
+ const modelTransform = {
55451
+ translateX: modelAsMercatorCoordinate.x,
55452
+ translateY: modelAsMercatorCoordinate.y,
55453
+ translateZ: modelAsMercatorCoordinate.z,
55454
+ rotateX: modelRotate[0],
55455
+ rotateY: modelRotate[1],
55456
+ rotateZ: modelRotate[2],
55457
+ scale: modelAsMercatorCoordinate.meterInMercatorCoordinateUnits()
55458
+ };
55459
+
55460
+ // 根据CustomLayerInterface为三维模型配置自定义层
55461
+ customLayer = {
55462
+ id: opt.id,
55463
+ type: 'custom',
55464
+ renderingMode: '3d',
55465
+ onAdd: (map, gl) => {
55466
+ const container = map.getCanvas();
55467
+
55468
+ // 摄像机
55469
+ camera = new PerspectiveCamera(50, container.clientWidth / container.clientHeight, 1, 5000);
55470
+ // camera = new THREE.Camera()
55471
+ // 场景
55472
+ scene = new Scene();
55473
+ group = new Group();
55474
+ group.name = 'water';
55475
+ scene.add(group);
55476
+
55477
+ // 水面
55478
+ let geometry = getWaterGeometry(modelAsMercatorCoordinate, opt);
55479
+ let bottomMat = new MeshBasicMaterial({
55480
+ color: opt.color || 0x7597dc,
55481
+ opacity: 0.7,
55482
+ transparent: true
55483
+ });
55484
+ waterBottom = new Mesh(geometry, bottomMat);
55485
+
55486
+ // 动态水面
55487
+ waterP = new Water(geometry, {
55488
+ textureWidth: 64,
55489
+ textureHeight: 64,
55490
+ waterNormals: new TextureLoader().load('/img/waternormals.jpg', texture => {
55491
+ texture.wrapS = texture.wrapT = RepeatWrapping;
55492
+ }),
55493
+ alpha: 0.3,
55494
+ side: DoubleSide,
55495
+ sunColor: 0xffffff,
55496
+ waterColor: 0xffffff,
55497
+ distortionScale: 3.7,
55498
+ fog: scene.fog !== undefined
55499
+ });
55500
+ waterP.material.transparent = true;
55501
+ scene.position.y = opt.hight;
55502
+ group.add(waterP);
55503
+ group.add(waterBottom);
55504
+ group.rotation.x = -Math.PI / 2;
55505
+
55506
+ // loadBackground()
55507
+
55508
+ // 渲染器
55509
+ renderer = new WebGLRenderer({
55510
+ canvas: map.getCanvas(),
55511
+ context: gl,
55512
+ logarithmicDepthBuffer: true,
55513
+ antialias: true
55514
+ });
55515
+ renderer.autoClear = false;
55516
+ renderer.physicallyCorrectLights = true;
55517
+ // renderer.outputEncoding = THREE.sRGBEncoding
55518
+ renderer.setSize(container.clientWidth, container.clientHeight);
55519
+
55520
+ // 曝光度
55521
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping
55522
+ // renderer.toneMappingExposure = 1
55523
+
55524
+ // 缩放比例调整
55525
+ window.addEventListener('resize', () => {
55526
+ renderer.setSize(container.clientWidth, container.clientHeight);
55527
+ camera.aspect = container.clientWidth / container.clientHeight;
55528
+ camera.updateProjectionMatrix();
55529
+ });
55530
+
55531
+ // 天空
55532
+ // let sky = new Sky()
55533
+ // scene.add(sky)
55534
+ // sky.scale.setScalar(10000000)
55535
+
55536
+ // const gui = opt.edit ? new dat.GUI() : null
55537
+ // if (gui) {
55538
+ // gui.add(group.position, 'y').step(0.1).name('淹没高度(米)')
55539
+ // }
55540
+
55541
+ // RoomEnvironment
55542
+ // const pmremGenerator = new THREE.PMREMGenerator(renderer)
55543
+ // scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.001).texture
55544
+ },
55545
+
55546
+ render: (gl, matrix) => {
55547
+ const rotationX = new Matrix4().makeRotationAxis(new Vector3(1, 0, 0), modelTransform.rotateX);
55548
+ const rotationY = new Matrix4().makeRotationAxis(new Vector3(0, 1, 0), modelTransform.rotateY);
55549
+ const rotationZ = new Matrix4().makeRotationAxis(new Vector3(0, 0, 1), modelTransform.rotateZ);
55550
+ const m = new Matrix4().fromArray(matrix);
55551
+ const l = new Matrix4().makeTranslation(modelTransform.translateX, modelTransform.translateY, modelTransform.translateZ).scale(new Vector3(modelTransform.scale, -modelTransform.scale, modelTransform.scale)).multiply(rotationX).multiply(rotationY).multiply(rotationZ);
55552
+ camera.projectionMatrix.elements = matrix;
55553
+ camera.projectionMatrix = m.multiply(l);
55554
+ renderer.resetState();
55555
+ renderer.render(scene, camera);
55556
+ map.triggerRepaint();
55557
+
55558
+ // 水面动画
55559
+ waterP.material.uniforms['time'].value += 1.0 / 60.0;
55560
+ // if (waterTop.material.map) {
55561
+ // waterTop.material.map.offset.x += 0.0005
55562
+ // }
55563
+ }
55564
+ };
55565
+
55566
+ return customLayer;
55567
+
55568
+ //获取水面轮廓
55569
+ function getWaterGeometry(center, opt) {
55570
+ if (opt.data) {
55571
+ var points = [];
55572
+ opt.data.features.forEach(geo => {
55573
+ geo.geometry.coordinates.forEach(arr => {
55574
+ arr.forEach(item => {
55575
+ let mercatorCoordinate = mapbox_gl_default().MercatorCoordinate.fromLngLat(item, 0);
55576
+ let units = mercatorCoordinate.meterInMercatorCoordinateUnits();
55577
+ points.push(new Vector2((mercatorCoordinate.x - center.x) / units, -1 * (mercatorCoordinate.y - center.y) / units));
55578
+ });
55579
+ });
55580
+ });
55581
+ var shape = new Shape(points);
55582
+ return new ShapeGeometry(shape);
55583
+ } else {
55584
+ return new PlaneGeometry(opt.size[0], opt.size[1]);
55585
+ }
55586
+ }
55587
+
55588
+ // 环境贴图
55589
+ function loadBackground() {
55590
+ // let sky = new Sky()
55591
+ // let uniforms = sky.material.uniforms
55592
+ // uniforms['turbidity'].value = 10
55593
+ // uniforms['rayleigh'].value = 3
55594
+ // uniforms['mieCoefficient'].value = 0.005
55595
+ // uniforms['mieDirectionalG'].value = 0.7
55596
+ // scene.add(sky)
55597
+
55598
+ new RGBELoader().setPath('/model/hdr/').load('hdr1.hdr', function (texture) {
55599
+ texture.mapping = EquirectangularReflectionMapping;
55600
+ scene.background = texture;
55601
+ scene.environment = texture;
55602
+ });
55603
+ }
55604
+ }
55605
+ });
55606
+ };
55121
55607
  // EXTERNAL MODULE: ./src/package/style/hoverHtml.css
55122
55608
  var hoverHtml = __webpack_require__(6444);
55123
55609
  ;// CONCATENATED MODULE: ./src/package/util/mapHoverHtml.js
@@ -59767,6 +60253,7 @@ var polygon_component = normalizeComponent(
59767
60253
 
59768
60254
 
59769
60255
 
60256
+
59770
60257
  // 图层操作
59771
60258
  const mapLayers = {
59772
60259
  showLayerText: showLayerText,
@@ -59794,7 +60281,8 @@ const mapDraw = {
59794
60281
  addLayerPolygon: addLayerPolygon,
59795
60282
  addLayerCircle: addLayerCircle,
59796
60283
  addCircleAnimate: addCircleAnimate,
59797
- addLayerModel: addLayerModel
60284
+ addLayerModel: addLayerModel,
60285
+ addLayerWater: addLayerWater
59798
60286
  };
59799
60287
 
59800
60288
  // 地图工具