- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 UIRotationGestureRecognizer
旋转 SCNNode
并更改 eulerAngles
。我在围绕 y
和围绕 z
轴的旋转之间切换。当我只旋转其中一个时,一切都很好。但是当我旋转两者时出现问题。它不再绕轴旋转,而是随机旋转。
我已经阅读了很多答案,尤其是来自 ARGeo 的答案,例如:SCNNode Z-rotation axis stays constant, while X and Y axes change when node is rotated , 并且我了解eulerAngles
和 gimbal lock 的问题。
但我不明白如何正确使用orientation
ant w
组件。这里有人成功使用 UIRotationGestureRecognizer
和 orientation
而不是 eulerAngles
吗?
最佳答案
下面是如何实现 UIRotationGestureRecognizer
的示例之一。
我从How can I rotate an SCNNode....复制过来的所以发帖。
private var startingOrientation = GLKQuaternion.identity
private var rotationAxis = GLKVector3Make(0, 0, 0)
@objc private func handleRotation(_ rotation: UIRotationGestureRecognizer) {
guard let node = sceneView.hitTest(rotation.location(in: sceneView), options: nil).first?.node else {
return
}
if rotation.state == .began {
startingOrientation = GLKQuaternion(boxNode.orientation)
let cameraLookingDirection = sceneView.pointOfView!.parentFront
let cameraLookingDirectionInTargetNodesReference = boxNode.convertVector(cameraLookingDirection,
from: sceneView.pointOfView!.parent!)
rotationAxis = GLKVector3(cameraLookingDirectionInTargetNodesReference)
} else if rotation.state == .ended {
startingOrientation = GLKQuaternionIdentity
rotationAxis = GLKVector3Make(0, 0, 0)
} else if rotation.state == .changed {
let quaternion = GLKQuaternion(angle: Float(rotation.rotation), axis: rotationAxis)
node.orientation = SCNQuaternion((startingOrientation * quaternion).normalized())
}
}
希望这对您有所帮助。
关于ios - SCNNode 方向而不是 eulerAngles,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55762144/
我正在尝试从旋转矩阵中提取欧拉角。我的约定:矩阵列主,坐标系右手,正角右手,旋转顺序YXZ(先航向,然后姿态,然后倾斜) 我找到了这个,但无法使用它,因为它们使用其他轴顺序:(http://www.e
我正在尝试使用 UIRotationGestureRecognizer 旋转 SCNNode 并更改 eulerAngles。我在围绕 y 和围绕 z 轴的旋转之间切换。当我只旋转其中一个时,一切都很
我尝试从 Eigen 3x3 旋转矩阵中提取欧拉角。但是,我从 eulerAngles() 方法获得的值似乎不正确。我写了一个小测试代码,但得到了奇怪的结果。代码如下。 #include #incl
在游戏对象的检查器中,我使用的起始旋转是“-90”,但是当我运行 print(transform.eulerAngles.x) 时,我得到 270(同上 transform.localEulerAng
我正在尝试更改相机旋转的 eulerAngle X,同时将 y 和 z 保持为 0。 但是,以下 IEnumerator 会产生奇怪的 eulerAngles,例如 10、-74.653、0。 我不明
在我的项目中,我有一个变换,我想在 eulersAngles 中获得该变换的方向。 . 我如何获得 eulerAngles来自 4 的变换x 4 Swift 语言中的矩阵? 我至少需要 Pitch ,
这个问题已经有答案了: What is the type of SCNVector3 components? CGFloat or Float? (1 个回答) 已关闭 7 年前。 根据SceneKi
假设我有一个 3 维框架,旋转 roll = 0,pitch = 0 和 yaw = 0,分别关于 x、y 和 z 轴。 我希望框架绕 x 轴旋转 3.14159 (Pi) 或 roll = Pi。
我正在尝试使用 SceneKit 为 tvOS 开发游戏,但我遇到了问题。当我在向 physicsBody 施加脉冲之前设置节点的 eulerAngle 时,节点将重置为其原始位置。 我期待看到节点在
我花了一些时间实现了几种算法来在 EulerAngles 和 Quaternions 之间进行转换。 我正在测试四元数值是否与此代码相同 Quaternion orientation0
Mathf.Clamp 在达到最大值时将我的欧拉角重置为最小值,而不是将其限制在最大值。我试过这个: rotateX = Input.GetAxis("Mouse X") *
我是一名优秀的程序员,十分优秀!