panoramic_no_drag.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <krpano version="1.20.9" title="Virtual Tour">
  2. <!-- <plugin name="pp_light" keep="true"
  3. url="https://dm.static.elab-plus.com/miniProgram/krpano/plugins/pp_light.js"
  4. enabled="true"
  5. exposure="0.0"
  6. lights="1.0"
  7. shadows="5.0"
  8. filterrange="60.0"
  9. masking="1.0"
  10. quality="7"
  11. order="1"
  12. phase="1"
  13. />
  14. <plugin name="pp_sharpen" keep="true"
  15. url="https://dm.static.elab-plus.com/miniProgram/krpano/plugins/pp_sharpen.js"
  16. enabled="true"
  17. strength="5.0"
  18. range="5"
  19. quality="5"
  20. luminanceonly="true"
  21. order="2"
  22. phase="1"
  23. /> -->
  24. <action name="mytest">
  25. screentosphere(mouse.x, mouse.y, toh, tov);
  26. jscall(calc('console.log("'+toh+'")'));
  27. jscall(calc('console.log("'+tov+'")'));
  28. </action>
  29. <events onclick="mytest();" />
  30. <!-- startup action - load the first scene -->
  31. <action name="startup" autorun="onstart">
  32. if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );
  33. loadscene(get(startscene), null, MERGE);
  34. if(startactions !== null, startactions() );
  35. </action>
  36. <events onloadcomplete="sceneload"></events>
  37. <action name="sceneload">
  38. jscall('window.sceneload()');
  39. </action>
  40. <scene name="mainScene" onstart="" havevrimage.mobilevr="false" havevrimage.no-mobilevr="true" lat="" lng=""
  41. heading="">
  42. <control bouncinglimits="calc:image.cube ? true : false" />
  43. <view hlookat="50.082" vlookat="12.404" fovtype="MFOV" fov="90.000" maxpixelzoom="4.0" fovmin="70" fovmax="120"
  44. limitview="auto" />
  45. <!-- <preview
  46. url="https://elab-marketing-web.oss-cn-shanghai.aliyuncs.com/fairyMountain/layout/hospital/panos/ceshi.tiles/preview.jpg" /> -->
  47. <image if="!(webvr.isenabled OR device.mobilevr)">
  48. <sphere url="%$panorama_url%" />
  49. </image>
  50. <image if="webvr.isenabled OR device.mobilevr">
  51. <sphere url="%$panorama_url%" />
  52. </image>
  53. <!-- 电子人 -->
  54. <hotspot name="video"
  55. ath="50.082"
  56. atv="14"
  57. url="https://dm.static.elab-plus.com/videoplayer.js"
  58. videourl=""
  59. width="180"
  60. height="320"
  61. chromakey="0x238E54|0.294|0.133"
  62. preload="true"
  63. pausedonstart="false"
  64. loop="true"
  65. distorted="true"
  66. muted="true"
  67. zoom="true"
  68. autopause="true"
  69. autoresume="true"
  70. scale="1"
  71. onvideoready="videoreadyFunc"
  72. onvideoplay="videoplayHandle"
  73. cursor="grab"
  74. zorder="2"
  75. enabled="false"
  76. >
  77. </hotspot>
  78. <!-- 电子人的阴影 -->
  79. <hotspot name="image_hotspot" ath="50.082" atv="14" rotate="0" zorder="1" enabled="false"
  80. distorted="true" scale="1" alpha="0.5" visible="false" width="180" height="320"
  81. url="https://dm.static.elab-plus.com/miniProgram/shadow11.png" keep="true"></hotspot>
  82. <!-- 宠物视频 -->
  83. <hotspot name="petVideo"
  84. ath="80.0"
  85. atv="14"
  86. url="https://dm.static.elab-plus.com/videoplayer.js"
  87. videourl=""
  88. width="180"
  89. height="180"
  90. chromakey="0x238E54|0.294|0.133"
  91. preload="true"
  92. pausedonstart="false"
  93. loop="true"
  94. distorted="true"
  95. muted="true"
  96. zoom="true"
  97. autopause="true"
  98. autoresume="true"
  99. scale="1"
  100. zorder="2"
  101. enabled="false"
  102. >
  103. </hotspot>
  104. <!-- 红包 -->
  105. <hotspot name="redBox"
  106. ath="60"
  107. atv="14"
  108. url="https://dm.static.elab-plus.com/videoplayer.js"
  109. videourl=""
  110. chromakey="0x30B524|0.294|0.133"
  111. preload="true"
  112. pausedonstart="false"
  113. loop="true"
  114. distorted="true"
  115. muted="true"
  116. zoom="true"
  117. autopause="true"
  118. autoresume="true"
  119. scale="1"
  120. zorder="2"
  121. enabled="true"
  122. onclick="toggleRedBox();"
  123. >
  124. </hotspot>
  125. <action name="toggleRedBox">
  126. jscall('window.toggleRedBox()');
  127. </action>
  128. <action name="showRedBox">
  129. set(hotspot[redBox].visible, 'true');
  130. hotspot[redBox].playvideo(%1, '', false);
  131. </action>
  132. <action name="hideRedBox">
  133. hotspot[redBox].stop();
  134. set(hotspot[redBox].visible, get(false));
  135. </action>
  136. <action name="mobilescale" autorun="preinit" devices="mobile">
  137. mul(stagescale,0.5);
  138. </action>
  139. <action name="rotateVideo">
  140. set(hotspot[video].rotate, %1);
  141. </action>
  142. <action name="playSceneName">
  143. def(scale, string, get(hotspot[video].scale));
  144. <!-- 打印日志 -->
  145. <!-- showlog(true, top); -->
  146. <!-- mobilescale(); -->
  147. <!-- 播放视频 -->
  148. set(hotspot[video].visible, 'true');
  149. set(hotspot[image_hotspot].visible, 'true');
  150. hotspot[video].playvideo(%1, '', false);
  151. set(hotspot[video].scale, get(scale));
  152. </action>
  153. <action name="stopPeopleVideo">
  154. <!-- 播放视频 -->
  155. <!-- hotspot[video].playvideo('', '', false); -->
  156. hotspot[video].stop();
  157. set(hotspot[video].visible, get(false));
  158. set(hotspot[image_hotspot].visible, get(false));
  159. </action>
  160. <!-- 显示数字宠物 -->
  161. <action name="playPetVideo">
  162. def(scale, string, get(hotspot[petVideo].scale));
  163. set(hotspot[petVideo].visible, 'true');
  164. hotspot[petVideo].playvideo(%1, '', false);
  165. set(hotspot[petVideo].scale, get(scale));
  166. </action>
  167. <!-- 隐藏数字宠物 -->
  168. <action name="stopPetVideo">
  169. hotspot[petVideo].stop();
  170. set(hotspot[petVideo].visible, get(false));
  171. </action>
  172. <!-- 设置数字人缩放大小 -->
  173. <action name="scalePeopleChange">
  174. set(hotspot[video].scale, %1);
  175. </action>
  176. <!-- 设置宠物缩放大小 -->
  177. <action name="scalePetChange">
  178. set(hotspot[petVideo].scale, %1);
  179. </action>
  180. <!-- 切换状态播放,暂停 -->
  181. <action name="toggleMute">
  182. set(hotspot[video].muted, %1);
  183. set(hotspot[petVideo].muted, %1);
  184. mutesound(bgsnd,%1);
  185. </action>
  186. <!-- 视频初始化完成 -->
  187. <action name="videoreadyFunc">
  188. jscall('window.videoready()');
  189. <!-- set(hotspot[video].scale, 0.3); -->
  190. </action>
  191. <!-- 视频播放 -->
  192. <action name="videoplayHandle">
  193. jscall('window.onvideoplay()');
  194. <!-- set(hotspot[video].scale, 0.3); -->
  195. </action>
  196. <action name="playBgMusic">
  197. <!-- 播放背景音乐 -->
  198. playsound(bgsnd, %1, true);
  199. mutesound(bgsnd,%2);
  200. <!-- mutesound(bgsnd,%2); -->
  201. </action>
  202. <!-- 关闭所有的声音 -->
  203. <action name="closeVoice">
  204. destroysound(bgsnd);
  205. </action>
  206. <!-- 播放音乐设置,引入插件 -->
  207. <plugin name="soundinterface"
  208. url="https://dm.static.elab-plus.com/soundinterface.swf"
  209. alturl="https://dm.static.elab-plus.com/soundinterface.js"
  210. preload="true"
  211. keep="true"
  212. loop="false"
  213. muted="true"
  214. ></plugin>
  215. <!-- 截图 -->
  216. <action name="makescreenshot_init" type="Javascript" autorun="onstart"><![CDATA[
  217. // count the screenshots (for the filenames)
  218. krpano.makescreenshot_count = 1;
  219. // create an empty Object as makeScreenshot cache
  220. var makeScreenshotCache = {};
  221. // add a 'makescreenshot' action to krpano
  222. krpano.makescreenshot = function(leftX,leftY,screenshotwidth,screenshotheight,hasRedBox=false)
  223. {
  224. // if there is already a screenshot layer, remove it now
  225. console.warn("***makescreenshot***",krpano.webGL,leftX,leftY,screenshotwidth,screenshotheight)
  226. var canvas = krpano.webGL.canvas;
  227. var pix = window.devicePixelRatio;
  228. // make a screenshot as canvas
  229. var sizeinfo = {w:screenshotwidth*pix, h:screenshotheight*pix};
  230. var crop = {
  231. x:leftX*pix,
  232. y:leftY*pix,
  233. w:screenshotwidth*pix,
  234. h:screenshotheight*pix
  235. };
  236. var scaledCanvas = document.createElement("canvas");
  237. var scaledContext = scaledCanvas.getContext('2d');
  238. scaledCanvas.width = 1684;//分享小图的尺寸-宽度-二倍图
  239. scaledCanvas.height = 1344;//分享小图的尺寸-高度-二倍图
  240. var unit = sizeinfo.w/scaledCanvas.width;
  241. var vfw = sizeinfo.w;
  242. var vfh = scaledCanvas.height * unit;
  243. var screenshotcanvas = krpano.webGL.makeScreenshot(
  244. canvas.width,
  245. canvas.height,
  246. true,
  247. "png",
  248. 1.0,
  249. crop,
  250. sizeinfo,
  251. makeScreenshotCache);
  252. var shotImg = '';
  253. var shareImg = '';
  254. if (screenshotcanvas)
  255. {
  256. //var imgBase64 = screenshotcanvas.toDataURL();
  257. // var shotImgBase64 = screenshotcanvas;
  258. var imgBase64 = screenshotcanvas;
  259. console.warn("***makescreenshot1***",vfw,vfh,scaledCanvas.width,scaledCanvas.height,hasRedBox)
  260. if(hasRedBox=='true'){//有前置背景
  261. var image = new Image();;
  262. image.src = imgBase64;
  263. image.onload = function() {
  264. scaledContext.save();
  265. scaledContext.drawImage(image,0,0,vfw,vfh,0,0,scaledCanvas.width,scaledCanvas.height);
  266. scaledContext.restore();
  267. var imageObj = new Image();;
  268. imageObj.src = 'https://dm.static.elab-plus.com/miniProgram/shareBg.png';
  269. imageObj.setAttribute("crossOrigin", "anonymous");
  270. imageObj.onload = function() {
  271. scaledContext.drawImage(imageObj,0,0,scaledCanvas.width,scaledCanvas.height,0,0,scaledCanvas.width,scaledCanvas.height);
  272. var img_src = scaledCanvas.toDataURL();
  273. screenshot(img_src,2);//生成分享的图
  274. }
  275. }
  276. }
  277. screenshot(imgBase64,1);
  278. function screenshot(imgBase64,type){
  279. var reqUrl = window.$config.api_url + 'elab-marketing-file/upload/uploadBase64';
  280. var data = JSON.stringify({
  281. base64Str: imgBase64
  282. })
  283. var request = $.ajax({
  284. type: "POST",
  285. url: reqUrl,
  286. contentType: 'application/json;charset=UTF-8',
  287. data: data
  288. });
  289. request.done(function(result) {
  290. console.warn("***krpano-request-result****",hasRedBox,result)
  291. if (result && result.success) {
  292. let shottingImg = result.single.filePath;
  293. if(type==1){
  294. shotImg = shottingImg;
  295. }else if(type==2){
  296. shareImg = shottingImg;
  297. }
  298. if(hasRedBox=='true'){
  299. if(shotImg && shareImg){
  300. window.show_img(shotImg,shareImg);
  301. }
  302. }else{
  303. window.show_img(shotImg,shareImg);
  304. }
  305. }
  306. });
  307. request.fail(function(jqXHR, textStatus) {
  308. console.warn("Request failed: " + textStatus);
  309. });
  310. }
  311. }
  312. }
  313. ]]>
  314. </action>
  315. </scene>
  316. </krpano>