UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

114 lines (104 loc) 3.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _NodeMaterial = _interopRequireDefault(require("./NodeMaterial.js")); var _MaterialNode = require("../../nodes/accessors/MaterialNode.js"); var _BasicEnvironmentNode = _interopRequireDefault(require("../../nodes/lighting/BasicEnvironmentNode.js")); var _BasicLightMapNode = _interopRequireDefault(require("../../nodes/lighting/BasicLightMapNode.js")); var _BasicLightingModel = _interopRequireDefault(require("../../nodes/functions/BasicLightingModel.js")); var _Normal = require("../../nodes/accessors/Normal.js"); var _PropertyNode = require("../../nodes/core/PropertyNode.js"); var _MeshBasicMaterial = require("../MeshBasicMaterial.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const _defaultValues = /*@__PURE__*/new _MeshBasicMaterial.MeshBasicMaterial(); /** * Node material version of {@link MeshBasicMaterial}. * * @augments NodeMaterial */ class MeshBasicNodeMaterial extends _NodeMaterial.default { static get type() { return 'MeshBasicNodeMaterial'; } /** * Constructs a new mesh basic node material. * * @param {Object} [parameters] - The configuration parameter. */ constructor(parameters) { super(); /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */ this.isMeshBasicNodeMaterial = true; /** * Although the basic material is by definition unlit, we set * this property to `true` since we use a lighting model to compute * the outgoing light of the fragment shader. * * @type {boolean} * @default true */ this.lights = true; this.setDefaultValues(_defaultValues); this.setValues(parameters); } /** * Basic materials are not affected by normal and bump maps so we * return by default {@link normalView}. * * @return {Node<vec3>} The normal node. */ setupNormal() { return _Normal.normalView; // see #28839 } /** * Overwritten since this type of material uses {@link BasicEnvironmentNode} * to implement the default environment mapping. * * @param {NodeBuilder} builder - The current node builder. * @return {?BasicEnvironmentNode<vec3>} The environment node. */ setupEnvironment(builder) { const envNode = super.setupEnvironment(builder); return envNode ? new _BasicEnvironmentNode.default(envNode) : null; } /** * This method must be overwritten since light maps are evaluated * with a special scaling factor for basic materials. * * @param {NodeBuilder} builder - The current node builder. * @return {?BasicLightMapNode<vec3>} The light map node. */ setupLightMap(builder) { let node = null; if (builder.material.lightMap) { node = new _BasicLightMapNode.default(_MaterialNode.materialLightMap); } return node; } /** * The material overwrites this method because `lights` is set to `true` but * we still want to return the diffuse color as the outgoing light. * * @return {Node<vec3>} The outgoing light node. */ setupOutgoingLight() { return _PropertyNode.diffuseColor.rgb; } /** * Setups the lighting model. * * @return {BasicLightingModel} The lighting model. */ setupLightingModel() { return new _BasicLightingModel.default(); } } var _default = exports.default = MeshBasicNodeMaterial;