@ino-cesium/layers 0.0.18 → 0.0.19
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/dist/index.d.ts +15 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,25 @@ import * as Cesium from 'cesium';
|
|
|
10
10
|
declare const loadTianDiTu: (option: ILoadTiandituOptions) => {
|
|
11
11
|
layers: Cesium.ImageryLayer[];
|
|
12
12
|
remove: () => void;
|
|
13
|
+
setOpacity: (opacity: number) => void;
|
|
13
14
|
};
|
|
14
15
|
interface ILoadTiandituOptions {
|
|
15
16
|
viewer: Cesium.Viewer;
|
|
16
17
|
token: string;
|
|
18
|
+
vec?: boolean;
|
|
19
|
+
label?: boolean;
|
|
17
20
|
zIndex?: number;
|
|
18
21
|
}
|
|
22
|
+
declare function setImageLayerTheme(viewer: Cesium.Viewer, options?: ISetImageLayerOptions): void;
|
|
23
|
+
interface ISetImageLayerOptions {
|
|
24
|
+
brightness?: number;
|
|
25
|
+
contrast?: number;
|
|
26
|
+
gamma?: number;
|
|
27
|
+
hue?: number;
|
|
28
|
+
saturation?: number;
|
|
29
|
+
invertColor?: boolean;
|
|
30
|
+
filterColor?: Cesium.Color;
|
|
31
|
+
}
|
|
19
32
|
|
|
20
33
|
declare const load3dTiles: (lOptions: ILoad3dtilesOptions) => Promise<{
|
|
21
34
|
tileset: Cesium.Cesium3DTileset;
|
|
@@ -85,5 +98,5 @@ interface ILoadI3sOptions {
|
|
|
85
98
|
options: Cesium.I3SDataProvider.ConstructorOptions;
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
export { TransformsFor3dtiles, getAllFeaturesFrom3dTiles, getAllTilesFrom3dTiles, load3dTiles, loadI3s, loadModel, loadTerrain, loadTerrainFromCesium, loadTianDiTu, loads3m, removeTerrain, setHeightOffsetFor3dTiles };
|
|
89
|
-
export type { ILoadTerrainOptions, ILoadTiandituOptions };
|
|
101
|
+
export { TransformsFor3dtiles, getAllFeaturesFrom3dTiles, getAllTilesFrom3dTiles, load3dTiles, loadI3s, loadModel, loadTerrain, loadTerrainFromCesium, loadTianDiTu, loads3m, removeTerrain, setHeightOffsetFor3dTiles, setImageLayerTheme };
|
|
102
|
+
export type { ILoadTerrainOptions, ILoadTiandituOptions, ISetImageLayerOptions };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"cesium";const r=r=>{const{viewer:t,token:
|
|
1
|
+
import*as e from"cesium";const r=r=>{const{viewer:t,token:o}=r,a=r.vec?"vec":"img",i=[],n=t.imageryLayers.addImageryProvider(new e.WebMapTileServiceImageryProvider({url:`//t{s}.tianditu.gov.cn/${a}_w/wmts?tk=${o}`,layer:a,style:"default",tileMatrixSetID:"w",format:"tiles",maximumLevel:18,subdomains:["0","1","2","3","4","5","6","7"]}));if(i.push(n),console.log(n),r.label){const r=t.imageryLayers.addImageryProvider(new e.WebMapTileServiceImageryProvider({url:`//t{s}.tianditu.gov.cn/cia_w/wmts?tk=${o}`,layer:"cia",style:"default",tileMatrixSetID:"w",format:"tiles",maximumLevel:18,subdomains:["0","1","2","3","4","5","6","7"]}));i.push(r)}return{layers:i,remove:()=>{i.forEach(e=>{t.imageryLayers.remove(e)})},setOpacity:e=>{i.forEach(r=>{r.alpha=e})}}};function t(r,t){t||(t={}),console.log(t.filterColor);const o=r.imageryLayers.get(0);if(!o)return;o.brightness=t.brightness??.6,o.contrast=t.contrast??1.8,o.gamma=t.gamma??.3,o.hue=t.hue??1,o.saturation=t.saturation||0;const a=r.scene.globe._surfaceShaderSet.baseFragmentShaderSource.sources;for(let r=0;r<a.length;r++){const o="color = czm_saturation(color, textureSaturation);\n#endif\n";let i="color = czm_saturation(color, textureSaturation);\n#endif\n";t.invertColor||(i+="\n color.r = 1.0 - color.r;\n color.g = 1.0 - color.g;\n color.b = 1.0 - color.b;\n "),t.filterColor||(t.filterColor=e.Color.fromCssColorString("rgba(100,138,230,0.5)")),i+=`\n color.r = color.r * ${t.filterColor.red.toFixed(2)};\n color.g = color.g * ${t.filterColor.green.toFixed(2)};\n color.b = color.b * ${t.filterColor.blue.toFixed(2)};\n // color.a = color.a * ${t.filterColor.alpha.toFixed(2)};\n `,a[r]=a[r].replace(o,i)}r.scene.requestRender()}const o={cacheBytes:4294967296,maximumCacheOverflowBytes:5368709120},a=async r=>{const{viewer:t,url:a,options:n}=r,s=await e.Cesium3DTileset.fromUrl(a,{...o,...n});t.scene.primitives.add(s);return{tileset:s,setHeightOffset:e=>{i(s,e)},remove:()=>{t.scene.primitives.remove(s)},flyTo:()=>{t.flyTo(s)}}},i=(r,t)=>{l(r,e.Cartesian3.fromElements(0,0,t,new e.Cartesian3))},n=async e=>{const r=[];function t(e){if(console.log(e),!e.content||!e.content.featuresLength)return;const o=e.content;for(let e=0;e<o.featuresLength;e++)r.push(o.getFeature(e));e.children?.forEach(t)}return new Promise(o=>{e.allTilesLoaded.addEventListener(()=>{t(e.root),o(r)})})},s=e=>{const r=[];function t(e){r.push(e),e.children?.forEach(t)}return new Promise(o=>{e.allTilesLoaded.addEventListener(()=>{t(e.root),o(r)})})},l=(r,t)=>{if(t.equals(e.Cartesian3.ZERO))return;const o=r.boundingSphere.center,a=e.Transforms.eastNorthUpToFixedFrame(o),i=e.Matrix4.multiplyByPoint(a,t,new e.Cartesian3),n=e.Cartesian3.subtract(i,o,new e.Cartesian3),s=e.Matrix4.fromTranslation(n);r.modelMatrix=e.Matrix4.multiply(s,r.modelMatrix,new e.Matrix4)},c={translate:l,scale:(r,t)=>{if(t.equals(e.Cartesian3.ZERO)||t.equals(e.Cartesian3.ONE))return;const o=r.boundingSphere.center,a=e.Transforms.eastNorthUpToFixedFrame(o),i=e.Matrix4.inverse(a,new e.Matrix4),n=e.Matrix4.fromScale(t),s=e.Matrix4.multiply(n,i,new e.Matrix4),l=e.Matrix4.multiply(a,s,new e.Matrix4);r.modelMatrix=e.Matrix4.multiply(l,r.modelMatrix,new e.Matrix4)},rotate:(r,t)=>{const{x:o,y:a,z:i}=t,n=r.boundingSphere.center,s=e.Transforms.eastNorthUpToFixedFrame(n),l=e.Matrix4.inverse(s,new e.Matrix4),c=e.Matrix4.clone(e.Matrix4.IDENTITY);if(0!==o){const r=e.Matrix4.fromRotation(e.Matrix3.fromRotationX(e.Math.toRadians(o)));e.Matrix4.multiply(r,c,c)}if(0!==a){const r=e.Matrix4.fromRotation(e.Matrix3.fromRotationY(e.Math.toRadians(a)));e.Matrix4.multiply(r,c,c)}if(0!==i){const r=e.Matrix4.fromRotation(e.Matrix3.fromRotationZ(e.Math.toRadians(i)));e.Matrix4.multiply(r,c,c)}const m=e.Matrix4.multiply(c,l,new e.Matrix4),u=e.Matrix4.multiply(s,m,new e.Matrix4);r.modelMatrix=e.Matrix4.multiply(u,r.modelMatrix,new e.Matrix4)}},m=async r=>{const{viewer:t,url:o}=r,a=await e.CesiumTerrainProvider.fromUrl(o,{requestWaterMask:!0,requestVertexNormals:!0});t.scene.terrainProvider=a;return{terrainProvider:a,remove:()=>{t.scene.terrainProvider=new e.EllipsoidTerrainProvider}}},u=r=>{r.scene.terrainProvider=new e.EllipsoidTerrainProvider},d=async()=>await e.CesiumTerrainProvider.fromIonAssetId(1,{requestWaterMask:!0,requestVertexNormals:!0}),f=()=>{},x=()=>{},M=async r=>{const{viewer:t,url:o,options:a}=r,n=await e.I3SDataProvider.fromUrl(o,a);t.scene.primitives.add(n);return{i3sProvider:n,setHeightOffset:e=>{n.layers.forEach(r=>{const t=r.tileset;t&&i(t,e)})},remove:()=>{t.scene.primitives.remove(n)},flyTo:r=>{const o=e.Rectangle.center(n.extent);o.height=r;let a=n.data;e.defined(a.layers)&&a.layers.length>0&&(a=a.layers[0]),e.defined(a.fullExtent)&&e.defined(a.fullExtent.zmax)&&(o.height+=a.fullExtent.zmax);const i=e.Ellipsoid.WGS84.cartographicToCartesian(o);t.camera.flyTo({destination:i,orientation:{}})}}};export{c as TransformsFor3dtiles,n as getAllFeaturesFrom3dTiles,s as getAllTilesFrom3dTiles,a as load3dTiles,M as loadI3s,f as loadModel,m as loadTerrain,d as loadTerrainFromCesium,r as loadTianDiTu,x as loads3m,u as removeTerrain,i as setHeightOffsetFor3dTiles,t as setImageLayerTheme};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ino-cesium/layers",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.19",
|
|
5
5
|
"author": "koino",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cesium",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"cesium": "1.131.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ino-cesium/common": "0.0.
|
|
31
|
+
"@ino-cesium/common": "0.0.19"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {},
|
|
34
34
|
"scripts": {
|