index.html 8.0 KB

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