在 AR.js/A-Frame 中有什么方法可以处理多个多标记区域? [英] Any way to handle more than one multimarker area in AR.js / A-Frame?

查看:22
本文介绍了在 AR.js/A-Frame 中有什么方法可以处理多个多标记区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 A-Frame 在 AR.js 中设置多个多标记区域.这个想法是将 4 个模式标记布置为每个内容的方形框架.AR.js 多标记示例 利用学习器将姿势矩阵数据放在 URL 中.有没有办法生成不同的多标记文件并将它们分配给每个 a-marker?我附上了一些示例代码来展示我想要实现的目标.

I'm trying to set-up more than one multi-marker area in AR.js with A-Frame. The idea is to have 4 pattern markers laid out as a square frame for each content. The AR.js multimarker examples make use of the learner to put the pose matrix data in the URL. Is there any way to generate different multimarker files and assign them to each a-marker? I've attached some sample code to show what I'm trying to achieve.

<a-scene>
<a-marker preset="area" id="first">
...
</a-marker>
<a-marker preset="area" id="second">
...
</a-marker>
<a-marker preset="area" id="third">
...
</a-marker>
<a-camera />
</a-scene>

推荐答案

似乎带有配置对象的 localstorage 项的名称是硬编码的 这里.

It seems the name of the localstorage item with the configuration object is hardcoded here.

我能够获得多个标记区域,但我不得不修改 ar.js 代码.结果在这个故障中,标记在资产中.

I was able to get multiple marker areas, but i had to modify the ar.js code. The result is in this glitch, the markers are in the assets.

首先,我必须创建并保留多标记配置对象(请参阅this SO线程,或this ar.js 关于自定义区域标记的问题).在创建场景之前,我设置了配置:

First, I had to create and keep the multimarker configuration objects (see this SO thread, or this ar.js issue on custom area markers). Before creating the scene i set the configs:

// the name will correspond to the marker id
var oneMarker = { /* paths, pose matrices, etc. */ }
localStorage.setItem("oneMarkerFile", JSON.stringify(oneMarker));

第二 - 我修改了 Arjs.Anchor 对象 - 所以它不会读取预定义的 localStorageObject:

Second - I've modified the Arjs.Anchor object - so it won't read a predefined localStorageObject:

// originally ARjsMultiMarkerFile
let markerId = markerParameters.markerName + "MarkerFile"

第三 - 我必须以某种方式传递 markerParameters.markerName.Arjs.Anchor 对象是在 arjs-anchor 组件初始化函数.只需一行,您就可以设置上面的 markerName 属性:

Third - I have to pass the markerParameters.markerName somehow. The Arjs.Anchor object is created in the arjs-anchor component init function. With one line you can set the above markerName property:

markerParameters.markerName = _this.el.id
// anywhere before instantiating the anchor (new ARjs.Anchor(arSession, markerParameters))

这篇关于在 AR.js/A-Frame 中有什么方法可以处理多个多标记区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆