Caven Chen 2 роки тому
джерело
коміт
faf5b0f590
2 змінених файлів з 28 додано та 32 видалено
  1. 9
    17
      src/modules/exts/Viewer.js
  2. 19
    15
      src/modules/viewer/Viewer.js

+ 9
- 17
src/modules/exts/Viewer.js Переглянути файл

@@ -153,10 +153,6 @@ function Viewer(container, options) {
container = getElement(container)
options = defaultValue(options, defaultValue.EMPTY_OBJECT)

const viewerContainer = document.createElement('div')

const bottomContainer = document.createElement('div')

const scene3DOnly = defaultValue(options.scene3DOnly, false)

let clock = new Clock()
@@ -189,20 +185,12 @@ function Viewer(container, options) {
maximumRenderTimeChange: options.maximumRenderTimeChange,
depthPlaneEllipsoidOffset: options.depthPlaneEllipsoidOffset,
msaaSamples: options.msaaSamples,
creditContainer: document.createElement('div'),
creditViewport: document.createElement('div'),
})

cesiumWidget.scene.backgroundColor = Color.TRANSPARENT

while (
cesiumWidget.creditViewport.hasChildNodes() &&
!(cesiumWidget.creditViewport.lastChild instanceof HTMLCanvasElement)
) {
cesiumWidget.creditViewport.removeChild(
cesiumWidget.creditViewport.lastChild
)
}

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

let dataSourceCollection = options.dataSources
let destroyDataSourceCollection = false
@@ -238,8 +226,8 @@ function Viewer(container, options) {

this._clock = clock
this._container = container
this._bottomContainer = bottomContainer
this._element = viewerContainer
this._bottomContainer = document.createElement('div')
this._element = document.createElement('div')
this._cesiumWidget = cesiumWidget
this._dataSourceCollection = dataSourceCollection
this._destroyDataSourceCollection = destroyDataSourceCollection
@@ -802,6 +790,10 @@ Viewer.prototype.isDestroyed = function () {
* removing the widget from layout.
*/
Viewer.prototype.destroy = function () {
if (this.isDestroyed()) {
return undefined
}

let i

// Unsubscribe from data sources

+ 19
- 15
src/modules/viewer/Viewer.js Переглянути файл

@@ -73,7 +73,7 @@ class Viewer {
*/
let widgets = createWidgets()
Object.keys(widgets).forEach((key) => {
this.use(widgets[key])
this._use(widgets[key])
})

/**
@@ -81,7 +81,7 @@ class Viewer {
*/
let tools = createTools()
Object.keys(tools).forEach((key) => {
this.use(tools[key])
this._use(tools[key])
})
}

@@ -189,6 +189,19 @@ class Viewer {
return this._delegate.scene.globe._surface._debug.maxDepthVisited
}


/**
* Adds a plugin
* @param plugin
* @returns {Viewer}
*/
_use(plugin) {
if (plugin && plugin.install) {
plugin.install(this)
}
return this
}

/***
*
* @param layerGroup
@@ -632,8 +645,10 @@ class Viewer {
this._delegate = undefined
this._baseLayerPicker = undefined
this._layerCache = {}
this._dcContainer.parentNode.removeChild(this._dcContainer)
this._dcContainer = undefined
this._widgetContainer.parentNode.removeChild(this._widgetContainer)
this._widgetContainer = undefined
this._layerContainer.parentNode.removeChild(this._layerContainer)
this._layerContainer = undefined
return this
}

@@ -657,17 +672,6 @@ class Viewer {
return this
}

/**
* Adds a plugin
* @param plugin
* @returns {Viewer}
*/
use(plugin) {
if (plugin && plugin.install) {
plugin.install(this)
}
return this
}
}

export default Viewer

Завантаження…
Відмінити
Зберегти