vue3使用krpano1.22

在這里插入圖片描述

官方文檔鏈接

  • https://krpano.com/docu/js/#top
例子
  • https://krpano.com/releases/1.22/viewer/examples/javascript-interface/js-api-examples.html

  • https://krpano.com/viewsource.html?releases/1.22/viewer/examples/javascript-interface/js-api-examples.html

注意點

文件路徑

在這里插入圖片描述

它是以首次獲取的tour.js為根目錄。后面xml里是xml為根目錄

完整代碼
//disasterpano.vue
<template><div><h1>krpano Javascript API Examples (Version 1.22)</h1><div id="localusagenote" style=" display:none;"><b>NOTE:</b>Start this example from a local server like the <a href="https://krpano.com/tools/testingserver/#top" target="_blank" style="color:red;">krpano Testing Server</a>and select the root folder of the krpano Download Package as server folder!<br>If using the example locally on a <u>file://</u> url or with another server folder,it might be not possible to access the files that are used by the examples(depending on the <a href="https://krpano.com/docu/localusage/#top" target="_blank" style="color:red;">Browser settings</a>).</div><div id="content"><div id="pano"></div><div id="buttons" style="pointer-events:none; user-select:none; opacity:0.0; transition:opacity 1.0s ease-out;">Loading panos:<br><div class="button" @click="loadxmlfile()">load xml file</div><br><div class="button" @click="loadxmlstring()">load xml string</div><br><div class="button" @click="loadimage()">load image (single-res)</div><br><div class="button" @click="loadimage_mres()">load image (multi-res)</div><br><div class="button" @click="loadimage_partial()">load image (partial-pano)</div><br><!--        <div class="button" onclick="loadimage_3dmodel()">load image (3D-model)</div><br>--><!--        <br>--><!--        Changing the view:<br>--><!--        <div class="button" onclick="reset_view()">Reset view</div><br>--><!--        <div class="button" onclick="randomview_set()">Set a Random view</div><br>--><!--        <div class="button" onclick="randomview_lookto()">Animated Look-to a Random view</div><br>--><!--        <br>--><!--        Hotspots:<br>--><!--        <div class="button" onclick="add_hotspot()">Add a Hotspot at the looking position</div><br>--><!--        <div class="button" onclick="add_hotspot_on_next_click()">Add a Hotspot at the click position</div><br>--><!--        <div class="button" onclick="add_poly_hotspot()">Add Polygonal Hotspot</div><br>--><!--        <div class="button" onclick="remove_all_hotspots()">Remove all hotspots</div><br>--><!--        <br>--><!--        Layers:<br>--><!--        <div class="button" onclick="textfield_template()">Add a Textfield with a template</div><br>--><!--        <div class="button" onclick="layers_colormixer_demo()">A Simple Color-Mixer as Demo</div><br>--><!--        <br>--><!--        Plugins:<br>--><!--        <div class="button" onclick="plugin_soundinterface_demo()">Soundinterface Demo</div><br>--><!--        <div class="button" onclick="plugin_videoplayer_demo()">Videoplayer Demo</div><br>--><!--        <div class="button" onclick="plugin_postprocessing_demo()">Postprocessing Demo</div><br>--></div></div></div>
</template>
<script setup>
// import { embedpano } from "@/assets/krpano/tour.js"
import {onMounted, ref, markRaw} from "vue";// a global 'krpano' variable (will be set in the embedpano.onready callback)
// open the Browsers developer tools and type 'krpano' for directly playing with it
const krpano = ref(null);const setup = () => {// show a note when opening that example directly from a local file:// urlif ( location.protocol === "file:" ){document.getElementById("localusagenote").style.display = "";}// 檢查embedpano函數是否存在,如果不存在則嘗試從krpanoJS獲取if (typeof window.embedpano !== 'function') {if (typeof window.krpanoJS !== 'undefined' && typeof window.krpanoJS.embedpano === 'function') {window.embedpano = window.krpanoJS.embedpano;} else {console.error('embedpano function not found. Make sure krpano library is loaded.');return;}}// embed the krpano viewerwindow.embedpano({target : document.getElementById("pano"), 	// embed the krpano viewer into the 'pano' div elementconsolelog : true,							// log the krpano messages also to the Browser console//bgcolor : "transparent",					// optionally: use a transparent background (for seeing the webpage behind 3D-models or partial panos)onready : function(krpanointerface){krpano.value = markRaw(krpanointerface);// enable the debugmode and handle all JS errors in the Browsers consolekrpano.value.debugmode = true;krpano.value.debugjsactions = true;krpano.value.debugjsplugins = true;// add a grid pano (with custom colors)krpano.value.image.preview = {type:"grid(cube,64,64,512,0xCCAA00,0x222222)"};// add an intro info textvar info = krpano.value.addlayer();info.setvars({type:"text", align:"center", text:"krpano is ready...", bg:false, css:"color:white;font-size:14px;font-weight:bold;"});info.onclick = function(){// disable the layer to avoid getting additional clicks during the animationinfo.enabled = false;// do an animation and remove the layerkrpano.value.tween(info, {scale:10,alpha:0}, 0.5, "smooth", function(){ info.remove(); });}// enable the example buttons nowvar buttons = document.getElementById("buttons");buttons.style.pointerEvents = "auto";buttons.style.opacity = 1.0;}});
}// examples
const tour = new URL('@/assets/krpano/demotour-corfu/tour.xml', import.meta.url).href
const loadxmlfile= ()=>
{console.log( tour)// load a tour xml fileif (krpano.value && krpano.value.actions) {krpano.value.actions.loadpano(tour, null, "RESET");} else {console.error('krpano not ready or actions not available');}
}const loadxmlstring= ()=>
{// load a xml as stringvar xmlstring =`<krpano><image><preview url="/src/assets/krpano/webvr/panos/intro/preview.jpg" /><cube url="/src/assets/krpano/webvr/panos/intro/pano_%s.jpg" /></image><view hlookat="0" vlookat="0" fov="100" /></krpano>`;if (krpano.value && krpano.value.actions) {krpano.value.actions.loadxml(xmlstring, null, "RESET", "BLEND(0.35)");} else {console.error('krpano not ready or actions not available');}
}const loadimage= ()=>
{if (krpano.value && krpano.value.actions && krpano.value.image) {// load a spherical image directlykrpano.value.image.reset();krpano.value.image.sphere = {url:"/src/assets/krpano/depthmap/depthmap-images/pano1.jpg"};krpano.value.actions.loadpanoimage("RESET", "BLEND(0.35)");krpano.value.actions.lookat(30,0,100);} else {console.error('krpano not ready or actions/image not available');}
}const loadimage_mres= ()=>
{if (krpano.value && krpano.value.actions && krpano.value.image) {// load images directly from the krpano cloudfront tile-serverkrpano.value.image.reset();krpano.value.image.preview = {url:"https://d8d913s460fub.cloudfront.net/tours/paris/panos/a.tiles/preview.jpg"};krpano.value.image.cube = {url:"https://d8d913s460fub.cloudfront.net/tours/paris/panos/a.tiles/l%l_%s_%v_%h.jpg", multires:"512|768|1536|3072|6144|12409"};krpano.value.actions.loadpanoimage("RESET", "BLEND(0.35)");// add a contextmenu with different projection settingskrpano.value.actions.includexml("/src/assets/krpano/plugins/contextmenu.xml");} else {console.error('krpano not ready or actions/image not available');}
}const loadimage_partial= ()=>
{if (!krpano.value || !krpano.value.actions || !krpano.value.image) {console.error('krpano not ready or actions/image not available');return;}if (krpano.value.display.istransparent == false){// unload and embed again with enabled transparent supportvar embeddingparameters = krpano.value.embeddingparameters;var old_onready = embeddingparameters.onready;embeddingparameters.bgcolor = "transparent";embeddingparameters.onready = function(krpanointerface){krpano.value = markRaw(krpanointerface);if(old_onready){ old_onready(krpanointerface); };loadimage_partial();};krpano.value.unload();// 檢查embedpano函數是否存在if (typeof window.embedpano === 'function') {window.embedpano(embeddingparameters);} else {console.error('embedpano function not found during reload.');}return;}// load a 'partial' (non 360x180) panokrpano.value.image.reset();krpano.value.image.preview = {url:"/src/assets/krpano/partialpano/tiles/preview.jpg"};krpano.value.image.sphere = {url:"/src/assets/krpano/partialpano/tiles/l%l/%0v/l%l_%0v_%0h.jpg", multires:"512,3072x928,6144x1854"};krpano.value.image.hfov = 156.0;krpano.value.image.vfov = 47.0;krpano.value.image.voffset = 9.0;krpano.value.actions.loadpanoimage("RESET", "BLEND(0.35)");// disable the viewing limits to better see the partial pano rangeskrpano.value.view.limitview = "off";// add a contextmenu with different projection settingskrpano.value.actions.includexml("/src/assets/krpano/plugins/contextmenu.xml");// add a helper script for changing the partial pano fov settingskrpano.value.actions.includexml("/src/assets/krpano/partialpano/partialpano_helpertool.xml", null, function(){});// add an other krpano viewer behind the current viewer one// to display a grid-pano behind the partial pano and sync its movements{var bg = krpano.value.addlayer();bg.setvars({type:"krpano",width:"100%",height:"100%",parent:"BGLAYER"});bg.onloaded = function(){bg.krpano.image.reset();bg.krpano.image.preview = {type:"grid(cube,64,64,512,0xAA9900,0x222222)"};bg.krpano.actions.loadpanoimage();// sync the viewkrpano.value.events.addListener("onviewchange", function(){bg.krpano.view.syncto( krpano.value.view );})}}
}onMounted(() => {setup()
})
</script>
<style scoped>h1{ color:white; font-size:16px; margin-top:0; }
#localusagenote{ background:white; border:1px solid red; border-radius:5px; color:red; padding:8px; margin:20px 16px 20px 0; }
#content { flex:1; display:flex; overflow:auto; }
#pano { width: 100vw; height: 100vh; flex:auto; border:1px solid #FFF; border-radius:11px; overflow:hidden; box-shadow:0px 3px 14px rgba(0,0,0,0.5); }
#buttons { padding:0 16px; overflow:auto; }
.button{ background:#fff; color:#245; display:inline-block; border:1px solid #333; border-radius:5px; box-shadow:0px 1px 3px rgba(0,0,0,0.3); cursor:pointer; padding:4px 8px; margin:4px 0; user-select:none; -moz-user-select:none; }
.button:hover{ background-color:#EEEEEE; }/* mobile layout */
@media (max-width:500px)
{#content{ flex-direction:column;  }#pano{ min-height:60vh; }#buttons { padding: 0; margin-top:16px;  }
}/* workaround for a Firefox bug:- backdrop-blur effects don't work when the container has a border-radius:- https://stackoverflow.com/questions/75137879/bug-with-backdrop-filter-in-firefox
*/
@-moz-document url-prefix(){ #pano{ border-radius:0px; } }
</style>
...
<script src="/src/assets/krpano/tour2.js"></script>
...
目錄結構

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/88432.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/88432.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/88432.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

2025年AI面試推薦榜單,數字化招聘轉型優選

一、AI面試為何成為2025招聘標配&#xff1f; 2025年企業對AI面試的需求從“效率工具”升級為“戰略級招聘伙伴”。數據顯示&#xff0c;超7成企業計劃年內全面引入AI面試&#xff0c;其中技術崗、全球化招聘及藍領用工場景需求增速顯著。以下以綜合技術實力、行業口碑及落地能…

人機協作新篇章:艾利特按摩機器人如何重塑健康生活

引言&#xff1a;按摩機器人的需求爆發 在快節奏的現代生活中&#xff0c;亞健康人群比例持續攀升。據《全球健康產業白皮書》顯示&#xff1a; 85%的都市人群存在肌肉勞損問題專業理療師供需缺口達1&#xff1a;3200精準按摩服務成本年均增長18% 這一背景下&#xff0c;按摩…

從代碼學習深度學習 - 情感分析:使用循環神經網絡 PyTorch版

文章目錄 前言1. 加載與預處理數據集數據讀取與詞元化構建詞匯表截斷、填充與數據迭代器2. 構建循環神經網絡模型雙向RNN模型(BiRNN)詳解權重初始化3. 加載預訓練詞向量構建詞向量加載器將預訓練向量注入模型4. 訓練與評估模型定義訓練函數可視化訓練過程5. 模型預測編寫預測…

化于無形的 lambda 語法

針對數據集合的每個成員進行計算是很常見的任務&#xff0c;用循環語句當然能實現&#xff0c;但比較麻煩&#xff0c;算個簡單的求和都要寫很多句代碼。 編程語言經常把這些運算封裝成函數&#xff0c;比如 Python 的 sum 函數&#xff0c;求訂單價格總和是這樣寫的&#xff…

day42

1. 回調函數&#xff1a;把一個函數當成“任務清單”交給另一個函數&#xff0c;等后者干完活&#xff0c;就按清單執行這個函數。比如點外賣后留電話&#xff0c;騎手送到了就打電話&#xff08;執行回調&#xff09;通知你。 2. lambda函數&#xff1a;臨時寫的超短函數&…

百度日志中臺前端重構實踐

日志中臺是百度內部針對打點數據的全生命周期管理平臺&#xff0c;作為公司日志數據的唯一入口&#xff0c;承擔以下核心職能&#xff1a;1.功能覆蓋&#xff1a;提供從數據采集、傳輸、存儲到查詢分析的一站式服務&#xff0c;支持產品運營分析、研發性能監控、運維管理等多元…

資訊安全 (Information Security)3大 “CIA“要素

資訊安全之3大要素&#xff0c;業界慣用"CIA"稱之&#xff0c;包括機密性 (Confidentiality)、完整性(Integrity)與可用性(Availability)&#xff1b;更應增加諸如鑑別性、可歸責性、不可否認性與可靠性。 1.機密性 (Confidentiality) 機密性是指採用適當的安全機制…

php后臺增加權限控制

背景 最近在對接某大廠&#xff0c;部署差不多了&#xff0c;但是在漏洞掃描環節有問題&#xff0c;前端是用vue代碼寫的。后端是php。發現前端路由可以攔截未登錄的url。但是后端php接口不用登錄就能訪問&#xff0c;很危險 解決方法 一、創建 Auth 中間件 首先創建一個專門…

跨平臺后端編程ASP.NET CORE Razor新一代Web開發框架C#

asp.net core Razor動態語言編程代替asp.net .aspx更高級嗎&#xff1f; https://blog.csdn.net/xiaoyao961/article/details/148846065 C#Blazor應用-跨平臺WEB開發VB.NET-CSDN博客 https://blog.csdn.net/xiaoyao961/article/details/148846437 Products.razor文件,Blazor和…

Storm-Pulse 全國強對流預報接口深度解析:從技術原理到防災應用(附API接入示例)

2025年6月14日安徽省氣象臺發布的強對流黃色預警中&#xff0c;合肥、阜陽等地出現了小時雨量 30-50 毫米的短時強降水和8-10級雷暴大風&#xff0c;局地甚至觀測到云閃現象。強對流天氣是指由強烈上升氣流引發的突發性、高破壞力天氣現象&#xff0c;涵蓋了短時強降水、雷暴大…

2024中國科學技術大學計算機保研上機真題

中國科學技術大學計算機保研上機真題 在線測評鏈接&#xff1a;https://pgcode.cn/problem 運動會比賽日程安排 題目描述 某運動會設立 M M M 個比賽項目&#xff0c;每個運動員&#xff08;共 N N N 個運動員&#xff09;可以參加多個項目&#xff0c;每個項目的比賽時長…

(LeetCode 面試經典 150 題) 122. 買賣股票的最佳時機 II (貪心)

題目&#xff1a;122. 買賣股票的最佳時機 II 思路&#xff1a;貪心&#xff0c;時間復雜度0(n)。 當天比前一天值大&#xff0c;就進行賣出的交易。購入是默認前一天已購入。 C版本&#xff1a; class Solution { public:int maxProfit(vector<int>& prices) {int…

一篇文章了解XML

一、什么是 XML&#xff1f; XML 是一種結構化數據的標記語言&#xff0c;用來存儲、傳輸和描述數據。 它和 HTML 很像&#xff0c;但它的標簽是自定義的&#xff0c;不限定格式和外觀&#xff0c;而是強調數據的結構和含義。 XML不是用來展示數據的&#xff0c;HTML是用來展…

react經驗:i18n配置換行的富文本

應用場景 調用"useTranslations().rich"輸出換行的文本。 實施步驟 1.翻譯文件 例如:zh.json {"home":"第一行<br></br>第二行<font>加粗文本</font>" }2.調用rich處理標簽 t.rich(home, { br: () > <br /&g…

Wpf中控件作為Binding的源

1、Xaml代碼 Slider 滑動控件&#xff0c;設置了最小值0和最大值100&#xff0c;TextBox作為Binding的目標對象&#xff0c;它的Text屬性作為Binding目標的屬性&#xff0c;Binding的源的Source就是slider_test這個Slider滑動控件&#xff0c;Binding的源的Path就是slider_test…

【機器學習深度學習】典型的模型訓練過程

目錄 一、模型訓練直觀圖 二、核心目標 三、訓練過程詳解 3.1 訓練階段 1、準備起點&#xff1a;輸入數據 初始參數權重 2、模型嘗試預測&#xff1a;變換計算 (前向傳播) 3、檢查錯誤&#xff1a;計算損失值 4、學習的關鍵&#xff1a;反向傳播 梯度下降法 (調整權…

Mysql8.0版本未卸載干凈如何重新下載

Mysql8.0版本未卸載干凈如何重新下載 安裝前準備 清理現有安裝&#xff08;確保干凈環境&#xff09; :: 停止并卸載現有MySQL服務 net stop MySQL >nul 2>&1 sc delete MySQL >nul 2>&1:: 刪除舊數據目錄 rd /s /q "C:\ProgramData\MySQL" &…

垃圾收集器G1ZGC詳解

G1收集器(-XX:UseG1GC) G1 把堆劃分為許多大小相同的 Region&#xff08;默認 1~32 MB&#xff0c;一個堆通常包含上千個 Region&#xff0c;JVM目標是不超過2048個Region(JVM源碼里TARGET_REGION_NUMBER 定義)&#xff09; 不再是傳統的 Eden、Survivor、Old 靜態分代模型&…

Bootstrap 5學習教程,從入門到精通,Bootstrap 5 彈出框(Popovers) 語法知識點及案例(22)

Bootstrap 5 彈出框(Popovers) 語法知識點及案例 一、彈出框基本概念 彈出框(Popovers)是Bootstrap提供的一個小型覆蓋層組件&#xff0c;用于顯示額外的信息&#xff0c;當用戶點擊某個元素時出現&#xff0c;再次點擊時消失。 二、彈出框基本語法知識點 1. 必需屬性 dat…

輕巧靈動,智啟未來 ——Kinova Gen3 Lite 機器人輕松解鎖各行業自動化新姿勢

近年來&#xff0c;Kinova Gen3 Lite 機器人憑借其卓越的性能、靈活的應用能力以及出色的性價比&#xff0c;在全球范圍內掀起了一股熱銷狂潮。無論是科研機構、高校實驗室&#xff0c;還是工業制造企業&#xff0c;都對它青睞有加。其銷量持續攀升&#xff0c;市場占有率不斷擴…