home.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>中科在线</title>
  6. <!-- layui -->
  7. <link rel="stylesheet" href="static/home/lib/layui/css/layui.css">
  8. <link rel="stylesheet" href="static/home/css/lib.css">
  9. <link rel="stylesheet" href="static/home/css/road.css">
  10. <link rel="stylesheet" href="static/home/css/index.css">
  11. <style>
  12. .canvas-stats {
  13. display: none;
  14. }
  15. #a{
  16. position: absolute;
  17. bottom: -20px;
  18. color: #fff;
  19. right: 0;
  20. }
  21. #a:hover{
  22. cursor: pointer;
  23. }
  24. .floating{
  25. width: 350px;
  26. height: 150px;
  27. background-image: url(./static/images/fuchuang.jpg);
  28. background-repeat: no-repeat;
  29. background-size: 100%;
  30. }
  31. .floatingInfo{
  32. color: #F6FE6A;
  33. text-align: center;
  34. height: 150px;
  35. padding: 40px 0;
  36. font-size: 30px;
  37. font-family: cursive;
  38. text-shadow: 5px 5px 5px #000;
  39. }
  40. .floatingInfo:hover{
  41. cursor: pointer;
  42. color: #76bdfe;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <div class="header">
  48. <a href="" style="display: none;">
  49. <div class="home-btn"></div>
  50. </a>
  51. <img class='image' src="static/images/logo.png" alt="">
  52. <p class='title'>中科在线</p>
  53. <!-- <p class='notice' >通知</p> -->
  54. </div>
  55. <img class="sci-wheel" src="static/home/images/sci.gif" alt="">
  56. <!-- 导航 -->
  57. <div class="center">
  58. <a class="list fn_1 moveUpDownFla1" target="_blank" href="market/index">
  59. <p>科技超市</p>
  60. </a>
  61. <a class="list fn_2 moveUpDownFla2" target="_blank" href="hallList/index">
  62. <p>直播大厅</p>
  63. </a>
  64. <a class="list fn_3 moveUpDownFla1" target="_blank" href="dynamic/index">
  65. <p>动态监测</p>
  66. </a>
  67. <a class="list fn_4 moveUpDownFla2" target="_blank" href="live/service">
  68. <p>创新服务</p>
  69. </a>
  70. <a class="list fn_5 moveUpDownFla2" target="_blank" href="technical/index">
  71. <p>技术交流</p>
  72. </a>
  73. </div>
  74. <!-- 浮窗 -->
  75. <div id="floatingDiv" style="position:absolute;left:50px;top:60px;z-index: 9999;">
  76. <div id="a" onClick="javascript:this.parentNode.style.display='none';">关闭窗口</div>
  77. <div class='floating' onclick="noticeBtn()">
  78. <p id="floatingid" class='floatingInfo'></p>
  79. </div>
  80. </div>
  81. <!--流星-->
  82. <div class="liuxing liuxing1 liuxingFla"></div>
  83. <div class="liuxing liuxing2 liuxingFla2"></div>
  84. <div class="liuxing liuxing3 liuxingFla3"></div>
  85. <div class="liuxing liuxing4 liuxingFla4"></div>
  86. <div id="canvas-container-1" class="canvas-container">
  87. <canvas id="canvas-1"></canvas>
  88. </div>
  89. <script src="static/home/js/stats.min.js"></script>
  90. <script src="static/home/js/three.min.js"></script>
  91. <script src="static/js/jquery-1.8.3.min.js"></script>
  92. <script>
  93. window.onload = function () {
  94. $.ajax({
  95. url:'/api/market/notice',
  96. type:"GET",
  97. contentType:'application/json',
  98. success:function(res){
  99. // console.log(res);
  100. if(res.errcode =='0') {
  101. if(res.data.length>0) {
  102. var head = res.data[0];
  103. $('#floatingid').text(head.title)
  104. }
  105. }
  106. },
  107. error:function (e) {
  108. console.error(e)
  109. }
  110. })
  111. }
  112. function ThreeJSCanvas(CANVAS_ID) {
  113. var SCREEN_HEIGHT = Math.min(window.innerWidth, window.innerHeight);
  114. var SCREEN_WIDTH = SCREEN_HEIGHT;
  115. var SCREEN_ASPECT_RATIO = SCREEN_WIDTH / SCREEN_HEIGHT;
  116. var canvas, container;
  117. var container, loader, stats;
  118. var renderer, camera, scene;
  119. var raycaster, controls;
  120. var ANIMATION_FRAME_LENGTH = 30,
  121. INTERACT_DISTANCE = 2.5;
  122. var objetArray = [],
  123. animationQueue = [];
  124. var color1 = [0 / 255, 110 / 255, 255 / 255],
  125. color2 = [0 / 255, 255 / 255, 140 / 255];
  126. var bitmap = [];
  127. var BITMAP_SKIP = 1;
  128. var fov = 90;
  129. var cameraPos = [0, 0, 30];
  130. var cameraLookAt = [0, 0, 0];
  131. var viewHeight = 2 * Math.tan(THREE.Math.degToRad(fov / 2)) * cameraPos[2],
  132. viewWidth = viewHeight * SCREEN_ASPECT_RATIO;
  133. var mouse = new THREE.Vector3(10000, 10000, -1),
  134. mouseScaled = new THREE.Vector3(10000, 10000, -1);
  135. var frame = 0;
  136. function init() {
  137. // Global Variables
  138. container = document.getElementById("canvas-container-" + CANVAS_ID);
  139. canvas = document.getElementById("canvas-" + CANVAS_ID);
  140. canvas.addEventListener('mousemove', onDocumentMouseMove, false);
  141. loader = new THREE.JSONLoader();
  142. stats = new Stats();
  143. stats.domElement.classList.add("canvas-stats");
  144. stats.domElement.id = "canvas-stats-" + CANVAS_ID;
  145. /* If you are familiar with python and opencv
  146. you can use this python script to generate custom bitmaps
  147. --------------------
  148. https://git.io/vdBAu
  149. --------------------
  150. */
  151. var data = '#000000000000000000011110000000000000000000' +
  152. '#000000000000000011111111110000000000000000' +
  153. '#000000000000001111111111111100000000000000' +
  154. '#000000000000011111111111111110000000000000' +
  155. '#000000000000111111111111111111000000000000' +
  156. '#000000000001111111111111111111100000000000' +
  157. '#000000000011111111111111111111110000000000' +
  158. '#000000000011111111111111111111110000000000' +
  159. '#000000000111111111111111111111111000000000' +
  160. '#000000000111111111111111111111111000000000' +
  161. '#000000001111111111111111111111111100000000' +
  162. '#000000001111111111111111111111111100000000' +
  163. '#000000001111111111111111111111111100000000' +
  164. '#000000001111111111111111111111111100000000' +
  165. '#000000001111111111111111111111111100000000' +
  166. '#000000000111111111111111111111111000000000' +
  167. '#000000000111111111111111111111111000000000' +
  168. '#000000000111111111111111111111111000000000' +
  169. '#000000000011111111111111111111110000000000' +
  170. '#000000000011111111111111111111110000000000' +
  171. '#000000000001111111111111111111100000000000' +
  172. '#000000000001111111111111111111100000000000' +
  173. '#000000000000111111111111111111000000000000' +
  174. '#000000000000111111111111111110000000000000' +
  175. '#000000000000011111111111111110000000000000' +
  176. '#000000000000001111111111111100000000000000' +
  177. '#000000000000001111111111111100000000000000' +
  178. '#000000000000001111111111111000000000000000' +
  179. '#000000000000000111111111111000000000000000' +
  180. '#000000000000000111111111111000000000000000' +
  181. '#000000000000000111111111111000000000000000' +
  182. '#000000000000000111111111111000000000000000' +
  183. '#000000000000000011111111110000000000000000' +
  184. '#000000000000000010000000010000000000000000' +
  185. '#000000000000000011111111110000000000000000' +
  186. '#000000000000000010000000010000000000000000' +
  187. '#000000000000000011111111110000000000000000' +
  188. '#000000000000000010000000010000000000000000' +
  189. '#000000000000000011111111110000000000000000' +
  190. '#000000000000000000100001000000000000000000' +
  191. '#000000000000000000110011000000000000000000' +
  192. '#000000000000000000011110000000000000000000';
  193. for (var i = 0; i < data.length; i++) {
  194. if (data[i] == '#') {
  195. bitmap.push([]);
  196. } else {
  197. bitmap[bitmap.length - 1].push(data[i] - '0');
  198. }
  199. }
  200. container.appendChild(stats.domElement);
  201. // Renderer
  202. renderer = new THREE.WebGLRenderer({
  203. alpha: true,
  204. antialias: true,
  205. canvas: canvas,
  206. });
  207. renderer.setClearColor(0x212121, 0);
  208. renderer.setPixelRatio(window.devicePixelRatio);
  209. renderer.shadowMap.enabled = true;
  210. renderer.shadowMap.type = THREE.PCFSoftShadowMap;
  211. renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
  212. // Camera and Controls
  213. camera = new THREE.PerspectiveCamera(fov, SCREEN_ASPECT_RATIO, 0.1, 1000);
  214. // camera = new THREE.OrthographicCamera(-viewWidth, viewWidth, viewHeight, -viewHeight, 1, 300);
  215. camera.position.set(cameraPos[0], cameraPos[1], cameraPos[2]);
  216. camera.lookAt(new THREE.Vector3(cameraLookAt[0], cameraLookAt[1], cameraLookAt[2]));
  217. raycaster = new THREE.Raycaster();
  218. // controls = new THREE.OrbitControls(camera);
  219. // controls.rotateSpeed = 2.0;
  220. // controls.zoomSpeed = 2.0;
  221. // controls.enableZoom = true;
  222. // controls.enablePan = true;
  223. // controls.dampingFactor = 0.2;
  224. // controls.addEventListener('change', render);
  225. //Scene
  226. scene = new THREE.Scene();
  227. //Lights
  228. // Making Object Array
  229. var xOffset = -bitmap[0].length / (BITMAP_SKIP * 2);
  230. var yOffset = bitmap.length / (BITMAP_SKIP * 2);
  231. for (var i = 0; i < bitmap.length; i += BITMAP_SKIP) {
  232. for (var j = 0; j < bitmap[i].length; j += BITMAP_SKIP) {
  233. if (bitmap[i][j] == 1) {
  234. planeGeometry = new THREE.PlaneGeometry(1, 1);
  235. var circleGeometry = new THREE.CircleGeometry(1, 5);
  236. var frac = i / bitmap.length;
  237. // Materials
  238. planeMaterial = new THREE.MeshBasicMaterial({
  239. color: new THREE.Color(
  240. color1[0] * frac + color2[0] * (1 - frac),
  241. color1[1] * frac + color2[1] * (1 - frac),
  242. color1[2] * frac + color2[2] * (1 - frac)
  243. ),
  244. transparent: true,
  245. opacity: THREE.Math.randFloat(0.4, 0.6),
  246. side: THREE.DoubleSide
  247. });
  248. var circleMaterial = new THREE.MeshBasicMaterial({
  249. color: new THREE.Color(1, 1, 1),
  250. transparent: true,
  251. opacity: THREE.Math.randFloat(0.8, 1),
  252. side: THREE.DoubleSide
  253. });
  254. // Mesh
  255. planeMesh = new THREE.Mesh(planeGeometry, planeMaterial);
  256. planeMesh.position.set(xOffset + j / BITMAP_SKIP, yOffset - i / BITMAP_SKIP, 0);
  257. var randWidth = THREE.Math.randFloat(0.6, 1.2);
  258. var randHeight = randWidth
  259. planeMesh.scale.set(randWidth, randHeight, 1);
  260. scene.add(planeMesh);
  261. objetArray.push([planeMesh, false]);
  262. circleMesh = new THREE.Mesh(circleGeometry, circleMaterial);
  263. circleMesh.position.set(xOffset + j / BITMAP_SKIP + THREE.Math.randFloat(-0.5, 0.5), yOffset - i / BITMAP_SKIP + THREE.Math.randFloat(-0.5, 0.5), 0.1);
  264. var randRadius = THREE.Math.randFloat(0.05, 0.1);
  265. circleMesh.scale.set(randRadius, randRadius, 1);
  266. scene.add(circleMesh);
  267. objetArray.push([circleMesh, false]);
  268. }
  269. }
  270. }
  271. //Geometry
  272. // Materials
  273. // Mesh
  274. // Helpers
  275. //Add Stuff to Scene
  276. }
  277. function animate() {
  278. requestAnimationFrame(animate);
  279. render();
  280. stats.update();
  281. // controls.update();
  282. frame++;
  283. }
  284. function render() {
  285. while (animationQueue.length > 0) {
  286. var obj_index = animationQueue[0][0];
  287. var ani_frame = animationQueue[0][1];
  288. if (ani_frame > ANIMATION_FRAME_LENGTH) {
  289. objetArray[obj_index][1] = false;
  290. animationQueue.shift();
  291. } else {
  292. break;
  293. }
  294. }
  295. for (var i = 0; i < objetArray.length; i++) {
  296. var obj = objetArray[i][0];
  297. var isAnimating = objetArray[i][1];
  298. if (isAnimating == false) {
  299. var px = obj.position.x;
  300. var py = obj.position.y;
  301. var dist = Math.sqrt(Math.pow(px - mouseScaled.x, 2) + Math.pow(py - mouseScaled.y, 2));
  302. if (dist < INTERACT_DISTANCE) {
  303. var startPosVector = obj.position.clone();
  304. var mouseRepelVector = new THREE.Vector3().subVectors(startPosVector, mouseScaled).multiplyScalar(THREE.Math.randFloat(INTERACT_DISTANCE + 0.5, INTERACT_DISTANCE + 2) - dist);
  305. var endPosVector = new THREE.Vector3().addVectors(startPosVector, mouseRepelVector);
  306. animationQueue.push([i, 0, startPosVector, endPosVector]);
  307. objetArray[i][1] = true;
  308. }
  309. }
  310. }
  311. for (var i = 0; i < animationQueue.length; i++) {
  312. var obj = objetArray[animationQueue[i][0]][0];
  313. var ani_frame = animationQueue[i][1];
  314. var startPosVector = animationQueue[i][2];
  315. var endPosVector = animationQueue[i][3];
  316. var curPosVector = new THREE.Vector3();
  317. var frac = 1 - Math.abs(ani_frame - (ANIMATION_FRAME_LENGTH / 2)) / (ANIMATION_FRAME_LENGTH / 2);
  318. frac = easeOutQuad(frac);
  319. curPosVector.lerpVectors(startPosVector, endPosVector, frac);
  320. obj.position.x = curPosVector.x;
  321. obj.position.y = curPosVector.y;
  322. obj.position.z = curPosVector.z;
  323. animationQueue[i][1] += 1;
  324. }
  325. mouse = new THREE.Vector3(10000, 10000, -2);
  326. mouseScaled = new THREE.Vector3(10000, 10000, -2);
  327. renderer.render(scene, camera);
  328. }
  329. function onWindowResize() {
  330. SCREEN_HEIGHT = Math.min(window.innerWidth, window.innerHeight);
  331. SCREEN_WIDTH = SCREEN_HEIGHT;
  332. SCREEN_ASPECT_RATIO = SCREEN_WIDTH / SCREEN_HEIGHT;
  333. camera.aspect = SCREEN_ASPECT_RATIO;
  334. camera.updateProjectionMatrix();
  335. renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
  336. console.log(SCREEN_WIDTH + "x" + SCREEN_HEIGHT)
  337. }
  338. function onDocumentMouseMove(event) {
  339. var rect = canvas.getBoundingClientRect();
  340. mouse.x = event.clientX - rect.left;
  341. mouse.y = event.clientY - rect.top;
  342. mouseScaled.x = mouse.x * viewWidth / SCREEN_WIDTH - viewWidth / 2;
  343. mouseScaled.y = -mouse.y * viewHeight / SCREEN_HEIGHT + viewHeight / 2;
  344. }
  345. function sigmoid(t) {
  346. return 1 / (1 + Math.pow(Math.E, -t));
  347. }
  348. // no easing, no acceleration
  349. function linear(t) {
  350. return t;
  351. }
  352. // accelerating from zero velocity
  353. function easeInQuad(t) {
  354. return t * t;
  355. }
  356. // decelerating to zero velocity
  357. function easeOutQuad(t) {
  358. return t * (2 - t);
  359. }
  360. // acceleration until halfway, then deceleration
  361. function easeInOutQuad(t) {
  362. return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
  363. }
  364. // accelerating from zero velocity
  365. function easeInCubic(t) {
  366. return t * t * t;
  367. }
  368. // decelerating to zero velocity
  369. function easeOutCubic(t) {
  370. return (--t) * t * t + 1;
  371. }
  372. // acceleration until halfway, then deceleration
  373. function easeInOutCubic(t) {
  374. return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
  375. }
  376. // accelerating from zero velocity
  377. function easeInQuart(t) {
  378. return t * t * t * t;
  379. }
  380. // decelerating to zero velocity
  381. function easeOutQuart(t) {
  382. return 1 - (--t) * t * t * t;
  383. }
  384. // acceleration until halfway, then deceleration
  385. function easeInOutQuart(t) {
  386. return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t;
  387. }
  388. // accelerating from zero velocity
  389. function easeInQuint(t) {
  390. return t * t * t * t * t;
  391. }
  392. // decelerating to zero velocity
  393. function easeOutQuint(t) {
  394. return 1 + (--t) * t * t * t * t;
  395. }
  396. // acceleration until halfway, then deceleration
  397. function easeInOutQuint(t) {
  398. return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t;
  399. }
  400. //Event Handlers
  401. window.addEventListener("resize", onWindowResize);
  402. init();
  403. animate();
  404. }
  405. ThreeJSCanvas(1);
  406. </script>
  407. <script>
  408. function noticeBtn() {
  409. window.location.href="../platlive/notice/index"
  410. }
  411. </script>
  412. <script>
  413. var xin = true,
  414. yin = true;
  415. var step = 2;
  416. var delay = 10;
  417. var $obj;
  418. $(function () {
  419. $obj = $('#floatingDiv');
  420. var time = window.setInterval('move()', delay);
  421. $obj.mouseover(function () {
  422. clearInterval(time);
  423. });
  424. $obj.mouseout(function () {
  425. time = window.setInterval('move()', delay);
  426. });
  427. });
  428. function move() {
  429. var left = $obj.offset().left;
  430. // console.log(left);
  431. var top = $obj.offset().top;
  432. var L = (T = 0); //左边界和顶部边界
  433. var R = $(window).width() - $obj.width(); // 右边界
  434. var B = $(window).height() - $obj.height(); //下边界
  435. //难点:怎样判断广告的4个边框有没有超出可视化范围!
  436. if (left < L) {
  437. xin = true; // 水平向右移动
  438. }
  439. if (left > R) {
  440. xin = false;
  441. }
  442. if (top < T) {
  443. yin = true;
  444. }
  445. if (top > B) {
  446. yin = false;
  447. }
  448. //根据有没有超出范围来确定广告的移动方向
  449. left += step * (xin == true ? 1 : -1);
  450. top += step * (yin == true ? 1 : -1);
  451. // 给div 元素重新定位
  452. $obj.offset({
  453. top: top,
  454. left: left,
  455. });
  456. }
  457. </script>
  458. </body>
  459. <!-- layui -->
  460. <script type="text/javascript" src="static/home/lib/layui/layui.all.js"></script>
  461. </html>