Merge pull request #15323 from ctrlaltdavid/M22052

Case 22052: Camera JSDoc
This commit is contained in:
Shannon Romano 2019-04-12 12:26:39 -07:00 committed by GitHub
commit 11e5f0a101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 75 deletions

View file

@ -19,14 +19,22 @@ class FancyCamera : public Camera {
Q_OBJECT
/**jsdoc
* @namespace
* @augments Camera
*/
// FIXME: JSDoc 3.5.5 doesn't augment @property definitions. The following definition is repeated in Camera.h.
/**jsdoc
* @property {Uuid} cameraEntity The ID of the entity that the camera position and orientation follow when the camera is in
* entity mode.
* The <code>Camera</code> API provides access to the "camera" that defines your view in desktop and HMD display modes.
*
* @namespace Camera
*
* @hifi-interface
* @hifi-client-entity
* @hifi-avatar
*
* @property {Vec3} position - The position of the camera. You can set this value only when the camera is in independent
* mode.
* @property {Quat} orientation - The orientation of the camera. You can set this value only when the camera is in
* independent mode.
* @property {Camera.Mode} mode - The camera mode.
* @property {ViewFrustum} frustum - The camera frustum.
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
* camera is in entity mode.
*/
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
@ -38,25 +46,25 @@ public:
public slots:
/**jsdoc
* Get the ID of the entity that the camera is set to use the position and orientation from when it's in entity mode. You can
* also get the entity ID using the <code>Camera.cameraEntity</code> property.
* @function Camera.getCameraEntity
* @returns {Uuid} The ID of the entity that the camera is set to follow when in entity mode; <code>null</code> if no camera
* entity has been set.
*/
/**jsdoc
* Gets the ID of the entity that the camera is set to follow (i.e., use the position and orientation from) when it's in
* entity mode. You can also get the entity ID using the {@link Camera|Camera.cameraEntity} property.
* @function Camera.getCameraEntity
* @returns {Uuid} The ID of the entity that the camera is set to follow when in entity mode; <code>null</code> if no
* camera entity has been set.
*/
QUuid getCameraEntity() const;
/**jsdoc
* Set the entity that the camera should use the position and orientation from when it's in entity mode. You can also set the
* entity using the <code>Camera.cameraEntity</code> property.
* @function Camera.setCameraEntity
* @param {Uuid} entityID The entity that the camera should follow when it's in entity mode.
* @example <caption>Move your camera to the position and orientation of the closest entity.</caption>
* Camera.setModeString("entity");
* var entity = Entities.findClosestEntity(MyAvatar.position, 100.0);
* Camera.setCameraEntity(entity);
*/
* Sets the entity that the camera should follow (i.e., use the position and orientation from) when it's in entity mode.
* You can also set the entity using the {@link Camera|Camera.cameraEntity} property.
* @function Camera.setCameraEntity
* @param {Uuid} entityID - The entity that the camera should follow when it's in entity mode.
* @example <caption>Move your camera to the position and orientation of the closest entity.</caption>
* Camera.setModeString("entity");
* var entity = Entities.findClosestEntity(MyAvatar.position, 100.0);
* Camera.setCameraEntity(entity);
*/
void setCameraEntity(QUuid entityID);
private:

View file

@ -36,25 +36,6 @@ static int cameraModeId = qRegisterMetaType<CameraMode>();
class Camera : public QObject {
Q_OBJECT
/**jsdoc
* The Camera API provides access to the "camera" that defines your view in desktop and HMD display modes.
*
* @namespace Camera
*
* @hifi-interface
* @hifi-client-entity
* @hifi-avatar
*
* @property {Vec3} position - The position of the camera. You can set this value only when the camera is in independent
* mode.
* @property {Quat} orientation - The orientation of the camera. You can set this value only when the camera is in
* independent mode.
* @property {Camera.Mode} mode - The camera mode.
* @property {ViewFrustum} frustum - The camera frustum.
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
* camera is in entity mode.
*/
// FIXME: The cameraEntity property definition is copied from FancyCamera.h.
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
Q_PROPERTY(QString mode READ getModeString WRITE setModeString)
@ -82,53 +63,54 @@ public:
public slots:
/**jsdoc
* Get the current camera mode. You can also get the mode using the <code>Camera.mode</code> property.
* Gets the current camera mode. You can also get the mode using the {@link Camera|Camera.mode} property.
* @function Camera.getModeString
* @returns {Camera.Mode} The current camera mode.
*/
QString getModeString() const;
/**jsdoc
* Set the camera mode. You can also set the mode using the <code>Camera.mode</code> property.
* @function Camera.setModeString
* @param {Camera.Mode} mode - The mode to set the camera to.
*/
* Sets the camera mode. You can also set the mode using the {@link Camera|Camera.mode} property.
* @function Camera.setModeString
* @param {Camera.Mode} mode - The mode to set the camera to.
*/
void setModeString(const QString& mode);
/**jsdoc
* Get the current camera position. You can also get the position using the <code>Camera.position</code> property.
* @function Camera.getPosition
* @returns {Vec3} The current camera position.
*/
* Gets the current camera position. You can also get the position using the {@link Camera|Camera.position} property.
* @function Camera.getPosition
* @returns {Vec3} The current camera position.
*/
glm::vec3 getPosition() const { return _position; }
/**jsdoc
* Set the camera position. You can also set the position using the <code>Camera.position</code> property. Only works if the
* camera is in independent mode.
* @function Camera.setPosition
* @param {Vec3} position - The position to set the camera at.
*/
* Sets the camera position. You can also set the position using the {@link Camera|Camera.position} property. Only works if
* the camera is in independent mode.
* @function Camera.setPosition
* @param {Vec3} position - The position to set the camera at.
*/
void setPosition(const glm::vec3& position);
/**jsdoc
* Get the current camera orientation. You can also get the orientation using the <code>Camera.orientation</code> property.
* @function Camera.getOrientation
* @returns {Quat} The current camera orientation.
*/
* Gets the current camera orientation. You can also get the orientation using the {@link Camera|Camera.orientation}
* property.
* @function Camera.getOrientation
* @returns {Quat} The current camera orientation.
*/
glm::quat getOrientation() const { return _orientation; }
/**jsdoc
* Set the camera orientation. You can also set the orientation using the <code>Camera.orientation</code> property. Only
* works if the camera is in independent mode.
* @function Camera.setOrientation
* @param {Quat} orientation - The orientation to set the camera to.
*/
* Sets the camera orientation. You can also set the orientation using the {@link Camera|Camera.orientation} property. Only
* works if the camera is in independent mode.
* @function Camera.setOrientation
* @param {Quat} orientation - The orientation to set the camera to.
*/
void setOrientation(const glm::quat& orientation);
/**jsdoc
* Compute a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
* {@link Overlays.findRayIntersection}.
* Computes a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
* {@link Overlays.findRayIntersection}.
* @function Camera.computePickRay
* @param {number} x - X-coordinate on screen.
* @param {number} y - Y-coordinate on screen.
@ -147,9 +129,9 @@ public slots:
virtual PickRay computePickRay(float x, float y) const = 0;
/**jsdoc
* Rotate the camera to look at the specified <code>position</code>. Only works if the camera is in independent mode.
* Rotates the camera to look at the specified <code>position</code>. Only works if the camera is in independent mode.
* @function Camera.lookAt
* @param {Vec3} position - Position to look at.
* @param {Vec3} position - The position to look at.
* @example <caption>Rotate your camera to look at entities as you click on them with your mouse.</caption>
* function onMousePressEvent(event) {
* var pickRay = Camera.computePickRay(event.x, event.y);
@ -168,15 +150,15 @@ public slots:
void lookAt(const glm::vec3& position);
/**jsdoc
* Set the camera to continue looking at the specified <code>position</code> even while the camera moves. Only works if the
* camera is in independent mode.
* Sets the camera to continue looking at the specified <code>position</code> even while the camera moves. Only works if
* the camera is in independent mode.
* @function Camera.keepLookingAt
* @param {Vec3} position - Position to keep looking at.
* @param {Vec3} position - The position to keep looking at.
*/
void keepLookingAt(const glm::vec3& position);
/**jsdoc
* Stops the camera from continually looking at the position that was set with <code>Camera.keepLookingAt</code>.
* Stops the camera from continually looking at the position that was set with {@link Camera.keepLookingAt}.
* @function Camera.stopLookingAt
*/
void stopLooking() { _isKeepLookingAt = false; }