UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

130 lines (129 loc) 4.11 kB
import "../../../../echarts/lib/echarts.mjs"; import componentViewControlMixin from "../common/componentViewControlMixin.mjs"; import componentPostEffectMixin from "../common/componentPostEffectMixin.mjs"; import componentLightMixin from "../common/componentLightMixin.mjs"; import componentShadingMixin from "../common/componentShadingMixin.mjs"; import ComponentModel from "../../../../echarts/lib/model/Component.mjs"; import { each, merge, reduce } from "../../../../zrender/lib/core/util.mjs"; function defaultId(option, idx) { option.id = option.id || option.name || idx + ""; } var GlobeModel = ComponentModel.extend({ type: "globe", layoutMode: "box", coordinateSystem: null, init: function() { GlobeModel.superApply(this, "init", arguments); each(this.option.layers, function(layerOption, idx) { merge(layerOption, this.defaultLayerOption); defaultId(layerOption, idx); }, this); }, mergeOption: function(option) { var oldLayers = this.option.layers; this.option.layers = null; GlobeModel.superApply(this, "mergeOption", arguments); function createLayerMap(layers) { return reduce(layers, function(obj, layerOption, idx) { defaultId(layerOption, idx); obj[layerOption.id] = layerOption; return obj; }, {}); } if (oldLayers && oldLayers.length) { var newLayerMap = createLayerMap(option.layers); var oldLayerMap = createLayerMap(oldLayers); for (var id in newLayerMap) { if (oldLayerMap[id]) { merge(oldLayerMap[id], newLayerMap[id], true); } else { oldLayers.push(option.layers[id]); } } this.option.layers = oldLayers; } each(this.option.layers, function(layerOption) { merge(layerOption, this.defaultLayerOption); }, this); }, optionUpdated: function() { this.updateDisplacementHash(); }, defaultLayerOption: { show: true, type: "overlay" }, defaultOption: { show: true, zlevel: -10, left: 0, top: 0, width: "100%", height: "100%", environment: "auto", baseColor: "#fff", baseTexture: "", heightTexture: "", displacementTexture: "", displacementScale: 0, displacementQuality: "medium", globeRadius: 100, globeOuterRadius: 150, shading: "lambert", light: { main: { time: "" } }, atmosphere: { show: false, offset: 5, color: "#ffffff", glowPower: 6, innerGlowPower: 2 }, viewControl: { autoRotate: true, panSensitivity: 0, targetCoord: null }, layers: [] }, setDisplacementData: function(data, width, height) { this.displacementData = data; this.displacementWidth = width; this.displacementHeight = height; }, getDisplacementTexture: function() { return this.get("displacementTexture") || this.get("heightTexture"); }, getDisplacemenScale: function() { var displacementTexture = this.getDisplacementTexture(); var displacementScale = this.get("displacementScale"); if (!displacementTexture || displacementTexture === "none") { displacementScale = 0; } return displacementScale; }, hasDisplacement: function() { return this.getDisplacemenScale() > 0; }, _displacementChanged: true, _displacementScale: 0, updateDisplacementHash: function() { var displacementTexture = this.getDisplacementTexture(); var displacementScale = this.getDisplacemenScale(); this._displacementChanged = this._displacementTexture !== displacementTexture || this._displacementScale !== displacementScale; this._displacementTexture = displacementTexture; this._displacementScale = displacementScale; }, isDisplacementChanged: function() { return this._displacementChanged; } }); merge(GlobeModel.prototype, componentViewControlMixin); merge(GlobeModel.prototype, componentPostEffectMixin); merge(GlobeModel.prototype, componentLightMixin); merge(GlobeModel.prototype, componentShadingMixin); var GlobeModel$1 = GlobeModel; export { GlobeModel$1 as default };