Hi.
I’m trying to make some scanning light effect, which a group of light line moves across the Y axis and lights up the center object. My code is like this:
const scanLight1 = new SpotLight('scanner1', new Vector3(0, 1, 20), new Vector3(0, 0, -1), toRad(15), 0, scene);
scanLight1.projectionTexture = new Texture('./static/lightmask.png', scene);
// and I made about 6 spotlights like this
const scannerGroup = new Mesh('scannerGroup');
scanLight1.parent = scannerGroup;
let scannerDirection: 1 | -1 = 1;
scene.onBeforeRenderObservable.add((scene, state) => {
scannerGroup.position.y += 0.05 * scannerDirection;
for (const child of scannerGroup.getChildren()) {
child as SpotLight;
}
if (scannerGroup.position.y > 5) {
scannerDirection = -1;
} else if (scannerGroup.position.y < 0) {
scannerDirection = 1;
}
});
engine.runRenderLoop(() => {
scene.render();
});
The texture is a 1024*1024 black image with a single green line at it’s center.
Then I can see the lights are moving as intended, but the texture remains at it’s initial position(green line at y:1).
Is there any way to make the texture move with the light?