pythreejs icon indicating copy to clipboard operation
pythreejs copied to clipboard

Track moving object with camera

Open Boomer91 opened this issue 6 years ago • 2 comments

Is it possible to track an animated object with a PerspectiveCamera such that it stays in view? A spotlight is able to do this using Spotlight.target = object, but I don't see any functions with camera.. lookAt() only works once, not during an ongoing animation.

Boomer91 avatar Apr 20 '19 05:04 Boomer91

I don't think there is any support for it in threejs, and I don't think it's been added here either. I do agree that it would be useful for avoiding a kernel round-trip per frame. We could either:

  • Set up an Object3D reference that it will track.
  • Set a 3d vector for it to target (which can then be jslinked).
  • A property that can be either (vector or object).

I'm not sure which one makes more sense.

vidartf avatar Apr 21 '19 19:04 vidartf

I think the first option would make the most sense initially, because we generally will want to track an object. This is also consistent with lightsource-tracking (.target method), you give it an object reference to track.

Boomer91 avatar Apr 23 '19 21:04 Boomer91