How to rotate scene object based on x,y,z coordinates

I have two properties: axisUp and axisRight

The can have the values: YNegative, Ypositive, XNegative, XPositive, ZNegative, ZPositive

What i want to do is rotate the scene based on what these properties are assigned to.

the cases i have listed below:

//If axisUp = Y ignore because three js uses right handed system where y is always up
//If axisUp = Z i believe i need to rotate the x axis. not sure why
//if axisUp= X not sure what needs to be done

//If axisRight:x then do nothing as x already right
//If axisRight = Z i believe i need to rotate the x axis. not sure why
//If axisRight= Y not sure what needs to be done.

example:
//not sure if correct
if (axis.axisUp === “z_positive”) {
scene.rotation.x = -90 * Math.PI/180;
}

Could you explain what you want to archive? To use a different “up-axis” you can set the up axis of any object or mesh with myObject.up.set(1.0, 0.0, 0.0) for positive-x for example, or set the THREE.Object3D.DefaultUp before any objects are created.

how can i do this for positive z facing up? myObject.up.set(0.0, 0.0, 0.1)?

Yes, if you want to set the axis globally you just need to set THREE.Object3D.DefaultUp.set(0.0, 0.0, 1.0); before you create any object.

but i want to set the z axis to up after all of the objects have been created not before.

Then you can set them directly on the object. Please use one post, the other one seems to be the same thing.

What is the purpose? Do you want to use Z as up axis instead Y? In this case you can set the axis as i described on the up property.

I will use this post and remove the other. Yes i want to set z up. but when i do scene.up.set(0.0.,0.0,0.1) nothing happens. everything is the same.

is it also correct to use scene.rotation.x = -90 * Math.PI/180; ? to rotate the x 90 degress so z points up?

You need to apply it to each single object you want to apply the axis. That’s why THREE.Object3D.DefaultUp might be useful for you.

In case you need to change the axis at runtime you could also create a new global Vector3 you overwrite the up property on each object you want to change dynamically (propbally all objects in the scene). Only if the up vector is purposed to be equal on all objects.

If you don’t have too much objects you could also simply traverse the scene and set the up axis on each object of the baseclass Object3D. (object3d, mesh, light, camera etc.)

i tried:
if (axis.axisUp === “z_positive”) {
scene.traverse(function (child) {
child.up.set(0.0, 0.0, 0.1);
});
}

it seems like it changes the vector to Vector3 {x: 0, y: 0, z: 0.1} but nothing changes visually. i expect the model to change.

Your camera get’s this up vector too, so nothing changes visially, but the coordinate system. If you want the camera to stay default skip cameras on the traversal.

so when i specify child.up.set this is setting the camera up position too? i thought it would only set up.

how can i skip it?

when i do scene.rotation.x = -90 * Math.PI/180; it is visually showing be the change.

im sure with the child.up.set code you provided i should not only see the coordinate change but also visually because currently my model has y up so if i run the rotate function on my model it should change the z up therefore there should be some visual changes too.

That’s why i asked what you want to archive exactly, it sounded like you only want to change the coordinate system from Y up to Z up.