diff --git a/ArModelData.json b/ArModelData.json index a2aa8be..6c2b035 100644 --- a/ArModelData.json +++ b/ArModelData.json @@ -20,9 +20,17 @@ "modelData": { "type": 0, "material": { + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", "contentType": "image/jpeg", - "id": "d6350683.jpg", - "textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg" + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "width": 1, @@ -100,9 +108,17 @@ }, "modelData": { "material": { + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", "contentType": "image/jpeg", - "id": "d6350683.jpg", - "textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg" + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "width": 0.75, @@ -133,9 +149,17 @@ "modelData": { "type": 2, "material": { + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", "contentType": "image/jpeg", - "id": "d6350683.jpg", - "textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg" + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -168,9 +192,17 @@ }, "modelData": { "material": { + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", "contentType": "image/jpeg", - "id": "d6350683.jpg", - "textureUrl": "https://cdn2.ettoday.net/images/6350/d6350683.jpg" + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -205,9 +237,17 @@ }, "modelData": { "material": { - "contentType": "model/gltf-binary", - "id": "spiderbot.glb", - "textureUrl": "https://www.ray650128.com/spiderbot.glb" + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", + "contentType": "image/jpeg", + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -247,9 +287,17 @@ }, "modelData": { "material": { - "contentType": "video/mpeg4", - "id": "ker1.mp4", - "textureUrl": "https://www.ray650128.com/video/ker1.mp4" + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", + "contentType": "image/jpeg", + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -288,9 +336,17 @@ }, "modelData": { "material": { - "contentType": "video/mpeg4", - "id": "ker2.mp4", - "textureUrl": "https://www.ray650128.com/video/ker2.mp4" + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", + "contentType": "image/jpeg", + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -326,9 +382,17 @@ }, "modelData": { "material": { - "contentType": "video/mpeg4", - "id": "hou1.mp4", - "textureUrl": "https://www.ray650128.com/video/hou1.mp4" + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", + "contentType": "image/jpeg", + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 }, "params": { "availableRange": 20, @@ -378,10 +442,10 @@ }, { "id": 9, - "name": "MultiFace", + "name": "MultiplePlane", "position": { - "x": 0, - "y": 1, + "x": 1, + "y": -1, "z": 0 }, "rotation": { @@ -395,56 +459,59 @@ "z": 1 }, "modelData": { - "material": { - "contentTypes": [ - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg", - "image/jpeg" - ], - "textureUrls": [ - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg", - "https://cdn2.ettoday.net/images/6350/d6350683.jpg" - ] - }, + "materials": [ + { + "_id": "6464410c9c67517fcbccf447", + "ownerId": "646435a39c67517fcbccf426", + "name": "奸笑的綿芽", + "path": "/upload/1684291852002.jpeg", + "contentType": "image/jpeg", + "fileTag": [ + "圖片", + "Hololive" + ], + "createAt": 1684291852023, + "updatedAt": 1684294290879 + }, + { + "_id": "646590294df2e46df0f7a51b", + "ownerId": "646435a39c67517fcbccf426", + "name": "供三小", + "path": "/upload/1684377641965.jpeg", + "contentType": "image/jpeg", + "createAt": 1684377641977 + }, + { + "_id": "646590674df2e46df0f7a524", + "ownerId": "646435a39c67517fcbccf426", + "name": "解散囉", + "path": "/upload/1684377703013.png", + "contentType": "image/png", + "createAt": 1684377703020 + }, + { + "_id": "646590e04df2e46df0f7a52f", + "ownerId": "646435a39c67517fcbccf426", + "name": "QRCode", + "path": "/upload/1684377824564.png", + "contentType": "image/png", + "createAt": 1684377824573 + }, + { + "_id": "646593304df2e46df0f7a54b", + "ownerId": "646435a39c67517fcbccf426", + "name": "煙霧", + "path": "/upload/1684378416412.png", + "contentType": "image/png", + "createAt": 1684378416417 + } + ], "params": { - "levelAngles": [ - 45, - 0, - -45 - ], - "levelBorders": [ - 0.1, - 0.1, - 0.1 - ], - "levelCount": 3, + "levelAngles": [ 0 ], + "levelBorders": [ 0 ], + "levelCount": 1, "planeBorder": 0.1, - "planeCount": 5, + "planeCount": 4, "speed": 1 }, "type": 6 diff --git a/src/main/kotlin/com/ray650128/extension/ModelDataExtension.kt b/src/main/kotlin/com/ray650128/extension/ModelDataExtension.kt index 92d5200..1135477 100644 --- a/src/main/kotlin/com/ray650128/extension/ModelDataExtension.kt +++ b/src/main/kotlin/com/ray650128/extension/ModelDataExtension.kt @@ -1,14 +1,28 @@ package com.ray650128.extension +import com.ray650128.model.pojo.Material import com.ray650128.model.pojo.arModel.ModelData import com.ray650128.model.pojo.arModelDto.ModelDataDto import com.ray650128.service.MaterialService +import org.litote.kmongo.Id fun ModelData.toDto(): ModelDataDto { val service = MaterialService() return ModelDataDto( type = this.type, - material = service.findById(this.material.toString()), + material = if (this.material != null) { + service.findById(this.material.toString()) + } else null, + materials = if (this.materials != null) { + ArrayList().apply { + materials?.forEach { id -> + val material = service.findById(id.toString()) + if (material != null) { + add(material) + } + } + } + } else null, params = this.params ) } @@ -18,5 +32,10 @@ fun ModelDataDto.toModelData(): ModelData = ModelData( type = this.type, material = this.material?._id, + materials = ArrayList>().apply { + materials?.forEach { material -> + add(material._id) + } + }, params = this.params ) \ No newline at end of file diff --git a/src/main/kotlin/com/ray650128/model/pojo/arModel/ModelData.kt b/src/main/kotlin/com/ray650128/model/pojo/arModel/ModelData.kt index ed7c99a..8eba228 100644 --- a/src/main/kotlin/com/ray650128/model/pojo/arModel/ModelData.kt +++ b/src/main/kotlin/com/ray650128/model/pojo/arModel/ModelData.kt @@ -9,5 +9,6 @@ import org.litote.kmongo.Id data class ModelData( var type: Int = -1, @Contextual var material: Id? = null, + @Contextual var materials: List>? = null, var params: ModelParams ) \ No newline at end of file diff --git a/src/main/kotlin/com/ray650128/model/pojo/arModelDto/ModelDataDto.kt b/src/main/kotlin/com/ray650128/model/pojo/arModelDto/ModelDataDto.kt index cb4873c..df73be8 100644 --- a/src/main/kotlin/com/ray650128/model/pojo/arModelDto/ModelDataDto.kt +++ b/src/main/kotlin/com/ray650128/model/pojo/arModelDto/ModelDataDto.kt @@ -10,5 +10,6 @@ import org.litote.kmongo.Id data class ModelDataDto( var type: Int = -1, var material: Material? = null, + var materials: List? = null, var params: ModelParams ) \ No newline at end of file diff --git a/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt b/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt index 81e774e..dbce23a 100644 --- a/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt +++ b/src/main/kotlin/com/ray650128/plugins/ArModelRouting.kt @@ -4,6 +4,7 @@ import com.ray650128.extension.* import com.ray650128.model.ErrorResponse import com.ray650128.model.pojo.arModel.ArModel import com.ray650128.model.pojo.User +import com.ray650128.model.pojo.arModelDto.ArModelDto import com.ray650128.service.ModelService import com.ray650128.service.UserService import io.ktor.server.application.* @@ -39,7 +40,7 @@ fun Application.configureArModelRouting() { call.sendUnauthorized() return@post } - val body = call.receive() + val body = call.receive().toArModel() body.apply { ownerId = user._id createAt = System.currentTimeMillis()