Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Envision visualization issue in "near real time" mode #1766

Merged
merged 7 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion envision/web/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><title>Envision</title><script src="https://www.webrtc-experiment.com/EBML.js"></script><link rel="shortcut icon" href="#"/></head><body><div id="root" style="width:100vw;height:100vh"></div><script src="main.js"></script></body></html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<title>Envision</title>

<!-- link this EBML.js to fix video seeking issues -->
<script src="https://www.webrtc-experiment.com/EBML.js"></script>

<!-- prevent missing favicon message -->
<link rel="shortcut icon" href="#" />
</head>

<body>
<div id="root" style="width: 100vw; height: 100vh"></div>
<script src="main.js"></script></body>
</html>
269,272 changes: 268,913 additions & 359 deletions envision/web/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion envision/web/dist/main.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions envision/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"babel-loader": "^8.1.0",
"css-loader": "^3.5.2",
"html-loader": "^1.0.0",
"html-webpack-plugin": "^4.0.3",
"html-webpack-plugin": "^4.5.2",
"regenerator-runtime": "^0.13.5",
"style-loader": "^1.1.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-server": "^4.11.1"
},
"dependencies": {
"@ant-design/dark-theme": "^2.0.1",
Expand All @@ -37,6 +37,7 @@
"antd": "^4.1.2",
"babylonjs": "^4.1.0",
"babylonjs-hook": "0.0.1",
"dayjs": "^1.11.6",
"earcut": "^2.2.2",
"html2canvas": "^1.0.0-rc.5",
"prettier": "^2.3.1",
Expand Down
14 changes: 7 additions & 7 deletions envision/web/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Client {
endpoint,
delay = 2000,
retries = Number.POSITIVE_INFINITY,
maxFrameBufferSize = 200,
maxFrameBufferSize = 10000,
frameBufferMode = frameBufferModes.NO_BIAS,
}) {
this._endpoint = new URL(endpoint);
Expand Down Expand Up @@ -121,15 +121,15 @@ export default class Client {
value === "NaN"
? Nan
: value === "Infinity"
? Infinity
: value === "-Infinity"
? -Infinity
: value
? Infinity
: value === "-Infinity"
? -Infinity
: value
);
if (
stateQueue.length > 0 &&
frame.current_elapsed_time <
stateQueue[stateQueue.length - 1].current_elapsed_time
stateQueue[stateQueue.length - 1].current_elapsed_time
) {
// if it's moved back in time, it was from a seek and we're now
// going to receive those frames again, so flush.
Expand Down Expand Up @@ -185,7 +185,7 @@ export default class Client {
socket.onerror = (error) => {
console.warn(
`Socket encountered error=${error.message} ` +
`trying to connect to endpoint=${url}`
`trying to connect to endpoint=${url}`
);
reject(error);
};
Expand Down
11 changes: 6 additions & 5 deletions envision/web/src/components/simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function Simulation({
egoView,
controlModes,
canvasRef = null,
onElapsedTimesChanged = (current, total) => {},
onElapsedTimesChanged = (current, total) => { },
style = {},
playing = true,
playingMode,
Expand Down Expand Up @@ -185,10 +185,11 @@ export default function Simulation({
// React to trigger update, 0.1 millisecond
await sleep(0.1);
} else if (playingMode == PLAYMODES.near_real_time) {
await sleep(
msInSec * (elapsed_times[0] - prevElapsedTime) -
(Date.now() - waitStartTime)
);
let deltaElapsedMs = msInSec * (elapsed_times[0] - prevElapsedTime);
if (deltaElapsedMs > 100) {
deltaElapsedMs = 100;
}
await sleep(deltaElapsedMs - (Date.now() - waitStartTime));
}
prevElapsedTime = elapsed_times[0];
let unpacked_wstate = unpack_worldstate(wstate);
Expand Down