| import Overlay from '../Overlay' | import Overlay from '../Overlay' | ||||
| class WaterPrimitive extends Overlay { | class WaterPrimitive extends Overlay { | ||||
| constructor(positions) { | |||||
| constructor(positions, holes = []) { | |||||
| super() | super() | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._holes = holes.map(item => Parse.parsePositions(item)) | |||||
| this._delegate = new Cesium.GroundPrimitive({ | this._delegate = new Cesium.GroundPrimitive({ | ||||
| geometryInstances: new Cesium.GeometryInstance({ | geometryInstances: new Cesium.GeometryInstance({ | ||||
| geometry: {} | geometry: {} | ||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions( | |||||
| { | |||||
| positions: Transform.transformWGS84ArrayToCartesianArray( | |||||
| this._positions | |||||
| ), | |||||
| height: this._style?.height, | |||||
| extrudedHeight: this._style?.extrudedHeight, | |||||
| closeTop: this._style?.closeTop, | |||||
| closeBottom: this._style?.closeBottom, | |||||
| vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT | |||||
| } | |||||
| ) | |||||
| this._delegate.geometryInstances.geometry = new Cesium.PolygonGeometry({ | |||||
| polygonHierarchy: new Cesium.PolygonHierarchy( | |||||
| Transform.transformWGS84ArrayToCartesianArray(this._positions), | |||||
| this._holes.map( | |||||
| item => | |||||
| new Cesium.PolygonHierarchy( | |||||
| Transform.transformWGS84ArrayToCartesianArray(item) | |||||
| ) | |||||
| ) | |||||
| ), | |||||
| height: this._style?.height, | |||||
| extrudedHeight: this._style?.extrudedHeight, | |||||
| closeTop: this._style?.closeTop, | |||||
| closeBottom: this._style?.closeBottom, | |||||
| vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT | |||||
| }) | |||||
| return this | return this | ||||
| } | } | ||||