- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在点击图片时显示 3D 模型 ( See here )。点击图片后,它会转到 3DFloorPlanViewController
(嵌入在导航 Controller 中),相机可以工作,但没有显示 3D 对象 ( See here )。
我在没有导航 Controller 的情况下尝试了完全相同的代码,它工作得很好,所以我很困惑为什么它在嵌入导航 Controller 时不起作用。
我的 3D 对象位于名为“3D 对象”的文件夹中 ( See here )。我在 addPaperPlane
函数中尝试了 named: "3D Objects/paperPlane.scn"
和 named: "paperPlane.scn"
,但都没有工作了。
这是 3DFloorPlanViewController
的代码:
import UIKit
import ARKit
import SceneKit
class _DFloorPlanViewController: UIViewController, ARSCNViewDelegate {
@IBOutlet weak var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
sceneView.delegate = self
addPaperPlane()
//addCar()
configureLighting()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneView.session.pause()
}
func addPaperPlane(x: Float = 0, y: Float = 0, z: Float = -0.5) {
guard let paperPlaneScene = SCNScene(named: "3D Objects/paperPlane.scn"), let paperPlaneNode = paperPlaneScene.rootNode.childNode(withName: "paperPlane", recursively: true) else { return }
paperPlaneNode.position = SCNVector3(x, y, z)
sceneView.scene.rootNode.addChildNode(paperPlaneNode)
}
func addCar(x: Float = 0, y: Float = 0, z: Float = -0.5) {
guard let carScene = SCNScene(named: "car.dae") else { return }
let carNode = SCNNode()
let carSceneChildNodes = carScene.rootNode.childNodes
for childNode in carSceneChildNodes {
carNode.addChildNode(childNode)
}
carNode.position = SCNVector3(x, y, z)
carNode.scale = SCNVector3(0.5, 0.5, 0.5)
sceneView.scene.rootNode.addChildNode(carNode)
}
func configureLighting() {
sceneView.autoenablesDefaultLighting = true
sceneView.automaticallyUpdatesLighting = true
}
}
最佳答案
目前您的场景 View 中没有设置场景
let scene = SCNScene()
self.sceneView.scene = scene
一般来说试试这个:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Set the view's delegate
self.sceneView.delegate = self
self.sceneView.showsStatistics = true
self.sceneView.autoenablesDefaultLighting = true
let scene = SCNScene()
self.sceneView.scene = scene
}
关于swift - ARSCNView 嵌入导航 Controller 时不显示对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53485811/
如何初始化 ARSCNView var sceneView: ARSCNView? override func viewDidLoad() { super.viewDidLoad()
我正在尝试获取由触摸位置确定的 CGPoint 处的像素颜色。我尝试了以下代码,但颜色值不正确。 override func touchesBegan(_ touches: Set, with eve
我的 ARSCNView 上有一个圆角半径,如下所示; override func viewDidLayoutSubviews() { sceneView.layer.cornerRa
我想使用 ARKit 来计算当前视频帧中的环境光量。但是,在我检索当前帧时创建 ARSCNView 对象后,它返回空值。 我做错了什么? public class EyeAlignmentUICame
我需要将 ARSCNView 的 2d 坐标空间中的点转换为 3d 空间中的坐标。基本上是一条从视点到触摸位置的射线(距离设定的距离)。 我想为此使用 arView.unprojectPoint(ve
我需要对ARSCNView进行截图,类定义如下: public class SceneLocationView: ARSCNView, ARSCNViewDelegate { } 我正在按照以下方法完
如何以编程方式添加 ARSCNView?如何设置宽度、高度和约束条件? class ViewController: UIViewController { var sceneView: ARSC
在 AR 中旋转 3d 对象时,我试图使我的平移手势与 jigspace 应用程序一样流畅。这是我现在拥有的: @objc func rotateObject(sender: UIPanGesture
有什么方法可以禁用实时摄像头馈送并将自定义视频作为 ARSession 中的输入传递吗? 我要实现Record & Replay ARSession通过代码。 最佳答案 你去吧:) var o
我正在拍摄每一帧的快照,应用过滤器,并使用过滤后的图像更新 ARSCNView 的背景内容。一切正常,但屏幕上的所有 UI 元素都有很多延迟。 ARSCNView 上没有延迟。 func sessi
我在 viewDidLoad 中有以下代码 let scene = SCNScene(named: "funModel")! myNode = scene.rootNode.childNode(wit
我正在制作一个使用 ARKit 来测量两点之间的应用。目标是能够测量长度、存储该值,然后测量宽度并存储。 我遇到的问题是在获得测量值后处理节点。 到目前为止的步骤:1) 添加了一个带有重启功能的按钮。
我在 ARSCNView 中添加节点作为子节点和克隆节点,具体取决于我从菜单中选择的内容。该对象放置在我点击屏幕的位置。如何平移和缩放特定节点。 最佳答案 使用transform SCNNode 的属
我正在使用 ARKit,我希望允许用户在纵向和横向模式下使用该应用程序。除了 ARSCNView 之外,我希望所有 UI 控件都在方向更改时旋转。我试图将 sceneView 变换到相反的方向,但没有
我想对我现有的 AR 应用做一些修改,我想 Split View并在里面添加 2 个 ARSCNView 这样用户就可以使用 VR Card Box 并获得不同的体验但是 Xcode 总是返回给我:
我想对我现有的 AR 应用做一些修改,我想 Split View并在里面添加 2 个 ARSCNView 这样用户就可以使用 VR Card Box 并获得不同的体验但是 Xcode 总是返回给我:
我试图在点击图片时显示 3D 模型 ( See here )。点击图片后,它会转到 3DFloorPlanViewController(嵌入在导航 Controller 中),相机可以工作,但没有显示
我想要一个添加到场景中的节点指向北方。我从 Core Location 获取航向数据,因此它表示设备在我的场景创建时当前所面对的方向(因此我的根节点所面向的方向),然后我将航向添加到我的新 scene
我正在使用 ARKit。我需要将相机中的 View 保存到相册中。所以我在 Storyboard 中添加了一个按钮,以及如下所示的功能: @IBAction func saveScreenshot()
是否可以使用 ARSCNView,为支持它的设备配置 ARWorldTrackingConfiguration,并为不支持它的设备配置另一种方式(使用 A8 芯片或更低的芯片)并且仍然在后台进行视频渲
我是一名优秀的程序员,十分优秀!