**引入腳本(html5渲染器)**
`<script src="./tour.js"></script>`
**創建嵌入容器**
`<div id="pano" style="width:100%;height:100%;"></div>`
**創建對象及配置參數**
~~~
embedpano({
swf:"krpano.swf", // flash渲染器
xml:"krpano.xml", // 主配置文件 缺省的時候會調用krpano.xml和krpano.swf 不加載設置0即可
target:"pano", // 嵌入容器id
id:"krpanoSWFObject", // 當前全景id,javascript接口調用會使用此id
bgcolor:"#000000",// 背景顏色
html5:"auto", // html5模式(auto:自動;prefer:優先使用html5;fallback:優先flash;only:只使用html5;always:始終使用html5-僅用于測試;never:始終使用flash;可加上webgl或css3d渲染技術,如auto+css3d)
flash:"auto",// flash模式(auto,prefer,fallback,only,never和html設置類似)
wmode:"window",// flash模式設置(window:窗口;opaque:不透明;opaque-flash:不透明,僅限flash;transparent:透明的;transparent-flash:透明的,僅限flash;direct:最佳性能,但可能不兼容舊系統和瀏覽器)
localfallback:"http://localhost:8090",
vars:{},// 在xml加載解析后設置啟動變量
initvars:{},// 在xml加載解析前設置啟動變量,可以在地址進行查詢(our.html?initvars.variable=value)
basepath:...// 基本路徑 (相對于krpano.swf)
consolelog:false,// 是否在瀏覽器控制臺打印日志信息
mwheel:true,// 是否啟用鼠標滾輪
focus:true,// 獲得焦點
webglsettings:{preserveDrawingBuffer:false, depth:false, stencil:false},//webgl設置
mobilescale:0.5, // 移動設備縮放
fakedevice:"",// "mobile", "tablet", "desktop";模擬設備 (僅限測試)
onready:function,// 準備就緒回調函數,一般當javascript調用krpano接口的時候,需要在此方法內
onerror:function,// 錯誤回調函數
passQueryParameters:true, // 啟用url查詢參數( html5, flash, wmode, mobilescale, fakedevice, initvars)作為變量傳遞,如tour.html?html5=only&startscene=scene2&initvars.design=flat
});
~~~
**移除全景**
`removepano(id);`
* * * * *
官網文檔:https://krpano.com/docu/html/#top
- 概述
- 文件說明
- 載入全景
- krpano xml語法
- krpano xml內置元素
- 特殊屬性
- krpano
- preview
- image
- view
- area
- display
- control
- cursors
- autorotate
- plugin/layer
- hotspot
- events
- action
- contextmenu
- network
- memory
- security
- lensflareset
- lensflare
- data
- scene
- style
- include
- progress(廢棄)
- textstyle(廢棄)
- action腳本語法
- 全局變量
- 邏輯、流程
- 數學運算符、函數
- 字符處理
- 動畫效果
- 動態加載
- 視圖動作、相機控制
- 坐標轉換
- 更新重繪
- 動態添加移除元素
- 擴展js接口
- 調試
- 顯示文字(廢棄)
- 參考手冊
- 常用操作
- 音樂控制
- 視頻熱點控制
- 全屏
- 鍵盤鼠標
- 場景
- 與js交互
- 獲取中心坐標
- 插入全景視頻
- krpano tools使用
- 常用插件
- Combobox(列表框)
- Videoplayer(視頻播放器)
- Scrollarea(區域滾動)
- Gyro2(陀螺儀)
- MoreTweenTypes(動效)
- gridmenu(網格縮略圖)
- skin_setting