babylon.pointLight.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.PointLight = function (name, position, scene) {
  5. BABYLON.Light.call(this, name, scene);
  6. this.position = position;
  7. this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
  8. this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
  9. };
  10. BABYLON.PointLight.prototype = Object.create(BABYLON.Light.prototype);
  11. // Methods
  12. BABYLON.PointLight.prototype.transferToEffect = function (effect, positionUniformName) {
  13. if (this.parent && this.parent.getWorldMatrix) {
  14. if (!this._transformedPosition) {
  15. this._transformedPosition = BABYLON.Vector3.Zero();
  16. }
  17. BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
  18. effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
  19. return;
  20. }
  21. effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
  22. };
  23. BABYLON.PointLight.prototype.getShadowGenerator = function () {
  24. return null;
  25. };
  26. BABYLON.PointLight.prototype._getWorldMatrix = function () {
  27. if (!this._worldMatrix) {
  28. this._worldMatrix = BABYLON.Matrix.Identity();
  29. }
  30. BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  31. return this._worldMatrix;
  32. };
  33. })();