@kimap/indoor-positioning-sdk-vue2 3.2.0 → 3.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimap/indoor-positioning-sdk-vue2",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -93,6 +93,78 @@
93
93
  }
94
94
  }
95
95
 
96
+ // 从OBJ内容中提取边界信息
97
+ function extractBorderFromOBJ(objContent) {
98
+ var border = {
99
+ min: { x: null, y: null, z: null },
100
+ max: { x: null, y: null, z: null }
101
+ };
102
+
103
+ var lines = objContent.split('\n');
104
+ var foundBorder = false;
105
+
106
+ for (var i = 0; i < lines.length; i++) {
107
+ var line = lines[i].trim();
108
+
109
+ if (line.indexOf('End Border Info') !== -1) break;
110
+
111
+ if (line.indexOf('KIMAP_BORDER_MIN_X') !== -1) {
112
+ border.min.x = parseFloat(line.split(' ')[2]);
113
+ foundBorder = true;
114
+ } else if (line.indexOf('KIMAP_BORDER_MIN_Y') !== -1) {
115
+ border.min.y = parseFloat(line.split(' ')[2]);
116
+ } else if (line.indexOf('KIMAP_BORDER_MIN_Z') !== -1) {
117
+ border.min.z = parseFloat(line.split(' ')[2]);
118
+ } else if (line.indexOf('KIMAP_BORDER_MAX_X') !== -1) {
119
+ border.max.x = parseFloat(line.split(' ')[2]);
120
+ } else if (line.indexOf('KIMAP_BORDER_MAX_Y') !== -1) {
121
+ border.max.y = parseFloat(line.split(' ')[2]);
122
+ } else if (line.indexOf('KIMAP_BORDER_MAX_Z') !== -1) {
123
+ border.max.z = parseFloat(line.split(' ')[2]);
124
+ }
125
+ }
126
+
127
+ if (foundBorder && border.min.x !== null && border.max.x !== null) {
128
+ return border;
129
+ }
130
+ return null;
131
+ }
132
+
133
+ // 从OBJ内容中提取地图配置信息(校准数据)
134
+ function extractMapConfigFromOBJ(objContent) {
135
+ var config = {
136
+ isCalibrated: false,
137
+ calibrationScale: null,
138
+ realWidth: null,
139
+ realHeight: null,
140
+ modelToRealScale: null
141
+ };
142
+
143
+ var lines = objContent.split('\n');
144
+ var foundConfig = false;
145
+
146
+ for (var i = 0; i < lines.length; i++) {
147
+ var line = lines[i].trim();
148
+
149
+ if (line.indexOf('KIMAP_CONFIG_CALIBRATED') !== -1) {
150
+ config.isCalibrated = line.split(' ')[2] === 'true';
151
+ foundConfig = true;
152
+ } else if (line.indexOf('KIMAP_CONFIG_CALIBRATION_SCALE') !== -1) {
153
+ config.calibrationScale = parseFloat(line.split(' ')[2]);
154
+ } else if (line.indexOf('KIMAP_CONFIG_REAL_WIDTH') !== -1) {
155
+ config.realWidth = parseFloat(line.split(' ')[2]);
156
+ } else if (line.indexOf('KIMAP_CONFIG_REAL_HEIGHT') !== -1) {
157
+ config.realHeight = parseFloat(line.split(' ')[2]);
158
+ } else if (line.indexOf('KIMAP_CONFIG_MODEL_TO_REAL_SCALE') !== -1) {
159
+ config.modelToRealScale = parseFloat(line.split(' ')[2]);
160
+ }
161
+
162
+ if (line.indexOf('End Config Info') !== -1) break;
163
+ }
164
+
165
+ return foundConfig ? config : null;
166
+ }
167
+
96
168
  // 从OBJ内容中提取颜色信息
97
169
  function extractColorsFromOBJ(objContent) {
98
170
  var colorMap = {};
@@ -449,6 +521,20 @@
449
521
  console.log('📄 OBJ内容预览(前500字符):');
450
522
  console.log(objContent.substring(0, 500));
451
523
 
524
+ // 提取边界信息
525
+ var borderInfo = extractBorderFromOBJ(objContent);
526
+ if (borderInfo) {
527
+ console.log('✅ 提取到边界信息:', borderInfo);
528
+ self._borderInfo = borderInfo;
529
+ }
530
+
531
+ // 提取地图配置信息(校准数据)
532
+ var mapConfig = extractMapConfigFromOBJ(objContent);
533
+ if (mapConfig && mapConfig.isCalibrated) {
534
+ console.log('✅ 提取到校准数据:', mapConfig);
535
+ self._mapConfig = mapConfig;
536
+ }
537
+
452
538
  // 提取颜色信息(作为备用,如果没有MTL的话)
453
539
  var colorMap = materials ? {} : extractColorsFromOBJ(objContent);
454
540
  if (!materials) {
@@ -767,6 +853,15 @@
767
853
 
768
854
  return self.core.init().then(function() {
769
855
  self.info = self.core.getMapInfo();
856
+
857
+ // 从SceneCore传递边界和配置信息
858
+ if (self.core._borderInfo) {
859
+ self._borderInfo = self.core._borderInfo;
860
+ }
861
+ if (self.core._mapConfig) {
862
+ self._mapConfig = self.core._mapConfig;
863
+ }
864
+
770
865
  self.addEventListeners();
771
866
  self.startRenderLoop();
772
867
  return self;
@@ -1286,21 +1381,22 @@
1286
1381
  * 获取地图配置信息(包含校准数据)
1287
1382
  */
1288
1383
  KimapSDK.prototype.getConfig = function() {
1289
- var config = {
1290
- maxX: this.config.maxX,
1291
- maxY: this.config.maxY,
1292
- origin: this.config.origin
1293
- };
1384
+ var config = {};
1385
+
1386
+ // 模型尺寸(从边界信息获取,单位:米)
1387
+ if (this._borderInfo) {
1388
+ var border = this._borderInfo;
1389
+ config.mapX = border.max.x - border.min.x;
1390
+ config.mapY = border.max.y - border.min.y;
1391
+ config.mapZ = border.max.z - border.min.z;
1392
+ }
1294
1393
 
1295
- // 如果有校准数据,一并返回
1296
- if (this._mapConfig) {
1297
- config.calibrationData = {
1298
- isCalibrated: this._mapConfig.isCalibrated || false,
1299
- calibrationScale: this._mapConfig.calibrationScale,
1300
- realWidth: this._mapConfig.realWidth,
1301
- realHeight: this._mapConfig.realHeight,
1302
- modelToRealScale: this._mapConfig.modelToRealScale
1303
- };
1394
+ // 如果有校准数据,返回底图真实世界尺寸(单位:米)
1395
+ if (this._mapConfig && this._mapConfig.isCalibrated) {
1396
+ config.isCalibrated = true;
1397
+ config.baseMapWidth = this._mapConfig.realWidth / 100; // 底图真实宽度(米)
1398
+ config.baseMapHeight = this._mapConfig.realHeight / 100; // 底图真实高度(米)
1399
+ config.modelToRealScale = this._mapConfig.modelToRealScale;
1304
1400
  }
1305
1401
 
1306
1402
  return config;
package/src/KimapCore.js CHANGED
@@ -1203,25 +1203,22 @@ KimapSDK.prototype.getCoordinateSystem = function() {
1203
1203
  * 获取地图配置信息(包含校准数据)
1204
1204
  */
1205
1205
  KimapSDK.prototype.getConfig = function() {
1206
- var config = {
1207
- maxX: this.core.coordinateSystem.maxX,
1208
- maxY: this.core.coordinateSystem.maxY,
1209
- origin: {
1210
- x: this.core.coordinateSystem.origin.x,
1211
- y: this.core.coordinateSystem.origin.y,
1212
- z: this.core.coordinateSystem.origin.z
1213
- }
1214
- };
1206
+ var config = {};
1207
+
1208
+ // 模型尺寸(从边界信息获取,单位:米)
1209
+ if (this._borderInfo) {
1210
+ var border = this._borderInfo;
1211
+ config.mapX = border.max.x - border.min.x;
1212
+ config.mapY = border.max.y - border.min.y;
1213
+ config.mapZ = border.max.z - border.min.z;
1214
+ }
1215
1215
 
1216
- // 如果有校准数据,一并返回
1217
- if (this._mapConfig) {
1218
- config.calibrationData = {
1219
- isCalibrated: this._mapConfig.isCalibrated || false,
1220
- calibrationScale: this._mapConfig.calibrationScale,
1221
- realWidth: this._mapConfig.realWidth,
1222
- realHeight: this._mapConfig.realHeight,
1223
- modelToRealScale: this._mapConfig.modelToRealScale
1224
- };
1216
+ // 如果有校准数据,返回底图真实世界尺寸(单位:米)
1217
+ if (this._mapConfig && this._mapConfig.isCalibrated) {
1218
+ config.isCalibrated = true;
1219
+ config.baseMapWidth = this._mapConfig.realWidth / 100; // 底图真实宽度(米)
1220
+ config.baseMapHeight = this._mapConfig.realHeight / 100; // 底图真实高度(米)
1221
+ config.modelToRealScale = this._mapConfig.modelToRealScale;
1225
1222
  }
1226
1223
 
1227
1224
  return config;