Skip to content

Commit

Permalink
Pass back camera info to GUI for use in scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanhab committed May 22, 2024
1 parent 4d25e77 commit 5e69078
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions editor/websocket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
Expand Down Expand Up @@ -29,7 +29,7 @@ function sendText(json) {
//console.log("sending text: " + json);
websocket.send(json);
}

async function onMessage(evt) {
// console.log("received: " + evt.data);
var msg = JSON.parse(evt.data);
Expand All @@ -41,7 +41,7 @@ async function onMessage(evt) {
case "Deselect":
editor.deselect();
break;
case "Frame":
case "Frame":
if (processing)
return;
if (msg.message_uuid === last_message_uuid)
Expand Down Expand Up @@ -98,7 +98,7 @@ async function onMessage(evt) {
editor.refresh();
last_message_uuid = msg.message_uuid;
}
break;
break;
case "addModelObject":
editor.executeCommandJson(msg);
let parentUuid = msg.command.object.object.parent;
Expand Down Expand Up @@ -135,6 +135,16 @@ async function onMessage(evt) {
case "getOffsets":
sendText(editor.getModelOffsetsJson());
break;
case "getCameraParams":
var camInfo = {
"type": "info",
"position": editor.camera.position,
"quaternion": editor.camera.quaternion,
"aspect": editor.camera.aspect,
"fov": editor.camera.fov
};
sendText(JSON.stringify(camInfo));
break;
}
processing = false; // Defensive in case render never finishes/errors
}
Expand Down

0 comments on commit 5e69078

Please sign in to comment.