UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

31 lines (30 loc) 941 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shapeCircle = void 0; var _TSLBase = require("../tsl/TSLBase.js"); var _MathNode = require("../math/MathNode.js"); var _UV = require("../accessors/UV.js"); /** * Generates a circle based on the uv coordinates. * * @tsl * @function * @param {Node<vec2>} coord - The uv to generate the circle. * @return {Node<float>} The circle shape. */ const shapeCircle = exports.shapeCircle = (0, _TSLBase.Fn)(([coord = (0, _UV.uv)()], { renderer, material }) => { const alpha = (0, _TSLBase.float)(1).toVar(); const len2 = (0, _MathNode.lengthSq)(coord.mul(2).sub(1)); if (material.alphaToCoverage && renderer.samples > 1) { const dlen = (0, _TSLBase.float)(len2.fwidth()).toVar(); alpha.assign((0, _MathNode.smoothstep)(dlen.oneMinus(), dlen.add(1), len2).oneMinus()); } else { len2.greaterThan(1.0).discard(); } return alpha; });