argon icon indicating copy to clipboard operation
argon copied to clipboard

Typescript examples throws type errors.

Open muningis opened this issue 8 years ago • 3 comments

Part 1:

userLocation.position.copy(userPose.position); Argument of type 'Cartesian3' is not assignable to parameter of type 'Vector3'. Property 'set' is missing in type 'Cartesian3'.'

Since TypeCast doesn't help, gotta do this:

userLocation.position.copy(new Three.Vector3(
  userPose.position.x,
  userPose.position.y,
  userPose.position.z,
))

And then there's more errors for these:

boxGeoEntity.position.setValue(boxPos, defaultFrame)
boxGeoEntity.orientation.setValue(Argon.Cesium.Quaternion.IDENTITY)
message: 'Property 'setValue' does not exist on type 'PositionProperty'. Did you mean 'getValue'?'
message: 'Property 'setValue' does not exist on type 'Property'. Did you mean 'getValue'?'

Yes, I'm using types both for THREE.js and Argon.

muningis avatar Jul 01 '17 18:07 muningis

You can cast to <any> to appease Typescript.

The better solution is to submit a PR to the types for threejs to relax the requirement for methods like "copy()", which really only care about certain properties on the passed object.

speigg avatar Jul 01 '17 18:07 speigg

And what about setValue? According to Cesium's documentation there indeed is no setValue method.

Also, slightly off-topic, but https://docs.argonjs.io/code/1-geopose/ doesn't work nor on desktop nor on mobile.

muningis avatar Jul 01 '17 18:07 muningis

So the generic PositionPropert doesn't have a setValue. The subtypes (Constant, Interval, etc) have their own. These are probably Constant.

Fixing the typing errors on the examples has been "on the todo list" for a while, we'd welcome PR's that clean them up.

If you do, please work against the develop branch.

blairmacintyre avatar Jul 01 '17 18:07 blairmacintyre