three绘制电路图效果

代码语言:html

所属分类:布局界面

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
html,
body {
  padding: 0;
  margin: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  background: #1B2B34;
}
</style>

</head>
<body translate="no">
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/three.js"></script>
<script >
console.clear();
const CellNeighbors = {
  topLeft: 'topLeft',
  top: 'top',
  topRight: 'topRight',
  left: 'left',
  right: 'right',
  bottomLeft: 'bottomLeft',
  bottom: 'bottom',
  bottomRight: 'bottomRight'
};

const rand = (min, max) => min + Math.random() * (max - min);

const notCrossedOver = (node, dir, visited) => {
  let a;
  let b;
  switch (dir) {
    case CellNeighbors.topRight:
      a = node.getNeighbor(CellNeighbors.left);
      b = node.getNeighbor(CellNeighbors.bottom);
      break;
    case CellNeighbors.bottomRight:
      a = node.getNeighbor(CellNeighbors.left);
      b = node.getNeighbor(CellNeighbors.top);
      break;
    case CellNeighbors.topLeft:
      a = node.getNeighbor(CellNeighbors.right);
      b = node.getNeighbor(CellNeighbors.bottom);
      break;
    case CellNeighbors.bottomLeft:
      a = node.getNeighbor(CellNeighbors.right);
      b = node.getNeighbor(CellNeighbors.top);
      break;
    default:
      return true;
  }
  
  const aVisited = a && visited[a.index];
  const bVisited = b && visited[b.index];
  const onSamePath = aVisited && bVisited && visited[a.index] === visited[b.index];
  
  return !onSamePath;
}

class Cell extends THREE.Box2 {
  constructor(min, max, index, position = []) {
    super(min, max);
    
    this._position = [...(Array.isArray(position) ? position : .........完整代码请登录后点击上方下载按钮下载查看

网友评论0