swkk.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <script src="//4dkk.4dage.com/v4/sdk/4.2.0/kankan-sdk-deps.js"></script>
  9. <script src="//4dkk.4dage.com/v4/sdk/4.2.0/kankan-sdk.js"></script>
  10. <style>
  11. * {
  12. margin: 0;
  13. padding: 0;
  14. box-sizing: border-box;
  15. }
  16. html,
  17. body {
  18. width: 100%;
  19. height: 100%;
  20. overflow: hidden;
  21. }
  22. .box {
  23. width: 100%;
  24. height: 100%;
  25. }
  26. [xui_min_map] {
  27. right: 10px;
  28. top: 75px
  29. }
  30. .inco {
  31. position: absolute;
  32. bottom: 20px;
  33. left: 50px;
  34. width: 160px;
  35. height: 36px;
  36. background-color: rgba(0, 0, 0, .4);
  37. border-radius: 18px;
  38. z-index: 11;
  39. display: flex;
  40. justify-content: space-around;
  41. padding: 0 10px 0 15px;
  42. }
  43. .inco>div {
  44. cursor: pointer;
  45. width: 33%;
  46. height: 100%;
  47. display: flex;
  48. justify-content: center;
  49. align-items: center;
  50. background-size: 36px 36px;
  51. background-repeat: no-repeat;
  52. background-position: center;
  53. }
  54. .inco1 {
  55. background-image: url('./img/inco1Ac.png');
  56. width: 22% !important;
  57. }
  58. .inco2 {
  59. background-image: url('./img/inco2.png');
  60. }
  61. .inco3 {
  62. background-image: url('./img/inco3.png');
  63. }
  64. .loading {
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. z-index: 12;
  69. width: 100%;
  70. height: 100%;
  71. background-color: black;
  72. display: flex;
  73. justify-content: center;
  74. align-items: center;
  75. }
  76. .loading .loadBox {
  77. color: #fff;
  78. text-align: center;
  79. letter-spacing: 2px;
  80. width: 110px;
  81. height: 110px;
  82. background: rgba(0, 0, 0, 0.5);
  83. border-radius: 2px;
  84. }
  85. .loadIcon {
  86. width: 60px;
  87. height: 60px;
  88. position: relative;
  89. overflow: hidden;
  90. margin: 10px auto;
  91. }
  92. .loadIcon img {
  93. height: 60px;
  94. position: absolute;
  95. left: 0;
  96. top: 0;
  97. animation: loading 1s steps(15) infinite;
  98. }
  99. @keyframes loading {
  100. 100% {
  101. left: -900px;
  102. }
  103. }
  104. </style>
  105. </head>
  106. <body>
  107. <div class="loading">
  108. <div class="loadBox">
  109. <div class="loadIcon">
  110. <img src="./img/loading.png" alt="">
  111. </div>
  112. <div class="txt">加载中</div>
  113. </div>
  114. </div>
  115. <div class="box"></div>
  116. <div class="inco">
  117. <div class="inco1 active" title="全景漫游"></div>
  118. <div class="inco2" title="俯视图"></div>
  119. <div class="inco3" title="迷你模型"></div>
  120. </div>
  121. </body>
  122. <script>
  123. // 获取地址栏信息
  124. let GetQueryString = (name) => {
  125. let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  126. let r = window.location.search.substr(1).match(reg);
  127. if (r != null) return unescape(r[2]);
  128. return "";
  129. }
  130. let num = GetQueryString('m')
  131. var kankan = new KanKan({
  132. dom: '.box',
  133. num
  134. })
  135. kankan.use('MinMap', {
  136. theme: {
  137. camera_fillStyle: "#C48871"
  138. }
  139. })
  140. kankan.render()
  141. kankan.Scene.on('loaded', () => {
  142. document.querySelector('.loading').style.display = 'none'
  143. //设置地面logo
  144. kankan.Scene.setFloorLogo({
  145. url: 'img/diBiao.png'
  146. })
  147. })
  148. let doms = document.querySelectorAll('.inco div')
  149. kankan.Camera.on('mode.afterChange', ({
  150. fromMode,
  151. toMode,
  152. floorIndex
  153. }) => {
  154. if (toMode == 'panorama') {
  155. doms[0].classList.add('active')
  156. doms[1].classList.remove('active')
  157. doms[2].classList.remove('active')
  158. doms[0].style.backgroundImage = "url(./img/inco1Ac.png)"
  159. doms[1].style.backgroundImage = "url(./img/inco2.png)"
  160. doms[2].style.backgroundImage = "url(./img/inco3.png)"
  161. }
  162. })
  163. doms.forEach((v, i) => {
  164. v.onclick = function () {
  165. let className = v.getAttribute('class')
  166. if (className.includes('active')) return
  167. if (i == 0) {
  168. doms[0].classList.add('active')
  169. doms[1].classList.remove('active')
  170. doms[2].classList.remove('active')
  171. doms[0].style.backgroundImage = "url(./img/inco1Ac.png)"
  172. doms[1].style.backgroundImage = "url(./img/inco2.png)"
  173. doms[2].style.backgroundImage = "url(./img/inco3.png)"
  174. kankan.Camera.panorama()
  175. } else if (i == 1) {
  176. doms[0].classList.remove('active')
  177. doms[1].classList.add('active')
  178. doms[2].classList.remove('active')
  179. doms[0].style.backgroundImage = "url(./img/inco1.png)"
  180. doms[1].style.backgroundImage = "url(./img/inco2Ac.png)"
  181. doms[2].style.backgroundImage = "url(./img/inco3.png)"
  182. kankan.Camera.floorplan()
  183. } else {
  184. doms[0].classList.remove('active')
  185. doms[1].classList.remove('active')
  186. doms[2].classList.add('active')
  187. doms[0].style.backgroundImage = "url(./img/inco1.png)"
  188. doms[1].style.backgroundImage = "url(./img/inco2.png)"
  189. doms[2].style.backgroundImage = "url(./img/inco3Ac.png)"
  190. kankan.Camera.dollhouse()
  191. }
  192. }
  193. })
  194. </script>
  195. </html>