* 根据配置参数生成对应形状的连线函数
()
| 154 | * 根据配置参数生成对应形状的连线函数 |
| 155 | */ |
| 156 | private defineLineShape(): void { |
| 157 | const { proximity, range, lineShape } = this.options |
| 158 | switch (lineShape) { |
| 159 | case 'cube': |
| 160 | this.lineShapeMaker = (x, y, sx, sy, cb) => { |
| 161 | const { positionX, positionY } = this |
| 162 | if ( |
| 163 | Math.abs(x - sx) <= proximity && |
| 164 | Math.abs(y - sy) <= proximity && |
| 165 | Math.abs(x - positionX!) <= range && |
| 166 | Math.abs(y - positionY!) <= range && |
| 167 | Math.abs(sx - positionX!) <= range && |
| 168 | Math.abs(sy - positionY!) <= range |
| 169 | ) { |
| 170 | cb() |
| 171 | } |
| 172 | } |
| 173 | break |
| 174 | default: |
| 175 | this.lineShapeMaker = (x, y, sx, sy, cb) => { |
| 176 | const { positionX, positionY } = this |
| 177 | if ( |
| 178 | Math.abs(x - sx) <= proximity && |
| 179 | Math.abs(y - sy) <= proximity && |
| 180 | ((Math.abs(x - positionX!) <= range && |
| 181 | Math.abs(y - positionY!) <= range) || |
| 182 | (Math.abs(sx - positionX!) <= range && |
| 183 | Math.abs(sy - positionY!) <= range)) |
| 184 | ) { |
| 185 | cb() |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * 根据配置参数创建许多粒子(纯数据) |