分享⼀个基于vue(2.9)和threeJs+⾼德地图实现的3d可视化项⽬
分享⼀个曾经做过的3d可视化项⽬,该项⽬使⽤vue2.9作为框架 使⽤webpack构建前段⼯程,
项⽬核⼼点:vue中集成threejs;⾼德地图中加载3d模型;threejs操作模型的各种应⽤。
项⽬运⾏效果图:
⾸页地图+3d管道
点击管道进⼊管道详情:
3d拾取查看详情:
⼯程核⼼代码:1.packge.json
{
"name": "code",
"description": "gcc-test",
"version": "1.0.0",
"author": "cc.guo",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" },
"dependencies": {
"array-includes": "^3.0.3",
"axios": "^0.19.0",
"cross-spawn": "^7.0.1",
"element-ui": "^2.9.1",
"jquery": "^3.4.1",
"js-md5": "^0.7.3",
"md5-node": "^1.0.1",
"sass": "^1.23.6",
"three": "^0.104.0",
"three-orbit-controls": "^82.1.0",
"vue": "^2.5.11",
"vue-axios": "^2.1.4",
"vue-router": "^3.0.1"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"copy-webpack-plugin": "^5.0.3",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.6",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.11.5"
}
}
fig.js 前段⼯程化配置
const path = require('path')
const webpack = require('webpack')
const CopyWebpackPlugin =require('copy-webpack-plugin')
let Plugins=[];
Plugins.push(new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
THREE:"three",
}))
// Plugins.push(new CopyWebpackPlugin([{
// from: "src/model/",
/
/ to: "model/",
// force: true
// }]))
entry: './src/main.js',
output: {
path: solve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
plugins:Plugins,
jquery框架使用
module: {
rules: [
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader'
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
,
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary. 'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
port: 8082,
host: 'localhost',
// contentBase: '../dist/',//服务器上⾯所有静态资源的源地址
// publicPath: '/',//服务器访问的时候添加的项⽬前缀,例如本实例的localhost:9000/ipems/scene1来进⾏访问场景1 proxy: [{
context: ['/oilpipe_xy'],
target: {
// "host": "10.24.19.246",
"host": "192.168.0.45",
"protocol": 'http:',
"port": 8080
}
}],
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (v.NODE_ENV === 'production') {
// /en/workflow/production.html
new webpack.DefinePlugin({
'v': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
]
)
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论