# Shape (two parameters)

I am trying to understand shape() and its two parameters. In this simple example below I have used createShape() to make two spheres. Spheres, in my world, are three-dimensional. All is fine until I get to position the spheres. Here I have only two parameters (x,y):

shape(globe, 0, 0); // two parameters?

Also, the second sphere seems to be a child of the first???

I know how to use
translate(x, y, z);
But I would like to understand shape.

``````PShape globe;
PShape blob;

void setup() {
size (300, 300, P3D);

globe = createShape(SPHERE, 100);
blob = createShape(SPHERE, 30);

globe.setStroke(false);
blob.setStroke(false);
//
globe.setFill(color(255, 0, 0));
blob.setFill(color(255));
}

void draw() {
background(0);

translate(width/2, height/2);
rotateX(map(mouseX, 0, width, 0, TAU));
rotateY(map(mouseY, 0, height, 0, TAU));

shape(globe, 0, 0); // two parameters?
shape(blob, 100, 0); // this is, strangely, relative to the globe
}
``````
2 Likes

You are correct – place your shape sphere with `translate(x, y, z)`

As you have noticed, `sphere()` and `box()` work in the same way – the 3D primitives draw at 0,0,0 and are positioned with translate.

An interesting point of comparison to is `image()`. You can position it in 2D space with parameters, but to position it in 3D you use translate et cetera.

https://processing.org/reference/image_.html

The second shape is not relative to the first – both shapes are relative to the origin frame of reference you defined with translate. Because your first shape is at 0,0, the first appears relative to it, but if you give each coordinates it will be clear that they are independent.

2 Likes