|
| 1 | +// const gridPrototye = {}; |
| 2 | +// |
| 3 | +// |
| 4 | +// function Grid() { |
| 5 | +// |
| 6 | +// } |
| 7 | +// |
| 8 | +// |
| 9 | +// Object.assign(Grid.prototype, gridPrototye); |
| 10 | +// |
| 11 | +// |
| 12 | +// export default class GridState { |
| 13 | +// constructor(grid, type) { |
| 14 | +// this.grid = grid; |
| 15 | +// this.type = type; |
| 16 | +// this.size = grid.size; |
| 17 | +// } |
| 18 | +// |
| 19 | +// |
| 20 | +// getGrid() { |
| 21 | +// return this.grid; |
| 22 | +// } |
| 23 | +// |
| 24 | +// |
| 25 | +// setGrid(grid) { |
| 26 | +// this.grid = grid; |
| 27 | +// } |
| 28 | +// |
| 29 | +// |
| 30 | +// // changeGrid(grid, type) { |
| 31 | +// // if (type === this.type) { |
| 32 | +// // return; |
| 33 | +// // } |
| 34 | +// // switch (type) { |
| 35 | +// // case 'circular': |
| 36 | +// // // this.circularLayout(board); |
| 37 | +// // break; |
| 38 | +// // case 'grid': |
| 39 | +// // default: { |
| 40 | +// // // this.standardLayout(board); |
| 41 | +// // } |
| 42 | +// // } |
| 43 | +// // } |
| 44 | +// |
| 45 | +// |
| 46 | +// getType() { |
| 47 | +// return this.type; |
| 48 | +// } |
| 49 | +// |
| 50 | +// |
| 51 | +// setType(type) { |
| 52 | +// this.type = type; |
| 53 | +// } |
| 54 | +// |
| 55 | +// |
| 56 | +// updateGrid(grid) { |
| 57 | +// this.grid = grid; |
| 58 | +// } |
| 59 | +// |
| 60 | +// |
| 61 | +// // // Peter Beshai's iddea for the creation and animation of a board-like grid section |
| 62 | +// // // https://codesandbox.io/s/r3f-demo-2-prj0b |
| 63 | +// // standardLayout(board) { |
| 64 | +// // const numPoints = board.length; |
| 65 | +// // const numCols = Math.ceil(Math.sqrt(numPoints)); |
| 66 | +// // |
| 67 | +// // for (let i = 0; i < numPoints; ++i) { |
| 68 | +// // const datum = board[i]; |
| 69 | +// // const col = (i % numCols) - numCols / 2; |
| 70 | +// // const row = Math.floor(i / numCols) - numCols / 2; |
| 71 | +// // |
| 72 | +// // datum.x = col * 1.05; |
| 73 | +// // datum.y = row * 1.05; |
| 74 | +// // datum.z = 0; |
| 75 | +// // } |
| 76 | +// // } |
| 77 | +// // |
| 78 | +// // |
| 79 | +// // circularLayout(board) { |
| 80 | +// // let theta = 0; |
| 81 | +// // for (let i = 0; i < board.length; ++i) { |
| 82 | +// // const datum = board[i]; |
| 83 | +// // const radius = Math.max(1, Math.sqrt(i + 1) * 0.8); |
| 84 | +// // theta += (Math.asin(1 / radius)); |
| 85 | +// // |
| 86 | +// // datum.x = radius * Math.cos(theta); |
| 87 | +// // datum.y = radius * Math.sin(theta); |
| 88 | +// // datum.z = 0; |
| 89 | +// // } |
| 90 | +// // } |
| 91 | +// } |
| 92 | +// |
| 93 | +// |
| 94 | +// |
0 commit comments