@@ -598,6 +598,16 @@ typedef struct cgltf_draco_mesh_compression {
598598 cgltf_size attributes_count ;
599599} cgltf_draco_mesh_compression ;
600600
601+ typedef struct cgltf_gaussian_splatting {
602+ char * kernel ;
603+ char * color_space ;
604+ char * sorting_method ;
605+ char * projection ;
606+ cgltf_extras extras ;
607+ cgltf_size extensions_count ;
608+ cgltf_extension * extensions ;
609+ } cgltf_gaussian_splatting ;
610+
601611typedef struct cgltf_mesh_gpu_instancing {
602612 cgltf_attribute * attributes ;
603613 cgltf_size attributes_count ;
@@ -616,6 +626,8 @@ typedef struct cgltf_primitive {
616626 cgltf_draco_mesh_compression draco_mesh_compression ;
617627 cgltf_material_mapping * mappings ;
618628 cgltf_size mappings_count ;
629+ cgltf_bool has_gaussian_splatting ;
630+ cgltf_gaussian_splatting gaussian_splatting ;
619631 cgltf_size extensions_count ;
620632 cgltf_extension * extensions ;
621633} cgltf_primitive ;
@@ -3139,6 +3151,55 @@ static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmnt
31393151 return i ;
31403152}
31413153
3154+ static int cgltf_parse_json_gaussian_splatting (cgltf_options * options , jsmntok_t const * tokens , int i , const uint8_t * json_chunk , cgltf_gaussian_splatting * out_gaussian_splatting )
3155+ {
3156+ CGLTF_CHECK_TOKTYPE (tokens [i ], JSMN_OBJECT );
3157+
3158+ int size = tokens [i ].size ;
3159+ ++ i ;
3160+
3161+ for (int j = 0 ; j < size ; ++ j )
3162+ {
3163+ CGLTF_CHECK_KEY (tokens [i ]);
3164+
3165+ if (cgltf_json_strcmp (tokens + i , json_chunk , "kernel" ) == 0 )
3166+ {
3167+ i = cgltf_parse_json_string (options , tokens , i + 1 , json_chunk , & out_gaussian_splatting -> kernel );
3168+ }
3169+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "colorSpace" ) == 0 )
3170+ {
3171+ i = cgltf_parse_json_string (options , tokens , i + 1 , json_chunk , & out_gaussian_splatting -> color_space );
3172+ }
3173+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "sortingMethod" ) == 0 )
3174+ {
3175+ i = cgltf_parse_json_string (options , tokens , i + 1 , json_chunk , & out_gaussian_splatting -> sorting_method );
3176+ }
3177+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "projection" ) == 0 )
3178+ {
3179+ i = cgltf_parse_json_string (options , tokens , i + 1 , json_chunk , & out_gaussian_splatting -> projection );
3180+ }
3181+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "extras" ) == 0 )
3182+ {
3183+ i = cgltf_parse_json_extras (options , tokens , i + 1 , json_chunk , & out_gaussian_splatting -> extras );
3184+ }
3185+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "extensions" ) == 0 )
3186+ {
3187+ i = cgltf_parse_json_unprocessed_extensions (options , tokens , i , json_chunk , & out_gaussian_splatting -> extensions_count , & out_gaussian_splatting -> extensions );
3188+ }
3189+ else
3190+ {
3191+ i = cgltf_skip_json (tokens , i + 1 );
3192+ }
3193+
3194+ if (i < 0 )
3195+ {
3196+ return i ;
3197+ }
3198+ }
3199+
3200+ return i ;
3201+ }
3202+
31423203static int cgltf_parse_json_mesh_gpu_instancing (cgltf_options * options , jsmntok_t const * tokens , int i , const uint8_t * json_chunk , cgltf_mesh_gpu_instancing * out_mesh_gpu_instancing )
31433204{
31443205 CGLTF_CHECK_TOKTYPE (tokens [i ], JSMN_OBJECT );
@@ -3410,6 +3471,11 @@ static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* t
34103471 out_prim -> has_draco_mesh_compression = 1 ;
34113472 i = cgltf_parse_json_draco_mesh_compression (options , tokens , i + 1 , json_chunk , & out_prim -> draco_mesh_compression );
34123473 }
3474+ else if (cgltf_json_strcmp (tokens + i , json_chunk , "KHR_gaussian_splatting" ) == 0 )
3475+ {
3476+ out_prim -> has_gaussian_splatting = 1 ;
3477+ i = cgltf_parse_json_gaussian_splatting (options , tokens , i + 1 , json_chunk , & out_prim -> gaussian_splatting );
3478+ }
34133479 else if (cgltf_json_strcmp (tokens + i , json_chunk , "KHR_materials_variants" ) == 0 )
34143480 {
34153481 i = cgltf_parse_json_material_mappings (options , tokens , i + 1 , json_chunk , out_prim );
0 commit comments