[done] How to rotate GridHelper?

Hi,

After exporting a scene in Blender with +YUp turned off and import it in threeJs I found out that everything seems to work with +ZUp in threeJs, which is exactly what I want.

However, now I try to use the GridHelper and it is rotated, but the rotation.set() or changing its x/y/z rotation values doesn’t work for some weird reason, eventhough it’s an Object3D. Also rotateOnWorldAxis() doesn’t work.

Why do rotations not work on the GridHelper? Why is everything so far adjusting to the +ZUp, but the GridHelper is not? How can we rotate the GridHelper?

1 Like

hi @Friksel
of course you can rotate the grid helper as every 3D object :

(in your init)

const size = 10;
const divisions = 10;
const gridHelper = new THREE.GridHelper( size, divisions );
gridHelper.rotation.x=Math.PI/2;
scene.add( gridHelper );

it rotates the grid 90 degree on x axis, according your Zup model.
( if it doesn’t work please upload a code sample to see your error)

But I think there are a lot of problems in your Zup choise… threejs standard axis world is Yup in some useful components (like orbitControl).
There is a possibility that in your current project you don’t need it, but pealse avaluate, in order to reuse you code, to export your blender scene with Yup according threejs standards.
I think you will be happier in the future :sweat_smile:

edit:
of course you can change the axes in all you want, but there is some extra work … is it really important?

1 Like

Hi @alessandro_guarino thanks for your response. As written in the opening post, rotation is not working on gridHelper here.

About axis: I’m not new to threejs. Using it for years now.
It’s frustrating to need to convert coordinates, rotations and camera’s in my head all the time when moving back and forth. I’m tired of it. So I wanted to sync up blender and threejs. Which in the end seemed easy by just switching off +Y up in the blender exporter.

I’m all for using standards, but the problem is there are no standards in the 3D industry. It’s making things overly complicated where it doesn’t need to be. That’s no problem when doing just a little move here and there, but when constantly animating, moving camera’s around, rotating things, working responsive and fit objects it’s getting complicated and frustrating to work with soon and prone to errors.

Working with +Z up has solved all this. If that means some parts of threejs don’t adapt to +Z up where others do than IMO it only means that threejs is in conflict with itself. But still to me that’s better than to have a frustrating workflow 100% of the time.

That said; the fact that the Gridhelper doesn’t rotate here doesn’t have anything to do with +Z being up. Or at least it wouldn’t make sense to me. It should always rotate on some axis. But it doesn’t here for some strange reason.

@Friksel Any chance to provide a small live code example, that demonstrates the issue? If possible.

Hi @Friksel
sorry if I gave you the impression that I consider you a novice, you are probably more experienced than me.
The code I posted works, I tried it before pasting it.
As @prisoner849 asked too, provide a working sample, in order to find the problem.
if I can’t fix it, someone more experienced than me will do (and prisoner849 it is, so take advantage of his availability ).

Yup has always been a feature of the library, where do you see threejs in conflict with itself?
I too usually think with the Zup (I’m a Blender and 3dmax user) but I think it is easier to make the effort to think of the Z in the manner of threejs than to have to write a lot more code (my opinion) .

@alessandro_guarino looks like you’re reading more into my post than there is.
I have nothing against threejs and don’t say it’s conflicting itself.

If both you and presoner849 say you tested the Gridhelper to be able to rotate with just rotate, also when Z is up and you imported the scene from Blender with +Y up turned off via gltf, than I probably made a mistake somewhere.

It’s hard to believe tho, as adding the grid helper is only 3 lines of code. Nothing fancy about it.

[edit] Just right now did a quick test in a new project with +Z up (coming from an imported gltf file) and added gridhelper. Now I could just rotate it without an issue. Not sure what was up in the other project earlier, but looks like I did something wrong. Can’t look it up, because I moved on on that project and got rid of the grid there.

Sorry for the inconvenience. We can argue about wether or not the grid should be a ground plane per default, wether or not +Y is up or +Z is up (which is not the case right now), but its rotation is working fine and it’s easy to fix. So fine for me.

Thanks for your responses!

2 Likes

@Friksel
I ask for an example not because I like to make people suffer, when they create something useless to please me.
From my experience, usually whilst the making of an example, I can find the line in my DNA, with the error, that causes problems :sweat_smile:
Good to know, that you managed your issue with rotation of GridHelper :beers: :+1: