-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreejs_scene.html
More file actions
253 lines (252 loc) · 14.2 KB
/
Copy paththreejs_scene.html
File metadata and controls
253 lines (252 loc) · 14.2 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meca500 Robot - Three.js FK/IK Viewer</title>
<link rel="stylesheet" href="viewer.css">
</head>
<body>
<div id="loading">Loading robot model...</div>
<canvas id="nav-gizmo"></canvas>
<div id="ws-status" title="Click for connection info"><span class="dot off" id="ws-dot"></span><span id="ws-text">API: not connected</span></div>
<div id="ws-info-panel" hidden>
<div class="wsi-row">
<span class="wsi-label">Session ID</span>
<code id="wsi-session" class="wsi-val"></code>
<button class="wsi-copy" data-copy="wsi-session" title="Copy">⎘</button>
</div>
<div class="wsi-row">
<span class="wsi-label">Example</span>
<code id="wsi-cmd" class="wsi-val"></code>
<button class="wsi-copy" data-copy="wsi-cmd" title="Copy">⎘</button>
</div>
<div class="wsi-divider"></div>
<a id="wsi-download" href="/RemoteAPI.zip" download="RemoteAPI.zip">
↓ Download RemoteAPI.zip
</a>
</div>
<div id="panel">
<button id="exitVRBtn" style="display:none; background:#622; border-color:#944; color:#faa;">Exit VR</button>
<div id="device-manager">
<div id="primary-model-row">
<label style="font-size:11px; color:#889;">Primary:</label>
<select id="primaryModelSelect"></select>
</div>
<div id="device-list"></div>
<div id="add-device-row">
<select id="addDeviceSelect"></select>
<button id="addDeviceBtn" title="Add device to scene">+</button>
</div>
<button id="moveDeviceBtn" style="margin-top:4px;">Move Device Origin</button>
<div id="device-mode" style="display:none; margin-top:4px;">
<div style="display:flex; gap:4px;">
<button id="devModeT" class="active" style="flex:1; margin:0;">Move</button>
<button id="devModeR" style="flex:1; margin:0;">Rotate</button>
<button id="devSpaceBtn" style="flex:1; margin:0;">World</button>
</div>
<div style="display:flex; gap:4px; margin-top:4px;">
<button id="devResetPos" style="flex:1; margin:0; padding:4px 0; font-size:11px;">Reset Position</button>
<button id="devResetOri" style="flex:1; margin:0; padding:4px 0; font-size:11px;">Reset Orientation</button>
</div>
<div id="dev-numeric" style="margin-top:6px; font-size:11px; color:#889;">
<div style="display:grid; grid-template-columns:18px 1fr 18px 1fr 18px 1fr; align-items:center; gap:2px 4px; margin-bottom:3px;">
<span style="color:#f88;">X</span><input class="val-input" id="devPosX" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#8f8;">Y</span><input class="val-input" id="devPosY" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#88f;">Z</span><input class="val-input" id="devPosZ" type="number" step="1" style="width:100%;min-width:0;">
</div>
<div style="display:grid; grid-template-columns:18px 1fr 18px 1fr 18px 1fr; align-items:center; gap:2px 4px;">
<span style="color:#f88;">Rx</span><input class="val-input" id="devRotX" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#8f8;">Ry</span><input class="val-input" id="devRotY" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#88f;">Rz</span><input class="val-input" id="devRotZ" type="number" step="1" style="width:100%;min-width:0;">
</div>
<div style="display:flex; gap:4px; margin-top:3px; color:#556; font-size:10px;">
<span style="flex:1; text-align:center;">mm</span>
<span style="flex:1; text-align:center;">deg</span>
</div>
</div>
</div>
<div id="device-parent" style="margin-top:4px;">
<label style="font-size:11px; color:#889;">Parent:</label>
<select id="deviceParentSelect">
<option value="">World</option>
</select>
</div>
</div>
<h2 id="panel-title">Joint Angles (deg)</h2>
<div id="joint-sliders"></div>
<div id="virtual-angles-container"></div>
<div id="ik-panel" style="display:none; margin-top: 8px; padding-top: 8px; border-top: 1px solid #334;">
<h2 style="color:#5b5;">IK Target (mm)</h2>
<div class="slider-row">
<label>X <span id="ikvx">190</span></label>
<input type="number" id="ikx" value="190" step="1" style="display:none">
</div>
<div class="slider-row">
<label>Y <span id="ikvy">0</span></label>
<input type="number" id="iky" value="0" step="1" style="display:none">
</div>
<div class="slider-row">
<label>Z <span id="ikvz">308</span></label>
<input type="number" id="ikz" value="308" step="1" style="display:none">
</div>
<h2 style="margin-top:8px; color:#5b5;">Orientation (deg)</h2>
<div class="slider-row">
<label>α (Rx) <span id="ikva">0</span></label>
<input type="range" id="ika" min="-180" max="180" value="0" step="1">
</div>
<div class="slider-row">
<label>β (Ry) <span id="ikvb">0</span></label>
<input type="range" id="ikb" min="-180" max="180" value="0" step="1">
</div>
<div class="slider-row">
<label>γ (Rz) <span id="ikvc">0</span></label>
<input type="range" id="ikc" min="-180" max="180" value="0" step="1">
</div>
<div id="ee-info">
EE: <span id="eePos">-</span><br>
Target: <span id="tgtPos">-</span><br>
Error: <span id="ikErr">-</span>
</div>
</div>
<div class="button-grid">
<button id="resetBtn">Reset to Home</button>
<button id="demoBtn" style="display:none;">Demo Pose</button>
<button id="ikBtn">IK Mode: OFF</button>
<button id="limitsBtn" title="Turn off to drive joints beyond their configured limits">Limits: ON</button>
<button id="labelBtn">Labels: OFF</button>
<button id="chainBtn">Chain: OFF</button>
<button id="originsBtn">Origins: OFF</button>
<button id="orthoBtn">Ortho: OFF</button>
<button id="flyBtn">Fly Around: OFF</button>
<button id="screenshotBtn">Screenshot</button>
<button id="collisionBtn">Collision: OFF</button>
<button id="floorCollisionBtn">Floor Collision: ON</button>
<button id="headlessCollisionBtn" title="Run collision checks off the render loop, as fast as they complete">Headless: OFF</button>
<button id="stlSelectBtn">Mesh Select: ON</button>
</div>
<div id="flySpeedRow" style="display:none; align-items:center; gap:6px; margin-top:4px;">
<label style="font-size:11px; color:#889; white-space:nowrap;">Fly speed:</label>
<input type="range" id="flySpeed" min="-8" max="8" value="2" step="0.5" style="flex:1;">
<span id="flySpeedVal" style="font-size:11px; color:#8cf; min-width:32px;">2.0×</span>
</div>
<div id="visBoxSection" style="display:none; margin-top:4px;">
<button id="visBoxPlaceBtn">Place Visibility Box</button>
<div style="display:flex; gap:4px; margin-top:4px;">
<button id="visBoxMove" class="active" style="flex:1; margin:0;">Move</button>
<button id="visBoxRotate" style="flex:1; margin:0;">Rotate</button>
<button id="visBoxScale" style="flex:1; margin:0;">Scale</button>
</div>
<div style="display:flex; gap:4px; margin-top:4px;">
<button id="visBoxModeBtn" style="flex:1; margin:0;">Showing: inside</button>
<button id="visBoxClearBtn" style="flex:1; margin:0;">Clear</button>
</div>
<div style="font-size:10px; color:#556; margin-top:2px; text-align:center;">Hides points/splats inside or outside the box · T / R / S</div>
</div>
<div style="display:flex; align-items:center; gap:6px; margin-top:4px;">
<label style="font-size:11px; color:#889; white-space:nowrap;">Floor:</label>
<input type="range" id="floorSize" min="0.5" max="4" value="2" step="0.25" style="flex:1;">
<span id="floorSizeVal" style="font-size:11px; color:#8cf; min-width:32px;">2 m</span>
</div>
<div id="splatClipRow" style="display:none; align-items:center; gap:6px; margin-top:4px;">
<label style="font-size:11px; color:#889; white-space:nowrap;">Splat clip:</label>
<input type="range" id="splatClip" min="0" max="100" value="0" step="1" style="flex:1;">
<span id="splatClipVal" style="font-size:11px; color:#8cf; min-width:32px;">0%</span>
</div>
<div id="pcClipRow" style="display:none; align-items:center; gap:6px; margin-top:4px;">
<label style="font-size:11px; color:#889; white-space:nowrap;">Point clip:</label>
<input type="range" id="pcClip" min="0" max="100" value="0" step="1" style="flex:1;">
<span id="pcClipVal" style="font-size:11px; color:#8cf; min-width:32px;">0%</span>
</div>
<button id="stlBtn">Import Mesh (STL / OBJ / PLY / GLB / Splat)</button>
<input type="file" id="stlFile" accept=".stl,.obj,.mtl,.ply,.glb,.gltf,.splat,.ksplat,.spz" multiple style="display:none">
<div style="display:flex; gap:4px; margin-top:4px;">
<button id="addCubeBtn" style="flex:1; margin:0;">Cube</button>
<button id="addSphereBtn" style="flex:1; margin:0;">Sphere</button>
<button id="addCylinderBtn" style="flex:1; margin:0;">Cylinder</button>
</div>
<div id="stl-list"></div>
<div id="stl-mode">
<span id="stl-sel-name" class="stl-mode-name"></span>
<div class="stl-mode-buttons">
<button id="stlModeT" class="active">Move</button>
<button id="stlModeR">Rotate</button>
<button id="stlModeS">Scale</button>
<button id="stlSpaceBtn">World</button>
<button id="stlDeselect">Deselect</button>
</div>
<div style="display:flex; gap:4px; margin-top:5px;">
<button id="stlResetPos" style="flex:1; width:auto; padding:4px 0; margin:0; font-size:11px;">Reset Position</button>
<button id="stlResetRot" style="flex:1; width:auto; padding:4px 0; margin:0; font-size:11px;">Reset Rotation</button>
<button id="stlResetScale" style="flex:1; width:auto; padding:4px 0; margin:0; font-size:11px;">Reset Scale</button>
</div>
<div id="stl-numeric" style="margin-top:6px; font-size:11px; color:#889;">
<div style="display:grid; grid-template-columns:18px 1fr 18px 1fr 18px 1fr; align-items:center; gap:2px 4px; margin-bottom:3px;">
<span style="color:#f88;">X</span><input class="val-input" id="stlPosX" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#8f8;">Y</span><input class="val-input" id="stlPosY" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#88f;">Z</span><input class="val-input" id="stlPosZ" type="number" step="1" style="width:100%;min-width:0;">
</div>
<div style="display:grid; grid-template-columns:18px 1fr 18px 1fr 18px 1fr; align-items:center; gap:2px 4px; margin-bottom:3px;">
<span style="color:#f88;">Rx</span><input class="val-input" id="stlRotX" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#8f8;">Ry</span><input class="val-input" id="stlRotY" type="number" step="1" style="width:100%;min-width:0;">
<span style="color:#88f;">Rz</span><input class="val-input" id="stlRotZ" type="number" step="1" style="width:100%;min-width:0;">
</div>
<div style="display:grid; grid-template-columns:18px 1fr 18px 1fr 18px 1fr; align-items:center; gap:2px 4px;">
<span style="color:#f88;">Sx</span><input class="val-input" id="stlScX" type="number" step="0.01" style="width:100%;min-width:0;">
<span style="color:#8f8;">Sy</span><input class="val-input" id="stlScY" type="number" step="0.01" style="width:100%;min-width:0;">
<span style="color:#88f;">Sz</span><input class="val-input" id="stlScZ" type="number" step="0.01" style="width:100%;min-width:0;">
</div>
<div style="display:flex; gap:4px; margin-top:3px; color:#556; font-size:10px;">
<span style="flex:1; text-align:center;">mm</span>
<span style="flex:1; text-align:center;">deg</span>
<span style="flex:1; text-align:center;">scale</span>
</div>
</div>
<div id="stl-lock-aspect" style="display:flex; align-items:center; gap:5px; margin-top:5px;">
<input type="checkbox" id="lockAspectCb" style="width:auto; margin:0;">
<label for="lockAspectCb" style="font-size:11px; color:#889; cursor:pointer; white-space:nowrap;">Lock aspect ratio</label>
</div>
<div id="stl-points" style="display:none; margin-top:5px;">
<div style="display:flex; align-items:center; gap:6px;">
<label for="pointShapeSelect" style="font-size:11px; color:#889; white-space:nowrap;">Point shape:</label>
<select id="pointShapeSelect">
<option value="square">Square</option>
<option value="round">Round</option>
<option value="soft">Soft</option>
</select>
</div>
<div style="display:flex; align-items:center; gap:6px; margin-top:4px;">
<label style="font-size:11px; color:#889; white-space:nowrap;">Point size:</label>
<input type="range" id="pointSizeSlider" min="0.2" max="100" value="3" step="0.1" style="flex:1;">
<span id="pointSizeVal" style="font-size:11px; color:#8cf; min-width:44px;">3.0 mm</span>
</div>
</div>
<div id="stl-parent">
<label>Parent:</label>
<select id="stlParentSelect">
<option value="">World</option>
</select>
</div>
</div>
<div id="collision-info" style="display:none;">Collisions: <span id="collision-text">none</span><span id="collision-rate"></span><span id="collision-pairs"></span></div>
<div style="display:flex; gap:4px; margin-top:8px; padding-top:8px; border-top:1px solid #334;">
<button id="saveSceneBtn" style="flex:1; margin:0;">Save Scene</button>
<button id="loadSceneBtn" style="flex:1; margin:0;">Load Scene</button>
<button id="clearSceneBtn" style="flex:1; margin:0;">Clear Scene</button>
<input type="file" id="loadSceneFile" accept=".json" style="display:none">
</div>
</div>
<script src="/node_modules/html2canvas/dist/html2canvas.min.js" onerror="console.warn('html2canvas not available')"></script>
<script type="importmap">
{
"imports": {
"three": "/node_modules/three/build/three.module.js",
"three/addons/": "/node_modules/three/examples/jsm/",
"three-mesh-bvh": "/node_modules/three-mesh-bvh/build/index.module.js",
"gaussian-splats-3d": "/node_modules/@mkkellogg/gaussian-splats-3d/build/gaussian-splats-3d.module.js"
}
}
</script>
<script type="module" src="js/main.js"></script>
</body>
</html>