FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
modelscript/extensions/vscode/src/vrVisualizationPanel.ts at main · modelscript/modelscript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
modelscript
/
modelscript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
3
Star
12
Code
Issues
1
Pull requests
5
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
modelscript
/
extensions
/
vscode
/
src
/
vrVisualizationPanel.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
106 lines (90 loc) · 3.04 KB
Breadcrumbs
modelscript
/
extensions
/
vscode
/
src
/
vrVisualizationPanel.ts
Copy path
File metadata and controls
106 lines (90 loc) · 3.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import
*
as
vscode
from
"vscode"
;
export
class
VrVisualizationPanel
{
public
static
currentPanel
:
VrVisualizationPanel
|
undefined
;
public
static
readonly
viewType
=
"modelscript.vrVisualization"
;
private
readonly
_panel
:
vscode
.
WebviewPanel
;
private
readonly
_extensionUri
:
vscode
.
Uri
;
private
_disposables
:
vscode
.
Disposable
[
]
=
[
]
;
public
static
createOrShow
(
extensionUri
:
vscode
.
Uri
)
{
const
column
=
vscode
.
window
.
activeTextEditor
?
vscode
.
window
.
activeTextEditor
.
viewColumn
:
undefined
;
if
(
VrVisualizationPanel
.
currentPanel
)
{
VrVisualizationPanel
.
currentPanel
.
_panel
.
reveal
(
column
)
;
return
;
}
const
panel
=
vscode
.
window
.
createWebviewPanel
(
VrVisualizationPanel
.
viewType
,
"VR Factory Visualization"
,
column
||
vscode
.
ViewColumn
.
One
,
{
enableScripts
:
true
,
localResourceRoots
:
[
vscode
.
Uri
.
joinPath
(
extensionUri
,
"dist"
)
]
,
}
,
)
;
VrVisualizationPanel
.
currentPanel
=
new
VrVisualizationPanel
(
panel
,
extensionUri
)
;
}
private
constructor
(
panel
:
vscode
.
WebviewPanel
,
extensionUri
:
vscode
.
Uri
)
{
this
.
_panel
=
panel
;
this
.
_extensionUri
=
extensionUri
;
this
.
_update
(
)
;
this
.
_panel
.
onDidDispose
(
(
)
=>
this
.
dispose
(
)
,
null
,
this
.
_disposables
)
;
this
.
_panel
.
webview
.
onDidReceiveMessage
(
(
message
)
=>
{
switch
(
message
.
command
)
{
case
"alert"
:
vscode
.
window
.
showErrorMessage
(
message
.
text
)
;
return
;
}
}
,
null
,
this
.
_disposables
,
)
;
}
public
dispose
(
)
{
VrVisualizationPanel
.
currentPanel
=
undefined
;
this
.
_panel
.
dispose
(
)
;
while
(
this
.
_disposables
.
length
)
{
const
x
=
this
.
_disposables
.
pop
(
)
;
if
(
x
)
{
x
.
dispose
(
)
;
}
}
}
/**
* Pushes a new VTK payload (from the orchestrator) to the WebXR view.
*/
public
updateVtkData
(
participantId
:
string
,
time
:
number
,
vtkData
:
Uint8Array
)
{
// Send raw binary to webview
this
.
_panel
.
webview
.
postMessage
(
{
command
:
"vtkData"
,
participantId
,
time
,
vtkData
:
Array
.
from
(
vtkData
)
,
// converting to array for postMessage serialization
}
)
;
}
private
_update
(
)
{
const
webview
=
this
.
_panel
.
webview
;
this
.
_panel
.
title
=
"VR Factory Visualization"
;
this
.
_panel
.
webview
.
html
=
this
.
_getHtmlForWebview
(
webview
)
;
}
private
_getHtmlForWebview
(
webview
:
vscode
.
Webview
)
{
const
scriptUri
=
webview
.
asWebviewUri
(
vscode
.
Uri
.
joinPath
(
this
.
_extensionUri
,
"dist"
,
"vrVisualizationWebview.js"
)
,
)
;
return
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VR Factory Visualization</title>
<style>
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #000; }
#container { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="container"></div>
<script src="
${
scriptUri
}
"></script>
</body>
</html>`
;
}
}
Back
|
FazBrowse Home
|
New Git URL