Camera.inputs.attached.pointers.buttons = [0] Works on PG but not on my project

I have built an Orientation gizmo to use in a 3d visualization tool. With it I use an ArcRotateCamera with disabled zoom and panning. However, if I press the panning button the camera starts to rotate. While looking on the forums I have found that

camera.inputs.attached.pointers.buttons = [0]

works just as I intended on Playground, but not in my TS project, producing the following error:

TypeScript error in OrientationGizmo.tsx(28,41):
Property ‘buttons’ does not exist on type ‘ICameraInput’. TS2339

26 | camera.attachControl(this.canvas, true,false);
27 |
28 | camera.inputs.attached.pointers.buttons = [0]
***|---------------------------------------------^

How would I proceed to fix this?

Below you can find my playground solution.

pinging @PolygonalSun

Hey @IgorAPM, lemme take a look and see what’s going on.

So the reason why it’s working in the Javascript playground but not with Typescript is because camera.inputs.attached.pointers is of type ICameraInput which wouldn’t have visibility of the “buttons” array. You’d need to cast camera.inputs.attached.pointers to the type of ArcRotateCameraPointersInput which would let you modify that array. Javascript doesn’t care about types so if it can find the values, it uses them.

Sorry for the long response time, went on vacation. This worked perfectly fine, Thank you for the help.

1 Like