- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在努力将 RealityKit 场景添加到 ARKit anchor 。正如我之前的问题,无法将 RealityKit 场景直接添加到 ARKit anchor 节点。
但是如何使用 ARKit Anchor 来放置我的场景?
例如,我想在房间中找到一个物体,根据我找到的物体,我想使用不同的场景并根据识别的物体位置将它们 anchor 定在房间中。
谢谢您的帮助。
当前尝试:
func makeUIView(context: Context) -> ARView {
let arView = ARView(frame: .zero)
// Load the "Box" scene from the "Experience" Reality File
let boxAnchor = try! Experience.loadBox()
// Add the box anchor to the scene
arView.scene.anchors.append(boxAnchor)
let configuration = ARWorldTrackingConfiguration()
guard let referenceObjects = ARReferenceObject.referenceObjects(
inGroupNamed: "AR Objects", bundle: nil) else {
fatalError("Missing expected asset catalog resources.")
}
configuration.detectionObjects = referenceObjects
arView.session.run(configuration) // not possible at arview, but i need arview for the .rcproject :-/
return arView
}
编辑:添加代码
最佳答案
ARKit 没有节点。 SceneKit 可以。
但是,如果您需要使用 ARKit 的 anchor 将 RealityKit 的模型放入 AR 场景中,就这么简单:
import ARKit
import RealityKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
let boxScene = try! Experience.loadBox()
override func viewDidLoad() {
super.viewDidLoad()
arView.session.delegate = self
let entity = boxScene.steelBox
var transform = simd_float4x4(diagonal: [1,1,1,1])
transform.columns.3.z = -3.0 // three meters away
let arkitAnchor = ARAnchor(name: "ARKit anchor",
transform: transform)
let anchorEntity = AnchorEntity(anchor: arkitAnchor)
anchorEntity.name = "RealityKit anchor"
arView.session.add(anchor: arkitAnchor)
anchor.addChild(entity)
arView.scene.anchors.append(anchorEntity)
}
}
由于 AnchorEntity 便利初始值设定项,这成为可能:
convenience init(anchor: ARAnchor)
session(_:didAdd:)
和
session(_:didUpdate:)
实例方法:
extension ViewController: ARSessionDelegate {
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
guard let objectAnchor = anchors.first as? ARObjectAnchor
else { return }
let anchor = AnchorEntity(anchor: objectAnchor)
let entity = boxScene.steelBox
anchor.addChild(entity)
arView.session.add(anchor: objectAnchor)
arView.scene.anchors.append(anchor)
}
}
关于swift - 使用 ARKit anchor 放置 RealityKit 场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65304656/
我正在尝试绘制一个可以帮助某人了解元素尺寸的盒子,但我一直遇到一个问题,因为当我将物理元素放在飞机顶部时,我首先需要识别飞机,所以我的盒子被画了进去项目的前面。 是否有可能以某种方式克服这一点? 最佳
我正在用 swift 4 制作一个简单的标尺 ARKit 应用。 但我遇到的问题是,有时我的措施有一点偏差或完全偏差。我认为,这可能是因为 ARkit 校准不当,没有正确检测到我的表面。 我目前在 3
我一直在用 ARKit 构建一个门户,虽然构建一个虚拟环境很容易创建和移动,但我想让我进入一个重复播放 360 度视频的环境。我认为可以通过将 360 度视频作为纹理包装到球体来完成,但 ARKit
我正在尝试向场景中的每个节点添加动画。我的一个问题是,在层次结构中 - 我应该将动画添加到哪个节点。我认为它是由您实际看到的内容所代表的节点,这将是网格对象...但我有一个持有两个灯和网格对象的节点.
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 2 年前。 Improve t
我正在使用 ARKit 进行 AR 项目。 我想添加一个 UIView 到 ARKit 场景。当我点击一个对象时,我想获取该对象旁边的“弹出窗口”信息。此信息位于 UIView 中。 是否可以将此 U
我想使用 Vuforia 检测标记并在其上放置一个 3d 对象。从那时起,我想在我的应用程序中使用 ARKit。我如何知道检测到的标记或 3d 对象的 ARKit 世界变换? 我正在使用相同的 Vie
我上下阅读了所有 ARKit 类的完整文档。我没有看到任何描述实际获取用户面部纹理的能力的地方。 ARFaceAnchor 包含 ARFaceGeometry(由顶点组成的拓扑和几何)和 BlendS
我正在使用 ARKit 2 和 ARWorldMapData 我创建了一个 AR 世界,它可以使用来自 link here 的 map 数据等识别您的周围环境.现在我正在尝试弄清楚如何获取所有特征点并
我正在使用 ARKit 将虚拟对象放置在真实环境中。它在 Xcode 9 和 iOS 11 中运行良好。但是当我更新 Xcode 和 iOS 时,如果我将虚拟对象放在检测到的平面上,它就会卡住,如果我
我收到关于 init() 的错误消息不适用于 ARLightEstimate . 代码: class LightSensorManager { let lightEstimate = ARLi
我需要使用 ARKit 检测虚拟对象何时与现实世界对象接触。 有什么办法可以查出来吗? 最佳答案 首先您需要创建一个符合OptionSet 协议(protocol)并具有bitset 类型属性的碰撞类
我想实现类似的东西 ARCore's raycast method它采用世界空间坐标中的任意光线而不是屏幕空间点: List hitTest (float[] origin3, int originO
嗨,我正在尝试在节点周围产生发光效果。我使用了 SCNNode 过滤器属性并设置为 CIFilter 数组。 仅当节点后面没有我不理解的节点时,它才起作用并呈现。我尝试设置渲染顺序和 readDept
我正在尝试重现 ARCamera 的项目点函数,但由于某种原因,这些值没有正确匹配。我正在使用 ARCamera 的投影矩阵和 View 矩阵并应用基本的 CG 透视变换数学,(PV) * p,但 N
我想获得所有三个轴的旋转度数。我正在尝试用横向模式来实现。当从左向右旋转设备(Y 旋转)时,我希望一旦用户设置左端并向右旋转即可覆盖度数。所以当它到达起点时我们需要 360 度。所以对于y轴旋转,使用
我正在使用新的 ARKit,并且能够创建一个名为 SphereNode 的新文件,该文件能够在 View 上创建可放置的 Sphere。 重点是我真的想添加一个自定义对象而不是标准球体。一些建议?这是
我一直在使用 ARkit 并且很喜欢它,但我注意到在负载跟踪期间可能会有点跳动(突然物体从它们的位置跳出一点点,比如 1-3 厘米)。我一直在想是否有一种方法可以平滑这些跳跃,这样就不会那么分散注意力
我正在尝试从以下内容中检索 string=Gate。 | geometryIndex=0 node= | no child> bone=(null)> MyCode 访问几何并且工作正常,如下 l
我正在尝试使用 ARKit 构建家具放置 AR 应用程序,我的项目中有 .scn 椅子及其 PNG 纹理,我的应用程序应该检测水平面,然后当用户点击时,将对象放置在点击的位置。 但是当我点击时,该对象
我是一名优秀的程序员,十分优秀!