mirror of
https://github.com/ethan-zf/cesium-plot-js.git
synced 2025-06-24 03:27:29 +00:00
Extend Styling to Material
This commit is contained in:
parent
9497a08cbd
commit
de9292fd09
@ -23,7 +23,6 @@ const viewer = new Cesium.Viewer('cesiumContainer', {
|
|||||||
navigationHelpButton: false,
|
navigationHelpButton: false,
|
||||||
baseLayerPicker: false,
|
baseLayerPicker: false,
|
||||||
imageryProvider: raster,
|
imageryProvider: raster,
|
||||||
// imageryProvider: raster,
|
|
||||||
contextOptions: {
|
contextOptions: {
|
||||||
requestWebgl2: true,
|
requestWebgl2: true,
|
||||||
},
|
},
|
||||||
@ -56,28 +55,35 @@ buttonGroup.onclick = (evt) => {
|
|||||||
switch (targetElement.id) {
|
switch (targetElement.id) {
|
||||||
case 'drawFineArrow':
|
case 'drawFineArrow':
|
||||||
geometry = new CesiumPlot.FineArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.FineArrow(Cesium, viewer, {
|
||||||
fillColor: Cesium.Color.fromCssColorString('rgba(59, 178, 208, 0.5)'),
|
material: Cesium.Color.fromCssColorString('rgba(59, 178, 208, 0.5)'),
|
||||||
|
outlineMaterial: Cesium.Color.fromCssColorString('rgba(59, 178, 208, 1)'),
|
||||||
|
outlineWidth: 3,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawAttackArrow':
|
case 'drawAttackArrow':
|
||||||
geometry = new CesiumPlot.AttackArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.AttackArrow(Cesium, viewer, {
|
||||||
outlineColor: Cesium.Color.RED,
|
outlineMaterial: Cesium.Color.RED,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawSwallowtailAttackArrow':
|
case 'drawSwallowtailAttackArrow':
|
||||||
geometry = new CesiumPlot.SwallowtailAttackArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.SwallowtailAttackArrow(Cesium, viewer, {
|
||||||
outlineColor: Cesium.Color.BLUE,
|
outlineMaterial: Cesium.Color.BLUE,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawSquadCombat':
|
case 'drawSquadCombat':
|
||||||
geometry = new CesiumPlot.SquadCombat(Cesium, viewer);
|
geometry = new CesiumPlot.SquadCombat(Cesium, viewer, {
|
||||||
|
outlineMaterial: new Cesium.PolylineDashMaterialProperty({
|
||||||
|
color: Cesium.Color.RED,
|
||||||
|
dashLength: 16.0,
|
||||||
|
}),
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawSwallowtailSquadCombat':
|
case 'drawSwallowtailSquadCombat':
|
||||||
geometry = new CesiumPlot.SwallowtailSquadCombat(Cesium, viewer);
|
geometry = new CesiumPlot.SwallowtailSquadCombat(Cesium, viewer);
|
||||||
break;
|
break;
|
||||||
case 'drawStraightArrow':
|
case 'drawStraightArrow':
|
||||||
geometry = new CesiumPlot.StraightArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.StraightArrow(Cesium, viewer, {
|
||||||
lineColor: Cesium.Color.RED,
|
material: Cesium.Color.RED,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawAssaultDirection':
|
case 'drawAssaultDirection':
|
||||||
@ -85,12 +91,12 @@ buttonGroup.onclick = (evt) => {
|
|||||||
break;
|
break;
|
||||||
case 'drawCurvedArrow':
|
case 'drawCurvedArrow':
|
||||||
geometry = new CesiumPlot.CurvedArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.CurvedArrow(Cesium, viewer, {
|
||||||
lineColor: Cesium.Color.BLUE,
|
material: Cesium.Color.BLUE,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawDoubleArrow':
|
case 'drawDoubleArrow':
|
||||||
geometry = new CesiumPlot.DoubleArrow(Cesium, viewer, {
|
geometry = new CesiumPlot.DoubleArrow(Cesium, viewer, {
|
||||||
outlineColor: Cesium.Color.GREEN,
|
outlineMaterial: Cesium.Color.GREEN,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'drawFreehandLine':
|
case 'drawFreehandLine':
|
||||||
@ -101,7 +107,6 @@ buttonGroup.onclick = (evt) => {
|
|||||||
break;
|
break;
|
||||||
case 'hide':
|
case 'hide':
|
||||||
geometry && geometry.hide();
|
geometry && geometry.hide();
|
||||||
// setTimeout(getCameraInfo, 2000);
|
|
||||||
break;
|
break;
|
||||||
case 'show':
|
case 'show':
|
||||||
geometry && geometry.show();
|
geometry && geometry.show();
|
||||||
|
14
src/base.ts
14
src/base.ts
@ -31,8 +31,8 @@ export default class Base {
|
|||||||
if (this.type === 'polygon') {
|
if (this.type === 'polygon') {
|
||||||
this.style = Object.assign(
|
this.style = Object.assign(
|
||||||
{
|
{
|
||||||
fillColor: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 0.2)'),
|
material: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 0.2)'),
|
||||||
outlineColor: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 1.0)'),
|
outlineMaterial: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 1.0)'),
|
||||||
outlineWidth: 2,
|
outlineWidth: 2,
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
@ -40,7 +40,7 @@ export default class Base {
|
|||||||
} else if (this.type === 'line') {
|
} else if (this.type === 'line') {
|
||||||
this.style = Object.assign(
|
this.style = Object.assign(
|
||||||
{
|
{
|
||||||
lineColor: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 1.0)'),
|
material: this.cesium.Color.fromCssColorString('rgba(59, 178, 208, 1.0)'),
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
@ -168,7 +168,7 @@ export default class Base {
|
|||||||
polygon: new this.cesium.PolygonGraphics({
|
polygon: new this.cesium.PolygonGraphics({
|
||||||
hierarchy: new this.cesium.CallbackProperty(callback, false),
|
hierarchy: new this.cesium.CallbackProperty(callback, false),
|
||||||
show: true,
|
show: true,
|
||||||
material: style.fillColor,
|
material: style.material,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ export default class Base {
|
|||||||
return [...this.geometryPoints, this.geometryPoints[0]];
|
return [...this.geometryPoints, this.geometryPoints[0]];
|
||||||
}, false),
|
}, false),
|
||||||
width: style.outlineWidth,
|
width: style.outlineWidth,
|
||||||
material: style.outlineColor,
|
material: style.outlineMaterial,
|
||||||
clampToGround: true,
|
clampToGround: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -198,7 +198,7 @@ export default class Base {
|
|||||||
// The line style between the first two points matches the outline style.
|
// The line style between the first two points matches the outline style.
|
||||||
const style = this.style as PolygonStyle;
|
const style = this.style as PolygonStyle;
|
||||||
const lineStyle = {
|
const lineStyle = {
|
||||||
lineColor: style.outlineColor,
|
material: style.outlineMaterial,
|
||||||
lineWidth: style.outlineWidth,
|
lineWidth: style.outlineWidth,
|
||||||
};
|
};
|
||||||
this.lineEntity = this.addLineEntity(lineStyle);
|
this.lineEntity = this.addLineEntity(lineStyle);
|
||||||
@ -210,7 +210,7 @@ export default class Base {
|
|||||||
polyline: {
|
polyline: {
|
||||||
positions: new this.cesium.CallbackProperty(() => this.geometryPoints, false),
|
positions: new this.cesium.CallbackProperty(() => this.geometryPoints, false),
|
||||||
width: style.lineWidth,
|
width: style.lineWidth,
|
||||||
material: style.lineColor,
|
material: style.material,
|
||||||
clampToGround: true,
|
clampToGround: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
import * as CesiumTypeOnly from '@examples/cesium';
|
import * as CesiumTypeOnly from '@examples/cesium';
|
||||||
|
|
||||||
export type PolygonStyle = {
|
export type PolygonStyle = {
|
||||||
fillColor?: CesiumTypeOnly.Color;
|
material?: CesiumTypeOnly.MaterialProperty;
|
||||||
outlineWidth?: number;
|
outlineWidth?: number;
|
||||||
outlineColor?: CesiumTypeOnly.Color;
|
outlineMaterial?: CesiumTypeOnly.MaterialProperty;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LineStyle = {
|
export type LineStyle = {
|
||||||
lineColor?: CesiumTypeOnly.Color;
|
material?: CesiumTypeOnly.Color;
|
||||||
lineWidth?: number;
|
lineWidth?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user