pubo-web 1.0.4-alpha.0

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.
Files changed (50) hide show
  1. package/dist/pubo-web.js +13 -0
  2. package/es/file/download.d.ts +1 -0
  3. package/es/file/download.js +14 -0
  4. package/es/file/parser.d.ts +3 -0
  5. package/es/file/parser.js +35 -0
  6. package/es/index.d.ts +7 -0
  7. package/es/index.js +7 -0
  8. package/es/load-script/index.d.ts +1 -0
  9. package/es/load-script/index.js +88 -0
  10. package/es/ros/factory/configure.d.ts +14 -0
  11. package/es/ros/factory/configure.js +230 -0
  12. package/es/ros/factory/index.d.ts +32 -0
  13. package/es/ros/factory/index.js +116 -0
  14. package/es/ros/factory/super.d.ts +11 -0
  15. package/es/ros/factory/super.js +43 -0
  16. package/es/ros/index.d.ts +7 -0
  17. package/es/ros/index.js +10 -0
  18. package/es/ros/ros3d/inject.d.ts +6 -0
  19. package/es/ros/ros3d/inject.js +39 -0
  20. package/es/ros/ros3d/utils.d.ts +11 -0
  21. package/es/ros/ros3d/utils.js +249 -0
  22. package/es/ros/ros3d/viewer.d.ts +19 -0
  23. package/es/ros/ros3d/viewer.js +244 -0
  24. package/es/storage/index.d.ts +16 -0
  25. package/es/storage/index.js +65 -0
  26. package/lib/file/download.d.ts +1 -0
  27. package/lib/file/download.js +21 -0
  28. package/lib/file/parser.d.ts +3 -0
  29. package/lib/file/parser.js +44 -0
  30. package/lib/index.d.ts +7 -0
  31. package/lib/index.js +72 -0
  32. package/lib/load-script/index.d.ts +1 -0
  33. package/lib/load-script/index.js +95 -0
  34. package/lib/ros/factory/configure.d.ts +14 -0
  35. package/lib/ros/factory/configure.js +243 -0
  36. package/lib/ros/factory/index.d.ts +32 -0
  37. package/lib/ros/factory/index.js +130 -0
  38. package/lib/ros/factory/super.d.ts +11 -0
  39. package/lib/ros/factory/super.js +50 -0
  40. package/lib/ros/index.d.ts +7 -0
  41. package/lib/ros/index.js +19 -0
  42. package/lib/ros/ros3d/inject.d.ts +6 -0
  43. package/lib/ros/ros3d/inject.js +46 -0
  44. package/lib/ros/ros3d/utils.d.ts +11 -0
  45. package/lib/ros/ros3d/utils.js +272 -0
  46. package/lib/ros/ros3d/viewer.d.ts +19 -0
  47. package/lib/ros/ros3d/viewer.js +259 -0
  48. package/lib/storage/index.d.ts +16 -0
  49. package/lib/storage/index.js +72 -0
  50. package/package.json +26 -0
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
20
+ function adopt(value) {
21
+ return value instanceof P ? value : new P(function (resolve) {
22
+ resolve(value);
23
+ });
24
+ }
25
+
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) {
28
+ try {
29
+ step(generator.next(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ }
34
+
35
+ function rejected(value) {
36
+ try {
37
+ step(generator["throw"](value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ }
42
+
43
+ function step(result) {
44
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
+ }
46
+
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+
51
+ var __generator = this && this.__generator || function (thisArg, body) {
52
+ var _ = {
53
+ label: 0,
54
+ sent: function sent() {
55
+ if (t[0] & 1) throw t[1];
56
+ return t[1];
57
+ },
58
+ trys: [],
59
+ ops: []
60
+ },
61
+ f,
62
+ y,
63
+ t,
64
+ g;
65
+ return g = {
66
+ next: verb(0),
67
+ "throw": verb(1),
68
+ "return": verb(2)
69
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
70
+ return this;
71
+ }), g;
72
+
73
+ function verb(n) {
74
+ return function (v) {
75
+ return step([n, v]);
76
+ };
77
+ }
78
+
79
+ function step(op) {
80
+ if (f) throw new TypeError("Generator is already executing.");
81
+
82
+ while (_) {
83
+ try {
84
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
85
+ if (y = 0, t) op = [op[0] & 2, t.value];
86
+
87
+ switch (op[0]) {
88
+ case 0:
89
+ case 1:
90
+ t = op;
91
+ break;
92
+
93
+ case 4:
94
+ _.label++;
95
+ return {
96
+ value: op[1],
97
+ done: false
98
+ };
99
+
100
+ case 5:
101
+ _.label++;
102
+ y = op[1];
103
+ op = [0];
104
+ continue;
105
+
106
+ case 7:
107
+ op = _.ops.pop();
108
+
109
+ _.trys.pop();
110
+
111
+ continue;
112
+
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
+ _ = 0;
116
+ continue;
117
+ }
118
+
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+
124
+ if (op[0] === 6 && _.label < t[1]) {
125
+ _.label = t[1];
126
+ t = op;
127
+ break;
128
+ }
129
+
130
+ if (t && _.label < t[2]) {
131
+ _.label = t[2];
132
+
133
+ _.ops.push(op);
134
+
135
+ break;
136
+ }
137
+
138
+ if (t[2]) _.ops.pop();
139
+
140
+ _.trys.pop();
141
+
142
+ continue;
143
+ }
144
+
145
+ op = body.call(thisArg, _);
146
+ } catch (e) {
147
+ op = [6, e];
148
+ y = 0;
149
+ } finally {
150
+ f = t = 0;
151
+ }
152
+ }
153
+
154
+ if (op[0] & 5) throw op[1];
155
+ return {
156
+ value: op[0] ? op[1] : void 0,
157
+ done: true
158
+ };
159
+ }
160
+ };
161
+
162
+ var __importDefault = this && this.__importDefault || function (mod) {
163
+ return mod && mod.__esModule ? mod : {
164
+ "default": mod
165
+ };
166
+ };
167
+
168
+ Object.defineProperty(exports, "__esModule", {
169
+ value: true
170
+ });
171
+ exports.basePointCloudOptions = exports.loadLib = exports.colormap = exports.getRainbowColor = void 0;
172
+
173
+ var roslib_1 = __importDefault(require("roslib"));
174
+
175
+ var load_script_1 = require("../../load-script");
176
+
177
+ function getRainbowColor(pct) {
178
+ var h = (1 - pct) * 5.0 + 1.0;
179
+ var i = Math.floor(h);
180
+ var f = h % 1.0;
181
+
182
+ if ((i & 1) === 0) {
183
+ f = 1 - f;
184
+ }
185
+
186
+ var n = 1 - f;
187
+ var dic = [{
188
+ r: n,
189
+ g: 0,
190
+ b: 1
191
+ }, {
192
+ r: 0,
193
+ g: n,
194
+ b: 1
195
+ }, {
196
+ r: 0,
197
+ g: 1,
198
+ b: n
199
+ }, {
200
+ r: n,
201
+ g: 1,
202
+ b: 0
203
+ }, {
204
+ r: 1,
205
+ g: n,
206
+ b: 0
207
+ }];
208
+
209
+ if (i < 1) {
210
+ i = 1;
211
+ }
212
+
213
+ var temp = dic[i - 1] || dic[4];
214
+ Object.keys(temp).forEach(function (key) {
215
+ return temp[key] = temp[key] * 255;
216
+ });
217
+ return __assign(__assign({}, temp), {
218
+ a: 1
219
+ });
220
+ }
221
+
222
+ exports.getRainbowColor = getRainbowColor;
223
+
224
+ function colormap(x) {
225
+ var minColorValue = 0;
226
+ var maxColorValue = 512 * 512 * 512;
227
+ var colorFieldRange = maxColorValue - minColorValue || Infinity;
228
+ var pct = Math.max(0, Math.min((Math.pow(x, 4) - minColorValue) / colorFieldRange, 1));
229
+ return getRainbowColor(pct);
230
+ }
231
+
232
+ exports.colormap = colormap;
233
+
234
+ function loadLib(url) {
235
+ return __awaiter(this, void 0, void 0, function () {
236
+ return __generator(this, function (_a) {
237
+ switch (_a.label) {
238
+ case 0:
239
+ if (!window.ROSLIB) {
240
+ window.ROSLIB = roslib_1["default"];
241
+ }
242
+
243
+ if (window.ROS3D) {
244
+ return [2
245
+ /*return*/
246
+ , window.ROS3D];
247
+ }
248
+
249
+ return [4
250
+ /*yield*/
251
+ , load_script_1.loadScript(url)];
252
+
253
+ case 1:
254
+ _a.sent();
255
+
256
+ return [2
257
+ /*return*/
258
+ , window.ROS3D];
259
+ }
260
+ });
261
+ });
262
+ }
263
+
264
+ exports.loadLib = loadLib;
265
+ exports.basePointCloudOptions = {
266
+ colorsrc: 'intensity',
267
+ material: {
268
+ size: 0.1
269
+ },
270
+ max_pts: 10000000,
271
+ colormap: colormap
272
+ };
@@ -0,0 +1,19 @@
1
+ import { RosConfigure } from '../factory/configure';
2
+ import { InjectUtil } from './inject';
3
+ interface InitProps {
4
+ elem: any;
5
+ view?: any;
6
+ tf?: any;
7
+ }
8
+ export declare class RosViewer {
9
+ private readonly configure;
10
+ private elem;
11
+ ROS3D: any;
12
+ viewer: any;
13
+ iu: InjectUtil;
14
+ constructor(configure: RosConfigure);
15
+ init({ elem, view, tf }: InitProps): Promise<void>;
16
+ destroy(): void;
17
+ initPointClouds(optList: any[]): any[];
18
+ }
19
+ export {};
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
20
+ function adopt(value) {
21
+ return value instanceof P ? value : new P(function (resolve) {
22
+ resolve(value);
23
+ });
24
+ }
25
+
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) {
28
+ try {
29
+ step(generator.next(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ }
34
+
35
+ function rejected(value) {
36
+ try {
37
+ step(generator["throw"](value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ }
42
+
43
+ function step(result) {
44
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
+ }
46
+
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+
51
+ var __generator = this && this.__generator || function (thisArg, body) {
52
+ var _ = {
53
+ label: 0,
54
+ sent: function sent() {
55
+ if (t[0] & 1) throw t[1];
56
+ return t[1];
57
+ },
58
+ trys: [],
59
+ ops: []
60
+ },
61
+ f,
62
+ y,
63
+ t,
64
+ g;
65
+ return g = {
66
+ next: verb(0),
67
+ "throw": verb(1),
68
+ "return": verb(2)
69
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
70
+ return this;
71
+ }), g;
72
+
73
+ function verb(n) {
74
+ return function (v) {
75
+ return step([n, v]);
76
+ };
77
+ }
78
+
79
+ function step(op) {
80
+ if (f) throw new TypeError("Generator is already executing.");
81
+
82
+ while (_) {
83
+ try {
84
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
85
+ if (y = 0, t) op = [op[0] & 2, t.value];
86
+
87
+ switch (op[0]) {
88
+ case 0:
89
+ case 1:
90
+ t = op;
91
+ break;
92
+
93
+ case 4:
94
+ _.label++;
95
+ return {
96
+ value: op[1],
97
+ done: false
98
+ };
99
+
100
+ case 5:
101
+ _.label++;
102
+ y = op[1];
103
+ op = [0];
104
+ continue;
105
+
106
+ case 7:
107
+ op = _.ops.pop();
108
+
109
+ _.trys.pop();
110
+
111
+ continue;
112
+
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
+ _ = 0;
116
+ continue;
117
+ }
118
+
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+
124
+ if (op[0] === 6 && _.label < t[1]) {
125
+ _.label = t[1];
126
+ t = op;
127
+ break;
128
+ }
129
+
130
+ if (t && _.label < t[2]) {
131
+ _.label = t[2];
132
+
133
+ _.ops.push(op);
134
+
135
+ break;
136
+ }
137
+
138
+ if (t[2]) _.ops.pop();
139
+
140
+ _.trys.pop();
141
+
142
+ continue;
143
+ }
144
+
145
+ op = body.call(thisArg, _);
146
+ } catch (e) {
147
+ op = [6, e];
148
+ y = 0;
149
+ } finally {
150
+ f = t = 0;
151
+ }
152
+ }
153
+
154
+ if (op[0] & 5) throw op[1];
155
+ return {
156
+ value: op[0] ? op[1] : void 0,
157
+ done: true
158
+ };
159
+ }
160
+ };
161
+
162
+ var __importDefault = this && this.__importDefault || function (mod) {
163
+ return mod && mod.__esModule ? mod : {
164
+ "default": mod
165
+ };
166
+ };
167
+
168
+ Object.defineProperty(exports, "__esModule", {
169
+ value: true
170
+ });
171
+ exports.RosViewer = void 0;
172
+
173
+ var roslib_1 = __importDefault(require("roslib"));
174
+
175
+ var inject_1 = require("./inject");
176
+
177
+ var utils_1 = require("./utils");
178
+
179
+ var RosViewer =
180
+ /** @class */
181
+ function () {
182
+ function RosViewer(configure) {
183
+ this.iu = new inject_1.InjectUtil();
184
+ this.configure = configure;
185
+ }
186
+
187
+ RosViewer.prototype.init = function (_a) {
188
+ var elem = _a.elem,
189
+ _b = _a.view,
190
+ view = _b === void 0 ? {} : _b,
191
+ _c = _a.tf,
192
+ tf = _c === void 0 ? {} : _c;
193
+ return __awaiter(this, void 0, void 0, function () {
194
+ var _d, tfClient;
195
+
196
+ return __generator(this, function (_e) {
197
+ switch (_e.label) {
198
+ case 0:
199
+ if (!this.configure.conf.ros3d_lib_url) {
200
+ throw new Error('ros3djs lib not found');
201
+ }
202
+
203
+ _d = this;
204
+ return [4
205
+ /*yield*/
206
+ , utils_1.loadLib(this.configure.conf.ros3d_lib_url)];
207
+
208
+ case 1:
209
+ _d.ROS3D = _e.sent();
210
+ this.elem = elem;
211
+ this.iu.install('ros', this.configure.ros);
212
+ this.viewer = new this.ROS3D.Viewer(__assign({
213
+ elem: elem,
214
+ width: elem.clientWidth,
215
+ height: elem.clientHeight,
216
+ antialias: true,
217
+ cameraPose: {
218
+ x: 100,
219
+ y: 100,
220
+ z: 100
221
+ },
222
+ displayPanAndZoomFrame: false,
223
+ background: '#000000'
224
+ }, view));
225
+ this.iu.install('rootObject', this.viewer.scene);
226
+ tfClient = this.iu.inject(roslib_1["default"].TFClient, __assign({
227
+ angularThres: 0.01,
228
+ transThres: 0.01,
229
+ fixedFrame: '/base_link'
230
+ }, tf));
231
+ this.iu.install('tfClient', tfClient);
232
+ return [2
233
+ /*return*/
234
+ ];
235
+ }
236
+ });
237
+ });
238
+ };
239
+
240
+ RosViewer.prototype.destroy = function () {
241
+ if (this.viewer && typeof this.viewer.stop === 'function') {
242
+ this.viewer.stop();
243
+ }
244
+
245
+ this.elem.innerHTML = '';
246
+ };
247
+
248
+ RosViewer.prototype.initPointClouds = function (optList) {
249
+ var _this = this;
250
+
251
+ return optList.map(function (opt) {
252
+ return _this.iu.inject(_this.ROS3D.PointCloud2, __assign(__assign({}, utils_1.basePointCloudOptions), opt));
253
+ });
254
+ };
255
+
256
+ return RosViewer;
257
+ }();
258
+
259
+ exports.RosViewer = RosViewer;
@@ -0,0 +1,16 @@
1
+ declare type StorageType = 'sessionStorage' | 'localStorage';
2
+ interface WebStorageProps {
3
+ type?: StorageType;
4
+ key: string;
5
+ }
6
+ export declare class WebStorage {
7
+ private readonly _key;
8
+ private readonly storage;
9
+ constructor(props: WebStorageProps);
10
+ get state(): any;
11
+ set state(data: any);
12
+ get key(): string;
13
+ merge(data: any): void;
14
+ clear(): void;
15
+ }
16
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ Object.defineProperty(exports, "__esModule", {
20
+ value: true
21
+ });
22
+ exports.WebStorage = void 0;
23
+
24
+ var WebStorage =
25
+ /** @class */
26
+ function () {
27
+ function WebStorage(props) {
28
+ var _a = props.type,
29
+ type = _a === void 0 ? 'sessionStorage' : _a,
30
+ key = props.key;
31
+ this._key = key;
32
+ this.storage = window[type];
33
+ }
34
+
35
+ Object.defineProperty(WebStorage.prototype, "state", {
36
+ get: function get() {
37
+ var value = this.storage.getItem(this._key);
38
+
39
+ if (value) {
40
+ return JSON.parse(value);
41
+ } else {
42
+ return null;
43
+ }
44
+ },
45
+ set: function set(data) {
46
+ var temp = JSON.stringify(data);
47
+ this.storage.setItem(this._key, temp);
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ Object.defineProperty(WebStorage.prototype, "key", {
53
+ get: function get() {
54
+ return this._key;
55
+ },
56
+ enumerable: false,
57
+ configurable: true
58
+ });
59
+
60
+ WebStorage.prototype.merge = function (data) {
61
+ var old = this.state;
62
+ this.state = __assign(__assign({}, old), data);
63
+ };
64
+
65
+ WebStorage.prototype.clear = function () {
66
+ this.storage.removeItem(this._key);
67
+ };
68
+
69
+ return WebStorage;
70
+ }();
71
+
72
+ exports.WebStorage = WebStorage;
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "pubo-web",
3
+ "version": "1.0.4-alpha.0",
4
+ "main": "./lib/index.js",
5
+ "module": "./es/index.js",
6
+ "types": "./lib/index.d.ts",
7
+ "unpkg": "dist/index.js",
8
+ "sideEffects": false,
9
+ "scripts": {
10
+ "build": "gulp && webpack-cli"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "lib",
15
+ "es",
16
+ "package.json"
17
+ ],
18
+ "engines": {
19
+ "node": ">=8.0.0"
20
+ },
21
+ "dependencies": {
22
+ "pubo-utils": "^1.0.3-alpha.0",
23
+ "roslib": "^1.2.0"
24
+ },
25
+ "gitHead": "34e995171bfc1cb3010bc1e68949e8a6e326b883"
26
+ }