index.html 8.0 KB

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