mosaic.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. <style>
  8. *,
  9. ::before,
  10. ::after {
  11. -webkit-appearance: auto !important;
  12. -moz-appearance: auto !important;
  13. appearance: auto !important;
  14. }
  15. html,
  16. body {
  17. width: 100%;
  18. height: 100%;
  19. margin: 0;
  20. overflow: hidden;
  21. }
  22. .scene {
  23. width: 100%;
  24. height: 100%;
  25. }
  26. #toolbar {
  27. position: absolute;
  28. left: 50%;
  29. top: 0;
  30. z-index: 10000;
  31. transform: translateX(-50%);
  32. }
  33. #toolbar > div.disable {
  34. opacity: 0.5;
  35. pointer-events: none;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="scene" class="scene"></div>
  41. <div id="toolbar">
  42. <button id="add" onclick="add()">添加</button>
  43. <button id="exit" disabled onclick="exit()">退出</button>
  44. <button id="confirm" disabled onclick="confirm()">确定</button>
  45. <button id="delete" onclick="remove()">删除</button>
  46. <div id="options" style="margin-top: 20px" class="disable">
  47. <label for="pen"><input type="radio" id="pen" name="s" onclick="setBrush('pen')" checked />马赛克</label>
  48. <label for="eraser"><input type="radio" id="eraser" name="s" onclick="setBrush('eraser')" /> 橡皮擦</label>
  49. <input type="range" onchange="setBrushSize(value)" value="20" min="0" max="100" />
  50. </div>
  51. </div>
  52. <script src="../../dist/sdk/kankan-sdk-deps.js"></script>
  53. <script src="../../dist/sdk/kankan-sdk.js"></script>
  54. <script>
  55. var kankan = new KanKan({
  56. dom: '#scene',
  57. num: 't-JKNqv1o',
  58. view:false
  59. })
  60. localStorage.setItem('token','eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxODgxOTI3MjIwOCIsInVzZXJOYW1lIjoiMTg4MTkyNzIyMDgiLCJpYXQiOjE2NjIwMDMzMjgsImp0aSI6IjI3MzMyNjZiLTM3YzktNGM1YS04ZjZiLWNhNzQ5ZTYyY2Y3MyJ9.oFLkFRluIv21PqR5JJSrKfyZIl0e2BXot3EgxiFVkQ8')
  61. kankan.use('Mosaic').then(mosaic => {
  62. // todo
  63. })
  64. kankan.render()
  65. function add() {
  66. kankan.RepairManager.mosaic.then(mosaic => {
  67. mosaic.enter()
  68. document.querySelector('#exit').removeAttribute('disabled')
  69. document.querySelector('#confirm').removeAttribute('disabled')
  70. document.querySelector('#options').classList.remove('disable')
  71. })
  72. }
  73. function exit() {
  74. kankan.RepairManager.mosaic.then(mosaic => {
  75. mosaic.exit()
  76. })
  77. document.querySelector('#exit').setAttribute('disabled',true)
  78. document.querySelector('#confirm').setAttribute('disabled',true)
  79. document.querySelector('#options').classList.add('disable')
  80. }
  81. function confirm() {
  82. kankan.RepairManager.mosaic.then(mosaic => {
  83. mosaic.save()
  84. })
  85. document.querySelector('#exit').setAttribute('disabled',true)
  86. document.querySelector('#confirm').setAttribute('disabled',true)
  87. document.querySelector('#options').classList.add('disable')
  88. }
  89. function remove() {
  90. kankan.RepairManager.mosaic.then(mosaic => {
  91. if (mosaic.mosaics.length) {
  92. mosaic.remove(mosaic.mosaics[0].panoId)
  93. }
  94. })
  95. }
  96. function setBrush(type) {
  97. kankan.RepairManager.mosaic.then(mosaic => {
  98. mosaic.setBrush(type)
  99. })
  100. }
  101. function setBrushSize(size) {
  102. kankan.RepairManager.mosaic.then(mosaic => {
  103. mosaic.setBrushSize(size)
  104. })
  105. }
  106. </script>
  107. </body>
  108. </html>