index.html 8.0 KB

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