Question

I'm wondering why do you need full Object3D as a target instead of just Vector3? It seems to me that the role of the target is just setting up a direction of the cone. Can Object3D bring some more manipulation magic to the SpotLight than a raw Vector3?

Était-ce utile?

La solution

Because shadow mapping needs that as reference for its frustum. However, I'm pending to remove that and using a distance property in the light instead.

Autres conseils

Spot light has position, direction vector, color, intensity, angle, fall-off. Those are just used for calculations within shader to determine how much is some fragment lit.

It probably doesn't do any special magic, it's just that Object3D class has it's attribute .target, and both Mesh and SpotLight classes (that actually inherit Object3D) use this attribute but for different calculations and in a bit different way. Target attribute is used also for lookAt matrix for Meshes, and for SpotLights, you can calculate direction vector by doing:

vec3 dir = targeted_3d.position - spot_light.position;

It's about re-using the attribute that has been inherited, and giving it slightly different usage for child-classes.

Hope this helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top