index.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  5. <meta http-equiv="Content-Language" content="utf-8" />
  6. <title></title>
  7. <meta content="all" name="robots" />
  8. <meta name="description" content="" />
  9. <meta name="keywords" content="" />
  10. <meta name="filetype" content="1" />
  11. <meta name="publishedtype" content="1" />
  12. <meta name="pagetype" content="2" />
  13. <meta name="catalogs" content="" />
  14. <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
  15. <!--优先使用 IE 最新版本和 Chrome-->
  16. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  17. <!--360 使用Google Chrome Frame-->
  18. <meta name="renderer" content="webkit">
  19. <script src="static/libs/jquery-1.11.1.min.js" type="text/javascript"></script>
  20. <link href="static/libs/swiper.min.css" rel="stylesheet">
  21. <link href="static/css/default.css" rel="stylesheet">
  22. <script src="static/libs/swiper.min.js"></script>
  23. <link rel="stylesheet" href="./static/css/main.css" charset="utf-8">
  24. <style>
  25. .slide2 .img3{top:50%;transform: translate(-50%,-50%);}
  26. .img3-1{width: 58.33333vw;}
  27. .sxdeg{position: absolute;
  28. color: #fff;
  29. right: 6.9vw;
  30. font-size: 22px;
  31. top: 48%;}
  32. .zydeg{ position: absolute; color: #fff;
  33. font-size: 22px;
  34. left: 50%;
  35. bottom: 5vw;
  36. transform: translateX(-50%);}
  37. .slide2 .img4{z-index: 1}
  38. </style>
  39. </head>
  40. <body>
  41. <div class="swiper-container swiper1">
  42. <div class="swiper-wrapper">
  43. <div class="swiper-slide slide1 swiper-no-swiping">
  44. <div class="d1">
  45. <img class="img1" src="static/images/text.png" alt="">
  46. </div>
  47. <div class="d2">
  48. <img class="yuan" src="static/images/tip1.png" alt="">
  49. <img class="yuan2" src="static/images/tip3.png" alt="">
  50. <img class="img2" src="static/images/tip2.png" alt="">
  51. </div>
  52. <div class="d3">
  53. <img class="yx" src="static/images/yx.png" alt="">
  54. </div>
  55. </div>
  56. <div class="swiper-slide slide2 swiper-no-swiping">
  57. <div class="img3">
  58. <img class="img3-1" src="static/images/yuan.png" alt="">
  59. <p class="sxdeg">0</p>
  60. <p class="zydeg">0</p>
  61. </div>
  62. <img class="img4" src="static/images/text2.png" alt="">
  63. <img class="img5" src="static/images/text3.png" alt="">
  64. <!-- 3D区域 -->
  65. <div class="box ox" template="home" id="o-home"></div>
  66. <ul class="nav">
  67. <li class="active"><img src="static/images/1.png" alt=""></li>
  68. <li class="show"><img src="static/images/2.png" alt=""></li>
  69. <li><img src="static/images/3.png" alt=""></li>
  70. </ul>
  71. </div>
  72. </div>
  73. </div>
  74. <script>
  75. $(document).ready(function () {
  76. $(".nav li").click(function(){
  77. var index = $(this).index()
  78. if(index==2){
  79. $(".slide2").fadeOut()
  80. }
  81. })
  82. $(".show").click(function(){
  83. if($(this).hasClass("active")){
  84. $(".img5").fadeOut()
  85. $(".show").removeClass("active")
  86. }else{
  87. $(".img5").fadeIn()
  88. $(".show").addClass("active")
  89. }
  90. })
  91. $(".d2").click(function(){
  92. $(".slide2").fadeIn()
  93. })
  94. window.owo.script.home.created()
  95. })
  96. </script>
  97. <script>
  98. "use strict";
  99. window.owo = {
  100. // 页面数据和方法
  101. script: {
  102. "home": {
  103. "data": {
  104. "controls": null,
  105. "camera": null,
  106. "scene": null,
  107. "renderer": null,
  108. "light": null,
  109. "clock": null,
  110. "type": "rotate",
  111. "model": null,
  112. "Material_58": null,
  113. "Material_59": null,
  114. "window_box_1": null,
  115. "window_box_2": null,
  116. "arrow_box": null,
  117. "waitTime": 0,
  118. "sxdeg": null,
  119. "zydeg": null
  120. },
  121. "init": function init() {
  122. var _this = this;
  123. THREE.Loader.Handlers.add( /\.tga$/i, new THREE.TGALoader() );
  124. // 创建摄像机
  125. this.data.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 200000);
  126. this.data.camera.position.set(0, 0, 700);
  127. this.data.controls = new THREE.OrbitControls(this.data.camera);
  128. // 禁止左右拖拽
  129. this.data.controls.enablePan = false
  130. this.data.controls.target.set(0, 0, 0);
  131. this.data.controls.maxDistance = 2500
  132. this.data.controls.minDistance = 300
  133. this.data.controls.screenSpacePanning = false
  134. this.data.controls.update();
  135. this.data.scene = new THREE.Scene();
  136. // this.data.scene.background = new THREE.Color(0xa0a0a0);
  137. this.data.light = new THREE.HemisphereLight(0xffffff, 0x444444);
  138. this.data.light.position.set(0, 200, 0);
  139. this.data.scene.add(this.data.light);
  140. this.data.light = new THREE.DirectionalLight(0xffffff);
  141. this.data.light.position.set(0, 200, 100);
  142. this.data.light.castShadow = true;
  143. this.data.light.shadow.camera.top = 180;
  144. this.data.light.shadow.camera.bottom = -100;
  145. this.data.light.shadow.camera.left = -120;
  146. this.data.light.shadow.camera.right = 120;
  147. this.data.scene.add(this.data.light); // this.data.scene.add( new THREE.CameraHelper( this.data.light.shadow.camera ) );
  148. // 网格线
  149. // var grid = new THREE.GridHelper( 2000, 20, 0x000000, 0x000000 );
  150. // grid.material.opacity = 0.2;
  151. // grid.material.transparent = true;
  152. // this.data.scene.add( grid );
  153. // model
  154. var loader = new THREE.FBXLoader();
  155. loader.load('./resource/yuyin.FBX', function(object) {
  156. object.traverse(function(child) {
  157. // console.log(child.name)
  158. if (child.isMesh) {
  159. child.castShadow = true;
  160. child.receiveShadow = true;
  161. }
  162. });
  163. object.position.y = -100
  164. object.scale.set(100,100,100)
  165. _this.data.scene.add(object);
  166. });
  167. this.data.renderer = new THREE.WebGLRenderer({
  168. antialias: true,
  169. alpha:true
  170. });
  171. this.data.renderer.setClearColor(0xEEEEEE, 0.0);
  172. this.data.renderer.setPixelRatio(window.devicePixelRatio);
  173. this.data.renderer.setSize(window.innerWidth, window.innerHeight);
  174. this.data.renderer.shadowMap.enabled = true;
  175. document.querySelector('#o-home').appendChild(this.data.renderer.domElement); // window.addEventListener( 'resize', this.onWindowResize, false );
  176. var gridHelper = new THREE.GridHelper( 1000, 30, 0x2C2C2C, 0x888888 );
  177. // _this.data.scene.add(gridHelper);
  178. this.data.sxdeg = document.querySelector('.sxdeg')
  179. this.data.zydeg = document.querySelector('.zydeg')
  180. },
  181. "animate": function animate() {
  182. var _this2 = this;
  183. var delta = this.data.clock.getDelta();
  184. this.data.renderer.render(this.data.scene, this.data.camera);
  185. this.data.sxdeg.innerText = parseInt(- owo.script.home.data.camera.rotation.x * 180) + '°'
  186. this.data.zydeg.innerText = parseInt(- owo.script.home.data.camera.rotation.z * 180) + '°'
  187. setTimeout(function() {
  188. _this2.animate();
  189. }, 25);
  190. },
  191. "onWindowResize": function onWindowResize() {
  192. this.data.camera.aspect = window.innerWidth / window.innerHeight;
  193. this.data.camera.updateProjectionMatrix();
  194. this.data.renderer.setSize(window.innerWidth, window.innerHeight);
  195. },
  196. "created": function created() {
  197. console.log(this);
  198. this.data.clock = new THREE.Clock();
  199. this.init();
  200. this.animate();
  201. }
  202. }
  203. }
  204. };
  205. </script>
  206. <script src="./static/js/three.js.js" type="text/javascript" charset="UTF-8"></script>
  207. <script src="https://ithanmang.gitee.io/threejs/home/libs/examples/js/loaders/TGALoader.js"></script>
  208. <script src="./static/js/FBXLoader.js" type="text/javascript" charset="UTF-8"></script>
  209. <script src="./static/js/OrbitControls.js" type="text/javascript" charset="UTF-8"></script>
  210. <script src="./static/js/inflate.min.js" type="text/javascript" charset="UTF-8"></script>
  211. </body>
  212. </html>