ngx-three icon indicating copy to clipboard operation
ngx-three copied to clipboard

Angular 19 and Signals support

Open ghost opened this issue 10 months ago • 5 comments

HI, I was wondering if there will the chance in the next feature to this library to be upgraded to support Angular 19 and the new signal API, if not already implemented.

ghost avatar Jan 10 '25 11:01 ghost

Hi, in the near future ngx-three will support angular 18 and 19 peer dependencies. You can already use Signals.

All components are already on push. So you already could go zoneless if you want.

The core wrapper components will still use non-signal inputs (with setters / getters). Because the three.js object3d wrappers do actually have quite a lot of inputs and using signal means instantiating a signal for every input upfront (regardless if used or not).

demike avatar Jan 17 '25 07:01 demike

Ok thank you! Do you think that instantiating a lot of inputs would be a problem? Theoretically you do the same thing by using @Input, and migrating to the new API should improve the performances and allow zoneless in the future.. Of course if we're switching to signals the setters should be migrated to the effect() or ngOnChanges API. If you want we can try migrating to that API on a experimental branch...

(same person of @giovanni-bertoncelli , using another account)

gbertoncelli avatar Jan 17 '25 08:01 gbertoncelli

Been working on it these few hours... it seems like a huge effort to migrate.. @demike do you have plans to progressively migrate to the new API?

gbertoncelli avatar Jan 17 '25 11:01 gbertoncelli

@gbertoncelli you already can run zoneless (all components are onPush). An additional problem would be, that you give up on a single source of truth for your data. It would be present in the wrapper in the signal and in the three.js object!

The only propper way would be to use a custom renderer, do not use wrappers and use the signals for "binding" state. But then you would not be able to react on value changes outside of the template. And you would loose strong typing in the template without doing workarounds (custom html types for vscode for example)

demike avatar Jan 17 '25 12:01 demike

I see... that's probably a use case not covered by the signal input API then... Do you think that using Input directives on newer Angular version will have impact on the performances?

gbertoncelli avatar Jan 17 '25 14:01 gbertoncelli