我正在为我的应用程序使用ARKit,我尝试从我的web服务器(URL)动态加载.scn文件
这是我的代码的一部分
let urlString = "https://da5645f1.ngrok.io/mug.scn"
let url = URL.init(string: urlString)
let request = URLRequest(url: url!)
let session = URLSession.shared
let downloadTask = session.downloadTask(with: request,
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
-> Void in
print("location:\(String(describing: location))")
let locationPath = location!.path
let documents:String = NSHomeDirectory() + "/Documents/mug.scn"
ls = NSHomeDirectory() + "/Documents"
let fileManager = FileManager.default
if (fileManager.fileExists(atPath: documents)){
try! fileManager.removeItem(atPath: documents)
}
try! fileManager.moveItem(atPath: locationPath, toPath: documents)
print("new location:\(documents)")
let node = SCNNode()
let scene = SCNScene(named:"mug.scn", inDirectory: ls)
let nodess …Run Code Online (Sandbox Code Playgroud) 我尝试在ARKit应用程序中从服务器URL加载动态.scn和纹理文件.我已经通过这种 方式从web url上实现了加载.scn文件..但是在运行后我没有在设备上看到任何纹理.我收到以下错误消息.
ARKitExample[3016:995067] [SceneKit] Error: Failed loading : <C3DImage 0x1d42e1980 src:file:///var/containers/Bundle/Application/622ACF79-2318-4953-A9AE-9A7F2B453AFB/ARKitExample.app/textures/lamp_DIFFUSE.png [0.000000x0.000000]>
ARKitExample[3016:995067] [SceneKit] Error: Failed loading : <C3DImage 0x1d00fe800 src:file:///var/containers/Bundle/Application/622ACF79-2318-4953-A9AE-9A7F2B453AFB/ARKitExample.app/textures/lamp_NORMAL.png [0.000000x0.000000]>
ARKitExample[3016:995067] [SceneKit] Error: Failed loading : <C3DImage 0x1d40ff800 src:file:///var/containers/Bundle/Application/622ACF79-2318-4953-A9AE-9A7F2B453AFB/ARKitExample.app/textures/lamp_METALLIC.png [0.000000x0.000000]>
ARKitExample[3016:995067] [SceneKit] Error: Failed loading : <C3DImage 0x1d42e0d80 src:file:///var/containers/Bundle/Application/622ACF79-2318-4953-A9AE-9A7F2B453AFB/ARKitExample.app/textures/lamp_ROUGHNESS.png [0.000000x0.000000]>
ARKitExample[3016:995067] [SceneKit] Error: Failed loading : <C3DImage 0x1d02e2e00 src:file:///var/containers/Bundle/Application/622ACF79-2318-4953-A9AE-9A7F2B453AFB/ARKitExample.app/textures/lamp_SHADOW.png [0.000000x0.000000]>
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题.谢谢
@ Xartec我已经尝试过你提到的方式,但我没有得到任何回复.我怎么能解决它?
let urlString = "\("https://d533c2fd.ngrok.io/")\("mode")"
let url = URL.init(string: urlString)
let request = URLRequest(url: url!)
let session = URLSession.shared
let downloadTask = session.downloadTask(with: request, …Run Code Online (Sandbox Code Playgroud) 我从Sketchfab下载了两个不同的3D模型.我在ARKit 3D对象放置中导入了两个模型.在放置3D模型时,节点没有正确地与其中一个模型的操纵器对齐..我已附上截图.
左侧是所选节点(视口)和操纵器正确对齐的位置.但右侧所选节点(视口)和操纵器未正确对齐.如何使节点和操纵器像左侧3D模型一样对齐中心.请指导我.谢谢
@Josh罗宾斯
我已经尝试过你的代码,但我仍然遇到同样的问题.
box.firstMaterial?.emission.contents = UIColor.green
box.firstMaterial?.shaderModifiers = [SCNShaderModifierEntryPoint.surface: sm]
box.firstMaterial?.isDoubleSided = true
let boxNode = SCNNode(geometry: box)
boxNode.position = SCNVector3(node.position.x,(node.position.y + Float((proheights * 0.0234)/2)),node.position.z)
let minimum = float3(treenode.boundingBox.min)
let maximum = float3(treenode.boundingBox.max)
let translation = (maximum - minimum) * 0.5
//3. Set The Pivot
treenode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
boxNode.pivot = SCNMatrix4MakeTranslation(translation.x, translation.y, translation.z)
self.addChildNode(boxNode)
Run Code Online (Sandbox Code Playgroud)
更新的代码
let treenode = SCNNode()
let box = SCNBox(width: (prowidths * 0.0234), height: (proheights * 0.0234), length: (prolenght * 0.0234), chamferRadius: 0) …Run Code Online (Sandbox Code Playgroud) I am trying to call multiple API parallel using rxjava2 in Android. it's working as per the requirement but in case of any api throws exception it fails to give the response of other API's, so is there any way to call other API who returning success response.
private fun getStoreCouponData() {
val userObservable = repo2
.create<StoreCouponsApi>(StoreCouponsApi::class.java!!)
.getCoupons
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
val eventsObservable = repo2
.create<StoreCouponsApi>(StoreCouponsApi::class.java!!)
.storeInfo
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
val combined = Observable.zip<StoreCoupons, StoreCoupons, StoreList>(userObservable, eventsObservable,
BiFunction<StoreCoupons, StoreCoupons, StoreList> { response1, …Run Code Online (Sandbox Code Playgroud)