@kimap/indoor-positioning-sdk-vue2 3.1.4 → 3.1.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/KimapCore.js +145 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimap/indoor-positioning-sdk-vue2",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
package/src/KimapCore.js CHANGED
@@ -161,6 +161,60 @@ function decryptTheme(themeContent) {
161
161
  }
162
162
  }
163
163
 
164
+ /**
165
+ * 从OBJ内容中提取边界信息
166
+ * 边界信息格式:
167
+ * # KIMAP_BORDER_MIN_X 0.000000
168
+ * # KIMAP_BORDER_MIN_Y 0.000000
169
+ * # KIMAP_BORDER_MIN_Z 0.000000
170
+ * # KIMAP_BORDER_MAX_X 10.500000
171
+ * # KIMAP_BORDER_MAX_Y 0.375000
172
+ * # KIMAP_BORDER_MAX_Z 8.200000
173
+ */
174
+ function extractBorderFromOBJ(objContent) {
175
+ var border = {
176
+ min: { x: null, y: null, z: null },
177
+ max: { x: null, y: null, z: null }
178
+ };
179
+
180
+ var lines = objContent.split('\n');
181
+ var foundBorder = false;
182
+
183
+ for (var i = 0; i < lines.length; i++) {
184
+ var line = lines[i].trim();
185
+
186
+ // 检测边界结束标记
187
+ if (line.indexOf('End Border Info') !== -1) {
188
+ break;
189
+ }
190
+
191
+ // 解析边界值
192
+ if (line.indexOf('KIMAP_BORDER_MIN_X') !== -1) {
193
+ border.min.x = parseFloat(line.split(' ')[2]);
194
+ foundBorder = true;
195
+ } else if (line.indexOf('KIMAP_BORDER_MIN_Y') !== -1) {
196
+ border.min.y = parseFloat(line.split(' ')[2]);
197
+ } else if (line.indexOf('KIMAP_BORDER_MIN_Z') !== -1) {
198
+ border.min.z = parseFloat(line.split(' ')[2]);
199
+ } else if (line.indexOf('KIMAP_BORDER_MAX_X') !== -1) {
200
+ border.max.x = parseFloat(line.split(' ')[2]);
201
+ } else if (line.indexOf('KIMAP_BORDER_MAX_Y') !== -1) {
202
+ border.max.y = parseFloat(line.split(' ')[2]);
203
+ } else if (line.indexOf('KIMAP_BORDER_MAX_Z') !== -1) {
204
+ border.max.z = parseFloat(line.split(' ')[2]);
205
+ }
206
+ }
207
+
208
+ // 验证是否成功解析
209
+ if (foundBorder &&
210
+ border.min.x !== null && border.min.y !== null && border.min.z !== null &&
211
+ border.max.x !== null && border.max.y !== null && border.max.z !== null) {
212
+ return border;
213
+ }
214
+
215
+ return null;
216
+ }
217
+
164
218
  /**
165
219
  * 从OBJ内容中提取颜色信息
166
220
  */
@@ -419,6 +473,16 @@ SceneCore.prototype.loadMap = function(OBJLoader, MTLLoader) {
419
473
 
420
474
  console.log('解密成功,开始解析OBJ模型...');
421
475
 
476
+ // 提取边界信息
477
+ var borderInfo = extractBorderFromOBJ(objContent);
478
+ if (borderInfo) {
479
+ console.log('✅ 提取到边界信息:', borderInfo);
480
+ // 存储到SDK实例中(需要通过回调或全局引用)
481
+ if (self.sdk && self.sdk._setBorderInfo) {
482
+ self.sdk._setBorderInfo(borderInfo);
483
+ }
484
+ }
485
+
422
486
  // 提取颜色信息(作为备用)
423
487
  var colorMap = materials ? {} : extractColorsFromOBJ(objContent);
424
488
  if (!materials) {
@@ -818,6 +882,7 @@ KimapSDK.prototype.init = function() {
818
882
  self.raycaster = new THREE.Raycaster();
819
883
  self.mouse = new THREE.Vector2();
820
884
  self.core = new SceneCore(self.config);
885
+ self.core.sdk = self; // 设置SDK引用,用于边界信息存储
821
886
  return self.core.init();
822
887
  })
823
888
  .then(function() {
@@ -1079,6 +1144,86 @@ KimapSDK.prototype.getCoordinateSystem = function() {
1079
1144
  };
1080
1145
  };
1081
1146
 
1147
+ /**
1148
+ * 获取地图配置信息
1149
+ */
1150
+ KimapSDK.prototype.getConfig = function() {
1151
+ return {
1152
+ maxX: this.core.coordinateSystem.maxX,
1153
+ maxY: this.core.coordinateSystem.maxY,
1154
+ origin: {
1155
+ x: this.core.coordinateSystem.origin.x,
1156
+ y: this.core.coordinateSystem.origin.y,
1157
+ z: this.core.coordinateSystem.origin.z
1158
+ }
1159
+ };
1160
+ };
1161
+
1162
+ /**
1163
+ * 获取地图边界信息
1164
+ * 边界信息从模型文件中读取,如果没有则根据坐标系统计算
1165
+ */
1166
+ KimapSDK.prototype.getBorder = function() {
1167
+ // 如果模型中有边界信息,优先使用(需要在加载OBJ时解析并存储)
1168
+ if (this._borderInfo) {
1169
+ return this._borderInfo;
1170
+ }
1171
+
1172
+ // 降级方案:根据坐标系统计算
1173
+ var origin = this.core.coordinateSystem.origin;
1174
+ var maxX = this.core.coordinateSystem.maxX;
1175
+ var maxY = this.core.coordinateSystem.maxY;
1176
+
1177
+ return {
1178
+ min: {
1179
+ x: origin.x,
1180
+ y: origin.y,
1181
+ z: origin.z
1182
+ },
1183
+ max: {
1184
+ x: origin.x + maxX,
1185
+ y: origin.y + 0.375, // 默认高度
1186
+ z: origin.z + maxY
1187
+ }
1188
+ };
1189
+ };
1190
+
1191
+ /**
1192
+ * 设置边界信息(从OBJ文件解析后调用)
1193
+ * @private
1194
+ */
1195
+ KimapSDK.prototype._setBorderInfo = function(borderInfo) {
1196
+ this._borderInfo = borderInfo;
1197
+ };
1198
+
1199
+ /**
1200
+ * 获取楼层列表
1201
+ * 注意:当前版本为单楼层,返回默认楼层信息
1202
+ */
1203
+ KimapSDK.prototype.getFloors = function() {
1204
+ // TODO: 多楼层支持,从配置或模型中读取
1205
+ return [
1206
+ { id: 'floor1', name: '一楼', order: 1 }
1207
+ ];
1208
+ };
1209
+
1210
+ /**
1211
+ * 获取当前楼层ID
1212
+ */
1213
+ KimapSDK.prototype.getCurrentFloor = function() {
1214
+ // TODO: 多楼层支持
1215
+ return 'floor1';
1216
+ };
1217
+
1218
+ /**
1219
+ * 切换楼层
1220
+ * @param {string} floorId - 楼层ID
1221
+ */
1222
+ KimapSDK.prototype.switchFloor = function(floorId) {
1223
+ // TODO: 多楼层支持,实现楼层切换逻辑
1224
+ console.warn('多楼层功能暂未实现,当前版本仅支持单楼层');
1225
+ };
1226
+
1082
1227
  KimapSDK.prototype.destroy = function() {
1083
1228
  if (this.animationFrameId) {
1084
1229
  cancelAnimationFrame(this.animationFrameId);