UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

72 lines (71 loc) 1.9 kB
import Light from "../Light.mjs"; import Vector3 from "../math/Vector3.mjs"; var SpotLight = Light.extend({ range: 20, umbraAngle: 30, penumbraAngle: 45, falloffFactor: 2, shadowBias: 1e-3, shadowSlopeScale: 2 }, { type: "SPOT_LIGHT", uniformTemplates: { spotLightPosition: { type: "3f", value: function(instance) { return instance.getWorldPosition().array; } }, spotLightRange: { type: "1f", value: function(instance) { return instance.range; } }, spotLightUmbraAngleCosine: { type: "1f", value: function(instance) { return Math.cos(instance.umbraAngle * Math.PI / 180); } }, spotLightPenumbraAngleCosine: { type: "1f", value: function(instance) { return Math.cos(instance.penumbraAngle * Math.PI / 180); } }, spotLightFalloffFactor: { type: "1f", value: function(instance) { return instance.falloffFactor; } }, spotLightDirection: { type: "3f", value: function(instance) { instance.__dir = instance.__dir || new Vector3(); return instance.__dir.copy(instance.worldTransform.z).negate().array; } }, spotLightColor: { type: "3f", value: function(instance) { var color = instance.color; var intensity = instance.intensity; return [color[0] * intensity, color[1] * intensity, color[2] * intensity]; } } }, clone: function() { var light = Light.prototype.clone.call(this); light.range = this.range; light.umbraAngle = this.umbraAngle; light.penumbraAngle = this.penumbraAngle; light.falloffFactor = this.falloffFactor; light.shadowBias = this.shadowBias; light.shadowSlopeScale = this.shadowSlopeScale; return light; } }); var SpotLight$1 = SpotLight; export { SpotLight$1 as default };