gpt4 book ai didi

javascript - 使用 8th Wall SDK 与多个图像目标进行增强

转载 作者:行者123 更新时间:2023-12-02 20:56:13 29 4
gpt4 key购买 nike

我想在多个图像上增强视频。所以我正在尝试使用多个图像实现第八墙图像跟踪增强。但我无法获得增强。我对图像目标有疑问。如果我在 html 中提到图像目标名称,那么它就可以工作。

<a-entity target-video="name: imageTargets; video: #alpha-video;" material="shader: chromakey; src: #alpha-video; color: 0.1 0.9 0.2" geometry="primitive: plane; height: 0.6; width: 1.38;"> </a-entity>

名称:imagetarget1(第 8 个墙壁控制台中的图像目标名称之一)

但是当我尝试使用多个图像时,它不起作用。任何人都可以帮我解决这个问题。我已在第 8 个墙上控制台上传了 10 张图像,名称如下 - 'imagetarget1'、'imagetarget2'、'imagetarget3'、'imagetarget4'、'imagetarget5'、'imagetarget6'、'imagetarget7'、'imagetarget8'、'imagetarget9 ', 'imagetarget10' 。

AFRAME.registerComponent('target-video', {
schema: {
name: {
type: 'string'
XR8.XrController.configure({
imageTargets: ['imagetarget1', 'imagetarget2', 'imagetarget3', 'imagetarget4', 'imagetarget5', 'imagetarget6', 'imagetarget7', 'imagetarget8', 'imagetarget9', 'imagetarget10']
})
},
video: {
type: 'string'
},
},
init: function() {
const object3D = this.el.object3D
const name = this.data.name
object3D.visible = false
const v = document.querySelector(this.data.video)
const el = this.el

const showImage = ({
detail
}) => {
if (name != detail.name) {
return
}
v.play()
object3D.position.copy(detail.position)
object3D.quaternion.copy(detail.rotation)
object3D.scale.set(detail.scale, detail.scale, detail.scale)
object3D.visible = true
}

const hideImage = ({
detail
}) => {
if (name != detail.name) {
return
}
v.pause()
object3D.visible = false
}

this.el.sceneEl.addEventListener('xrimagefound', showImage)
this.el.sceneEl.addEventListener('xrimageupdated', showImage)
this.el.sceneEl.addEventListener('xrimagelost', hideImage)
}
})
<!doctype html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">

<title>8th Wall Alpha Video Example</title>

<script src="//cdn.8thwall.com/web/aframe/8frame-0.9.0.min.js"></script>
<script src="https://unpkg.com/aframe-chromakey-material/dist/aframe-chromakey-material.min.js"></script>


<!-- XR Extras - provides utilities like load screen, almost there, and error handling.
See github.com/8thwall/web/xrextras -->
<script src="//cdn.8thwall.com/web/xrextras/xrextras.js"></script>

<!-- 8thWall Web - Replace the app key here with your own app key -->
<script src="//apps.8thwall.com/xrweb?appKey=XXXXXXXXXX"></script>

</head>

<body>

<a-scene xrweb="disableWorldTracking: true" xrextras-gesture-detector xrextras-almost-there xrextras-loading xrextras-runtime-error>

<a-assets>
<video id="alpha-video" autoplay playsinline crossorigin="anonymous" loop="true" src="https://cdn.glitch.com/087c366e-1fe1-4d07-8886-bfaf18fbc321%2Fdino.mp4?v=1588058174702">
</video>
</a-assets>

<a-camera position="0 4 10" raycaster="objects: .cantap" cursor="fuse: false; rayOrigin: mouse;">
</a-camera>

<a-light type="directional" intensity="0.5" position="1 1 1"></a-light>

<a-light type="ambient" intensity="1"></a-light>

<!-- Note: "name:" must be set to the name of the image target uploaded to the 8th Wall Console -->
<a-entity target-video="name: imageTargets; video: #alpha-video;" material="shader: chromakey; src: #alpha-video; color: 0.1 0.9 0.2" geometry="primitive: plane; height: 0.6; width: 1.38;">
</a-entity>

</a-scene>

<script>
</script>

</body>

</html>

最佳答案

请尝试这可能会对您的多 AR 标记有所帮助

<a-scene
xrextras-almost-there
xrextras-loading
xrextras-runtime-error
config-targets=
"targets: macaw, owl, peacock, pelican, pigeon, puffin, cardinal, toucan, blue-jay, rooster"
xrweb="disableWorldTracking: true">

关于javascript - 使用 8th Wall SDK 与多个图像目标进行增强,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61478102/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com