1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- var __extends = this.__extends || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
- };
- var BABYLON;
- (function (BABYLON) {
- var SpotLight = (function (_super) {
- __extends(SpotLight, _super);
- function SpotLight(name, position, direction, angle, exponent, scene) {
- _super.call(this, name, scene);
- this.position = position;
- this.direction = direction;
- this.angle = angle;
- this.exponent = exponent;
- }
- SpotLight.prototype.setDirectionToTarget = function (target) {
- this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
- return this.direction;
- };
- SpotLight.prototype.transferToEffect = function (effect, positionUniformName, directionUniformName) {
- var normalizeDirection;
- if (this.parent && this.parent.getWorldMatrix) {
- if (!this._transformedDirection) {
- this._transformedDirection = BABYLON.Vector3.Zero();
- }
- if (!this._transformedPosition) {
- this._transformedPosition = BABYLON.Vector3.Zero();
- }
- var parentWorldMatrix = this.parent.getWorldMatrix();
- BABYLON.Vector3.TransformCoordinatesToRef(this.position, parentWorldMatrix, this._transformedPosition);
- BABYLON.Vector3.TransformNormalToRef(this.direction, parentWorldMatrix, this._transformedDirection);
- effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, this.exponent);
- normalizeDirection = BABYLON.Vector3.Normalize(this._transformedDirection);
- } else {
- effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, this.exponent);
- normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
- }
- effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(this.angle * 0.5));
- };
- SpotLight.prototype._getWorldMatrix = function () {
- if (!this._worldMatrix) {
- this._worldMatrix = BABYLON.Matrix.Identity();
- }
- BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
- return this._worldMatrix;
- };
- return SpotLight;
- })(BABYLON.Light);
- BABYLON.SpotLight = SpotLight;
- })(BABYLON || (BABYLON = {}));
- //# sourceMappingURL=babylon.spotLight.js.map
|