Post not yet marked as solved
Hi,
I want to begin by saying thank you Apple for making the Spatial framework! Please add a million more features ;-)
I'm using the following code to make an object "look at" another point, but at a particular rotation the object "flips" its rotations.
See a video here: https://www.dropbox.com/s/5irxt0gxou4c2j6/QuaternionFlip.mov?dl=0
I shake the mouse cursor when it happens to make it obvious to you.
import Spatial
let lookAtRotation = Rotation3D(eye: Point3D(position), target: Point3D(x: 0, y: 0, z: 0), up: Vector3D(x: 0, y: 1, z: 0))
myObj.quaternion = lookAtRotation.quaternion
So my question is why is this happening, and how can I fix it?
thx
Post not yet marked as solved
Hi,
I'm trying to convert my SceneKit code into pure Metal/MetalKit and I feel confused about this code and how I should rewrite it.
I've made the code simple for this case with some pseudocode. The part where it says "SceneKit magic" is where I feel lost.
The SCNNode is just an empty placeholder just as it is – and it works for the calculations it is doing inside.
Any help and pointers are much appreciated :-)
class Scene
{
let ball = Ball()
let scnNode = SCNNode()
var quaternionAngleVelocity = float2(0, 0)
func update()
{
// pseudocode, the user press the up key
quaternionAngleVelocity.x -= 3
// pseudocode, the user press the down key
quaternionAngleVelocity.x += 3
// pseudocode, the user press the left key
quaternionAngleVelocity.y -= 3
// pseudocode, the user press the right key
quaternionAngleVelocity.y += 3
...
// apply friction
quaternionAngleVelocity *= (1 - 0.05) // i.e. decrease with 5%
// rotate
let newQuaternionAxisX = simd_quatf(angle: quaternionAngleVelocity.x.degreesToRadians,
axis: simd_float3(x: 1, y: 0, z: 0))
let newQuaternionAxisY = simd_quatf(angle: quaternionAngleVelocity.y.degreesToRadians,
axis: simd_float3(x: 0, y: 1, z: 0))
let finalQuaternion = simd_normalize(newQuaternionAxisX * newQuaternionAxisY)
// SceneKit magic…?
let matrix4 = SCNMatrix4Mult(scnNode.worldTransform, SCNMatrix4(simd_float4x4(finalQuaternion)))
scnNode.transform = matrix4
ball.quaternion = scnNode.simdWorldOrientation
}
}
class Ball
{
var position: float3 = [0, 0, 0]
var rotation: float3 = [0, 0, 0]
{
didSet
{
let rotationMatrix = float4x4(rotation: rotation)
quaternion = simd_quatf(rotationMatrix)
}
}
var scale: float3 = [1, 1, 1]
var forwardVector: float3 { return normalize([sin(rotation.y), 0, cos(rotation.y)]) }
var rightVector: float3 { return [forwardVector.z, forwardVector.y, -forwardVector.x] }
var upVector: float3 { return [0, forwardVector.z, 0] }
var quaternion = simd_quatf()
var modelMatrix: float4x4
{
let translateMatrix = float4x4(translation: position)
// let rotateMatrix = float4x4(rotation: rotation)
let rotateMatrix = float4x4(quaternion)
let scaleMatrix = float4x4(scaling: scale)
return (translateMatrix * rotateMatrix * scaleMatrix)
}
var worldTransform: float4x4
{
return modelMatrix
}
}
Post not yet marked as solved
I get
Error Domain=kCLErrorDomain Code=1 "(null)" in the Xcode console when a start to update for location. This does not happen in the example app, so I'm wondering what I might have done wrong?
Post not yet marked as solved
Be aware, there are many errors / non-existing API's etc. in this session. This is yet the worst session I've seen in this years WWDC. Sorry but I have to be honest.
Post not yet marked as solved
Watching https://developer.apple.com/wwdc20/10644
Using Swift on AWS Lambda with Xcode.
When I call http://127.0.0.1:7000/invoke I get Status: 405 Method Not Allowed? in the browser. And my breakpoint does not hit, no message in Xcode either. Did anyone get this to work?
Post not yet marked as solved
I'm using Xcode 12.
I have set the ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME to "AccentColor", and created a Color Set named "AccentColor". When run I still see the default system blue color as the tint.
I don't understand why this does not work. I've done exactly as it is when I create a new iOS project from scratch. This does not seem to work in my existing project.