mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 00:53:17 +02:00
Merge pull request #12689 from ctrlaltdavid/21808
Reinstate Overlays.getOverlayObject API function
This commit is contained in:
commit
790162c88b
3 changed files with 63 additions and 0 deletions
|
@ -388,6 +388,21 @@ QString Overlays::getOverlayType(OverlayID overlayId) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* Overlays::getOverlayObject(OverlayID id) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QObject* result;
|
||||||
|
PROFILE_RANGE(script, __FUNCTION__);
|
||||||
|
BLOCKING_INVOKE_METHOD(this, "getOverlayObject", Q_RETURN_ARG(QObject*, result), Q_ARG(OverlayID, id));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
if (thisOverlay) {
|
||||||
|
return qobject_cast<QObject*>(&(*thisOverlay));
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
return UNKNOWN_OVERLAY_ID;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
|
|
|
@ -235,6 +235,50 @@ public slots:
|
||||||
*/
|
*/
|
||||||
QString getOverlayType(OverlayID overlayId);
|
QString getOverlayType(OverlayID overlayId);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Get the overlay script object. In particular, this is useful for accessing the event bridge for a <code>web3d</code>
|
||||||
|
* overlay.
|
||||||
|
* @function Overlays.getOverlayObject
|
||||||
|
* @param {Uuid} overlayID - The ID of the overlay to get the script object of.
|
||||||
|
* @returns {object} The script object for the overlay if found.
|
||||||
|
* @example <caption>Receive "hello" messages from a <code>web3d</code> overlay.</caption>
|
||||||
|
* // HTML file: name "web3d.html".
|
||||||
|
* <!DOCTYPE html>
|
||||||
|
* <html>
|
||||||
|
* <head>
|
||||||
|
* <title>HELLO</title>
|
||||||
|
* </head>
|
||||||
|
* <body>
|
||||||
|
* <h1>HELLO</h1></h1>
|
||||||
|
* <script>
|
||||||
|
* setInterval(function () {
|
||||||
|
* EventBridge.emitWebEvent("hello");
|
||||||
|
* }, 2000);
|
||||||
|
* </script>
|
||||||
|
* </body>
|
||||||
|
* </html>
|
||||||
|
*
|
||||||
|
* // Script file.
|
||||||
|
* var web3dOverlay = Overlays.addOverlay("web3d", {
|
||||||
|
* position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.5, z: -3 })),
|
||||||
|
* rotation: MyAvatar.orientation,
|
||||||
|
* url: Script.resolvePath("web3d.html"),
|
||||||
|
* alpha: 1.0
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* function onWebEventReceived(event) {
|
||||||
|
* print("onWebEventReceived() : " + JSON.stringify(event));
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* overlayObject = Overlays.getOverlayObject(web3dOverlay);
|
||||||
|
* overlayObject.webEventReceived.connect(onWebEventReceived);
|
||||||
|
*
|
||||||
|
* Script.scriptEnding.connect(function () {
|
||||||
|
* Overlays.deleteOverlay(web3dOverlay);
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
QObject* getOverlayObject(OverlayID id);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get the ID of the 2D overlay at a particular point on the screen or HUD.
|
* Get the ID of the 2D overlay at a particular point on the screen or HUD.
|
||||||
* @function Overlays.getOverlayAtPoint
|
* @function Overlays.getOverlayAtPoint
|
||||||
|
|
|
@ -307,6 +307,10 @@ WebTablet.prototype.setScriptURL = function (scriptURL) {
|
||||||
Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL });
|
Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WebTablet.prototype.getOverlayObject = function () {
|
||||||
|
return Overlays.getOverlayObject(this.webOverlayID);
|
||||||
|
};
|
||||||
|
|
||||||
WebTablet.prototype.setWidth = function (width) {
|
WebTablet.prototype.setWidth = function (width) {
|
||||||
// imported from libraries/utils.js
|
// imported from libraries/utils.js
|
||||||
resizeTablet(width);
|
resizeTablet(width);
|
||||||
|
|
Loading…
Reference in a new issue