function escapeRegExp(string) {
    return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}

/**
 * Removes excluded text from a Node.
 *
 * @param {Node} target Node to filter.
 * @param {string} exclude CSS selector of nodes to exclude.
 * @returns {DOMString} Text from `target` with text removed.
 */
function filterText(target, exclude) {
    const clone = target.cloneNode(true);  // clone as to not modify the live DOM
    if (exclude) {
        // remove excluded nodes
        clone.querySelectorAll(exclude).forEach(node => node.remove());
    }
    return clone.innerText;
}

// Callback when a copy button is clicked. Will be passed the node that was clicked
// should then grab the text and replace pieces of text that shouldn't be used in output
function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onlyCopyPromptLines = true, removePrompts = true, copyEmptyLines = true, lineContinuationChar = "", hereDocDelim = "") {
    var regexp;
    var match;

    // Do we check for line continuation characters and "HERE-documents"?
    var useLineCont = !!lineContinuationChar
    var useHereDoc = !!hereDocDelim

    // create regexp to capture prompt and remaining line
    if (isRegexp) {
        regexp = new RegExp('^(' + copybuttonPromptText + ')(.*)')
    } else {
        regexp = new RegExp('^(' + escapeRegExp(copybuttonPromptText) + ')(.*)')
    }

    const outputLines = [];
    var promptFound = false;
    var gotLineCont = false;
    var gotHereDoc = false;
    const lineGotPrompt = [];
    for (const line of textContent.split('\n')) {
        match = line.match(regexp)
        if (match || gotLineCont || gotHereDoc) {
            promptFound = regexp.test(line)
            lineGotPrompt.push(promptFound)
            if (removePrompts && promptFound) {
                outputLines.push(match[2])
            } else {
                outputLines.push(line)
            }
            gotLineCont = line.endsWith(lineContinuationChar) & useLineCont
            if (line.includes(hereDocDelim) & useHereDoc)
                gotHereDoc = !gotHereDoc
        } else if (!onlyCopyPromptLines) {
            outputLines.push(line)
        } else if (copyEmptyLines && line.trim() === '') {
        }
    }

    // If no lines with the prompt were found then just use original lines
    if (lineGotPrompt.some(v => v === true)) {
        textContent = outputLines.join('\n');
    }

    // Remove a trailing newline to avoid auto-running when pasting
    if (textContent.endsWith("\n")) {
        textContent = textContent.slice(0, -1)
    }
    return textContent
}

The latest CAD files can downloaded from `this link. <https://github.com/gocivici/trinteract/archive/refs/heads/master.zip>`_ The CAD files can be edited in Fusion360. You can also use the .stl files directly for the 3D printing.

 The CAD files can be edited in Fusion360. You can also use the .stl files directly for the 3D printing.

The 3D prints were done on a fdm printer with a eSun PLA+ filament. The following settings were used for the print:

Here are the parts that are required to biuld trinteract. You can also prototype it first before fabricating a pcb following the wiring diagram below.

`Infenion TLV493DA Low Power 3D Magnetic Sensor <https://eu.mouser.com/ProductDetail/Infineon-Technologies/TLV493DA1B6HTSA2?qs=0DP5yvOrqYnbdRXsuslLCg%3D%3D&countryCode=DE&currencyCode=EUR>`_

': *These parts can be bought from any major electronics supplier, like Digikey or Mouser*

*These parts can be bought from any major electronics supplier, like Digikey or Mouser*

These parts can be bought from any major electronics supplier, like Digikey or Mouser

The Arduino code for trinteract can be found in the Software folder in the github repository. You can download the latest version by clicking the following link: https://github.com/gocivici/trinteract/archive/refs/heads/master.zip

The Arduino code for trinteract can be found in the Software folder in the github repository. You can download the latest version by clicking the following link: 

the Arduino code comes configured and calibrated based on a 4x4mm neodymium magnet. If you want to use a different magnet or magnetic material like magnetic textiles etc. you have to
configure the range of the magnetic field in the Arduino code.

//  uncomment the following line for debugging
Serial.begin(9600);

Next, upload the code to arduino and launch the serial monitor to see the new values. Now move the magnet to the maximum and minimum ends to determine the range of values.

Replace ``xMin``, ``xMax``, ``yMin``, ``yMax``, ``zMin``, ``zMax`` with the new values.

int y = map((calX-Tlv493dMagnetic3DSensor.getX()),yMax,yMin,-64,64);
int x = map((calY-Tlv493dMagnetic3DSensor.getY()),xMax,xMin,-64,64);
int z = map((calZ-Tlv493dMagnetic3DSensor.getZ()),zMin,zMax,-64,64);

The button on trinteract is set up as a calibration button, however calibration is also implemented on boot so you can configure to use it to control something else. If you decide to do so you can
comment the following line in the arduino code:

// comment the following lines if you want to use the button for something else
if(digitalRead(calButton) || !calibrationState){
  calibrate();
  calibrationState = true;
}

This interactive guide will guide you throug the capabilities of the sensor. But first you have to use a plugin to let figma communicate with trinteract.
download the zxyKit driver from here, unzip the folder and on Figma goto Plugins → Development → trinteract Driver.

<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="800" height="450" src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FUFxI3BClRxhGJ0QWtABtZl%2FTutorial%3Ftype%3Dwhiteboard%26node-id%3D2%253A265%26t%3DRoKtvZkPYlV7qNqe-1" allowfullscreen></iframe>

To get started with **trinteract**, connect an **3.3v** arduino pro micro to the board as shown in the picture along with the 3D printed top. If you're building your own kit head over to the :doc:`🛠️ Build Your Own </build_your_own/overview>` section.

 arduino pro micro to the board as shown in the picture along with the 3D printed top. If you’re building your own kit head over to the 

trinteract is only compatible with 3.3 volts, any higher voltage could fry the sensor

It can track movement in all 3 axes, and you can customize it further by following the

The zxyKit is pre-configured to work with **Blender** out of the box, If you want to use it with other software

Next, launch the interactive tutorial on figma following the link below.

- Attach the purple board to the Arduino as shown in the picture.

- Launch Blender and go into fly mode from the ``View ‣ Navigation`` menu.

On Windows, Your computer will recognize trinteract as a game controller. To check if it's recognized go to:
``Control Panel`` → ``Devices and Printers`` → ``Set up USB game controllers`` and click ``Properties``

On Windows, Your computer will recognize trinteract as a game controller. To check if it’s recognized go to:

If trinteract isn't recognized on your computer you can visit the Troubleshooting guide here

If trinteract isn’t recognized on your computer you can visit the Troubleshooting guide here

C:\Users\gogob\Documents\zxyKit\docs\source\build_your_own\Bill of materials.rst

The latest PCB files can downloaded from `this link <https://github.com/gocivici/trinteract/archive/refs/heads/master.zip>`_

There are two subfolders under the PCB folder. One contains the KiCAD files that can be edited and customized. The other folder titled "Gerbers" contains the manufacture ready files
that can be directly sent to a PCB manufacturer like JLCPCB.

There are two subfolders under the PCB folder. One contains the KiCAD files that can be edited and customized. The other folder titled “Gerbers” contains the manufacture ready files

The PCB in these pictures are from the previous version, I'll update them once I receive the new batch. The only difference in the new version is the button placement. The newer version has the button on the back.

The PCB in these pictures are from the previous version, I’ll update them once I receive the new batch. The only difference in the new version is the button placement. The newer version has the button on the back.

The components can be soldered on to the PCB by hand, but you could also use solder paste and a reflow oven to make the process easier. I followed this tutorial
for the hand soldering:

<iframe width="560" height="315" src="https://www.youtube.com/embed/4zXP0TtORWo" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

The only Through-Hole components in this build are te header pins. You can also solder additional expansion pins if you plan to prototype with the board.

After you conect the board to arduino as shown in the picture, download the arduino code from  `the repository <https://github.com/gocivici/trinteract>`_ and upload the code to the
arduino with the following settings:

After you conect the board to arduino as shown in the picture, download the arduino code from  

 and upload the code to the