Skip to content

Instantly share code, notes, and snippets.

@ashconnell
Created December 6, 2021 13:07
Show Gist options
  • Save ashconnell/67afa71035e0782a83abaf21d099b228 to your computer and use it in GitHub Desktop.
Save ashconnell/67afa71035e0782a83abaf21d099b228 to your computer and use it in GitHub Desktop.
A simple crosshair buffer geometry for three.js
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