sdk-overlay.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. html,
  9. body{
  10. width: 100%;
  11. height: 100%;
  12. margin: 0;
  13. overflow: hidden;
  14. }
  15. .scene{
  16. width: 100%;
  17. height: 100%;
  18. }
  19. #toolbar{
  20. position: absolute;
  21. left: 50%;
  22. top: 0;
  23. z-index: 10000;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div id="scene" class="scene"></div>
  29. <div id="toolbar">
  30. <button onclick="enter()">进入“添加视频”</button>
  31. <button onclick="upload()">上传视频</button>
  32. <button onclick="switchTransfrom()">switchTransfrom</button>
  33. <button onclick="resetRatio()">resetRatio</button>
  34. <button onclick="setThinkness()">setThinkness</button>
  35. <button onclick="setWidth()">setWidth</button>
  36. <button onclick="setHeight()">setHeight</button>
  37. <button onclick="confirm()">保存视频</button>
  38. <button onclick="deleteVideo()">删除视频</button>
  39. <button onclick="cancel()">取消</button>
  40. <button onclick="exit()">退出</button>
  41. </div>
  42. <video id="myVideo" loop crossOrigin="anonymous" playsinline style="display:none">
  43. <source src="https://4dkk.4dage.com/images/imagest-JNg3ds4cxZ/overlaybk8IA625652.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
  44. </video>
  45. <script src="../dist/sdk/kankan-sdk-deps.js"></script>
  46. <script src="../dist/sdk/kankan-sdk.js"></script>
  47. <script>
  48. window.dontForbitSetsize = true
  49. var kankan = new KanKan({
  50. dom:'#scene',
  51. num:'t-YhBCzQr'
  52. })
  53. kankan.use("Controls")
  54. kankan.use("Tag").then(tour=>{
  55. })
  56. kankan.render()
  57. kankan.Scene.on('loaded',()=>{
  58. })
  59. kankan.VideoManager.on("videos/panel/display", (display) => {
  60. console.error("编辑面板出现:", display)
  61. } );
  62. kankan.VideoManager.on("videos/panel/exit", () => {
  63. console.error("编辑面板退出")
  64. })
  65. kankan.VideoManager.on("videos/panel/switchTclMode", (mode) => {
  66. console.error("切换控制器模式:", mode)
  67. })
  68. kankan.VideoManager.on("videos/panel/changeSize", (data) => {
  69. console.error("更新视频尺寸的数字: ", data.wText, data.hText, data.width, data.height)
  70. })
  71. kankan.VideoManager.on("videos/panel/updatePoster", (video) => {
  72. console.error("3d视频上传完成:", video)
  73. })
  74. kankan.VideoManager.on("videos/panel/changeDepth", (depth) => {
  75. console.error("改变视频厚度:", depth)
  76. })
  77. function enter(){
  78. kankan.VideoManager.BoxVideo.edit.enter();
  79. }
  80. function upload(){
  81. let video = document.getElementById("myVideo")
  82. video.play()
  83. kankan.VideoManager.BoxVideo.edit.upload(null, video);
  84. }
  85. var index = 1
  86. function switchTransfrom(){
  87. kankan.VideoManager.BoxVideo.edit.transfrom(index);
  88. index >= 2 ? index = 0 : index ++;
  89. }
  90. function resetRatio() {
  91. kankan.VideoManager.BoxVideo.edit.resetRatio();
  92. }
  93. function setWidth() {
  94. let newWidth = kankan.VideoManager.BoxVideo.edit.setPlaneWH("W", {
  95. value: 2,
  96. min: 0,
  97. max: 10
  98. });
  99. // console.error(newWidth)
  100. }
  101. function setHeight() {
  102. let newHeight = kankan.VideoManager.BoxVideo.edit.setPlaneWH("H", {
  103. value: 2,
  104. min: 0,
  105. max: 10
  106. });
  107. // console.error(newHeight)
  108. }
  109. function setThinkness(){
  110. let thinkness = kankan.VideoManager.BoxVideo.edit.setThinkness({
  111. value: 2,
  112. min: 0,
  113. max: 100
  114. });
  115. // console.error(thinkness)
  116. }
  117. function confirm(){
  118. var info = kankan.VideoManager.BoxVideo.edit.save();
  119. // console.error(info)
  120. }
  121. function deleteVideo(){
  122. kankan.VideoManager.BoxVideo.edit.delete((sid, done) => { });
  123. }
  124. function cancel() {
  125. kankan.VideoManager.BoxVideo.edit.cancel()
  126. }
  127. function exit() {
  128. kankan.VideoManager.BoxVideo.edit.exit()
  129. }
  130. </script>
  131. </body>
  132. </html>