当前位置:   article > 正文

Krpano 二维全景图项目开发记录

krpano debugger

Krpano是一款全景开发插件,废话就不多说了,这篇文章用于记录Krpano后台集成开发,即将该插件应用到后台系统中,上传全景图片后,可自动生成全景,同时可以在场景编辑器中自定义路线、语音等,简化了全景开发的复杂性。

官方网站

  • https://krpano.com

参考案例

  • http://www.krpano.tech/

 

Krpano 二维全景图项目开发记录

全景图嵌入式开发

服务器端数据处理

全景图场景编辑器

全景图数据文件生成

全景图数据文件回显-涉及添加多个全景(*重要)

 

Tour代码模块

动态统一代码模板(tour.xml.jsp)

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <krpano version="1.19" title="Virtual Tour">
  4. <include url="%SWFPATH%/skin/vtourskin.xml?v=1.3" />
  5. <action name="startup" autorun="onstart">
  6. if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );
  7. loadscene(get(startscene), null, MERGE);
  8. playsound(bgsnd, '', 0);
  9. if(startactions !== null, startactions() );
  10. js('onready');
  11. </action>
  12. <c:forEach items="${param.tourUrlIds}" var="UUID">
  13. <scene name="${UUID}" title="${UUID}" onstart="" thumburl="panos/${UUID}/thumb.jpg" lat="" lng="" heading="">
  14. <view hlookat="0" vlookat="0" fovtype="MFOV" fov="90" fovmin="5" fovmax="120" vlookatmin="-90" vlookatmax="90" limitview="lookat"/>
  15. <preview url="panos/${UUID}/preview.jpg" />
  16. <image>
  17. <cube url="panos/${UUID}/pano_%s.jpg" />
  18. </image>
  19. </scene>
  20. </c:forEach>
  21. </krpano>

Java代码模块

全景图Tour.xml文件代码生成及保存

全景图Tour.xml文件代码回显二次生成保存

全景图多图选择

  1. /**
  2. * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
  3. */
  4. package com.thinkgem.jeesite.modules.hnly.web;
  5. import java.io.BufferedReader;
  6. import java.io.BufferedWriter;
  7. import java.io.File;
  8. import java.io.FileInputStream;
  9. import java.io.FileOutputStream;
  10. import java.io.IOException;
  11. import java.io.InputStreamReader;
  12. import java.io.OutputStreamWriter;
  13. import java.io.PrintWriter;
  14. import java.net.URLDecoder;
  15. import java.util.ArrayList;
  16. import java.util.Arrays;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. import javax.servlet.http.HttpServletRequest;
  21. import javax.servlet.http.HttpServletResponse;
  22. import org.apache.shiro.authz.annotation.RequiresPermissions;
  23. import org.junit.runners.Parameterized.Parameter;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Controller;
  26. import org.springframework.ui.Model;
  27. import org.springframework.web.bind.annotation.ModelAttribute;
  28. import org.springframework.web.bind.annotation.RequestBody;
  29. import org.springframework.web.bind.annotation.RequestMapping;
  30. import org.springframework.web.bind.annotation.RequestParam;
  31. import org.springframework.web.multipart.MultipartFile;
  32. import org.springframework.web.servlet.mvc.support.RedirectAttributes;
  33. import org.w3c.dom.NamedNodeMap;
  34. import org.w3c.dom.Node;
  35. import org.w3c.dom.NodeList;
  36. import com.thinkgem.jeesite.common.config.Global;
  37. import com.thinkgem.jeesite.common.mapper.JsonMapper;
  38. import com.thinkgem.jeesite.common.persistence.Page;
  39. import com.thinkgem.jeesite.common.utils.FileUtils;
  40. import com.thinkgem.jeesite.common.utils.IdGen;
  41. import com.thinkgem.jeesite.common.utils.KrpanoUtils;
  42. import com.thinkgem.jeesite.common.utils.StringUtils;
  43. import com.thinkgem.jeesite.common.web.BaseController;
  44. import com.thinkgem.jeesite.modules.hnly.entity.KrpanoHotspots;
  45. import com.thinkgem.jeesite.modules.hnly.entity.KrpanoView;
  46. import com.thinkgem.jeesite.modules.hnly.entity.Panoramic;
  47. import com.thinkgem.jeesite.modules.hnly.entity.PanoramicMaterialPic;
  48. import com.thinkgem.jeesite.modules.hnly.entity.PanoramicPicHotspots;
  49. import com.thinkgem.jeesite.modules.hnly.entity.PanoramicPicMusic;
  50. import com.thinkgem.jeesite.modules.hnly.entity.PanoramicPicView;
  51. import com.thinkgem.jeesite.modules.hnly.service.PanoramicMaterialPicService;
  52. import com.thinkgem.jeesite.modules.hnly.service.PanoramicPicHotspotsService;
  53. import com.thinkgem.jeesite.modules.hnly.service.PanoramicPicMusicService;
  54. import com.thinkgem.jeesite.modules.hnly.service.PanoramicPicViewService;
  55. import com.thinkgem.jeesite.modules.hnly.service.PanoramicService;
  56. /**
  57. * 全景图管理Controller
  58. * @author WenC
  59. * @version 2017-08-15
  60. */
  61. @Controller
  62. @RequestMapping(value = "${adminPath}/hnly/panoramic")
  63. public class PanoramicController extends BaseController {
  64. @Autowired
  65. private PanoramicService panoramicService;
  66. @Autowired
  67. private PanoramicMaterialPicService panoramicMaterialPicService;
  68. @Autowired
  69. private PanoramicPicViewService panoramicPicViewService;
  70. @Autowired
  71. private PanoramicPicHotspotsService panoramicPicHotspotsService;
  72. @Autowired
  73. private PanoramicPicMusicService panoramicPicMusicService;
  74. Map<String, String> iMap = new HashMap<String, String>();
  75. @ModelAttribute
  76. public Panoramic get(@RequestParam(required=false) String id) {
  77. Panoramic entity = null;
  78. if (StringUtils.isNotBlank(id)){
  79. entity = panoramicService.get(id);
  80. }
  81. if (entity == null){
  82. entity = new Panoramic();
  83. }
  84. return entity;
  85. }
  86. @RequiresPermissions("hnly:panoramic:view")
  87. @RequestMapping(value = {"list", ""})
  88. public String list(Panoramic panoramic, HttpServletRequest request, HttpServletResponse response, Model model) {
  89. Page<Panoramic> page = panoramicService.findPage(new Page<Panoramic>(request, response), panoramic);
  90. model.addAttribute("page", page);
  91. return "modules/hnly/panoramicList";
  92. }
  93. @RequiresPermissions("hnly:panoramic:view")
  94. @RequestMapping(value = "form")
  95. public String form(Panoramic panoramic, Model model) {
  96. model.addAttribute("panoramic", panoramic);
  97. return "modules/hnly/panoramicForm";
  98. }
  99. @RequiresPermissions("hnly:panoramic:edit")
  100. @RequestMapping(value = "save")
  101. public String save(Panoramic panoramic, Model model, @RequestParam("imagesUrl") MultipartFile file, HttpServletRequest request, RedirectAttributes redirectAttributes) {
  102. if (!beanValidator(model, panoramic)){
  103. return form(panoramic, model);
  104. }
  105. if(!file.isEmpty()){
  106. String uuid = IdGen.uuidAtoZ();
  107. String path = request.getSession().getServletContext().getRealPath("krpano/panos");
  108. String fileName = file.getOriginalFilename();
  109. String uuidFileName = uuid + fileName.substring(fileName.lastIndexOf("."));
  110. File dir = new File(path,uuidFileName);
  111. if(!dir.exists()){
  112. dir.mkdirs();
  113. }
  114. //MultipartFile自带的解析方法
  115. try {
  116. file.transferTo(dir);
  117. } catch (IllegalStateException e) {
  118. // TODO Auto-generated catch block
  119. e.printStackTrace();
  120. } catch (IOException e) {
  121. // TODO Auto-generated catch block
  122. e.printStackTrace();
  123. }
  124. String allPath = request.getContextPath() + "/krpano/panos/" + uuidFileName;
  125. panoramic.setUrl(allPath);
  126. }
  127. panoramicService.save(panoramic);
  128. addMessage(redirectAttributes, "保存全景图成功");
  129. return "redirect:"+Global.getAdminPath()+"/hnly/panoramic/?repage";
  130. }
  131. @RequiresPermissions("hnly:panoramic:edit")
  132. @RequestMapping(value = "delete")
  133. public String delete(Panoramic panoramic, RedirectAttributes redirectAttributes) {
  134. panoramicService.delete(panoramic);
  135. addMessage(redirectAttributes, "删除全景图成功");
  136. return "redirect:"+Global.getAdminPath()+"/hnly/panoramic/?repage";
  137. }
  138. @RequiresPermissions("hnly:panoramic:edit")
  139. @RequestMapping(value = "vtourGenerate")
  140. public String vtourGenerate(Panoramic panoramic, RedirectAttributes redirectAttributes){
  141. String tempThumbUrl = KrpanoUtils.krpanoVtourMultires(KrpanoUtils.VNP, panoramic.getUrl());
  142. panoramic.setThumbUrl(tempThumbUrl);
  143. panoramic.setTourUrl(KrpanoUtils.getTourUrl(panoramic.getUrl()));
  144. panoramicService.save(panoramic);
  145. addMessage(redirectAttributes, "生成全景图成功");
  146. return "redirect:"+Global.getAdminPath()+"/hnly/panoramic/?repage";
  147. }
  148. @RequiresPermissions("hnly:panoramic:edit")
  149. @RequestMapping(value = "multiSelect")
  150. public String multiSelect(Panoramic panoramic, HttpServletRequest request, HttpServletResponse response, Model model) {
  151. // System.out.println(panoramic.getPanoramicMaterialPicIdList());
  152. model.addAttribute("panoramic", panoramic);
  153. model.addAttribute("AllPanoramicMaterialPic", panoramicMaterialPicService.findList(null));
  154. return "modules/hnly/panoramicMultiSelect";
  155. }
  156. /**
  157. * 全景图更新
  158. * @param panoramic
  159. * @param request
  160. * @param response
  161. * @param model
  162. */
  163. @RequiresPermissions("hnly:panoramic:edit")
  164. @RequestMapping(value = "multiSelectSave")
  165. public void multiSelectSave(Panoramic panoramic, HttpServletRequest request, HttpServletResponse response, Model model) {
  166. // 更新全景关联要素图片数据
  167. String[] cpmpil = request.getParameterValues("panoramicMaterialPicIdList");
  168. // System.out.println(cpmpil);
  169. // if(null != cpmpil){
  170. // for(String s : cpmpil){
  171. // System.out.println(s);
  172. // }
  173. // }
  174. // System.out.println(panoramic.getPanoramicMaterialPicIdList());
  175. if(null == cpmpil){ //如果为NULL,证明只选择了主场景,没有选择其他场景联动
  176. panoramic.setPanoramicMaterialPicList(null);
  177. }
  178. panoramicService.updatePanoramicPic(panoramic);
  179. panoramic = panoramicService.get(panoramic.getId());
  180. String tourUrls = panoramic.getTourUrl();
  181. // String panoramicMaterialPicIds = "";
  182. for(int i=0;i<panoramic.getPanoramicMaterialPicList().size();i++){
  183. PanoramicMaterialPic pmp = panoramic.getPanoramicMaterialPicList().get(i);
  184. tourUrls = tourUrls + "," + pmp.getTourUrl();
  185. // panoramicMaterialPicIds = panoramicMaterialPicIds + pmp.getId() + ",";
  186. // if((i+1)==panoramic.getPanoramicMaterialPicList().size()){
  187. // panoramicMaterialPicIds = panoramicMaterialPicIds.substring(0, panoramicMaterialPicIds.length()-1);
  188. // }
  189. }
  190. String[] tourUrlsTemp = tourUrls.split(","); //页面选中的场景数组数据
  191. List<PanoramicPicView> panoramicPicViewList = panoramicPicViewService.findListByPanoramicId(panoramic.getId());
  192. // ===== 存在代码修改数据,检查有无新增数据,有则添加codeView代码原始模块
  193. if(null != panoramicPicViewList && panoramicPicViewList.size()>0){
  194. String[] tourUrlsExist = new String[panoramicPicViewList.size()];
  195. for(int i=0;i<panoramicPicViewList.size();i++){
  196. tourUrlsExist[i] = panoramicPicViewList.get(i).getTourUrl();
  197. }
  198. List<String> delList = compare(tourUrlsTemp,tourUrlsExist);
  199. for (String str : delList) {
  200. // System.out.println(str);
  201. iMap.clear();
  202. iMap.put("panoramicId", panoramic.getId());
  203. iMap.put("tourUrl", str);
  204. panoramicPicViewService.delByPanoramicIdAndTourUrl(iMap);
  205. }
  206. List<String> addList = compare(tourUrlsExist,tourUrlsTemp);
  207. for (String str : addList) {
  208. // System.out.println(str);
  209. PanoramicPicView panoramicPicView = new PanoramicPicView();
  210. panoramicPicView.setTourUrl(str);
  211. panoramicPicView.setPanoramic(panoramic);
  212. panoramicPicView.setCode("<view hlookat=\"0\" vlookat=\"0\" fovtype=\"MFOV\" fov=\"90\" fovmin=\"5\" fovmax=\"120\" vlookatmin=\"-90\" vlookatmax=\"90\" limitview=\"auto\"/>\r\n");
  213. panoramicPicViewService.save(panoramicPicView);
  214. }
  215. } else {
  216. for(String str : tourUrlsTemp){
  217. PanoramicPicView panoramicPicView = new PanoramicPicView();
  218. panoramicPicView.setTourUrl(str);
  219. panoramicPicView.setPanoramic(panoramic);
  220. panoramicPicView.setCode("<view hlookat=\"0\" vlookat=\"0\" fovtype=\"MFOV\" fov=\"90\" fovmin=\"5\" fovmax=\"120\" vlookatmin=\"-90\" vlookatmax=\"90\" limitview=\"auto\"/>\r\n");
  221. panoramicPicViewService.save(panoramicPicView);
  222. }
  223. }
  224. // ===== 存在代码修改数据,检查有无新增数据,新增加场景中去除原有场景则去除codeHotspots代码模块,在此不执行热点原始代码模块,因为是一对多的关系
  225. List<PanoramicPicHotspots> panoramicPicHotspotsList = panoramicPicHotspotsService.findListByPanoramicId(panoramic.getId());
  226. if(null != panoramicPicHotspotsList && panoramicPicHotspotsList.size()>0){
  227. String[] tourUrlsExist = new String[panoramicPicHotspotsList.size()];
  228. for(int i=0;i<panoramicPicHotspotsList.size();i++){
  229. tourUrlsExist[i] = panoramicPicHotspotsList.get(i).getTourUrl();
  230. }
  231. List<String> delList = compare(tourUrlsTemp,tourUrlsExist);
  232. for (String str : delList) {
  233. System.out.println(str);
  234. iMap.clear();
  235. iMap.put("panoramicId", panoramic.getId());
  236. iMap.put("tourUrl", str);
  237. panoramicPicHotspotsService.delByPanoramicIdAndTourUrl(iMap);
  238. }
  239. }
  240. // ===== 获取语音数据回显
  241. List<PanoramicPicMusic> panoramicPicMusicList = panoramicPicMusicService.findListByPanoramicId(panoramic.getId());
  242. // ===== 配置文件回显操作,重新生成配置文件
  243. if(null != panoramic && "1".equals(panoramic.getTourFlag())){
  244. panoramicPicViewList = panoramicPicViewService.findListByPanoramicId(panoramic.getId());
  245. StringBuffer sb = new StringBuffer();
  246. sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
  247. sb.append("<krpano version=\"1.19\" title=\"Virtual Tour\">\r\n");
  248. sb.append("<include url=\"%SWFPATH%/skin/vtourskin.xml?v=1.3\" />\r\n");
  249. // sb.append("<skin_settings maps=\"false\" maps_type=\"google\" maps_bing_api_key=\"\" maps_google_api_key=\"\" maps_zoombuttons=\"false\" gyro=\"true\" webvr=\"true\" webvr_gyro_keeplookingdirection=\"false\" webvr_prev_next_hotspots=\"true\" littleplanetintro=\"true\" title=\"true\" thumbs=\"true\" thumbs_width=\"120\" thumbs_height=\"80\" thumbs_padding=\"10\" thumbs_crop=\"0|40|240|160\" thumbs_opened=\"false\" thumbs_text=\"false\" thumbs_dragging=\"true\" thumbs_onhoverscrolling=\"false\" thumbs_scrollbuttons=\"false\" thumbs_scrollindicator=\"false\" thumbs_loop=\"false\" tooltips_buttons=\"false\" tooltips_thumbs=\"false\" tooltips_hotspots=\"false\" tooltips_mapspots=\"false\" deeplinking=\"false\" loadscene_flags=\"MERGE\" loadscene_blend=\"OPENBLEND(0.5, 0.0, 0.75, 0.05, linear)\" loadscene_blend_prev=\"SLIDEBLEND(0.5, 180, 0.75, linear)\" loadscene_blend_next=\"SLIDEBLEND(0.5, 0, 0.75, linear)\" loadingtext=\"loading...\" layout_width=\"100%\" layout_maxwidth=\"814\" controlbar_width=\"-24\" controlbar_height=\"40\" controlbar_offset=\"20\" controlbar_offset_closed=\"-40\" controlbar_overlap.no-fractionalscaling=\"10\" controlbar_overlap.fractionalscaling=\"0\" design_skin_images=\"vtourskin.png\" design_bgcolor=\"0x2D3E50\" design_bgalpha=\"0.8\" design_bgborder=\"0\" design_bgroundedge=\"1\" design_bgshadow=\"0 4 10 0x000000 0.3\" design_thumbborder_bgborder=\"3 0xFFFFFF 1.0\" design_thumbborder_padding=\"2\" design_thumbborder_bgroundedge=\"0\" design_text_css=\"color:#FFFFFF; font-family:Arial;\" design_text_shadow=\"1\"/>");
  250. sb.append("<action name=\"startup\" autorun=\"onstart\">\r\n");
  251. sb.append("if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );loadscene(get(startscene), null, MERGE);playsound(bgsnd, '', 0);if(startactions !== null, startactions() );js('onready');\r\n");
  252. sb.append("</action>\r\n");
  253. for(int i=0;i<panoramicPicViewList.size();i++){
  254. PanoramicPicView panoramicPicView = panoramicPicViewList.get(i);
  255. String sceneName = panoramicPicView.getTourUrl();
  256. String codeView = panoramicPicView.getCode();
  257. sb.append("<scene name=\"" + sceneName + "\" title=\"" + sceneName + "\" onstart=\"\" thumburl=\"panos/" + sceneName + "/thumb.jpg\" ");
  258. for(int j=0;j<panoramicPicMusicList.size();j++){
  259. PanoramicPicMusic panoramicPicMusic = panoramicPicMusicList.get(j);
  260. if(sceneName.equals(panoramicPicMusic.getTourUrl())){
  261. sb.append(panoramicPicMusic.getCode() + " ");
  262. break;
  263. }
  264. }
  265. sb.append("lat=\"\" lng=\"\" heading=\"\">\r\n");
  266. sb.append(codeView);
  267. sb.append("<preview url=\"panos/" + sceneName + "/preview.jpg\" />\r\n");
  268. sb.append("<image>\r\n");
  269. sb.append("<cube url=\"panos/" + sceneName + "/pano_%s.jpg\" />\r\n");
  270. sb.append("</image>\r\n");
  271. iMap.clear();
  272. iMap.put("panoramicId", panoramic.getId());
  273. iMap.put("tourUrl", sceneName);
  274. panoramicPicHotspotsList = panoramicPicHotspotsService.findListByPanoramicIdAndTourUrl(iMap);
  275. for(int j=0;j<panoramicPicHotspotsList.size();j++){
  276. PanoramicPicHotspots hotspots = panoramicPicHotspotsList.get(j);
  277. sb.append(hotspots.getCode());
  278. System.out.println(hotspots.getCode());
  279. }
  280. sb.append("</scene>\r\n");
  281. }
  282. // sb.append("<action name=\"add_all_the_time_tooltip_for_VR\">\r\n");
  283. // sb.append("txtadd(tooltipname, 'vrtooltip_', get(name));addhotspot(get(tooltipname)); set(hotspot[get(tooltipname)].type,text);copy(hotspot[get(tooltipname)].edge,hotspot[get(name)].edge);copy(hotspot[get(tooltipname)].distorted,hotspot[get(name)].distorted);copy(hotspot[get(tooltipname)].ath,hotspot[get(name)].ath);copy(hotspot[get(tooltipname)].atv,hotspot[get(name)].atv);set(hotspot[get(tooltipname)].oy,-50);set(hotspot[get(tooltipname)].ox,0);set(hotspot[get(tooltipname)].vcenter,false);set(hotspot[get(tooltipname)].padding,10);set(hotspot[get(tooltipname)].bg,true);set(hotspot[get(tooltipname)].bgcolor,0x000000);set(hotspot[get(tooltipname)].bgroundedge,5);set(hotspot[get(tooltipname)].bgalpha,0.65);set(hotspot[get(tooltipname)].bgborder,0);set(hotspot[get(tooltipname)].bgshadow,'0 0 0 0x000000 0');set(hotspot[get(tooltipname)].css,'text-align:left; color:#FFFFFF; font-family:MicrosoftYahei; font-size:24px;');if(device.mobile,set(hotspot[get(tooltipname)].css,'text-align:center; color:#FFFFFF; font-family:MicrosoftYahei; font-weight:bold; font-size:24px;'););set(hotspot[get(tooltipname)].txtshadow,'0 0 0 0x000000 0');if(text == '' OR text === null,copy(hotspot[get(tooltipname)].html,scene[get(linkedscene)].title),copy(hotspot[get(tooltipname)].html,text);); set(hotspot[get(tooltipname)].enabled,false); if(lp_running == false,set(hotspot[get(tooltipname)].visible,true); , if(!webvr.isenabled,if(lp_running == true,set(hotspot[get(tooltipname)].visible,false); set(hotspot[get(tooltipname)].mark2,true););););if(hotspot[get(name)].normal == false, set(hotspot[get(tooltipname)].normal,false);set(hotspot[get(tooltipname)].onloaded,if(webvr.isenabled,set(visible,false);, if(lp_running == false OR lp_running == null OR lp_running === null, set(visible,true);););););\r\n");
  284. // sb.append("</action>\r\n");
  285. sb.append("</krpano>\r\n");
  286. String path = request.getSession().getServletContext().getRealPath("krpano");
  287. String pathAll = path + "\\tour" + panoramic.getTourUrl() + ".xml.jsp";
  288. FileUtils.createFile(pathAll);
  289. File f = new File(pathAll);
  290. try {
  291. FileOutputStream fos = new FileOutputStream(pathAll);
  292. //设置bom头
  293. fos.write(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF});
  294. OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
  295. BufferedWriter bw = new BufferedWriter(osw);
  296. bw.close();
  297. } catch (IOException e) {
  298. System.out.println(e.toString());
  299. }
  300. try {
  301. // 第四个属性必须要设置true,对存在的文件执行追加操作,否则上面设置的bom头会被覆盖掉
  302. FileUtils.writeStringToFile(f, sb.toString(), "UTF-8", true);
  303. } catch (IOException e) {
  304. // TODO Auto-generated catch block
  305. e.printStackTrace();
  306. }
  307. }
  308. try {
  309. response.sendRedirect(request.getContextPath() + "/krpano/tour_editor_custom.jsp"
  310. + "?panoramicId=" + panoramic.getId()
  311. + "&tourUrl=" + panoramic.getTourUrl()
  312. + "&tourFlag=" + panoramic.getTourFlag()
  313. // + "&panoramicMaterialPicIds=" + panoramicMaterialPicIds
  314. + "&tourUrlIds=" + tourUrls);
  315. System.out.println(request.getContextPath() + "/krpano/tour_editor_custom.jsp"
  316. + "?panoramicId=" + panoramic.getId()
  317. + "&tourUrl=" + panoramic.getTourUrl()
  318. + "&tourFlag=" + panoramic.getTourFlag()
  319. // + "&panoramicMaterialPicIds=" + panoramicMaterialPicIds
  320. + "&tourUrlIds=" + tourUrls);
  321. } catch (IOException e) {
  322. // TODO Auto-generated catch block
  323. e.printStackTrace();
  324. }
  325. }
  326. /**
  327. * 全景图保存
  328. * @param panoramic
  329. * @param request
  330. * @param response
  331. * @param data
  332. * @throws IOException
  333. */
  334. @RequiresPermissions("hnly:panoramic:edit")
  335. @RequestMapping(value = "vtourSave")
  336. public void vtourSave(Panoramic panoramic, HttpServletRequest request, HttpServletResponse response, @RequestBody String data) throws IOException{
  337. // data = URLDecoder.decode(URLDecoder.decode( data, "UTF-8"), "UTF-8");
  338. System.out.println(data);
  339. System.out.println(request.getParameter("panoramicId"));
  340. String panoramicId = request.getParameter("panoramicId");
  341. panoramic = panoramicService.get(panoramicId);
  342. System.out.println(request.getParameter("tourUrlIds"));
  343. String tourUrlIds = request.getParameter("tourUrlIds");
  344. String[] tourUrlIdsData = tourUrlIds.split(",");
  345. // System.out.println(request.getParameter("panoramicMaterialPicIds"));
  346. // String panoramicMaterialPicIds = request.getParameter("panoramicMaterialPicIds");
  347. // String[] panoramicMaterialPicIdsData = panoramicMaterialPicIds.split(",");
  348. // JSONObject obj = new JSONObject(data.substring(1, data.length()-1));
  349. // System.out.println(obj.getString("index"));
  350. JsonMapper ji = JsonMapper.getInstance();
  351. List<KrpanoView> krpanoViewList = (List<KrpanoView>)ji.fromJson(data, ji.createCollectionType(ArrayList.class, KrpanoView.class));
  352. // for(KrpanoView kv : krpanoViewList){
  353. // System.out.println(kv.getName());
  354. // }
  355. // KrpanoView kv = (KrpanoView) JsonMapper.fromJsonString(data.substring(1, data.length()-1), KrpanoView.class);
  356. // System.out.println(kv.getName() + kv.getInitH() + kv.getInitV());
  357. StringBuffer sb = new StringBuffer();
  358. String viewCode = "";
  359. sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
  360. sb.append("<krpano version=\"1.19\" title=\"Virtual Tour\">\r\n");
  361. sb.append("<include url=\"%SWFPATH%/skin/vtourskin.xml?v=1.3\" />\r\n");
  362. //sb.append("<skin_settings maps=\"false\" maps_type=\"google\" maps_bing_api_key=\"\" maps_google_api_key=\"\" maps_zoombuttons=\"false\" gyro=\"true\" webvr=\"true\" webvr_gyro_keeplookingdirection=\"false\" webvr_prev_next_hotspots=\"true\" littleplanetintro=\"true\" title=\"true\" thumbs=\"true\" thumbs_width=\"120\" thumbs_height=\"80\" thumbs_padding=\"10\" thumbs_crop=\"0|40|240|160\" thumbs_opened=\"false\" thumbs_text=\"false\" thumbs_dragging=\"true\" thumbs_onhoverscrolling=\"false\" thumbs_scrollbuttons=\"false\" thumbs_scrollindicator=\"false\" thumbs_loop=\"false\" tooltips_buttons=\"false\" tooltips_thumbs=\"false\" tooltips_hotspots=\"false\" tooltips_mapspots=\"false\" deeplinking=\"false\" loadscene_flags=\"MERGE\" loadscene_blend=\"OPENBLEND(0.5, 0.0, 0.75, 0.05, linear)\" loadscene_blend_prev=\"SLIDEBLEND(0.5, 180, 0.75, linear)\" loadscene_blend_next=\"SLIDEBLEND(0.5, 0, 0.75, linear)\" loadingtext=\"loading...\" layout_width=\"100%\" layout_maxwidth=\"814\" controlbar_width=\"-24\" controlbar_height=\"40\" controlbar_offset=\"20\" controlbar_offset_closed=\"-40\" controlbar_overlap.no-fractionalscaling=\"10\" controlbar_overlap.fractionalscaling=\"0\" design_skin_images=\"vtourskin.png\" design_bgcolor=\"0x2D3E50\" design_bgalpha=\"0.8\" design_bgborder=\"0\" design_bgroundedge=\"1\" design_bgshadow=\"0 4 10 0x000000 0.3\" design_thumbborder_bgborder=\"3 0xFFFFFF 1.0\" design_thumbborder_padding=\"2\" design_thumbborder_bgroundedge=\"0\" design_text_css=\"color:#FFFFFF; font-family:Arial;\" design_text_shadow=\"1\"/>");
  363. sb.append("<action name=\"startup\" autorun=\"onstart\">\r\n");
  364. sb.append("if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );loadscene(get(startscene), null, MERGE);playsound(bgsnd, '', 0);if(startactions !== null, startactions() );js('onready');\r\n");
  365. sb.append("</action>\r\n");
  366. for(int i=0;i<tourUrlIdsData.length;i++){
  367. String sceneName = tourUrlIdsData[i];
  368. sb.append("<scene name=\"" + sceneName + "\" title=\"" + sceneName + "\" onstart=\"\" thumburl=\"panos/" + sceneName + "/thumb.jpg\" ");
  369. for(int j=0;j<krpanoViewList.size();j++){
  370. KrpanoView kv = krpanoViewList.get(j);
  371. if(kv.getName().equals(sceneName) && null != kv.getBgmusic()){
  372. String codeMusic = "bgmusic=\"" + kv.getBgmusic() + "\" ";
  373. sb.append(codeMusic);
  374. iMap.clear();
  375. iMap.put("panoramicId", panoramic.getId());
  376. iMap.put("tourUrl", sceneName);
  377. PanoramicPicMusic panoramicPicMusic = panoramicPicMusicService.findByPanoramicIdAndTourUrl(iMap);
  378. if(null == panoramicPicMusic){
  379. panoramicPicMusic = new PanoramicPicMusic();
  380. panoramicPicMusic.setPanoramic(panoramic);
  381. panoramicPicMusic.setTourUrl(sceneName);
  382. }
  383. panoramicPicMusic.setCode(codeMusic);
  384. panoramicPicMusicService.save(panoramicPicMusic);
  385. break;
  386. }
  387. }
  388. sb.append("lat=\"\" lng=\"\" heading=\"\">\r\n");
  389. for(int j=0;j<krpanoViewList.size();j++){
  390. KrpanoView kv = krpanoViewList.get(j);
  391. // System.out.println(kv.getName());
  392. if(kv.getName().equals(sceneName)){
  393. if(null != kv.getInitH() && null != kv.getInitV() && null != kv.getFov()){
  394. viewCode = "<view hlookat=\"" + kv.getInitH() + "\" vlookat=\"" + kv.getInitV() + "\" fovtype=\"MFOV\" fov=\"" + kv.getFov() + "\" fovmin=\"5\" fovmax=\"120\" vlookatmin=\"-90\" vlookatmax=\"90\" limitview=\"auto\"/>\r\n";
  395. iMap.clear();
  396. iMap.put("panoramicId", panoramic.getId());
  397. iMap.put("tourUrl", sceneName);
  398. PanoramicPicView panoramicPicView = panoramicPicViewService.findByPanoramicIdAndTourUrl(iMap);
  399. panoramicPicView.setCode(viewCode);
  400. panoramicPicViewService.save(panoramicPicView);
  401. } else {
  402. viewCode = "<view hlookat=\"0\" vlookat=\"0\" fovtype=\"MFOV\" fov=\"90\" fovmin=\"5\" fovmax=\"120\" vlookatmin=\"-90\" vlookatmax=\"90\" limitview=\"auto\"/>\r\n";
  403. }
  404. sb.append(viewCode);
  405. break;
  406. }
  407. // 根据实际测试,场景中有多少个图片会传多少个参数,这个暂时隐藏,如出现意外情况,再加上
  408. // if((j+1)==krpanoViewList.size()){
  409. // viewCode = "<view hlookat=\"0\" vlookat=\"0\" fovtype=\"MFOV\" fov=\"90\" fovmin=\"5\" fovmax=\"120\" vlookatmin=\"-90\" vlookatmax=\"90\" limitview=\"auto\"/>\r\n";
  410. // sb.append(viewCode);
  411. // }
  412. }
  413. sb.append("<preview url=\"panos/" + sceneName + "/preview.jpg\" />\r\n");
  414. sb.append("<image>\r\n");
  415. sb.append("<cube url=\"panos/" + sceneName + "/pano_%s.jpg\" />\r\n");
  416. sb.append("</image>\r\n");
  417. for(int j=0;j<krpanoViewList.size();j++){
  418. KrpanoView kv = krpanoViewList.get(j);
  419. if(kv.getName().equals(sceneName)){
  420. for(KrpanoHotspots hotspots : kv.getHotSpots()){
  421. if(hotspots.getName().indexOf("vrtooltip") != -1) continue;
  422. String codeHotspots = "<hotspot text=\"" + hotspots.getText() + "\" ath=\"" + hotspots.getAth() + "\" atv=\"" + hotspots.getAtv() + "\" linkedscene=\"" + hotspots.getLinkedscene() + "\" name=\"" + hotspots.getName() + "\" style=\"" + hotspots.getStyle() + "\" dive=\"" + hotspots.isDive() + "\" onloaded=\"add_all_the_time_tooltip_for_VR()\"/>\r\n";
  423. //sb.append(codeHotspots);
  424. iMap.clear();
  425. iMap.put("panoramicId", panoramic.getId());
  426. iMap.put("tourUrl", sceneName);
  427. iMap.put("name", hotspots.getName());
  428. System.out.println(hotspots.getName());
  429. PanoramicPicHotspots panoramicPicHotspots = panoramicPicHotspotsService.findByPanoramicIdAndTourUrlAndName(iMap);
  430. if(null == panoramicPicHotspots){
  431. panoramicPicHotspots = new PanoramicPicHotspots();
  432. panoramicPicHotspots.setPanoramic(panoramic);
  433. panoramicPicHotspots.setTourUrl(sceneName);
  434. panoramicPicHotspots.setName(hotspots.getName());
  435. panoramicPicHotspots.setLinkedscene(hotspots.getLinkedscene());
  436. }
  437. panoramicPicHotspots.setCode(codeHotspots);
  438. panoramicPicHotspotsService.save(panoramicPicHotspots);
  439. }
  440. iMap.clear();
  441. iMap.put("panoramicId", panoramic.getId());
  442. iMap.put("tourUrl", sceneName);
  443. List<PanoramicPicHotspots> panoramicPicHotspotsList = panoramicPicHotspotsService.findListByPanoramicIdAndTourUrl(iMap);
  444. for(int k=0;k<panoramicPicHotspotsList.size();k++){
  445. PanoramicPicHotspots hotspots = panoramicPicHotspotsList.get(k);
  446. sb.append(hotspots.getCode());
  447. System.out.println(hotspots.getCode());
  448. }
  449. }
  450. }
  451. sb.append("</scene>\r\n");
  452. }
  453. //sb.append("<action name=\"add_all_the_time_tooltip_for_VR\">\r\n");
  454. //sb.append("txtadd(tooltipname, 'vrtooltip_', get(name));addhotspot(get(tooltipname)); set(hotspot[get(tooltipname)].type,text);copy(hotspot[get(tooltipname)].edge,hotspot[get(name)].edge);copy(hotspot[get(tooltipname)].distorted,hotspot[get(name)].distorted);copy(hotspot[get(tooltipname)].ath,hotspot[get(name)].ath);copy(hotspot[get(tooltipname)].atv,hotspot[get(name)].atv);set(hotspot[get(tooltipname)].oy,-50);set(hotspot[get(tooltipname)].ox,0);set(hotspot[get(tooltipname)].vcenter,false);set(hotspot[get(tooltipname)].padding,10);set(hotspot[get(tooltipname)].bg,true);set(hotspot[get(tooltipname)].bgcolor,0x000000);set(hotspot[get(tooltipname)].bgroundedge,5);set(hotspot[get(tooltipname)].bgalpha,0.65);set(hotspot[get(tooltipname)].bgborder,0);set(hotspot[get(tooltipname)].bgshadow,'0 0 0 0x000000 0');set(hotspot[get(tooltipname)].css,'text-align:left; color:#FFFFFF; font-family:MicrosoftYahei; font-size:24px;');if(device.mobile,set(hotspot[get(tooltipname)].css,'text-align:center; color:#FFFFFF; font-family:MicrosoftYahei; font-weight:bold; font-size:24px;'););set(hotspot[get(tooltipname)].txtshadow,'0 0 0 0x000000 0');if(text == '' OR text === null,copy(hotspot[get(tooltipname)].html,scene[get(linkedscene)].title),copy(hotspot[get(tooltipname)].html,text);); set(hotspot[get(tooltipname)].enabled,false); if(lp_running == false,set(hotspot[get(tooltipname)].visible,true); , if(!webvr.isenabled,if(lp_running == true,set(hotspot[get(tooltipname)].visible,false); set(hotspot[get(tooltipname)].mark2,true););););if(hotspot[get(name)].normal == false, set(hotspot[get(tooltipname)].normal,false);set(hotspot[get(tooltipname)].onloaded,if(webvr.isenabled,set(visible,false);, if(lp_running == false OR lp_running == null OR lp_running === null, set(visible,true);););););\r\n");
  455. //sb.append("</action>\r\n");
  456. sb.append("</krpano>\r\n");
  457. String path = request.getSession().getServletContext().getRealPath("krpano");
  458. String pathAll = path + "\\tour" + panoramic.getTourUrl() + ".xml.jsp";
  459. FileUtils.createFile(pathAll);
  460. File f = new File(pathAll);
  461. // if(!f.exists()){
  462. // f.mkdirs();
  463. // }
  464. try {
  465. FileOutputStream fos = new FileOutputStream(pathAll);
  466. //设置bom头
  467. fos.write(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF});
  468. OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
  469. BufferedWriter bw = new BufferedWriter(osw);
  470. bw.close();
  471. } catch (IOException e) {
  472. System.out.println(e.toString());
  473. }
  474. // 第四个属性必须要设置true,对存在的文件执行追加操作,否则上面设置的bom头会被覆盖掉
  475. FileUtils.writeStringToFile(f, sb.toString(), "UTF-8", true);
  476. panoramic = panoramicService.get(panoramicId);
  477. panoramic.setTourFlag("1");
  478. panoramicService.save(panoramic);
  479. response.setContentType("text/html;charset=utf-8");
  480. PrintWriter pw = response.getWriter();
  481. String mess = "保存成功";
  482. pw.write(URLDecoder.decode(mess, "utf-8"));
  483. pw.flush();
  484. pw.close();
  485. }
  486. public static <T> List<T> compare(T[] t1, T[] t2) {
  487. List<T> list1 = Arrays.asList(t1);
  488. List<T> list2 = new ArrayList<T>();
  489. for (T t : t2) {
  490. if (!list1.contains(t)) {
  491. list2.add(t);
  492. }
  493. }
  494. return list2;
  495. }
  496. }

Krpano工具类-生成场景

  1. package com.thinkgem.jeesite.common.utils;
  2. import java.io.BufferedReader;
  3. import java.io.BufferedWriter;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.io.OutputStreamWriter;
  7. import javax.servlet.http.HttpServletResponse;
  8. public class KrpanoUtils {
  9. public static final String VN = "vtour-normal";
  10. public static final String VM = "vtour-multires";
  11. public static final String VNP = "vtour-normal-picture";
  12. public static final String VMP = "vtour-multires-picture";
  13. public static synchronized String krpanoVtourMultires(String type, String fileUrl){
  14. // 生成全景图thumb的图片地址
  15. String tempFileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.lastIndexOf("."));
  16. String tempThumbUrl = fileUrl.substring(0, fileUrl.lastIndexOf("/") + 1)
  17. + tempFileName + "/thumb.jpg";
  18. // 创建全景图
  19. String projectRealPath = RequestResponseContext.getRequest().getSession().getServletContext().getRealPath("").replaceAll("\\\\\\\\","\\\\");
  20. String command = projectRealPath
  21. + "\\krpano\\krpanotools64.exe makepano -config="
  22. + "templates\\" + type + ".config "
  23. + projectRealPath + fileUrl.replaceAll("/", "\\\\");
  24. // + projectRealPath.substring(0, projectRealPath.lastIndexOf("\\")) + fileUrl.replaceAll("/", "\\\\");
  25. System.out.println(command);
  26. Runtime runtime = Runtime.getRuntime();
  27. StringBuilder sb = new StringBuilder();
  28. BufferedReader bufferedReader = null;
  29. Process process = null;
  30. try {
  31. process = runtime.exec(command);
  32. try {
  33. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
  34. bw.write("y\r\n");
  35. bw.flush();
  36. bw.close();
  37. } catch (Exception e) {
  38. // TODO Auto-generated catch block
  39. e.printStackTrace();
  40. }
  41. bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
  42. String line = null;
  43. while ((line = bufferedReader.readLine()) != null) {
  44. sb.append(line + "\n");
  45. // if(line.contains("overwrite")){
  46. // System.out.println(line);
  47. // }
  48. }
  49. } catch (IOException e) {
  50. e.printStackTrace();
  51. } finally {
  52. try {
  53. bufferedReader.close();
  54. process.destroy();
  55. } catch (IOException e) {
  56. // TODO Auto-generated catch block
  57. e.printStackTrace();
  58. }
  59. }
  60. // System.out.println(sb.toString());
  61. return tempThumbUrl;
  62. }
  63. // 获取全景地址编号
  64. public static String getTourUrl(String fileUrl){
  65. String tempFileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1, fileUrl.lastIndexOf("."));
  66. return tempFileName;
  67. }
  68. public static void main(String[] args) {
  69. System.out.println();
  70. // KrpanoUtils.krpanoVtourMultires(null);
  71. }
  72. }

全景编辑器

tour_editor_custom.jsp

  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <title>全景高级编辑DEMO</title>
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
  8. <meta name="apple-mobile-web-app-capable" content="yes"/>
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  10. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  11. <meta http-equiv="x-ua-compatible" content="IE=edge"/>
  12. <link rel="stylesheet" href="./style/krpano.editor.css">
  13. <style>
  14. @-ms-viewport {
  15. width: device-width;
  16. }
  17. @media only screen and (min-device-width: 800px) {
  18. html {
  19. overflow: hidden;
  20. }
  21. }
  22. html {
  23. height: 100%;
  24. }
  25. body {
  26. height: 100%;
  27. overflow: hidden;
  28. margin: 0;
  29. padding: 0;
  30. font-family: Arial, Helvetica, sans-serif;
  31. font-size: 16px;
  32. color: #FFFFFF;
  33. background-color: #000000;
  34. }
  35. .sureBtn {
  36. background-color: #00a3d8;
  37. border-bottom-color: #00a3d8;
  38. border-bottom-left-radius: 0px;
  39. border-bottom-right-radius: 0px;
  40. border-bottom-style: solid;
  41. border-bottom-width: 1px;
  42. border-image-outset: 0;
  43. border-image-repeat: stretch stretch;
  44. border-image-slice: 100%;
  45. border-image-source: none;
  46. border-image-width: 1;
  47. border-left-color: #00a3d8;
  48. border-left-style: solid;
  49. border-left-width: 1px;
  50. border-right-color: #00a3d8;
  51. border-right-style: solid;
  52. border-right-width: 1px;
  53. border-top-color: #00a3d8;
  54. border-top-left-radius: 0px;
  55. border-top-right-radius: 0px;
  56. border-top-style: solid;
  57. border-top-width: 1px;
  58. box-sizing: border-box;
  59. color: rgb(255, 255, 255);
  60. cursor: pointer;
  61. display: inline-block;
  62. font-family: "microsoft yahei",Arial,Helvetica,sans-serif;
  63. font-feature-settings: normal;
  64. font-kerning: auto;
  65. font-language-override: normal;
  66. font-size: 13px;
  67. font-size-adjust: none;
  68. font-stretch: normal;
  69. font-style: normal;
  70. font-variant: normal;
  71. font-variant-alternates: normal;
  72. font-variant-caps: normal;
  73. font-variant-east-asian: normal;
  74. font-variant-ligatures: normal;
  75. font-variant-numeric: normal;
  76. font-variant-position: normal;
  77. font-weight: 400;
  78. line-height: 20px;
  79. list-style-image: none;
  80. list-style-position: outside;
  81. list-style-type: none;
  82. margin-bottom: 0px;
  83. margin-left: 0px;
  84. margin-right: 0px;
  85. margin-top: 0px;
  86. padding-bottom: 5px;
  87. padding-left: 12px;
  88. padding-right: 12px;
  89. padding-top: 5px;
  90. text-align: center;
  91. text-shadow: rgba(0, 0, 0, 0.2) 0px -1px 0px;
  92. text-transform: none;
  93. transition-delay: 0s;
  94. transition-duration: 0.4s;
  95. transition-property: all;
  96. transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1);
  97. vertical-align: middle;
  98. white-space: nowrap;
  99. -moz-border-bottom-colors: none;
  100. -moz-border-left-colors: none;
  101. -moz-border-right-colors: none;
  102. -moz-border-top-colors: none;
  103. -moz-user-select: none;
  104. }
  105. </style>
  106. </head>
  107. <body>
  108. <script src="tour.js"></script>
  109. <div id="pano" style="width:100%;height:100%;">
  110. <noscript>
  111. <table style="width:100%;height:100%;">
  112. <tr style="vertical-align:middle;">
  113. <td>
  114. <div style="text-align:center;">ERROR:<br/><br/>Javascript not activated<br/><br/></div>
  115. </td>
  116. </tr>
  117. </table>
  118. </noscript>
  119. <script>
  120. //alert("${param.prefixUrl}");
  121. //touFlag为1,为回显编辑模式,调用对应生成的XML文件,否则使用默认的模板文件
  122. embedpano({
  123. swf: "tour.swf",
  124. xml: "tour${param.tourFlag eq '1' ? param.tourUrl : ''}.xml.jsp?tourUrlIds=${param.tourUrlIds}",
  125. target: "pano",
  126. html5: "auto",
  127. mobilescale: 1.0,
  128. passQueryParameters: true
  129. });
  130. </script>
  131. </div>
  132. <input type="hidden" name="panoramicId" id="panoramicId" value="${param.panoramicId}"/>
  133. <!--
  134. <input type="hidden" name="panoramicMaterialPicIds" id="panoramicMaterialPicIds" value="${param.panoramicMaterialPicIds}"/> -->
  135. <input type="hidden" name="tourUrlIds" id="tourUrlIds" value="${param.tourUrlIds}"/>
  136. <div class="frame" name="#viewFrame">
  137. <button onclick="setAsDefaultView()" class="btn btn-blue">设为初始视角</button>
  138. <div class="frame-line frame-line-top"></div>
  139. <div class="frame-line frame-line-right"></div>
  140. <div class="frame-line frame-line-bottom"></div>
  141. <div class="frame-line frame-line-left"></div>
  142. <span class="angle angle-tl"><i class="angle-a"></i><i class="angle-b"></i></span>
  143. <span class="angle angle-tr"><i class="angle-a"></i><i class="angle-b"></i></span>
  144. <span class="angle angle-bl"><i class="angle-a"></i><i class="angle-b"></i></span>
  145. <span class="angle angle-br"><i class="angle-a"></i><i class="angle-b"></i></span>
  146. </div>
  147. <div class="overlay overlay-right">
  148. <div class="save-wrap">
  149. <button onclick="save()" id="isEdited" class="btn btn-blue">保存</button>
  150. </div>
  151. <div class="tool-panel">
  152. <ul class="tool-btn-lst">
  153. <li>
  154. <span class="btn J-tool-btn btn-blue" data-target="#viewFrame">视角</span>
  155. <div class="tool-main" style="display: block" name="#viewFrame">
  156. <section class="tool-section">
  157. <div style="margin: 5px;">
  158. <label style="padding-right: 5px;vertical-align: middle;" for="autoSpin">自动旋转</label>
  159. <input type="checkbox" name="autoSpin" id="autoSpin" style="vertical-align: middle;"
  160. onclick="autoSpinClick()"/>
  161. </div>
  162. <div id="waitTimeInput" style="display: none;margin: 5px;">
  163. <label style="padding-right: 5px;vertical-align: middle;" for="waitTime">等待时间</label>
  164. <input type="text" class="wait-time-input" id="waitTime" onblur="autoSpinClick()"/>
  165. <label style="padding-left: 5px"></label>
  166. </div>
  167. <div style="margin: 5px;">
  168. <label>(默认应用于所有场景)</label>
  169. </div>
  170. </section>
  171. <section class="tool-section">
  172. <div style="margin: 5px;">
  173. <label>初始fov
  174. <input type="text" class="fov-input" id="initFov" onblur="updateFov()"/>
  175. </label>
  176. </div>
  177. <section id="sample-pb">
  178. <article>
  179. <div class="number-pb">
  180. <div class="number-pb-shown" style="display: none">
  181. <div class="triangle triangle-up-left" style="float: left;"></div>
  182. <div class="triangle triangle-down"></div>
  183. <div class="triangle triangle-up-right" style="float: right;"></div>
  184. </div>
  185. <div class="number-pb-num" style="left: 70%;">
  186. </div>
  187. </div>
  188. </article>
  189. </section>
  190. <div style="margin: 5px;">
  191. <label>最小fov
  192. <input type="text" class="fov-input" id="initFovMin" onblur="updateFov()"/>
  193. </label>
  194. </div>
  195. <div style="margin: 5px;">
  196. <label>最大fov
  197. <input type="text" class="fov-input" id="initFovMax" onblur="updateFov()"/>
  198. </label>
  199. </div>
  200. <div style="margin: 5px;">
  201. <input type="button" style="vertical-align: middle;" value="应用于所有场景" class="btn btn-blue"
  202. onclick="fovForAll()"/>
  203. </div>
  204. </section>
  205. </div>
  206. </li>
  207. <li>
  208. <span class="btn J-tool-btn" data-target="#toolHot">热点</span>
  209. <div class="tool-main" name="#toolHot" id="hotToolButton">
  210. <section class="tool-section">
  211. <h3 style="margin-bottom: 5px;">热点类型</h3>
  212. <button class="btn btn-blue">场景切换</button>
  213. </section>
  214. <section class="tool-section">
  215. <h3 style="margin-bottom: 5px;">热点列表</h3>
  216. <ul>
  217. <div id="hotSpotList"></div>
  218. <script id="tplHotSpotList" type="text/html">
  219. {{each list as eachSpot}}
  220. <div class="hot-spot-list" name="{{eachSpot.name}}Hover">
  221. <div class="hot-spot-img" style="background-image: url('{{eachSpot.url}}')"
  222. spot-style="{{eachSpot.style}}"></div>
  223. <div class="hot-spot-text">{{eachSpot.linkedscene}}</div>
  224. <div class="hot-spot-del" onclick="removeHotSpot('{{eachSpot.name}}')">-</div>
  225. </div>
  226. {{/each}}
  227. </script>
  228. </ul>
  229. <button class="hot-spot-button" onclick="showAddHotSpot()">+</button>
  230. </section>
  231. </div>
  232. </li>
  233. <li>
  234. <span class="btn J-tool-btn" data-target="#toolVoice">音乐</span>
  235. <div class="tool-main" name="#toolVoice" id="toolVoiceButton">
  236. <section class="tool-section">
  237. <h3 style="margin-bottom: 5px;">音乐类型</h3>
  238. <button class="btn btn-blue">语音播报</button>
  239. <button class="btn btn-blue">背景音乐</button>
  240. </section>
  241. <section class="tool-section">
  242. <h3 style="margin-bottom: 5px;">音乐列表</h3>
  243. <ul>
  244. <div id="bgMusicList"></div>
  245. <script id="tplBgMusicList" type="text/html">
  246. {{each list as eachMusic}}
  247. <div class="hot-spot-list" name="{{eachMusic.name}}Hover">
  248. <div class="hot-spot-text">{{eachMusic.name}}</div>
  249. <div class="hot-spot-del" onclick="removeBgMusic('{{eachMusic.name}}')">-</div>
  250. </div>
  251. {{/each}}
  252. </script>
  253. </ul>
  254. <button class="hot-spot-button" onclick="showAddVoice()">+</button>
  255. </section>
  256. </div>
  257. </li>
  258. </ul>
  259. </div>
  260. </div>
  261. <div class="left-column">
  262. <div class="scene-select">
  263. <div class="blue-banner"></div>
  264. <div class="select_scene_text">
  265. <p class="p_title">场景选择</p>
  266. </div>
  267. <div class="blue-banner"></div>
  268. <ul style="margin: 0;padding: 0;">
  269. <div id="sceneList"></div>
  270. <script id="tplSceneList" type="text/html">
  271. {{each list as scene}}
  272. <li key="{{scene.index}}" name="{{scene.name}}" class="li-scene">
  273. <div class="thumbs-img-scene-list"
  274. style='background-image: url("panos/{{scene.name}}/thumb.jpg")'></div>
  275. <div class="li-scene-span" onclick="changeScene({{scene.index}})">{{scene.name}}</div>
  276. <input type="hidden" value="{{scene.name}}" class="li-scene-input" onblur="doRename($(this))"/>
  277. <input type="button" class="scene-li-button" onclick="rename($(this).prev())"/>
  278. <div class="circle" onclick="selectWelcomeScene({{scene.index}})"></div>
  279. </li>
  280. {{/each}}
  281. </script>
  282. </ul>
  283. </div>
  284. </div>
  285. <div class="add-hot-pot" style="display: none" name="#toolHot">
  286. <div class="add-hot-banner">添加全景切换热点<a class="div-close" onclick="hideAddHotSpot()">×</a></div>
  287. <div class="progress-banner">
  288. <div class="progress-title progress-title-on" id="selectStyleTitle"><span style="line-height: 30px">选择样式</span>
  289. </div>
  290. <div class="progress-title" id="goToSceneTitle"><span style="line-height: 30px">选择目标场景</span></div>
  291. <div class="progress-title" id="writeTitleTitle"><span style="line-height: 30px">填写title</span></div>
  292. </div>
  293. <div>
  294. <div class="dive-text">俯冲效果:</div>
  295. <div class="my-open-out">
  296. <div class="my-open-in my-open-in-open"></div>
  297. </div>
  298. </div>
  299. <div id="selectStyle" class="add-hot-content">
  300. <div class="add-hot-bottom-div">
  301. <div class="hot-style"
  302. style="background-image: url('./skin/vtourskin_hotspot.png')"
  303. name="skin_hotspotstyle"></div>
  304. </div>
  305. <div class="add-hot-button" onclick="nextToSelectTargetScene()">下一步</div>
  306. </div>
  307. <div id="goToScene" class="add-hot-content" style="display: none">
  308. <div class="add-hot-bottom-div">
  309. <div id="targetScene"></div>
  310. <script id="tplTargetScene" type="text/html">
  311. {{each list as each}}
  312. <div class="select-scene-div" name="{{each.name}}">
  313. {{each.name}}
  314. <div class="thumbs-img" style='background-image: url("panos/{{each.name}}/thumb.jpg")'></div>
  315. </div>
  316. {{/each}}
  317. </script>
  318. </div>
  319. <div class="add-hot-button" onclick="nextToWriteTitle()">下一步</div>
  320. </div>
  321. <div id="writeTitle" class="add-hot-content write-title" style="display: none">
  322. <div class="add-hot-bottom-div">
  323. <p style="padding: 50px;"><label for="addHotTitle">请出入热点上方的文字title(可不填):</label></p>
  324. <input type="text" id="addHotTitle"/>
  325. </div>
  326. <div class="add-hot-button" onclick="addHotSpot()">完成</div>
  327. </div>
  328. </div>
  329. <div class="add-voice" style="display: none" name="#toolVoice">
  330. <div class="add-hot-banner">添加背景语音/音乐<a class="div-close" onclick="hideAddVoice()">×</a></div>
  331. <div id="writeTitle" class="add-hot-content write-title">
  332. <div class="add-hot-bottom-div" id="add-voice-frame">
  333. <p style="padding: 20px;"><label for="addHotTitle">请选择一段语音/音乐插入到场景中:</label> <button class="sureBtn" onclick="addVoice()">确定选择</button></p>
  334. </div>
  335. </div>
  336. </div>
  337. <script src="./script/jQuery-2.1.4.min.js"></script>
  338. <script src="./script/krpano.editor.js"></script>
  339. <script src="./script/template.min.js"></script>
  340. </body>
  341. </html>

krpano.editor.css

  1. html, body, div, span, applet, input, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  2. margin: 0;
  3. padding: 0;
  4. border: 0;
  5. font-size: 100%;
  6. vertical-align: baseline;
  7. }
  8. article, aside, details, figcaption, figure, footer, header, menu, nav, section {
  9. display: block;
  10. }
  11. body {
  12. line-height: 1;
  13. }
  14. ol, ul {
  15. list-style: none;
  16. }
  17. blockquote, q {
  18. quotes: none;
  19. }
  20. blockquote:before,
  21. blockquote:after {
  22. content: none;
  23. }
  24. q:before,
  25. q:after {
  26. content: "";
  27. }
  28. table {
  29. border-collapse: collapse;
  30. border-spacing: 0;
  31. }
  32. button {
  33. padding: 0;
  34. margin: 0;
  35. background-color: #fff;
  36. border: none;
  37. outline: 0;
  38. }
  39. body {
  40. font-family: 'PingFang SC', 'Helvetica Neue', 'Helvetica', 'STHeitiSC-Light', 'Arial', 'Microsoft Yahei', sans-serif;
  41. font-size: 14px;
  42. line-height: 1.5;
  43. }
  44. a {
  45. text-decoration: none;
  46. }
  47. .btn {
  48. cursor: pointer;
  49. display: inline-block;
  50. padding: 8px 20px;
  51. background-color: rgba(0, 0, 0, .7);
  52. color: #fff;
  53. border-radius: 4px;
  54. font-size: 14px;
  55. }
  56. .btn-blue {
  57. background-color: #2185D0;
  58. }
  59. .scene-name {
  60. position: absolute;
  61. top: 0;
  62. left: 0;
  63. right: 0;
  64. background-color: rgba(0, 0, 0, .6);
  65. color: #fff;
  66. text-align: right;
  67. height: 40px;
  68. line-height: 40px;
  69. padding-right: 15px;
  70. }
  71. .frame-line {
  72. position: absolute;
  73. background-color: #eee;
  74. }
  75. .frame-line-top,
  76. .frame-line-bottom {
  77. height: 1px;
  78. left: 30%;
  79. right: 30%;
  80. }
  81. .frame-line-top {
  82. top: 25%;
  83. }
  84. .frame-line-bottom {
  85. bottom: 25%;
  86. }
  87. .frame-line-left,
  88. .frame-line-right {
  89. top: 25%;
  90. bottom: 25%;
  91. width: 1px;
  92. }
  93. .frame-line-left {
  94. left: 30%;
  95. }
  96. .frame-line-right {
  97. right: 30%;
  98. }
  99. .angle {
  100. width: 40px;
  101. height: 40px;
  102. position: absolute;
  103. }
  104. .angle i {
  105. position: absolute;
  106. background-color: #eee;
  107. }
  108. .angle-a {
  109. left: 0;
  110. width: 8px;
  111. top: 0;
  112. bottom: 0;
  113. }
  114. .angle-b {
  115. top: 0;
  116. left: 0;
  117. right: 0;
  118. height: 8px;
  119. }
  120. .angle-tl {
  121. left: 30%;
  122. top: 25%;
  123. }
  124. .angle-tr {
  125. right: 30%;
  126. top: 25%;
  127. }
  128. .angle-tr .angle-a {
  129. left: auto;
  130. right: 0;
  131. }
  132. .angle-bl {
  133. left: 30%;
  134. bottom: 25%;
  135. }
  136. .angle-bl .angle-b {
  137. bottom: 0;
  138. top: auto;
  139. }
  140. .angle-br {
  141. right: 30%;
  142. bottom: 25%;
  143. }
  144. .angle-br .angle-a {
  145. left: auto;
  146. right: 0;
  147. }
  148. .angle-br .angle-b {
  149. top: auto;
  150. bottom: 0;
  151. }
  152. .frame .btn {
  153. position: absolute;
  154. left: 50%;
  155. top: 30%;
  156. transform: translate(-50%, 0);
  157. }
  158. .overlay {
  159. position: absolute;
  160. right: 15px;
  161. top: 15px;
  162. z-index: 9999;
  163. }
  164. .save-wrap {
  165. margin-top: 40px;
  166. margin-bottom: 20px;
  167. }
  168. .tool-panel {
  169. position: relative;
  170. }
  171. .tool-btn-lst {
  172. float: right;
  173. }
  174. .tool-btn-lst > li {
  175. margin-bottom: 10px;
  176. position: relative;
  177. }
  178. .tool-main {
  179. moz-user-select: -moz-none;
  180. -moz-user-select: none;
  181. -o-user-select:none;
  182. -khtml-user-select:none;
  183. -webkit-user-select:none;
  184. -ms-user-select:none;
  185. user-select:none;
  186. display: none;
  187. position: absolute;
  188. right: 80px;
  189. top: 0;
  190. padding: 15px;
  191. background-color: rgba(0, 0, 0, .7);
  192. min-width: 200px;
  193. border-top: 3px solid #00a3d8;
  194. }
  195. .tool-section {
  196. border-bottom: 1px solid #2185D0;
  197. padding: 15px 0;
  198. }
  199. .tool-section:last-child {
  200. margin-bottom: 0;
  201. border-bottom: none;
  202. padding-bottom: 0;
  203. }
  204. .tool-section:first-child {
  205. padding-top: 0;
  206. }
  207. .tool-section h4 {
  208. color: #999;
  209. }
  210. .choose-lst {
  211. margin: 7px 0;
  212. }
  213. .choose-lst li {
  214. padding: 3px 0;
  215. }
  216. .choose-lst input {
  217. margin-right: 5px;
  218. }
  219. .left-column {
  220. position: absolute;
  221. top: 0;
  222. left: -250px;
  223. z-index: 9999;
  224. background-color: rgba(0, 0, 0, 0.3);
  225. width: 250px;
  226. height: 100%;
  227. -webkit-animation:hideLeft 0.8s infinite;
  228. -webkit-animation-iteration-count:1;
  229. }
  230. @-webkit-keyframes showLeft {
  231. 0% {left: -250px;}
  232. 100% {left: 0;}
  233. }
  234. @-webkit-keyframes hideLeft {
  235. 0% {left: 0;}
  236. 100% {left: -250px;}
  237. }
  238. .scene-select {
  239. margin-top: 20px;
  240. margin-left: 10px;
  241. margin-right: 10px;
  242. background-color: rgba(0, 0, 0, 0.5);
  243. padding-bottom: 1px;
  244. overflow: auto;
  245. max-height: 600px;
  246. overflow-x: hidden;
  247. }
  248. .blue-banner {
  249. background-color: #00a3d8;
  250. height: 3px;
  251. }
  252. .li-scene {
  253. list-style-type: none;
  254. height: 30px;
  255. border: 2px solid rgba(255, 255, 255, 0);
  256. margin: 10px;
  257. width: 200px;
  258. }
  259. .li-scene:hover {
  260. border-color: #FF9800;
  261. }
  262. .li-scene-hover {
  263. border-color: #FF9800;
  264. }
  265. .li-scene-span {
  266. cursor: pointer;
  267. height: 30px;
  268. font-size: 16px;
  269. line-height: 30px;
  270. float: left;
  271. width: 100px;
  272. overflow: hidden;
  273. }
  274. .li-scene-input {
  275. background-color: rgba(185, 185, 185, 0.5);
  276. height: 30px;
  277. width: 100px;
  278. font-size: 18px;
  279. }
  280. .scene-li-button {
  281. width: 30px;
  282. height: 30px;
  283. background: rgba(255, 255, 255, 0) url("../img/krpano.modify.png");
  284. border: 0;
  285. float: right;
  286. cursor: pointer;
  287. }
  288. .circle {
  289. width: 30px;
  290. height: 30px;
  291. float: right;
  292. background: #292827 url("../img/krpano.home.png");
  293. border-radius: 50%;
  294. text-align: center;
  295. line-height: 30px;
  296. cursor: pointer;
  297. }
  298. .select_scene_text {
  299. text-align: center;
  300. background-color: rgba(40, 40, 40, 0.7);
  301. height: 50px;
  302. }
  303. .p_title {
  304. margin-top: 0;
  305. font-size: 20px;
  306. line-height: 50px;
  307. }
  308. .add-hot-pot {
  309. position: absolute;
  310. z-index: 9999;
  311. background-color: rgba(0, 0, 0, 0.8);
  312. width: 700px;
  313. height: 440px;
  314. top: 0;
  315. left: 0;
  316. bottom: 0;
  317. right: 0;
  318. margin: auto;
  319. }
  320. .add-voice {
  321. position: absolute;
  322. z-index: 9999;
  323. background-color: rgba(0, 0, 0, 0.8);
  324. width: 700px;
  325. height: 440px;
  326. top: 0;
  327. left: 0;
  328. bottom: 0;
  329. right: 0;
  330. margin: auto;
  331. }
  332. .progress-banner {
  333. margin: 20px;
  334. background-color: rgba(150, 150, 150, 0.4);
  335. height: 30px;
  336. }
  337. .progress-title {
  338. float: left;
  339. text-align: center;
  340. width: 33.33%;
  341. height: 100%;
  342. }
  343. .progress-title-on {
  344. background-color: #00a3d8;
  345. }
  346. .add-hot-banner {
  347. font-size: 16px;
  348. background-color: rgba(150, 150, 150, 0.4);
  349. padding: 8px 8px 8px 15px;
  350. height: 20px;
  351. line-height: 20px;
  352. }
  353. .div-close {
  354. cursor: pointer;
  355. float: right;
  356. font-size: 30px;
  357. }
  358. .add-hot-content {
  359. margin: 10px 20px 20px 20px;
  360. }
  361. .add-hot-bottom-div {
  362. height: 250px;
  363. }
  364. .write-title {
  365. font-size: 18px;
  366. text-align: center;
  367. }
  368. #addHotTitle {
  369. color: white;
  370. width: 57%;
  371. background-color: rgba(150, 150, 150, 0.4);
  372. }
  373. .add-hot-button {
  374. cursor: pointer;
  375. background-color: #00a3d8;
  376. line-height: 30px;
  377. text-align: center;
  378. font-size: 18px;
  379. height: 30px;
  380. }
  381. .hot-style {
  382. background-color: rgba(255, 255, 255, 0);
  383. border: 2px solid rgba(255, 255, 255, 0);
  384. cursor: pointer;
  385. margin: 7px;
  386. width: 64px;
  387. height: 56px;
  388. background-size: cover;
  389. float: left;
  390. }
  391. .hot-spot-img {
  392. background-color: rgba(255, 255, 255, 0);
  393. width: 32px;
  394. height: 32px;
  395. background-size: cover;
  396. float: left;
  397. }
  398. .hot-style:hover {
  399. border: 2px solid orange;
  400. }
  401. .hot-style-on {
  402. border: 2px solid orange;
  403. }
  404. .select-scene-div {
  405. float: left;
  406. width: 80px;
  407. text-align: center;
  408. cursor: pointer;
  409. margin: 5px;
  410. }
  411. .select-scene-div:hover {
  412. margin: 3px;
  413. border: 2px solid orange;
  414. }
  415. .select-scene-div-on {
  416. margin: 3px;
  417. border: 2px solid orange;
  418. }
  419. .thumbs-img {
  420. height: 80px;
  421. background-size: 80px 80px;
  422. margin-top: 5px;
  423. margin-left: auto;
  424. margin-right: auto;
  425. }
  426. .thumbs-img-scene-list {
  427. width: 30px;
  428. height: 30px;
  429. background-size: 30px 30px;
  430. float: left;
  431. margin-right: 10px;
  432. }
  433. .hot-pot-select-span {
  434. position: absolute;
  435. left: 15px;
  436. top: 5px;
  437. }
  438. .wait-time-input {
  439. vertical-align: middle;
  440. width: 30px;
  441. background-color: rgba(255, 255, 255, 0.5);
  442. text-align: center
  443. }
  444. .fov-input {
  445. vertical-align: middle;
  446. width: 65px;
  447. background-color: rgba(255, 255, 255, 0.5);
  448. text-align: center;
  449. float: right;
  450. height: 21px;
  451. }
  452. .hot-spot-list {
  453. height: 32px;
  454. width: 200px;
  455. color: white;
  456. font-size: 18px;
  457. border: solid 2px rgba(0, 0, 0, 0);
  458. margin-top: 5px;
  459. }
  460. .hot-spot-text {
  461. width: 130px;
  462. height: 26px;
  463. float: left;
  464. text-align: center;
  465. padding: 3px;
  466. }
  467. .hot-spot-del {
  468. cursor: pointer;
  469. width: 32px;
  470. height: 32px;
  471. float: left;
  472. text-align: center;
  473. background-color: rgba(255, 255, 255, 0.1);
  474. }
  475. .hot-spot-button {
  476. cursor: pointer;
  477. background-color: rgba(255, 255, 255, 0.1);
  478. height: 32px;
  479. width: 202px;
  480. color: white;
  481. font-size: 18px;
  482. margin-top: 10px;
  483. }
  484. .hot-spot-list-hover {
  485. border: solid 2px orange;
  486. }
  487. .number-pb {
  488. position: relative;
  489. height: 3px;
  490. background-color: #ffffff;
  491. margin: 40px 0;
  492. }
  493. .number-pb .number-pb-shown {
  494. position: absolute;
  495. background: #00a3d8;
  496. left: 0;
  497. height: 3px;
  498. }
  499. .number-pb .number-pb-num {
  500. position: absolute;
  501. background-color: #00a3d8;
  502. left: 0;
  503. padding: 0 5px;
  504. }
  505. .triangle-up-left {
  506. border-bottom: 20px solid #00a3d8;
  507. margin-top: 3px;
  508. margin-left: -10px;
  509. }
  510. .triangle-up-right {
  511. border-bottom: 20px solid #00a3d8;
  512. margin-top: 3px;
  513. margin-right: -10px;
  514. }
  515. .triangle-down {
  516. border-top: 20px solid #00a3d8;
  517. margin-top: -20px;
  518. float: none;
  519. }
  520. .triangle {
  521. width: 0;
  522. height: 0;
  523. border-left: 10px solid transparent;
  524. border-right: 10px solid transparent;
  525. }
  526. .my-open-out {
  527. margin-left: 90px;
  528. width: 40px;
  529. height: 20px;
  530. border-radius: 10px;
  531. position: relative;
  532. background: #00a3d8;
  533. }
  534. .my-open-in {
  535. width: 18px;
  536. height: 18px;
  537. border-radius: 9px;
  538. position: absolute;
  539. background: white;
  540. box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  541. top: 1px;
  542. }
  543. .my-open-in-open {
  544. right: 1px;
  545. }
  546. .my-open-in-close {
  547. left: 1px;
  548. }
  549. .dive-text {
  550. line-height: 20px;
  551. float: left;
  552. margin-left: 20px;
  553. }

jQuery-2.1.4.min.js

(略),自行下载。

template.min.js

  1. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  2. !function(){function a(a){return a.replace(t,"").replace(u,",").replace(v,"").replace(w,"").replace(x,"").split(y)}function b(a){return"'"+a.replace(/('|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+"'"}function c(c,d){function e(a){return m+=a.split(/\n/).length-1,k&&(a=a.replace(/\s+/g," ").replace(/<!--[\w\W]*?-->/g,"")),a&&(a=s[1]+b(a)+s[2]+"\n"),a}function f(b){var c=m;if(j?b=j(b,d):g&&(b=b.replace(/\n/g,function(){return m++,"$line="+m+";"})),0===b.indexOf("=")){var e=l&&!/^=[=#]/.test(b);if(b=b.replace(/^=[=#]?|[\s;]*$/g,""),e){var f=b.replace(/\s*\([^\)]+\)/,"");n[f]||/^(include|print)$/.test(f)||(b="$escape("+b+")")}else b="$string("+b+")";b=s[1]+b+s[2]}return g&&(b="$line="+c+";"+b),r(a(b),function(a){if(a&&!p[a]){var b;b="print"===a?u:"include"===a?v:n[a]?"$utils."+a:o[a]?"$helpers."+a:"$data."+a,w+=a+"="+b+",",p[a]=!0}}),b+"\n"}var g=d.debug,h=d.openTag,i=d.closeTag,j=d.parser,k=d.compress,l=d.escape,m=1,p={$data:1,$filename:1,$utils:1,$helpers:1,$out:1,$line:1},q="".trim,s=q?["$out='';","$out+=",";","$out"]:["$out=[];","$out.push(",");","$out.join('')"],t=q?"$out+=text;return $out;":"$out.push(text);",u="function(){var text=''.concat.apply('',arguments);"+t+"}",v="function(filename,data){data=data||$data;var text=$utils.$include(filename,data,$filename);"+t+"}",w="'use strict';var $utils=this,$helpers=$utils.$helpers,"+(g?"$line=0,":""),x=s[0],y="return new String("+s[3]+");";r(c.split(h),function(a){a=a.split(i);var b=a[0],c=a[1];1===a.length?x+=e(b):(x+=f(b),c&&(x+=e(c)))});var z=w+x+y;g&&(z="try{"+z+"}catch(e){throw {filename:$filename,name:'Render Error',message:e.message,line:$line,source:"+b(c)+".split(/\\n/)[$line-1].replace(/^\\s+/,'')};}");try{var A=new Function("$data","$filename",z);return A.prototype=n,A}catch(B){throw B.temp="function anonymous($data,$filename) {"+z+"}",B}}var d=function(a,b){return"string"==typeof b?q(b,{filename:a}):g(a,b)};d.version="3.0.0",d.config=function(a,b){e[a]=b};var e=d.defaults={openTag:"<%",closeTag:"%>",escape:!0,cache:!0,compress:!1,parser:null},f=d.cache={};d.render=function(a,b){return q(a,b)};var g=d.renderFile=function(a,b){var c=d.get(a)||p({filename:a,name:"Render Error",message:"Template not found"});return b?c(b):c};d.get=function(a){var b;if(f[a])b=f[a];else if("object"==typeof document){var c=document.getElementById(a);if(c){var d=(c.value||c.innerHTML).replace(/^\s*|\s*$/g,"");b=q(d,{filename:a})}}return b};var h=function(a,b){return"string"!=typeof a&&(b=typeof a,"number"===b?a+="":a="function"===b?h(a.call(a)):""),a},i={"<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","&":"&#38;"},j=function(a){return i[a]},k=function(a){return h(a).replace(/&(?![\w#]+;)|[<>"']/g,j)},l=Array.isArray||function(a){return"[object Array]"==={}.toString.call(a)},m=function(a,b){var c,d;if(l(a))for(c=0,d=a.length;d>c;c++)b.call(a,a[c],c,a);else for(c in a)b.call(a,a[c],c)},n=d.utils={$helpers:{},$include:g,$string:h,$escape:k,$each:m};d.helper=function(a,b){o[a]=b};var o=d.helpers=n.$helpers;d.onerror=function(a){var b="Template Error\n\n";for(var c in a)b+="<"+c+">\n"+a[c]+"\n\n";"object"==typeof console&&console.error(b)};var p=function(a){return d.onerror(a),function(){return"{Template Error}"}},q=d.compile=function(a,b){function d(c){try{return new i(c,h)+""}catch(d){return b.debug?p(d)():(b.debug=!0,q(a,b)(c))}}b=b||{};for(var g in e)void 0===b[g]&&(b[g]=e[g]);var h=b.filename;try{var i=c(a,b)}catch(j){return j.filename=h||"anonymous",j.name="Syntax Error",p(j)}return d.prototype=i.prototype,d.toString=function(){return i.toString()},h&&b.cache&&(f[h]=d),d},r=n.$each,s="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,undefined",t=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|\s*\.\s*[$\w\.]+/g,u=/[^\w$]+/g,v=new RegExp(["\\b"+s.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),w=/^\d[^,]*|,\d[^,]*/g,x=/^,+|,+$/g,y=/^$|,+/;e.openTag="{{",e.closeTag="}}";var z=function(a,b){var c=b.split(":"),d=c.shift(),e=c.join(":")||"";return e&&(e=", "+e),"$helpers."+d+"("+a+e+")"};e.parser=function(a){a=a.replace(/^\s/,"");var b=a.split(" "),c=b.shift(),e=b.join(" ");switch(c){case"if":a="if("+e+"){";break;case"else":b="if"===b.shift()?" if("+b.join(" ")+")":"",a="}else"+b+"{";break;case"/if":a="}";break;case"each":var f=b[0]||"$data",g=b[1]||"as",h=b[2]||"$value",i=b[3]||"$index",j=h+","+i;"as"!==g&&(f="[]"),a="$each("+f+",function("+j+"){";break;case"/each":a="});";break;case"echo":a="print("+e+");";break;case"print":case"include":a=c+"("+b.join(",")+");";break;default:if(/^\s*\|\s*[\w\$]/.test(e)){var k=!0;0===a.indexOf("#")&&(a=a.substr(1),k=!1);for(var l=0,m=a.split("|"),n=m.length,o=m[l++];n>l;l++)o=z(o,m[l]);a=(k?"=":"=#")+o}else a=d.helpers[c]?"=#"+c+"("+b.join(",")+");":"="+a}return a},"function"==typeof define?define(function(){return d}):"undefined"!=typeof exports?module.exports=d:this.template=d}();

krpano.editor.js

  1. var krpano = document.getElementById("krpanoSWFObject");
  2. var sceneList = [];
  3. var toAddHotSpot = {};
  4. var currentSceneIndex = 0;
  5. var movingSpot = {};
  6. //视角拖动模块变量
  7. var pbX = 0;
  8. var moveIntervalId;
  9. var canDownMove = false;
  10. var canLeftMove = false;
  11. var canRightMove = false;
  12. //设置为不动态显示,在页面中直接显示就好了 已经设置left: 0 !important;到页面中
  13. var canShowLeft = true;
  14. $(function () {
  15. //右侧功能选择
  16. $(".J-tool-btn").click(function () {
  17. $(".J-tool-btn").each(function () {
  18. $(this).removeClass("btn-blue");
  19. $("[name=" + $(this).attr("data-target") + "]").hide();
  20. });
  21. $(this).addClass("btn-blue");
  22. $("[name=" + $(this).attr("data-target") + "]").show();
  23. window.clearInterval(moveIntervalId);
  24. $(".add-hot-pot").hide();
  25. $(".add-voice").hide();
  26. });
  27. //视角拖动条
  28. $(".triangle-down").mouseup(function () {
  29. canDownMove = false;
  30. }).mouseout(function () {
  31. canDownMove = false;
  32. });
  33. $(".triangle-up-left").mouseup(function () {
  34. canLeftMove = false;
  35. }).mouseout(function () {
  36. canLeftMove = false;
  37. });
  38. $(".triangle-up-right").mouseup(function () {
  39. canRightMove = false;
  40. }).mouseout(function () {
  41. canRightMove = false;
  42. });
  43. //添加热点模块
  44. $(".hot-style").click(function () {
  45. toAddHotSpot.style = $(this).attr("name");
  46. $(".hot-style").removeClass("hot-style-on");
  47. $(this).addClass("hot-style-on");
  48. });
  49. $(this).mousemove(function () {
  50. if (canShowLeft) {
  51. if (krpano.get("mouse.x") <= 300) {
  52. $(".left-column").css("-webkit-animation", "showLeft 0.8s infinite").css("-webkit-animation-iteration-count", "1")
  53. .css("left", "0");
  54. } else {
  55. $(".left-column").css("-webkit-animation", "hideLeft 0.8s infinite").css("-webkit-animation-iteration-count", "1")
  56. .css("left", "-250px");
  57. }
  58. }
  59. });
  60. $(".my-open-out").click(function () {
  61. if (toAddHotSpot.dive) {
  62. toAddHotSpot.dive = false;
  63. $(this).css("background", "rgba(255,255,255,0.4)");
  64. $(".my-open-in").removeClass("my-open-in-open").addClass("my-open-in-close");
  65. } else {
  66. toAddHotSpot.dive = true;
  67. $(this).css("background", "#00a3d8");
  68. $(".my-open-in").removeClass("my-open-in-close").addClass("my-open-in-open");
  69. }
  70. });
  71. });
  72. //noinspection JSUnusedGlobalSymbols
  73. function onready() {
  74. //隐藏下方自带控制条
  75. krpano.set("layer[skin_control_bar].visible", false);
  76. krpano.set("layer[skin_splitter_bottom].visible", false);
  77. krpano.set("layer[skin_scroll_window].visible", false);
  78. //初始化场景选择列表
  79. var sceneListHTML;
  80. var dataSceneList = {list: []};
  81. krpano.get("scene").getArray().forEach(function (scene) {
  82. dataSceneList.list.push({name: scene.name, index: scene.index, bgmusic: scene.bgmusic});
  83. });
  84. sceneListHTML = template('tplSceneList', dataSceneList);
  85. document.getElementById('sceneList').innerHTML = sceneListHTML;
  86. //初始化选中以及首场景
  87. $("li[name=" + krpano.get("startscene") + "] .circle").css("background-color", "#FF9800");
  88. $("li[name=" + krpano.get("xml.scene") + "]").addClass("li-scene-hover");
  89. currentSceneIndex = krpano.get("scene").getItem(krpano.get("xml.scene")).index;
  90. //热点列表模块
  91. var hotSpotHTML;
  92. var dataHotSpotList = {list: []};
  93. //覆盖原热点选中事件,添加热点点击移动事件
  94. krpano.get("hotspot").getArray().forEach(function (oldHotSpot) {
  95. if (oldHotSpot.name !== 'vr_cursor' && oldHotSpot.name !== 'webvr_prev_scene'
  96. && oldHotSpot.name !== 'webvr_next_scene') {
  97. dataHotSpotList.list.push(oldHotSpot);
  98. hotSpotInitEvent(oldHotSpot.name);
  99. }
  100. });
  101. hotSpotHTML = template('tplHotSpotList', dataHotSpotList);
  102. document.getElementById('hotSpotList').innerHTML = hotSpotHTML;
  103. //背景音乐列表模块
  104. var bgMusicHTML;
  105. var dataBgMusicList = {list: []};
  106. var bgMusicUrl=krpano.get("scene").getItem(currentSceneIndex).bgmusic;
  107. if(typeof(bgMusicUrl) != "undefined")
  108. {
  109. var bgmusicArr=bgMusicUrl.split("/");
  110. var bgMusicName=bgmusicArr[bgmusicArr.length-1].substring(0,bgmusicArr[bgmusicArr.length-1].length-4);
  111. dataBgMusicList.list.push({name: bgMusicName});
  112. }
  113. bgMusicHTML = template('tplBgMusicList', dataBgMusicList);
  114. document.getElementById('bgMusicList').innerHTML = bgMusicHTML;
  115. //右侧数值初始化
  116. $("#waitTime").val(krpano.get("autorotate.waittime"));
  117. if (krpano.get("autorotate.enabled")) {
  118. $("#autoSpin").prop("checked", true);
  119. $("#waitTimeInput").show();
  120. } else {
  121. $("#autoSpin").prop("checked", false);
  122. $("#waitTimeInput").hide();
  123. }
  124. $("#initFov").val(krpano.get("view.fov").toFixed(0));
  125. $("#initFovMax").val(krpano.get("view.fovmax").toFixed(0));
  126. $("#initFovMin").val(krpano.get("view.fovmin").toFixed(0));
  127. updatePbLine();
  128. initPbLineEvent();
  129. //初始化提交数据
  130. if (!sceneList.length) {
  131. krpano.get("scene").getArray().forEach(function (scene) {
  132. var sceneObj = {};
  133. sceneObj.index = scene.index;
  134. sceneObj.name = scene.name;
  135. sceneObj.bgmusic = scene.bgmusic;
  136. if (scene.name == krpano.get("startscene")) {
  137. sceneObj.welcomeFlag = true;
  138. }
  139. sceneList.push(sceneObj);
  140. });
  141. }
  142. }
  143. //场景切换,重命名模块
  144. function changeScene(index) {
  145. krpano.call("loadscene(" + krpano.get("scene").getItem(index).name + ")");
  146. //当前存储对象展示
  147. var currentScene = sceneList[index];
  148. if (currentScene.initH) krpano.set("view.hlookat", currentScene.initH);
  149. if (currentScene.initV) krpano.set("view.vlookat", currentScene.initV);
  150. if (currentScene.fov) krpano.set("view.fov", currentScene.fov);
  151. if (currentScene.fovmax) krpano.set("view.fovmax", currentScene.fovmax);
  152. if (currentScene.fovmin) krpano.set("view.fovmin", currentScene.fovmin);
  153. if (currentScene.autorotate) {
  154. krpano.set("autorotate.enabled", currentScene.autorotate.enabled);
  155. krpano.set("autorotate.waittime", currentScene.autorotate.waitTime);
  156. }
  157. if (currentScene.hotSpots) {
  158. krpano.get("hotspot").getArray().forEach(function (everySpot) {
  159. if (everySpot.name !== "vr_cursor" && everySpot.name !== 'webvr_prev_scene'
  160. && everySpot.name !== 'webvr_next_scene') {
  161. krpano.call("removehotspot(" + everySpot.name + ")");
  162. }
  163. });
  164. currentScene.hotSpots.forEach(function (everySpot) {
  165. krpano.call("addhotspot(" + everySpot.name + ");");
  166. krpano.set("hotspot[" + everySpot.name + "].ath", everySpot.ath);
  167. krpano.set("hotspot[" + everySpot.name + "].atv", everySpot.atv);
  168. krpano.set("hotspot[" + everySpot.name + "].text", everySpot.text);
  169. krpano.set("hotspot[" + everySpot.name + "].linkedscene", everySpot.linkedscene);
  170. krpano.set("hotspot[" + everySpot.name + "].dive", everySpot.dive);
  171. krpano.get("hotspot[" + everySpot.name + "]").loadstyle(everySpot.style);
  172. });
  173. }
  174. $('.li-scene-hover').removeClass('li-scene-hover');
  175. $("li[name=" + krpano.get("xml.scene") + "]").addClass("li-scene-hover");
  176. $(".circle").css("background-color", "#292827");
  177. sceneList.forEach(function (scene) {
  178. if (scene.welcomeFlag) {
  179. $(".circle:eq(" + scene.index + ")").css("background-color", "#FF9800");
  180. krpano.set("startscene", scene.name);
  181. }
  182. });
  183. onready();
  184. }
  185. function rename(prevButton) {
  186. prevButton.prev().hide();
  187. prevButton.attr("type", "text");
  188. var focusValue = prevButton.val();
  189. prevButton.val("");
  190. prevButton.focus();
  191. prevButton.val(focusValue);
  192. }
  193. function doRename(thisInput) {
  194. var nameIndex = thisInput.parent().attr('key');
  195. var newName = thisInput.val();
  196. var oldName = krpano.get("scene").getItem(nameIndex).name;
  197. var doFlag = true;
  198. //判断名字是否重复
  199. sceneList.forEach(function (eachScene) {
  200. if (eachScene.index !== nameIndex) {
  201. if (eachScene.name === newName) {
  202. doFlag = false;
  203. return false;
  204. }
  205. }
  206. });
  207. if (doFlag) {
  208. krpano.get("scene").renameItem(oldName, newName);
  209. if (currentSceneIndex === nameIndex) {
  210. krpano.set("xml.scene", newName);
  211. }
  212. if (oldName === krpano.get("startscene")) {
  213. krpano.set("startscene", newName);
  214. }
  215. sceneList[nameIndex].name = newName;
  216. //修改热点指向场景名字
  217. sceneList.forEach(function (eachScene) {
  218. if (eachScene.index !== nameIndex && eachScene.hotSpots) {
  219. eachScene.hotSpots.forEach(function (eachSpot) {
  220. if (eachSpot.linkedscene === oldName) {
  221. eachSpot.linkedscene = newName;
  222. eachSpot.text = newName;
  223. krpano.set("hotspot[" + eachSpot.name + "].text", newName);
  224. krpano.set("hotspot[" + eachSpot.name + "].linkedscene", newName);
  225. }
  226. });
  227. }
  228. });
  229. $(".hot-spot-text").each(function () {
  230. if ($(this).text() == oldName) {
  231. $(this).text(newName);
  232. }
  233. });
  234. $("#isEdited").text('保存*');
  235. thisInput.prev().text(newName);
  236. } else {
  237. thisInput.val(oldName);
  238. alert("名字重复");
  239. }
  240. thisInput.prev().show();
  241. thisInput.attr("type", "hidden");
  242. }
  243. function selectWelcomeScene(index) {
  244. $(".circle").css("background-color", "#292827");
  245. $(".circle:eq(" + index + ")").css("background-color", "#FF9800");
  246. sceneList.forEach(function (scene) {
  247. scene.welcomeFlag = false;
  248. });
  249. sceneList[index].welcomeFlag = true;
  250. $("#isEdited").text('保存*');
  251. }
  252. //视角修改模块
  253. function setAsDefaultView() {
  254. sceneList[currentSceneIndex].initH = krpano.get("view.hlookat");
  255. sceneList[currentSceneIndex].initV = krpano.get("view.vlookat");
  256. sceneList[currentSceneIndex].fov = krpano.get("view.fov");
  257. $("#initFov").val(krpano.get("view.fov").toFixed(0));
  258. updatePbLine();
  259. $("#isEdited").text('保存*');
  260. }
  261. function autoSpinClick() {
  262. var isChecked = $("#autoSpin").is(":checked");
  263. if (isChecked) {
  264. $("#waitTimeInput").show();
  265. } else {
  266. $("#waitTimeInput").hide();
  267. }
  268. krpano.set("autorotate.enabled", isChecked);
  269. krpano.set("autorotate.waittime", $("#waitTime").val());
  270. krpano.get("scene").getArray().forEach(function (scene) {
  271. sceneList[scene.index].autorotate = {enabled: $("#autoSpin").is(":checked"), waitTime: $("#waitTime").val()};
  272. });
  273. $("#isEdited").text('保存*');
  274. }
  275. function updateFov() {
  276. var fov = $("#initFov").val();
  277. var fovMax = $("#initFovMax").val();
  278. var fovMin = $("#initFovMin").val();
  279. if (fov == "" || Number(fov) > 180 || Number(fov) < 0) {
  280. $("#initFov").val(krpano.get("view.fov").toFixed(0));
  281. return
  282. }
  283. if (fovMax == "" || Number(fovMax) > 180 || Number(fovMax) < 0) {
  284. $("#initFovMax").val(krpano.get("view.fovmax").toFixed(0));
  285. return
  286. }
  287. if (fovMin == "" || Number(fovMin) > 180 || Number(fovMin) < 0) {
  288. $("#initFovMin").val(krpano.get("view.fovmin").toFixed(0));
  289. return
  290. }
  291. krpano.set("view.fov", fov);
  292. krpano.set("view.fovmax", fovMax);
  293. krpano.set("view.fovmin", fovMin);
  294. sceneList[currentSceneIndex].fov = fov;
  295. sceneList[currentSceneIndex].fovmax = fovMax;
  296. sceneList[currentSceneIndex].fovmin = fovMin;
  297. updatePbLine();
  298. $("#isEdited").text('保存*');
  299. }
  300. function fovForAll() {
  301. sceneList.forEach(function (eachScene) {
  302. eachScene.fov = $("#initFov").val();
  303. eachScene.fovmax = $("#initFovMax").val();
  304. eachScene.fovmin = $("#initFovMin").val();
  305. });
  306. $("#isEdited").text('保存*');
  307. alert("操作成功");
  308. }
  309. function updatePbLine() {
  310. //视角条
  311. var startPx = Number(krpano.get("view.fovmin")) / 0.9;
  312. var widthPx = Number(krpano.get("view.fovmax")) / 0.9 - startPx;
  313. var currPx = Number(krpano.get("view.fov")) / 0.9 - startPx - 10;
  314. $(".triangle-down").css("margin-left", currPx.toFixed(0) + "px");
  315. $(".number-pb-shown").css("left", startPx.toFixed(0) + "px").css("width", widthPx.toFixed(0) + "px").show();
  316. }
  317. function initPbLineEvent() {
  318. $(".triangle-down").unbind("mousedown").mousedown(function () {
  319. pbX = krpano.get("mouse.x");
  320. canDownMove = true;
  321. }).unbind("mousemove").mousemove(function () {
  322. if (canDownMove) {
  323. moveDownLine();
  324. }
  325. });
  326. $(".triangle-up-left").unbind("mousedown").mousedown(function () {
  327. pbX = krpano.get("mouse.x");
  328. canLeftMove = true;
  329. }).unbind("mousemove").mousemove(function () {
  330. if (canLeftMove) {
  331. moveLeftLine();
  332. }
  333. });
  334. $(".triangle-up-right").unbind("mousedown").mousedown(function () {
  335. pbX = krpano.get("mouse.x");
  336. canRightMove = true;
  337. }).unbind("mousemove").mousemove(function () {
  338. if (canRightMove) {
  339. moveRightLine();
  340. }
  341. });
  342. }
  343. function moveDownLine() {
  344. var startPx = Number(krpano.get("view.fovmin")) / 0.9;
  345. var widthPx = Number(krpano.get("view.fovmax")) / 0.9 - startPx;
  346. var leftPx = Number(krpano.get("view.fov")) / 0.9 - startPx - 10 + krpano.get("mouse.x") - pbX;
  347. if (leftPx + 10 < 0) {
  348. canDownMove = false;
  349. leftPx = -10;
  350. }
  351. if (leftPx + 10 > widthPx) {
  352. canDownMove = false;
  353. leftPx = widthPx - 10;
  354. }
  355. pbX = krpano.get("mouse.x");
  356. krpano.set("view.fov", (leftPx + 10 + startPx) * 0.9);
  357. $(".triangle-down").css("margin-left", leftPx.toFixed(0) + "px");
  358. $("#initFov").val(krpano.get("view.fov").toFixed(0));
  359. sceneList[currentSceneIndex].fov = krpano.get("view.fov");
  360. $("#isEdited").text('保存*');
  361. }
  362. function moveLeftLine() {
  363. var startPx = Number(krpano.get("view.fovmin")) / 0.9 + krpano.get("mouse.x") - pbX;
  364. var endPx = Number(krpano.get("view.fovmax")) / 0.9;
  365. if (startPx < 0) {
  366. startPx = 0;
  367. canLeftMove = false;
  368. }
  369. if (endPx - startPx < 20) {
  370. startPx = endPx - 20;
  371. canLeftMove = false;
  372. }
  373. if (krpano.get("view.fov") < krpano.get("view.fovmin")) {
  374. krpano.set("view.fov", krpano.get("view.fovmin"))
  375. }
  376. pbX = krpano.get("mouse.x");
  377. krpano.set("view.fovmin", startPx * 0.9);
  378. updatePbLine();
  379. $("#initFovMin").val(krpano.get("view.fovmin").toFixed(0));
  380. sceneList[currentSceneIndex].fovmin = krpano.get("view.fovmin");
  381. $("#isEdited").text('保存*');
  382. }
  383. function moveRightLine() {
  384. var startPx = Number(krpano.get("view.fovmin")) / 0.9;
  385. var endPx = Number(krpano.get("view.fovmax")) / 0.9 + krpano.get("mouse.x") - pbX;
  386. if (endPx > 200) {
  387. endPx = 200;
  388. canRightMove = false;
  389. }
  390. if (endPx - startPx < 20) {
  391. endPx = startPx + 20;
  392. canRightMove = false;
  393. }
  394. if (krpano.get("view.fov") > krpano.get("view.fovmax")) {
  395. krpano.set("view.fov", krpano.get("view.fovmax"))
  396. }
  397. pbX = krpano.get("mouse.x");
  398. krpano.set("view.fovmax", endPx * 0.9);
  399. updatePbLine();
  400. $("#initFovMax").val(krpano.get("view.fovmax").toFixed(0));
  401. sceneList[currentSceneIndex].fovmax = krpano.get("view.fovmax");
  402. $("#isEdited").text('保存*');
  403. }
  404. //提交表单修改模块
  405. function updateHotSpotData() {
  406. var hotSpotHTML;
  407. var dataHotSpotList = {list: []};
  408. //修改全局变量
  409. var hotSpotData = [];
  410. krpano.get("hotspot").getArray().forEach(function (everySpot) {
  411. if (everySpot.name !== "vr_cursor" && everySpot.name !== 'webvr_prev_scene'
  412. && everySpot.name !== 'webvr_next_scene' && everySpot.name.indexOf('vrtooltip') == -1) {
  413. //这里加判断过滤掉vrtooltip热点标签
  414. dataHotSpotList.list.push(everySpot);
  415. var hotSpot = {};
  416. hotSpot.ath = everySpot.ath.toString();
  417. hotSpot.atv = everySpot.atv.toString();
  418. hotSpot.linkedscene = everySpot.linkedscene;
  419. hotSpot.name = everySpot.name;
  420. hotSpot.style = everySpot.style;
  421. hotSpot.text = everySpot.text;
  422. hotSpot.dive = everySpot.dive;
  423. hotSpotData.push(hotSpot);
  424. }
  425. });
  426. sceneList[currentSceneIndex].hotSpots = hotSpotData;
  427. hotSpotHTML = template('tplHotSpotList', dataHotSpotList);
  428. document.getElementById('hotSpotList').innerHTML = hotSpotHTML;
  429. }
  430. //数据保存并提交操作
  431. function save() {
  432. if ($("#isEdited").text() === '保存') {
  433. return;
  434. }
  435. var postData = JSON.stringify(sceneList);
  436. var panoramicId = $("#panoramicId").val();
  437. var panoramicMaterialPicIds = $("#panoramicMaterialPicIds").val();
  438. var tourUrlIds = $("#tourUrlIds").val();
  439. var curWwwPath = window.document.location.href;
  440. var pathName = window.document.location.pathname;
  441. var pos = curWwwPath.indexOf(pathName);
  442. var localhostPaht = curWwwPath.substring(0, pos);
  443. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  444. var prefix = localhostPaht + projectName + "/a";
  445. alert(postData);
  446. alert(panoramicId);
  447. alert(tourUrlIds);
  448. alert(prefix);
  449. $.ajax({
  450. type: 'POST',
  451. contentType: "application/json; charset=utf-8",
  452. url: prefix + "/hnly/panoramic/vtourSave?panoramicId=" + panoramicId + "&tourUrlIds=" + tourUrlIds,
  453. data: postData,
  454. success: function (data) {
  455. alert(data);
  456. if (data === "保存成功") {
  457. $("#isEdited").text('保存');
  458. }
  459. },
  460. error: function () {
  461. alert("系统错误");
  462. }
  463. });
  464. }
  465. //热点移动模块
  466. function autoMove() {
  467. krpano.call("screentosphere(mouse.x, mouse.y, mouseath, mouseatv);");
  468. krpano.set("hotspot[" + movingSpot.name + "].ath", krpano.get("mouseath") + movingSpot.athDis);
  469. krpano.set("hotspot[" + movingSpot.name + "].atv", krpano.get("mouseatv") + movingSpot.atvDis);
  470. krpano.set("hotspot[vrtooltip_" + movingSpot.name + "].ath", krpano.get("mouseath") + movingSpot.athDis);
  471. krpano.set("hotspot[vrtooltip_" + movingSpot.name + "].atv", krpano.get("mouseatv") + movingSpot.atvDis);
  472. }
  473. //添加热点模块
  474. function showAddHotSpot() {
  475. $(".hot-style").removeClass("hot-style-on");
  476. $(".hot-style").first().addClass("hot-style-on");
  477. toAddHotSpot.style = $(".hot-style").first().attr("name");
  478. toAddHotSpot.dive = true;
  479. $(".my-open-out").css("background", "#00a3d8");
  480. $(".my-open-in").removeClass("my-open-in-close").addClass("my-open-in-open");
  481. $("#hotToolButton").hide();
  482. $(".add-hot-pot").show();
  483. $("#selectStyle").show();
  484. $("#goToScene").hide();
  485. $("#writeTitle").hide();
  486. $("#selectStyleTitle").addClass("progress-title-on");
  487. $("#goToSceneTitle").removeClass("progress-title-on");
  488. $("#writeTitleTitle").removeClass("progress-title-on");
  489. }
  490. //隐藏添加热点窗口
  491. function hideAddHotSpot() {
  492. window.clearInterval(moveIntervalId);
  493. toAddHotSpot = {};
  494. $(".add-hot-pot").hide();
  495. $("span[data-target=#toolHot]").click();
  496. }
  497. //隐藏添加语音窗口
  498. function hideAddVoice() {
  499. $("div").remove(".radio-voice");
  500. $("#add-voice").hide();
  501. $("span[data-target=#toolVoice]").click();
  502. }
  503. function nextToSelectTargetScene() {
  504. if (!toAddHotSpot.style) {
  505. alert("请选择热点样式");
  506. return
  507. }
  508. window.clearInterval(moveIntervalId);
  509. // 目标场景列表
  510. var targetSceneHTML;
  511. var dataTargetScene = {list: []};
  512. krpano.get("scene").getArray().forEach(function (scene) {
  513. if (scene.name !== krpano.get('xml.scene')) {
  514. dataTargetScene.list.push({name: scene.name, index: scene.index + 1})
  515. }
  516. });
  517. targetSceneHTML = template('tplTargetScene', dataTargetScene);
  518. document.getElementById('targetScene').innerHTML = targetSceneHTML;
  519. $(".select-scene-div").removeClass("select-scene-div-on");
  520. $(".select-scene-div").first().addClass("select-scene-div-on");
  521. toAddHotSpot.linkedscene = $(".select-scene-div").first().attr("name");
  522. $(".select-scene-div").unbind("click").click(function () {
  523. toAddHotSpot.linkedscene = $(this).attr("name");
  524. $(".select-scene-div").removeClass("select-scene-div-on");
  525. $(this).addClass("select-scene-div-on");
  526. });
  527. $("#selectStyle").hide();
  528. $("#goToScene").show();
  529. $("#writeTitle").hide();
  530. $("#goToSceneTitle").addClass("progress-title-on");
  531. $("#selectStyleTitle").removeClass("progress-title-on");
  532. $("#writeTitleTitle").removeClass("progress-title-on");
  533. }
  534. function nextToWriteTitle() {
  535. if (!toAddHotSpot.linkedscene) {
  536. alert("请选择目标场景");
  537. return;
  538. }
  539. $("#addHotTitle").val(toAddHotSpot.linkedscene);
  540. $("#selectStyle").hide();
  541. $("#goToScene").hide();
  542. $("#writeTitle").show();
  543. $("#writeTitleTitle").addClass("progress-title-on");
  544. $("#selectStyleTitle").removeClass("progress-title-on");
  545. $("#goToSceneTitle").removeClass("progress-title-on");
  546. }
  547. //添加语音/音乐模块
  548. function showAddVoice(){
  549. $(".add-voice").show();
  550. var postData = "";
  551. var curWwwPath = window.document.location.href;
  552. var pathName = window.document.location.pathname;
  553. var pos = curWwwPath.indexOf(pathName);
  554. var localhostPaht = curWwwPath.substring(0, pos);
  555. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  556. var prefix = localhostPaht + projectName + "/a";
  557. $.ajax({
  558. type: 'POST',
  559. contentType: "application/json; charset=utf-8",
  560. url: prefix + "/hnly/panoramicMaterialMusic/getData",
  561. data: postData,
  562. success: function (data) {
  563. var panoramicMaterialMusicLists = data.panoramicMaterialMusicList;
  564. for(var i=0;i<panoramicMaterialMusicLists.length;i++){
  565. //alert(JSON.stringify(panoramicMaterialMusicLists[i].id));
  566. $("<div style=\"float: left;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\" class=\"radio-voice\">"
  567. //$("<div style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\" class=\"radio-voice\">"
  568. //+ "<div style=\"position: relative;float: left;width: 25%;line-height: 40px;font-weight: 700;text-align: left;\">"
  569. + "<div style=\"position: relative;line-height: 40px;font-weight: 700;\">"
  570. + "<label for=" + JSON.stringify(panoramicMaterialMusicLists[i].id)
  571. + "> <input type=\"radio\" name=\"panoramicMaterialMusicId\" value="
  572. + JSON.stringify(panoramicMaterialMusicLists[i].url)
  573. + " id="
  574. + JSON.stringify(panoramicMaterialMusicLists[i].name) + "/> "
  575. + panoramicMaterialMusicLists[i].name
  576. + "</label> "
  577. + "</div>"
  578. + "<div style=\"position: relative;\">"
  579. //+ "<div style=\"position: relative;float: left;width: 75%;\">"
  580. //+ "<audio controls=\"controls\" height=\"40\" width=\"100\">"
  581. //+ "<source src=" + panoramicMaterialMusicLists[i].url + " type=\"audio/wav\" />"
  582. //+ "<source src=\"song.ogg\" type=\"audio/ogg\" />"
  583. //+ "<embed height=\"40\" width=\"100\" src=" + panoramicMaterialMusicLists[i].url + " />"
  584. //+ "</audio>"
  585. + "</div>"
  586. + "</div>"
  587. ).appendTo("#add-voice-frame");
  588. }
  589. },
  590. error: function () {
  591. alert("系统错误");
  592. }
  593. });
  594. $("#isEdited").text('保存*');
  595. }
  596. //添加热点到场景列表中,关闭热点弹出窗口
  597. function addHotSpot() {
  598. // 计算中间位置的球面坐标
  599. krpano.set("halfHeight", krpano.get("stageheight") / 2);
  600. krpano.set("halfWidth", krpano.get("stagewidth") / 2);
  601. krpano.call("screentosphere(halfWidth,halfHeight,init_h,init_v);");
  602. var init_h = krpano.get("init_h");
  603. var init_v = krpano.get("init_v");
  604. //添加热点
  605. var newHotSpotName = "spot" + new Date().getTime();
  606. krpano.call("addhotspot(" + newHotSpotName + ");");
  607. krpano.get("hotspot[" + newHotSpotName + "]").loadstyle(toAddHotSpot.style);
  608. krpano.set("hotspot[" + newHotSpotName + "].ath", init_h);
  609. krpano.set("hotspot[" + newHotSpotName + "].atv", init_v);
  610. krpano.set("hotspot[" + newHotSpotName + "].text", $("#addHotTitle").val());
  611. krpano.set("hotspot[" + newHotSpotName + "].linkedscene", toAddHotSpot.linkedscene);
  612. krpano.set("hotspot[" + newHotSpotName + "].dive", toAddHotSpot.dive);
  613. krpano.set("hotspot[" + newHotSpotName + "].onloaded", "add_all_the_time_tooltip_for_VR();");
  614. hotSpotInitEvent(newHotSpotName);
  615. updateHotSpotData();
  616. $("#isEdited").text('保存*');
  617. hideAddHotSpot();
  618. $("span[data-target=#toolHot]").click();
  619. }
  620. //添加语音到场景列表中,关闭语音弹出窗口
  621. function addVoice(){
  622. var musicName;
  623. var obj = document.getElementsByName("panoramicMaterialMusicId");
  624. for(i=0; i<obj.length;i++){
  625. if(obj[i].checked){
  626. musicName=obj[i].value;
  627. updateVoice(obj[i].id);
  628. krpano.get("scene").getItem(currentSceneIndex).bgmusic= obj[i].id;
  629. sceneList[currentSceneIndex].bgmusic=obj[i].value;
  630. }
  631. }
  632. hideAddVoice();
  633. }
  634. function updateVoice(musicName){
  635. var bgMusicHTML;
  636. var dataBgMusicList = {list: []};
  637. dataBgMusicList.list.push({name: musicName});
  638. bgMusicHTML = template('tplBgMusicList', dataBgMusicList);
  639. document.getElementById('bgMusicList').innerHTML = bgMusicHTML;
  640. }
  641. //热点选择模块
  642. function selectHotSpot() {
  643. krpano.call("screentosphere(mouse.x, mouse.y, mouseath, mouseatv);");
  644. var nearHotSpot = {};
  645. krpano.get("hotspot").getArray().forEach(function (thisHotSpot) {
  646. var thisAthDis = krpano.get("hotspot[" + thisHotSpot.name + "]").ath - krpano.get("mouseath");
  647. var thisAtvDis = krpano.get("hotspot[" + thisHotSpot.name + "]").atv - krpano.get("mouseatv");
  648. var thisDis = Math.abs(thisAthDis) + Math.abs(thisAtvDis);
  649. if (!nearHotSpot.name) {
  650. nearHotSpot = {name: thisHotSpot.name, athDis: thisAthDis, atvDis: thisAtvDis, dis: thisDis};
  651. } else {
  652. if (thisDis < nearHotSpot.dis) {
  653. nearHotSpot = {name: thisHotSpot.name, athDis: thisAthDis, atvDis: thisAtvDis, dis: thisDis};
  654. }
  655. }
  656. });
  657. return nearHotSpot;
  658. }
  659. //热点初始化事件
  660. function hotSpotInitEvent(spotName) {
  661. krpano.get("hotspot[" + spotName + "]").ondown = function () {
  662. movingSpot = selectHotSpot();
  663. var intervalId = setInterval(autoMove, 1000.0 / 30.0);
  664. krpano.set("autoMoveIntervalId", intervalId);
  665. canShowLeft = false;
  666. };
  667. krpano.get("hotspot[" + spotName + "]").onup = function () {
  668. window.clearInterval(krpano.get("autoMoveIntervalId"));
  669. movingSpot = {};
  670. updateHotSpotData();
  671. canShowLeft = true;
  672. $("#isEdited").text('保存*');
  673. };
  674. krpano.get("hotspot[" + spotName + "]").onclick = null;
  675. krpano.get("hotspot[" + spotName + "]").onover = function () {
  676. if (movingSpot === {}) {
  677. var currentSpot = selectHotSpot();
  678. $("[name=" + currentSpot.name + "Hover]").addClass("hot-spot-list-hover");
  679. }
  680. };
  681. krpano.get("hotspot[" + spotName + "]").onout = function () {
  682. $(".hot-spot-list").removeClass("hot-spot-list-hover");
  683. };
  684. }
  685. //去除热点
  686. function removeHotSpot(name) {
  687. krpano.call("removehotspot(" + name + ")");
  688. updateHotSpotData();
  689. $("#isEdited").text('保存*');
  690. }
  691. //去除背景音乐
  692. function removeBgMusic(name) {
  693. var bgMusicHTML;
  694. var dataBgMusicList = {list: []};
  695. bgMusicHTML = template('tplBgMusicList', dataBgMusicList);
  696. document.getElementById('bgMusicList').innerHTML = bgMusicHTML;
  697. $("#isEdited").text('保存*');
  698. krpano.get("scene").getItem(currentSceneIndex).bgmusic= null;
  699. sceneList[currentSceneIndex].bgmusic=null;
  700. }

 

转载于:https://my.oschina.net/discussjava/blog/1535033

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/523716
推荐阅读
相关标签
  

闽ICP备14008679号