pixijs-userland/pixi-haxe

No more Point::clone ?

Closed this issue · 8 comments

Hello,
I noticed the "clone" method has been recently removed from the pixi.core.math.Point externs :
30832bd#diff-3fa4277d62a58058a161b3c04e7b25c3

I may miss something obvious, but the Point class have not changed for a while :
https://github.com/pixijs/pixi.js/commits/dev/src/core/math/Point.js

... and the source shows it is still there :
https://github.com/pixijs/pixi.js/blob/dev/src/core/math/Point.js

You can also look at the pixi.js raw file, Point::clone is still defined.

Could you please restore this method into the externs ? Is there any good reason to exclude it and to differ from pixi.js ?

ObservablePoint doesn't have clone(), because ... developers issues. You can put it there.

PIXI.ObservablePoint.prototype.clone = PIXI.Point.prototype.clone;

I didn't know about the ObservablePoint class, it could make sense here to not have a clone method as it looks to be a convenience object in its own context.

But about the Point class, I don't see any good reason to remove its clone method from the Haxe externs, it looks like a mistake ^^ As you mention in your example, it's still there ^^ but no more in Haxe externs ^^

Because we have problem with ObservablePoint vs Point. Either use new Point().copy(oldPoint), either do something about externs and hack js that way Observables that are used in all places all over pixi stage have clone object.

We'll solve this situation in v5.

Thanks for answers.

Not sure to understand.

I indeed "hacked" the externs (well, I just reverted to previous version) just to be able to call the defined Point::clone into pixi.js library.

I just use Point class for simple/regular mathematics, not using it for "Observables that are used in all places all over pixi stage". I might be out of date with this context, just doing simple processes with vectors (physics / speed / mecanics ...). But if you recommand to use copy instead of clone, it's ok :)

So Point::clone is deprecated, still there (into pixi.js) but been muted from Haxe externs, if it's intended I'm ok with that.

I understand there are some kind of dependencies with Observables, so you prefer to mute it into Haxe externs, but keep it into the pixi.js file, ok.

I just use Point class for simple/regular mathematics, not using it for "Observables that are used in all places all over pixi stage". I might be out of date with this context, just doing simple processes with vectors (physics / speed / mecanics ...). But if you recommand to use copy instead of clone, it's ok :)

You can implement your own class then, with same interface as Point. PIXI point and matrix are limited even compared to Flash

I found it convenient to dialogue with PIXI (ie: DisplayObject::toLocal).

Instead of a rich Point class, I use a static class with tools that use PIXI Point, but I'll follow your advice, no need to be dependant (just it was convenient)

Thanks again for the answers, my "point" was to be sure the removal only from Haxe externs was intended (still there into pixi.js file) :)

Things like toLocal accept anything that has "x" and "y". Even better, you can specify where it stores the result, whether it creates PIXI.Point . Just give it your own point.

That way you can use rich Point class with PIXI directly. The only problem is that things like "displayObject.position" are still ObservablePoint.

I worked a lot with different implementations of stage trees, and points, and matrices. Its ok to have your own classes for that. PIXI uses minimal interfaces for those objects, just make sure that its kinda compatible ;)

Nice, I didn't know, thanks :) Great job by the way :)