index.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <link rel="icon" href="favicon.ico" type="image/x-icon">
  6. <title>四维展厅</title>
  7. <style>
  8. html,
  9. body {
  10. width: 100%;
  11. height: 100%;
  12. background-color: #000;
  13. color: #fff;
  14. margin: 0px;
  15. padding: 0;
  16. overflow: hidden;
  17. }
  18. </style>
  19. <link rel="stylesheet" href="./css/style.css">
  20. </head>
  21. <script type="text/javascript">
  22. const ossPrefix = 'https://laser.4dkankan.com/data/';
  23. const ossPrefixDep = 'https://laser.4dkankan.com/public/';
  24. const sceneNum = 't-iksBApb';
  25. </script>
  26. <script src="IndoorViewerAPI.js"></script>
  27. <script type="text/javascript" src="js/OBJExporter.js"></script>
  28. <script type="text/javascript" src="js/Animation.js"></script>
  29. <script type="text/javascript" src="js/AnimationHandler.js"></script>
  30. <script type="text/javascript" src="js/KeyFrameAnimation.js"></script>
  31. <script type="text/javascript" src="js/ColladaLoader.js"></script>
  32. <script type="text/javascript" src="js/OBJLoader.js"></script>
  33. <script type="text/javascript" src="js/tinyqueue.js"></script>
  34. <script type="text/javascript" src="js/THREE.MeshLine.js"></script>
  35. <script type="text/javascript" src="js/popindoorAPI2.7.1.js"></script>
  36. <script type="text/javascript" src="js/utf.js"></script>
  37. <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
  38. <script type="text/javascript" src="js/jquery.qrcode.js"></script>
  39. <script type="text/javascript" src="js/proj4.js"></script>
  40. <script type="text/javascript">
  41. var indoorViewer;
  42. var run = false;
  43. IV.loaded(function() {
  44. indoorViewer = new IndoorViewer({
  45. 'base_url': '',
  46. 'onLoadComplete': setLayers
  47. });
  48. });
  49. var setLayers = function() {
  50. if (!run) {
  51. run = true;
  52. var setting = new Setting()
  53. var doorOpenCLose = new DoorOpenCLose();
  54. main_view.addToScene(doorOpenCLose);
  55. }
  56. };
  57. var DoorOpenCLose = function(e) {
  58. var main_view = IV.getMainView();
  59. // var model;
  60. // var animations;
  61. // var kfAnimations = [];
  62. // var kfAnimationsLength = 0;
  63. // var progress = 0;
  64. // var lastTimestamp = 0;
  65. // var pre_select_map_id = -1;
  66. // let path = './models/mesh/';
  67. // var mtlLoader = new IV.THREE.MTLLoader()
  68. // .setPath( path )
  69. // .load('mesh.mtl', function ( materials ) {
  70. // console.log(materials)
  71. // materials.preload();
  72. // // 加载obj
  73. // new IV.THREE.OBJLoader()
  74. // .setMaterials( materials )
  75. // .setPath( path )
  76. // .load('mesh.obj', function ( object ) {
  77. // // console.log(object)
  78. // // 设置旋转中心点
  79. // //object.children[0].geometry.computeBoundingBox();
  80. // //object.children[0].geometry.center()
  81. // object.position.x = 0;
  82. // object.position.y = 0;
  83. // object.position.z = 0;
  84. // // 将模型加入到场景
  85. // scene.add( object );
  86. // }, onProgress, onError );
  87. // });
  88. // OBJLoader_plugin();
  89. // var loader = new IV.THREE.OBJLoader();
  90. // loader.load('./models/mesh/mesh.obj', function (object) {
  91. // //controller = object.children[0];
  92. // var texture_loader = new IV.THREE.TextureLoader();
  93. // var material = new IV.THREE.MeshBasicMaterial();
  94. // main_view.scene.add(object);
  95. // });
  96. }
  97. /*
  98. if (!IV.custom) { //自定义功能集合
  99. IV.custom = {};
  100. }
  101. var loader_wall = new IV.THREE.ColladaLoader();
  102. loader_wall.load('./models/qt.dae', function(collada) {
  103. model = collada.scene.children[2];
  104. var material = new IV.THREE.MeshBasicMaterial({
  105. color: 0x00FA9A
  106. });
  107. material.colorWrite = false;
  108. model.children[0].material = material;
  109. model.renderOrder = 2;
  110. model.children[0].renderOrder = 2;
  111. main_view.overlayScene.add(model);
  112. //mesh.material.colorWrite = false;
  113. });
  114. var loader = new IV.THREE.ColladaLoader();
  115. */
  116. // loader.load('./models/m4.dae', function (collada) {
  117. // //console.log(collada)
  118. // model = collada.scene;
  119. // model.renderOrder = 3;
  120. // for (var j = 0; j < model.children.length; ++j) {
  121. // model.children[j].renderOrder = 3;
  122. // }
  123. // animations = collada.animations;
  124. // kfAnimationsLength = animations.length;
  125. // model.scale.x = model.scale.y = model.scale.z = 1;
  126. // main_view.scene.add(model);
  127. // //main_view.overlayScene.add(model);
  128. // //map_scene.add(model)
  129. // for (var i = 0; i < kfAnimationsLength; ++i) {
  130. // var animation = animations[i];
  131. // var kfAnimation = new IV.THREE.KeyFrameAnimation(animation);
  132. // kfAnimation.timeScale = 1;
  133. // kfAnimations.push(kfAnimation);
  134. // }
  135. // door_animation_start(0);
  136. // animate(lastTimestamp);
  137. // });
  138. function door_animation_start(time) {
  139. for (var i = 0; i < kfAnimationsLength; ++i) {
  140. var animation = kfAnimations[i];
  141. // if (animation.root.name === "animation_door1") {
  142. // console.log(animation.root.name)
  143. for (var h = 0, hl = animation.hierarchy.length; h < hl; h++) {
  144. var keys = animation.data.hierarchy[h].keys;
  145. var sids = animation.data.hierarchy[h].sids;
  146. var obj = animation.hierarchy[h];
  147. if (keys.length && sids) {
  148. for (var s = 0; s < sids.length; s++) {
  149. var sid = sids[s];
  150. var next = animation.getNextKeyWith(sid, h, 0);
  151. if (next) next.apply(sid);
  152. }
  153. obj.matrixAutoUpdate = false;
  154. animation.data.hierarchy[h].node.updateMatrix();
  155. obj.matrixWorldNeedsUpdate = true;
  156. }
  157. }
  158. // }
  159. animation.loop = false;
  160. animation.play(time);
  161. }
  162. }
  163. function animate(timestamp) {
  164. var frameTime = (timestamp - lastTimestamp) * 0.001;
  165. if (IV.custom.select_map_id && (pre_select_map_id !== IV.custom.select_map_id)) {
  166. pre_select_map_id = IV.custom.select_map_id;
  167. for (var i = 0; i < kfAnimationsLength; ++i) {
  168. kfAnimations[i].stop();
  169. }
  170. if (IV.custom.select_map_id === 2) {
  171. progress = 0;
  172. door_animation_start(6);
  173. } else if (IV.custom.select_map_id === 3) {
  174. progress = 0;
  175. door_animation_start(0);
  176. }
  177. }
  178. //console.log(progress,max_progress,start,end)
  179. if (progress >= 0 && progress < 6) {
  180. for (var i = 0; i < kfAnimationsLength; ++i) {
  181. //if (kfAnimations[i].root.name === "door1") {
  182. kfAnimations[i].update(frameTime);
  183. //}
  184. }
  185. } else if (progress >= 6) {
  186. for (var i = 0; i < kfAnimationsLength; ++i) {
  187. kfAnimations[i].stop();
  188. }
  189. // progress = 0;
  190. // door_animation_start();
  191. }
  192. main_view.invalidateScene();
  193. progress += frameTime;
  194. lastTimestamp = timestamp;
  195. requestAnimationFrame(animate);
  196. }
  197. </script>
  198. <script src="./js/index.js"></script>
  199. <body>
  200. <indoorviewer style="height: 100%"></indoorviewer>
  201. <div id="curscroll" style="position:absolute;visibility:hidden;padding: 2px 10px;z-index:2000"></div>
  202. </body>
  203. </html>