index.vue 19 KB

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