JSFiddle - React, Tailwind, and code Playground

by michaelnicol

HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  </head>

  <body>

    <script type="importmap">
      {
          "imports": {
            "three": "https://unpkg.com/[email protected]/build/three.module.js"
          }
        }
      </script>

    <script type="module">
      import { OrbitControls } from "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js"

      import * as three from 'three'
export default class Maze3D {
  /**
    * @constructor
    * @param {Object} constriants - Contains the constructor data for the maze: barrierChar, spaceChar, depth, height, width, xChance, yChance, zChance, diagChance, voidSpace, voidChar, sliceOffVoid
  */
  constructor(constraints) {
    /**
     * @public {Object} contraints - Contains the Maze3D data for the maze: barrierChar, spaceChar, depth, height, width, xChance, yChance, zChance, diagChance, voidSpace, voidChar, sliceOffVoid
     */
    this.constraints = {
      barrierChar: "X",
      spaceChar: " ",
      pathChar: "O",
      width: 10,
      height: 10,
      depth: 10,
      xChance: 2,
      yChance: 2,
      zChance: 2,
      diagChance: 2,
      voidSpace: [],
      voidChar: "#",
      sliceOffVoid: false,
    }
    if (typeof constraints === "object") {
      Object.assign(this.constraints, constraints)
    }
    let characters = [this.constraints.barrierChar, this.constraints.spaceChar, this.constraints.pathChar, this.constraints.voidChar];
    for (let i = 0; i < characters.length; i++) {
      for (let j = 0; j < characters.length; j++) {
        if (characters[i] === characters[j] && i !== j) {
          throw new TypeError("Error in Maze Constraints: " + characters[i] + " maze Character is duplicated across multiple properties " + JSON.stringify(characters) + ".")
        }
      }
    }
   ...