@operato/scene-urdf 9.1.1 → 10.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editors/index.d.ts +6 -0
- package/dist/editors/index.js +7 -1
- package/dist/editors/index.js.map +1 -1
- package/dist/editors/property-editor-urdf-joints.d.ts +54 -0
- package/dist/editors/property-editor-urdf-joints.js +242 -0
- package/dist/editors/property-editor-urdf-joints.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/real-object-urdf.d.ts +75 -0
- package/dist/real-object-urdf.js +284 -0
- package/dist/real-object-urdf.js.map +1 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +2 -3
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/{urdf-controller.d.ts → urdf.d.ts} +3 -0
- package/dist/templates/urdf.js +19 -0
- package/dist/templates/urdf.js.map +1 -0
- package/dist/urdf-object.d.ts +264 -0
- package/dist/urdf-object.js +163 -0
- package/dist/urdf-object.js.map +1 -0
- package/icons/urdf.png +0 -0
- package/package.json +19 -18
- package/dist/elements/drag-n-drop.d.ts +0 -2
- package/dist/elements/drag-n-drop.js +0 -126
- package/dist/elements/drag-n-drop.js.map +0 -1
- package/dist/elements/urdf-controller-element.d.ts +0 -12
- package/dist/elements/urdf-controller-element.js +0 -283
- package/dist/elements/urdf-controller-element.js.map +0 -1
- package/dist/elements/urdf-drag-controls.d.ts +0 -32
- package/dist/elements/urdf-drag-controls.js +0 -185
- package/dist/elements/urdf-drag-controls.js.map +0 -1
- package/dist/elements/urdf-manipulator-element.d.ts +0 -15
- package/dist/elements/urdf-manipulator-element.js +0 -110
- package/dist/elements/urdf-manipulator-element.js.map +0 -1
- package/dist/elements/urdf-viewer-element.d.ts +0 -53
- package/dist/elements/urdf-viewer-element.js +0 -402
- package/dist/elements/urdf-viewer-element.js.map +0 -1
- package/dist/templates/urdf-controller.js +0 -16
- package/dist/templates/urdf-controller.js.map +0 -1
- package/dist/templates/urdf-viewer.d.ts +0 -14
- package/dist/templates/urdf-viewer.js +0 -16
- package/dist/templates/urdf-viewer.js.map +0 -1
- package/dist/urdf-controller.d.ts +0 -15
- package/dist/urdf-controller.js +0 -69
- package/dist/urdf-controller.js.map +0 -1
- package/dist/urdf-viewer.d.ts +0 -16
- package/dist/urdf-viewer.js +0 -202
- package/dist/urdf-viewer.js.map +0 -1
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, css, html } from 'lit';
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
import { registerDragEvents } from './drag-n-drop.js';
|
|
6
|
-
import { ScrollbarStyles } from '@operato/styles';
|
|
7
|
-
const DEG2RAD = Math.PI / 180;
|
|
8
|
-
const RAD2DEG = 1 / DEG2RAD;
|
|
9
|
-
let URDFControllerElement = class URDFControllerElement extends LitElement {
|
|
10
|
-
render() {
|
|
11
|
-
const { joints = {} } = this.robot || {};
|
|
12
|
-
const { ignoreLimits = false } = this.viewer || {};
|
|
13
|
-
const jointsArray = Object.values(joints);
|
|
14
|
-
return html `
|
|
15
|
-
<ul>
|
|
16
|
-
${jointsArray.map(joint => {
|
|
17
|
-
var { jointType, name, angle, limit } = joint;
|
|
18
|
-
var degVal = Number(angle || 0);
|
|
19
|
-
if (jointType === 'revolute' || jointType === 'continuous') {
|
|
20
|
-
degVal *= RAD2DEG;
|
|
21
|
-
}
|
|
22
|
-
if (Math.abs(degVal) > 1) {
|
|
23
|
-
degVal = degVal.toFixed(1);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
degVal = degVal.toPrecision(2);
|
|
27
|
-
}
|
|
28
|
-
var sliderMin;
|
|
29
|
-
var sliderMax;
|
|
30
|
-
var inputMin;
|
|
31
|
-
var inputMax;
|
|
32
|
-
if (ignoreLimits || jointType === 'continuous') {
|
|
33
|
-
sliderMin = -6.28;
|
|
34
|
-
sliderMax = 6.28;
|
|
35
|
-
inputMin = -6.28 * RAD2DEG;
|
|
36
|
-
inputMax = 6.28 * RAD2DEG;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
sliderMin = limit.lower;
|
|
40
|
-
sliderMax = limit.upper;
|
|
41
|
-
inputMin = Number(limit.lower) * RAD2DEG;
|
|
42
|
-
inputMax = Number(limit.upper) * RAD2DEG;
|
|
43
|
-
}
|
|
44
|
-
return html `
|
|
45
|
-
<li joint-type=${jointType} joint-name=${name}>
|
|
46
|
-
<span title=${name}>${name}</span>
|
|
47
|
-
<input
|
|
48
|
-
type="range"
|
|
49
|
-
.value=${String(angle)}
|
|
50
|
-
step="0.0001"
|
|
51
|
-
min=${sliderMin}
|
|
52
|
-
max=${sliderMax}
|
|
53
|
-
@input=${(e) => {
|
|
54
|
-
var _a;
|
|
55
|
-
(_a = this.viewer) === null || _a === void 0 ? void 0 : _a.setJointValue(name, e.target.value);
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
<input
|
|
59
|
-
type="number"
|
|
60
|
-
.value=${degVal}
|
|
61
|
-
step="0.0001"
|
|
62
|
-
min=${inputMin}
|
|
63
|
-
max=${inputMax}
|
|
64
|
-
@change=${(e) => {
|
|
65
|
-
var _a;
|
|
66
|
-
(_a = this.viewer) === null || _a === void 0 ? void 0 : _a.setJointValue(name, Number(e.target.value) * DEG2RAD);
|
|
67
|
-
}}
|
|
68
|
-
/>
|
|
69
|
-
</li>
|
|
70
|
-
`;
|
|
71
|
-
})}
|
|
72
|
-
</ul>
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
updated(changes) {
|
|
76
|
-
if (changes.has('viewer')) {
|
|
77
|
-
this._setupViewer(this.viewer);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
_setupViewer(viewer) {
|
|
81
|
-
if (!viewer) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
this.robot = viewer.robot;
|
|
85
|
-
viewer.addEventListener('urdf-processed', () => {
|
|
86
|
-
this.robot = viewer.robot;
|
|
87
|
-
});
|
|
88
|
-
viewer.addEventListener('ignore-limits-change', () => {
|
|
89
|
-
this.requestUpdate();
|
|
90
|
-
});
|
|
91
|
-
viewer.addEventListener('angle-change', (e) => {
|
|
92
|
-
this.requestUpdate();
|
|
93
|
-
});
|
|
94
|
-
viewer.addEventListener('joint-mouseover', (e) => {
|
|
95
|
-
const j = this.renderRoot.querySelector(`li[joint-name="${e.detail}"]`);
|
|
96
|
-
if (j) {
|
|
97
|
-
j.setAttribute('robot-hovered', 'true');
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
viewer.addEventListener('joint-mouseout', (e) => {
|
|
101
|
-
const j = this.renderRoot.querySelector(`li[joint-name="${e.detail}"]`);
|
|
102
|
-
if (j) {
|
|
103
|
-
j.removeAttribute('robot-hovered');
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
let originalNoAutoRecenter;
|
|
107
|
-
viewer.addEventListener('manipulate-start', (e) => {
|
|
108
|
-
const j = this.renderRoot.querySelector(`li[joint-name="${e.detail}"]`);
|
|
109
|
-
if (j) {
|
|
110
|
-
// ??
|
|
111
|
-
j.scrollIntoView({ block: 'nearest' });
|
|
112
|
-
window.scrollTo(0, 0);
|
|
113
|
-
}
|
|
114
|
-
originalNoAutoRecenter = viewer.noAutoRecenter;
|
|
115
|
-
viewer.noAutoRecenter = true;
|
|
116
|
-
});
|
|
117
|
-
viewer.addEventListener('manipulate-end', (e) => {
|
|
118
|
-
viewer.noAutoRecenter = originalNoAutoRecenter;
|
|
119
|
-
});
|
|
120
|
-
registerDragEvents(viewer, () => {
|
|
121
|
-
this.setColor('#263238');
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
setColor(color) {
|
|
125
|
-
this.viewer.highlightColor = '#' + new THREE.Color(0xffffff).lerp(new THREE.Color(color), 0.35).getHexString();
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
URDFControllerElement.styles = [
|
|
129
|
-
ScrollbarStyles,
|
|
130
|
-
css `
|
|
131
|
-
:host {
|
|
132
|
-
display: flex;
|
|
133
|
-
flex-direction: column;
|
|
134
|
-
width: 100%;
|
|
135
|
-
margin: 15px 0;
|
|
136
|
-
overflow: hidden;
|
|
137
|
-
user-select: none;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
:host > * {
|
|
141
|
-
margin: 5px 0;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
input[type='number'] {
|
|
145
|
-
color: white;
|
|
146
|
-
border: none;
|
|
147
|
-
font-weight: 300;
|
|
148
|
-
background: rgba(255, 255, 255, 0.25);
|
|
149
|
-
padding: 1px 2px;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
ul {
|
|
153
|
-
list-style: none;
|
|
154
|
-
padding: 0;
|
|
155
|
-
margin: 0;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
input[type='range'] {
|
|
159
|
-
-webkit-appearance: none;
|
|
160
|
-
border: none;
|
|
161
|
-
outline: none;
|
|
162
|
-
width: 100%;
|
|
163
|
-
flex: 1;
|
|
164
|
-
height: 16px;
|
|
165
|
-
background-color: transparent;
|
|
166
|
-
}
|
|
167
|
-
input[type='range']::-webkit-slider-runnable-track {
|
|
168
|
-
width: 100%;
|
|
169
|
-
height: 1px;
|
|
170
|
-
background: white;
|
|
171
|
-
border: none;
|
|
172
|
-
border-radius: 5px;
|
|
173
|
-
}
|
|
174
|
-
input[type='range']::-webkit-slider-thumb {
|
|
175
|
-
-webkit-appearance: none;
|
|
176
|
-
border: none;
|
|
177
|
-
height: 10px;
|
|
178
|
-
width: 10px;
|
|
179
|
-
border-radius: 50%;
|
|
180
|
-
background: white;
|
|
181
|
-
margin-top: -5px;
|
|
182
|
-
}
|
|
183
|
-
input[type='range']:focus {
|
|
184
|
-
outline: none;
|
|
185
|
-
}
|
|
186
|
-
input[type='range']:focus::-webkit-slider-runnable-track {
|
|
187
|
-
background: white;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
input[type='range']::-moz-range-track {
|
|
191
|
-
width: 100%;
|
|
192
|
-
height: 1px;
|
|
193
|
-
background: white;
|
|
194
|
-
border: none;
|
|
195
|
-
border-radius: 5px;
|
|
196
|
-
}
|
|
197
|
-
input[type='range']::-moz-range-thumb {
|
|
198
|
-
border: none;
|
|
199
|
-
height: 10px;
|
|
200
|
-
width: 10px;
|
|
201
|
-
border-radius: 50%;
|
|
202
|
-
background: white;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
input[type='range']:-moz-focusring {
|
|
206
|
-
outline: 1px solid white;
|
|
207
|
-
outline-offset: -1px;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
input[type='range']::-ms-track {
|
|
211
|
-
width: 100%;
|
|
212
|
-
height: 1px;
|
|
213
|
-
background: white;
|
|
214
|
-
border-radius: 10px;
|
|
215
|
-
color: transparent;
|
|
216
|
-
border: none;
|
|
217
|
-
outline: none;
|
|
218
|
-
}
|
|
219
|
-
input[type='range']::-ms-thumb {
|
|
220
|
-
height: 10px;
|
|
221
|
-
width: 10px;
|
|
222
|
-
border-radius: 50%;
|
|
223
|
-
background: white;
|
|
224
|
-
border: none;
|
|
225
|
-
outline: none;
|
|
226
|
-
margin-top: 2px;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
input:focus {
|
|
230
|
-
outline: none;
|
|
231
|
-
opacity: 1;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/* list of joint sliders */
|
|
235
|
-
ul {
|
|
236
|
-
flex: 1;
|
|
237
|
-
overflow-y: auto;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
li {
|
|
241
|
-
font-size: 16px;
|
|
242
|
-
display: flex;
|
|
243
|
-
align-items: center;
|
|
244
|
-
padding: 1px 0;
|
|
245
|
-
|
|
246
|
-
width: 100%;
|
|
247
|
-
user-select: text;
|
|
248
|
-
|
|
249
|
-
transition: background 0.25s ease;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
li[robot-hovered] {
|
|
253
|
-
background: rgba(255, 255, 255, 0.35);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
li:hover {
|
|
257
|
-
background: rgba(255, 255, 255, 0.35);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
li span {
|
|
261
|
-
padding: 0 5px;
|
|
262
|
-
max-width: 125px;
|
|
263
|
-
text-overflow: ellipsis;
|
|
264
|
-
overflow: hidden;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
li input[type='number'] {
|
|
268
|
-
width: 50px;
|
|
269
|
-
overflow: hidden;
|
|
270
|
-
}
|
|
271
|
-
`
|
|
272
|
-
];
|
|
273
|
-
__decorate([
|
|
274
|
-
property({ type: Object })
|
|
275
|
-
], URDFControllerElement.prototype, "viewer", void 0);
|
|
276
|
-
__decorate([
|
|
277
|
-
property({ type: Object })
|
|
278
|
-
], URDFControllerElement.prototype, "robot", void 0);
|
|
279
|
-
URDFControllerElement = __decorate([
|
|
280
|
-
customElement('urdf-controller')
|
|
281
|
-
], URDFControllerElement);
|
|
282
|
-
export default URDFControllerElement;
|
|
283
|
-
//# sourceMappingURL=urdf-controller-element.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urdf-controller-element.js","sourceRoot":"","sources":["../../src/elements/urdf-controller-element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAIjD,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG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import { customElement, property } from 'lit/decorators.js'\nimport * as THREE from 'three'\nimport { registerDragEvents } from './drag-n-drop.js'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { URDFRobot } from 'urdf-loader'\nimport URDFManipulatorElement from './urdf-manipulator-element.js'\n\nconst DEG2RAD = Math.PI / 180\nconst RAD2DEG = 1 / DEG2RAD\n\n@customElement('urdf-controller')\nexport default class URDFControllerElement extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin: 15px 0;\n overflow: hidden;\n user-select: none;\n }\n\n :host > * {\n margin: 5px 0;\n }\n\n input[type='number'] {\n color: white;\n border: none;\n font-weight: 300;\n background: rgba(255, 255, 255, 0.25);\n padding: 1px 2px;\n }\n\n ul {\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n input[type='range'] {\n -webkit-appearance: none;\n border: none;\n outline: none;\n width: 100%;\n flex: 1;\n height: 16px;\n background-color: transparent;\n }\n input[type='range']::-webkit-slider-runnable-track {\n width: 100%;\n height: 1px;\n background: white;\n border: none;\n border-radius: 5px;\n }\n input[type='range']::-webkit-slider-thumb {\n -webkit-appearance: none;\n border: none;\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background: white;\n margin-top: -5px;\n }\n input[type='range']:focus {\n outline: none;\n }\n input[type='range']:focus::-webkit-slider-runnable-track {\n background: white;\n }\n\n input[type='range']::-moz-range-track {\n width: 100%;\n height: 1px;\n background: white;\n border: none;\n border-radius: 5px;\n }\n input[type='range']::-moz-range-thumb {\n border: none;\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background: white;\n }\n\n input[type='range']:-moz-focusring {\n outline: 1px solid white;\n outline-offset: -1px;\n }\n\n input[type='range']::-ms-track {\n width: 100%;\n height: 1px;\n background: white;\n border-radius: 10px;\n color: transparent;\n border: none;\n outline: none;\n }\n input[type='range']::-ms-thumb {\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background: white;\n border: none;\n outline: none;\n margin-top: 2px;\n }\n\n input:focus {\n outline: none;\n opacity: 1;\n }\n\n /* list of joint sliders */\n ul {\n flex: 1;\n overflow-y: auto;\n }\n\n li {\n font-size: 16px;\n display: flex;\n align-items: center;\n padding: 1px 0;\n\n width: 100%;\n user-select: text;\n\n transition: background 0.25s ease;\n }\n\n li[robot-hovered] {\n background: rgba(255, 255, 255, 0.35);\n }\n\n li:hover {\n background: rgba(255, 255, 255, 0.35);\n }\n\n li span {\n padding: 0 5px;\n max-width: 125px;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n li input[type='number'] {\n width: 50px;\n overflow: hidden;\n }\n `\n ]\n\n @property({ type: Object }) viewer?: URDFManipulatorElement\n @property({ type: Object }) robot?: URDFRobot\n\n render() {\n const { joints = {} } = this.robot || {}\n const { ignoreLimits = false } = this.viewer || {}\n const jointsArray = Object.values(joints)\n\n return html`\n <ul>\n ${jointsArray.map(joint => {\n var { jointType, name, angle, limit } = joint\n var degVal: number | string = Number(angle || 0)\n\n if (jointType === 'revolute' || jointType === 'continuous') {\n degVal *= RAD2DEG\n }\n\n if (Math.abs(degVal) > 1) {\n degVal = degVal.toFixed(1)\n } else {\n degVal = degVal.toPrecision(2)\n }\n\n var sliderMin\n var sliderMax\n var inputMin\n var inputMax\n\n if (ignoreLimits || jointType === 'continuous') {\n sliderMin = -6.28\n sliderMax = 6.28\n\n inputMin = -6.28 * RAD2DEG\n inputMax = 6.28 * RAD2DEG\n } else {\n sliderMin = limit.lower\n sliderMax = limit.upper\n\n inputMin = Number(limit.lower) * RAD2DEG\n inputMax = Number(limit.upper) * RAD2DEG\n }\n\n return html`\n <li joint-type=${jointType} joint-name=${name}>\n <span title=${name}>${name}</span>\n <input\n type=\"range\"\n .value=${String(angle)}\n step=\"0.0001\"\n min=${sliderMin}\n max=${sliderMax}\n @input=${(e: Event) => {\n this.viewer?.setJointValue(name, (e.target as any).value)\n }}\n />\n <input\n type=\"number\"\n .value=${degVal}\n step=\"0.0001\"\n min=${inputMin}\n max=${inputMax}\n @change=${(e: Event) => {\n this.viewer?.setJointValue(name, Number((e.target as HTMLInputElement).value) * DEG2RAD)\n }}\n />\n </li>\n `\n })}\n </ul>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('viewer')) {\n this._setupViewer(this.viewer)\n }\n }\n\n _setupViewer(viewer?: URDFManipulatorElement) {\n if (!viewer) {\n return\n }\n\n this.robot = viewer.robot\n\n viewer.addEventListener('urdf-processed', () => {\n this.robot = viewer.robot\n })\n\n viewer.addEventListener('ignore-limits-change', () => {\n this.requestUpdate()\n })\n\n viewer.addEventListener('angle-change', (e: Event) => {\n this.requestUpdate()\n })\n\n viewer.addEventListener('joint-mouseover', (e: Event) => {\n const j = this.renderRoot.querySelector(`li[joint-name=\"${(e as CustomEvent).detail}\"]`)\n if (j) {\n j.setAttribute('robot-hovered', 'true')\n }\n })\n\n viewer.addEventListener('joint-mouseout', (e: Event) => {\n const j = this.renderRoot.querySelector(`li[joint-name=\"${(e as CustomEvent).detail}\"]`)\n if (j) {\n j.removeAttribute('robot-hovered')\n }\n })\n\n let originalNoAutoRecenter: boolean\n viewer.addEventListener('manipulate-start', (e: Event) => {\n const j = this.renderRoot.querySelector(`li[joint-name=\"${(e as CustomEvent).detail}\"]`)\n if (j) {\n // ??\n j.scrollIntoView({ block: 'nearest' })\n window.scrollTo(0, 0)\n }\n\n originalNoAutoRecenter = viewer.noAutoRecenter\n viewer.noAutoRecenter = true\n })\n\n viewer.addEventListener('manipulate-end', (e: Event) => {\n viewer.noAutoRecenter = originalNoAutoRecenter\n })\n\n registerDragEvents(viewer, () => {\n this.setColor('#263238')\n })\n }\n\n setColor(color: string) {\n this.viewer!.highlightColor = '#' + new THREE.Color(0xffffff).lerp(new THREE.Color(color), 0.35).getHexString()\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Raycaster, Vector3, Scene, Camera, Ray } from 'three';
|
|
2
|
-
import { URDFJoint } from 'urdf-loader';
|
|
3
|
-
export declare class URDFDragControls {
|
|
4
|
-
scene: Scene;
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
raycaster: Raycaster;
|
|
7
|
-
initialGrabPoint: Vector3;
|
|
8
|
-
hitDistance: number;
|
|
9
|
-
hovered: any;
|
|
10
|
-
manipulating: any;
|
|
11
|
-
constructor(scene: Scene);
|
|
12
|
-
update(): void;
|
|
13
|
-
updateJoint(joint: URDFJoint, angle: number): void;
|
|
14
|
-
onDragStart(joint: URDFJoint): void;
|
|
15
|
-
onDragEnd(joint: URDFJoint): void;
|
|
16
|
-
onHover(joint: URDFJoint): void;
|
|
17
|
-
onUnhover(joint: URDFJoint): void;
|
|
18
|
-
getRevoluteDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3): number;
|
|
19
|
-
getPrismaticDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3): number;
|
|
20
|
-
moveRay(toRay: Ray): void;
|
|
21
|
-
setGrabbed(grabbed: boolean): void;
|
|
22
|
-
}
|
|
23
|
-
export declare class PointerURDFDragControls extends URDFDragControls {
|
|
24
|
-
camera: Camera;
|
|
25
|
-
domElement: HTMLElement;
|
|
26
|
-
_mouseDown: (e: MouseEvent) => void;
|
|
27
|
-
_mouseMove: (e: MouseEvent) => void;
|
|
28
|
-
_mouseUp: (e: MouseEvent) => void;
|
|
29
|
-
constructor(scene: Scene, camera: Camera, domElement: HTMLElement);
|
|
30
|
-
getRevoluteDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3): number;
|
|
31
|
-
dispose(): void;
|
|
32
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { Raycaster, Vector3, Plane, Vector2 } from 'three';
|
|
2
|
-
// Find the nearest parent that is a joint
|
|
3
|
-
function isJoint(j) {
|
|
4
|
-
return j.isURDFJoint && j.jointType !== 'fixed';
|
|
5
|
-
}
|
|
6
|
-
function findNearestJoint(child) {
|
|
7
|
-
let curr = child;
|
|
8
|
-
while (curr) {
|
|
9
|
-
if (isJoint(curr)) {
|
|
10
|
-
return curr;
|
|
11
|
-
}
|
|
12
|
-
curr = curr.parent;
|
|
13
|
-
}
|
|
14
|
-
return curr;
|
|
15
|
-
}
|
|
16
|
-
const prevHitPoint = new Vector3();
|
|
17
|
-
const newHitPoint = new Vector3();
|
|
18
|
-
const pivotPoint = new Vector3();
|
|
19
|
-
const tempVector = new Vector3();
|
|
20
|
-
const tempVector2 = new Vector3();
|
|
21
|
-
const projectedStartPoint = new Vector3();
|
|
22
|
-
const projectedEndPoint = new Vector3();
|
|
23
|
-
const plane = new Plane();
|
|
24
|
-
export class URDFDragControls {
|
|
25
|
-
constructor(scene) {
|
|
26
|
-
this.enabled = true;
|
|
27
|
-
this.scene = scene;
|
|
28
|
-
this.raycaster = new Raycaster();
|
|
29
|
-
this.initialGrabPoint = new Vector3();
|
|
30
|
-
this.hitDistance = -1;
|
|
31
|
-
this.hovered = null;
|
|
32
|
-
this.manipulating = null;
|
|
33
|
-
}
|
|
34
|
-
update() {
|
|
35
|
-
const { raycaster, hovered, manipulating, scene } = this;
|
|
36
|
-
if (manipulating) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
let hoveredJoint = null;
|
|
40
|
-
const intersections = raycaster.intersectObject(scene, true);
|
|
41
|
-
if (intersections.length !== 0) {
|
|
42
|
-
const hit = intersections[0];
|
|
43
|
-
this.hitDistance = hit.distance;
|
|
44
|
-
hoveredJoint = findNearestJoint(hit.object);
|
|
45
|
-
this.initialGrabPoint.copy(hit.point);
|
|
46
|
-
}
|
|
47
|
-
if (hoveredJoint !== hovered) {
|
|
48
|
-
if (hovered) {
|
|
49
|
-
this.onUnhover(hovered);
|
|
50
|
-
}
|
|
51
|
-
this.hovered = hoveredJoint;
|
|
52
|
-
if (hoveredJoint) {
|
|
53
|
-
this.onHover(hoveredJoint);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
updateJoint(joint, angle) {
|
|
58
|
-
joint.setJointValue(angle);
|
|
59
|
-
}
|
|
60
|
-
onDragStart(joint) { }
|
|
61
|
-
onDragEnd(joint) { }
|
|
62
|
-
onHover(joint) { }
|
|
63
|
-
onUnhover(joint) { }
|
|
64
|
-
getRevoluteDelta(joint, startPoint, endPoint) {
|
|
65
|
-
// set up the plane
|
|
66
|
-
tempVector.copy(joint.axis).transformDirection(joint.matrixWorld).normalize();
|
|
67
|
-
pivotPoint.set(0, 0, 0).applyMatrix4(joint.matrixWorld);
|
|
68
|
-
plane.setFromNormalAndCoplanarPoint(tempVector, pivotPoint);
|
|
69
|
-
// project the drag points onto the plane
|
|
70
|
-
plane.projectPoint(startPoint, projectedStartPoint);
|
|
71
|
-
plane.projectPoint(endPoint, projectedEndPoint);
|
|
72
|
-
// get the directions relative to the pivot
|
|
73
|
-
projectedStartPoint.sub(pivotPoint);
|
|
74
|
-
projectedEndPoint.sub(pivotPoint);
|
|
75
|
-
tempVector.crossVectors(projectedStartPoint, projectedEndPoint);
|
|
76
|
-
const direction = Math.sign(tempVector.dot(plane.normal));
|
|
77
|
-
return direction * projectedEndPoint.angleTo(projectedStartPoint);
|
|
78
|
-
}
|
|
79
|
-
getPrismaticDelta(joint, startPoint, endPoint) {
|
|
80
|
-
tempVector.subVectors(endPoint, startPoint);
|
|
81
|
-
plane.normal.copy(joint.axis).transformDirection(joint.parent.matrixWorld).normalize();
|
|
82
|
-
return tempVector.dot(plane.normal);
|
|
83
|
-
}
|
|
84
|
-
moveRay(toRay) {
|
|
85
|
-
const { raycaster, hitDistance, manipulating } = this;
|
|
86
|
-
const { ray } = raycaster;
|
|
87
|
-
if (manipulating) {
|
|
88
|
-
ray.at(hitDistance, prevHitPoint);
|
|
89
|
-
toRay.at(hitDistance, newHitPoint);
|
|
90
|
-
let delta = 0;
|
|
91
|
-
if (manipulating.jointType === 'revolute' || manipulating.jointType === 'continuous') {
|
|
92
|
-
delta = this.getRevoluteDelta(manipulating, prevHitPoint, newHitPoint);
|
|
93
|
-
}
|
|
94
|
-
else if (manipulating.jointType === 'prismatic') {
|
|
95
|
-
delta = this.getPrismaticDelta(manipulating, prevHitPoint, newHitPoint);
|
|
96
|
-
}
|
|
97
|
-
if (delta) {
|
|
98
|
-
this.updateJoint(manipulating, manipulating.angle + delta);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
this.raycaster.ray.copy(toRay);
|
|
102
|
-
this.update();
|
|
103
|
-
}
|
|
104
|
-
setGrabbed(grabbed) {
|
|
105
|
-
const { hovered, manipulating } = this;
|
|
106
|
-
if (grabbed) {
|
|
107
|
-
if (manipulating !== null || hovered === null) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.manipulating = hovered;
|
|
111
|
-
this.onDragStart(hovered);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
if (this.manipulating === null) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
this.onDragEnd(this.manipulating);
|
|
118
|
-
this.manipulating = null;
|
|
119
|
-
this.update();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export class PointerURDFDragControls extends URDFDragControls {
|
|
124
|
-
constructor(scene, camera, domElement) {
|
|
125
|
-
super(scene);
|
|
126
|
-
this.camera = camera;
|
|
127
|
-
this.domElement = domElement;
|
|
128
|
-
const raycaster = new Raycaster();
|
|
129
|
-
const mouse = new Vector2();
|
|
130
|
-
function updateMouse(e) {
|
|
131
|
-
mouse.x = (e.offsetX / domElement.offsetWidth) * 2 - 1;
|
|
132
|
-
mouse.y = -(e.offsetY / domElement.offsetHeight) * 2 + 1;
|
|
133
|
-
}
|
|
134
|
-
this._mouseDown = (e) => {
|
|
135
|
-
updateMouse(e);
|
|
136
|
-
raycaster.setFromCamera(mouse, this.camera);
|
|
137
|
-
this.moveRay(raycaster.ray);
|
|
138
|
-
this.setGrabbed(true);
|
|
139
|
-
};
|
|
140
|
-
this._mouseMove = (e) => {
|
|
141
|
-
updateMouse(e);
|
|
142
|
-
raycaster.setFromCamera(mouse, this.camera);
|
|
143
|
-
this.moveRay(raycaster.ray);
|
|
144
|
-
};
|
|
145
|
-
this._mouseUp = (e) => {
|
|
146
|
-
updateMouse(e);
|
|
147
|
-
raycaster.setFromCamera(mouse, this.camera);
|
|
148
|
-
this.moveRay(raycaster.ray);
|
|
149
|
-
this.setGrabbed(false);
|
|
150
|
-
};
|
|
151
|
-
domElement.addEventListener('pointerdown', this._mouseDown);
|
|
152
|
-
domElement.addEventListener('pointermove', this._mouseMove);
|
|
153
|
-
domElement.addEventListener('pointerup', this._mouseUp);
|
|
154
|
-
}
|
|
155
|
-
getRevoluteDelta(joint, startPoint, endPoint) {
|
|
156
|
-
const { camera, initialGrabPoint } = this;
|
|
157
|
-
// set up the plane
|
|
158
|
-
tempVector.copy(joint.axis).transformDirection(joint.matrixWorld).normalize();
|
|
159
|
-
pivotPoint.set(0, 0, 0).applyMatrix4(joint.matrixWorld);
|
|
160
|
-
plane.setFromNormalAndCoplanarPoint(tempVector, pivotPoint);
|
|
161
|
-
tempVector.copy(camera.position).sub(initialGrabPoint).normalize();
|
|
162
|
-
// if looking into the plane of rotation
|
|
163
|
-
if (Math.abs(tempVector.dot(plane.normal)) > 0.3) {
|
|
164
|
-
return super.getRevoluteDelta(joint, startPoint, endPoint);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
// get the up direction
|
|
168
|
-
tempVector.set(0, 1, 0).transformDirection(camera.matrixWorld);
|
|
169
|
-
// get points projected onto the plane of rotation
|
|
170
|
-
plane.projectPoint(startPoint, projectedStartPoint);
|
|
171
|
-
plane.projectPoint(endPoint, projectedEndPoint);
|
|
172
|
-
tempVector.set(0, 0, -1).transformDirection(camera.matrixWorld);
|
|
173
|
-
tempVector.cross(plane.normal);
|
|
174
|
-
tempVector2.subVectors(endPoint, startPoint);
|
|
175
|
-
return tempVector.dot(tempVector2);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
dispose() {
|
|
179
|
-
const { domElement } = this;
|
|
180
|
-
domElement.removeEventListener('pointerdown', this._mouseDown);
|
|
181
|
-
domElement.removeEventListener('pointermove', this._mouseMove);
|
|
182
|
-
domElement.removeEventListener('pointerup', this._mouseUp);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
//# sourceMappingURL=urdf-drag-controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urdf-drag-controls.js","sourceRoot":"","sources":["../../src/elements/urdf-drag-controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgC,MAAM,OAAO,CAAA;AAGxF,0CAA0C;AAC1C,SAAS,OAAO,CAAC,CAAY;IAC3B,OAAO,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,SAAS,KAAK,OAAO,CAAA;AACjD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAe;IACvC,IAAI,IAAI,GAAoB,KAAK,CAAA;IACjC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,OAAO,CAAC,IAAiB,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,OAAO,EAAE,CAAA;AAClC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE,CAAA;AACjC,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAA;AAChC,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAA;AAChC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE,CAAA;AACjC,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAE,CAAA;AACzC,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAE,CAAA;AACvC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAA;AACzB,MAAM,OAAO,gBAAgB;IAW3B,YAAY,KAAY;Q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AAC,UAAU,CAAC,CAAA;QAC9D,UAAU,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC5D,CAAC;CACF","sourcesContent":["import { Raycaster, Vector3, Plane, Vector2, Scene, Camera, Object3D, Ray } from 'three'\nimport { URDFJoint } from 'urdf-loader'\n\n// Find the nearest parent that is a joint\nfunction isJoint(j: URDFJoint) {\n return j.isURDFJoint && j.jointType !== 'fixed'\n}\n\nfunction findNearestJoint(child: Object3D) {\n let curr: Object3D | null = child\n while (curr) {\n if (isJoint(curr as URDFJoint)) {\n return curr\n }\n\n curr = curr.parent\n }\n\n return curr\n}\n\nconst prevHitPoint = new Vector3()\nconst newHitPoint = new Vector3()\nconst pivotPoint = new Vector3()\nconst tempVector = new Vector3()\nconst tempVector2 = new Vector3()\nconst projectedStartPoint = new Vector3()\nconst projectedEndPoint = new Vector3()\nconst plane = new Plane()\nexport class URDFDragControls {\n scene: Scene\n\n enabled: boolean\n raycaster: Raycaster\n initialGrabPoint: Vector3\n hitDistance: number\n\n hovered: any\n manipulating: any\n\n constructor(scene: Scene) {\n this.enabled = true\n this.scene = scene\n\n this.raycaster = new Raycaster()\n this.initialGrabPoint = new Vector3()\n\n this.hitDistance = -1\n this.hovered = null\n this.manipulating = null\n }\n\n update() {\n const { raycaster, hovered, manipulating, scene } = this\n\n if (manipulating) {\n return\n }\n\n let hoveredJoint = null\n const intersections = raycaster.intersectObject(scene, true)\n if (intersections.length !== 0) {\n const hit = intersections[0]\n this.hitDistance = hit.distance\n hoveredJoint = findNearestJoint(hit.object)\n this.initialGrabPoint.copy(hit.point)\n }\n\n if (hoveredJoint !== hovered) {\n if (hovered) {\n this.onUnhover(hovered)\n }\n\n this.hovered = hoveredJoint\n\n if (hoveredJoint) {\n this.onHover(hoveredJoint as URDFJoint)\n }\n }\n }\n\n updateJoint(joint: URDFJoint, angle: number) {\n joint.setJointValue(angle)\n }\n\n onDragStart(joint: URDFJoint) {}\n\n onDragEnd(joint: URDFJoint) {}\n\n onHover(joint: URDFJoint) {}\n\n onUnhover(joint: URDFJoint) {}\n\n getRevoluteDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3) {\n // set up the plane\n tempVector.copy(joint.axis).transformDirection(joint.matrixWorld).normalize()\n pivotPoint.set(0, 0, 0).applyMatrix4(joint.matrixWorld)\n plane.setFromNormalAndCoplanarPoint(tempVector, pivotPoint)\n\n // project the drag points onto the plane\n plane.projectPoint(startPoint, projectedStartPoint)\n plane.projectPoint(endPoint, projectedEndPoint)\n\n // get the directions relative to the pivot\n projectedStartPoint.sub(pivotPoint)\n projectedEndPoint.sub(pivotPoint)\n\n tempVector.crossVectors(projectedStartPoint, projectedEndPoint)\n\n const direction = Math.sign(tempVector.dot(plane.normal))\n return direction * projectedEndPoint.angleTo(projectedStartPoint)\n }\n\n getPrismaticDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3) {\n tempVector.subVectors(endPoint, startPoint)\n plane.normal.copy(joint.axis).transformDirection(joint.parent!.matrixWorld).normalize()\n\n return tempVector.dot(plane.normal)\n }\n\n moveRay(toRay: Ray) {\n const { raycaster, hitDistance, manipulating } = this\n const { ray } = raycaster\n\n if (manipulating) {\n ray.at(hitDistance, prevHitPoint)\n toRay.at(hitDistance, newHitPoint)\n\n let delta = 0\n if (manipulating.jointType === 'revolute' || manipulating.jointType === 'continuous') {\n delta = this.getRevoluteDelta(manipulating, prevHitPoint, newHitPoint)\n } else if (manipulating.jointType === 'prismatic') {\n delta = this.getPrismaticDelta(manipulating, prevHitPoint, newHitPoint)\n }\n\n if (delta) {\n this.updateJoint(manipulating, manipulating.angle + delta)\n }\n }\n\n this.raycaster.ray.copy(toRay)\n this.update()\n }\n\n setGrabbed(grabbed: boolean) {\n const { hovered, manipulating } = this\n if (grabbed) {\n if (manipulating !== null || hovered === null) {\n return\n }\n\n this.manipulating = hovered\n this.onDragStart(hovered)\n } else {\n if (this.manipulating === null) {\n return\n }\n\n this.onDragEnd(this.manipulating)\n this.manipulating = null\n this.update()\n }\n }\n}\n\nexport class PointerURDFDragControls extends URDFDragControls {\n camera: Camera\n domElement: HTMLElement\n\n _mouseDown: (e: MouseEvent) => void\n _mouseMove: (e: MouseEvent) => void\n _mouseUp: (e: MouseEvent) => void\n\n constructor(scene: Scene, camera: Camera, domElement: HTMLElement) {\n super(scene)\n\n this.camera = camera\n this.domElement = domElement\n\n const raycaster = new Raycaster()\n const mouse = new Vector2()\n\n function updateMouse(e: MouseEvent) {\n mouse.x = (e.offsetX / domElement.offsetWidth) * 2 - 1\n mouse.y = -(e.offsetY / domElement.offsetHeight) * 2 + 1\n }\n\n this._mouseDown = (e: MouseEvent) => {\n updateMouse(e)\n raycaster.setFromCamera(mouse, this.camera)\n this.moveRay(raycaster.ray)\n this.setGrabbed(true)\n }\n\n this._mouseMove = (e: MouseEvent) => {\n updateMouse(e)\n raycaster.setFromCamera(mouse, this.camera)\n this.moveRay(raycaster.ray)\n }\n\n this._mouseUp = (e: MouseEvent) => {\n updateMouse(e)\n raycaster.setFromCamera(mouse, this.camera)\n this.moveRay(raycaster.ray)\n this.setGrabbed(false)\n }\n\n domElement.addEventListener('pointerdown', this._mouseDown)\n domElement.addEventListener('pointermove', this._mouseMove)\n domElement.addEventListener('pointerup', this._mouseUp)\n }\n\n getRevoluteDelta(joint: URDFJoint, startPoint: Vector3, endPoint: Vector3) {\n const { camera, initialGrabPoint } = this\n\n // set up the plane\n tempVector.copy(joint.axis).transformDirection(joint.matrixWorld).normalize()\n pivotPoint.set(0, 0, 0).applyMatrix4(joint.matrixWorld)\n plane.setFromNormalAndCoplanarPoint(tempVector, pivotPoint)\n\n tempVector.copy(camera.position).sub(initialGrabPoint).normalize()\n\n // if looking into the plane of rotation\n if (Math.abs(tempVector.dot(plane.normal)) > 0.3) {\n return super.getRevoluteDelta(joint, startPoint, endPoint)\n } else {\n // get the up direction\n tempVector.set(0, 1, 0).transformDirection(camera.matrixWorld)\n\n // get points projected onto the plane of rotation\n plane.projectPoint(startPoint, projectedStartPoint)\n plane.projectPoint(endPoint, projectedEndPoint)\n\n tempVector.set(0, 0, -1).transformDirection(camera.matrixWorld)\n tempVector.cross(plane.normal)\n tempVector2.subVectors(endPoint, startPoint)\n\n return tempVector.dot(tempVector2)\n }\n }\n\n dispose() {\n const { domElement } = this\n domElement.removeEventListener('pointerdown', this._mouseDown)\n domElement.removeEventListener('pointermove', this._mouseMove)\n domElement.removeEventListener('pointerup', this._mouseUp)\n }\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PointerURDFDragControls } from './urdf-drag-controls.js';
|
|
2
|
-
import { MeshPhongMaterial } from 'three';
|
|
3
|
-
import URDFViewerElement from './urdf-viewer-element.js';
|
|
4
|
-
export default class URDFManipulatorElement extends URDFViewerElement {
|
|
5
|
-
static get observedAttributes(): string[];
|
|
6
|
-
highlightMaterial: MeshPhongMaterial;
|
|
7
|
-
dragControls: PointerURDFDragControls;
|
|
8
|
-
get disableDragging(): boolean;
|
|
9
|
-
set disableDragging(val: boolean);
|
|
10
|
-
get highlightColor(): string;
|
|
11
|
-
set highlightColor(val: string);
|
|
12
|
-
constructor();
|
|
13
|
-
disconnectedCallback(): void;
|
|
14
|
-
attributeChangedCallback(attr: string, oldval: any, newval: any): void;
|
|
15
|
-
}
|