@@ -30,7 +30,6 @@ export class UrdfWidget extends DocumentWidget<UrdfPanel, DocumentModel> {
30
30
/**
31
31
* UrdfPanel: widget that contains the main view of the UrdfWidget.
32
32
*/
33
-
34
33
export class UrdfPanel extends Panel {
35
34
private _context : DocumentRegistry . IContext < DocumentModel > ;
36
35
@@ -40,22 +39,18 @@ export class UrdfPanel extends Panel {
40
39
* @param context - The documents context
41
40
*/
42
41
constructor ( context : DocumentRegistry . IContext < DocumentModel > ) {
43
- super ( {
44
- layout : new URDFLayout ( )
45
- } ) ;
42
+ super ( { layout : new URDFLayout ( ) } ) ;
43
+
46
44
this . addClass ( 'jp-urdf-canvas' ) ; // for css styling
47
45
this . _context = context ;
48
46
49
47
this . _context . ready . then ( value => {
50
- // TODO
51
48
( this . layout as URDFLayout ) . setURDF ( this . _context . model . toString ( ) ) ;
52
49
this . _context . model . contentChanged . connect ( ( sender , args ) => {
53
50
console . log ( "Model changed." , args ) ;
54
51
( this . layout as URDFLayout ) . setURDF ( this . _context . model . toString ( ) ) ;
55
52
} ) ;
56
53
} ) ;
57
-
58
- // TODO
59
54
}
60
55
61
56
// Dispose of resources held by widget
@@ -74,7 +69,6 @@ export class UrdfPanel extends Panel {
74
69
*/
75
70
protected onAfterAttach ( msg : Message ) : void {
76
71
super . onAfterAttach ( msg ) ;
77
- // TODO
78
72
}
79
73
80
74
/**
@@ -84,7 +78,6 @@ export class UrdfPanel extends Panel {
84
78
*/
85
79
protected onBeforeDetach ( msg : Message ) : void {
86
80
super . onBeforeDetach ( msg ) ;
87
- // TODO
88
81
}
89
82
90
83
/**
@@ -93,166 +86,5 @@ export class UrdfPanel extends Panel {
93
86
* @param event - Event on the widget
94
87
*/
95
88
public handleEvent ( event : MouseEvent ) : void {
96
- // TODO
97
89
}
98
90
}
99
- // export class UrdfPanel extends Widget {
100
- // /**
101
- // * Construct a UrdfPanel
102
- // *
103
- // * @param context - The documents context
104
- // */
105
- // constructor(context: DocumentRegistry.IContext<DocumentModel>) {
106
- // super();
107
- // this.id = 'canvasP';
108
- // this.addClass('jp-urdf-canvas'); // for css styling
109
- // this._context = context;
110
- // // this._isDown = false;
111
- // // this._offset = { x: 0, y: 0};
112
-
113
-
114
- // this._context.ready.then((value) => {
115
- // // TODO
116
- // this.update();
117
- // });
118
-
119
-
120
-
121
- // // TODO
122
- // // const obj = this._context.model.getSharedObject();
123
- // this._canvas = document.createElement('div');
124
- // this._canvas.className = 'jp-urdf-canvas';
125
- // this._canvas.style.left = '0px';
126
- // this._canvas.innerText = 'URDF ROBOT';
127
- // // this.node.appendChild(this._canvas);
128
-
129
- // // URDF Loader
130
- // this._scene = new Scene();
131
- // this._scene.background = new Color(0x263238);
132
-
133
- // this._camera = new PerspectiveCamera();
134
- // this._camera.position.set(10, 10, 10);
135
- // this._camera.lookAt(0, 0, 0);
136
-
137
- // this._renderer = new WebGLRenderer({ antialias: true });
138
- // this._renderer.outputEncoding = sRGBEncoding;
139
- // this._renderer.shadowMap.enable = true;
140
- // this._renderer.shadowMap.type = PCFSoftShadowMap;
141
-
142
- // const directionalLight = new DirectionalLight(0xffffff, 1.0);
143
- // directionalLight.castShadow = true;
144
- // directionalLight.shadow.mapSize.setScalar(1024);
145
- // directionalLight.position.set(5, 30, 5);
146
- // this._scene.add(directionalLight);
147
-
148
- // const ambientLight = new AmbientLight(0xffffff, 0.2);
149
- // this._scene.add(ambientLight);
150
-
151
- // const ground = new Mesh(new PlaneBufferGeometry(),
152
- // new ShadowMaterial({ opacity: 0.25}));
153
- // ground.rotation.x = -Math.PI / 2;
154
- // ground.scale.setScalar(30);
155
- // ground.receiveShadow = true;
156
- // this._scene.add(ground);
157
-
158
- // // TODO import orbit controls
159
-
160
- // // Load Robot
161
- // this._manager = new LoadingManager();
162
- // this._loader = new URDFLoader(this._manager);
163
-
164
- // // this._loader.load(context.path, (result: any) => {
165
- // // this._robot = result;
166
- // // });
167
-
168
- // this._robot = this._loader.parse(context.model.value.text);
169
-
170
-
171
- // // Wait until all geometry has been loaded to add model to scene
172
- // this._manager.onLoad = () => {
173
- // this._robot.rotation.x = Math.PI / 2;
174
- // this._robot.traverse((c : any) => {
175
- // c.castShadow = true;
176
- // });
177
- // for (let i = 1; i <=6; i++) {
178
- // this._robot.joints[`HP${ i }`].setJointValue(MathUtils.degToRad(30));
179
- // this._robot.joints[`KP${ i }`].setJointValue(MathUtils.degToRad(120));
180
- // this._robot.joints[`AP${ i }`].setJointValue(MathUtils.degToRad(-60));
181
- // }
182
- // this._robot.updateMatrixWorld(true);
183
-
184
- // const bb = new Box3();
185
- // bb.setFromObject(this._robot);
186
-
187
- // this._robot.position.y -= bb.min.y;
188
- // this._scene.add(this._robot);
189
- // };
190
-
191
- // // TODO add onResize()
192
-
193
- // this._renderer.render(this._scene, this._camera);
194
-
195
- // this.node.appendChild(this._renderer.domElement);
196
-
197
-
198
- // }
199
-
200
- // // Dispose of resources held by widget
201
- // dispose(): void {
202
- // if (this.isDisposed) {
203
- // return;
204
- // }
205
- // Signal.clearData(this);
206
- // super.dispose();
207
- // }
208
-
209
- // /**
210
- // * Handle after-attach messages sent to widget
211
- // *
212
- // * @param msg - Widget layout message
213
- // */
214
- // protected onAfterAttach(msg: Message): void {
215
- // super.onAfterAttach(msg);
216
- // // this._cube.addEventListener('mousedown', this, true);
217
- // // TODO
218
- // }
219
-
220
- // /**
221
- // * Handle before-detach messages sent to widget
222
- // *
223
- // * @param msg - Widget layout message
224
- // */
225
- // protected onBeforeDetach(msg: Message): void {
226
- // super.onBeforeDetach(msg);
227
- // // this._cube.removeEventListener('mousedown', this, true);
228
- // // TODO
229
- // }
230
-
231
- // /**
232
- // * Handle event messages sent to widget
233
- // *
234
- // * @param event - Event on the widget
235
- // */
236
- // public handleEvent(event: MouseEvent): void {
237
- // event.preventDefault();
238
- // event.stopPropagation();
239
-
240
- // // TODO
241
- // }
242
-
243
-
244
- // private _context: DocumentRegistry.IContext<DocumentModel>;
245
- // private _canvas: HTMLElement;
246
- // // private _isDown: boolean;
247
- // // private _offset: Position;
248
- // // private _cube: HTMLElement;
249
-
250
- // // URDF Loader variables
251
- // private _scene: any;
252
- // private _camera: any;
253
- // private _renderer: any;
254
- // private _robot: any;
255
- // // private _controls: any;
256
- // private _manager: any;
257
- // private _loader: any;
258
- // }
0 commit comments