UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

73 lines (66 loc) 2.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.positionWorldDirection = exports.positionWorld = exports.positionViewDirection = exports.positionView = exports.positionPrevious = exports.positionLocal = exports.positionGeometry = void 0; var _AttributeNode = require("../core/AttributeNode.js"); var _TSLCore = require("../tsl/TSLCore.js"); var _ModelNode = require("./ModelNode.js"); /** * TSL object that represents the position attribute of the current rendered object. * * @tsl * @type {AttributeNode<vec3>} */ const positionGeometry = exports.positionGeometry = /*@__PURE__*/(0, _AttributeNode.attribute)('position', 'vec3'); /** * TSL object that represents the vertex position in local space of the current rendered object. * * @tsl * @type {AttributeNode<vec3>} */ const positionLocal = exports.positionLocal = /*@__PURE__*/positionGeometry.toVarying('positionLocal'); /** * TSL object that represents the previous vertex position in local space of the current rendered object. * Used in context of {@link VelocityNode} for rendering motion vectors. * * @tsl * @type {AttributeNode<vec3>} */ const positionPrevious = exports.positionPrevious = /*@__PURE__*/positionGeometry.toVarying('positionPrevious'); /** * TSL object that represents the vertex position in world space of the current rendered object. * * @tsl * @type {VaryingNode<vec3>} */ const positionWorld = exports.positionWorld = /*@__PURE__*/_ModelNode.modelWorldMatrix.mul(positionLocal).xyz.toVarying('v_positionWorld').context({ needsPositionReassign: true }); /** * TSL object that represents the position world direction of the current rendered object. * * @tsl * @type {Node<vec3>} */ const positionWorldDirection = exports.positionWorldDirection = /*@__PURE__*/positionLocal.transformDirection(_ModelNode.modelWorldMatrix).toVarying('v_positionWorldDirection').normalize().toVar('positionWorldDirection').context({ needsPositionReassign: true }); /** * TSL object that represents the vertex position in view space of the current rendered object. * * @tsl * @type {VaryingNode<vec3>} */ const positionView = exports.positionView = /*@__PURE__*/(0, _TSLCore.Fn)(builder => { return builder.context.setupPositionView(); }, 'vec3').once()().toVarying('v_positionView').context({ needsPositionReassign: true }); /** * TSL object that represents the position view direction of the current rendered object. * * @tsl * @type {VaryingNode<vec3>} */ const positionViewDirection = exports.positionViewDirection = /*@__PURE__*/positionView.negate().toVarying('v_positionViewDirection').normalize().toVar('positionViewDirection');