一 webpack 2.0 及用到的插件安装(默认已经有node环境)

1. package.json文件 (插件安装及插件的功能不详解)

  1. {
  2. "private": true,
  3. "devDependencies": {
  4. "autoprefixer-loader": "^3.2.0",
  5. "babel-core": "^6.18.2",
  6. "babel-loader": "^6.2.7",
  7. "babel-plugin-transform-runtime": "^6.15.0",
  8. "babel-preset-es2015": "^6.18.0",
  9. "babel-preset-stage-0": "^6.16.0",
  10. "babel-runtime": "^5.8.38",
  11. "clean-webpack-plugin": "^0.1.15",
  12. "css-loader": "^0.25.0",
  13. "debug": "^2.2.0",
  14. "express": "^4.14.0",
  15. "extract-text-webpack-plugin": "^2.0.0",
  16. "file-loader": "^0.9.0",
  17. "html-webpack-plugin": "^2.24.1",
  18. "node-sass": "^4.5.0",
  19. "postcss-loader": "^1.3.2",
  20. "sass-loader": "^6.0.2",
  21. "style-loader": "^0.13.1",
  22. "url-loader": "^0.5.7",
  23. "vue-hot-reload-api": "^1.2.0",
  24. "vue-html-loader": "^1.2.3",
  25. "vue-loader": "^7.3.0",
  26. "vue-resource": "^1.2.1",
  27. "webpack": "^2.2.1",
  28. "webpack-dev-middleware": "^1.8.4",
  29. "webpack-dev-server": "^1.16.2",
  30. "webpack-hot-middleware": "^2.13.1"
  31. },
  32. "dependencies": {
  33. "vue": "^2.0.0",
  34. "vue-router": "^2.0.0"
  35. },
  36. "scripts": {
  37. "build": "webpack --display-modules --display-chunks --config webpack.prod.config.js",
  38. "dev": "cross-env webpack --hide-modules --display-chunks --config webpack.dev.config.js",
  39. "test": "cross-env webpack --config webpack.config.js"
  40. }
  41. }

注明:scripts 设置了一些执行的命令 如dev 就是执行dev环境下webpack编译用的命令 控制台之行:npm run dev即可

2.webpack  配置文件 (有些配置的路径 按项目改变)

(1)webpack.config.js

  1. var path = require('path');
  2. var webpack = require('webpack');
  3. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  4. module.exports = {
  5. /* 输入文件 */
  6. entry: {
  7. // path.resolve([from ...], to) 将to参数解析为绝对路径
  8. index:path.resolve(__dirname, './resources/js/src/index.js'),
  9. // 需要被提取为公共模块的群组
  10. vendors:['vue','vue-router','three','convex'],
  11. },
  12. output: {
  13. /* 输出目录,没有则新建 */
  14. path: path.resolve(__dirname, './public/js/'),
  15. /* 静态目录,可以直接从这里取文件 */
  16. //publicPath: './resources/js/dist/',
  17. /* 文件名 */
  18. filename: '[name].[hash].js',
  19. },
  20. resolve:{
  21. extensions: ['.js', '.css', '.scss','.vue'],
  22. alias: {
  23. 'vue$': path.resolve(__dirname,'./node_modules/vue/dist/vue.js'),
  24. 'vue-router$':path.resolve(__dirname,'./node_modules/vue-router/dist/vue-router.js'),
  25. 'three$':path.resolve(__dirname,'./resources/js/lib/threejs/build/three.min.js'),
  26. 'convex$':path.resolve(__dirname,'./resources/js/lib/convex.js'),
  27. }
  28. },
  29. module: {
  30. rules: [
  31. /* 用来解析vue后缀的文件 */
  32. {
  33. test: /\.vue$/,
  34. use: ['vue-loader']
  35. },
  36. /* 用babel来解析js文件并把es6的语法转换成浏览器认识的语法 */
  37. {
  38. test: /\.js$/,
  39. loader: 'babel-loader',
  40. /* 排除模块安装目录的文件 */
  41. exclude: /node_modules/,
  42. options:{
  43. presets: ['es2015', 'stage-0'],
  44. plugins: ['transform-runtime']
  45. }
  46. },
  47. {
  48. test: /\.css$/,
  49. // 将样式抽取出来为独立的文件
  50. loader: ExtractTextPlugin.extract({fallback:"style-loader", use:["css-loader","postcss-loader"]}),
  51. exclude: /node_modules/
  52. },
  53. // 使用less-loader、autoprefixer-loader、css-loader和style-loade 加载 .less 结尾的文件
  54. {
  55. test: /\.scss$/,
  56. // 将样式抽取出来为独立的文件
  57. use:['style-loader','css-loader','autoprefixer-loader','sass-loader'],
  58. exclude: /node_modules/
  59. },
  60. // 加载图片
  61. {
  62. test: /\.(png|jpg|gif)$/,
  63. loader: 'url-loader',
  64. options: {
  65. // 把较小的图片转换成base64的字符串内嵌在生成的js文件里
  66. limit: 10000,
  67. // 路径和生产环境下的不同,要与修改后的publickPath相结合
  68. name: 'img/[name].[ext]?[hash:7]'
  69. }
  70. },
  71. // 加载图标
  72. {
  73. test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/,
  74. loader: 'file-loader',
  75. options: {
  76. limit: 10000,
  77. // 路径和生产环境下的不同,要与修改后的publickPath相结合
  78. name:'fonts/[name].[ext]?[hash:7]',
  79. prefix:'font'
  80. }
  81. }
  82. ]
  83. },
  84. //devtool: '#eval-source-map',
  85. }

注明:webpack2.0中loader名称要补全 如sass-loader 之前可以省略-loader这样的后缀 但是现在必须写全 否则无法编译

2.webpack.dev.conifg.js

  1. // 引入依赖模块
  2. var path = require('path');
  3. var webpack = require('webpack');
  4. var HtmlWebpackPlugin = require('html-webpack-plugin');
  5. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  6. var CleanWebpackPlugin = require('clean-webpack-plugin');
  7.  
  8. // 引入基本配置
  9. var config = require('./webpack.config.js');
  10.  
  11. // 必须修改原配置中网站运行时的访问路径,相当于绝对路径,修改完之后,当前配置文件下的很多相对路径都是相对于这个来设定;
  12. // 注意:webpack-dev-server会实时的编译,但是最后的编译的文件并没有输出到目标文件夹,而是保存到了内存当中
  13. config.output.publicPath = '/game/laravel-master/public/js/';
  14.  
  15. // 重新配置插件项
  16. config.plugins = [
  17. // 位于开发环境下
  18. new webpack.DefinePlugin({
  19. 'process.env': {
  20. NODE_ENV: '"development"'
  21. }
  22. }),
  23. // 自动生成html插件,如果创建多个HtmlWebpackPlugin的实例,就会生成多个页面
  24. new HtmlWebpackPlugin({
  25. // 生成html文件的名字,路径和生产环境下的不同,要与修改后的publickPath相结合,否则开启服务器后页面空白
  26. filename: '../../resources/views/dist/index.blade.php',
  27. // 源文件,路径相对于本文件所在的位置
  28. template: path.resolve(__dirname, './resources/views/index.blade.php'),
  29. // 需要引入entry里面的哪几个入口,如果entry里有公共模块,记住一定要引入
  30. chunks: ['vendors','index'],
  31. // 要把<script>标签插入到页面哪个标签里(body|true|head|false)
  32. inject: 'body',
  33. // 生成html文件的标题
  34. title:''
  35. // hash如果为true,将添加hash到所有包含的脚本和css文件,对于解除cache很有用
  36. // minify用于压缩html文件,其中的removeComments:true用于移除html中的注释,collapseWhitespace:true用于删除空白符与换行符
  37. }),
  38.  
  39. // 提取css单文件的名字,路径和生产环境下的不同,要与修改后的publickPath相结合
  40. new ExtractTextPlugin("[name].[contenthash].css"),
  41.  
  42. // 提取入口文件里面的公共模块
  43. new webpack.optimize.CommonsChunkPlugin({
  44. name: 'vendors',
  45. filename: 'vendors.js',
  46. }),
  47.  
  48. new CleanWebpackPlugin(['js','views','css'],{
  49. root:path.resolve(__dirname, './public/'),
  50. verbose: true,
  51. dry: false,
  52. //exclude: ['shared.js']
  53. }),
  54. new CleanWebpackPlugin(['views/dist'],{
  55. root:path.resolve(__dirname, './resources/'),
  56. verbose: true,
  57. dry: false,
  58. //exclude: ['shared.js']
  59. }),
  60. // 为组件分配ID,通过这个插件webpack可以分析和优先考虑使用最多的模块,并为它们分配最小的ID
  61. //new webpack.optimize.OccurenceOrderPlugin(),
  62.  
  63. // 模块热替换插件
  64. //new webpack.HotModuleReplacementPlugin(),
  65.  
  66. // 允许错误不打断程序
  67. //new webpack.NoErrorsPlugin(),
  68.  
  69. // 全局挂载插件
  70. new webpack.ProvidePlugin({
  71. Vue: "vue",
  72. THREE:'three'
  73. })
  74. ];
  75.  
  76. module.exports = config;

注明:HtmlWebpackPlugin inject 最好还是配置为body 会规避一些问题 (如 渲染速度 加载时序等)

二 vue项目

1。项目结构  (用的laravel php框架 webpack中的部分路径与该项目结构一致)

2.看下主视图文件 index.blade.php (这个文件由于用的laravel框架 目前没找到怎么改后缀名)

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Laravel</title>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  6. </head>
  7. <body>
  8. <div id="app">
  9.  
  10. </div>
  11.  
  12. <script type="text/javascript" src="/game/laravel-master/public/js/vendors.js"></script><script type="text/javascript" src="/game/laravel-master/public/js/index.f6c1bc018a4da91a571e.js"></script></body>
  13. </html>

注明:视图文件 什么都没做 就放一个用于vue实例挂载的元素 js文件也是用webpack编译后插入的

3. resources - js - src -index.js 项目的入口文件(es6语法)

  1. import App from './pages/app.vue';
  2. import VueRouter from 'vue-router';
  3. import VueResource from 'vue-resource';
  4.  
  5. Vue.use(VueRouter);
  6. Vue.use(VueResource);
  7.  
  8. const main = resolve => {
  9. require.ensure(['./pages/main.vue'],()=>{
  10. resolve(require('./pages/main.vue'))
  11. })
  12. }
  13.  
  14. const router = new VueRouter({
  15. routes: [{
  16. path:'/page',
  17. component: main,
  18. }
  19. ]
  20. })
  21.  
  22. Vue.http.options.emulateJSON = true;
  23.  
  24. Vue.http.interceptors.push((request, next) =>{
  25.  
  26. next((response) => {
  27. return response
  28. });
  29.  
  30. });
  31.  
  32. const app = new Vue({
  33. router:router,
  34. render: h => h(App),
  35. }).$mount('#app')

注明:创建了Vue实例并挂载在id为app的元素上,并创建了一个简单的路由实例

4.app.vue 文件 什么也没做 就是使用<router-view></router-view>标签,它用于渲染匹配的组件 和 加载一个common.scss文件设置一些页面全局样式

<template>
<router-view></router-view>
</template>

<script>
export default {
components: {

}
}
</script>

<style scoped lang='sass-loader'>
@import '../../../css/src/common.scss';
</style>

5.main.vue  基本上写了单页面组件所有能用到常用属性

  1. <template>
  2. <div class="data-webgl-main" ref="canvasbox">
  3. <canvas ref="canvas"></canvas>
  4. </div>
  5. </template>
  6.  
  7. <script >
  8.  
  9. export default{
       //监听父传递的变量和函数
  10. props:[
  11. ],
         //声明用到组件
  12. components:{
  13.  
  14. },
        //组建的数据
  15. data () {
  16. return {
  17. vinit:'',
  18. vscene:'',
  19. vcamera:'',
  20. vrenderer:'',
  21. vlight:'',
  22. vgeometry:'',
  23. vmaterial:'',
  24. vcube: '',
  25. vsphere:'',
  26. vline:'',
  27. vspGroup:'',
  28. vhullMesh:'',
  29. vcloud:''
  30.  
  31. }
  32. },
        //组建加载完执行
  33. mounted (){
  34. this.vscene = new THREE.Scene();
  35. this.vcamera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, 0.1, 1000);
  36. this.vrenderer = new THREE.WebGLRenderer({canvas:this.$refs.canvas,antialias : true});
  37.  
  38. this.finitRender();
  39. this.finitCamera();
  40. this.finitScene();
  41. this.finitLight();
  42. this.finitMesh();
  43. //this.fgeneratePoints();
  44. this.fcreatePointCloud(3,true,0.6,true, 0xffffff);
  45. this.frender();
  46. },
        //组建被创建触发
  47. created () {
  48.  
  49. },
    //监听路由和一些变量的变化出发 监听函数要注意 this的指向
  50. watch:{
  51.  
  52. },
    //组建用到的所有方法
  53. methods:{
  54. frender (){
  55. // this.vrenderer.clear();
  56. // this.vcamera.position.x = this.vcamera.position.x + 1;
  57. // this.vcube.rotation.x += 0.02;
  58. // this.vcube.rotation.y += 0.02;
  59. // this.vcube.rotation.z += 0.02;
  60. // this.vline.rotation.z += 0.01;
  61. // this.vspGroup.rotation.y = this.vhullMesh.rotation.y;
  62. // this.vhullMesh.rotation.y += 0.01;
  63.  
  64. var vertices = this.vcloud.geometry.vertices;
  65. vertices.forEach(function (v) {
  66. v.y = v.y - (v.velocityY);
  67. v.x = v.x - (v.velocityX);
  68.  
  69. if (v.y <= 0) v.y = 60;
  70. if (v.x <= -20 || v.x >= 20) v.velocityX = v.velocityX * -1;
  71. });
  72. this.vrenderer.render(this.vscene, this.vcamera);
  73. requestAnimationFrame(this.frender);
  74. },
  75. finitRender (){
  76. this.vrenderer.setClearColor(0x000000,1.0);
  77. this.vrenderer.shadowMapEnabled = true;
  78. this.vrenderer.setSize(window.innerWidth,window.innerHeight);
  79. },
  80. finitCamera (){
  81. this.vcamera.position.x = 20;
  82. this.vcamera.position.y = 40;
  83. this.vcamera.position.z = 110;
  84. // this.vcamera.up.x = 0;
  85. // this.vcamera.up.y = 0;
  86. // this.vcamera.up.z = 0;
  87. this.vcamera.lookAt(new THREE.Vector3(20, 30, 0))
  88. },
  89. finitScene (){
  90.  
  91. },
  92. finitLight (){
  93. // let light = new THREE.AmbientLight(0xFFFFFF);
  94. // light.position.set(100, 100, 200);
  95. // this.vscene.add(light);
  96. // light = new THREE.PointLight(0x00FF00);
  97. // light.position.set(0, 0,300);
  98. // this.vscene.add(light);
  99. // let light = new THREE.SpotLight(0xFFFFFF);
  100. // light.position.set(-40,60,-10);
  101. // light.castShadow = true;
  102. // this.vscene.add(light);
  103.  
  104. var ambientLight = new THREE.AmbientLight(0x0c0c0c);
  105. this.vscene.add(ambientLight);
  106. // add spotlight for the shadows
  107. var spotLight = new THREE.SpotLight(0xffffff);
  108. spotLight.position.set(-40, 60, -10);
  109. spotLight.castShadow = true;
  110. this.vscene.add(spotLight);
  111. },
  112. finitMesh (){
  113. // var geometry = new THREE.CylinderGeometry( 100,150,400);
  114. // var material = new THREE.MeshLambertMaterial( { color:0xFFFF00} );
  115. // var mesh = new THREE.Mesh( geometry,material);
  116. // mesh.position.add(new THREE.Vector3(0,0,0));
  117. // var planeGeometry = new THREE.PlaneGeometry(60,20,1,1);
  118. // var planeMaterial = new THREE.MeshLambertMaterial({color:0xffffff});
  119. // var plane = new THREE.Mesh(planeGeometry,planeMaterial);
  120. // plane.rotation.x = -0.5*Math.PI;
  121. // plane.position.x = 15;
  122. // plane.position.y = 0;
  123. // plane.position.z = 0;
  124. // plane.receiveShadow = true;
  125. // this.vscene.add(plane);
  126.  
  127. // var cubeGeometry = new THREE.CubeGeometry(4,4,4);
  128. // var cubeMaterial = new THREE.MeshLambertMaterial({color:0xff0000,wireframe:false});
  129. // var cube = new THREE.Mesh(cubeGeometry,cubeMaterial);
  130. // cube.position.x = -4;
  131. // cube.position.y = 3;
  132. // cube.position.z = 0;
  133. // cube.castShadow = true;
  134. // this.vcube = cube;
  135. // this.vscene.add(cube);
  136.  
  137. // var sphereGeometry = new THREE.SphereGeometry(4,20,20);
  138. // var sphereMaterial = new THREE.MeshLambertMaterial({color:0x7777ff,wireframe:false});
  139. // var sphere = new THREE.Mesh(sphereGeometry,sphereMaterial);
  140. // sphere.position.x = 20;
  141. // sphere.position.y = 4;
  142. // sphere.position.z = 2;
  143. // this.vsphere = sphere;
  144. // this.vscene.add(sphere);
  145.  
  146. // this.vcube = new THREE.Mesh();
  147. // var mats = [];
  148. // mats.push(new THREE.MeshBasicMaterial({color:0x009e60}))
  149. // mats.push(new THREE.MeshBasicMaterial({color:0x0051ba}))
  150. // mats.push(new THREE.MeshBasicMaterial({color:0xffd500}))
  151. // mats.push(new THREE.MeshBasicMaterial({color:0xff5800}))
  152. // mats.push(new THREE.MeshBasicMaterial({color:0xc41e3a}))
  153. // mats.push(new THREE.MeshBasicMaterial({color:0xffffff}))
  154. // var faceMaterial = new THREE.MeshFaceMaterial(mats);
  155. // for(var x=0;x<3;x++){
  156. // for(var y = 0;y<3;y++){
  157. // for(var z=0;z<3;z++){
  158. // var cubeGeom = new THREE.CubeGeometry(2.9,2.9,2.9);
  159. // var cube = new THREE.Mesh(cubeGeom,faceMaterial);
  160. // cube.position.add(new THREE.Vector3(x*3-3,y*3,z*3-3));
  161. // this.vcube.add(cube);
  162. // }
  163. // }
  164. // }
  165. // this.vscene.add(this.vcube)
  166.  
  167. // var points = this.fgosper(4, 60);
  168. // var lines = new THREE.Geometry();
  169. // var colors = [];
  170. // var i = 0;
  171. // points.forEach(function (e) {
  172. // lines.vertices.push(new THREE.Vector3(e.x, e.z, e.y));
  173. // colors[i] = new THREE.Color(0xffffff);
  174. // colors[i].setHSL(e.x / 100 + 0.5, ( e.y * 20 ) / 300, 0.8);
  175. // i++;
  176. // });
  177. // lines.colors = colors;
  178. // var material = new THREE.LineBasicMaterial({
  179. // opacity: 1.0,
  180. // linewidth: 1,
  181. // vertexColors: THREE.VertexColors
  182. // });
  183. // this.vline = new THREE.Line(lines, material);
  184. // this.vline.position.set(25, -30, -60);
  185. // this.vscene.add(this.vline);
  186.  
  187. },
  188. fgosper (a, b) {
  189. var turtle = [0, 0, 0];
  190. var points = [];
  191. var count = 0;
  192. rg(a, b, turtle);
  193. return points;
  194. function rt(x) {
  195. turtle[2] += x;
  196. }
  197. function lt(x) {
  198. turtle[2] -= x;
  199. }
  200. function fd(dist) {
  201. // ctx.beginPath();
  202. points.push({x: turtle[0], y: turtle[1], z: Math.sin(count) * 5});
  203. // ctx.moveTo(turtle[0], turtle[1]);
  204. var dir = turtle[2] * (Math.PI / 180);
  205. turtle[0] += Math.cos(dir) * dist;
  206. turtle[1] += Math.sin(dir) * dist;
  207. points.push({x: turtle[0], y: turtle[1], z: Math.sin(count) * 5});
  208. // ctx.lineTo(turtle[0], turtle[1]);
  209. // ctx.stroke();
  210. }
  211. function rg(st, ln, turtle) {
  212. st--;
  213. ln = ln / 2.6457;
  214. if (st > 0) {
  215. // ctx.strokeStyle = '#111';
  216. rg(st, ln, turtle);
  217. rt(60);
  218. gl(st, ln, turtle);
  219. rt(120);
  220. gl(st, ln, turtle);
  221. lt(60);
  222. rg(st, ln, turtle);
  223. lt(120);
  224. rg(st, ln, turtle);
  225. rg(st, ln, turtle);
  226. lt(60);
  227. gl(st, ln, turtle);
  228. rt(60);
  229. }
  230. if (st == 0) {
  231. fd(ln);
  232. rt(60);
  233. fd(ln);
  234. rt(120);
  235. fd(ln);
  236. lt(60);
  237. fd(ln);
  238. lt(120);
  239. fd(ln);
  240. fd(ln);
  241. lt(60);
  242. fd(ln);
  243. rt(60)
  244. }
  245. }
  246. function gl(st, ln, turtle) {
  247. st--;
  248. ln = ln / 2.6457;
  249. if (st > 0) {
  250. // ctx.strokeStyle = '#555';
  251. lt(60);
  252. rg(st, ln, turtle);
  253. rt(60);
  254. gl(st, ln, turtle);
  255. gl(st, ln, turtle);
  256. rt(120);
  257. gl(st, ln, turtle);
  258. rt(60);
  259. rg(st, ln, turtle);
  260. lt(120);
  261. rg(st, ln, turtle);
  262. lt(60);
  263. gl(st, ln, turtle);
  264. }
  265. if (st == 0) {
  266. lt(60);
  267. fd(ln);
  268. rt(60);
  269. fd(ln);
  270. fd(ln);
  271. rt(120);
  272. fd(ln);
  273. rt(60);
  274. fd(ln);
  275. lt(120);
  276. fd(ln);
  277. lt(60);
  278. fd(ln);
  279. }
  280. }
  281. },
  282. fgeneratePoints() {
  283. // add 10 random spheres
  284. var points = [];
  285. for (var i = 0; i < 20; i++) {
  286. var randomX = -15 + Math.round(Math.random() * 30);
  287. var randomY = -15 + Math.round(Math.random() * 30);
  288. var randomZ = -15 + Math.round(Math.random() * 30);
  289. points.push(new THREE.Vector3(randomX, randomY, randomZ));
  290. }
  291. this.vspGroup = new THREE.Object3D();
  292. var material = new THREE.MeshBasicMaterial({color: 0xff0000, transparent: false});
  293. points.forEach((point) => {
  294. var spGeom = new THREE.SphereGeometry(0.2);
  295. var spMesh = new THREE.Mesh(spGeom, material);
  296. spMesh.position.copy(point);
  297. this.vspGroup.add(spMesh);
  298. });
  299. // add the points as a group to the scene
  300. this.vscene.add(this.vspGroup);
  301. // use the same points to create a convexgeometry
  302. var hullGeometry = new THREE.ConvexGeometry(points);
  303. this.vhullMesh = this.fcreateMesh(hullGeometry);
  304. this.vscene.add(this.vhullMesh);
  305. },
  306.  
  307. fcreateMesh (geom) {
  308. // assign two materials
  309. var meshMaterial = new THREE.MeshBasicMaterial({color: 0x00ff00, transparent: true, opacity: 0.2});
  310. meshMaterial.side = THREE.DoubleSide;
  311. var wireFrameMat = new THREE.MeshBasicMaterial();
  312. wireFrameMat.wireframe = true;
  313. // create a multimaterial
  314. var mesh = THREE.SceneUtils.createMultiMaterialObject(geom, [meshMaterial, wireFrameMat]);
  315. return mesh;
  316. },
  317. fcreatePointCloud(size, transparent, opacity, sizeAttenuation, color) {
  318.  
  319. var texture = THREE.ImageUtils.loadTexture("laravel-master/resources/images/textures/particles/raindrop-3.png");
  320. var geom = new THREE.Geometry();
  321.  
  322. var material = new THREE.ParticleBasicMaterial({
  323. size: size,
  324. transparent: transparent,
  325. opacity: opacity,
  326. map: texture,
  327. blending: THREE.AdditiveBlending,
  328. sizeAttenuation: sizeAttenuation,
  329. color: color
  330. });
  331.  
  332. var range = 40;
  333. for (var i = 0; i < 20; i++) {
  334. var particle = new THREE.Vector3(
  335. Math.random() * range - range / 2,
  336. Math.random() * range * 1.5,
  337. Math.random() * range - range / 2);
  338. particle.velocityY = 0.1 + Math.random() / 5;
  339. particle.velocityX = (Math.random() - 0.5) / 3;
  340. geom.vertices.push(particle);
  341. }
  342.  
  343. this.vcloud = new THREE.ParticleSystem(geom, material);
  344. this.vcloud.sortParticles = true;
  345.  
  346. this.vscene.add(this.vcloud);
  347. }
  348.  
  349. },
         //属性的一个实时计算
  350. computed:{
  351.  
  352. },
  353.  
  354. }
  355. </script>
  356.  
  357. <style lang="sass-loader" scoped>
  358. @import '../../../css/src/main.scss';
  359. </style>

未完待续。。。。。。

webpack2.0+ vue2.0的更多相关文章

  1. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之十二 || 三种跨域方式比较,DTOs(数据传输对象)初探

    更新反馈 1.博友@落幕残情童鞋说到了,Nginx反向代理实现跨域,因为我目前还没有使用到,给忽略了,这次记录下,为下次补充.此坑已填 2.提示:跨域的姊妹篇——<三十三║ ⅖ 种方法实现完美跨 ...

  2. Vuex2.0+Vue2.0构建备忘录应用实践

    一.介绍Vuex Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化,适合于构建中大型单页应用. ...

  3. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之四 || Swagger的使用 3.2

    前言 如果想直接在域名的根目录直接加载 swagger 比如访问:localhost:8001 就能访问,可以这样设置: app.UseSwaggerUI(c => { c.SwaggerEnd ...

  4. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之十三 || DTOs 对象映射使用,项目部署Windows+Linux完整版

    更新 很多小伙伴在用 IIS 发布的时候,总是会有一些问题,文章下边 #autoid-6-0-0 我也简单的动图展示了,如何 publish 到 IIS 的过程,如果你能看懂,却发现自己的项目有问题的 ...

  5. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之二 || 后端项目搭建

    前言 至于为什么要搭建.Net Core 平台,这个网上的解释以及铺天盖地,想了想,还是感觉重要的一点,跨平台,嗯!没错,而且比.Net 更容易搭建,速度也更快,所有的包均有Nuget提供,不再像以前 ...

  6. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之三 || Swagger的使用 3.1

    常见问题 1.经常有小伙伴遇到这个错误 这是因为接口json文档定义和调用不是一个 1.定义: ConfigureServices 方法中的  services.AddSwaggerGen 注册的一个 ...

  7. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之五 || Swagger的使用 3.3 JWT权限验证【必看】

    前言 关于JWT一共三篇 姊妹篇,内容分别从简单到复杂,一定要多看多想: 一.Swagger的使用 3.3 JWT权限验证[修改] 二.解决JWT权限验证过期问题 三.JWT完美实现权限与接口的动态分 ...

  8. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之六 || API项目整体搭建 6.1 仓储模式

    前言 1.@LearningCoding 小伙伴关于用Sqlsugar在mysql数据库上的研究成果: sqlsugarcore支持mysql等数据库,在DbContext里面只需要设置dbtype为 ...

  9. 从壹开始前后端分离【 .NET Core2.0 +Vue2.0 】框架之七 || API项目整体搭建 6.2 轻量级ORM

    更新 1.在使用的时候,特别是更新数据的时候,如果不知道哪里有问题,可以查看数据库 和 实体类 的字段,是否大小写一致,比如 name 和 Name 2.在使用Sqlsugar 的 CodeFirst ...

随机推荐

  1. 1015. [JSOI2008]星球大战【并查集】

    Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的 机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通 ...

  2. Java多线程和并发基础面试总结

    多线程和并发问题是Java技术面试中面试官比较喜欢问的问题之一.在这里,从面试的角度列出了大部分重要的问题,但是你仍然应该牢固的掌握Java多线程基础知识来对应日后碰到的问题.收藏起来,希望给予即将找 ...

  3. 02.Java入门

    Java 是SUN(Starfard University Network)公司在1995年开发的一门完全面向对象的,开源的高级编程语言. Java的发展历史 1995年诞生,1996年发布第一个版本 ...

  4. JS应该放在什么位置?

    (1)放在底部,虽然放在底部照样会阻塞所有呈现,但不会阻塞资源下载 (2)如果嵌入JS放在head中,请把嵌入JS放在CSS头部 (3)使用defer(只支持IE) (4)不要在嵌入的JS中调用运行时 ...

  5. c++——const关键字

    1 const基础知识(用法.含义.好处) int main() { const int a; int const b; const int *c; int * const d; const int ...

  6. 【PHP笔试题】

    1.以下脚本输出什么? $s = '12345'; $m = 'a2b1c'; $s[$s[$m]] = '3'; echo $s; [ ] A.12345 [ ] B.12235 [ ] C.223 ...

  7. Nginx与浏览器缓存

    Nginx与浏览器缓存 一.浏览器对缓存的处理:Internet选项 ★ 控制请求服务器策略:是忽略资源的缓存策略的情况下额外强制请求服务器的意思.  ★ 检查存储的页面较新版本 1.每次访问网页时  ...

  8. C++重载运算符练习--对people类重载“= =”运算符和“=”运算符

    题目描述 对people类重载“= =”运算符和“=”运算符,“==”运算符判断两个people类对象的id属性是否相等:“=”运算符实现people类对象的赋值操作. 代码如下 #include&l ...

  9. 浅析 golang interface 实现原理

    interface 在 golang 中是一个非常重要的特性.它相对于其它语言有很多优势: duck typing.大多数的静态语言需要显示的声明类型的继承关系.而 golang 通过 interfa ...

  10. 2017-2018-1 20155207&20155308《信息安全技术》实验四-木马及远程控制技术

    2017-2018-1 20155207&20155308<信息安全技术>实验四-木马及远程控制技术 实验目的 剖析网页木马的工作原理 理解木马的植入过程 学会编写简单的网页木马脚 ...