Skip to content

Custom properties in existing classes #1187

@rudiedirkx

Description

@rudiedirkx

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions