Skip to content

Instantly share code, notes, and snippets.

@skrat
Created June 19, 2013 10:29
Show Gist options
  • Save skrat/5813322 to your computer and use it in GitHub Desktop.
Save skrat/5813322 to your computer and use it in GitHub Desktop.
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class vec3i
X = 0
Y = 1
Z = 2
constructor: (x, y, z) ->
@data = new Uint32Array()
@data[X] = x
@data[Y] = y
@data[Z] = z
@property 'x',
get: -> @data[X]
set: (x) -> @data[X] = x
@property 'y',
get: -> @data[Y]
set: (y) -> @data[Y] = y
@property 'z',
get: -> @data[Z]
set: (z) -> @data[Z] = z
console.log(new vec3i(1,2,3).x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment