@openhps/core
Version:
Open Hybrid Positioning System - Core component
54 lines (50 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _LightingModel = _interopRequireDefault(require("../core/LightingModel.js"));
var _PropertyNode = require("../core/PropertyNode.js");
var _TSLBase = require("../tsl/TSLBase.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Represents lighting model for a shadow material. Used in {@link ShadowNodeMaterial}.
*
* @augments LightingModel
*/
class ShadowMaskModel extends _LightingModel.default {
/**
* Constructs a new shadow mask model.
*/
constructor() {
super();
/**
* The shadow mask node.
*
* @type {Node}
*/
this.shadowNode = (0, _TSLBase.float)(1).toVar('shadowMask');
}
/**
* Only used to save the shadow mask.
*
* @param {Object} input - The input data.
*/
direct({
lightNode
}) {
this.shadowNode.mulAssign(lightNode.shadowNode);
}
/**
* Uses the shadow mask to produce the final color.
*
* @param {NodeBuilder} builder - The current node builder.
*/
finish({
context
}) {
_PropertyNode.diffuseColor.a.mulAssign(this.shadowNode.oneMinus());
context.outgoingLight.rgb.assign(_PropertyNode.diffuseColor.rgb); // TODO: Optimize LightsNode to avoid this assignment
}
}
var _default = exports.default = ShadowMaskModel;