本文へスキップ

ライト

説明

このコンポーネントは、実体を発光させる。

プロパティ

プロパティタイプデフォルト説明
typestring''Allowed values: 'directional', 'point', 'ambient', 'spot', 'area'
castShadowbooleantrueIf the light source should cast shadows
intensitynumber0.5The light's intensity, or strength
rnumber255The amount of red the light emits. A value between 0 and 255.
gnumber255The amount of green the light emits. A value between 0 and 255.
bnumber255The amount of blue the light emits. A value between 0 and 255.
colorMapstring''The color map source
shadowBiasnumber-0.005How much to add or subtract from the normalized depth when deciding whether a surface is in shadow
shadowNormalBiasnumber0How much the position used to query the shadow map is offset along the object normal
shadowRadiusnumber1The radius of the shadow
shadowAutoUpdatebooleantrueShould the shadow be automatically calculated and updated
shadowBlurSamplesnumber8The amount of samples to use when calculating the Virtual Shadow Map
shadowMapSizeHeightnumber1024The height of the Shadow Map. Values must be powers of 2.
shadowMapSizeWidthnumber1024The width of the Shadow Map. Values must be powers of 2.
shadowCameraNearnumber0.5Camera frustum near-pane for calculating shadows
shadowCameraFarnumber200Camera frustum far-pane for calculating shadows
shadowCameraLeftnumber-50Camera frustum left-pane for calculating shadows
shadowCameraRightnumber50Camera frustum right-pane for calculating shadows
shadowCameraBottomnumber-50Camera frustum bottom-pane for calculating shadows
shadowCameraTopnumber50Camera frustum top-pane for calculating shadows
targetXnumber0The target X coordinate of the light (Directional only)
targetYnumber0The target Y coordinate of the light (Directional only)
targetZnumber0The target Z coordinate of the light (Directional only)
widthnumber10Width of the light source (Area only)
heightnumber10Height of the light source (Area only)
penumbranumber0Percent of the spotlight cone that is attenuated due to penumbra. Accepted values between 0 and 1. (Spot only)
decaynumber2The amount the light dims along the distance of the light
anglenumberMath.PI / 3Maximum extent of the spotlight, in radians, from its direction. Should be no more than Math.PI / 2.
followCamerabooleantrueWhether the light should follow where the camera is moving (Directional only)
distancenumber0When distance is zero, light will attenuate according to inverse-square law to infinite distance. When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff, where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not physically correct.

機能

Get

Returns a read-only reference.

Example

ecs.Light.get(world, component.eid)

Set

Ensures the component exists on the entity, then assigns the (optional) data to the component.

Example

ecs.Light.set(world, component.eid, {
type: 'directional',
castShadow: true,
intensity: 0.5,
r: 255,
g: 255,
b: 255,
shadowBias: -0.005,
shadowNormalBias: 0,
shadowRadius: 1,
shadowAutoUpdate: true,
shadowBlurSamples: 8,
shadowMapSizeHeight: 1024,
shadowMapSizeWidth: 1024,
shadowCameraNear: 0.5,
shadowCameraFar: 200,
shadowCameraLeft: -50,
shadowCameraRight: 50,
shadowCameraBottom: -50,
shadowCameraTop: 50,
targetX: 0,
targetY: 0,
targetZ: 0
})

Mutate

Perform an update to the component within a callback function. Return true to indicate no changes made.

Example

ecs.Light.mutate(world, component.eid, (cursor) => {
cursor.intensity = 1.0;
cursor.castShadow = false;
return false;
})

Remove

Removes the component from the entity.

Example

ecs.Light.remove(world, component.eid)

Has

Returns true if the component is present on the entity.

Example

ecs.Light.has(world, component.eid)

Reset

Adds, or resets the component to its default state.

Example

ecs.Light.reset(world, component.eid)

Advanced Functions

Cursor

Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.

Example
ecs.Light.cursor(world, component.eid)

Acquire

Same behavior as cursor, but commit must be called after the cursor is done being used.

Example
ecs.Light.acquire(world, component.eid)

Commit

Called after acquire. An optional third argument determines whether the cursor was mutated or not.

Example
ecs.Light.commit(world, component.eid)
ecs.Light.commit(world, component.eid, false)

Dirty

Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.

Example
ecs.Light.dirty(world, component.eid)