Set scene dimensions?

Hey,

i have the following example:
https://www.babylonjs-playground.com/#28YUR5#672

When i click the button, i want a mesh to basically follow my cursor until i click somewhere.

However the scene seems to be too small. The cylinder just becomes visible when i move it near another object. So the scene seems to have approximately the size to wrap the displayed objects.
I’d like to set the dimensions of the scene to the whole screen, so i could move my cursor anywhere.

Is it possible to somehow extend the scene dimensions to maximum size?

Thanks alot!

Hey!

the scene has no size per se :slight_smile: You can move the camera to see a bigger part of it. But technically scene has no limit. It is just the virtual container of meshes + a point of view (the camera)

1 Like

Thanks alot for the fast answer :slight_smile:

Well, that makes sense.
The problem seems to be within the scene.pick method then?
I tried logging the position inside the onPointerMove function and when my cursor is far away from the existing objects, “console.log(scene.pick(scene.pointerX, scene.pointerY, null, null).pickedPoint);” will always log “null”. When my cursor is close the existing objects, then coordinates will be printed out.

Is there a way to always get the mouse position, no matter where it is on the screen? I’m kind of confused why it would give me null when its further away.

The mouse coordinates are always available in scene.pointerX and scene.pointerY.

scene.pick is for picking: if there’s no mesh under the mouse you won’t have any pickedPoint.

2 Likes

See https://doc.babylonjs.com/api/classes/babylon.scene#pick

1 Like

Thanks alot. I’ll look into transforming the screen coordinates to the world coordinates tomorrow then :slight_smile:

Instead of attaching the mesh to the mouse, i ended up using the PointerDragBehavior.
I realized its more suitable for my needs and runs super smooth and nice:
https://tarrew.gitlab.io/masterprojekt/

Thanks alot again!