index.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 = 'test3';
  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/tinyqueue.js"></script>
  33. <script type="text/javascript" src="js/THREE.MeshLine.js"></script>
  34. <script type="text/javascript" src="js/popindoorAPI2.7.1.js"></script>
  35. <script type="text/javascript" src="js/utf.js"></script>
  36. <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
  37. <script type="text/javascript" src="js/jquery.qrcode.js"></script>
  38. <script type="text/javascript" src="js/proj4.js"></script>
  39. <script type="text/javascript">
  40. var indoorViewer;
  41. var run = false;
  42. IV.loaded(function () {
  43. indoorViewer = new IndoorViewer({
  44. 'base_url': '',
  45. 'onLoadComplete': setLayers
  46. });
  47. });
  48. var setLayers = function () {
  49. if (!run) {
  50. run = true;
  51. var setting = new Setting()
  52. var doorOpenCLose = new DoorOpenCLose();
  53. main_view.addToScene(doorOpenCLose);
  54. }
  55. };
  56. var DoorOpenCLose = function (e) {
  57. var main_view = IV.getMainView();
  58. var model;
  59. var animations;
  60. var kfAnimations = [];
  61. var kfAnimationsLength = 0;
  62. var progress = 0;
  63. var lastTimestamp = 0;
  64. var pre_select_map_id = -1;
  65. if (!IV.custom) { //自定义功能集合
  66. IV.custom = {};
  67. }
  68. var loader_wall = new IV.THREE.ColladaLoader();
  69. loader_wall.load('./models/qt.dae', function (collada) {
  70. model = collada.scene.children[2];
  71. var material = new IV.THREE.MeshBasicMaterial({
  72. color: 0x00FA9A
  73. });
  74. material.colorWrite = false;
  75. model.children[0].material = material;
  76. model.renderOrder = 2;
  77. model.children[0].renderOrder = 2;
  78. main_view.overlayScene.add(model);
  79. //mesh.material.colorWrite = false;
  80. });
  81. var loader = new IV.THREE.ColladaLoader();
  82. loader.load('./models/m4.dae', function (collada) {
  83. //console.log(collada)
  84. model = collada.scene;
  85. model.renderOrder = 3;
  86. for (var j = 0; j < model.children.length; ++j) {
  87. model.children[j].renderOrder = 3;
  88. }
  89. animations = collada.animations;
  90. kfAnimationsLength = animations.length;
  91. model.scale.x = model.scale.y = model.scale.z = 1;
  92. main_view.scene.add(model);
  93. //main_view.overlayScene.add(model);
  94. //map_scene.add(model)
  95. for (var i = 0; i < kfAnimationsLength; ++i) {
  96. var animation = animations[i];
  97. var kfAnimation = new IV.THREE.KeyFrameAnimation(animation);
  98. kfAnimation.timeScale = 1;
  99. kfAnimations.push(kfAnimation);
  100. }
  101. door_animation_start(0);
  102. animate(lastTimestamp);
  103. });
  104. function door_animation_start(time) {
  105. for (var i = 0; i < kfAnimationsLength; ++i) {
  106. var animation = kfAnimations[i];
  107. // if (animation.root.name === "animation_door1") {
  108. // console.log(animation.root.name)
  109. for (var h = 0, hl = animation.hierarchy.length; h < hl; h++) {
  110. var keys = animation.data.hierarchy[h].keys;
  111. var sids = animation.data.hierarchy[h].sids;
  112. var obj = animation.hierarchy[h];
  113. if (keys.length && sids) {
  114. for (var s = 0; s < sids.length; s++) {
  115. var sid = sids[s];
  116. var next = animation.getNextKeyWith(sid, h, 0);
  117. if (next) next.apply(sid);
  118. }
  119. obj.matrixAutoUpdate = false;
  120. animation.data.hierarchy[h].node.updateMatrix();
  121. obj.matrixWorldNeedsUpdate = true;
  122. }
  123. }
  124. // }
  125. animation.loop = false;
  126. animation.play(time);
  127. }
  128. }
  129. function animate(timestamp) {
  130. var frameTime = (timestamp - lastTimestamp) * 0.001;
  131. if (IV.custom.select_map_id && (pre_select_map_id !== IV.custom.select_map_id)) {
  132. pre_select_map_id = IV.custom.select_map_id;
  133. for (var i = 0; i < kfAnimationsLength; ++i) {
  134. kfAnimations[i].stop();
  135. }
  136. if (IV.custom.select_map_id === 2) {
  137. progress = 0;
  138. door_animation_start(6);
  139. } else if (IV.custom.select_map_id === 3) {
  140. progress = 0;
  141. door_animation_start(0);
  142. }
  143. }
  144. //console.log(progress,max_progress,start,end)
  145. if (progress >= 0 && progress < 6) {
  146. for (var i = 0; i < kfAnimationsLength; ++i) {
  147. //if (kfAnimations[i].root.name === "door1") {
  148. kfAnimations[i].update(frameTime);
  149. //}
  150. }
  151. } else if (progress >= 6) {
  152. for (var i = 0; i < kfAnimationsLength; ++i) {
  153. kfAnimations[i].stop();
  154. }
  155. // progress = 0;
  156. // door_animation_start();
  157. }
  158. main_view.invalidateScene();
  159. progress += frameTime;
  160. lastTimestamp = timestamp;
  161. requestAnimationFrame(animate);
  162. }
  163. }
  164. </script>
  165. <body>
  166. <indoorviewer style="height: 100%"></indoorviewer>
  167. <div id="curscroll" style="position:absolute;visibility:hidden;padding: 2px 10px;z-index:2000"></div>
  168. </body>
  169. </html>