<script setup lang="ts">
import {onLoad} from "@dcloudio/uni-app";
let session :any= null
let markerId :any= null
onLoad((op:any)=>{
console.log("url",op.url)
init()
addOSDMarker(op.url);
})
function init(){
session = wx.createVKSession({
track: {
plane: {
mode: 3
},
OSD: true,
},
version: 'v1',
})
}
function startOSD(){
session.start((err:any)=>{
console.log("start err",err)
session.on("addAnchors",(anchors :any[])=>{
console.log("addAnchors",anchors)
})
session.on("updateAnchors",(anchors :any[])=>{
console.log("updateAnchors",anchors)
})
session.on("removeAnchors",(anchors :any[])=>{
console.log("removeAnchors",anchors)
})
})
}
function addOSDMarker(url:string) {
const path = `${wx.env.USER_DATA_PATH}/test_osd.jpg`
wx.downloadFile({
url: url,
path,
success: () => {
console.log('addOSDMarker', path)
markerId = session.addOSDMarker(path)
startOSD()
}
})
}
function btnTest(){
console.log("getAllOSDMarker",session.getAllOSDMarker())
}
</script>
<template>
<camera type="webgl" style="width: 100%; height: 70vh;">
</camera>
<button @click="btnTest">测试</button>
</template>
<style scoped lang="scss">
</style>