symbol_unique() in Javascript?

Peter Castine's icon

Does the Javascript API expose symbol_unique() anywhere?

I'm looking but not finding it.

The issue is that I'm calling new JitterObject() for a jit.gl.text3d, and the returned object doesn't have a name component (myObj.name appears to be ""). I can programmatically set the name, but if I re-instantiate the Javascript the name is no longer unique and ob3d complains. Hence the need for something like symbol_unique().

Peter Castine's icon

Is something unclear about the question or is everybody just too busy with other stuff?

Jan M's icon

Hi Peter,
as far as i know there is no such object/method in JavaScript.
A posible solution that comes to my mind would be to use the actual timestamp as part of the name-string. When using micro seconds that should be able to create a unique string.
Or you could create a JavaScript object in the global scope that carries an incremental index. Add this index to a string an raise it by 1 each time you instantiate your object.
Best jan.

Peter Castine's icon

Thanks, Jan!

Appending Date.now() works fine for my purposes.

It does seem strange that jit.gl.text3d objects don't automatically get a unique string when they're instantiated in Javascript.

Jan M's icon

Yes indeed it is strange that is doesn't - especially other objects like jit.matrix do expose their automatically created names. Sounds like a bug for me...