index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <div>
  3. <template v-if="notWebgl"></template>
  4. <template v-else>
  5. <canvas id="output"></canvas>
  6. <div class="wrapper">
  7. <div class="header">
  8. <span class="logo">NUTUI
  9. <s></s>
  10. </span>
  11. <search/>
  12. <div class="menu">
  13. <ul>
  14. <li>
  15. <a href="#/doc">指南</a>
  16. </li>
  17. <li>
  18. <a href="#/ActionSheet">组件</a>
  19. </li>
  20. <li>
  21. <a href="/demo.html#/index" class="qrcode top-qr" target="_blank">示例
  22. <a>
  23. <span>请使用手机扫码体验</span>
  24. <img
  25. src="http://img13.360buyimg.com/uba/jfs/t1/14144/37/3433/5890/5c26d976E7cd98b80/94583409233081cc.png"
  26. alt
  27. >
  28. </a>
  29. </a>
  30. </li>
  31. </ul>
  32. <select @change="openwindow">
  33. <option value="2">2.X</option>
  34. <option value="1">1.X</option>
  35. </select>
  36. <a href="https://github.com/jdf2e/nutui" title="Github" target="_blank" class="github-icon">github</a>
  37. </div>
  38. </div>
  39. <div class="content">
  40. <div class="mouseDiv" id="mouseDiv"></div>
  41. <p class="title">NutUI</p>
  42. <p class="sub-title">一套轻量级移动端Vue / 微信小程序组件库</p>
  43. <a href="#/doc" class="blue-btn">开始使用</a>
  44. <a href="javascript:;" class="qrcode btn">
  45. 扫码体验
  46. <a>
  47. <span>请使用手机扫码体验</span>
  48. <img
  49. src="http://img13.360buyimg.com/uba/jfs/t1/14144/37/3433/5890/5c26d976E7cd98b80/94583409233081cc.png"
  50. alt
  51. >
  52. </a>
  53. </a>
  54. </div>
  55. </div>
  56. </template>
  57. </div>
  58. </template>
  59. <script>
  60. import * as THREE from "three";
  61. import TWEEN from "@tweenjs/tween.js";
  62. import Detector from "./asset/js/Detector.js";
  63. import search from './search.vue';
  64. export default {
  65. name: "frontCover",
  66. data() {
  67. return {
  68. timer: null,
  69. notWebgl: true
  70. };
  71. },
  72. components:{
  73. search
  74. },
  75. methods: {
  76. openwindow(val) {
  77. if (val.target.value == 1) {
  78. window.location.href = " http://nutui.jd.com/1x/";
  79. }
  80. },
  81. threeAnimation() {
  82. this.timer = setTimeout(() => {
  83. //获取视窗宽高
  84. var mouseX = 0,
  85. mouseY = 0;
  86. var SCREEN_HEIGHT = window.innerHeight;
  87. var SCREEN_WIDTH = window.innerWidth;
  88. var tween;
  89. var planeObj = {
  90. x: 450,
  91. y: 80
  92. };
  93. //渲染器(render)
  94. var renderer = new THREE.WebGLRenderer({
  95. canvas: document.getElementById("output")
  96. });
  97. //设置背景颜色
  98. renderer.setClearColor(0xffffff, 1.0);
  99. renderer.setPixelRatio(window.devicePixelRatio);
  100. renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
  101. //场景(Scene)
  102. var scene = new THREE.Scene();
  103. //透视投影相机
  104. var camera = new THREE.PerspectiveCamera(
  105. 45,
  106. SCREEN_WIDTH / SCREEN_HEIGHT,
  107. 1,
  108. 10000
  109. );
  110. camera.position.set(0, 0, 1300);
  111. camera.lookAt(scene.position);
  112. scene.add(camera);
  113. //光源
  114. var ambientLight = new THREE.AmbientLight("#468be8");
  115. scene.add(ambientLight);
  116. ambientLight.color.setHex(0xffffff);
  117. //背景蓝色
  118. var texture = new THREE.TextureLoader().load(
  119. "//img12.360buyimg.com/uba/jfs/t1/22824/40/3136/6504/5c24a3f4E76fdafde/802d02d1ec5d3d55.png"
  120. );
  121. var material = new THREE.MeshBasicMaterial({
  122. map: texture,
  123. transparent: true
  124. });
  125. var geometry = new THREE.PlaneBufferGeometry(1174, 923);
  126. //货物箱
  127. var texture1 = new THREE.TextureLoader().load(
  128. "//img14.360buyimg.com/uba/jfs/t1/21115/40/3224/5652/5c24a411E03ef9eb6/83781b97e59da905.png"
  129. );
  130. var material1 = new THREE.MeshBasicMaterial({
  131. map: texture1,
  132. transparent: true
  133. });
  134. var geometry1 = new THREE.PlaneBufferGeometry(146, 206);
  135. //人物
  136. var texture2 = new THREE.TextureLoader().load(
  137. "//img12.360buyimg.com/uba/jfs/t1/9330/16/10894/8662/5c24a42aE708692b3/14455d20eca1ccee.png"
  138. );
  139. var material2 = new THREE.MeshBasicMaterial({
  140. map: texture2,
  141. transparent: true
  142. });
  143. var geometry2 = new THREE.PlaneBufferGeometry(230, 417);
  144. //phone
  145. var texture3 = new THREE.TextureLoader().load(
  146. "//img10.360buyimg.com/uba/jfs/t1/19171/19/3175/23282/5c24a440Ee2a94261/45321aeaf173f237.png"
  147. );
  148. var material3 = new THREE.MeshBasicMaterial({
  149. map: texture3,
  150. transparent: true
  151. });
  152. var geometry3 = new THREE.PlaneBufferGeometry(284, 524);
  153. //flower
  154. var texture4 = new THREE.TextureLoader().load(
  155. "//img13.360buyimg.com/uba/jfs/t1/20972/11/3212/7155/5c24a45aE356f126d/2649726673daddc8.png"
  156. );
  157. var material4 = new THREE.MeshBasicMaterial({
  158. map: texture4,
  159. transparent: true
  160. });
  161. var geometry4 = new THREE.PlaneBufferGeometry(257, 193);
  162. //nut
  163. var texture5 = new THREE.TextureLoader().load(
  164. "//img14.360buyimg.com/uba/jfs/t1/21247/15/3196/859/5c24a472E1e9853ab/6bec8c6940288bc3.png"
  165. );
  166. var material5 = new THREE.MeshPhongMaterial({
  167. map: texture5,
  168. transparent: true,
  169. opacity: 1
  170. });
  171. var geometry5 = new THREE.PlaneBufferGeometry(57, 57);
  172. //fly
  173. var texture6 = new THREE.TextureLoader().load(
  174. "//img14.360buyimg.com/uba/jfs/t1/7300/6/10801/16348/5c24a487E98a8139b/27b70ff5b4ddaf1f.png"
  175. );
  176. var material6 = new THREE.MeshBasicMaterial({
  177. map: texture6,
  178. transparent: true,
  179. opacity: 0
  180. });
  181. var geometry6 = new THREE.PlaneBufferGeometry(851, 597);
  182. //flyContents
  183. var fly_texture_1_1 = new THREE.TextureLoader().load(
  184. "//img14.360buyimg.com/uba/jfs/t1/24669/35/3260/1611/5c24a4a9E4e0941ab/65a238650812a7a9.png"
  185. );
  186. var fly_materila_1_1 = new THREE.MeshBasicMaterial({
  187. map: fly_texture_1_1,
  188. transparent: true,
  189. opacity: 0
  190. });
  191. fly_materila_1_1.side = THREE.DoubleSide;
  192. var fly_geometry_1_1 = new THREE.PlaneBufferGeometry(77, 77);
  193. var fly_texture_1_2 = new THREE.TextureLoader().load(
  194. "//img10.360buyimg.com/uba/jfs/t1/16477/11/3111/645/5c24a4beE3668b9c1/f7f0b074baab071c.png"
  195. );
  196. var fly_materila_1_2 = new THREE.MeshBasicMaterial({
  197. map: fly_texture_1_2,
  198. transparent: true,
  199. opacity: 0
  200. });
  201. fly_materila_1_2.side = THREE.DoubleSide;
  202. var fly_geometry_1_2 = new THREE.PlaneBufferGeometry(54, 45);
  203. var fly_texture_2_1 = new THREE.TextureLoader().load(
  204. "//img12.360buyimg.com/uba/jfs/t1/8267/36/10934/1385/5c24a4d2E036f7ef1/d88f41ccd8d8f409.png"
  205. );
  206. var fly_materila_2_1 = new THREE.MeshBasicMaterial({
  207. map: fly_texture_2_1,
  208. transparent: true,
  209. opacity: 0
  210. });
  211. fly_materila_2_1.side = THREE.DoubleSide;
  212. var fly_geometry_2_1 = new THREE.PlaneBufferGeometry(103, 74);
  213. var fly_texture_2_2 = new THREE.TextureLoader().load(
  214. "//img20.360buyimg.com/uba/jfs/t1/9695/33/10662/1607/5c24a4e4Ee2f9bab1/18c829d3e46efc4e.png"
  215. );
  216. var fly_materila_2_2 = new THREE.MeshBasicMaterial({
  217. map: fly_texture_2_2,
  218. transparent: true,
  219. opacity: 0
  220. });
  221. fly_materila_2_2.side = THREE.DoubleSide;
  222. var fly_geometry_2_2 = new THREE.PlaneBufferGeometry(69, 79);
  223. var fly_texture_3_1 = new THREE.TextureLoader().load(
  224. "//img12.360buyimg.com/uba/jfs/t1/27128/26/3128/1206/5c24a4faEb2c39e88/825abcfc5fc19761.png"
  225. );
  226. var fly_materila_3_1 = new THREE.MeshBasicMaterial({
  227. map: fly_texture_3_1,
  228. transparent: true,
  229. opacity: 0
  230. });
  231. fly_materila_3_1.side = THREE.DoubleSide;
  232. var fly_geometry_3_1 = new THREE.PlaneBufferGeometry(52, 53);
  233. var fly_texture_3_2 = new THREE.TextureLoader().load(
  234. "//img12.360buyimg.com/uba/jfs/t1/29872/1/3250/1154/5c24a50eE15e06d48/2412d3d556bf7463.png"
  235. );
  236. var fly_materila_3_2 = new THREE.MeshBasicMaterial({
  237. map: fly_texture_3_2,
  238. transparent: true,
  239. opacity: 0
  240. });
  241. fly_materila_3_2.side = THREE.DoubleSide;
  242. var fly_geometry_3_2 = new THREE.PlaneBufferGeometry(73, 73);
  243. var plane = new THREE.Mesh(geometry, material);
  244. plane.position.x = 450;
  245. plane.position.y = 80;
  246. scene.add(plane);
  247. var plane1 = new THREE.Mesh(geometry1, material1);
  248. plane1.position.x = 220;
  249. plane1.position.y = -170;
  250. scene.add(plane1);
  251. var plane3 = new THREE.Mesh(geometry3, material3);
  252. plane3.position.x = 570;
  253. plane3.position.y = -12;
  254. scene.add(plane3);
  255. var plane5 = new THREE.Mesh(geometry5, material5);
  256. plane5.position.x = 505;
  257. plane5.position.y = 147;
  258. scene.add(plane5);
  259. var plane2 = new THREE.Mesh(geometry2, material2);
  260. plane2.position.x = 420;
  261. plane2.position.y = -65;
  262. scene.add(plane2);
  263. var plane4 = new THREE.Mesh(geometry4, material4);
  264. plane4.position.x = 770;
  265. plane4.position.y = -175;
  266. scene.add(plane4);
  267. var plane6 = new THREE.Mesh(geometry6, material6);
  268. plane6.position.x = 498;
  269. plane6.position.y = 23;
  270. scene.add(plane6);
  271. var planeFly_1_1 = new THREE.Mesh(fly_geometry_1_1, fly_materila_1_1);
  272. planeFly_1_1.position.x = 305;
  273. planeFly_1_1.position.y = 220;
  274. scene.add(planeFly_1_1);
  275. var planeFly_1_2 = new THREE.Mesh(fly_geometry_1_2, fly_materila_1_2);
  276. planeFly_1_2.position.x = 385;
  277. planeFly_1_2.position.y = 225;
  278. scene.add(planeFly_1_2);
  279. var planeFly_2_1 = new THREE.Mesh(fly_geometry_2_1, fly_materila_2_1);
  280. planeFly_2_1.position.x = 770;
  281. planeFly_2_1.position.y = 20;
  282. scene.add(planeFly_2_1);
  283. var planeFly_2_2 = new THREE.Mesh(fly_geometry_2_2, fly_materila_2_2);
  284. planeFly_2_2.position.x = 820;
  285. planeFly_2_2.position.y = 90;
  286. scene.add(planeFly_2_2);
  287. var planeFly_3_1 = new THREE.Mesh(fly_geometry_3_1, fly_materila_3_1);
  288. planeFly_3_1.position.x = 500;
  289. planeFly_3_1.position.y = -130;
  290. scene.add(planeFly_3_1);
  291. var planeFly_3_2 = new THREE.Mesh(fly_geometry_3_2, fly_materila_3_2);
  292. planeFly_3_2.position.x = 350;
  293. planeFly_3_2.position.y = -200;
  294. scene.add(planeFly_3_2);
  295. var flyTweenParams = {
  296. x: 565,
  297. y: 147,
  298. op: 0,
  299. r: 70,
  300. g: 139,
  301. b: 232
  302. };
  303. var flyTween = new TWEEN.Tween(flyTweenParams)
  304. .easing(TWEEN.Easing.Quadratic.Out)
  305. .to({ x: 505, y: 147, op: 1, r: 255, g: 255, b: 255 }, 3000)
  306. .onUpdate(function(p) {
  307. plane5.position.x = p.x;
  308. plane5.position.y = p.y;
  309. material5.opacity = p.op;
  310. ambientLight.color.setRGB(p.r / 255, p.g / 255, p.b / 255);
  311. })
  312. .start();
  313. var flyTweenBack = new TWEEN.Tween(flyTweenParams)
  314. .easing(TWEEN.Easing.Quadratic.Out)
  315. .to({ x: 565, y: 147, op: 0, r: 70, g: 139, b: 232 }, 3000)
  316. .onUpdate(function(p) {
  317. plane5.position.x = p.x;
  318. plane5.position.y = p.y;
  319. material5.opacity = p.op;
  320. ambientLight.color.setRGB(p.r / 255, p.g / 255, p.b / 255);
  321. });
  322. var flyContentsOp = {
  323. op: 0
  324. };
  325. var flyContentTween = new TWEEN.Tween(flyContentsOp)
  326. .easing(TWEEN.Easing.Quadratic.Out)
  327. .to({ op: 1 }, 2500)
  328. .onUpdate(function(p) {
  329. fly_materila_1_1.opacity = fly_materila_1_2.opacity = fly_materila_2_1.opacity = fly_materila_2_2.opacity = fly_materila_3_1.opacity = fly_materila_3_2.opacity = material6.opacity =
  330. p.op;
  331. });
  332. var flyContentTweenBack = new TWEEN.Tween(flyContentsOp)
  333. .easing(TWEEN.Easing.Quadratic.Out)
  334. .to({ op: 0 }, 2000)
  335. .onUpdate(function(p) {
  336. fly_materila_1_1.opacity = fly_materila_1_2.opacity = fly_materila_2_1.opacity = fly_materila_2_2.opacity = fly_materila_3_1.opacity = fly_materila_3_2.opacity = material6.opacity =
  337. p.op;
  338. });
  339. flyTween.chain(flyContentTween);
  340. //flyContentTween.chain(flyTween);
  341. flyContentTween.chain(flyContentTweenBack);
  342. flyContentTweenBack.chain(flyTweenBack);
  343. flyTweenBack.chain(flyTween);
  344. //flyContentTweenBack.chain(flyContentTween);
  345. //监听事件
  346. document
  347. .querySelector("#mouseDiv")
  348. .addEventListener("mousemove", onDocumentMouseMove, false);
  349. window.addEventListener("resize", onWindowResize, false);
  350. var timer = null;
  351. function onWindowResize(event) {
  352. SCREEN_HEIGHT = window.innerHeight;
  353. SCREEN_WIDTH = window.innerWidth;
  354. camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
  355. camera.updateProjectionMatrix();
  356. renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
  357. }
  358. function onDocumentMouseMove(event) {
  359. clearTimeout(timer);
  360. timer = setTimeout(function() {
  361. if (tween) {
  362. tween.stop();
  363. }
  364. if (event.clientX - mouseX > 100) {
  365. tween = new TWEEN.Tween(planeObj)
  366. .easing(TWEEN.Easing.Quadratic.Out)
  367. .to({ x: 520, y: 150 }, 1000)
  368. .onUpdate(function(p) {
  369. plane.position.x = p.x;
  370. plane.position.y = p.y;
  371. })
  372. .start();
  373. } else if (event.clientX - mouseX < -100) {
  374. tween = new TWEEN.Tween(planeObj)
  375. .easing(TWEEN.Easing.Quadratic.Out)
  376. .to({ x: 450, y: 80 }, 1000)
  377. .onUpdate(function(p) {
  378. plane.position.x = p.x;
  379. plane.position.y = p.y;
  380. })
  381. .start();
  382. }
  383. tween.start();
  384. mouseX = event.clientX;
  385. mouseY = event.clientY;
  386. }, 100);
  387. }
  388. function render() {
  389. var timer = Date.now() * 0.0001;
  390. requestAnimationFrame(render);
  391. TWEEN.update();
  392. //渲染,输出
  393. renderer.render(scene, camera);
  394. }
  395. render();
  396. });
  397. }
  398. },
  399. watch: {},
  400. computed: {},
  401. created() {},
  402. mounted() {
  403. this.$nextTick(() => {
  404. if (!Detector.webgl) {
  405. //Detector.addGetWebGLMessage();
  406. } else {
  407. this.notWebgl = false;
  408. this.threeAnimation();
  409. }
  410. });
  411. },
  412. destroyed() {}
  413. };
  414. </script>
  415. <style lang="scss" scoped>
  416. .wrapper {
  417. position: fixed;
  418. top: 0;
  419. right: 0;
  420. bottom: 0;
  421. left: 0;
  422. .header {
  423. top: 0;
  424. min-width: 990px;
  425. width: 100%;
  426. z-index: 999;
  427. height: 64px;
  428. display: flex;
  429. align-items:center;
  430. }
  431. .menu {
  432. position: absolute;
  433. top: 0;
  434. right: 14%;
  435. width: 376px;
  436. font-size: 12px;
  437. li {
  438. float: left;
  439. width: 70px;
  440. text-align: center;
  441. height: 64px;
  442. line-height: 64px;
  443. cursor: pointer;
  444. color: #fff;
  445. a {
  446. color: #fff;
  447. text-decoration: none;
  448. }
  449. }
  450. select {
  451. width: 74px;
  452. height: 28px;
  453. margin-top: 18px;
  454. margin-left: 20px;
  455. font-size: 12px;
  456. }
  457. li:hover {
  458. border-bottom: 2px solid #fff;
  459. }
  460. .github-icon {
  461. display: inline-block;
  462. height: 26px;
  463. width: 26px;
  464. font-size: 0;
  465. background: url("./asset/css/i/github.png") 0 0 no-repeat;
  466. vertical-align: middle;
  467. position: relative;
  468. top: -1px;
  469. margin-left: 35px;
  470. cursor: pointer;
  471. }
  472. }
  473. .logo {
  474. height: 100%;
  475. line-height: 64px;
  476. float: left;
  477. width: 245px;
  478. font-size: 0;
  479. position: relative;
  480. s {
  481. background: url(./asset/css/i/nut.png) 0 0 no-repeat;
  482. background-size:contain;
  483. height: 46px;
  484. width: 120px;
  485. display: inline-block;
  486. position: absolute;
  487. top: 50%;
  488. left: 50px;
  489. margin-top: -23px;
  490. }
  491. }
  492. .search {
  493. margin: 20px 0;
  494. display: inline-block;
  495. border-left: 1px solid #d8d8d8;
  496. padding-left: 84px;
  497. position: relative;
  498. &:before {
  499. content: "";
  500. display: inline-block;
  501. background: url(./asset/css/i/search.png) 0 0 no-repeat;
  502. height: 22px;
  503. width: 22px;
  504. position: absolute;
  505. top: 50%;
  506. margin-top: -11px;
  507. left: 40px;
  508. }
  509. .search-input {
  510. border: none;
  511. height: 24px;
  512. line-height: 24px;
  513. font-size: 12px;
  514. outline: none;
  515. width: 200px;
  516. background: transparent;
  517. }
  518. }
  519. .content {
  520. padding: 250px 0 0 8.8%;
  521. z-index: 999;
  522. position: relative;
  523. .mouseDiv {
  524. height: 300px;
  525. width: 500px;
  526. //background:#ccc;
  527. position: absolute;
  528. top: 50%;
  529. left: 50%;
  530. margin-left: -250px;
  531. margin-top: -50px;
  532. }
  533. .title {
  534. font-size: 42px;
  535. color: #333;
  536. font-weight: bold;
  537. }
  538. .sub-title {
  539. font-size: 24px;
  540. color: #333;
  541. padding-top: 30px;
  542. padding-bottom: 100px;
  543. }
  544. .btn,
  545. .blue-btn {
  546. border: 1px solid #5396ff;
  547. color: #5396ff;
  548. width: 130px;
  549. height: 40px;
  550. line-height: 40px;
  551. text-align: center;
  552. display: inline-block;
  553. font-size: 14px;
  554. text-decoration: none;
  555. border-radius: 20px;
  556. }
  557. .blue-btn {
  558. color: #fff;
  559. background: #5396ff;
  560. margin-right: 40px;
  561. }
  562. }
  563. .qrcode {
  564. background: none;
  565. width: auto;
  566. margin: 0;
  567. opacity: 1;
  568. &.top-qr {
  569. a {
  570. left: -88px;
  571. }
  572. }
  573. a {
  574. position: absolute; //display: none;
  575. top: 44px;
  576. width: 200px;
  577. height: 240px;
  578. transform: scale(0.5);
  579. transform-origin: 50% top 0;
  580. transition: all 100ms ease-in-out 50ms;
  581. background: url("./asset/css/i/kuang.png") no-repeat;
  582. background-size: 200px;
  583. text-decoration: none;
  584. font-style: normal;
  585. text-align: center;
  586. left: -35px;
  587. overflow: hidden;
  588. pointer-events: none;
  589. span {
  590. display: block;
  591. overflow: hidden;
  592. color: #666;
  593. font-size: 14px;
  594. text-align: center;
  595. height: 45px;
  596. width: 100%;
  597. line-height: 60px;
  598. }
  599. img {
  600. opacity: 0.8;
  601. width: 166px;
  602. height: 166px;
  603. }
  604. }
  605. &:hover {
  606. opacity: 1;
  607. a {
  608. display: inline-block;
  609. opacity: 1;
  610. transform: scale(1);
  611. }
  612. }
  613. }
  614. }
  615. </style>