Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
staven630 committed Jul 23, 2021
1 parent bd572ba commit b2a5116
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,101 +51,6 @@ viewer.zoomTo(viewer.entities);
| classificationType | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [ClassificationType](https://staven630.github.io/cesium-doc-zh/global.html#ClassificationType) | <可选> | ClassificationType.BOTH | 指定此折线在地面上时是否对地形、3D 瓷砖或两者进行分类。 |
| zIndex | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| number | <可选> | 0 | 指定用于排序地面几何图形的 zIndex 的属性。仅当 `clampToGround` 为 true 并且支持地形上的折线时才有效。 |

## [PolylineGlowMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineGlowMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :--------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :-------------------------------------------------------------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| glowPower | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 0.25 | 指定发光强度,作为总线宽的百分比 |
| taperPower | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 1.0 | 指定锥形效果的强度,以总线条长度的百分比表示。如果 1.0 或更高,则不使用锥形效果。 |

```js
const glowingLine = viewer.entities.add({
name: "GlowingLine",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([-75, 37, -125, 37]),
width: 10,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.2,
taperPower: 0.5,
color: Cesium.Color.CORNFLOWERBLUE,
}),
},
});
```

![PolylineGlowMaterialProperty](../img/PolylineGlowMaterialProperty.png)

## [PolylineArrowMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineArrowMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :---- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :-------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |

```js
const purpleArrow = viewer.entities.add({
name: "PurpleArrow",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
-75,
43,
500000,
-125,
43,
500000,
]),
width: 10,
arcType: Cesium.ArcType.NONE,
material: new Cesium.PolylineArrowMaterialProperty(Cesium.Color.PURPLE),
},
});
```

![PolylineArrowMaterialProperty](../img/PolylineArrowMaterialProperty.png)

## [PolylineOutlineMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineOutlineMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :----------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :----------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| outlineColor | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | 1.0 | 指定轮廓的 color 属性 |
| outlineWidth | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 1.0 | 指定轮廓的宽度(以像素为单位) |

```js
const orangeOutlined = viewer.entities.add({
name: "OrangeLine",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
-75,
39,
250000,
-125,
39,
250000,
]),
width: 5,
material: new Cesium.PolylineOutlineMaterialProperty({
color: Cesium.Color.ORANGE,
outlineWidth: 2,
outlineColor: Cesium.Color.BLACK,
}),
},
});
```

![PolylineOutlineMaterialProperty](../img/PolylineOutlineMaterialProperty.png)

## [PolylineDashMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineDashMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :---------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :--------------------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| gapColor | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | 1.0 | 指定间隙的颜色 |
| dashLength | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 16.0 | 以像素为单位指定虚线图案长度的数字属性。 |
| dashPattern | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 255.0 | 用于指定破折号的 16 位模式 |

![PolylineDashMaterialProperty](../img/PolylineDashMaterialProperty.png)

## 示例

- [Cesium Sandcastle Polyline Demo](https://sandcastle.cesium.com/index.html?src=Polyline.html)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Fabric](https://github.com/CesiumGS/cesium/wiki/Fabric)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 网格材质[GridMaterialProperty](https://staven630.github.io/cesium-doc-zh/GridMaterialProperty.html)

| 名称 | 类型 | 默认值 | 是否可选 | 描述 |
| :------------ | :--------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------- | :------- | -------------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | Color.WHITE | 可选 | 指定网格的 Color 属性。 |
| cellAlpha | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 0.1 | 可选 | 指定单元格 alpha 值得数字属性 |
| lineCount | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Cartesian2](https://staven630.github.io/cesium-doc-zh/Cartesian2.html) | new Cartesian(8, 8) | 可选 | 指定沿每个轴网格线的数量。 |
| lineThickness | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Cartesian2](https://staven630.github.io/cesium-doc-zh/Cartesian2.html) | new Cartesian(1.0, 1.0) | 可选 | 指定沿每个轴网格线的厚度。 |
| lineOffset | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Cartesian2](https://staven630.github.io/cesium-doc-zh/Cartesian2.html) | new Cartesian(0.0, 0.0) | 可选 | 指定的起始偏移的沿每个轴网格线。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## 发光折线材质[PolylineGlowMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineGlowMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :--------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :-------------------------------------------------------------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| glowPower | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 0.25 | 指定发光强度,作为总线宽的百分比 |
| taperPower | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 1.0 | 指定锥形效果的强度,以总线条长度的百分比表示。如果 1.0 或更高,则不使用锥形效果。 |

```js
const glowingLine = viewer.entities.add({
name: "GlowingLine",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([-75, 37, -125, 37]),
width: 10,
material: new Cesium.PolylineGlowMaterialProperty({
glowPower: 0.2,
taperPower: 0.5,
color: Cesium.Color.CORNFLOWERBLUE,
}),
},
});
```

![PolylineGlowMaterialProperty](../img/PolylineGlowMaterialProperty.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## 轮廓线材质[PolylineOutlineMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineOutlineMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :----------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :----------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| outlineColor | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | 1.0 | 指定轮廓的 color 属性 |
| outlineWidth | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 1.0 | 指定轮廓的宽度(以像素为单位) |

```js
const orangeOutlined = viewer.entities.add({
name: "OrangeLine",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
-75,
39,
250000,
-125,
39,
250000,
]),
width: 5,
material: new Cesium.PolylineOutlineMaterialProperty({
color: Cesium.Color.ORANGE,
outlineWidth: 2,
outlineColor: Cesium.Color.BLACK,
}),
},
});
```

![PolylineOutlineMaterialProperty](../img/PolylineOutlineMaterialProperty.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## 箭头材质[PolylineArrowMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineArrowMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :---- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :-------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |

```js
const purpleArrow = viewer.entities.add({
name: "PurpleArrow",
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
-75,
43,
500000,
-125,
43,
500000,
]),
width: 10,
arcType: Cesium.ArcType.NONE,
material: new Cesium.PolylineArrowMaterialProperty(Cesium.Color.PURPLE),
},
});
```

![PolylineArrowMaterialProperty](../img/PolylineArrowMaterialProperty.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 虚线材质:[PolylineDashMaterialProperty](https://staven630.github.io/cesium-doc-zh/PolylineDashMaterialProperty.html)

| 名称 | 类型 | 是否必填 | 默认值 | 描述 |
| :---------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :---------- | :--------------------------------------- |
| color | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | Color.WHITE | 用于线的 Color 属性。 |
| gapColor | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| [Color](https://staven630.github.io/cesium-doc-zh/Color.html) | 可选 | 1.0 | 指定间隙的颜色 |
| dashLength | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 16.0 | 以像素为单位指定虚线图案长度的数字属性。 |
| dashPattern | [Property](https://staven630.github.io/cesium-doc-zh/Property.html) \| Number | 可选 | 255.0 | 用于指定破折号的 16 位模式 |

![PolylineDashMaterialProperty](../img/PolylineDashMaterialProperty.png)
105 changes: 105 additions & 0 deletions md/前端可视化/Cesium/效果/Cesium地球自转.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
> autoRotation.js
```js
import * as Cesium from "cesium";

export const generateAutoRotationCallback = (viewer, prev) => () => {
const { camera, clock, scene } = viewer;
if (!viewer || !clock.shouldAnimate) {
return;
}
prev = prev || clock.currentTime;
const { currentTime } = clock;
// 算出前后两次的时间间隔
if (scene.mode === Cesium.SceneMode.SCENE2D) {
// 获取相机高度
const { height } = scene.globe.ellipsoid.cartesianToCartographic(
camera.position
);
// 根据高度、地球半径等参数,计算出每秒钟相机需要平移的值
const a = (465.2 / (6371 * 1000)) * (height + 6371 * 1000);
const interval =
Cesium.JulianDate.toDate(currentTime) - Cesium.JulianDate.toDate(prev);
// 调用api平移镜头
camera.moveLeft((interval * a) / 1000);
} else if (scene.mode === Cesium.SceneMode.SCENE3D) {
const interval =
Cesium.JulianDate.toDate(currentTime) - Cesium.JulianDate.toDate(prev);
camera.rotate(
Cesium.Cartesian3.UNIT_Z,
(Math.PI / (24 * 60 * 60)) * (interval / 1000)
);
}
prev = currentTime;
};

export const generate2DAutoRotationCallback = (viewer, prev) => () => {
const { camera, clock, scene } = viewer;

if (
!viewer ||
scene.mode !== Cesium.SceneMode.SCENE2D ||
!clock.shouldAnimate
) {
return;
}

prev = prev || clock.currentTime;

// 获取相机高度
const { height } = scene.globe.ellipsoid.cartesianToCartographic(
camera.position
);
// 根据高度、地球半径等参数,计算出每秒钟相机需要平移的值
const a = (465.2 / (6371 * 1000)) * (height + 6371 * 1000);
const { currentTime } = clock;
// 算出前后两次的时间间隔
const interval =
Cesium.JulianDate.toDate(currentTime) - Cesium.JulianDate.toDate(prev);
prev = currentTime;
// 调用api平移镜头
camera.moveLeft((interval * a) / 1000);
prev = clock.currentTime;
};

export const generate3DAutoRotationCallback = (viewer, prev) => () => {
const { camera, clock, scene } = viewer;

if (
!viewer ||
scene.mode !== Cesium.SceneMode.SCENE3D ||
!clock.shouldAnimate
) {
return;
}

prev = prev || clock.currentTime;
const { currentTime } = clock;
const interval =
Cesium.JulianDate.toDate(currentTime) - Cesium.JulianDate.toDate(prev);
prev = currentTime;

camera.rotate(
Cesium.Cartesian3.UNIT_Z,
(Math.PI / (24 * 60 * 60)) * (interval / 1000)
);
prev = clock.currentTime;
};

// options可以设置时钟的一些参数,比如自转开始的时间,自转的速度等
export const startAutoRotation = (viewer, cb, options = { multiplier: 1 }) => {
stopAutoRotation(viewer, cb);
viewer.scene.postUpdate.addEventListener(cb);
if (viewer.clock) {
const keys = Object.keys(options);
for (const k of keys) {
viewer.clock[k] = options[k];
}
}
};

export const stopAutoRotation = function(viewer, cb) {
if (!viewer) return;
viewer.scene.postUpdate.removeEventListener(cb);
};
```

0 comments on commit b2a5116

Please sign in to comment.