123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792 |
- import { __decorate } from "../tslib.es6.js";
- import { serialize, serializeAsColor3, expandToProperty } from "../Misc/decorators.js";
- import { Vector3 } from "../Maths/math.vector.js";
- import { Color3, TmpColors } from "../Maths/math.color.js";
- import { Node } from "../node.js";
- import { UniformBuffer } from "../Materials/uniformBuffer.js";
- import { GetClass } from "../Misc/typeStore.js";
- import { LightConstants } from "./lightConstants.js";
- import { SerializationHelper } from "../Misc/decorators.serialization.js";
- /**
- * Base class of all the lights in Babylon. It groups all the generic information about lights.
- * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
- * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
- */
- export class Light extends Node {
- /**
- * Defines how far from the source the light is impacting in scene units.
- * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
- */
- get range() {
- return this._range;
- }
- /**
- * Defines how far from the source the light is impacting in scene units.
- * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
- */
- set range(value) {
- this._range = value;
- this._inverseSquaredRange = 1.0 / (this.range * this.range);
- }
- /**
- * Gets the photometric scale used to interpret the intensity.
- * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
- */
- get intensityMode() {
- return this._intensityMode;
- }
- /**
- * Sets the photometric scale used to interpret the intensity.
- * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
- */
- set intensityMode(value) {
- this._intensityMode = value;
- this._computePhotometricScale();
- }
- /**
- * Gets the light radius used by PBR Materials to simulate soft area lights.
- */
- get radius() {
- return this._radius;
- }
- /**
- * sets the light radius used by PBR Materials to simulate soft area lights.
- */
- set radius(value) {
- this._radius = value;
- this._computePhotometricScale();
- }
- /**
- * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
- * the current shadow generator.
- */
- get shadowEnabled() {
- return this._shadowEnabled;
- }
- /**
- * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
- * the current shadow generator.
- */
- set shadowEnabled(value) {
- if (this._shadowEnabled === value) {
- return;
- }
- this._shadowEnabled = value;
- this._markMeshesAsLightDirty();
- }
- /**
- * Gets the only meshes impacted by this light.
- */
- get includedOnlyMeshes() {
- return this._includedOnlyMeshes;
- }
- /**
- * Sets the only meshes impacted by this light.
- */
- set includedOnlyMeshes(value) {
- this._includedOnlyMeshes = value;
- this._hookArrayForIncludedOnly(value);
- }
- /**
- * Gets the meshes not impacted by this light.
- */
- get excludedMeshes() {
- return this._excludedMeshes;
- }
- /**
- * Sets the meshes not impacted by this light.
- */
- set excludedMeshes(value) {
- this._excludedMeshes = value;
- this._hookArrayForExcluded(value);
- }
- /**
- * Gets the layer id use to find what meshes are not impacted by the light.
- * Inactive if 0
- */
- get excludeWithLayerMask() {
- return this._excludeWithLayerMask;
- }
- /**
- * Sets the layer id use to find what meshes are not impacted by the light.
- * Inactive if 0
- */
- set excludeWithLayerMask(value) {
- this._excludeWithLayerMask = value;
- this._resyncMeshes();
- }
- /**
- * Gets the layer id use to find what meshes are impacted by the light.
- * Inactive if 0
- */
- get includeOnlyWithLayerMask() {
- return this._includeOnlyWithLayerMask;
- }
- /**
- * Sets the layer id use to find what meshes are impacted by the light.
- * Inactive if 0
- */
- set includeOnlyWithLayerMask(value) {
- this._includeOnlyWithLayerMask = value;
- this._resyncMeshes();
- }
- /**
- * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
- */
- get lightmapMode() {
- return this._lightmapMode;
- }
- /**
- * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
- */
- set lightmapMode(value) {
- if (this._lightmapMode === value) {
- return;
- }
- this._lightmapMode = value;
- this._markMeshesAsLightDirty();
- }
- /**
- * Returns the view matrix.
- * @param _faceIndex The index of the face for which we want to extract the view matrix. Only used for point light types.
- * @returns The view matrix. Can be null, if a view matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).
- */
- getViewMatrix(_faceIndex) {
- return null;
- }
- /**
- * Returns the projection matrix.
- * Note that viewMatrix and renderList are optional and are only used by lights that calculate the projection matrix from a list of meshes (e.g. directional lights with automatic extents calculation).
- * @param _viewMatrix The view transform matrix of the light (optional).
- * @param _renderList The list of meshes to take into account when calculating the projection matrix (optional).
- * @returns The projection matrix. Can be null, if a projection matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).
- */
- getProjectionMatrix(_viewMatrix, _renderList) {
- return null;
- }
- /**
- * Creates a Light object in the scene.
- * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction
- * @param name The friendly name of the light
- * @param scene The scene the light belongs too
- */
- constructor(name, scene) {
- super(name, scene);
- /**
- * Diffuse gives the basic color to an object.
- */
- this.diffuse = new Color3(1.0, 1.0, 1.0);
- /**
- * Specular produces a highlight color on an object.
- * Note: This is not affecting PBR materials.
- */
- this.specular = new Color3(1.0, 1.0, 1.0);
- /**
- * Defines the falloff type for this light. This lets overriding how punctual light are
- * falling off base on range or angle.
- * This can be set to any values in Light.FALLOFF_x.
- *
- * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
- * other types of materials.
- */
- this.falloffType = Light.FALLOFF_DEFAULT;
- /**
- * Strength of the light.
- * Note: By default it is define in the framework own unit.
- * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
- */
- this.intensity = 1.0;
- this._range = Number.MAX_VALUE;
- this._inverseSquaredRange = 0;
- /**
- * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
- * of light.
- */
- this._photometricScale = 1.0;
- this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
- this._radius = 0.00001;
- /**
- * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
- * exceeding the number allowed of the materials.
- */
- this.renderPriority = 0;
- this._shadowEnabled = true;
- this._excludeWithLayerMask = 0;
- this._includeOnlyWithLayerMask = 0;
- this._lightmapMode = 0;
- /**
- * Shadow generators associated to the light.
- * @internal Internal use only.
- */
- this._shadowGenerators = null;
- /**
- * @internal Internal use only.
- */
- this._excludedMeshesIds = new Array();
- /**
- * @internal Internal use only.
- */
- this._includedOnlyMeshesIds = new Array();
- /** @internal */
- this._isLight = true;
- this.getScene().addLight(this);
- this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);
- this._buildUniformLayout();
- this.includedOnlyMeshes = [];
- this.excludedMeshes = [];
- this._resyncMeshes();
- }
- /**
- * Sets the passed Effect "effect" with the Light textures.
- * @param effect The effect to update
- * @param lightIndex The index of the light in the effect to update
- * @returns The light
- */
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- transferTexturesToEffect(effect, lightIndex) {
- // Do nothing by default.
- return this;
- }
- /**
- * Binds the lights information from the scene to the effect for the given mesh.
- * @param lightIndex Light index
- * @param scene The scene where the light belongs to
- * @param effect The effect we are binding the data to
- * @param useSpecular Defines if specular is supported
- * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows
- */
- _bindLight(lightIndex, scene, effect, useSpecular, receiveShadows = true) {
- const iAsString = lightIndex.toString();
- let needUpdate = false;
- this._uniformBuffer.bindToEffect(effect, "Light" + iAsString);
- if (this._renderId !== scene.getRenderId() || this._lastUseSpecular !== useSpecular || !this._uniformBuffer.useUbo) {
- this._renderId = scene.getRenderId();
- this._lastUseSpecular = useSpecular;
- const scaledIntensity = this.getScaledIntensity();
- this.transferToEffect(effect, iAsString);
- this.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);
- this._uniformBuffer.updateColor4("vLightDiffuse", TmpColors.Color3[0], this.range, iAsString);
- if (useSpecular) {
- this.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);
- this._uniformBuffer.updateColor4("vLightSpecular", TmpColors.Color3[1], this.radius, iAsString);
- }
- needUpdate = true;
- }
- // Textures might still need to be rebound.
- this.transferTexturesToEffect(effect, iAsString);
- // Shadows
- if (scene.shadowsEnabled && this.shadowEnabled && receiveShadows) {
- const shadowGenerator = this.getShadowGenerator(scene.activeCamera) ?? this.getShadowGenerator();
- if (shadowGenerator) {
- shadowGenerator.bindShadowLight(iAsString, effect);
- needUpdate = true;
- }
- }
- if (needUpdate) {
- this._uniformBuffer.update();
- }
- else {
- this._uniformBuffer.bindUniformBuffer();
- }
- }
- /**
- * Returns the string "Light".
- * @returns the class name
- */
- getClassName() {
- return "Light";
- }
- /**
- * Converts the light information to a readable string for debug purpose.
- * @param fullDetails Supports for multiple levels of logging within scene loading
- * @returns the human readable light info
- */
- toString(fullDetails) {
- let ret = "Name: " + this.name;
- ret += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()];
- if (this.animations) {
- for (let i = 0; i < this.animations.length; i++) {
- ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
- }
- }
- return ret;
- }
- /** @internal */
- _syncParentEnabledState() {
- super._syncParentEnabledState();
- if (!this.isDisposed()) {
- this._resyncMeshes();
- }
- }
- /**
- * Set the enabled state of this node.
- * @param value - the new enabled state
- */
- setEnabled(value) {
- super.setEnabled(value);
- this._resyncMeshes();
- }
- /**
- * Returns the Light associated shadow generator if any.
- * @param camera Camera for which the shadow generator should be retrieved (default: null). If null, retrieves the default shadow generator
- * @returns the associated shadow generator.
- */
- getShadowGenerator(camera = null) {
- if (this._shadowGenerators === null) {
- return null;
- }
- return this._shadowGenerators.get(camera) ?? null;
- }
- /**
- * Returns all the shadow generators associated to this light
- * @returns
- */
- getShadowGenerators() {
- return this._shadowGenerators;
- }
- /**
- * Returns a Vector3, the absolute light position in the World.
- * @returns the world space position of the light
- */
- getAbsolutePosition() {
- return Vector3.Zero();
- }
- /**
- * Specifies if the light will affect the passed mesh.
- * @param mesh The mesh to test against the light
- * @returns true the mesh is affected otherwise, false.
- */
- canAffectMesh(mesh) {
- if (!mesh) {
- return true;
- }
- if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
- return false;
- }
- if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
- return false;
- }
- if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
- return false;
- }
- if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
- return false;
- }
- return true;
- }
- /**
- * Releases resources associated with this node.
- * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
- * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
- */
- dispose(doNotRecurse, disposeMaterialAndTextures = false) {
- if (this._shadowGenerators) {
- const iterator = this._shadowGenerators.values();
- for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
- const shadowGenerator = key.value;
- shadowGenerator.dispose();
- }
- this._shadowGenerators = null;
- }
- // Animations
- this.getScene().stopAnimation(this);
- if (this._parentContainer) {
- const index = this._parentContainer.lights.indexOf(this);
- if (index > -1) {
- this._parentContainer.lights.splice(index, 1);
- }
- this._parentContainer = null;
- }
- // Remove from meshes
- for (const mesh of this.getScene().meshes) {
- mesh._removeLightSource(this, true);
- }
- this._uniformBuffer.dispose();
- // Remove from scene
- this.getScene().removeLight(this);
- super.dispose(doNotRecurse, disposeMaterialAndTextures);
- }
- /**
- * Returns the light type ID (integer).
- * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
- */
- getTypeID() {
- return 0;
- }
- /**
- * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
- * @returns the scaled intensity in intensity mode unit
- */
- getScaledIntensity() {
- return this._photometricScale * this.intensity;
- }
- /**
- * Returns a new Light object, named "name", from the current one.
- * @param name The name of the cloned light
- * @param newParent The parent of this light, if it has one
- * @returns the new created light
- */
- clone(name, newParent = null) {
- const constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
- if (!constructor) {
- return null;
- }
- const clonedLight = SerializationHelper.Clone(constructor, this);
- if (name) {
- clonedLight.name = name;
- }
- if (newParent) {
- clonedLight.parent = newParent;
- }
- clonedLight.setEnabled(this.isEnabled());
- this.onClonedObservable.notifyObservers(clonedLight);
- return clonedLight;
- }
- /**
- * Serializes the current light into a Serialization object.
- * @returns the serialized object.
- */
- serialize() {
- const serializationObject = SerializationHelper.Serialize(this);
- serializationObject.uniqueId = this.uniqueId;
- // Type
- serializationObject.type = this.getTypeID();
- // Parent
- if (this.parent) {
- this.parent._serializeAsParent(serializationObject);
- }
- // Inclusion / exclusions
- if (this.excludedMeshes.length > 0) {
- serializationObject.excludedMeshesIds = [];
- this.excludedMeshes.forEach((mesh) => {
- serializationObject.excludedMeshesIds.push(mesh.id);
- });
- }
- if (this.includedOnlyMeshes.length > 0) {
- serializationObject.includedOnlyMeshesIds = [];
- this.includedOnlyMeshes.forEach((mesh) => {
- serializationObject.includedOnlyMeshesIds.push(mesh.id);
- });
- }
- // Animations
- SerializationHelper.AppendSerializedAnimations(this, serializationObject);
- serializationObject.ranges = this.serializeAnimationRanges();
- serializationObject.isEnabled = this.isEnabled();
- return serializationObject;
- }
- /**
- * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
- * This new light is named "name" and added to the passed scene.
- * @param type Type according to the types available in Light.LIGHTTYPEID_x
- * @param name The friendly name of the light
- * @param scene The scene the new light will belong to
- * @returns the constructor function
- */
- static GetConstructorFromName(type, name, scene) {
- const constructorFunc = Node.Construct("Light_Type_" + type, name, scene);
- if (constructorFunc) {
- return constructorFunc;
- }
- // Default to no light for none present once.
- return null;
- }
- /**
- * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
- * @param parsedLight The JSON representation of the light
- * @param scene The scene to create the parsed light in
- * @returns the created light after parsing
- */
- static Parse(parsedLight, scene) {
- const constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
- if (!constructor) {
- return null;
- }
- const light = SerializationHelper.Parse(constructor, parsedLight, scene);
- // Inclusion / exclusions
- if (parsedLight.excludedMeshesIds) {
- light._excludedMeshesIds = parsedLight.excludedMeshesIds;
- }
- if (parsedLight.includedOnlyMeshesIds) {
- light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
- }
- // Parent
- if (parsedLight.parentId !== undefined) {
- light._waitingParentId = parsedLight.parentId;
- }
- if (parsedLight.parentInstanceIndex !== undefined) {
- light._waitingParentInstanceIndex = parsedLight.parentInstanceIndex;
- }
- // Falloff
- if (parsedLight.falloffType !== undefined) {
- light.falloffType = parsedLight.falloffType;
- }
- // Lightmaps
- if (parsedLight.lightmapMode !== undefined) {
- light.lightmapMode = parsedLight.lightmapMode;
- }
- // Animations
- if (parsedLight.animations) {
- for (let animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
- const parsedAnimation = parsedLight.animations[animationIndex];
- const internalClass = GetClass("BABYLON.Animation");
- if (internalClass) {
- light.animations.push(internalClass.Parse(parsedAnimation));
- }
- }
- Node.ParseAnimationRanges(light, parsedLight, scene);
- }
- if (parsedLight.autoAnimate) {
- scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
- }
- // Check if isEnabled is defined to be back compatible with prior serialized versions.
- if (parsedLight.isEnabled !== undefined) {
- light.setEnabled(parsedLight.isEnabled);
- }
- return light;
- }
- _hookArrayForExcluded(array) {
- const oldPush = array.push;
- array.push = (...items) => {
- const result = oldPush.apply(array, items);
- for (const item of items) {
- item._resyncLightSource(this);
- }
- return result;
- };
- const oldSplice = array.splice;
- array.splice = (index, deleteCount) => {
- const deleted = oldSplice.apply(array, [index, deleteCount]);
- for (const item of deleted) {
- item._resyncLightSource(this);
- }
- return deleted;
- };
- for (const item of array) {
- item._resyncLightSource(this);
- }
- }
- _hookArrayForIncludedOnly(array) {
- const oldPush = array.push;
- array.push = (...items) => {
- const result = oldPush.apply(array, items);
- this._resyncMeshes();
- return result;
- };
- const oldSplice = array.splice;
- array.splice = (index, deleteCount) => {
- const deleted = oldSplice.apply(array, [index, deleteCount]);
- this._resyncMeshes();
- return deleted;
- };
- this._resyncMeshes();
- }
- _resyncMeshes() {
- for (const mesh of this.getScene().meshes) {
- mesh._resyncLightSource(this);
- }
- }
- /**
- * Forces the meshes to update their light related information in their rendering used effects
- * @internal Internal Use Only
- */
- _markMeshesAsLightDirty() {
- for (const mesh of this.getScene().meshes) {
- if (mesh.lightSources.indexOf(this) !== -1) {
- mesh._markSubMeshesAsLightDirty();
- }
- }
- }
- /**
- * Recomputes the cached photometric scale if needed.
- */
- _computePhotometricScale() {
- this._photometricScale = this._getPhotometricScale();
- this.getScene().resetCachedMaterial();
- }
- /**
- * @returns the Photometric Scale according to the light type and intensity mode.
- */
- _getPhotometricScale() {
- let photometricScale = 0.0;
- const lightTypeID = this.getTypeID();
- //get photometric mode
- let photometricMode = this.intensityMode;
- if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
- if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
- photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
- }
- else {
- photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
- }
- }
- //compute photometric scale
- switch (lightTypeID) {
- case Light.LIGHTTYPEID_POINTLIGHT:
- case Light.LIGHTTYPEID_SPOTLIGHT:
- switch (photometricMode) {
- case Light.INTENSITYMODE_LUMINOUSPOWER:
- photometricScale = 1.0 / (4.0 * Math.PI);
- break;
- case Light.INTENSITYMODE_LUMINOUSINTENSITY:
- photometricScale = 1.0;
- break;
- case Light.INTENSITYMODE_LUMINANCE:
- photometricScale = this.radius * this.radius;
- break;
- }
- break;
- case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
- switch (photometricMode) {
- case Light.INTENSITYMODE_ILLUMINANCE:
- photometricScale = 1.0;
- break;
- case Light.INTENSITYMODE_LUMINANCE: {
- // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
- // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
- let apexAngleRadians = this.radius;
- // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
- apexAngleRadians = Math.max(apexAngleRadians, 0.001);
- const solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
- photometricScale = solidAngle;
- break;
- }
- }
- break;
- case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
- // No fall off in hemispheric light.
- photometricScale = 1.0;
- break;
- }
- return photometricScale;
- }
- /**
- * Reorder the light in the scene according to their defined priority.
- * @internal Internal Use Only
- */
- _reorderLightsInScene() {
- const scene = this.getScene();
- if (this._renderPriority != 0) {
- scene.requireLightSorting = true;
- }
- this.getScene().sortLightsByPriority();
- }
- }
- /**
- * Falloff Default: light is falling off following the material specification:
- * standard material is using standard falloff whereas pbr material can request special falloff per materials.
- */
- Light.FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT;
- /**
- * Falloff Physical: light is falling off following the inverse squared distance law.
- */
- Light.FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL;
- /**
- * Falloff gltf: light is falling off as described in the gltf moving to PBR document
- * to enhance interoperability with other engines.
- */
- Light.FALLOFF_GLTF = LightConstants.FALLOFF_GLTF;
- /**
- * Falloff Standard: light is falling off like in the standard material
- * to enhance interoperability with other materials.
- */
- Light.FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD;
- //lightmapMode Consts
- /**
- * If every light affecting the material is in this lightmapMode,
- * material.lightmapTexture adds or multiplies
- * (depends on material.useLightmapAsShadowmap)
- * after every other light calculations.
- */
- Light.LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT;
- /**
- * material.lightmapTexture as only diffuse lighting from this light
- * adds only specular lighting from this light
- * adds dynamic shadows
- */
- Light.LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR;
- /**
- * material.lightmapTexture as only lighting
- * no light calculation from this light
- * only adds dynamic shadows from this light
- */
- Light.LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY;
- // Intensity Mode Consts
- /**
- * Each light type uses the default quantity according to its type:
- * point/spot lights use luminous intensity
- * directional lights use illuminance
- */
- Light.INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC;
- /**
- * lumen (lm)
- */
- Light.INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER;
- /**
- * candela (lm/sr)
- */
- Light.INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY;
- /**
- * lux (lm/m^2)
- */
- Light.INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE;
- /**
- * nit (cd/m^2)
- */
- Light.INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE;
- // Light types ids const.
- /**
- * Light type const id of the point light.
- */
- Light.LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT;
- /**
- * Light type const id of the directional light.
- */
- Light.LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT;
- /**
- * Light type const id of the spot light.
- */
- Light.LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT;
- /**
- * Light type const id of the hemispheric light.
- */
- Light.LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT;
- __decorate([
- serializeAsColor3()
- ], Light.prototype, "diffuse", void 0);
- __decorate([
- serializeAsColor3()
- ], Light.prototype, "specular", void 0);
- __decorate([
- serialize()
- ], Light.prototype, "falloffType", void 0);
- __decorate([
- serialize()
- ], Light.prototype, "intensity", void 0);
- __decorate([
- serialize()
- ], Light.prototype, "range", null);
- __decorate([
- serialize()
- ], Light.prototype, "intensityMode", null);
- __decorate([
- serialize()
- ], Light.prototype, "radius", null);
- __decorate([
- serialize()
- ], Light.prototype, "_renderPriority", void 0);
- __decorate([
- expandToProperty("_reorderLightsInScene")
- ], Light.prototype, "renderPriority", void 0);
- __decorate([
- serialize("shadowEnabled")
- ], Light.prototype, "_shadowEnabled", void 0);
- __decorate([
- serialize("excludeWithLayerMask")
- ], Light.prototype, "_excludeWithLayerMask", void 0);
- __decorate([
- serialize("includeOnlyWithLayerMask")
- ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
- __decorate([
- serialize("lightmapMode")
- ], Light.prototype, "_lightmapMode", void 0);
- //# sourceMappingURL=light.js.map
|