Browse Source

fix:新增空白作品时生成地板和视角

liaoyitao 4 months ago
parent
commit
567a5c1969

+ 14 - 4
src/main/java/com/lqkj/link/module/zone/service/ZoneInfoService.java

@@ -302,13 +302,12 @@ public class ZoneInfoService {
302 302
             template = zoneInfoRepository.findById(templateId).get();
303 303
         }
304 304
 
305
-        ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, template == null ? null : template.getInitLocation(),
305
+        ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, template == null ? new JSONObject(JSON.parseObject("{\"rotation\":{\"x\":0,\"y\":0.4383658766746521,\"z\":0,\"w\":0.8987966179847717},\"translation\":{\"x\":-820.947265625,\"y\":0,\"z\":955.6719360351563},\"scale3D\":{\"x\":1,\"y\":1,\"z\":1}}")) : template.getInitLocation(),
306 306
                 template == null ? null : template.getThumbnail(), 0, new Date(), 0, 0,
307 307
                 null, null, 0,null);
308 308
         ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
309
-
309
+        GeometryFactory geometryFactory = new GeometryFactory();
310 310
         if (templateId != null) {
311
-            GeometryFactory geometryFactory = new GeometryFactory();
312 311
             if (geomInfoRepository.hasGeom(templateId)) {
313 312
                 List<GeomInfo> geomInfoList = geomInfoRepository.findAllByZoneId(templateId);
314 313
                 List<GeomInfo> list = new ArrayList<>();
@@ -331,6 +330,17 @@ public class ZoneInfoService {
331 330
             }
332 331
             // 模板使用次数+1
333 332
             zoneInfoRepository.addTemplateUse(templateId);
333
+        }else {
334
+            GeomInfo geomInfo = new GeomInfo();
335
+            geomInfo.setZoneId(newInfo.getZoneId());
336
+            geomInfo.setGeomId(newInfo.getZoneId() + "_1");
337
+            geomInfo.setModelId(10000);
338
+            geomInfo.setGeomName("地板");
339
+            geomInfo.setLocking(false);
340
+            geomInfo.setTrans(new JSONObject(JSON.parseObject("{\"rotation\":{\"x\":0,\"y\":0,\"z\":0,\"w\":1},\"translation\":{\"x\":0,\"y\":0,\"z\":20},\"scale3D\":{\"x\":1,\"y\":1,\"z\":1}}")));
341
+            geomInfo.setGeom(geometryFactory.createPoint(new Coordinate(0, 0, 0)));
342
+            geomInfo.setTypeNumber(0);
343
+            geomInfoRepository.save(geomInfo);
334 344
         }
335 345
         result.put("zone", newInfo);
336 346
 
@@ -340,7 +350,7 @@ public class ZoneInfoService {
340 350
     public void saveThumbnail(Integer zoneId, String thumbnailPath) {
341 351
         ZoneInfo zoneInfo = zoneInfoRepository.findById(zoneId).get();
342 352
         zoneInfo.setThumbnail(thumbnailPath);
343
-        zoneInfo.setUpdateTime(new Date());
353
+//        zoneInfo.setUpdateTime(new Date());
344 354
         zoneInfoRepository.save(zoneInfo);
345 355
     }
346 356
 

+ 5 - 1
src/main/resources/db/migration/V5__1.0.0.sql

@@ -8,4 +8,8 @@ comment on column geom_info.type_number is '类型编号0:模型 1:特效';
8 8
 
9 9
 ALTER TABLE geom_info
10 10
     add COLUMN if not exists static_id int;
11
-comment on column geom_info.static_id is '类型编号';
11
+comment on column geom_info.static_id is '类型编号';
12
+
13
+INSERT INTO "public"."model_category" ("category_id", "user_id", "icon", "category_name", "order_id", "compress_file_path", "compress_file_name") VALUES (10000, NULL, 'https://link-meta.oss-cn-chengdu.aliyuncs.com/file/2024-12-02/7F1B512F-4D21-4c7a-83E8-4AE96D0C3CB4.png', '地形', NULL, NULL, NULL);
14
+
15
+INSERT INTO "public"."model_info" ("model_id", "category_id", "model_name", "json_path", "texture_path", "order_id", "original_path", "model_icon", "template_id") VALUES (10000, 10000, '地板', NULL, NULL, NULL, 'https://link-meta.oss-cn-chengdu.aliyuncs.com/file/2024-12-02/2.fbx', 'https://link-meta.oss-cn-chengdu.aliyuncs.com/file/2024-12-02/7F1B512F-4D21-4c7a-83E8-4AE96D0C3CB4.png', NULL);