瀏覽代碼

1.修改框架目录2.拆分OVerlay为单独框架包

tags/1.0.0
Caven 5 年之前
父節點
當前提交
3414e413a7

+ 8
- 5
package.json 查看文件

@@ -7,18 +7,21 @@
"license": "MIT",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "yarn run build:core && yarn run build:plugins && yarn run build:plot",
"publish": "yarn run publish:core && yarn run publish:plugins && yarn run publish:plot",
"build": "yarn run build:core && yarn run build:plugins && yarn run build:plot && yarn run build:overlay",
"build:core": "yarn run clean:core && webpack --config webpack.conf --mode development",
"publish:core": "yarn run clean:core && webpack --config webpack.conf --mode production --env.production",
"build:plugins": "yarn run clean:plugins && webpack --config webpack.plugins.conf --mode development",
"publish:plugins": "yarn run clean:plugins && webpack --config webpack.plugins.conf --mode production --env.production",
"build:plot": "yarn run clean:plot && webpack --config webpack.plot.conf --mode development",
"build:overlay": "yarn run clean:overlay && webpack --config webpack.overlay.conf --mode development",
"publish": "yarn run publish:core && yarn run publish:plugins && yarn run publish:plot && yarn run publish:overlay",
"publish:core": "yarn run clean:core && webpack --config webpack.conf --mode production --env.production",
"publish:plugins": "yarn run clean:plugins && webpack --config webpack.plugins.conf --mode production --env.production",
"publish:plot": "yarn run clean:plot && webpack --config webpack.plot.conf --mode production --env.production",
"publish:overlay": "yarn run clean:overlay && webpack --config webpack.overlay.conf --mode production --env.production",
"clean": "rimraf dist/",
"clean:core": "rimraf dist/dc-sdk/resources dist/dc-sdk/dc.*.js dist/dc-sdk/dc.*.css",
"clean:plugins": "rimraf dist/dc-sdk/plugins",
"clean:plot": "rimraf dist/dc-sdk/plot"
"clean:plot": "rimraf dist/dc-sdk/plot",
"clean:overlay": "rimraf dist/dc-sdk/overlay"
},
"devDependencies": {
"@babel/core": "^7.4.0",

+ 22
- 11
src/core/DC.js 查看文件

@@ -2,30 +2,33 @@
* @Author: Caven
* @Date: 2019-12-27 14:29:05
* @Last Modified by: Caven
* @Last Modified time: 2020-04-08 19:44:15
* @Last Modified time: 2020-04-09 20:29:07
*/
;(function() {
let namespace = {}

let initialized = false

let isCesiumLoaded = false

let DC = {
Author: 'Caven Chen',
GitHub: 'https://github.com/Digital-Visual',
Version: '1.0.0',
Config: {}
}

delete window.DC
window.DC = DC

require('../log')

let requireCesium = () => {
/**
* load Cesium
*/
function requireCesium() {
return new Promise((resolve, reject) => {
let Cesium = require('cesium/Cesium')
namespace['Cesium'] = Cesium
resolve()
resolve(Cesium)
})
}

@@ -45,25 +48,33 @@
}

/**
* start
*
*/
DC.init = callback => {
DC.ready(callback)
if (!isCesiumLoaded) {
requireCesium().then(Cesium => {
namespace['Cesium'] = Cesium
delete window.Cesium
isCesiumLoaded = true
callback && callback()
})
} else {
callback && callback()
}
}

/**
* start
*
*/
DC.ready = callback => {
try {
if (!initialized) {
requireCesium().then(() => {
DC.init(() => {
require('../thirdpart')
require('./DC.Loader')
delete window.Cesium //删除winow下的Cesium
callback && callback()
initialized = true
})
initialized = true
} else {
callback && callback()
}

+ 13
- 5
src/core/const/index.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-01-03 10:09:19
* @Last Modified by: Caven
* @Last Modified time: 2020-02-29 18:15:18
* @Last Modified time: 2020-04-09 20:42:47
*/
import Cesium from '@/namespace'

@@ -43,7 +43,9 @@ DC.SceneEventType = {
CLOCK_TICK: 'clockTick'
}

DC.LayerType = {}
DC.LayerType = {
...DC.LayerType
}

DC.LayerEventType = {
...baseEventType,
@@ -57,7 +59,9 @@ DC.LayerState = {
CLEARED: 'cleared'
}

DC.OverlayType = {}
DC.OverlayType = {
...DC.OverlayType
}

DC.OverlayEventType = {
...baseEventType
@@ -67,7 +71,9 @@ DC.OverlayState = {
...baseState
}

DC.EffectType = {}
DC.EffectType = {
...DC.EffectType
}

DC.EffectEventType = {
...baseEventType
@@ -77,7 +83,9 @@ DC.EffectState = {
...baseState
}

DC.WidgetType = {}
DC.WidgetType = {
...DC.WidgetType
}

DC.WidgetState = {
INITIALIZED: 'initialized',

src/plugins/layer/DC.HtmlLayer.js → src/core/layer/DC.HtmlLayer.js 查看文件

@@ -2,11 +2,11 @@
* @Author: Caven
* @Date: 2020-02-12 21:43:33
* @Last Modified by: Caven
* @Last Modified time: 2020-03-21 23:52:31
* @Last Modified time: 2020-04-09 20:36:13
*/

import Cesium from '@/namespace'
import Layer from '@/core/layer/Layer'
import Layer from './Layer'

DC.HtmlLayer = class extends Layer {
constructor(id) {

+ 1
- 1
src/core/layer/DC.TopoJsonLayer.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-03-22 01:12:39
* @Last Modified by: Caven
* @Last Modified time: 2020-03-30 17:21:49
* @Last Modified time: 2020-04-09 20:36:44
*/
DC.TopoJsonLayer = class extends DC.GeoJsonLayer {
constructor(id, url, options = {}) {

+ 4
- 2
src/core/layer/index.js 查看文件

@@ -2,9 +2,11 @@
* @Author: Caven
* @Date: 2020-01-03 11:06:26
* @Last Modified by: Caven
* @Last Modified time: 2020-02-10 12:33:54
* @Last Modified time: 2020-04-09 20:46:00
*/
import './DC.VectorLayer'
import './DC.TilesetLayer'
import './DC.GeoJsonLayer'
import './DC.ClusterLayer'
import './DC.TopoJsonLayer'
import './DC.HtmlLayer'
import './DC.LabelLayer'

src/plugins/overlay/DC.DivIcon.js → src/core/overlay/base/DC.DivIcon.js 查看文件


+ 2
- 1
src/core/overlay/index.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-01-06 15:04:15
* @Last Modified by: Caven
* @Last Modified time: 2020-02-18 16:12:38
* @Last Modified time: 2020-04-09 20:45:35
*/

import './base/DC.Point'
@@ -12,5 +12,6 @@ import './base/DC.Billboard'
import './base/DC.Cricle'
import './base/DC.Label'
import './base/DC.Plane'
import './base/DC.DivIcon'
import './model/DC.Model'
import './model/DC.Tileset'

+ 10
- 0
src/overlay/DC.Overlay.Loader.js 查看文件

@@ -0,0 +1,10 @@
/*
* @Author: Caven
* @Date: 2020-04-09 20:03:32
* @Last Modified by: Caven
* @Last Modified time: 2020-04-09 20:52:54
*/
import '@/core/const'
import './base/DC.Wall'
import './custom/DC.CustomBillboard'
import './custom/DC.CustomPolygon'

src/plugins/overlay/DC.Wall.js → src/overlay/base/DC.Wall.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-02-25 18:28:36
* @Last Modified by: Caven
* @Last Modified time: 2020-03-06 17:03:46
* @Last Modified time: 2020-04-09 20:47:30
*/
import Cesium from '@/namespace'
import Overlay from '@/core/overlay/Overlay'

src/plugins/overlay/DC.CustomBillboard.js → src/overlay/custom/DC.CustomBillboard.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-02-12 21:44:24
* @Last Modified by: Caven
* @Last Modified time: 2020-04-03 09:55:22
* @Last Modified time: 2020-04-09 20:47:02
*/
import Cesium from '@/namespace'
import '@/core/overlay/base/DC.Billboard'

src/plugins/overlay/DC.CustomPolygon.js → src/overlay/custom/DC.CustomPolygon.js 查看文件


+ 16
- 0
src/overlay/index.js 查看文件

@@ -0,0 +1,16 @@
/*
* @Author: Caven
* @Date: 2020-04-09 20:02:37
* @Last Modified by: Caven
* @Last Modified time: 2020-04-09 20:48:12
*/
;(function() {
let initialized = false
if (!DC) {
console.error('DC.Overlay: Missing DC Sdk')
}
DC.init(() => {
isCesiumLoaded && !initialized && require('./DC.Overlay.Loader')
initialized = true
})
})()

+ 1
- 1
src/plot/draw/DrawCircle.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-01-31 19:44:41
* @Last Modified by: Caven
* @Last Modified time: 2020-04-04 21:37:42
* @Last Modified time: 2020-04-09 19:21:49
*/
import Cesium from '@/namespace'
import Draw from './Draw'

+ 3
- 2
src/plot/index.js 查看文件

@@ -2,12 +2,13 @@
* @Author: Caven
* @Date: 2020-04-03 10:13:42
* @Last Modified by: Caven
* @Last Modified time: 2020-04-03 10:14:28
* @Last Modified time: 2020-04-09 20:29:17
*/
;(function() {
let initialized = false

if (!DC) {
console.error('missing dc sdk')
console.error('DC.Plot: Missing DC Sdk')
}

DC.init(() => {

+ 2
- 2
src/plugins/DC.Pulgins.Loader.js 查看文件

@@ -2,11 +2,11 @@
* @Author: Caven
* @Date: 2020-01-14 18:24:57
* @Last Modified by: Caven
* @Last Modified time: 2020-04-03 09:57:52
* @Last Modified time: 2020-04-09 20:37:45
*/
import '@/core/const'
import './animation'
import './roaming/DC.Roaming'
import './material'
import './effects'
import './layer'
import './overlay'

+ 2
- 3
src/plugins/DC.Pulgins.js 查看文件

@@ -2,14 +2,13 @@
* @Author: Caven
* @Date: 2020-01-14 18:22:10
* @Last Modified by: Caven
* @Last Modified time: 2020-03-23 13:57:51
* @Last Modified time: 2020-04-09 20:28:49
*/
;(function() {
let initialized = false
if (!DC) {
console.error('missing dc sdk')
console.error('DC.Plugins: Missing DC Sdk')
}

let namespace = DC.getNamespace()
namespace['mapv'] = window.mapv || undefined
delete window.mapv

src/core/layer/DC.ClusterLayer.js → src/plugins/layer/DC.ClusterLayer.js 查看文件

@@ -2,10 +2,10 @@
* @Author: Caven
* @Date: 2020-02-10 10:05:41
* @Last Modified by: Caven
* @Last Modified time: 2020-03-29 13:19:33
* @Last Modified time: 2020-04-09 20:36:27
*/
import Cesium from '@/namespace'
import Layer from './Layer'
import Layer from '@/core/layer/Layer'

const DEF_OPT = {
size: 48,

+ 2
- 2
src/plugins/layer/index.js 查看文件

@@ -2,10 +2,10 @@
* @Author: Caven
* @Date: 2020-01-19 11:04:45
* @Last Modified by: Caven
* @Last Modified time: 2020-02-27 13:54:29
* @Last Modified time: 2020-04-09 20:36:29
*/
import './DC.HeatmapLayer'
import './DC.ClusterLayer'
import './DC.CzmlLayer'
import './DC.KmlLayer'
import './DC.HtmlLayer'
import './DC.MapvLayer'

+ 0
- 10
src/plugins/overlay/index.js 查看文件

@@ -1,10 +0,0 @@
/*
* @Author: Caven
* @Date: 2020-02-06 19:40:43
* @Last Modified by: Caven
* @Last Modified time: 2020-03-05 22:20:35
*/
import './DC.CustomBillboard'
import './DC.CustomPolygon'
import './DC.DivIcon'
import './DC.Wall'

+ 102
- 0
webpack.overlay.conf.js 查看文件

@@ -0,0 +1,102 @@
/*
* @Author: Caven
* @Date: 2020-01-18 18:22:23
* @Last Modified by: Caven
* @Last Modified time: 2020-04-09 20:49:23
*/

const path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')

function resolve(dir) {
return path.join(__dirname, '.', dir)
}

module.exports = env => {
const IS_PROD = (env && env.production) || false
const publicPath = IS_PROD ? '/' : '/'
let plugins = [
new MiniCssExtractPlugin({
filename: IS_PROD ? '[name].min.css' : '[name].css',
allChunks: true
})
]
if (IS_PROD) {
plugins.push(new OptimizeCssAssetsPlugin())
plugins.push(new webpack.NoEmitOnErrorsPlugin())
}
return {
entry: {
'dc.overlay': ['entry']
},
devtool: IS_PROD ? false : 'cheap-module-eval-source-map',
output: {
filename: IS_PROD ? '[name].min.js' : '[name].js',
path: path.resolve(__dirname, 'dist/dc-sdk/overlay'),
publicPath: publicPath,
sourcePrefix: ''
},
amd: {
toUrlUndefinded: true
},
node: {
fs: 'empty'
},
module: {
unknownContextCritical: false,
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['@babel/preset-env'],
compact: false,
ignore: ['checkTree']
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 20000
}
}
]
},
resolve: {
extensions: ['.js', '.json', '.css'],
alias: {
'@': resolve('src'),
entry: './src/overlay'
}
},
plugins
}
}

+ 1
- 5
webpack.plot.conf.js 查看文件

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-01-18 18:22:23
* @Last Modified by: Caven
* @Last Modified time: 2020-04-03 10:14:44
* @Last Modified time: 2020-04-09 20:49:30
*/

const path = require('path')
@@ -87,10 +87,6 @@ module.exports = env => {
options: {
limit: 20000
}
},
{
test: /\.glsl$/,
loader: 'webpack-glsl-loader'
}
]
},

Loading…
取消
儲存