25c Flashlight effect three.js

Опубликовано: 17 Май 2025
на канале: flanniganable
1,596
like

Learn how to make a flashlight effect in three.js using PointerLockControls and SpotLight. Learn how to make a switch to turn the flashlight on and off. Learn how to make objects child of a parent object.

Timestamps:
00:00 Intro/demo
00:16 How to make objects children of a parent object
02:03 Import PointerLockControls.js & use key controls from three.js PointerLockControls example
02:21 Add camera to the scene three.js
02:26 Create PointerLockControls three.js
02:34 Create SpotLight three.js
03:19 Add SpotLIght & SpotLight target as children of camera three.js
03:56 How to make on/off switch for flashlight three.js

Resources:
PointerLockControls example three.js:
https://threejs.org/examples/?q=point...

PointerLockControls.js file @ GitHub:
https://raw.githubusercontent.com/mrd...

SpotLight three.js doc:
https://threejs.org/docs/?q=spotlight...

Credits:
Creeper model
source: https://sketchfab.com/3d-models/minec...
author: Vincent Yanez (https://sketchfab.com/vinceyanez)