codecamp

three.js DirectionalLightHelper

用于模拟场景中平行光 DirectionalLight 的辅助对象. 其中包含了表示光位置的平面和表示光方向的线段.

代码示例

const light = new THREE.DirectionalLight( 0xFFFFFF );
const helper = new THREE.DirectionalLightHelper( light, 5 );
scene.add( helper );

构造函数

DirectionalLightHelper( light : DirectionalLight, size : Number, color : Hex )

light-- 被模拟的光源.

size -- (可选的) 平面的尺寸. 默认为 1.

color -- (可选的) 如果没有设置颜色将使用光源的颜色.

属性

请到基类 Object3D 页面查看公共属性.

.lightPlane : Line

包含表示平行光方向的线网格.

.light : DirectionalLight

被模拟的光源. 请参考 directionalLight .

.matrix : Object

请参考光源的世界矩阵 matrixWorld.

.matrixAutoUpdate : Object

请查看 Object3D.matrixAutoUpdate 页面. 这里设置为 false 表示辅助对象 使用光源的 matrixWorld.

.color : hex

构造函数中传入的颜色值. 默认为 undefined. 如果改变该值, 辅助对象的颜色将在下一次 update 被调用时更新.

方法

请到基类 Object3D 页面查看公共方法.

.dispose () : undefined

销毁该平行光辅助对象.

.update () : undefined

更新辅助对象,与模拟的 directionalLight 光源的位置和方向保持一致.

源码

src/helpers/DirectionalLightHelper.js


three.js CameraHelper
three.js GridHelper
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

参考

核心 / BufferAttributes

渲染器 / WebXR

开发者参考

WebGL渲染器

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }