我正在使用Transformable节点,并能够设置最小和最大比例值.但我使用的是默认尺寸更大的模型,因此我必须使用手势来缩小尺寸.如何设置模型/ Transformable节点的默认比例值?
我想用 PBR 呈现一些场景。我创建了金属度和粗糙度纹理,并希望将其应用于网格。当我尝试在 Xcode 中执行此操作时 - 一切都很好。我可以将此模型添加到场景中,然后将此纹理添加到模型中。

但我想以编程方式进行。这是我的代码:
NSData *vertices = [[NSData alloc] initWithBytes:modelPly->vertices length:modelPly->vertexCount * 3 * sizeof(float)];
SCNGeometrySource *vertexSource = [SCNGeometrySource geometrySourceWithData:vertices
semantic:SCNGeometrySourceSemanticVertex
vectorCount:modelPly->vertexCount
floatComponents:YES
componentsPerVector:3
bytesPerComponent:sizeof(float)
dataOffset:0
dataStride:sizeof(float) * 3];
// Normal source
NSData *normals = [[NSData alloc] initWithBytes:modelPly->normals length:modelPly->vertexCount * 3 * sizeof(float)];
SCNGeometrySource *normalSource = [SCNGeometrySource geometrySourceWithData:normals
semantic:SCNGeometrySourceSemanticNormal
vectorCount:modelPly->vertexCount
floatComponents:YES
componentsPerVector:3
bytesPerComponent:sizeof(float)
dataOffset:0
dataStride:sizeof(float) * 3];
// Texture coordinates source
NSData *facesTextures = [[NSData alloc] initWithBytes:modelPly->texCoord length:modelPly->vertexCount * 2 * sizeof(float)];
SCNGeometrySource *texcoordSource = [SCNGeometrySource …Run Code Online (Sandbox Code Playgroud) 最近在做一个项目,我需要用App音频和麦克风音频录制系统屏幕。
我尝试了以下解决方案。
调用函数之前
Run Code Online (Sandbox Code Playgroud)recorder.isMicrophoneEnabled = true startRecording(r: recorder)
func startRecording(_ r: RPScreenRecorder) {
r.startRecording(handler: { (error: Error?) -> Void in
if error == nil { // Recording has started
// sender.title = "Stop"
self.recorder.isMicrophoneEnabled = true
} else {
// Handle error
print(error?.localizedDescription ?? "Unknown error")
}
})
}
Run Code Online (Sandbox Code Playgroud)
问题是视频录制并保存到相机胶卷中,但保存的视频中既没有应用音频也没有麦克风音频记录
然后我尝试了 Replay Kit 的 screenCapture 功能。代码如下
//MARK: Screen Recording
func startRecording(withFileName fileName: String, recordingHandler:@escaping (Error?)-> Void)
{
if #available(iOS 11.0, *)
{
let fileURL = …Run Code Online (Sandbox Code Playgroud) RealityKit 的文档包括 structs: OcclusionMaterial, SimpleMaterial, 和UnlitMaterial用于将材料添加到ModelEntity.
或者,您可以加载一个带有材料的模型。
我想以ModelEntity编程方式向 a 添加自定义材料/纹理。如何在不将材质添加到 Reality Composer 或其他一些 3D 软件中的模型的情况下即时实现这一点?
我正在尝试将平面检测添加到一个简单的ARKit应用中。我想将图片放在垂直平面上。
因此,首先我需要检测平面,然后可以添加在RealityKit中创建的对象锚。
但是问题是我不确定使用ARKit 3和Xcode 11检测平面并将其添加到场景中的正确方法。
它应该很简单:
import ARKit
import RealityKit
@IBOutlet var arView: ARView!
override func viewDidLoad() {
super.viewDidLoad()
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = .horizontal
arView.session.run(arConfiguration)
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
类型“ ARView”的值没有成员“会话”
我什至尝试了以下内容,Apple在其WWDC演示(4:27)中将其用作示例,
苹果演示!
let anchor = AnchorEntity(plane: .verticle, minimumBounds: [0.2, 0.2])
arView.scene.addAnchor(anchor)
Run Code Online (Sandbox Code Playgroud)
但是尝试创建AnchorEntity时出现以下错误
表达式类型“ AnchorEntity”在没有更多上下文的情况下是模棱两可的
import UIKit
import RealityKit
import ARKit
class ViewController: UIViewController {
@IBOutlet var arView: ARView!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
}
override func viewDidLoad() {
super.viewDidLoad()
}
func …Run Code Online (Sandbox Code Playgroud) 对于我们有 SCNNodes SCNBillboardConstraint,那么有什么方法可以将此约束应用于实体(使用 RealityKit 而不是 SceneKit 时),以便实体在设备移动时始终面向相机?
纹理是否可以具有 alpha 透明度?
我有包含 8 位 RGBA 的 png 文件,但由于某种原因,应该透明的部分只是黑色。
我这样分配材料:
private func setupLightMeshes(_ scene: Entity) {
let lightEntity = scene.findEntity(named: "LightWindow_Plane")!
var lightMaterial = UnlitMaterial()
lightMaterial.baseColor = try! MaterialColorParameter.texture(
TextureResource.load(named: "light.png")) // this is 8bpc RGBA
var modelComponent = lightEntity.components[ModelComponent] as! ModelComponent
modelComponent = ModelComponent(mesh: modelComponent.mesh, materials: [lightMaterial])
lightEntity.components.set(modelComponent)
}
Run Code Online (Sandbox Code Playgroud) 我在启用 LiDAR 的设备上运行 iOS14 ARSession,并让它输出通过相机源动态创建的网格覆盖层。
是否可以禁用 ARView 或 ARSession 的相机源,同时仍然看到调试网格覆盖?
这是我显示网格覆盖的方式:
arView.debugOptions.insert(.showSceneUnderstanding)
Run Code Online (Sandbox Code Playgroud)
我想看到的是:黑屏,带有代表网格顶点和面的彩色线条。
我试图理解有关 Scenekit 的 Apple 文档,在谈论 SCNNode 变量时发现一些问题:
\n例如,使用 simdScale 变量或scale 变量应用比例有什么区别?
\n阅读文档,\n无法理解何时以及为何使用“管理节点\xe2\x80\x99s 变换(SceneKit 类型)”下的变量以及何时使用管理节点变换下的变量
\n例如,使用 var "scale" 还是 simdScale 更改 SCNode 的比例更好?
\n我认为 RealityView 应该能够做更多奇特的事情,但我仍然想弄清楚它们之间的确切区别。目前,它们彼此太相似了,例如它们都需要一个实体名称来初始化。我想知道什么时候 Model3D 就足够了,什么时候必须使用 RealityView?