angular-threejs / angular-three

Angular Renderer for THREE.js
MIT License
200 stars 27 forks source link

Issues migrating from @angular-three to angular-three #21

Closed IRobot1 closed 2 months ago

IRobot1 commented 1 year ago

Missing with no obvious replacement NgtTriple -

position = [0, 0, 0] as NgtTriple`

Radian Pipe -

item.rotation | radian

Ready Event -

(ready)="meshready($event)"

Value of local variable -instance is no

<ngt-mesh #inst (click)="click(inst.instance.value)" >

No documentation for NgtLoader

  constructor(private loader: NgtLoader) { }
    const s = this.loader.use(TextureLoader, newvalue).subscribe(next => {
      this.texture = next;
    },
      () => { },
      () => { s.unsubscribe(); }
    );
IRobot1 commented 1 year ago
<ngt-color attach="background" color="gray"></ngt-color>

migrates to

<ngt-color attach="background" *args="['gray']"></ngt-color>
IRobot1 commented 1 year ago

I used to be able to do this

<ngt-mesh #inst (click)="this.panelSelected.next(inst.instance.value)">

Looks like inst variable is now an NgtMesh which is extends Mesh. I can't do this, because I get a compile error TS2345: Argument of type 'NgtMesh' is not assignable to parameter of type 'Object3D'.

<ngt-mesh #inst (click)="this.panelSelected.next(inst)">

Also, I can't do this either, due to a different compile error

<ngt-mesh #inst (click)="this.panelSelected.next(<Object3D><unknown>inst)">

I'm forced to create a function just to handle the type conversion

<ngt-mesh #inst (click)="doclick(inst)">
@Output() panelSelected = new EventEmitter<Object3D>();
doclick(mesh: NgtMesh) {
  this.panelSelected.emit(<Object3D><unknown>mesh)
}

Is there a better way to handle this?

nartc commented 2 months ago

Unfortunately, NgtMesh is an expended type of Mesh and it is required to have the custom renderer working with property like [position] and such. What you can do is to cast as $any() on the template. The type of the EventEmitter doesn't have to change.