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

标签 javascript augmented-reality 8thwall-xr 8thwall-web 8th

我想在多个图像上增强视频。所以我正在尝试使用多个图像实现第八墙图像跟踪增强。但我无法获得增强。我对图像目标有疑问。如果我在 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/

相关文章:

javascript - 在调整大小时更改导航栏标题颜色

javascript - 在给定索引上将字符串一分为二并返回两个部分

javascript - Socket.io错误: failed to require "socket.io" from "root"

ios - ARKit + Core 位置 - 点不固定在同一个地方

8thwall-xr - XR远程抛出系统异常工作

javascript - 如何使用 CSS 类更改特定样式?

objective-c - 具有简单 "events"系统的 iOS 增强现实库

android - ARCore Pose 和 Aruco estimatePoseSingleMarkers

android - 8th Wall XR 相机位置没有改变

android - 场景背景不显示相机捕获