BLUE
PHP 7.4.33
Path:
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/helpers
Run
Logout
Edit File
Size: 3.57 KB
Close
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/helpers/DirectionalLightHelper.js
Text
Base64
import { Vector3 } from '../math/Vector3.js'; import { Object3D } from '../core/Object3D.js'; import { Line } from '../objects/Line.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; const _v1 = /*@__PURE__*/ new Vector3(); const _v2 = /*@__PURE__*/ new Vector3(); const _v3 = /*@__PURE__*/ new Vector3(); /** * Helper object to assist with visualizing a {@link DirectionalLight}'s * effect on the scene. This consists of plane and a line representing the * light's position and direction. * * ```js * const light = new THREE.DirectionalLight( 0xFFFFFF ); * scene.add( light ); * * const helper = new THREE.DirectionalLightHelper( light, 5 ); * scene.add( helper ); * ``` * * @augments Object3D */ class DirectionalLightHelper extends Object3D { /** * Constructs a new directional light helper. * * @param {DirectionalLight} light - The light to be visualized. * @param {number} [size=1] - The dimensions of the plane. * @param {number|Color|string} [color] - The helper's color. If not set, the helper will take * the color of the light. */ constructor( light, size, color ) { super(); /** * The light being visualized. * * @type {DirectionalLight} */ this.light = light; this.matrix = light.matrixWorld; this.matrixAutoUpdate = false; /** * The color parameter passed in the constructor. * If not set, the helper will take the color of the light. * * @type {number|Color|string} */ this.color = color; this.type = 'DirectionalLightHelper'; if ( size === undefined ) size = 1; let geometry = new BufferGeometry(); geometry.setAttribute( 'position', new Float32BufferAttribute( [ - size, size, 0, size, size, 0, size, - size, 0, - size, - size, 0, - size, size, 0 ], 3 ) ); const material = new LineBasicMaterial( { fog: false, toneMapped: false } ); /** * Contains the line showing the location of the directional light. * * @type {Line} */ this.lightPlane = new Line( geometry, material ); this.add( this.lightPlane ); geometry = new BufferGeometry(); geometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); /** * Represents the target line of the directional light. * * @type {Line} */ this.targetLine = new Line( geometry, material ); this.add( this.targetLine ); this.update(); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever this instance is no longer used in your app. */ dispose() { this.lightPlane.geometry.dispose(); this.lightPlane.material.dispose(); this.targetLine.geometry.dispose(); this.targetLine.material.dispose(); } /** * Updates the helper to match the position and direction of the * light being visualized. */ update() { this.light.updateWorldMatrix( true, false ); this.light.target.updateWorldMatrix( true, false ); _v1.setFromMatrixPosition( this.light.matrixWorld ); _v2.setFromMatrixPosition( this.light.target.matrixWorld ); _v3.subVectors( _v2, _v1 ); this.lightPlane.lookAt( _v2 ); if ( this.color !== undefined ) { this.lightPlane.material.color.set( this.color ); this.targetLine.material.color.set( this.color ); } else { this.lightPlane.material.color.copy( this.light.color ); this.targetLine.material.color.copy( this.light.color ); } this.targetLine.lookAt( _v2 ); this.targetLine.scale.z = _v3.length(); } } export { DirectionalLightHelper };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 13
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArrowHelper.js
4.35 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
AxesHelper.js
2.29 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Box3Helper.js
1.94 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
BoxHelper.js
3.68 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CameraHelper.js
9.52 KB
lrw-r--r--
2025-03-28 11:04:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DirectionalLightHelper.js
3.57 KB
lrw-r--r--
2025-03-28 11:04:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
GridHelper.js
2.21 KB
lrw-r--r--
2025-03-28 11:04:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
HemisphereLightHelper.js
3.10 KB
lrw-r--r--
2025-03-28 11:04:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PlaneHelper.js
2.45 KB
lrw-r--r--
2025-03-28 11:04:39
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PointLightHelper.js
2.89 KB
lrw-r--r--
2025-03-28 11:04:39
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PolarGridHelper.js
3.19 KB
lrw-r--r--
2025-03-28 11:04:39
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SkeletonHelper.js
3.62 KB
lrw-r--r--
2025-03-28 11:04:39
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SpotLightHelper.js
3.35 KB
lrw-r--r--
2025-03-28 11:04:39
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).