home.html 18 KB

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