CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.72k stars 308 forks source link

obj to b3dm Use draco compression #233

Open mylove10086 opened 4 years ago

mylove10086 commented 4 years ago

Hello, I have completed the conversion of obj to gltf using the draco compression model. But when I converted obj to a 3dtiles b3dm file and used the draco compression model, there was no success. When loading 3dtiles in cesium, the browser prompted ‘Unsupported draco mesh geometry type.’ But I didn't find the documentation about draco compressed 3dtiles on the cesium official website. I have a question How do I use draco to compress 3dtiles?

lilleyse commented 4 years ago

@mylove10086 did you use https://github.com/CesiumGS/gltf-pipeline or some other tool to do the draco compression? Could you post the obj and gltf?

mylove10086 commented 4 years ago

I refer to https://github.com/KhronosGroup/COLLADA2GLTF to complete the obj conversion gltf and b3dm. However, when using draco to compress b3dm tiles, there is an error when loading in cesium. The error in the browser is ‘Unsupported draco mesh geometry type.’ I do n’t know where the problem is now. I guess it's in gltf: "extensionsRequired": [      "KHR_draco_mesh_compression"    ],    "extensionsUsed": [      "KHR_draco_mesh_compression"    ]. do you have any good advice. Is there a reference to b3dm files done using draco compression?

mylove10086 commented 4 years ago

This is part of the b3dm compressed by draco: {   "BATCH_LENGTH": 1 } {   "batchId": [     0   ],   "name": [     "Plane"   ],   "maxPoint": [     [       6.4123969078063969,       0.0,       6.4123969078063969     ]   ],   "minPoint": [     [       -6.4123969078063969,       0.0,       -6.4123969078063969     ]   ] } {   "asset": {     "version": "2.0",     "copyright": "Mylove",     "generator": "CObj2Gltf @ Mylove"   },   "scenes": [     {       "nodes": [         0       ]     }   ],   "scene": 0,   "nodes": [     {       "name": "Plane_node",       "mesh": 0     }   ],   "meshes": [     {       "name": "Plane_Mesh",       "primitives": [         {           "name": "Plane_primitive",           "extensions": {             "KHR_draco_mesh_compression": {               "bufferView": 0,               "attributes": {                 "NORMAL": 1,                 "POSITION": 0               }             }           },           "attributes": {             "NORMAL": 1,             "POSITION": 2,             "_BATCHID": 3           },           "indices": 0,           "mode": 4,           "material": 0         }       ]     }   ],   "accessors": [     {       "name": "Plane_indices",       "count": 6,       "type": "SCALAR",       "componentType": 5123,       "max": [         3       ],       "min": [         0       ]     },     {       "name": "Plane_normal",       "count": 4,       "type": "VEC3",       "componentType": 5126,       "max": [         0.0,         1.0,         0.0       ],       "min": [         0.0,         1.0,         0.0       ]     },     {       "name": "Plane_position",       "count": 4,       "type": "VEC3",       "componentType": 5126,       "max": [         6.4123969078063969,         0.0,         6.4123969078063969       ],       "min": [         -6.4123969078063969,         0.0,         -6.4123969078063969       ]     },     {       "name": "Plane_batchId",       "byteOffset": 0,       "bufferView": 1,       "count": 4,       "type": "SCALAR",       "componentType": 5123,       "max": [         0       ],       "min": [         0       ]     }   ],   "materials": [     {       "name": "None",       "pbrMetallicRoughness": {         "baseColorFactor": [           0.800000011920929,           0.800000011920929,           0.800000011920929,           1.0         ],         "metallicFactor": 0.0,         "roughnessFactor": 1.0       },       "emissiveFactor": [         0.0,         0.0,         0.0       ],       "alphaMode": "OPAQUE"     }   ],   "bufferViews": [     {       "buffer": 0,       "byteLength": 127,       "byteOffset": 0     },     {       "name": "Plane_batchId_bufferView",       "buffer": 0,       "byteLength": 8,       "byteOffset": 0,       "byteStride": 0,       "target": 34962     }   ],   "buffers": [     {       "byteLength": 135     }   ],   "extensionsRequired": [     "KHR_draco_mesh_compression"   ],   "extensionsUsed": [     "KHR_draco_mesh_compression"   ] }

lilleyse commented 4 years ago

Here's an example .b3dm and .gltf: 0.zip

lilleyse commented 4 years ago

Does the glTF work before it is converted to a b3dm?

mylove10086 commented 4 years ago

When you do not use draco to compress b3dm, it can load and display normally in the browser. Draco compressed gltf is also possible. But draco compressed b3dm cannot be displayed in the browser.

mylove10086 commented 4 years ago

I have found the problem by looking at the model 0.b3dm file that you donated. When using draco to compress b3dm, there is no "_BATCHID" compression. Now I have a problem: when using draco to compress _BATCHID, the type of draco should be used: class GeometryAttribute {   public:    // Supported attribute types.    enum Type {      INVALID = -1,      // Named attributes start here. The difference between named and generic      // attributes is that for named attributes we know their purpose and we      // can apply some special methods when dealing with them (e.g. during      // encoding).      POSITION = 0,      NORMAL,      COLOR,      TEX_COORD,      // A special id used to mark attributes that are not assigned to any known      // predefined use case. Such attributes are often used for a shader specific      // data.      GENERIC,      // Total number of different attribute types.      // Always keep behind all named attributes.      NAMED_ATTRIBUTES_COUNT,    };

mylove10086 commented 4 years ago

thank you very much for your help. But the draco compressed b3dm model was still unsuccessful. This is my gltf and b3dm model using draco compression, but b3dm cannot be displayed in the browser. Can you find the reason for me. [Uploading 1.zip…]()

mylove10086 commented 4 years ago

1.zip

This is the model I converted

mylove10086 commented 4 years ago

谢谢,我已经成功了! Thank you, I have succeeded!

yulongyu commented 2 years ago

你好 能指点下我怎么转3dtiles格式么