Three.js: [TypeScript Support] Camera missing some properties.

Created on 13 May 2019  路  2Comments  路  Source: mrdoob/three.js

Description of the problem
       camera.aspect = window.innerWidth / window.innerHeight;
       camera.updateProjectionMatrix();

tsc will indicate
Property 'aspect' does not exist on type 'Camera'
and
Property 'updateProjectionMatrix' does not exist on type 'Camera'

which is not aligned with THREE documentation here:
https://threejs.org/docs/#api/en/cameras/PerspectiveCamera

I believe more properties is missing in the Camera.d.ts, or the typing is still in progress?

Three.js version
  • [ ] Dev
  • [x] r104
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS

Most helpful comment

I believe more properties is missing in the Camera.d.ts, or the typing is still in progress?

It seems your are mixing Camera with PerspectiveCamera. The base class Camera does not have the property aspect and the method updateProjectionMatrix(). But PerspectiveCamera does.

https://github.com/mrdoob/three.js/blob/3ee4074c68a91c99c156de55ab71b000c9284ce7/src/cameras/PerspectiveCamera.d.ts#L35
https://github.com/mrdoob/three.js/blob/3ee4074c68a91c99c156de55ab71b000c9284ce7/src/cameras/PerspectiveCamera.d.ts#L116

All 2 comments

I believe more properties is missing in the Camera.d.ts, or the typing is still in progress?

It seems your are mixing Camera with PerspectiveCamera. The base class Camera does not have the property aspect and the method updateProjectionMatrix(). But PerspectiveCamera does.

https://github.com/mrdoob/three.js/blob/3ee4074c68a91c99c156de55ab71b000c9284ce7/src/cameras/PerspectiveCamera.d.ts#L35
https://github.com/mrdoob/three.js/blob/3ee4074c68a91c99c156de55ab71b000c9284ce7/src/cameras/PerspectiveCamera.d.ts#L116

Totally, thanks for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Horray picture Horray  路  3Comments

Bandit picture Bandit  路  3Comments

danieljack picture danieljack  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

clawconduce picture clawconduce  路  3Comments