如何处理 3D 对象大小及其在 ARKit 中的位置
how to handle 3D object size and its position in ARKit
我长期以来一直面临 3d 对象大小及其位置 x、y、z 的困难我将 3d 对象添加到 sceneView 但它的大小太大,如何根据我的要求减小 3d 对象大小,任何人都可以帮助我处理 3D 对象的大小及其 x、y 的位置,z.i 我正在使用 swift 进行编码。
如有帮助将非常感谢appreciated.Thanks
每个SCNNode
都有一个比例尺属性:
Each component of the scale vector multiplies the corresponding
dimension of the node’s geometry. The default scale is 1.0 in all
three dimensions. For example, applying a scale of (2.0, 0.5, 2.0) to
a node containing a cube geometry reduces its height and increases its
width and depth.
可以设置如下:
var scale: SCNVector3 { get set }
例如,如果您的节点名为 myNode
,您可以使用以下方法将其缩放为原始大小的 1/10:
myNode.scale = SCNVector3(0.1, 0.1, 0.1)
关于定位 SCNNodes 这可以通过设置 position
属性:
来实现
The node’s position locates it within the coordinate system of its
parent, as modified by the node’s pivot property. The default position
is the zero vector, indicating that the node is placed at the origin
of the parent node’s coordinate system.
因此,如果您想将 SCNNode 添加到 worldOrigin
的中心,并且距离相机 1m,您可以使用以下方法:
myNode.position = SCNVector3(0, 0, -1)
希望对您有所帮助...
我长期以来一直面临 3d 对象大小及其位置 x、y、z 的困难我将 3d 对象添加到 sceneView 但它的大小太大,如何根据我的要求减小 3d 对象大小,任何人都可以帮助我处理 3D 对象的大小及其 x、y 的位置,z.i 我正在使用 swift 进行编码。
如有帮助将非常感谢appreciated.Thanks
每个SCNNode
都有一个比例尺属性:
Each component of the scale vector multiplies the corresponding dimension of the node’s geometry. The default scale is 1.0 in all three dimensions. For example, applying a scale of (2.0, 0.5, 2.0) to a node containing a cube geometry reduces its height and increases its width and depth.
可以设置如下:
var scale: SCNVector3 { get set }
例如,如果您的节点名为 myNode
,您可以使用以下方法将其缩放为原始大小的 1/10:
myNode.scale = SCNVector3(0.1, 0.1, 0.1)
关于定位 SCNNodes 这可以通过设置 position
属性:
The node’s position locates it within the coordinate system of its parent, as modified by the node’s pivot property. The default position is the zero vector, indicating that the node is placed at the origin of the parent node’s coordinate system.
因此,如果您想将 SCNNode 添加到 worldOrigin
的中心,并且距离相机 1m,您可以使用以下方法:
myNode.position = SCNVector3(0, 0, -1)
希望对您有所帮助...