- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 Experience.rcproject
有可以通过点击操作触发的动画。两个圆柱体分别命名为“Button 1”和“Button 2”,并启用了 Collide。
我正在使用 Async
方法加载 Experience.Map 场景,并使用 addAnchor
方法将 mapAnchor 添加到 ViewController 中的 ARView。
我尝试在场景中运行 HitTest 以查看应用程序是否正确 react 。
尽管如此,HitTest 结果会打印按钮的实体名称,即使我没有点击按钮而是点击它附近的区域也是如此。
class augmentedReality: UIViewController {
@IBOutlet weak var arView: ARView!
@IBAction func onTap(_ sender: UITapGestureRecognizer) {
let tapLocation = sender.location(in: arView)
// Get the entity at the location we've tapped, if one exists
if let button = arView.entity(at: tapLocation) {
// For testing purposes, print the name of the tapped entity
print(button.name)
}
}
}
下面是我尝试将 AR 场景和点击手势识别器添加到 arView。
class augmentedReality: UIViewController {
arView.scene.addAnchor(mapAnchor)
mapAnchor.notifications.hideAll.post()
mapAnchor.notifications.mapStart.post()
self.arView.isUserInteractionEnabled = true
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(onTap))
self.arView.addGestureRecognizer(tapGesture)
}
问题一
如何实现真正点击而不是靠近按钮时只打印按钮实体名称的目标?
问题二
我真的需要打开 Collide 才能在 HitTest 中检测到两个按钮吗?
问题三
有一个 installGestures 方法。目前没有关于此的在线教程或讨论。我试过了,但我对 (Entity & HasCollision) 感到困惑。这个方法如何实现?
最佳答案
To implement a robust
Hit-Testing
in RealityKit, all you need is the following code:
import RealityKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
let scene = try! Experience.loadScene()
@IBAction func onTap(_ sender: UITapGestureRecognizer) {
let tapLocation: CGPoint = sender.location(in: arView)
let result: [CollisionCastHit] = arView.hitTest(tapLocation)
guard let hitTest: CollisionCastHit = result.first
else { return }
let entity: Entity = hitTest.entity
print(entity.name)
}
override func viewDidLoad() {
super.viewDidLoad()
scene.steelBox!.scale = [2,2,2]
scene.steelCylinder!.scale = [2,2,2]
scene.steelBox!.name = "BOX"
scene.steelCylinder!.name = "CYLINDER"
arView.scene.anchors.append(scene)
}
}
当您点击 ARView 中的实体时,调试区域会打印“BOX”或“CYLINDER”。如果您点击实体以外的任何东西,调试区域只会打印“Ground Plane”。
If you need to implement a Ray-Casting read this post, please.
附言
如果您在 macOS 模拟器上运行此应用程序,它只会打印 Ground Plane
而不是 BOX
和 CYLINDER
。所以你需要在 iPhone 上运行这个应用程序。
关于swift - 即使我没有点击它,HitTest 也会打印 AR 实体名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56736645/
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit th
谷歌是现代增强现实 (AR) 领域的早期领导者之一,但该公司近年来的努力似乎并未取得太大进展。不过,随着苹果和 Facebook 都在 AR 上投入了大量资金,这种趋势很快就会逆转。 ▲
我正在 Unity3D 中开发一款类似于 Pokemon Go 的游戏。使用 Kudan 增强现实 SDK。我的要求很简单,AR 对象必须始终面向相机。我完全不知道如何使用 Kudan AR 完成这项
这是我的主要代码 package com.example.ar; import androidx.appcompat.app.AppCompatActivity; import android.app
有任何方法可以从普通 View 切换到耳机 View ,并将所有模型保留在最后一个 View 中。我正在将模型放在普通 View 中的地面上,然后用户点击一个按钮切换到耳机 View (并佩戴谷歌纸板
我有一个关于 ar 对象触摸检测的问题。我将 A-Frame 与 Ar.js 结合使用 在我的项目中,我有一个可以旋转的地球仪。现在我想添加特定于国家/地区的“标记”,它也应该是对象。 我尝试过: A
我需要一些关于将自定义 AR 标记与 AR.js 结合使用的帮助。从自定义标记生成器页面下载 .patt 文件后,我们遇到了一些问题,让对象在标记上初始化。一切都在 Node.js 服务器上的客户端进
在浏览器上演示 AR.js AR 功能的所有示例和代码,在网页加载后立即运行。但是,我想为用户提供一个选项,以手动启动和停止扫描过程以及隐藏 AR 内容。 基本上,我只想在用户单击网页上的按钮时加载
正如我在以下问题中所问的那样: Arabic number in Arabic text in Android 如果我使用阿拉伯语语言环境 ar-ae 或 ar-sa,数字将使用印度-阿拉伯数字显示。
当尝试使用这些方法找到最佳 AR(p) 模型时,我得到了截然不同的结果。 ar {统计信息}:http://stat.ethz.ch/R-manual/R-patched/library/stats/
我正在尝试使用 for 循环对列表的值求和。这是我的代码: def sumAnArray(ar): theSum = 0 for i in ar: theSum = t
我正在使用 node-ar-drone 来控制无人机,在起飞之前我想执行平面配平。但是,我注意到该模块中没有执行此操作的函数,所以我想知道如何做到这一点。 最佳答案 node-ar-drone 有一个
为什么我需要在运行 hello-ar 示例之前安装 ar-core 预览版 apk 服务。如果我不安装 ar-core 预览版 apk,hello-ar 示例应用程序会崩溃。 最佳答案 您必须安装 a
随着第四次工业革命的出现,制造业引入了工业4.0的概念。工业4.0实际上是通过使用机器人、物联网、网络安全、人工智能、增强现实(AR)、虚拟现实(VR)等先进技术对制造业进行数字化转型,它也被称
在 AR.JS 演示中,具有多个后置摄像头的 Android 手机往往会使用错误的镜头,例如伸缩镜头。比如华为mate 20 pro就使用了3倍镜头。如何选择合适的相机使用? 最佳答案 我遇到了同样的
我在公司项目中使用两个内部库。我导入了.aar文件,然后将它们作为依赖项添加到Projedt Structure->“+”按钮中已声明的依赖项下。这在我的应用程序级gradle文件中生成了以下几行:
我正在尝试开发AR Android应用程序。 它应该检测并识别相机捕获的对象,为此,我正在使用OpenCV,但我对AR Realm 中的移动设备的对象识别不是很熟悉。 我有两个问题: 1- SIFT,
我有一个由 bjam 提供给 ar (android ar exactly) 的超长命令行,而 ar 只是破坏了一个文件路径和提示文件不存在。 有没有办法让 ar 分配更大的命令行缓冲区? 最佳答案
如果命令行中指定的某些库不存在,则来自 Binutils 的经典“ar”工具不会失败。它仅显示消息“ar: .a: No such file or directory”,但返回代码为零。 这使得有时很
最近我在使用 ARToolKit 工作,我面临着从静态图像创建 AR 标记的必要性。因此,正如 ARToolKit 旧时事通讯中所建议的那样,我开始编写自己的视频函数,当我执行 mk_patt.exe
我是一名优秀的程序员,十分优秀!