UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

63 lines (59 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.materialRefractionRatio = exports.materialEnvRotation = exports.materialEnvIntensity = void 0; var _Euler = require("../../math/Euler.js"); var _Matrix = require("../../math/Matrix4.js"); var _UniformNode = require("../core/UniformNode.js"); const _e1 = /*@__PURE__*/new _Euler.Euler(); const _m1 = /*@__PURE__*/new _Matrix.Matrix4(); /** * TSL object that represents the refraction ratio of the material used for rendering the current object. * * @tsl * @type {UniformNode<float>} */ const materialRefractionRatio = exports.materialRefractionRatio = /*@__PURE__*/(0, _UniformNode.uniform)(0).onReference(({ material }) => material).onObjectUpdate(({ material }) => material.refractionRatio); /** * TSL object that represents the intensity of environment maps of PBR materials. * When `material.envMap` is set, the value is `material.envMapIntensity` otherwise `scene.environmentIntensity`. * * @tsl * @type {Node<float>} */ const materialEnvIntensity = exports.materialEnvIntensity = /*@__PURE__*/(0, _UniformNode.uniform)(1).onReference(({ material }) => material).onObjectUpdate(function ({ material, scene }) { return material.envMap ? material.envMapIntensity : scene.environmentIntensity; }); /** * TSL object that represents the rotation of environment maps. * When `material.envMap` is set, the value is `material.envMapRotation`. `scene.environmentRotation` controls the * rotation of `scene.environment` instead. * * @tsl * @type {Node<mat4>} */ const materialEnvRotation = exports.materialEnvRotation = /*@__PURE__*/(0, _UniformNode.uniform)(new _Matrix.Matrix4()).onReference(function (frame) { return frame.material; }).onObjectUpdate(function ({ material, scene }) { const rotation = scene.environment !== null && material.envMap === null ? scene.environmentRotation : material.envMapRotation; if (rotation) { _e1.copy(rotation); _m1.makeRotationFromEuler(_e1); } else { _m1.identity(); } return _m1; });