Want to keep lights fixed while rotating the ground

My scene has a single mesh, a standard ground. I’m using an ArcRotateCamera and have a couple spotlights. When I free rotate the camera around the ground, the lights move with the ground. But I want the lights to stay fixed in their original position, in relation to the HTML canvas viewport. I suppose that what I’m asking for is nonsensical, do I need to use a plane instead of a ground object?

Thanks so much for any help!

Hi @CrowAndSky
The ArcRotateCamera is moving/rotating, not the ground or lights :slight_smile:

@aWeirdo,

That sure makes sense, when giving it a moment’s thought. It seemed that the ArcRotate is the type of camera that I wanted in this case. I just have PBR materials applied to the ground mesh with a couple of cameras. I want the ground to stay centered while I animate it. By the lights staying fixed and the ground moving, the play of the changing highlights and shadows will demonstrate the rich PBR texture.
I tried attaching the camera to the ground, instead of the scene, like this:

const ground = BABYLON.MeshBuilder.CreateGround(“ground”, {width: 2, height: 2, subdivsions: 0}, scene1)

const camera = new BABYLON.ArcRotateCamera(“camera”, Math.PI / 2, 0, 2, new BABYLON.Vector3(0, 0, 0), ground)

But that threw an exception. Is there an abstracted method to attach the mouse movements to the ground position, instead of the camera position?

Thanks so much for your super fast feedback. This community really is amazing!

My best,
Preston

@CrowAndSky
With a bit of picking and stuff, this rotates ground on Y axis (recording mouse movement on X axis only)
https://playground.babylonjs.com/#QFRJ7K#14

This one works without picking and just assumes ground is to be rotated, (now we can also rotate if our initial click doesn’t hit the ground mesh)
https://playground.babylonjs.com/#QFRJ7K#15

I hope it helped, Have a nice day :slight_smile:

2 Likes