mrdoob/three.js — Issue #1187: Custom properties in existing classes
Author: rudiedirkx
Created: 2012-01-26 00:11:36+00:00
State: open

Some generically named properties like `speed` and `rotating` and `paused` etc. don't really belong directly in existing classes IMO. I'd like a `.custom` property (a simple hash) that I can assign such properties to. Not in extensions of existing classes, but in their objects:

var block = new THREE.Mesh(geo, material);
block.custom.speed = 1; // instead of block.speed = 1

`block.speed` is not very safe, forward compatibility wise, especially with the lib being in dev.

Assigning my own `.custom` to the prototype won't work however, because then all objects share 1 `custom` hash:

THREE.Object3D.prototype.custom = {};

It's a feature request, but very simple: add `this.custom = {};` to the `Object3D` constructor.