Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSD 一直不识别是为什么呢?不会进入事件,addOSDMarker 返回的也是null #149

Open
bbhxwl opened this issue Aug 30, 2024 · 1 comment

Comments

@bbhxwl
Copy link

bbhxwl commented Aug 30, 2024

我用uniapp开发的,全部代码如下。不会进入事件

<script setup lang="ts">
import {onLoad} from "@dcloudio/uni-app";

let session :any= null
let markerId :any= null

onLoad((op:any)=>{
    // @ts-ignore
    const version = wx.getAppBaseInfo().SDKVersion
    console.log("url",version,op.url)
    // @ts-ignore
    session = wx.createVKSession({
        track: {
            OSD: true,
        }
    })
    addOSDMarker(op.url);
})

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) {
    // @ts-ignore
    const path = `${wx.env.USER_DATA_PATH}/find_osd_obj.jpg`
    // @ts-ignore
    wx.downloadFile({
        url: url,
        filePath:path,
        success: (obj:any) => {
            console.log("downloadFile success",obj)
            markerId = session.addOSDMarker(obj.filePath)
            console.log('addOSDMarker', markerId)
            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>
@congfamin
Copy link

congfamin commented Aug 30, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants