Lights for car headlight

Hi all. Which lights work best for a car headlights I have created a basic scene where a truck travels on a road… i am struggling in creating lights for headlights… I have tried recArealights … Pointlight and spotlight

Pointlight and spotlight fail… because they don’t point to the new target you set instead they end up pointing to the origin. so you end up with lights pointing in the correct direction before the origin and pointing backwards after the origin

1 Like

This is a problem in your code since you can change the target for SpotLight. Check out SpotLight.target. In any event, using an instance of SpotLight seems the right approach. Ideal for stuff like headlights or flashlights.

BTW: A PointLight is omnidirectional and has no target.

2 Likes

A spotlight basic example in the collection:

https://hofk.de/main/discourse.threejs/2018/index2018.html there https://hofk.de/main/discourse.threejs/2018/Spotlight/Spotlight.html

see target at line 42

3 Likes

Made it now just for fun :slight_smile:
https://codepen.io/prisoner849/full/RwbjwgZHeadlights

5 Likes

Using SpotLight.target is a bit hard… But if you attach the light target to the car as a sibling to the light, the light will point at the local position, following the motion of the car.

I did it in eliashasle.github.io/tunnel.html (Be careful with cloning SpotLight, though! https://github.com/mrdoob/three.js/issues/17299 (even though I do it in that example))

1 Like

That is a nice collection! :+1: Almost all of them seem to work too. I only miss a reference to the original context/question where each example is posted. I think that would be useful.

1 Like

To read there Collection of examples from discourse.threejs.org :


You can try them out immediately and use Ctrl U to view the code.
The source code contains the links and the author.

In addition, extended examples ar aviable.


For example:

line 2: Direction of the SpotLightHelper
line 3: https://jsfiddle.net/f2Lommf5/15490/

Spotlight


The effort for this collection must be kept within limits for me, therefore the simple sequential arrangement. :slightly_smiling_face:

49

Combined with this

Addon to create special / extended geometries
https://hofk.de/main/discourse.threejs/2019/RoadRace/RoadRace.

that makes a great race! :red_car: :taxi: :police_car: :blue_car:

OK. Then I think that should be stated on the page too. :+1:

On the selection page per year it also says.
en/de
22

As you can see in the index file, I only copy one schema there.

31

As I wrote, I must absolutely minimize the effort for me. There is still enough work to view all contributions and copy the examples.
That’s why there are some basic examples in the extended ones as well. Copying it was too complex for me for various reasons.
Extended ones are only links. Whether they will work forever is open.

With the copies of the basic examples are perhaps only some resources later no longer available.
I only copy HTML, CSS and JS, replace important external scripts like three.js OrbitControls … by the ones on my server with the appropriate version (which is static then!) and paste

// @author … in the main script.

Enough work.

30

The example page itself is usually not changed in the layout. Who only looks at it does not need a source, who has interest looks into the source text and finds all information.

Because my English is so weak:
Translated with www.DeepL.com/Translator

1 Like

No worries. I understand that your time is valuable, and that I cannot dictate how you should spend it. I appreciate the collection of the examples, and now also see that you have provided references to the original context, although “hidden” in the sources.

2 Likes