类型“[vector_float3]”(又名 'Array<float3>')的值没有成员 'advanced'
Value of type '[vector_float3]' (aka 'Array<float3>') has no member 'advanced'
在 apple 的 arkit 示例代码中,我收到此错误“[vector_float3]”类型的值(又名 'Array')没有成员 'advanced'
它在 XCode 9 beta 版本或 GM 版本
上运行良好
我正在使用此代码
func hitTestWithFeatures(_ point: CGPoint, coneOpeningAngleInDegrees: Float,
minDistance: Float = 0,
maxDistance: Float = Float.greatestFiniteMagnitude,
maxResults: Int = 1) -> [FeatureHitTestResult] {
var results = [FeatureHitTestResult]()
guard let features = self.session.currentFrame?.rawFeaturePoints else {
return results
}
guard let ray = hitTestRayFromScreenPos(point) else {
return results
}
let maxAngleInDeg = min(coneOpeningAngleInDegrees, 360) / 2
let maxAngle = ((maxAngleInDeg / 180) * Float.pi)
let points = features.points
for i in 0...features.__count {
let feature = points.advanced(by: Int(i))
let featurePos = SCNVector3(feature.pointee)
let originToFeature = featurePos - ray.origin
let crossProduct = originToFeature.cross(ray.direction)
let featureDistanceFromResult = crossProduct.length()
let hitTestResult = ray.origin + (ray.direction * ray.direction.dot(originToFeature))
let hitTestResultDistance = (hitTestResult - ray.origin).length()
// All tests passed: Add the hit against this feature to the results.
results.append(FeatureHitTestResult(position: hitTestResult,
distanceToRayOrigin: hitTestResultDistance,
featureHit: featurePos,
featureDistanceToHitResult: featureDistanceFromResult))
}
// Sort the results by feature distance to the ray.
results = results.sorted(by: { (first, second) -> Bool in
return first.distanceToRayOrigin < second.distanceToRayOrigin
})
return cappedResults
}
我遇到了同样的问题,很高兴解决了。 Apple 已经在此处更新了此示例:https://developer.apple.com/library/content/samplecode/AudioInARKit/Listings/Audio_in_ARKit_ARSCNView_HitTests_swift.html
只需一点零钱就可以了:
let points = features.__points
而不是:
let points = features.points
希望对您有所帮助
在 apple 的 arkit 示例代码中,我收到此错误“[vector_float3]”类型的值(又名 'Array')没有成员 'advanced' 它在 XCode 9 beta 版本或 GM 版本
上运行良好我正在使用此代码
func hitTestWithFeatures(_ point: CGPoint, coneOpeningAngleInDegrees: Float,
minDistance: Float = 0,
maxDistance: Float = Float.greatestFiniteMagnitude,
maxResults: Int = 1) -> [FeatureHitTestResult] {
var results = [FeatureHitTestResult]()
guard let features = self.session.currentFrame?.rawFeaturePoints else {
return results
}
guard let ray = hitTestRayFromScreenPos(point) else {
return results
}
let maxAngleInDeg = min(coneOpeningAngleInDegrees, 360) / 2
let maxAngle = ((maxAngleInDeg / 180) * Float.pi)
let points = features.points
for i in 0...features.__count {
let feature = points.advanced(by: Int(i))
let featurePos = SCNVector3(feature.pointee)
let originToFeature = featurePos - ray.origin
let crossProduct = originToFeature.cross(ray.direction)
let featureDistanceFromResult = crossProduct.length()
let hitTestResult = ray.origin + (ray.direction * ray.direction.dot(originToFeature))
let hitTestResultDistance = (hitTestResult - ray.origin).length()
// All tests passed: Add the hit against this feature to the results.
results.append(FeatureHitTestResult(position: hitTestResult,
distanceToRayOrigin: hitTestResultDistance,
featureHit: featurePos,
featureDistanceToHitResult: featureDistanceFromResult))
}
// Sort the results by feature distance to the ray.
results = results.sorted(by: { (first, second) -> Bool in
return first.distanceToRayOrigin < second.distanceToRayOrigin
})
return cappedResults
}
我遇到了同样的问题,很高兴解决了。 Apple 已经在此处更新了此示例:https://developer.apple.com/library/content/samplecode/AudioInARKit/Listings/Audio_in_ARKit_ARSCNView_HitTests_swift.html
只需一点零钱就可以了:
let points = features.__points
而不是:
let points = features.points
希望对您有所帮助