index.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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, body {
  9. width: 100%;
  10. height: 100%;
  11. background-color: #000;
  12. color: #fff;
  13. margin: 0px;
  14. padding: 0;
  15. overflow: hidden;
  16. }
  17. </style>
  18. </head>
  19. <script type="text/javascript">
  20. const ossPrefix = 'https://laser.4dkankan.com/data/';
  21. const ossPrefixDep = 'https://laser.4dkankan.com/public/';
  22. const sceneNum = 'test3';
  23. </script>
  24. <script src="IndoorViewerAPI.js"></script>
  25. <script type="text/javascript" src="js/OBJExporter.js"></script>
  26. <script type="text/javascript" src="js/Animation.js"></script>
  27. <script type="text/javascript" src="js/AnimationHandler.js"></script>
  28. <script type="text/javascript" src="js/KeyFrameAnimation.js"></script>
  29. <script type="text/javascript" src="js/ColladaLoader.js"></script>
  30. <script type="text/javascript" src="js/tinyqueue.js"></script>
  31. <script type="text/javascript" src="js/THREE.MeshLine.js"></script>
  32. <script type="text/javascript" src="js/popindoorAPI2.7.1.js"></script>
  33. <script type="text/javascript" src="js/utf.js"></script>
  34. <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
  35. <script type="text/javascript" src="js/jquery.qrcode.js"></script>
  36. <script type="text/javascript" src="js/proj4.js"></script>
  37. <script type="text/javascript">
  38. var indoorViewer;
  39. var run =false;
  40. IV.loaded(function()
  41. {
  42. indoorViewer = new IndoorViewer({
  43. 'base_url': '',
  44. 'onLoadComplete': setLayers
  45. });
  46. });
  47. var setLayers = function()
  48. {
  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({color: 0x00FA9A});
  72. material.colorWrite = false;
  73. model.children[0].material=material;
  74. model.renderOrder = 2;
  75. model.children[0].renderOrder = 2;
  76. main_view.overlayScene.add(model);
  77. //mesh.material.colorWrite = false;
  78. } );
  79. var loader = new IV.THREE.ColladaLoader();
  80. loader.load( './models/m4.dae', function ( collada ) {
  81. //console.log(collada)
  82. model = collada.scene;
  83. model.renderOrder = 3;
  84. for ( var j = 0; j < model.children.length; ++j ) {
  85. model.children[j].renderOrder = 3;
  86. }
  87. animations = collada.animations;
  88. kfAnimationsLength = animations.length;
  89. model.scale.x = model.scale.y = model.scale.z = 1;
  90. main_view.scene.add(model);
  91. //main_view.overlayScene.add(model);
  92. //map_scene.add(model)
  93. for ( var i = 0; i < kfAnimationsLength; ++i ) {
  94. var animation = animations[ i ];
  95. var kfAnimation = new IV.THREE.KeyFrameAnimation( animation );
  96. kfAnimation.timeScale = 1;
  97. kfAnimations.push( kfAnimation );
  98. }
  99. door_animation_start(0);
  100. animate( lastTimestamp );
  101. } );
  102. function door_animation_start(time) {
  103. for ( var i = 0; i < kfAnimationsLength; ++i ) {
  104. var animation = kfAnimations[i];
  105. // if (animation.root.name === "animation_door1") {
  106. // console.log(animation.root.name)
  107. for (var h = 0, hl = animation.hierarchy.length; h < hl; h++) {
  108. var keys = animation.data.hierarchy[h].keys;
  109. var sids = animation.data.hierarchy[h].sids;
  110. var obj = animation.hierarchy[h];
  111. if (keys.length && sids) {
  112. for (var s = 0; s < sids.length; s++) {
  113. var sid = sids[s];
  114. var next = animation.getNextKeyWith(sid, h, 0);
  115. if (next) next.apply(sid);
  116. }
  117. obj.matrixAutoUpdate = false;
  118. animation.data.hierarchy[h].node.updateMatrix();
  119. obj.matrixWorldNeedsUpdate = true;
  120. }
  121. }
  122. // }
  123. animation.loop = false;
  124. animation.play(time);
  125. }
  126. }
  127. function animate( timestamp ) {
  128. var frameTime = ( timestamp - lastTimestamp ) * 0.001;
  129. if (IV.custom.select_map_id&&(pre_select_map_id!==IV.custom.select_map_id)){
  130. pre_select_map_id=IV.custom.select_map_id;
  131. for ( var i = 0; i < kfAnimationsLength; ++i ) {
  132. kfAnimations[ i ].stop();
  133. }
  134. if(IV.custom.select_map_id===2){
  135. progress =0;
  136. door_animation_start(6);
  137. }else if(IV.custom.select_map_id===3){
  138. progress =0;
  139. door_animation_start(0);
  140. }
  141. }
  142. //console.log(progress,max_progress,start,end)
  143. if ( progress >= 0 && progress < 6) {
  144. for (var i = 0; i < kfAnimationsLength; ++i) {
  145. //if (kfAnimations[i].root.name === "door1") {
  146. kfAnimations[i].update(frameTime);
  147. //}
  148. }
  149. } else if ( progress >=6 ) {
  150. for ( var i = 0; i < kfAnimationsLength; ++i ) {
  151. kfAnimations[ i ].stop();
  152. }
  153. // progress = 0;
  154. // door_animation_start();
  155. }
  156. main_view.invalidateScene();
  157. progress += frameTime;
  158. lastTimestamp = timestamp;
  159. requestAnimationFrame( animate );
  160. }
  161. }
  162. </script>
  163. <body >
  164. <indoorviewer style="height: 100%"></indoorviewer>
  165. <div id="curscroll" style="position:absolute;visibility:hidden;padding: 2px 10px;z-index:2000"></div>
  166. </body>
  167. </html>