Reputation: 305
I am facing difficulties with 3D object size and its x, y, z positioning. I added the 3D object to sceneView
, but its size is too big. How do I reduce the 3D object size based on my requirement? Can anyone help me handle the 3D object's size and its x, y, z positioning?
I am using Swift to code.
Upvotes: 0
Views: 2764
Reputation: 7385
Each SCNNode
has a scale property:
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.
Which can be set as follows:
var scale: SCNVector3 { get set }
If for example your node was called myNode
, you could thus use the following to scale it by 1/10 of it's original size:
myNode.scale = SCNVector3(0.1, 0.1, 0.1)
Regarding positioning SCNNodes this can be achieved by setting the position
property:
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.
If therefore, you wanted to add your SCNNode to the center of the worldOrigin
, and 1m away from the camera you can use the following:
myNode.position = SCNVector3(0, 0, -1)
Hope it helps...
Upvotes: 5