├── .eslintignore
├── .browserslistrc
├── public
├── favicon.ico
├── models
│ └── gltf
│ │ └── example.glb
└── index.html
├── src
├── assets
│ ├── logo.png
│ └── ajax-loader.gif
├── main.js
└── App.vue
├── babel.config.js
├── jsconfig.json
├── .editorconfig
├── .gitignore
├── .eslintrc.js
├── ci
└── .drone.yml
├── README.md
├── gulpfile.js
├── package.json
└── vue.config.js
/.eslintignore:
--------------------------------------------------------------------------------
1 | src/thirdparty/
--------------------------------------------------------------------------------
/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 | not dead
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alvisisme/cesium-with-threejs/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alvisisme/cesium-with-threejs/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/src/assets/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alvisisme/cesium-with-threejs/HEAD/src/assets/ajax-loader.gif
--------------------------------------------------------------------------------
/public/models/gltf/example.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alvisisme/cesium-with-threejs/HEAD/public/models/gltf/example.glb
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "./",
4 | "paths": {
5 | "@/*": ["src/*"]
6 | }
7 | },
8 | "exclude": ["node_modules"]
9 | }
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 |
4 | import 'cesium/Build/Cesium/Widgets/widgets.css'
5 |
6 | Vue.config.productionTip = false
7 |
8 | new Vue({
9 | render: h => h(App)
10 | }).$mount('#app')
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 |
9 | [*.{js,jsx,ts,tsx,vue}]
10 | charset = utf-8
11 | indent_style = space
12 | indent_size = 2
13 | trim_trailing_whitespace = true
14 | insert_final_newline = true
15 | end_of_line = lf
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
25 | src/thirdparty/Cesium/
26 | src/thirdparty/Three/
27 | src/thirdparty/ThreeExamples/
28 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 |
2 | const production = process.env.NODE_ENV === 'production'
3 |
4 | module.exports = {
5 | root: true,
6 | env: {
7 | node: true
8 | },
9 | extends: [
10 | 'plugin:vue/essential',
11 | '@vue/standard'
12 | ],
13 | parserOptions: {
14 | parser: 'babel-eslint'
15 | },
16 | rules: {
17 | 'no-console': production ? 'warn' : 'off',
18 | 'no-debugger': production ? 'warn' : 'off',
19 | "no-unused-vars": production ? 'error' : 'off',
20 | 'space-before-function-paren': 0
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ci/.drone.yml:
--------------------------------------------------------------------------------
1 | ---
2 | kind: pipeline
3 | type: docker
4 | name: Build
5 | steps:
6 | - name: build
7 | image: node:16.0.0
8 | commands:
9 | - npm config set registry https://registry.npmmirror.com
10 | - npm i -g pnpm
11 | - pnpm i
12 | - pnpm build
13 |
14 | ---
15 | kind: pipeline
16 | type: exec
17 | name: Mirror
18 | steps:
19 | - name: gitee
20 | commands:
21 | - git push --mirror git@gitee.com:alvisisme/$DRONE_REPO_NAME
22 | - name: github
23 | commands:
24 | - git push --mirror git@github.com:alvisisme/$DRONE_REPO_NAME
25 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cesium-with-threejs
2 |
3 | 将Cesium与ThreeJs集成的样例。
4 |
5 | * cesium 1.100.0
6 | * three 0.147.0
7 |
8 | 参考并修改自[cesium-threejs-experiment](https://github.com/CesiumGS/cesium-threejs-experiment)
9 |
10 | ## 升级记录
11 |
12 | * Cesium 升级到 1.100.0
13 | * Cesium 升级到 1.99.0
14 | * Cesium 升级到 1.96.0
15 | * Cesium 升级到 1.95.0
16 | * threejs 升级到 0.147.0,Cesium 升级到 1.90.0
17 | * threejs 从 0.96.0 升级到 0.128.0
18 | * threejs 从 0.95.0 升级到 0.96.0
19 |
20 | 缺少灯光的话将无法显示,场景需要加入灯光
21 |
22 | ```js
23 | const Amlight = new AmbientLight(0xffffff, 2)
24 | three.scene.add(Amlight)
25 | ThreeContainer.appendChild(three.renderer.domElement)
26 | ```
27 |
28 | * threejs 从 0.88.0 升级到 0.95.0
29 | * threejs 从 0.87.1 升级到 0.88.0
30 |
31 | lookAt 函数签名有变化
32 |
33 | ```js
34 | _3Dobjects[id].threeMesh.lookAt(centerHigh)
35 | ```
36 |
37 | 修改为
38 |
39 | ```js
40 | _3Dobjects[id].threeMesh.lookAt(centerHigh.x, centerHigh.y, centerHigh.z)
41 | ```
42 |
43 | * cesium 从 1.45.0 升级到 1.81.0,threejs 为 0.87.1
44 |
45 | ## 参考引用
46 |
47 | * [cesium-threejs-experiment](https://github.com/CesiumGS/cesium-threejs-experiment)
48 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | const fsExtra = require('fs-extra')
2 | const gulp = require('gulp')
3 | const Promise = require('bluebird')
4 |
5 | // Copies relevant parts of client JS libraries to `public/ThirdParty` for local development
6 | gulp.task('postInstall', function () {
7 | const thirdPartyDirectory = 'src/thirdparty'
8 | fsExtra.removeSync(thirdPartyDirectory)
9 |
10 | var webSiteLibs = [
11 | {
12 | name: 'Three',
13 | glob: [
14 | 'node_modules/three/src/**'
15 | ],
16 | subDir: true
17 | }, {
18 | name: 'ThreeExamples',
19 | glob: [
20 | 'node_modules/three/examples/jsm/**'
21 | ],
22 | subDir: true
23 | }
24 | ]
25 |
26 | var promises = []
27 | webSiteLibs.forEach(function (module) {
28 | var dest = thirdPartyDirectory
29 | if (module.subDir) {
30 | dest += '/' + module.name
31 | }
32 |
33 | var options = {
34 | nodir: true,
35 | base: module.base
36 | }
37 | promises.push(streamToPromise(gulp.src(module.glob, options).pipe(gulp.dest(dest))))
38 | })
39 |
40 | return Promise.all(promises)
41 | })
42 |
43 | function streamToPromise (stream) {
44 | return new Promise(function (resolve, reject) {
45 | stream.on('finish', resolve)
46 | stream.on('end', reject)
47 | })
48 | }
49 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cesium-with-threejs",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "postinstall": "gulp postInstall",
7 | "serve": "vue-cli-service serve",
8 | "build": "vue-cli-service build",
9 | "lint": "vue-cli-service lint"
10 | },
11 | "dependencies": {
12 | "cesium": "1.100.0",
13 | "core-js": "3.12.1",
14 | "three": "0.147.0",
15 | "vue": "2.7.14"
16 | },
17 | "devDependencies": {
18 | "@vue/cli-plugin-babel": "~4.5.19",
19 | "@vue/cli-plugin-eslint": "~4.5.19",
20 | "@vue/cli-service": "~4.5.19",
21 | "@vue/eslint-config-standard": "^5.1.2",
22 | "babel-eslint": "^10.1.0",
23 | "bluebird": "^3.7.2",
24 | "eslint": "^6.8.0",
25 | "eslint-plugin-import": "^2.26.0",
26 | "eslint-plugin-node": "^11.1.0",
27 | "eslint-plugin-promise": "^4.3.1",
28 | "eslint-plugin-standard": "^4.1.0",
29 | "eslint-plugin-vue": "^6.2.2",
30 | "fs-extra": "^10.1.0",
31 | "glslify-loader": "^2.0.0",
32 | "gulp": "^4.0.2",
33 | "less": "^3.13.1",
34 | "less-loader": "^5.0.0",
35 | "lint-staged": "^9.5.0",
36 | "raw-loader": "^4.0.2",
37 | "url-loader": "^4.1.1",
38 | "vue-template-compiler": "^2.7.14",
39 | "webpack": "^4.46.0"
40 | },
41 | "gitHooks": {
42 | "pre-commit": "lint-staged"
43 | },
44 | "lint-staged": {
45 | "*.{js,jsx,vue}": [
46 | "vue-cli-service lint",
47 | "git add"
48 | ]
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | const webpack = require('webpack')
3 | const CopyWebpackPlugin = require('copy-webpack-plugin')
4 |
5 | /* eslint-disable-next-line */
6 | const development = process.env.NODE_ENV === 'development'
7 | /* eslint-disable-next-line */
8 | const production = process.env.NODE_ENV === 'production'
9 |
10 | const CesiumSource = path.join('node_modules', 'cesium', 'Build', 'Cesium')
11 |
12 | const config = {
13 | publicPath: './',
14 | transpileDependencies: [
15 | '@cesium/engine'
16 | ],
17 | configureWebpack: {
18 | plugins: [
19 | new CopyWebpackPlugin([{ from: path.join(CesiumSource, 'Assets'), to: 'Assets' }]),
20 | new CopyWebpackPlugin([{ from: path.join(CesiumSource, 'ThirdParty'), to: 'ThirdParty' }]),
21 | new CopyWebpackPlugin([{ from: path.join(CesiumSource, 'Widgets'), to: 'Widgets' }]),
22 | new CopyWebpackPlugin([{ from: path.join(CesiumSource, 'Workers'), to: 'Workers' }]),
23 | new webpack.DefinePlugin({
24 | CESIUM_BASE_URL: JSON.stringify('./')
25 | })
26 | ],
27 | module: {
28 | unknownContextCritical: false,
29 | rules: [
30 | {
31 | test: /\.(png|jpg|gif)$/,
32 | use: [
33 | {
34 | loader: 'url-loader',
35 | options: {
36 | limit: 8192
37 | }
38 | }
39 | ]
40 | },
41 | // {
42 | // test: /\.glsl$/,
43 | // use: [
44 | // {
45 | // loader: 'webpack-glsl'
46 | // }
47 | // ]
48 | // },
49 | {
50 | test: /\.(glsl|vs|fs|vert|frag)$/,
51 | exclude: /node_modules/,
52 | use: [
53 | 'raw-loader',
54 | 'glslify-loader'
55 | ]
56 | }
57 | ]
58 | }
59 | }
60 | }
61 |
62 | module.exports = config
63 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
338 |
339 |
409 |
--------------------------------------------------------------------------------