-
Notifications
You must be signed in to change notification settings - Fork 47
/
ros-rviz-grid.html
82 lines (74 loc) · 1.9 KB
/
ros-rviz-grid.html
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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="imports.html">
<dom-module id="ros-rviz-grid">
<template>
<paper-input label="Cell size (m)" value="{{cellSize}}"></paper-input>
<paper-input label="Color" value="{{color}}"></paper-input>
<paper-input label="# cells per side" value="{{numCells}}"></paper-input>
</template>
<script>
Polymer({
is: 'ros-rviz-grid',
properties: {
cellSize: {
notify: true,
type: Number,
value: 1,
},
color: {
type: String,
value: '#cccccc',
notify: true,
},
isShown: Boolean,
name: {
type: String,
value: 'Grid',
},
numCells: {
notify: true,
type: Number,
value: 10,
},
viewer: {
type: Object,
},
_grid: Object,
},
observers: [
'_optionsChanged(viewer, cellSize, color, numCells)',
],
destroy: function() {
// Nothing to destroy.
},
hide: function() {
if (this.viewer) {
this.viewer.scene.remove(this._grid);
}
},
show: function() {
if (this.viewer && this.isShown) {
this.viewer.scene.remove(this._grid);
this.viewer.addObject(this._grid);
}
},
_optionsChanged: function(viewer, cellSize, color, numCells) {
this.hide();
this._updateGrid();
this.show();
},
_updateGrid: function() {
if (this.viewer) {
this.viewer.scene.remove(this._grid);
}
this._grid = new ROS3D.Grid({
cellSize: this.cellSize,
color: this.color,
lineWidth: this.lineWidth,
num_cells: this.numCells,
});
},
});
</script>
</dom-module>