glTF2Asset.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2021, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file glTFAsset.h
  34. * Declares a glTF class to handle gltf/glb files
  35. *
  36. * glTF Extensions Support:
  37. * KHR_materials_pbrSpecularGlossiness full
  38. * KHR_materials_unlit full
  39. * KHR_lights_punctual full
  40. * KHR_materials_sheen full
  41. * KHR_materials_clearcoat full
  42. * KHR_materials_transmission full
  43. * KHR_materials_volume full
  44. * KHR_materials_ior full
  45. */
  46. #ifndef GLTF2ASSET_H_INC
  47. #define GLTF2ASSET_H_INC
  48. #if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
  49. #include <assimp/Exceptional.h>
  50. #include <algorithm>
  51. #include <list>
  52. #include <map>
  53. #include <set>
  54. #include <stdexcept>
  55. #include <string>
  56. #include <vector>
  57. // clang-format off
  58. #if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
  59. #pragma GCC diagnostic push
  60. #pragma GCC diagnostic ignored "-Wclass-memaccess"
  61. #endif
  62. #include <rapidjson/document.h>
  63. #include <rapidjson/error/en.h>
  64. #include <rapidjson/rapidjson.h>
  65. #include <rapidjson/schema.h>
  66. #if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
  67. # pragma GCC diagnostic pop
  68. #endif
  69. #ifdef ASSIMP_API
  70. # include <assimp/ByteSwapper.h>
  71. # include <assimp/DefaultIOSystem.h>
  72. # include <memory>
  73. #else
  74. # include <memory>
  75. # define AI_SWAP4(p)
  76. # define ai_assert
  77. #endif
  78. #if _MSC_VER > 1500 || (defined __GNUC___)
  79. # define ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
  80. #else
  81. # define gltf_unordered_map map
  82. # define gltf_unordered_set set
  83. #endif
  84. #ifdef ASSIMP_GLTF_USE_UNORDERED_MULTIMAP
  85. # include <unordered_map>
  86. # include <unordered_set>
  87. # if defined(_MSC_VER) && _MSC_VER <= 1600
  88. # define gltf_unordered_map tr1::unordered_map
  89. # define gltf_unordered_set tr1::unordered_set
  90. # else
  91. # define gltf_unordered_map unordered_map
  92. # define gltf_unordered_set unordered_set
  93. # endif
  94. #endif
  95. // clang-format on
  96. #include <assimp/StringUtils.h>
  97. #include "AssetLib/glTF/glTFCommon.h"
  98. namespace glTF2 {
  99. using glTFCommon::Nullable;
  100. using glTFCommon::Ref;
  101. using glTFCommon::IOStream;
  102. using glTFCommon::IOSystem;
  103. using glTFCommon::shared_ptr;
  104. using rapidjson::Document;
  105. using rapidjson::Value;
  106. class Asset;
  107. class AssetWriter;
  108. struct BufferView; // here due to cross-reference
  109. struct Texture;
  110. struct Skin;
  111. using glTFCommon::mat4;
  112. using glTFCommon::vec3;
  113. using glTFCommon::vec4;
  114. //! Magic number for GLB files
  115. #define AI_GLB_MAGIC_NUMBER "glTF"
  116. #include <assimp/pbrmaterial.h>
  117. #ifdef ASSIMP_API
  118. #include <assimp/Compiler/pushpack1.h>
  119. #endif
  120. //! For binary .glb files
  121. //! 12-byte header (+ the JSON + a "body" data section)
  122. struct GLB_Header {
  123. uint8_t magic[4]; //!< Magic number: "glTF"
  124. uint32_t version; //!< Version number (always 2 as of the last update)
  125. uint32_t length; //!< Total length of the Binary glTF, including header, scene, and body, in bytes
  126. } PACK_STRUCT;
  127. struct GLB_Chunk {
  128. uint32_t chunkLength;
  129. uint32_t chunkType;
  130. } PACK_STRUCT;
  131. #ifdef ASSIMP_API
  132. #include <assimp/Compiler/poppack1.h>
  133. #endif
  134. //! Values for the GLB_Chunk::chunkType field
  135. enum ChunkType {
  136. ChunkType_JSON = 0x4E4F534A,
  137. ChunkType_BIN = 0x004E4942
  138. };
  139. //! Values for the mesh primitive modes
  140. enum PrimitiveMode {
  141. PrimitiveMode_POINTS = 0,
  142. PrimitiveMode_LINES = 1,
  143. PrimitiveMode_LINE_LOOP = 2,
  144. PrimitiveMode_LINE_STRIP = 3,
  145. PrimitiveMode_TRIANGLES = 4,
  146. PrimitiveMode_TRIANGLE_STRIP = 5,
  147. PrimitiveMode_TRIANGLE_FAN = 6
  148. };
  149. //! Values for the Accessor::componentType field
  150. enum ComponentType {
  151. ComponentType_BYTE = 5120,
  152. ComponentType_UNSIGNED_BYTE = 5121,
  153. ComponentType_SHORT = 5122,
  154. ComponentType_UNSIGNED_SHORT = 5123,
  155. ComponentType_UNSIGNED_INT = 5125,
  156. ComponentType_FLOAT = 5126
  157. };
  158. inline unsigned int ComponentTypeSize(ComponentType t) {
  159. switch (t) {
  160. case ComponentType_SHORT:
  161. case ComponentType_UNSIGNED_SHORT:
  162. return 2;
  163. case ComponentType_UNSIGNED_INT:
  164. case ComponentType_FLOAT:
  165. return 4;
  166. case ComponentType_BYTE:
  167. case ComponentType_UNSIGNED_BYTE:
  168. return 1;
  169. default:
  170. throw DeadlyImportError("GLTF: Unsupported Component Type ", ai_to_string(t));
  171. }
  172. }
  173. //! Values for the BufferView::target field
  174. enum BufferViewTarget {
  175. BufferViewTarget_NONE = 0,
  176. BufferViewTarget_ARRAY_BUFFER = 34962,
  177. BufferViewTarget_ELEMENT_ARRAY_BUFFER = 34963
  178. };
  179. //! Values for the Sampler::magFilter field
  180. enum class SamplerMagFilter : unsigned int {
  181. UNSET = 0,
  182. SamplerMagFilter_Nearest = 9728,
  183. SamplerMagFilter_Linear = 9729
  184. };
  185. //! Values for the Sampler::minFilter field
  186. enum class SamplerMinFilter : unsigned int {
  187. UNSET = 0,
  188. SamplerMinFilter_Nearest = 9728,
  189. SamplerMinFilter_Linear = 9729,
  190. SamplerMinFilter_Nearest_Mipmap_Nearest = 9984,
  191. SamplerMinFilter_Linear_Mipmap_Nearest = 9985,
  192. SamplerMinFilter_Nearest_Mipmap_Linear = 9986,
  193. SamplerMinFilter_Linear_Mipmap_Linear = 9987
  194. };
  195. //! Values for the Sampler::wrapS and Sampler::wrapT field
  196. enum class SamplerWrap : unsigned int {
  197. UNSET = 0,
  198. Clamp_To_Edge = 33071,
  199. Mirrored_Repeat = 33648,
  200. Repeat = 10497
  201. };
  202. //! Values for the Texture::format and Texture::internalFormat fields
  203. enum TextureFormat {
  204. TextureFormat_ALPHA = 6406,
  205. TextureFormat_RGB = 6407,
  206. TextureFormat_RGBA = 6408,
  207. TextureFormat_LUMINANCE = 6409,
  208. TextureFormat_LUMINANCE_ALPHA = 6410
  209. };
  210. //! Values for the Texture::target field
  211. enum TextureTarget {
  212. TextureTarget_TEXTURE_2D = 3553
  213. };
  214. //! Values for the Texture::type field
  215. enum TextureType {
  216. TextureType_UNSIGNED_BYTE = 5121,
  217. TextureType_UNSIGNED_SHORT_5_6_5 = 33635,
  218. TextureType_UNSIGNED_SHORT_4_4_4_4 = 32819,
  219. TextureType_UNSIGNED_SHORT_5_5_5_1 = 32820
  220. };
  221. //! Values for the Animation::Target::path field
  222. enum AnimationPath {
  223. AnimationPath_TRANSLATION,
  224. AnimationPath_ROTATION,
  225. AnimationPath_SCALE,
  226. AnimationPath_WEIGHTS,
  227. };
  228. //! Values for the Animation::Sampler::interpolation field
  229. enum Interpolation {
  230. Interpolation_LINEAR,
  231. Interpolation_STEP,
  232. Interpolation_CUBICSPLINE,
  233. };
  234. //! Values for the Accessor::type field (helper class)
  235. class AttribType {
  236. public:
  237. enum Value { SCALAR,
  238. VEC2,
  239. VEC3,
  240. VEC4,
  241. MAT2,
  242. MAT3,
  243. MAT4 };
  244. private:
  245. static const size_t NUM_VALUES = static_cast<size_t>(MAT4) + 1;
  246. struct Info {
  247. const char *name;
  248. unsigned int numComponents;
  249. };
  250. template <int N>
  251. struct data { static const Info infos[NUM_VALUES]; };
  252. public:
  253. inline static Value FromString(const char *str) {
  254. for (size_t i = 0; i < NUM_VALUES; ++i) {
  255. if (strcmp(data<0>::infos[i].name, str) == 0) {
  256. return static_cast<Value>(i);
  257. }
  258. }
  259. return SCALAR;
  260. }
  261. inline static const char *ToString(Value type) {
  262. return data<0>::infos[static_cast<size_t>(type)].name;
  263. }
  264. inline static unsigned int GetNumComponents(Value type) {
  265. return data<0>::infos[static_cast<size_t>(type)].numComponents;
  266. }
  267. };
  268. // must match the order of the AttribTypeTraits::Value enum!
  269. template <int N>
  270. const AttribType::Info
  271. AttribType::data<N>::infos[AttribType::NUM_VALUES] = {
  272. { "SCALAR", 1 }, { "VEC2", 2 }, { "VEC3", 3 }, { "VEC4", 4 }, { "MAT2", 4 }, { "MAT3", 9 }, { "MAT4", 16 }
  273. };
  274. struct CustomExtension {
  275. //
  276. // A struct containing custom extension data added to a glTF2 file
  277. // Has to contain Object, Array, String, Double, Uint64, and Int64 at a minimum
  278. // String, Double, Uint64, and Int64 are stored in the Nullables
  279. // Object and Array are stored in the std::vector
  280. //
  281. std::string name;
  282. Nullable<std::string> mStringValue;
  283. Nullable<double> mDoubleValue;
  284. Nullable<uint64_t> mUint64Value;
  285. Nullable<int64_t> mInt64Value;
  286. Nullable<bool> mBoolValue;
  287. // std::vector<CustomExtension> handles both Object and Array
  288. Nullable<std::vector<CustomExtension>> mValues;
  289. operator bool() const {
  290. return Size() != 0;
  291. }
  292. size_t Size() const {
  293. if (mValues.isPresent) {
  294. return mValues.value.size();
  295. } else if (mStringValue.isPresent || mDoubleValue.isPresent || mUint64Value.isPresent || mInt64Value.isPresent || mBoolValue.isPresent) {
  296. return 1;
  297. }
  298. return 0;
  299. }
  300. CustomExtension() = default;
  301. ~CustomExtension() = default;
  302. CustomExtension(const CustomExtension &other) :
  303. name(other.name),
  304. mStringValue(other.mStringValue),
  305. mDoubleValue(other.mDoubleValue),
  306. mUint64Value(other.mUint64Value),
  307. mInt64Value(other.mInt64Value),
  308. mBoolValue(other.mBoolValue),
  309. mValues(other.mValues) {
  310. // empty
  311. }
  312. };
  313. //! Base class for all glTF top-level objects
  314. struct Object {
  315. int index; //!< The index of this object within its property container
  316. int oIndex; //!< The original index of this object defined in the JSON
  317. std::string id; //!< The globally unique ID used to reference this object
  318. std::string name; //!< The user-defined name of this object
  319. CustomExtension customExtensions;
  320. CustomExtension extras;
  321. //! Objects marked as special are not exported (used to emulate the binary body buffer)
  322. virtual bool IsSpecial() const { return false; }
  323. virtual ~Object() {}
  324. //! Maps special IDs to another ID, where needed. Subclasses may override it (statically)
  325. static const char *TranslateId(Asset & /*r*/, const char *id) { return id; }
  326. inline Value *FindString(Value &val, const char *id);
  327. inline Value *FindNumber(Value &val, const char *id);
  328. inline Value *FindUInt(Value &val, const char *id);
  329. inline Value *FindArray(Value &val, const char *id);
  330. inline Value *FindObject(Value &val, const char *id);
  331. inline Value *FindExtension(Value &val, const char *extensionId);
  332. inline void ReadExtensions(Value &val);
  333. inline void ReadExtras(Value &val);
  334. };
  335. //
  336. // Classes for each glTF top-level object type
  337. //
  338. //! A buffer points to binary geometry, animation, or skins.
  339. struct Buffer : public Object {
  340. /********************* Types *********************/
  341. public:
  342. enum Type {
  343. Type_arraybuffer,
  344. Type_text
  345. };
  346. /// \struct SEncodedRegion
  347. /// Descriptor of encoded region in "bufferView".
  348. struct SEncodedRegion {
  349. const size_t Offset; ///< Offset from begin of "bufferView" to encoded region, in bytes.
  350. const size_t EncodedData_Length; ///< Size of encoded region, in bytes.
  351. uint8_t *const DecodedData; ///< Cached encoded data.
  352. const size_t DecodedData_Length; ///< Size of decoded region, in bytes.
  353. const std::string ID; ///< ID of the region.
  354. /// \fn SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string pID)
  355. /// Constructor.
  356. /// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
  357. /// \param [in] pEncodedData_Length - size of encoded region, in bytes.
  358. /// \param [in] pDecodedData - pointer to decoded data array.
  359. /// \param [in] pDecodedData_Length - size of encoded region, in bytes.
  360. /// \param [in] pID - ID of the region.
  361. SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID) :
  362. Offset(pOffset),
  363. EncodedData_Length(pEncodedData_Length),
  364. DecodedData(pDecodedData),
  365. DecodedData_Length(pDecodedData_Length),
  366. ID(pID) {}
  367. /// \fn ~SEncodedRegion()
  368. /// Destructor.
  369. ~SEncodedRegion() { delete[] DecodedData; }
  370. };
  371. /******************* Variables *******************/
  372. //std::string uri; //!< The uri of the buffer. Can be a filepath, a data uri, etc. (required)
  373. size_t byteLength; //!< The length of the buffer in bytes. (default: 0)
  374. //std::string type; //!< XMLHttpRequest responseType (default: "arraybuffer")
  375. size_t capacity = 0; //!< The capacity of the buffer in bytes. (default: 0)
  376. Type type;
  377. /// \var EncodedRegion_Current
  378. /// Pointer to currently active encoded region.
  379. /// Why not decoding all regions at once and not to set one buffer with decoded data?
  380. /// Yes, why not? Even "accessor" point to decoded data. I mean that fields "byteOffset", "byteStride" and "count" has values which describes decoded
  381. /// data array. But only in range of mesh while is active parameters from "compressedData". For another mesh accessors point to decoded data too. But
  382. /// offset is counted for another regions is encoded.
  383. /// Example. You have two meshes. For every of it you have 4 bytes of data. That data compressed to 2 bytes. So, you have buffer with encoded data:
  384. /// M1_E0, M1_E1, M2_E0, M2_E1.
  385. /// After decoding you'll get:
  386. /// M1_D0, M1_D1, M1_D2, M1_D3, M2_D0, M2_D1, M2_D2, M2_D3.
  387. /// "accessors" must to use values that point to decoded data - obviously. So, you'll expect "accessors" like
  388. /// "accessor_0" : { byteOffset: 0, byteLength: 4}, "accessor_1" : { byteOffset: 4, byteLength: 4}
  389. /// but in real life you'll get:
  390. /// "accessor_0" : { byteOffset: 0, byteLength: 4}, "accessor_1" : { byteOffset: 2, byteLength: 4}
  391. /// Yes, accessor of next mesh has offset and length which mean: current mesh data is decoded, all other data is encoded.
  392. /// And when before you start to read data of current mesh (with encoded data of course) you must decode region of "bufferView", after read finished
  393. /// delete encoding mark. And after that you can repeat process: decode data of mesh, read, delete decoded data.
  394. ///
  395. /// Remark. Encoding all data at once is good in world with computers which do not has RAM limitation. So, you must use step by step encoding in
  396. /// exporter and importer. And, thanks to such way, there is no need to load whole file into memory.
  397. SEncodedRegion *EncodedRegion_Current;
  398. private:
  399. shared_ptr<uint8_t> mData; //!< Pointer to the data
  400. bool mIsSpecial; //!< Set to true for special cases (e.g. the body buffer)
  401. /// \var EncodedRegion_List
  402. /// List of encoded regions.
  403. std::list<SEncodedRegion *> EncodedRegion_List;
  404. /******************* Functions *******************/
  405. public:
  406. Buffer();
  407. ~Buffer();
  408. void Read(Value &obj, Asset &r);
  409. bool LoadFromStream(IOStream &stream, size_t length = 0, size_t baseOffset = 0);
  410. /// \fn void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string& pID)
  411. /// Mark region of "bufferView" as encoded. When data is request from such region then "bufferView" use decoded data.
  412. /// \param [in] pOffset - offset from begin of "bufferView" to encoded region, in bytes.
  413. /// \param [in] pEncodedData_Length - size of encoded region, in bytes.
  414. /// \param [in] pDecodedData - pointer to decoded data array.
  415. /// \param [in] pDecodedData_Length - size of encoded region, in bytes.
  416. /// \param [in] pID - ID of the region.
  417. void EncodedRegion_Mark(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID);
  418. /// \fn void EncodedRegion_SetCurrent(const std::string& pID)
  419. /// Select current encoded region by ID. \sa EncodedRegion_Current.
  420. /// \param [in] pID - ID of the region.
  421. void EncodedRegion_SetCurrent(const std::string &pID);
  422. /// \fn bool ReplaceData(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t* pReplace_Data, const size_t pReplace_Count)
  423. /// Replace part of buffer data. Pay attention that function work with original array of data (\ref mData) not with encoded regions.
  424. /// \param [in] pBufferData_Offset - index of first element in buffer from which new data will be placed.
  425. /// \param [in] pBufferData_Count - count of bytes in buffer which will be replaced.
  426. /// \param [in] pReplace_Data - pointer to array with new data for buffer.
  427. /// \param [in] pReplace_Count - count of bytes in new data.
  428. /// \return true - if successfully replaced, false if input arguments is out of range.
  429. bool ReplaceData(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t *pReplace_Data, const size_t pReplace_Count);
  430. bool ReplaceData_joint(const size_t pBufferData_Offset, const size_t pBufferData_Count, const uint8_t *pReplace_Data, const size_t pReplace_Count);
  431. size_t AppendData(uint8_t *data, size_t length);
  432. void Grow(size_t amount);
  433. uint8_t *GetPointer() { return mData.get(); }
  434. void MarkAsSpecial() { mIsSpecial = true; }
  435. bool IsSpecial() const override { return mIsSpecial; }
  436. std::string GetURI() { return std::string(this->id) + ".bin"; }
  437. static const char *TranslateId(Asset &r, const char *id);
  438. };
  439. //! A view into a buffer generally representing a subset of the buffer.
  440. struct BufferView : public Object {
  441. Ref<Buffer> buffer; //! The ID of the buffer. (required)
  442. size_t byteOffset; //! The offset into the buffer in bytes. (required)
  443. size_t byteLength; //! The length of the bufferView in bytes. (default: 0)
  444. unsigned int byteStride; //!< The stride, in bytes, between attributes referenced by this accessor. (default: 0)
  445. BufferViewTarget target; //! The target that the WebGL buffer should be bound to.
  446. void Read(Value &obj, Asset &r);
  447. uint8_t *GetPointer(size_t accOffset);
  448. };
  449. //! A typed view into a BufferView. A BufferView contains raw binary data.
  450. //! An accessor provides a typed view into a BufferView or a subset of a BufferView
  451. //! similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer.
  452. struct Accessor : public Object {
  453. struct Sparse;
  454. Ref<BufferView> bufferView; //!< The ID of the bufferView. (required)
  455. size_t byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required)
  456. ComponentType componentType; //!< The datatype of components in the attribute. (required)
  457. size_t count; //!< The number of attributes referenced by this accessor. (required)
  458. AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
  459. std::vector<double> max; //!< Maximum value of each component in this attribute.
  460. std::vector<double> min; //!< Minimum value of each component in this attribute.
  461. std::unique_ptr<Sparse> sparse;
  462. std::unique_ptr<Buffer> decodedBuffer; // Packed decoded data, returned instead of original bufferView if present
  463. unsigned int GetNumComponents();
  464. unsigned int GetBytesPerComponent();
  465. unsigned int GetElementSize();
  466. inline uint8_t *GetPointer();
  467. inline size_t GetStride();
  468. inline size_t GetMaxByteSize();
  469. template <class T>
  470. void ExtractData(T *&outData);
  471. void WriteData(size_t count, const void *src_buffer, size_t src_stride);
  472. void WriteSparseValues(size_t count, const void *src_data, size_t src_dataStride);
  473. void WriteSparseIndices(size_t count, const void *src_idx, size_t src_idxStride);
  474. //! Helper class to iterate the data
  475. class Indexer {
  476. friend struct Accessor;
  477. // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
  478. // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field]
  479. protected:
  480. Accessor &accessor;
  481. private:
  482. uint8_t *data;
  483. size_t elemSize, stride;
  484. Indexer(Accessor &acc);
  485. public:
  486. //! Accesses the i-th value as defined by the accessor
  487. template <class T>
  488. T GetValue(int i);
  489. //! Accesses the i-th value as defined by the accessor
  490. inline unsigned int GetUInt(int i) {
  491. return GetValue<unsigned int>(i);
  492. }
  493. inline bool IsValid() const {
  494. return data != nullptr;
  495. }
  496. };
  497. inline Indexer GetIndexer() {
  498. return Indexer(*this);
  499. }
  500. Accessor() {}
  501. void Read(Value &obj, Asset &r);
  502. //sparse
  503. struct Sparse {
  504. size_t count;
  505. ComponentType indicesType;
  506. Ref<BufferView> indices;
  507. size_t indicesByteOffset;
  508. Ref<BufferView> values;
  509. size_t valuesByteOffset;
  510. std::vector<uint8_t> data; //!< Actual data, which may be defaulted to an array of zeros or the original data, with the sparse buffer view applied on top of it.
  511. void PopulateData(size_t numBytes, uint8_t *bytes);
  512. void PatchData(unsigned int elementSize);
  513. };
  514. };
  515. struct Camera : public Object {
  516. enum Type {
  517. Perspective,
  518. Orthographic
  519. };
  520. Type type;
  521. union {
  522. struct {
  523. float aspectRatio; //!<The floating - point aspect ratio of the field of view. (0 = undefined = use the canvas one)
  524. float yfov; //!<The floating - point vertical field of view in radians. (required)
  525. float zfar; //!<The floating - point distance to the far clipping plane. (required)
  526. float znear; //!< The floating - point distance to the near clipping plane. (required)
  527. } perspective;
  528. struct {
  529. float xmag; //! The floating-point horizontal magnification of the view. (required)
  530. float ymag; //! The floating-point vertical magnification of the view. (required)
  531. float zfar; //! The floating-point distance to the far clipping plane. (required)
  532. float znear; //! The floating-point distance to the near clipping plane. (required)
  533. } ortographic;
  534. } cameraProperties;
  535. Camera() :
  536. type(Perspective),
  537. cameraProperties() {
  538. // empty
  539. }
  540. void Read(Value &obj, Asset &r);
  541. };
  542. //! A light (from KHR_lights_punctual extension)
  543. struct Light : public Object {
  544. enum Type {
  545. Directional,
  546. Point,
  547. Spot
  548. };
  549. Type type;
  550. vec3 color;
  551. float intensity;
  552. Nullable<float> range;
  553. float innerConeAngle;
  554. float outerConeAngle;
  555. Light() {}
  556. void Read(Value &obj, Asset &r);
  557. };
  558. //! Image data used to create a texture.
  559. struct Image : public Object {
  560. std::string uri; //! The uri of the image, that can be a file path, a data URI, etc.. (required)
  561. Ref<BufferView> bufferView;
  562. std::string mimeType;
  563. int width, height;
  564. private:
  565. std::unique_ptr<uint8_t[]> mData;
  566. size_t mDataLength;
  567. public:
  568. Image();
  569. void Read(Value &obj, Asset &r);
  570. inline bool HasData() const { return mDataLength > 0; }
  571. inline size_t GetDataLength() const { return mDataLength; }
  572. inline const uint8_t *GetData() const { return mData.get(); }
  573. inline uint8_t *StealData();
  574. inline void SetData(uint8_t *data, size_t length, Asset &r);
  575. };
  576. const vec4 defaultBaseColor = { 1, 1, 1, 1 };
  577. const vec3 defaultEmissiveFactor = { 0, 0, 0 };
  578. const vec4 defaultDiffuseFactor = { 1, 1, 1, 1 };
  579. const vec3 defaultSpecularFactor = { 1, 1, 1 };
  580. const vec3 defaultSheenFactor = { 0, 0, 0 };
  581. const vec3 defaultAttenuationColor = { 1, 1, 1 };
  582. struct TextureInfo {
  583. Ref<Texture> texture;
  584. unsigned int index;
  585. unsigned int texCoord = 0;
  586. bool textureTransformSupported = false;
  587. struct TextureTransformExt {
  588. float offset[2];
  589. float rotation;
  590. float scale[2];
  591. } TextureTransformExt_t;
  592. };
  593. struct NormalTextureInfo : TextureInfo {
  594. float scale = 1;
  595. };
  596. struct OcclusionTextureInfo : TextureInfo {
  597. float strength = 1;
  598. };
  599. struct PbrMetallicRoughness {
  600. vec4 baseColorFactor;
  601. TextureInfo baseColorTexture;
  602. TextureInfo metallicRoughnessTexture;
  603. float metallicFactor;
  604. float roughnessFactor;
  605. };
  606. struct PbrSpecularGlossiness {
  607. vec4 diffuseFactor;
  608. vec3 specularFactor;
  609. float glossinessFactor;
  610. TextureInfo diffuseTexture;
  611. TextureInfo specularGlossinessTexture;
  612. PbrSpecularGlossiness() { SetDefaults(); }
  613. void SetDefaults();
  614. };
  615. struct MaterialSheen {
  616. vec3 sheenColorFactor;
  617. float sheenRoughnessFactor;
  618. TextureInfo sheenColorTexture;
  619. TextureInfo sheenRoughnessTexture;
  620. MaterialSheen() { SetDefaults(); }
  621. void SetDefaults();
  622. };
  623. struct MaterialClearcoat {
  624. float clearcoatFactor = 0.f;
  625. float clearcoatRoughnessFactor = 0.f;
  626. TextureInfo clearcoatTexture;
  627. TextureInfo clearcoatRoughnessTexture;
  628. NormalTextureInfo clearcoatNormalTexture;
  629. };
  630. struct MaterialTransmission {
  631. TextureInfo transmissionTexture;
  632. float transmissionFactor = 0.f;
  633. };
  634. struct MaterialVolume {
  635. float thicknessFactor = 0.f;
  636. TextureInfo thicknessTexture;
  637. float attenuationDistance = 0.f;
  638. vec3 attenuationColor;
  639. MaterialVolume() { SetDefaults(); }
  640. void SetDefaults();
  641. };
  642. struct MaterialIOR {
  643. float ior = 0.f;
  644. MaterialIOR() { SetDefaults(); }
  645. void SetDefaults();
  646. };
  647. //! The material appearance of a primitive.
  648. struct Material : public Object {
  649. //PBR metallic roughness properties
  650. PbrMetallicRoughness pbrMetallicRoughness;
  651. //other basic material properties
  652. NormalTextureInfo normalTexture;
  653. OcclusionTextureInfo occlusionTexture;
  654. TextureInfo emissiveTexture;
  655. vec3 emissiveFactor;
  656. std::string alphaMode;
  657. float alphaCutoff;
  658. bool doubleSided;
  659. //extension: KHR_materials_pbrSpecularGlossiness
  660. Nullable<PbrSpecularGlossiness> pbrSpecularGlossiness;
  661. //extension: KHR_materials_sheen
  662. Nullable<MaterialSheen> materialSheen;
  663. //extension: KHR_materials_clearcoat
  664. Nullable<MaterialClearcoat> materialClearcoat;
  665. //extension: KHR_materials_transmission
  666. Nullable<MaterialTransmission> materialTransmission;
  667. //extension: KHR_materials_volume
  668. Nullable<MaterialVolume> materialVolume;
  669. //extension: KHR_materials_ior
  670. Nullable<MaterialIOR> materialIOR;
  671. //extension: KHR_materials_unlit
  672. bool unlit;
  673. Material() { SetDefaults(); }
  674. void Read(Value &obj, Asset &r);
  675. void SetDefaults();
  676. inline void SetTextureProperties(Asset &r, Value *prop, TextureInfo &out);
  677. inline void ReadTextureProperty(Asset &r, Value &vals, const char *propName, TextureInfo &out);
  678. inline void ReadTextureProperty(Asset &r, Value &vals, const char *propName, NormalTextureInfo &out);
  679. inline void ReadTextureProperty(Asset &r, Value &vals, const char *propName, OcclusionTextureInfo &out);
  680. };
  681. //! A set of primitives to be rendered. A node can contain one or more meshes. A node's transform places the mesh in the scene.
  682. struct Mesh : public Object {
  683. using AccessorList = std::vector<Ref<Accessor>>;
  684. struct Primitive {
  685. PrimitiveMode mode;
  686. struct Attributes {
  687. AccessorList position, normal, tangent, texcoord, color, joint, jointmatrix, weight;
  688. } attributes;
  689. Ref<Accessor> indices;
  690. Ref<Material> material;
  691. struct Target {
  692. AccessorList position, normal, tangent;
  693. };
  694. std::vector<Target> targets;
  695. // extension: FB_ngon_encoding
  696. bool ngonEncoded;
  697. Primitive(): ngonEncoded(false) {}
  698. };
  699. std::vector<Primitive> primitives;
  700. std::vector<float> weights;
  701. std::vector<std::string> targetNames;
  702. Mesh() {}
  703. /// Get mesh data from JSON-object and place them to root asset.
  704. /// \param [in] pJSON_Object - reference to pJSON-object from which data are read.
  705. /// \param [out] pAsset_Root - reference to root asset where data will be stored.
  706. void Read(Value &pJSON_Object, Asset &pAsset_Root);
  707. };
  708. struct Node : public Object {
  709. std::vector<Ref<Node>> children;
  710. std::vector<Ref<Mesh>> meshes;
  711. Nullable<mat4> matrix;
  712. Nullable<vec3> translation;
  713. Nullable<vec4> rotation;
  714. Nullable<vec3> scale;
  715. Ref<Camera> camera;
  716. Ref<Light> light;
  717. std::vector<Ref<Node>> skeletons; //!< The ID of skeleton nodes. Each of which is the root of a node hierarchy.
  718. Ref<Skin> skin; //!< The ID of the skin referenced by this node.
  719. std::string jointName; //!< Name used when this node is a joint in a skin.
  720. Ref<Node> parent; //!< This is not part of the glTF specification. Used as a helper.
  721. Node() {}
  722. void Read(Value &obj, Asset &r);
  723. };
  724. struct Program : public Object {
  725. Program() {}
  726. void Read(Value &obj, Asset &r);
  727. };
  728. struct Sampler : public Object {
  729. SamplerMagFilter magFilter; //!< The texture magnification filter.
  730. SamplerMinFilter minFilter; //!< The texture minification filter.
  731. SamplerWrap wrapS; //!< The texture wrapping in the S direction.
  732. SamplerWrap wrapT; //!< The texture wrapping in the T direction.
  733. Sampler() { SetDefaults(); }
  734. void Read(Value &obj, Asset &r);
  735. void SetDefaults();
  736. };
  737. struct Scene : public Object {
  738. std::string name;
  739. std::vector<Ref<Node>> nodes;
  740. Scene() {}
  741. void Read(Value &obj, Asset &r);
  742. };
  743. struct Shader : public Object {
  744. Shader() {}
  745. void Read(Value &obj, Asset &r);
  746. };
  747. struct Skin : public Object {
  748. Nullable<mat4> bindShapeMatrix; //!< Floating-point 4x4 transformation matrix stored in column-major order.
  749. Ref<Accessor> inverseBindMatrices; //!< The ID of the accessor containing the floating-point 4x4 inverse-bind matrices.
  750. std::vector<Ref<Node>> jointNames; //!< Joint names of the joints (nodes with a jointName property) in this skin.
  751. std::string name; //!< The user-defined name of this object.
  752. Skin() {}
  753. void Read(Value &obj, Asset &r);
  754. };
  755. //! A texture and its sampler.
  756. struct Texture : public Object {
  757. Ref<Sampler> sampler; //!< The ID of the sampler used by this texture. (required)
  758. Ref<Image> source; //!< The ID of the image used by this texture. (required)
  759. //TextureFormat format; //!< The texture's format. (default: TextureFormat_RGBA)
  760. //TextureFormat internalFormat; //!< The texture's internal format. (default: TextureFormat_RGBA)
  761. //TextureTarget target; //!< The target that the WebGL texture should be bound to. (default: TextureTarget_TEXTURE_2D)
  762. //TextureType type; //!< Texel datatype. (default: TextureType_UNSIGNED_BYTE)
  763. Texture() {}
  764. void Read(Value &obj, Asset &r);
  765. };
  766. struct Animation : public Object {
  767. struct Sampler {
  768. Sampler() :
  769. interpolation(Interpolation_LINEAR) {}
  770. Ref<Accessor> input; //!< Accessor reference to the buffer storing the key-frame times.
  771. Ref<Accessor> output; //!< Accessor reference to the buffer storing the key-frame values.
  772. Interpolation interpolation; //!< Type of interpolation algorithm to use between key-frames.
  773. };
  774. struct Target {
  775. Target() :
  776. path(AnimationPath_TRANSLATION) {}
  777. Ref<Node> node; //!< The node to animate.
  778. AnimationPath path; //!< The property of the node to animate.
  779. };
  780. struct Channel {
  781. Channel() :
  782. sampler(-1) {}
  783. int sampler; //!< The sampler index containing the animation data.
  784. Target target; //!< The node and property to animate.
  785. };
  786. std::vector<Sampler> samplers; //!< All the key-frame data for this animation.
  787. std::vector<Channel> channels; //!< Data to connect nodes to key-frames.
  788. Animation() {}
  789. void Read(Value &obj, Asset &r);
  790. };
  791. //! Base class for LazyDict that acts as an interface
  792. class LazyDictBase {
  793. public:
  794. virtual ~LazyDictBase() {}
  795. virtual void AttachToDocument(Document &doc) = 0;
  796. virtual void DetachFromDocument() = 0;
  797. #if !defined(ASSIMP_BUILD_NO_EXPORT)
  798. virtual void WriteObjects(AssetWriter &writer) = 0;
  799. #endif
  800. };
  801. template <class T>
  802. class LazyDict;
  803. //! (Implemented in glTFAssetWriter.h)
  804. template <class T>
  805. void WriteLazyDict(LazyDict<T> &d, AssetWriter &w);
  806. //! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID
  807. //! It is the owner the loaded objects, so when it is destroyed it also deletes them
  808. template <class T>
  809. class LazyDict : public LazyDictBase {
  810. friend class Asset;
  811. friend class AssetWriter;
  812. using Dict = typename std::gltf_unordered_map<unsigned int, unsigned int>;
  813. using IdDict = typename std::gltf_unordered_map<std::string, unsigned int>;
  814. std::vector<T *> mObjs; //! The read objects
  815. Dict mObjsByOIndex; //! The read objects accessible by original index
  816. IdDict mObjsById; //! The read objects accessible by id
  817. const char *mDictId; //! ID of the dictionary object
  818. const char *mExtId; //! ID of the extension defining the dictionary
  819. Value *mDict; //! JSON dictionary object
  820. Asset &mAsset; //! The asset instance
  821. std::gltf_unordered_set<unsigned int> mRecursiveReferenceCheck; //! Used by Retrieve to prevent recursive lookups
  822. void AttachToDocument(Document &doc);
  823. void DetachFromDocument();
  824. #if !defined(ASSIMP_BUILD_NO_EXPORT)
  825. void WriteObjects(AssetWriter &writer) { WriteLazyDict<T>(*this, writer); }
  826. #endif
  827. Ref<T> Add(T *obj);
  828. public:
  829. LazyDict(Asset &asset, const char *dictId, const char *extId = 0);
  830. ~LazyDict();
  831. Ref<T> Retrieve(unsigned int i);
  832. Ref<T> Get(unsigned int i);
  833. Ref<T> Get(const char *id);
  834. Ref<T> Create(const char *id);
  835. Ref<T> Create(const std::string &id) { return Create(id.c_str()); }
  836. unsigned int Remove(const char *id);
  837. inline unsigned int Size() const { return unsigned(mObjs.size()); }
  838. inline T &operator[](size_t i) { return *mObjs[i]; }
  839. };
  840. struct AssetMetadata {
  841. std::string copyright; //!< A copyright message suitable for display to credit the content creator.
  842. std::string generator; //!< Tool that generated this glTF model.Useful for debugging.
  843. struct {
  844. std::string api; //!< Specifies the target rendering API (default: "WebGL")
  845. std::string version; //!< Specifies the target rendering API (default: "1.0.3")
  846. } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {})
  847. std::string version; //!< The glTF format version
  848. void Read(Document &doc);
  849. AssetMetadata() :
  850. version() {}
  851. };
  852. //
  853. // glTF Asset class
  854. //
  855. //! Root object for a glTF asset
  856. class Asset {
  857. using IdMap = std::gltf_unordered_map<std::string, int>;
  858. template <class T>
  859. friend class LazyDict;
  860. friend struct Buffer; // To access OpenFile
  861. friend class AssetWriter;
  862. private:
  863. IOSystem *mIOSystem;
  864. rapidjson::IRemoteSchemaDocumentProvider *mSchemaDocumentProvider;
  865. std::string mCurrentAssetDir;
  866. size_t mSceneLength;
  867. size_t mBodyOffset, mBodyLength;
  868. std::vector<LazyDictBase *> mDicts;
  869. IdMap mUsedIds;
  870. Ref<Buffer> mBodyBuffer;
  871. Asset(Asset &);
  872. Asset &operator=(const Asset &);
  873. public:
  874. //! Keeps info about the enabled extensions
  875. struct Extensions {
  876. bool KHR_materials_pbrSpecularGlossiness;
  877. bool KHR_materials_unlit;
  878. bool KHR_lights_punctual;
  879. bool KHR_texture_transform;
  880. bool KHR_materials_sheen;
  881. bool KHR_materials_clearcoat;
  882. bool KHR_materials_transmission;
  883. bool KHR_materials_volume;
  884. bool KHR_materials_ior;
  885. bool KHR_draco_mesh_compression;
  886. bool FB_ngon_encoding;
  887. bool KHR_texture_basisu;
  888. } extensionsUsed;
  889. //! Keeps info about the required extensions
  890. struct RequiredExtensions {
  891. bool KHR_draco_mesh_compression;
  892. bool KHR_texture_basisu;
  893. } extensionsRequired;
  894. AssetMetadata asset;
  895. Value *extras = nullptr;
  896. // Dictionaries for each type of object
  897. LazyDict<Accessor> accessors;
  898. LazyDict<Animation> animations;
  899. LazyDict<Buffer> buffers;
  900. LazyDict<BufferView> bufferViews;
  901. LazyDict<Camera> cameras;
  902. LazyDict<Light> lights;
  903. LazyDict<Image> images;
  904. LazyDict<Material> materials;
  905. LazyDict<Mesh> meshes;
  906. LazyDict<Node> nodes;
  907. LazyDict<Sampler> samplers;
  908. LazyDict<Scene> scenes;
  909. LazyDict<Skin> skins;
  910. LazyDict<Texture> textures;
  911. Ref<Scene> scene;
  912. public:
  913. Asset(IOSystem *io = nullptr, rapidjson::IRemoteSchemaDocumentProvider *schemaDocumentProvider = nullptr) :
  914. mIOSystem(io),
  915. mSchemaDocumentProvider(schemaDocumentProvider),
  916. asset(),
  917. accessors(*this, "accessors"),
  918. animations(*this, "animations"),
  919. buffers(*this, "buffers"),
  920. bufferViews(*this, "bufferViews"),
  921. cameras(*this, "cameras"),
  922. lights(*this, "lights", "KHR_lights_punctual"),
  923. images(*this, "images"),
  924. materials(*this, "materials"),
  925. meshes(*this, "meshes"),
  926. nodes(*this, "nodes"),
  927. samplers(*this, "samplers"),
  928. scenes(*this, "scenes"),
  929. skins(*this, "skins"),
  930. textures(*this, "textures") {
  931. memset(&extensionsUsed, 0, sizeof(extensionsUsed));
  932. memset(&extensionsRequired, 0, sizeof(extensionsRequired));
  933. }
  934. //! Main function
  935. void Load(const std::string &file, bool isBinary = false);
  936. //! Parse the AssetMetadata and check that the version is 2.
  937. bool CanRead(const std::string &pFile, bool isBinary = false);
  938. //! Enables binary encoding on the asset
  939. void SetAsBinary();
  940. //! Search for an available name, starting from the given strings
  941. std::string FindUniqueID(const std::string &str, const char *suffix);
  942. Ref<Buffer> GetBodyBuffer() { return mBodyBuffer; }
  943. private:
  944. void ReadBinaryHeader(IOStream &stream, std::vector<char> &sceneData);
  945. //! Obtain a JSON document from the stream.
  946. // \param second argument is a buffer used by the document. It must be kept
  947. // alive while the document is in use.
  948. Document ReadDocument(IOStream& stream, bool isBinary, std::vector<char>& sceneData);
  949. void ReadExtensionsUsed(Document &doc);
  950. void ReadExtensionsRequired(Document &doc);
  951. IOStream *OpenFile(const std::string &path, const char *mode, bool absolute = false);
  952. };
  953. inline std::string getContextForErrorMessages(const std::string &id, const std::string &name) {
  954. std::string context = id;
  955. if (!name.empty()) {
  956. context += " (\"" + name + "\")";
  957. }
  958. return context;
  959. }
  960. } // namespace glTF2
  961. // Include the implementation of the methods
  962. #include "glTF2Asset.inl"
  963. #endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
  964. #endif // GLTF2ASSET_H_INC