Browse Source

init

tags/3.0.0
Caven Chen 2 years ago
parent
commit
d236e97aca
61 changed files with 839 additions and 464 deletions
  1. 7
    41
      README.md
  2. 134
    0
      examples/index.html
  3. 328
    0
      examples/jquery.accordion.js
  4. 34
    0
      examples/list.js
  5. 0
    30
      examples/test.html
  6. 1
    2
      package.json
  7. 1
    3
      server.js
  8. 12
    5
      src/modules/exts/BaseLayerPicker.js
  9. 3
    3
      src/modules/exts/Viewer.js
  10. 39
    26
      src/modules/imagery/ImageryLayerFactory.js
  11. 1
    1
      src/modules/imagery/provider/AmapImageryProvider.js
  12. 9
    102
      src/modules/imagery/provider/BaiduImageryProvider.js
  13. 29
    0
      src/modules/imagery/provider/GeoVisImageryProvider.js
  14. 5
    1
      src/modules/index.js
  15. 1
    1
      src/modules/material/property/polyline/PolylineLightingMaterialProperty.js
  16. 1
    1
      src/modules/material/property/polyline/PolylineLightingTrailMaterialProperty.js
  17. 1
    1
      src/modules/material/property/polyline/PolylineTrailMaterialProperty.js
  18. 1
    1
      src/modules/material/property/radar/RadarLineMaterialProperty.js
  19. 1
    1
      src/modules/material/property/radar/RadarSweepMaterialProperty.js
  20. 1
    1
      src/modules/material/property/radar/RadarWaveMaterialProperty.js
  21. 1
    1
      src/modules/material/property/wall/WallImageTrailMaterialProperty.js
  22. 1
    1
      src/modules/material/property/wall/WallLineTrailMaterialProperty.js
  23. 1
    1
      src/modules/material/property/wall/WallTrailMaterialProperty.js
  24. 1
    1
      src/modules/material/property/water/WaterMaterialProperty.js
  25. 24
    24
      src/modules/material/type/polyline.js
  26. 12
    12
      src/modules/material/type/radar.js
  27. 47
    47
      src/modules/material/type/thirdpart.js
  28. 16
    16
      src/modules/material/type/wall.js
  29. 3
    3
      src/modules/math/curve.js
  30. 1
    1
      src/modules/measure/Measure.js
  31. 6
    6
      src/modules/measure/MeasureBase.js
  32. 1
    1
      src/modules/measure/MeasureType.js
  33. 5
    5
      src/modules/measure/edit/EditPolygon.js
  34. 5
    5
      src/modules/measure/edit/EditPolyline.js
  35. 4
    5
      src/modules/measure/type/Area.js
  36. 5
    5
      src/modules/measure/type/AreaHeight.js
  37. 6
    7
      src/modules/measure/type/AreaSurface.js
  38. 5
    5
      src/modules/measure/type/Distance.js
  39. 6
    6
      src/modules/measure/type/DistanceSurface.js
  40. 5
    5
      src/modules/measure/type/Heading.js
  41. 9
    9
      src/modules/measure/type/Height.js
  42. 14
    14
      src/modules/measure/type/TriangleHeight.js
  43. 27
    13
      src/modules/viewer/Viewer.js
  44. 2
    2
      src/modules/widget/Widget.js
  45. 1
    1
      src/modules/widget/index.js
  46. 1
    1
      src/modules/widget/type/Compass.js
  47. 1
    1
      src/modules/widget/type/ContextMenu.js
  48. 1
    1
      src/modules/widget/type/DistanceLegend.js
  49. 1
    1
      src/modules/widget/type/HawkeyeMap.js
  50. 1
    1
      src/modules/widget/type/LoadingMask.js
  51. 1
    1
      src/modules/widget/type/LocationBar.js
  52. 1
    1
      src/modules/widget/type/MapSplit.js
  53. 2
    2
      src/modules/widget/type/MapSwitch.js
  54. 1
    1
      src/modules/widget/type/Popup.js
  55. 1
    1
      src/modules/widget/type/SceneSplit.js
  56. 1
    1
      src/modules/widget/type/TilesetSplit.js
  57. 1
    1
      src/modules/widget/type/Tooltip.js
  58. 1
    1
      src/modules/widget/type/ZoomController.js
  59. 1
    1
      src/modules/wind/WindCanvas.js
  60. 1
    0
      src/themes/index.js
  61. 6
    33
      src/themes/index.scss

+ 7
- 41
README.md View File

``` ```


```js ```js
import DC from '@dvgis/dc-sdk/dist/dc.base.min'
import DcCore from '@dvgis/dc-sdk/dist/dc.core.min'
import DcChart from '@dvgis/dc-sdk/dist/dc.chart.min'
import DcMapv from '@dvgis/dc-sdk/dist/dc.mapv.min'
import DcS3M from '@dvgis/dc-sdk/dist/dc.s3m.min'
import '@dvgis/dc-sdk/dist/dc.core.min.css'
```

`NPM / YARN` **_`(On-demand)`_**

```shell
yarn add @dvgis/dc-base
yarn add @dvgis/dc-core
yarn add @dvgis/dc-chart
yarn add @dvgis/dc-mapv
yarn add @dvgis/dc-s3m
-------------------------
npm install @dvgis/dc-base
npm install @dvgis/dc-core
npm install @dvgis/dc-chart
npm install @dvgis/dc-mapv
npm install @dvgis/dc-s3m
```

```js
import DC from '@dvgis/dc-base'
import DcCore from '@dvgis/dc-core'
import DcChart from '@dvgis/dc-chart'
import DcMapv from '@dvgis/dc-mapv'
import DcS3M from '@dvgis/dc-s3m'
import '@dvgis/dc-core/dist/dc.core.min.css'
import * as DC from '@dvgis/dc-sdk'
import '@dvgis/dc-sdk/dist/dc.min.css'
``` ```


`CDN` `CDN`
[Resources](https://github.com/dvgis/dc-sdk/releases) [Resources](https://github.com/dvgis/dc-sdk/releases)


```html ```html
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.base.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.mapv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.s3m.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.min.js"></script>
<link <link
href="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.core.min.css"
href="https://cdn.jsdelivr.net/npm/@dvgis/dc-sdk/dist/dc.min.css"
rel="stylesheet" rel="stylesheet"
type="text/css" type="text/css"
/> />


> The configuration is mainly used in the `NPM / YARN` way > The configuration is mainly used in the `NPM / YARN` way


Since the `DC` framework sets `CESIUM_BASE_URL` to `./libs/dc-sdk/resources/` , you need to copy `Cesium` related static resources files: `Assets` , `Workers` , `ThirdParty `to `libs/dc-sdk/resources` directory of the project to ensure that the 3D scene can be rendered properly. You can also use `DC.baseUrl` to set the static resource base related to `Cesium` .
Since the `DC` framework sets `CESIUM_BASE_URL` to `./libs/dc-sdk/resources/` , you need to copy `Cesium` related static resources files: `Assets` , `Workers` , `ThirdParty `to `libs/dc-sdk/resources` directory of the project to ensure that the 3D scene can be rendered properly. You can also use `DC.config.baseUrl` to set the static resource base related to `Cesium` .


`Webpack` `Webpack`




```js ```js
global.DC = DC global.DC = DC
DC.use(DcCore) // node
DC.ready(() => {
let viewer = new DC.Viewer(divId) // divId is the Id attribute value of a div node. If it is not passed in, the 3D scene cannot be initialized
DC.ready({}).then(()=>{
let viewer = new DC.Viewer()
}) })
``` ```



+ 134
- 0
examples/index.html View File

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="./jquery.min.js"></script>
<script src="./jquery.accordion.js"></script>
<style>

* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
overflow: hidden;
}
.container{
display: flex;
height: 100%;
}
.nav{
width: 300px;
height: 100%;
overflow: hidden;
background: #222;
color: #fff;
}
.example{
flex: 1;
height: 100%;
overflow: hidden;
}

iframe{
width: 100%;
height: 100%;
overflow: hidden;
}

.nav .banner{
padding: 20px 20px 0 20px;
color:#1e80ff;
font-weight: bold;
font-style: italic;
}
.example-list-wrapper{
overflow: hidden;
overflow-y: auto;
user-select: none;
margin-top: 15px;
}

.example-list h4{
padding-left: 20px;
padding-top: 20px;
margin: 10px 0;
border-top: 1px solid #444 ;
}

.example-list h4:hover,.example-list ul li:hover{
cursor: pointer;
}

.example-list ul{
padding-left: 33px;
list-style: none;
}

.example-list ul li{
margin: 10px 0;
font-size: 15px;
}

.example-list ul li:hover,.example-list ul li.active{
color: #1e80ff;
}




</style>
</head>
<body>

<div class="container">
<div class="nav">
<div class="banner"> DC-SDK v3.0.0 </div>
<div class="example-list-wrapper">
<div id="example-list" class="example-list" data-accordion-group> </div>
</div>
</div>
<div class="example">
<iframe id="inner-page" src="info/start.html" style="border: 0"></iframe>
</div>

<script src="./list.js"></script>
<script type="text/javascript">
$(document).ready(function() {
let $currentPage = undefined
EXAMPLE_LIST.forEach(item => {
let $section = $('<div data-accordion ></div>')
let $title = $('<h4 data-control ></h4>').text(item.name)
$title.appendTo($section)
let $pageWrapper= $('<ul data-content></ul>')
$pageWrapper.appendTo($section)
if(item.children){
item.children.forEach(child => {
let $page = $('<li>'+ child.name +'</li>')
$page.bind('click',e=>{
if($currentPage){
$currentPage.removeClass('active')
}
$('#inner-page').attr('src',item.folder+'/'+child.page)
$page.addClass('active')
$currentPage =$page
})
$pageWrapper.append($page)
})
}
$section.appendTo($('#example-list'))

})
$('#example-list [data-accordion]').accordion();
});
</script>
</div>
</body>
</html>

+ 328
- 0
examples/jquery.accordion.js View File

;(function ($, window, document, undefined) {
var pluginName = 'accordion',
defaults = {
transitionSpeed: 300,
transitionEasing: 'ease',
controlElement: '[data-control]',
contentElement: '[data-content]',
groupElement: '[data-accordion-group]',
singleOpen: true,
}

function Accordion(element, options) {
this.element = element
this.options = $.extend({}, defaults, options)
this._defaults = defaults
this._name = pluginName
this.init()
}

Accordion.prototype.init = function () {
var self = this,
opts = self.options

var $accordion = $(self.element),
$controls = $accordion.find('> ' + opts.controlElement),
$content = $accordion.find('> ' + opts.contentElement)

var accordionParentsQty = $accordion.parents('[data-accordion]').length,
accordionHasParent = accordionParentsQty > 0

var closedCSS = { 'max-height': 0, overflow: 'hidden' }

var CSStransitions = supportsTransitions()

function debounce(func, threshold, execAsap) {
var timeout

return function debounced() {
var obj = this,
args = arguments

function delayed() {
if (!execAsap) func.apply(obj, args)
timeout = null
}

if (timeout) clearTimeout(timeout)
else if (execAsap) func.apply(obj, args)

timeout = setTimeout(delayed, threshold || 100)
}
}

function supportsTransitions() {
var b = document.body || document.documentElement,
s = b.style,
p = 'transition'

if (typeof s[p] == 'string') {
return true
}

var v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms']

p = 'Transition'

for (var i = 0; i < v.length; i++) {
if (typeof s[v[i] + p] == 'string') {
return true
}
}

return false
}

function requestAnimFrame(cb) {
if (window.requestAnimationFrame) {
requestAnimationFrame(cb)
} else if (window.webkitRequestAnimationFrame) {
webkitRequestAnimationFrame(cb)
} else if (window.mozRequestAnimationFrame) {
mozRequestAnimationFrame(cb)
} else {
setTimeout(cb, 1000 / 60)
}
}

function toggleTransition($el, remove) {
if (!remove) {
$content.css({
'-webkit-transition':
'max-height ' +
opts.transitionSpeed +
'ms ' +
opts.transitionEasing,
transition:
'max-height ' +
opts.transitionSpeed +
'ms ' +
opts.transitionEasing,
})
} else {
$content.css({
'-webkit-transition': '',
transition: '',
})
}
}

function calculateHeight($el) {
var height = 0

$el.children().each(function () {
height = height + $(this).outerHeight(true)
})

$el.data('oHeight', height)
}

function updateParentHeight(
$parentAccordion,
$currentAccordion,
qty,
operation
) {
var $content = $parentAccordion.filter('.open').find('> [data-content]'),
$childs = $content.find('[data-accordion].open > [data-content]'),
$matched

if (!opts.singleOpen) {
$childs = $childs.not(
$currentAccordion
.siblings('[data-accordion].open')
.find('> [data-content]')
)
}

$matched = $content.add($childs)

if ($parentAccordion.hasClass('open')) {
$matched.each(function () {
var currentHeight = $(this).data('oHeight')

switch (operation) {
case '+':
$(this).data('oHeight', currentHeight + qty)
break
case '-':
$(this).data('oHeight', currentHeight - qty)
break
default:
throw 'updateParentHeight method needs an operation'
}

$(this).css('max-height', $(this).data('oHeight'))
})
}
}

function refreshHeight($accordion) {
if ($accordion.hasClass('open')) {
var $content = $accordion.find('> [data-content]'),
$childs = $content.find('[data-accordion].open > [data-content]'),
$matched = $content.add($childs)

calculateHeight($matched)

$matched.css('max-height', $matched.data('oHeight'))
}
}

function closeAccordion($accordion, $content) {
$accordion.trigger('accordion.close')

if (CSStransitions) {
if (accordionHasParent) {
var $parentAccordions = $accordion.parents('[data-accordion]')

updateParentHeight(
$parentAccordions,
$accordion,
$content.data('oHeight'),
'-'
)
}

$content.css(closedCSS)

$accordion.removeClass('open')
} else {
$content.css('max-height', $content.data('oHeight'))

$content.animate(closedCSS, opts.transitionSpeed)

$accordion.removeClass('open')
}
}

function openAccordion($accordion, $content) {
$accordion.trigger('accordion.open')
if (CSStransitions) {
toggleTransition($content)

if (accordionHasParent) {
var $parentAccordions = $accordion.parents('[data-accordion]')

updateParentHeight(
$parentAccordions,
$accordion,
$content.data('oHeight'),
'+'
)
}

requestAnimFrame(function () {
$content.css('max-height', $content.data('oHeight'))
})

$accordion.addClass('open')
} else {
$content.animate(
{
'max-height': $content.data('oHeight'),
},
opts.transitionSpeed,
function () {
$content.css({ 'max-height': 'none' })
}
)

$accordion.addClass('open')
}
}

function closeSiblingAccordions($accordion) {
var $accordionGroup = $accordion.closest(opts.groupElement)

var $siblings = $accordion.siblings('[data-accordion]').filter('.open'),
$siblingsChildren = $siblings.find('[data-accordion]').filter('.open')

var $otherAccordions = $siblings.add($siblingsChildren)

$otherAccordions.each(function () {
var $accordion = $(this),
$content = $accordion.find(opts.contentElement)

closeAccordion($accordion, $content)
})

$otherAccordions.removeClass('open')
}

function toggleAccordion() {
var isAccordionGroup = opts.singleOpen
? $accordion.parents(opts.groupElement).length > 0
: false

calculateHeight($content)

if (isAccordionGroup) {
closeSiblingAccordions($accordion)
}

if ($accordion.hasClass('open')) {
closeAccordion($accordion, $content)
} else {
openAccordion($accordion, $content)
}
}

function addEventListeners() {
$controls.on('click', toggleAccordion)

$controls.on('accordion.toggle', function () {
if (opts.singleOpen && $controls.length > 1) {
return false
}

toggleAccordion()
})

$controls.on('accordion.refresh', function () {
refreshHeight($accordion)
})

$(window).on(
'resize',
debounce(function () {
refreshHeight($accordion)
})
)
}

function setup() {
$content.each(function () {
var $curr = $(this)

if ($curr.css('max-height') != 0) {
if (!$curr.closest('[data-accordion]').hasClass('open')) {
$curr.css({ 'max-height': 0, overflow: 'hidden' })
} else {
toggleTransition($curr)
calculateHeight($curr)

$curr.css('max-height', $curr.data('oHeight'))
}
}
})

if (!$accordion.attr('data-accordion')) {
$accordion.attr('data-accordion', '')
$accordion.find(opts.controlElement).attr('data-control', '')
$accordion.find(opts.contentElement).attr('data-content', '')
}
}

setup()
addEventListeners()
}

$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Accordion(this, options))
}
})
}
})(jQuery, window, document)

+ 34
- 0
examples/list.js View File

const EXAMPLE_LIST = [
{
name: '基础',
folder: 'info',
children: [
{
name: '开始',
page: 'start.html',
},
{
name: '坐标参考',
page: 'coord.html',
},
],
},
{
name: '地图',
folder: 'baselayer',
children: [
{
name: '高德地图',
page: 'amap.html',
},
{
name: '高德地图(偏移)',
page: 'amap_no_offset.html',
},
{
name: 'Arcgis',
page: 'arcgis.html',
},
],
},
]

+ 0
- 30
examples/test.html View File

<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>demo</title>
<script src='/libs/dc-sdk/dc.min.js'></script>
<link href='/libs/dc-sdk/dc.min.css' type='text/css' rel='stylesheet'>
<style>
*{
padding: 0;
margin: 0;
}
html,body,#map-container{
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<div id="map-container">
</div>
</body>
<script>
DC.ready().then(()=>{
new DC.Viewer('map-container')
})
</script>

+ 1
- 2
package.json View File

{ {
"name": "@dvgis/dc-sdk", "name": "@dvgis/dc-sdk",
"version": "3.0.3",
"version": "3.0.0",
"license": "MIT", "license": "MIT",
"description": "The SDK is based on Cesium for secondary development of 2, 3D all-in-one WebGis application framework, the framework optimizes the use of Cesium and add some additional features, designed for developers to quickly build WebGis applications.", "description": "The SDK is based on Cesium for secondary development of 2, 3D all-in-one WebGis application framework, the framework optimizes the use of Cesium and add some additional features, designed for developers to quickly build WebGis applications.",
"repository": "https://github.com/dvgis/dc-sdk.git", "repository": "https://github.com/dvgis/dc-sdk.git",
"@rollup/plugin-commonjs": "^24.1.0", "@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.1", "@rollup/plugin-terser": "^0.4.1",
"@turf/turf": "^6.5.0",
"chalk": "^5.2.0", "chalk": "^5.2.0",
"esbuild": "^0.17.18", "esbuild": "^0.17.18",
"esbuild-plugin-glsl": "^1.2.1", "esbuild-plugin-glsl": "^1.2.1",

+ 1
- 3
server.js View File

if (exists) { if (exists) {
portfinder.getPort((err, port) => { portfinder.getPort((err, port) => {
server.listen(port) server.listen(port)
shell.echo(
chalk.yellow(`the url is : http://localhost:${port}/test.html`)
)
shell.echo(chalk.yellow(`the url is : http://localhost:${port}`))
server.use('/libs/dc-sdk/', express.static(dist)) server.use('/libs/dc-sdk/', express.static(dist))
server.use(express.static('examples')) server.use(express.static('examples'))
}) })

+ 12
- 5
src/modules/exts/BaseLayerPicker.js View File

**/ **/


import { Cesium } from '../../namespace' import { Cesium } from '../../namespace'

const { EllipsoidTerrainProvider } = Cesium
const { EllipsoidTerrainProvider, ImageryLayer } = Cesium


class BaseLayerPicker { class BaseLayerPicker {
constructor(options) { constructor(options) {
let imageryLayers = this._globe.imageryLayers let imageryLayers = this._globe.imageryLayers
if (!this._selectedImageryLayer) { if (!this._selectedImageryLayer) {
for (let i = imageryLayer.layers.length - 1; i >= 0; i--) { for (let i = imageryLayer.layers.length - 1; i >= 0; i--) {
imageryLayers.add(imageryLayer.layers[i], 0)
imageryLayers.add(
new ImageryLayer(imageryLayer.layers[i], imageryLayer.options),
0
)
} }
} else if ( } else if (
this._selectedImageryLayer && this._selectedImageryLayer &&
) { ) {
imageryLayers.removeAll() imageryLayers.removeAll()
for (let i = imageryLayer.layers.length - 1; i >= 0; i--) { for (let i = imageryLayer.layers.length - 1; i >= 0; i--) {
imageryLayers.addImageryProvider(imageryLayer.layers[i], 0)
imageryLayers.add(
new ImageryLayer(imageryLayer.layers[i], imageryLayer.options),
0
)
} }
} }
this._selectedImageryLayer = imageryLayer this._selectedImageryLayer = imageryLayer
/** /**
* *
* @param imageryLayer * @param imageryLayer
* @param options
* @returns {BaseLayerPicker} * @returns {BaseLayerPicker}
*/ */
addImageryLayer(imageryLayer) {
addImageryLayer(imageryLayer, options = {}) {
let imageryLayers = [] let imageryLayers = []
if (Array.isArray(imageryLayer)) { if (Array.isArray(imageryLayer)) {
imageryLayers = imageryLayer.slice(0) imageryLayers = imageryLayer.slice(0)
this._imageryLayers.push({ this._imageryLayers.push({
id: `dc-imagery-${this._count}`, id: `dc-imagery-${this._count}`,
layers: imageryLayers, layers: imageryLayers,
options: options,
}) })
return this return this
} }

+ 3
- 3
src/modules/exts/Viewer.js View File

/** /**
@author : Caven Chen @author : Caven Chen
@date : 2023-05-23
@date : 2023-05-26
*/ */
import { Cesium } from '../../namespace'


import { Cesium } from '../../namespace'
const { const {
BoundingSphere, BoundingSphere,
BoundingSphereState, BoundingSphereState,
) )
} }


cesiumWidget.creditViewport.className = 'dc-viewer-canvas'
cesiumWidget.creditViewport.className = 'viewer-canvas'


let dataSourceCollection = options.dataSources let dataSourceCollection = options.dataSources
let destroyDataSourceCollection = false let destroyDataSourceCollection = false

+ 39
- 26
src/modules/imagery/ImageryLayerFactory.js View File

import ImageryType from './ImageryType' import ImageryType from './ImageryType'
import AmapImageryProvider from './provider/AmapImageryProvider' import AmapImageryProvider from './provider/AmapImageryProvider'
import BaiduImageryProvider from './provider/BaiduImageryProvider' import BaiduImageryProvider from './provider/BaiduImageryProvider'
import GeoVisImageryProvider from './provider/GeoVisImageryProvider.js'
import GoogleImageryProvider from './provider/GoogleImageryProvider' import GoogleImageryProvider from './provider/GoogleImageryProvider'
import TdtImageryProvider from './provider/TdtImageryProvider' import TdtImageryProvider from './provider/TdtImageryProvider'
import TencentImageryProvider from './provider/TencentImageryProvider' import TencentImageryProvider from './provider/TencentImageryProvider'


class ImageryLayerFactory { class ImageryLayerFactory {
/** /**
* Create amap image layer
* Create amap imagery layer
* @param options * @param options
* @returns {AmapImageryProvider} * @returns {AmapImageryProvider}
*/ */
} }


/** /**
* Create baidu image layer
* Create baidu imagery layer
* @param options * @param options
* @returns {BaiduImageryProvider} * @returns {BaiduImageryProvider}
*/ */
} }


/** /**
* Create google image layer
* Create geoVis imagery layer
* @param options
* @returns {GeoVisImageryProvider}
*/
static createGeoVisImageryLayer(options) {
return new GeoVisImageryProvider(options)
}

/**
* Create google imagery layer
* @param options * @param options
* @returns {GoogleImageryProvider} * @returns {GoogleImageryProvider}
*/ */
} }


/** /**
* Create tdt image layer
* Create tdt imagery layer
* @param options * @param options
* @returns {TdtImageryProvider} * @returns {TdtImageryProvider}
*/ */
} }


/** /**
* Create tencent image layer
* Create tencent imagery layer
* @param options * @param options
* @returns {TencentImageryProvider} * @returns {TencentImageryProvider}
*/ */
} }


/** /**
* Create arcgis image layer
* Create arcgis imagery layer
* @param options * @param options
* @returns {module:cesium.ArcGisMapServerImageryProvider}
* @returns {ImageryProvider}
*/ */
static createArcGisImageryLayer(options) { static createArcGisImageryLayer(options) {
return new Cesium.ArcGisMapServerImageryProvider(options) return new Cesium.ArcGisMapServerImageryProvider(options)
} }


/** /**
* Create single tile image layer
* Create single tile imagery layer
* @param options * @param options
* @returns {module:cesium.SingleTileImageryProvider}
* @returns {ImageryProvider}
*/ */
static createSingleTileImageryLayer(options) { static createSingleTileImageryLayer(options) {
return new Cesium.SingleTileImageryProvider(options) return new Cesium.SingleTileImageryProvider(options)
} }


/** /**
* Create WMS image layer
* Create WMS imagery layer
* @param options * @param options
* @returns {module:cesium.WebMapServiceImageryProvider}
* @returns {ImageryProvider}
*/ */
static createWMSImageryLayer(options) { static createWMSImageryLayer(options) {
return new Cesium.WebMapServiceImageryProvider(options) return new Cesium.WebMapServiceImageryProvider(options)
} }


/** /**
* Create WMTS image layer
* Create WMTS imagery layer
* @param options * @param options
* @returns {module:cesium.WebMapTileServiceImageryProvider}
* @returns {ImageryProvider}
*/ */
static createWMTSImageryLayer(options) { static createWMTSImageryLayer(options) {
return new Cesium.WebMapTileServiceImageryProvider(options) return new Cesium.WebMapTileServiceImageryProvider(options)
} }


/** /**
* Create xyz image layer
* Create xyz imagery layer
* @param options * @param options
* @returns {module:cesium.UrlTemplateImageryProvider}
* @returns {ImageryProvider}
*/ */
static createXYZImageryLayer(options) { static createXYZImageryLayer(options) {
return new Cesium.UrlTemplateImageryProvider(options) return new Cesium.UrlTemplateImageryProvider(options)
} }


/** /**
* Create coord image layer
* Create coord imagery layer
* @param options * @param options
* @returns {module:cesium.TileCoordinatesImageryProvider}
* @returns {ImageryProvider}
*/ */
static createCoordImageryLayer(options) { static createCoordImageryLayer(options) {
return new Cesium.TileCoordinatesImageryProvider(options) return new Cesium.TileCoordinatesImageryProvider(options)
} }


/** /**
* Create grid image layer
* Create grid imagery layer
* @param options * @param options
* @returns {module:cesium.GridImageryProvider}
* @returns {ImageryProvider}
*/ */
static createGridImageryLayer(options) { static createGridImageryLayer(options) {
return new Cesium.GridImageryProvider(options) return new Cesium.GridImageryProvider(options)
} }


/** /**
* Create mapbox image layer
* Create mapbox imagery layer
* @param options * @param options
* @returns {module:cesium.MapboxImageryProvider}
* @returns {ImageryProvider}
*/ */
static createMapboxImageryLayer(options) { static createMapboxImageryLayer(options) {
return new Cesium.MapboxImageryProvider(options) return new Cesium.MapboxImageryProvider(options)
} }


/** /**
* Create mapbox style image layer
* Create mapbox style imagery layer
* @param options * @param options
* @returns {module:cesium.MapboxStyleImageryProvider}
* @returns {ImageryProvider}
*/ */
static createMapboxStyleImageryLayer(options) { static createMapboxStyleImageryLayer(options) {
return new Cesium.MapboxStyleImageryProvider(options) return new Cesium.MapboxStyleImageryProvider(options)
} }


/** /**
* Create TMS image layer
* Create TMS imagery layer
* @param options * @param options
* @returns {module:cesium.TileMapServiceImageryProvider}
* @returns {ImageryProvider}
*/ */
static createTMSImageryLayer(options) { static createTMSImageryLayer(options) {
return new Cesium.TileMapServiceImageryProvider(options) return new Cesium.TileMapServiceImageryProvider(options)
} }


/** /**
* Create Imagery Layer
* Create Imagery Layer by Type
* @param type * @param type
* @param options * @param options
* @returns {any} * @returns {any}
case ImageryType.BAIDU: case ImageryType.BAIDU:
imageryLayer = this.createBaiduImageryLayer(options) imageryLayer = this.createBaiduImageryLayer(options)
break break
case ImageryType.GEO_VIS:
imageryLayer = this.createGeoVisImageryLayer(options)
break
case ImageryType.GOOGLE: case ImageryType.GOOGLE:
imageryLayer = this.createGoogleImageryLayer(options) imageryLayer = this.createGoogleImageryLayer(options)
break break

+ 1
- 1
src/modules/imagery/provider/AmapImageryProvider.js View File

* @Date: 2020-01-15 20:31:28 * @Date: 2020-01-15 20:31:28
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'
import ImageryType from '../ImageryType' import ImageryType from '../ImageryType'
import AmapMercatorTilingScheme from '../tiling-scheme/AmapMercatorTilingScheme' import AmapMercatorTilingScheme from '../tiling-scheme/AmapMercatorTilingScheme'



+ 9
- 102
src/modules/imagery/provider/BaiduImageryProvider.js View File

'//its.map.baidu.com:8002/traffic/TrafficTileService?time={time}&label={labelStyle}&v=016&level={z}&x={x}&y={y}&scaler=2', '//its.map.baidu.com:8002/traffic/TrafficTileService?time={time}&label={labelStyle}&v=016&level={z}&x={x}&y={y}&scaler=2',
} }


class BaiduImageryProvider {
class BaiduImageryProvider extends Cesium.UrlTemplateImageryProvider {
constructor(options = {}) { constructor(options = {}) {
this._url =
options['url'] =
options.url || options.url ||
[ [
options.protocol || '', options.protocol || '',
TILE_URL[options.style] || TILE_URL['custom'], TILE_URL[options.style] || TILE_URL['custom'],
].join('') ].join('')
this._labelStyle = options.labelStyle || 'web2D'
this._tileWidth = 256
this._tileHeight = 256
this._maximumLevel = 18
this._crs = options.crs || 'BD09'

if (options.crs === 'WGS84') { if (options.crs === 'WGS84') {
let resolutions = [] let resolutions = []
for (let i = 0; i < 19; i++) { for (let i = 0; i < 19; i++) {
resolutions[i] = 256 * Math.pow(2, 18 - i) resolutions[i] = 256 * Math.pow(2, 18 - i)
} }
this._tilingScheme = new BaiduMercatorTilingScheme({
options['tilingScheme'] = new BaiduMercatorTilingScheme({
resolutions, resolutions,
rectangleSouthwestInMeters: new Cesium.Cartesian2( rectangleSouthwestInMeters: new Cesium.Cartesian2(
-20037726.37, -20037726.37,
), ),
}) })
} else { } else {
this._tilingScheme = new Cesium.WebMercatorTilingScheme({
options['tilingScheme'] = new Cesium.WebMercatorTilingScheme({
rectangleSouthwestInMeters: new Cesium.Cartesian2(-33554054, -33746824), rectangleSouthwestInMeters: new Cesium.Cartesian2(-33554054, -33746824),
rectangleNortheastInMeters: new Cesium.Cartesian2(33554054, 33746824), rectangleNortheastInMeters: new Cesium.Cartesian2(33554054, 33746824),
}) })
} }
options['maximumLevel'] = 18
super(options)
this._rectangle = this._tilingScheme.rectangle this._rectangle = this._tilingScheme.rectangle
this._credit = undefined
this._token = undefined
this._url = options.url
this._crs = options.crs || 'BD09'
this._style = options.style || 'normal' this._style = options.style || 'normal'
this._errorEvent = new Cesium.Event()
}

get url() {
return this._url
}

get token() {
return this._token
} }


get tileWidth() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'tileWidth must not be called before the imagery provider is ready.'
)
}
return this._tileWidth
}

get tileHeight() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'tileHeight must not be called before the imagery provider is ready.'
)
}
return this._tileHeight
}

get maximumLevel() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'maximumLevel must not be called before the imagery provider is ready.'
)
}
return this._maximumLevel
}

get minimumLevel() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'minimumLevel must not be called before the imagery provider is ready.'
)
}
return 0
}

get tilingScheme() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'tilingScheme must not be called before the imagery provider is ready.'
)
}
return this._tilingScheme
}

get rectangle() {
if (!this.ready) {
throw new Cesium.DeveloperError(
'rectangle must not be called before the imagery provider is ready.'
)
}
return this._rectangle
}

get ready() {
return !!this._url
}

get credit() {
return this._credit
}

get hasAlphaChannel() {
return true
}

get errorEvent() {
return this._errorEvent
}

getTileCredits(x, y, level) {}

/**
* Request Image
* @param x
* @param y
* @param level
* @returns {Promise<HTMLImageElement | HTMLCanvasElement>}
*/
requestImage(x, y, level) { requestImage(x, y, level) {
if (!this.ready) { if (!this.ready) {
throw new Cesium.DeveloperError( throw new Cesium.DeveloperError(
.replace('{z}', level) .replace('{z}', level)
.replace('{s}', String(1)) .replace('{s}', String(1))
.replace('{style}', this._style) .replace('{style}', this._style)
.replace('{labelStyle}', this._labelStyle)
.replace('{time}', String(new Date().getTime()))

if (this._crs === 'WGS84') { if (this._crs === 'WGS84') {
url = url.replace('{x}', String(x)).replace('{y}', String(-y)) url = url.replace('{x}', String(x)).replace('{y}', String(-y))
} else { } else {

+ 29
- 0
src/modules/imagery/provider/GeoVisImageryProvider.js View File

/**
@author : Caven Chen
@date : 2023-05-18
*/

import { Cesium } from '../../../namespace'
import ImageryType from '../ImageryType'

const TILE_URL =
'//tiles{s}.geovisearth.com/base/v1/{style}/{z}/{x}/{y}?format={format}&tmsIds=w&token={key}'

class GeoVisImageryProvider extends Cesium.UrlTemplateImageryProvider {
constructor(options = {}) {
options['url'] =
options.url ||
[
options.protocol || '',
TILE_URL.replace(/\{style\}/g, options.style || 'vec')
.replace(/\{format\}/g, options.format || 'png')
.replace(/\{key\}/g, options.key || ''),
].join('')
options['subdomains'] = options.subdomains || ['1', '2', '3']
super(options)
}
}

ImageryType.GEO_VIS = 'geoVis'

export default GeoVisImageryProvider

+ 5
- 1
src/modules/index.js View File

@date : 2023-05-08 @date : 2023-05-08
*/ */


export { default as Viewer } from './viewer/Viewer.js'
export { default as Viewer } from './viewer/Viewer'

export { ImageryType, ImageryLayerFactory } from './imagery'

export { default as Position } from './position/Position'

+ 1
- 1
src/modules/material/property/polyline/PolylineLightingMaterialProperty.js View File



Object.defineProperties(PolylineLightingMaterialProperty.prototype, { Object.defineProperties(PolylineLightingMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
image: Cesium.createPropertyDescriptor('image')
image: Cesium.createPropertyDescriptor('image'),
}) })


export default PolylineLightingMaterialProperty export default PolylineLightingMaterialProperty

+ 1
- 1
src/modules/material/property/polyline/PolylineLightingTrailMaterialProperty.js View File

Object.defineProperties(PolylineLightingTrailMaterialProperty.prototype, { Object.defineProperties(PolylineLightingTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'), speed: Cesium.createPropertyDescriptor('speed'),
image: Cesium.createPropertyDescriptor('image')
image: Cesium.createPropertyDescriptor('image'),
}) })


export default PolylineLightingTrailMaterialProperty export default PolylineLightingTrailMaterialProperty

+ 1
- 1
src/modules/material/property/polyline/PolylineTrailMaterialProperty.js View File



Object.defineProperties(PolylineTrailMaterialProperty.prototype, { Object.defineProperties(PolylineTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
speed: Cesium.createPropertyDescriptor('speed'),
}) })


export default PolylineTrailMaterialProperty export default PolylineTrailMaterialProperty

+ 1
- 1
src/modules/material/property/radar/RadarLineMaterialProperty.js View File



Object.defineProperties(RadarLineMaterialProperty.prototype, { Object.defineProperties(RadarLineMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
speed: Cesium.createPropertyDescriptor('speed'),
}) })


export default RadarLineMaterialProperty export default RadarLineMaterialProperty

+ 1
- 1
src/modules/material/property/radar/RadarSweepMaterialProperty.js View File



Object.defineProperties(RadarSweepMaterialProperty.prototype, { Object.defineProperties(RadarSweepMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
speed: Cesium.createPropertyDescriptor('speed'),
}) })


export default RadarSweepMaterialProperty export default RadarSweepMaterialProperty

+ 1
- 1
src/modules/material/property/radar/RadarWaveMaterialProperty.js View File



Object.defineProperties(RadarWaveMaterialProperty.prototype, { Object.defineProperties(RadarWaveMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
speed: Cesium.createPropertyDescriptor('speed'),
}) })


export default RadarWaveMaterialProperty export default RadarWaveMaterialProperty

+ 1
- 1
src/modules/material/property/wall/WallImageTrailMaterialProperty.js View File

image: Cesium.createPropertyDescriptor('image'), image: Cesium.createPropertyDescriptor('image'),
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'), speed: Cesium.createPropertyDescriptor('speed'),
repeat: Cesium.createPropertyDescriptor('repeat')
repeat: Cesium.createPropertyDescriptor('repeat'),
}) })


export default WallImageTrailMaterialProperty export default WallImageTrailMaterialProperty

+ 1
- 1
src/modules/material/property/wall/WallLineTrailMaterialProperty.js View File

color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
image: Cesium.createPropertyDescriptor('image'), image: Cesium.createPropertyDescriptor('image'),
repeat: Cesium.createPropertyDescriptor('repeat'), repeat: Cesium.createPropertyDescriptor('repeat'),
speed: Cesium.createPropertyDescriptor('speed')
speed: Cesium.createPropertyDescriptor('speed'),
}) })


export default WallLineTrailMaterialProperty export default WallLineTrailMaterialProperty

+ 1
- 1
src/modules/material/property/wall/WallTrailMaterialProperty.js View File

Object.defineProperties(WallTrailMaterialProperty.prototype, { Object.defineProperties(WallTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'), color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'), speed: Cesium.createPropertyDescriptor('speed'),
image: Cesium.createPropertyDescriptor('image')
image: Cesium.createPropertyDescriptor('image'),
}) })


export default WallTrailMaterialProperty export default WallTrailMaterialProperty

+ 1
- 1
src/modules/material/property/water/WaterMaterialProperty.js View File

baseWaterColor: Cesium.createPropertyDescriptor('baseWaterColor'), baseWaterColor: Cesium.createPropertyDescriptor('baseWaterColor'),
blendColor: Cesium.createPropertyDescriptor('blendColor'), blendColor: Cesium.createPropertyDescriptor('blendColor'),
specularMap: Cesium.createPropertyDescriptor('specularMap'), specularMap: Cesium.createPropertyDescriptor('specularMap'),
normalMap: Cesium.createPropertyDescriptor('normalMap')
normalMap: Cesium.createPropertyDescriptor('normalMap'),
}) })


export default WaterMaterialProperty export default WaterMaterialProperty

+ 24
- 24
src/modules/material/type/polyline.js View File

type: Cesium.Material.PolylineFlickerType, type: Cesium.Material.PolylineFlickerType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
speed: 1,
}, },
source: LineFlickerMaterial
source: LineFlickerMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )


color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1, speed: 1,
percent: 0.03, percent: 0.03,
gradient: 0.1
gradient: 0.1,
}, },
source: LineFlowMaterial
source: LineFlowMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
speed: 1, speed: 1,
repeat: new Cesium.Cartesian2(1, 1)
repeat: new Cesium.Cartesian2(1, 1),
}, },
source: LineImageTrailMaterial
source: LineImageTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )


type: Cesium.Material.PolylineLightingType, type: Cesium.Material.PolylineLightingType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId
image: Cesium.Material.DefaultImageId,
}, },
source: LineLightingMaterial
source: LineLightingMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )


uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
speed: 3.0
speed: 3.0,
}, },
source: LineLightingTrailMaterial
source: LineLightingTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )


color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
speed: 1, speed: 1,
repeat: new Cesium.Cartesian2(1, 1)
repeat: new Cesium.Cartesian2(1, 1),
}, },
source: LineTrailMaterial
source: LineTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })

+ 12
- 12
src/modules/material/type/radar.js View File

type: Cesium.Material.RadarLineType, type: Cesium.Material.RadarLineType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: RadarLineMaterial
source: RadarLineMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.RadarSweepType, type: Cesium.Material.RadarSweepType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: RadarSweepMaterial
source: RadarSweepMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.RadarWaveType, type: Cesium.Material.RadarWaveType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: RadarWaveMaterial
source: RadarWaveMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })

+ 47
- 47
src/modules/material/type/thirdpart.js View File

uniforms: { uniforms: {
asphaltColor: new Cesium.Color(0.15, 0.15, 0.15, 1.0), asphaltColor: new Cesium.Color(0.15, 0.15, 0.15, 1.0),
bumpSize: 0.02, bumpSize: 0.02,
roughness: 0.2
roughness: 0.2,
}, },
source: AsphaltMaterial
source: AsphaltMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return material.uniforms.asphaltColor.alpha < 1.0 return material.uniforms.asphaltColor.alpha < 1.0
}
},
}) })


/** /**
uniforms: { uniforms: {
lightColor: new Cesium.Color(1.0, 1.0, 1.0, 0.5), lightColor: new Cesium.Color(1.0, 1.0, 1.0, 0.5),
darkColor: new Cesium.Color(0.0, 0.0, 1.0, 0.5), darkColor: new Cesium.Color(0.0, 0.0, 1.0, 0.5),
frequency: 10.0
frequency: 10.0,
}, },
source: BlobMaterial
source: BlobMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
var uniforms = material.uniforms var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0 return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
},
}) })


/** /**
brickSize: new Cesium.Cartesian2(0.3, 0.15), brickSize: new Cesium.Cartesian2(0.3, 0.15),
brickPct: new Cesium.Cartesian2(0.9, 0.85), brickPct: new Cesium.Cartesian2(0.9, 0.85),
brickRoughness: 0.2, brickRoughness: 0.2,
mortarRoughness: 0.1
mortarRoughness: 0.1,
}, },
source: BrickMaterial
source: BrickMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
var uniforms = material.uniforms var uniforms = material.uniforms
return uniforms.brickColor.alpha < 1.0 || uniforms.mortarColor.alpha < 1.0 return uniforms.brickColor.alpha < 1.0 || uniforms.mortarColor.alpha < 1.0
}
},
}) })


/** /**
uniforms: { uniforms: {
cementColor: new Cesium.Color(0.95, 0.95, 0.85, 1.0), cementColor: new Cesium.Color(0.95, 0.95, 0.85, 1.0),
grainScale: 0.01, grainScale: 0.01,
roughness: 0.3
roughness: 0.3,
}, },
source: CementMaterial
source: CementMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return material.uniforms.cementColor.alpha < 1.0 return material.uniforms.cementColor.alpha < 1.0
}
},
}) })


/** /**
type: Cesium.Material.ErosionType, type: Cesium.Material.ErosionType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.5), color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
time: 1.0
time: 1.0,
}, },
source: ErosionMaterial
source: ErosionMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return material.uniforms.color.alpha < 1.0 return material.uniforms.color.alpha < 1.0
}
},
}) })


/** /**
uniforms: { uniforms: {
lightColor: new Cesium.Color(0.25, 0.25, 0.25, 0.75), lightColor: new Cesium.Color(0.25, 0.25, 0.25, 0.75),
darkColor: new Cesium.Color(0.75, 0.75, 0.75, 0.75), darkColor: new Cesium.Color(0.75, 0.75, 0.75, 0.75),
frequency: 10.0
frequency: 10.0,
}, },
source: FacetMaterial
source: FacetMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
var uniforms = material.uniforms var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0 return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
},
}) })


/** /**
type: Cesium.Material.FresnelType, type: Cesium.Material.FresnelType,
materials: { materials: {
reflection: { reflection: {
type: Cesium.Material.ReflectionType
type: Cesium.Material.ReflectionType,
}, },
refraction: { refraction: {
type: Cesium.Material.RefractionType
}
type: Cesium.Material.RefractionType,
},
}, },
source: FresnelMaterial
source: FresnelMaterial,
}, },
translucent: false
translucent: false,
}) })


/** /**
uniforms: { uniforms: {
grassColor: new Cesium.Color(0.25, 0.4, 0.1, 1.0), grassColor: new Cesium.Color(0.25, 0.4, 0.1, 1.0),
dirtColor: new Cesium.Color(0.1, 0.1, 0.1, 1.0), dirtColor: new Cesium.Color(0.1, 0.1, 0.1, 1.0),
patchiness: 1.5
patchiness: 1.5,
}, },
source: GrassMaterial
source: GrassMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
var uniforms = material.uniforms var uniforms = material.uniforms
return uniforms.grassColor.alpha < 1.0 || uniforms.dirtColor.alpha < 1.0 return uniforms.grassColor.alpha < 1.0 || uniforms.dirtColor.alpha < 1.0
}
},
}) })


/** /**
type: Cesium.Material.ReflectionType, type: Cesium.Material.ReflectionType,
uniforms: { uniforms: {
cubeMap: Cesium.Material.DefaultCubeMapId, cubeMap: Cesium.Material.DefaultCubeMapId,
channels: 'rgb'
channels: 'rgb',
}, },
source: ReflectionMaterial
source: ReflectionMaterial,
}, },
translucent: false
translucent: false,
}) })


/** /**
uniforms: { uniforms: {
cubeMap: Cesium.Material.DefaultCubeMapId, cubeMap: Cesium.Material.DefaultCubeMapId,
channels: 'rgb', channels: 'rgb',
indexOfRefractionRatio: 0.9
indexOfRefractionRatio: 0.9,
}, },
source: RefractionMaterial
source: RefractionMaterial,
}, },
translucent: false
translucent: false,
}) })


/** /**
uniforms: { uniforms: {
lightColor: new Cesium.Color(1.0, 1.0, 0.0, 0.75), lightColor: new Cesium.Color(1.0, 1.0, 0.0, 0.75),
darkColor: new Cesium.Color(1.0, 0.0, 0.0, 0.75), darkColor: new Cesium.Color(1.0, 0.0, 0.0, 0.75),
frequency: 5.0
frequency: 5.0,
}, },
source: TieDyeMaterial
source: TieDyeMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
var uniforms = material.uniforms var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0 return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
},
}) })


/** /**
darkWoodColor: new Cesium.Color(0.4, 0.2, 0.07, 1.0), darkWoodColor: new Cesium.Color(0.4, 0.2, 0.07, 1.0),
ringFrequency: 3.0, ringFrequency: 3.0,
noiseScale: new Cesium.Cartesian2(0.7, 0.5), noiseScale: new Cesium.Cartesian2(0.7, 0.5),
grainFrequency: 27.0
grainFrequency: 27.0,
}, },
source: WoodMaterial
source: WoodMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
let uniforms = material.uniforms let uniforms = material.uniforms
return ( return (
uniforms.lightWoodColor.alpha < 1.0 || uniforms.darkWoodColor.alpha < 1.0 uniforms.lightWoodColor.alpha < 1.0 || uniforms.darkWoodColor.alpha < 1.0
) )
}
},
}) })

+ 16
- 16
src/modules/material/type/wall.js View File

fabric: { fabric: {
type: Cesium.Material.WallDiffuseType, type: Cesium.Material.WallDiffuseType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7)
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
}, },
source: WallDiffuseMaterial
source: WallDiffuseMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0, speed: 3.0,
repeat: new Cesium.Cartesian2(1, 1)
repeat: new Cesium.Cartesian2(1, 1),
}, },
source: WallImageTrailMaterial
source: WallImageTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
repeat: new Cesium.Cartesian2(1, 1), repeat: new Cesium.Cartesian2(1, 1),
speed: 3.0
speed: 3.0,
}, },
source: WallLineTrailMaterial
source: WallLineTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId, image: Cesium.Material.DefaultImageId,
speed: 1
speed: 1,
}, },
source: WallTrailMaterial
source: WallTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })

+ 3
- 3
src/modules/math/curve.js View File

} }
let curveCoordinates = [] let curveCoordinates = []
count = count || 40 // 曲线是由一些小的线段组成的,这个表示这个曲线所有到的折线的个数 count = count || 40 // 曲线是由一些小的线段组成的,这个表示这个曲线所有到的折线的个数
let B1 = function(x) {
let B1 = function (x) {
return 1 - 2 * x + x * x return 1 - 2 * x + x * x
} }
let B2 = x => {
let B2 = (x) => {
return 2 * x - 2 * x * x return 2 * x - 2 * x * x
} }
let B3 = x => {
let B3 = (x) => {
return x * x return x * x
} }



+ 1
- 1
src/modules/measure/Measure.js View File

this._viewer.dataSources.add(this._layer) this._viewer.dataSources.add(this._layer)
Object.defineProperty(viewer, 'measure', { Object.defineProperty(viewer, 'measure', {
value: this, value: this,
writable: false
writable: false,
}) })
} }



+ 6
- 6
src/modules/measure/MeasureBase.js View File

font: '12px', font: '12px',
pixelOffset: { x: 0, y: -15 }, pixelOffset: { x: 0, y: -15 },
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true
}
showBackground: true,
},
}) })
this._resultLabel = new Cesium.Entity({ this._resultLabel = new Cesium.Entity({
label: { label: {
font: '12px', font: '12px',
pixelOffset: { x: 0, y: -15 }, pixelOffset: { x: 0, y: -15 },
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true
}
showBackground: true,
},
}) })
this._options = {} this._options = {}
} }
!(this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider) !(this._viewer.terrainProvider instanceof Cesium.EllipsoidTerrainProvider)
? Cesium.sampleTerrainMostDetailed( ? Cesium.sampleTerrainMostDetailed(
this._viewer.terrainProvider, this._viewer.terrainProvider,
positions.map(item => Cesium.Cartographic.fromCartesian(item))
positions.map((item) => Cesium.Cartographic.fromCartesian(item))
) )
: Promise.resolve( : Promise.resolve(
positions.map(item => Cesium.Cartographic.fromCartesian(item))
positions.map((item) => Cesium.Cartographic.fromCartesian(item))
) )


let modelPromise = let modelPromise =

+ 1
- 1
src/modules/measure/MeasureType.js View File

DISTANCE_SURFACE: 'diatance_surface', DISTANCE_SURFACE: 'diatance_surface',
HEADING: 'heading', HEADING: 'heading',
HEIGHT: 'height', HEIGHT: 'height',
TRIANGLE_HEIGHT: 'triangle_height'
TRIANGLE_HEIGHT: 'triangle_height',
} }


export default MeasureType export default MeasureType

+ 5
- 5
src/modules/measure/edit/EditPolygon.js View File

*/ */
_mountedHook() { _mountedHook() {
this.editTool.tooltipMess = '点击锚点移动,右击结束编辑' this.editTool.tooltipMess = '点击锚点移动,右击结束编辑'
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty(time => {
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty((time) => {
if (this._positions.length > 2) { if (this._positions.length > 2) {
return new Cesium.PolygonHierarchy(this._positions) return new Cesium.PolygonHierarchy(this._positions)
} else { } else {
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
this._layer.entities.remove(this._overlay) this._layer.entities.remove(this._overlay)
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this._positions[nextMidAnchorIndex] = nextMidPosition this._positions[nextMidAnchorIndex] = nextMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: preMidAnchorIndex, index: preMidAnchorIndex,
position: preMidPosition
position: preMidPosition,
}) })
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: nextMidAnchorIndex, index: nextMidAnchorIndex,
position: nextMidPosition
position: nextMidPosition,
}) })
} }
this._options.onCalc && this._options.onCalc(this._positions) this._options.onCalc && this._options.onCalc(this._positions)

+ 5
- 5
src/modules/measure/edit/EditPolyline.js View File

this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} else { } else {
this._positions.forEach((item, index) => { this._positions.forEach((item, index) => {
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index
index: index,
}) })
}) })
} }
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this._positions[preMidAnchorIndex] = preMidPosition this._positions[preMidAnchorIndex] = preMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: preMidAnchorIndex, index: preMidAnchorIndex,
position: preMidPosition
position: preMidPosition,
}) })
} }


this._positions[nextMidAnchorIndex] = nextMidPosition this._positions[nextMidAnchorIndex] = nextMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: nextMidAnchorIndex, index: nextMidAnchorIndex,
position: nextMidPosition
position: nextMidPosition,
}) })
} }
} }

+ 4
- 5
src/modules/measure/type/Area.js View File

new EditPolygon(entity).start( new EditPolygon(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
this._options this._options
) )
*/ */
_onCalc(positions) { _onCalc(positions) {
if (positions.length > 2) { if (positions.length > 2) {
this._resultLabel.position = Cesium.BoundingSphere.fromPoints(
positions
)?.center
this._resultLabel.position =
Cesium.BoundingSphere.fromPoints(positions)?.center
this._resultLabel.label.text = `面积:${area(positions).toFixed( this._resultLabel.label.text = `面积:${area(positions).toFixed(
2 2
)} 平方米` )} 平方米`
this._startHook(measure, options) this._startHook(measure, options)
new DrawPolygon({ new DrawPolygon({
material: options.material || Cesium.Color.YELLOW.withAlpha(0.6), material: options.material || Cesium.Color.YELLOW.withAlpha(0.6),
perPositionHeight: true
perPositionHeight: true,
}).start(measure, this._options) }).start(measure, this._options)
return this return this
} }

+ 5
- 5
src/modules/measure/type/AreaHeight.js View File

new EditPolygon(entity).start( new EditPolygon(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
this._options this._options
) )
? Cesium.Cartographic.fromCartesian(updatedCartesians[index]) ? Cesium.Cartographic.fromCartesian(updatedCartesians[index])
.height .height
: 0 : 0
)
),
} }
}) })
}) })
.then(positions => {
.then((positions) => {
let max = 0 let max = 0
let position = undefined let position = undefined
positions.forEach(item => {
positions.forEach((item) => {
if (item.alt > max) { if (item.alt > max) {
max = item.alt max = item.alt
position = item position = item
start(measure, options) { start(measure, options) {
this._startHook(measure, options) this._startHook(measure, options)
new DrawPolygon({ new DrawPolygon({
material: options.material || Cesium.Color.YELLOW.withAlpha(0.6)
material: options.material || Cesium.Color.YELLOW.withAlpha(0.6),
}).start(measure, this._options) }).start(measure, this._options)
return this return this
} }

+ 6
- 7
src/modules/measure/type/AreaSurface.js View File

new EditPolygon(entity).start( new EditPolygon(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
this._options this._options
) )
*/ */
_onCalc(positions) { _onCalc(positions) {
if (positions.length > 2) { if (positions.length > 2) {
this._resultLabel.position = Cesium.BoundingSphere.fromPoints(
positions
)?.center
this._resultLabel.position =
Cesium.BoundingSphere.fromPoints(positions)?.center


let lerpPositions = this._lerp( let lerpPositions = this._lerp(
Cesium.Rectangle.fromCartesianArray(positions), Cesium.Rectangle.fromCartesianArray(positions),


this._getSampledHeight(lerpPositions.concat(positions), false) this._getSampledHeight(lerpPositions.concat(positions), false)
.then(([updatedCartographics]) => { .then(([updatedCartographics]) => {
return updatedCartographics.map(item =>
return updatedCartographics.map((item) =>
Cesium.Cartesian3.fromDegrees( Cesium.Cartesian3.fromDegrees(
Cesium.Math.toDegrees(item.longitude), Cesium.Math.toDegrees(item.longitude),
Cesium.Math.toDegrees(item.latitude), Cesium.Math.toDegrees(item.latitude),
) )
) )
}) })
.then(positions => {
.then((positions) => {
this._resultLabel.label.text = `面积:${area(positions).toFixed( this._resultLabel.label.text = `面积:${area(positions).toFixed(
2 2
)} 平方米` )} 平方米`
start(measure, options) { start(measure, options) {
this._startHook(measure, options) this._startHook(measure, options)
new DrawPolygon({ new DrawPolygon({
material: options.material || Cesium.Color.YELLOW.withAlpha(0.6)
material: options.material || Cesium.Color.YELLOW.withAlpha(0.6),
}).start(measure, this._options) }).start(measure, this._options)
return this return this
} }

+ 5
- 5
src/modules/measure/type/Distance.js View File

new EditPolyline(entity).start( new EditPolyline(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2, width: options.width || 2,
clampToGround: false
clampToGround: false,
}).start(measure, { }).start(measure, {
...options, ...options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 6
- 6
src/modules/measure/type/DistanceSurface.js View File

new EditPolyline(entity).start( new EditPolyline(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
) )
) )
}) })
.then(positions => {
.then((positions) => {
let sum = 0 let sum = 0
for (let i = 0; i < positions.length - 1; i++) { for (let i = 0; i < positions.length - 1; i++) {
let s = Cesium.Cartesian3.distance(positions[i], positions[i + 1]) let s = Cesium.Cartesian3.distance(positions[i], positions[i + 1])
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2, width: options.width || 2,
clampToGround: true
clampToGround: true,
}).start(measure, { }).start(measure, {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 5
- 5
src/modules/measure/type/Heading.js View File

new EditPolyline(entity).start( new EditPolyline(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2
width: options.width || 2,
}).start(measure, { }).start(measure, {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 9
- 9
src/modules/measure/type/Height.js View File

} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
} }


new EditPolyline(entity).start( new EditPolyline(entity).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
positions[1], positions[1],
new Cesium.Cartesian3() new Cesium.Cartesian3()
), ),
positions[1]
positions[1],
] ]


let hegiht = Math.abs(Cesium.Plane.getPointDistance(plane, positions[1])) let hegiht = Math.abs(Cesium.Plane.getPointDistance(plane, positions[1]))
start(measure, options) { start(measure, options) {
this._startHook(measure, options) this._startHook(measure, options)
let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({ let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.GREENYELLOW
color: Cesium.Color.GREENYELLOW,
}) })
this._helpLine.polyline.material = helpLineMaterial this._helpLine.polyline.material = helpLineMaterial
this._helpLine.polyline.depthFailMaterial = helpLineMaterial this._helpLine.polyline.depthFailMaterial = helpLineMaterial
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2
width: options.width || 2,
}).start(measure, { }).start(measure, {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 14
- 14
src/modules/measure/type/TriangleHeight.js View File

} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._lengthLabel = new Cesium.Entity({ this._lengthLabel = new Cesium.Entity({
label: { label: {
font: '12px', font: '12px',
pixelOffset: { x: 0, y: -15 }, pixelOffset: { x: 0, y: -15 },
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true
}
showBackground: true,
},
}) })
this._heightLabel = new Cesium.Entity({ this._heightLabel = new Cesium.Entity({
label: { label: {
font: '12px', font: '12px',
pixelOffset: { x: 0, y: -15 }, pixelOffset: { x: 0, y: -15 },
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true
}
showBackground: true,
},
}) })
this._distanceLabel = new Cesium.Entity({ this._distanceLabel = new Cesium.Entity({
label: { label: {
font: '12px', font: '12px',
pixelOffset: { x: 0, y: -15 }, pixelOffset: { x: 0, y: -15 },
disableDepthTestDistance: Number.POSITIVE_INFINITY, disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true
}
showBackground: true,
},
}) })
} }


new EditPolyline(delegate).start( new EditPolyline(delegate).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
start(measure, options) { start(measure, options) {
this._startHook(measure, options) this._startHook(measure, options)
let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({ let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.GREENYELLOW
color: Cesium.Color.GREENYELLOW,
}) })
this._helpLine.polyline.material = helpLineMaterial this._helpLine.polyline.material = helpLineMaterial
this._helpLine.polyline.depthFailMaterial = helpLineMaterial this._helpLine.polyline.depthFailMaterial = helpLineMaterial
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2, width: options.width || 2,
clampToGround: false
clampToGround: false,
}).start(measure, { }).start(measure, {
...options, ...options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 27
- 13
src/modules/viewer/Viewer.js View File

this._viewerOption = new ViewerOption(this) // Initialize the viewer option this._viewerOption = new ViewerOption(this) // Initialize the viewer option
this._cameraOption = new CameraOption(this) // Initialize the camera option this._cameraOption = new CameraOption(this) // Initialize the camera option


this._dcContainer = DomUtil.create(
this._widgetContainer = DomUtil.create(
'div', 'div',
'dc-container',
'viewer-widgets',
typeof id === 'string' ? document.getElementById(id) : id typeof id === 'string' ? document.getElementById(id) : id
) //Register the custom container
) //Register the widgets container

this._layerContainer = DomUtil.create(
'div',
'viewer-layers',
typeof id === 'string' ? document.getElementById(id) : id
) //Register the layers container


this._baseLayerPicker = new BaseLayerPicker({ this._baseLayerPicker = new BaseLayerPicker({
globe: this._delegate.scene.globe, globe: this._delegate.scene.globe,
return this._delegate return this._delegate
} }


get dcContainer() {
return this._dcContainer
get container() {
return this._delegate.container
}

get widgetContainer() {
return this._widgetContainer
}

get layerContainer() {
return this._layerContainer
} }


get scene() { get scene() {
* Adds the baseLayer . * Adds the baseLayer .
* The baseLayer can be a single or an array, * The baseLayer can be a single or an array,
* and when the baseLayer is an array, the baseLayer will be loaded together * and when the baseLayer is an array, the baseLayer will be loaded together
* @param baseLayers
* @param baseLayer
* @param options * @param options
* @returns {Viewer} * @returns {Viewer}
*/ */
addBaseLayer(baseLayers, options = {}) {
if (!baseLayers) {
addBaseLayer(baseLayer, options = {}) {
if (!baseLayer) {
return this return this
} }
this._baseLayerPicker.addImageryProvider(baseLayers)
if (!this._baseLayerPicker.selectedImagery) {
this._baseLayerPicker.changeImagery(0)
this._baseLayerPicker.addImageryLayer(baseLayer)
if (!this._baseLayerPicker.selectedImageryLayer) {
this._baseLayerPicker.changeImageryLayer(0)
} }
this.mapSwitch && this.mapSwitch.addMap(options)
this['mapSwitch'] && this['mapSwitch'].addMap(options)
return this return this
} }


* @returns {Viewer} * @returns {Viewer}
*/ */
changeBaseLayer(index) { changeBaseLayer(index) {
this._baseLayerPicker.changeImagery(index)
this._baseLayerPicker.changeImageryLayer(index)
return this return this
} }



+ 2
- 2
src/modules/widget/Widget.js View File

!this._ready && this._mountContent() !this._ready && this._mountContent()
if (this._enable) { if (this._enable) {
!this._wrapper.parentNode && !this._wrapper.parentNode &&
this._viewer.dcContainer.appendChild(this._wrapper)
this._viewer.widgetContainer.appendChild(this._wrapper)
this._bindEvent() this._bindEvent()
} else { } else {
this._unbindEvent() this._unbindEvent()
this._wrapper.parentNode && this._wrapper.parentNode &&
this._viewer.dcContainer.removeChild(this._wrapper)
this._viewer.widgetContainer.removeChild(this._wrapper)
} }
} }



+ 1
- 1
src/modules/widget/index.js View File

zoomController: new ZoomController(), zoomController: new ZoomController(),
loadingMask: new LoadingMask(), loadingMask: new LoadingMask(),
tilesetSplit: new TilesetSplit(), tilesetSplit: new TilesetSplit(),
sceneSplit: new SceneSplit()
sceneSplit: new SceneSplit(),
} }
} }

+ 1
- 1
src/modules/widget/type/Compass.js View File

class Compass extends Widget { class Compass extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', `dc-compass`)
this._wrapper = DomUtil.create('div', `widget compass`)
this._compassRectangle = undefined this._compassRectangle = undefined
this._outRing = undefined this._outRing = undefined
this._gyro = undefined this._gyro = undefined

+ 1
- 1
src/modules/widget/type/ContextMenu.js View File

class ContextMenu extends Widget { class ContextMenu extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-context-menu')
this._wrapper = DomUtil.create('div', 'widget context-menu')
this._ulEl = undefined this._ulEl = undefined
this._handler = undefined this._handler = undefined
this._overlay = undefined this._overlay = undefined

+ 1
- 1
src/modules/widget/type/DistanceLegend.js View File

class DistanceLegend extends Widget { class DistanceLegend extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-distance-legend')
this._wrapper = DomUtil.create('div', 'widget distance-legend')
this._labelEl = undefined this._labelEl = undefined
this._scaleBarEl = undefined this._scaleBarEl = undefined
this._lastUpdate = Cesium.getTimestamp() this._lastUpdate = Cesium.getTimestamp()

+ 1
- 1
src/modules/widget/type/HawkeyeMap.js View File

class HawkeyeMap extends Widget { class HawkeyeMap extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-hawkeye-map', null)
this._wrapper = DomUtil.create('div', 'widget hawkeye-map', null)
this._wrapper.setAttribute('id', Util.uuid()) this._wrapper.setAttribute('id', Util.uuid())
this._baseLayers = [] this._baseLayers = []
this._map = undefined this._map = undefined

+ 1
- 1
src/modules/widget/type/LoadingMask.js View File

class LoadingMask extends Widget { class LoadingMask extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-loading-mask')
this._wrapper = DomUtil.create('div', 'widget loading-mask')
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }



+ 1
- 1
src/modules/widget/type/LocationBar.js View File

class LocationBar extends Widget { class LocationBar extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-location-bar')
this._wrapper = DomUtil.create('div', 'widget location-bar')
this._mouseEl = undefined this._mouseEl = undefined
this._cameraEl = undefined this._cameraEl = undefined
this._fpsEl = undefined this._fpsEl = undefined

+ 1
- 1
src/modules/widget/type/MapSplit.js View File

class MapSplit extends Widget { class MapSplit extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-slider')
this._wrapper = DomUtil.create('div', 'widget slider')
this._baseLayer = undefined this._baseLayer = undefined
this._moveActive = false this._moveActive = false
this._state = State.INITIALIZED this._state = State.INITIALIZED

+ 2
- 2
src/modules/widget/type/MapSwitch.js View File

class MapSwitch extends Widget { class MapSwitch extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-map-switch')
this._wrapper = DomUtil.create('div', 'widget map-switch')
this._config = undefined this._config = undefined
this._cache = [] this._cache = []
this._state = State.INITIALIZED this._state = State.INITIALIZED
_enableHook() { _enableHook() {
!this._wrapper.parentNode && !this._wrapper.parentNode &&
this._viewer && this._viewer &&
this._viewer.dcContainer.appendChild(this._wrapper)
this._viewer.widgetContainer.appendChild(this._wrapper)
} }


/** /**

+ 1
- 1
src/modules/widget/type/Popup.js View File

class Popup extends Widget { class Popup extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-popup')
this._wrapper = DomUtil.create('div', 'widget popup')
this._config = { customClass: '' } this._config = { customClass: '' }
this._position = undefined this._position = undefined
this._state = State.INITIALIZED this._state = State.INITIALIZED

+ 1
- 1
src/modules/widget/type/SceneSplit.js View File

class SceneSplit extends Widget { class SceneSplit extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-slider')
this._wrapper = DomUtil.create('div', 'widget slider')
this._tileset = undefined this._tileset = undefined
this._baseLayer = undefined this._baseLayer = undefined
this._moveActive = false this._moveActive = false

+ 1
- 1
src/modules/widget/type/TilesetSplit.js View File

class TilesetSplit extends Widget { class TilesetSplit extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-slider')
this._wrapper = DomUtil.create('div', 'widget slider')
this._tileset = undefined this._tileset = undefined
this._moveActive = false this._moveActive = false
this._state = State.INITIALIZED this._state = State.INITIALIZED

+ 1
- 1
src/modules/widget/type/Tooltip.js View File

class Tooltip extends Widget { class Tooltip extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-tool-tip')
this._wrapper = DomUtil.create('div', 'widget tool-tip')
this._ready = true this._ready = true
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }

+ 1
- 1
src/modules/widget/type/ZoomController.js View File

class ZoomController extends Widget { class ZoomController extends Widget {
constructor() { constructor() {
super() super()
this._wrapper = DomUtil.create('div', 'dc-zoom-controller')
this._wrapper = DomUtil.create('div', 'widget zoom-controller')
this._zoomInEl = undefined this._zoomInEl = undefined
this._zoomOutEl = undefined this._zoomOutEl = undefined
this._refreshEl = undefined this._refreshEl = undefined

+ 1
- 1
src/modules/wind/WindCanvas.js View File

particles.push( particles.push(
this.field.randomize( this.field.randomize(
{ {
age: Math.floor(Math.random() * this.options.maxAge)
age: Math.floor(Math.random() * this.options.maxAge),
}, },
width, width,
height, height,

+ 1
- 0
src/themes/index.js View File

*/ */


import './index.scss' import './index.scss'
import './map-switch.scss'

+ 6
- 33
src/themes/index.scss View File

@charset "UTF-8"; @charset "UTF-8";


* {
padding: 0;
margin: 0;
}

.dc-container {
overflow: hidden;
display: block;
}

.dc-viewer {
font-family: sans-serif;
font-size: 16px;
overflow: hidden;
display: block;
.viewer-canvas {
position: relative; position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.dc-viewer-widget-container {
width: 100%;
height: 100%;
}

.dc-widget {
font-family: sans-serif;
font-size: 16px;
overflow: hidden; overflow: hidden;
display: block;
position: relative;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }


.dc-widget,
.dc-widget canvas {
.viewer-canvas canvas {
width: 100%; width: 100%;
height: 100%; height: 100%;
touch-action: none; touch-action: none;
} }



.div-icon { .div-icon {
user-select: none; user-select: none;
background-color: #fff; background-color: #fff;
cursor: pointer; cursor: pointer;
} }
} }




Loading…
Cancel
Save