UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

39 lines (37 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.spherizeUV = exports.rotateUV = void 0; var _TSLBase = require("../tsl/TSLBase.js"); var _RotateNode = require("./RotateNode.js"); /** * Rotates the given uv coordinates around a center point * * @tsl * @function * @param {Node<vec2>} uv - The uv coordinates. * @param {Node<float>} rotation - The rotation defined in radians. * @param {Node<vec2>} center - The center of rotation * @return {Node<vec2>} The rotated uv coordinates. */ const rotateUV = exports.rotateUV = /*@__PURE__*/(0, _TSLBase.Fn)(([uv, rotation, center = (0, _TSLBase.vec2)(0.5)]) => { return (0, _RotateNode.rotate)(uv.sub(center), rotation).add(center); }); /** * Applies a spherical warping effect to the given uv coordinates. * * @tsl * @function * @param {Node<vec2>} uv - The uv coordinates. * @param {Node<float>} strength - The strength of the effect. * @param {Node<vec2>} center - The center point * @return {Node<vec2>} The updated uv coordinates. */ const spherizeUV = exports.spherizeUV = /*@__PURE__*/(0, _TSLBase.Fn)(([uv, strength, center = (0, _TSLBase.vec2)(0.5)]) => { const delta = uv.sub(center); const delta2 = delta.dot(delta); const delta4 = delta2.mul(delta2); const deltaOffset = delta4.mul(strength); return uv.add(delta.mul(deltaOffset)); });