UNPKG

react-audio-visualizers

Version:

<h1 align="center">React Audio Visualizers</h1>

24 lines (23 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RoundBar = void 0; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var three_1 = require("three"); var CURVE_HEIGHT = 6; var RoundBar = function (_a) { var _b = _a.position, x = _b[0], y = _b[1], height = _a.height, width = _a.width, color = _a.color; var shape = (0, react_1.useMemo)(function () { var shape = new three_1.Shape(); var xWidth = x + width; var yHeight = y + height; shape.currentPoint = new three_1.Vector2(x, y); shape.lineTo(x, yHeight); shape.bezierCurveTo(x, yHeight, x + width / 2, yHeight + CURVE_HEIGHT, xWidth, yHeight); shape.lineTo(xWidth, y); shape.bezierCurveTo(xWidth, y, x + width / 2, y - CURVE_HEIGHT, x, y); return shape; }, [x, y, width, height]); return ((0, jsx_runtime_1.jsxs)("mesh", { children: [(0, jsx_runtime_1.jsx)("shapeBufferGeometry", { args: [shape] }, void 0), (0, jsx_runtime_1.jsx)("meshBasicMaterial", { color: color }, void 0)] }, void 0)); }; exports.RoundBar = RoundBar;