Created
December 6, 2021 13:07
-
-
Save ashconnell/67afa71035e0782a83abaf21d099b228 to your computer and use it in GitHub Desktop.
A simple crosshair buffer geometry for three.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BufferGeometry, Vector3 } from 'three' | |
export class CrosshairGeometry extends BufferGeometry { | |
constructor(thickness = 0.5) { | |
super() | |
const t = thickness | |
const points = [ | |
[-5, t, 0], | |
[5, -t, 0], | |
[5, t, 0], | |
[-5, -t, 0], | |
[5, -t, 0], | |
[-5, t, 0], | |
[-t, t, 0], | |
[t, 5, 0], | |
[-t, 5, 0], | |
[t, t, 0], | |
[t, 5, 0], | |
[-t, t, 0], | |
[-t, -t, 0], | |
[t, -5, 0], | |
[t, -t, 0], | |
[-t, -t, 0], | |
[-t, -5, 0], | |
[t, -5, 0], | |
] | |
this.setFromPoints(points.map(point => new Vector3().fromArray(point))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment