babylon.glTF2Interface.d.ts 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. /* eslint-disable @typescript-eslint/naming-convention */
  2. /* eslint-disable @typescript-eslint/no-unused-vars */
  3. declare module "babylonjs-gltf2interface" {
  4. export = BABYLON.GLTF2;
  5. }
  6. /**
  7. * Module for glTF 2.0 Interface
  8. */
  9. declare module BABYLON.GLTF2 {
  10. /**
  11. * The datatype of the components in the attribute
  12. */
  13. const enum AccessorComponentType {
  14. /**
  15. * Byte
  16. */
  17. BYTE = 5120,
  18. /**
  19. * Unsigned Byte
  20. */
  21. UNSIGNED_BYTE = 5121,
  22. /**
  23. * Short
  24. */
  25. SHORT = 5122,
  26. /**
  27. * Unsigned Short
  28. */
  29. UNSIGNED_SHORT = 5123,
  30. /**
  31. * Unsigned Int
  32. */
  33. UNSIGNED_INT = 5125,
  34. /**
  35. * Float
  36. */
  37. FLOAT = 5126,
  38. }
  39. /**
  40. * Specifies if the attirbute is a scalar, vector, or matrix
  41. */
  42. const enum AccessorType {
  43. /**
  44. * Scalar
  45. */
  46. SCALAR = "SCALAR",
  47. /**
  48. * Vector2
  49. */
  50. VEC2 = "VEC2",
  51. /**
  52. * Vector3
  53. */
  54. VEC3 = "VEC3",
  55. /**
  56. * Vector4
  57. */
  58. VEC4 = "VEC4",
  59. /**
  60. * Matrix2x2
  61. */
  62. MAT2 = "MAT2",
  63. /**
  64. * Matrix3x3
  65. */
  66. MAT3 = "MAT3",
  67. /**
  68. * Matrix4x4
  69. */
  70. MAT4 = "MAT4",
  71. }
  72. /**
  73. * The name of the node's TRS property to modify,
  74. * or the weights of the Morph Targets it instantiates,
  75. * or pointer is use of KHR_animation_pointer extension
  76. */
  77. const enum AnimationChannelTargetPath {
  78. /**
  79. * Translation
  80. */
  81. TRANSLATION = "translation",
  82. /**
  83. * Rotation
  84. */
  85. ROTATION = "rotation",
  86. /**
  87. * Scale
  88. */
  89. SCALE = "scale",
  90. /**
  91. * Weights
  92. */
  93. WEIGHTS = "weights",
  94. /**
  95. * Pointer
  96. */
  97. POINTER = "pointer",
  98. }
  99. /**
  100. * Interpolation algorithm
  101. */
  102. const enum AnimationSamplerInterpolation {
  103. /**
  104. * The animated values are linearly interpolated between keyframes
  105. */
  106. LINEAR = "LINEAR",
  107. /**
  108. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  109. */
  110. STEP = "STEP",
  111. /**
  112. * The animation's interpolation is computed using a cubic spline with specified tangents
  113. */
  114. CUBICSPLINE = "CUBICSPLINE",
  115. }
  116. /**
  117. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  118. */
  119. const enum CameraType {
  120. /**
  121. * A perspective camera containing properties to create a perspective projection matrix
  122. */
  123. PERSPECTIVE = "perspective",
  124. /**
  125. * An orthographic camera containing properties to create an orthographic projection matrix
  126. */
  127. ORTHOGRAPHIC = "orthographic",
  128. }
  129. /**
  130. * The mime-type of the image
  131. */
  132. const enum ImageMimeType {
  133. /**
  134. * JPEG Mime-type
  135. */
  136. JPEG = "image/jpeg",
  137. /**
  138. * PNG Mime-type
  139. */
  140. PNG = "image/png",
  141. /**
  142. * WEBP Mime-type
  143. */
  144. WEBP = "image/webp",
  145. /**
  146. * AVIF Mime-type
  147. */
  148. AVIF = "image/avif",
  149. }
  150. /**
  151. * The alpha rendering mode of the material
  152. */
  153. const enum MaterialAlphaMode {
  154. /**
  155. * The alpha value is ignored and the rendered output is fully opaque
  156. */
  157. OPAQUE = "OPAQUE",
  158. /**
  159. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  160. */
  161. MASK = "MASK",
  162. /**
  163. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  164. */
  165. BLEND = "BLEND",
  166. }
  167. /**
  168. * The type of the primitives to render
  169. */
  170. const enum MeshPrimitiveMode {
  171. /**
  172. * Points
  173. */
  174. POINTS = 0,
  175. /**
  176. * Lines
  177. */
  178. LINES = 1,
  179. /**
  180. * Line Loop
  181. */
  182. LINE_LOOP = 2,
  183. /**
  184. * Line Strip
  185. */
  186. LINE_STRIP = 3,
  187. /**
  188. * Triangles
  189. */
  190. TRIANGLES = 4,
  191. /**
  192. * Triangle Strip
  193. */
  194. TRIANGLE_STRIP = 5,
  195. /**
  196. * Triangle Fan
  197. */
  198. TRIANGLE_FAN = 6,
  199. }
  200. /**
  201. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  202. */
  203. const enum TextureMagFilter {
  204. /**
  205. * Nearest
  206. */
  207. NEAREST = 9728,
  208. /**
  209. * Linear
  210. */
  211. LINEAR = 9729,
  212. }
  213. /**
  214. * Minification filter. All valid values correspond to WebGL enums
  215. */
  216. const enum TextureMinFilter {
  217. /**
  218. * Nearest
  219. */
  220. NEAREST = 9728,
  221. /**
  222. * Linear
  223. */
  224. LINEAR = 9729,
  225. /**
  226. * Nearest Mip-Map Nearest
  227. */
  228. NEAREST_MIPMAP_NEAREST = 9984,
  229. /**
  230. * Linear Mipmap Nearest
  231. */
  232. LINEAR_MIPMAP_NEAREST = 9985,
  233. /**
  234. * Nearest Mipmap Linear
  235. */
  236. NEAREST_MIPMAP_LINEAR = 9986,
  237. /**
  238. * Linear Mipmap Linear
  239. */
  240. LINEAR_MIPMAP_LINEAR = 9987,
  241. }
  242. /**
  243. * S (U) wrapping mode. All valid values correspond to WebGL enums
  244. */
  245. const enum TextureWrapMode {
  246. /**
  247. * Clamp to Edge
  248. */
  249. CLAMP_TO_EDGE = 33071,
  250. /**
  251. * Mirrored Repeat
  252. */
  253. MIRRORED_REPEAT = 33648,
  254. /**
  255. * Repeat
  256. */
  257. REPEAT = 10497,
  258. }
  259. /**
  260. * glTF Property
  261. */
  262. interface IProperty {
  263. /**
  264. * Dictionary object with extension-specific objects
  265. */
  266. extensions?: {
  267. [key: string]: any;
  268. };
  269. /**
  270. * Application-Specific data
  271. */
  272. extras?: any;
  273. }
  274. /**
  275. * glTF Child of Root Property
  276. */
  277. interface IChildRootProperty extends IProperty {
  278. /**
  279. * The user-defined name of this object
  280. */
  281. name?: string;
  282. }
  283. /**
  284. * Indices of those attributes that deviate from their initialization value
  285. */
  286. interface IAccessorSparseIndices extends IProperty {
  287. /**
  288. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  289. */
  290. bufferView: number;
  291. /**
  292. * The offset relative to the start of the bufferView in bytes. Must be aligned
  293. */
  294. byteOffset?: number;
  295. /**
  296. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  297. */
  298. componentType: AccessorComponentType;
  299. }
  300. /**
  301. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  302. */
  303. interface IAccessorSparseValues extends IProperty {
  304. /**
  305. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  306. */
  307. bufferView: number;
  308. /**
  309. * The offset relative to the start of the bufferView in bytes. Must be aligned
  310. */
  311. byteOffset?: number;
  312. }
  313. /**
  314. * Sparse storage of attributes that deviate from their initialization value
  315. */
  316. interface IAccessorSparse extends IProperty {
  317. /**
  318. * The number of attributes encoded in this sparse accessor
  319. */
  320. count: number;
  321. /**
  322. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  323. */
  324. indices: IAccessorSparseIndices;
  325. /**
  326. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  327. */
  328. values: IAccessorSparseValues;
  329. }
  330. /**
  331. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  332. */
  333. interface IAccessor extends IChildRootProperty {
  334. /**
  335. * The index of the bufferview
  336. */
  337. bufferView?: number;
  338. /**
  339. * The offset relative to the start of the bufferView in bytes
  340. */
  341. byteOffset?: number;
  342. /**
  343. * The datatype of components in the attribute
  344. */
  345. componentType: AccessorComponentType;
  346. /**
  347. * Specifies whether integer data values should be normalized
  348. */
  349. normalized?: boolean;
  350. /**
  351. * The number of attributes referenced by this accessor
  352. */
  353. count: number;
  354. /**
  355. * Specifies if the attribute is a scalar, vector, or matrix
  356. */
  357. type: AccessorType;
  358. /**
  359. * Maximum value of each component in this attribute
  360. */
  361. max?: number[];
  362. /**
  363. * Minimum value of each component in this attribute
  364. */
  365. min?: number[];
  366. /**
  367. * Sparse storage of attributes that deviate from their initialization value
  368. */
  369. sparse?: IAccessorSparse;
  370. }
  371. /**
  372. * Targets an animation's sampler at a node's property
  373. */
  374. interface IAnimationChannel extends IProperty {
  375. /**
  376. * The index of a sampler in this animation used to compute the value for the target
  377. */
  378. sampler: number;
  379. /**
  380. * The index of the node and TRS property to target
  381. */
  382. target: IAnimationChannelTarget;
  383. }
  384. /**
  385. * The index of the node and TRS property that an animation channel targets
  386. */
  387. interface IAnimationChannelTarget extends IProperty {
  388. /**
  389. * The index of the node to target
  390. */
  391. node?: number;
  392. /**
  393. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  394. */
  395. path: AnimationChannelTargetPath;
  396. }
  397. /**
  398. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  399. */
  400. interface IAnimationSampler extends IProperty {
  401. /**
  402. * The index of an accessor containing keyframe input values, e.g., time
  403. */
  404. input: number;
  405. /**
  406. * Interpolation algorithm
  407. */
  408. interpolation?: AnimationSamplerInterpolation;
  409. /**
  410. * The index of an accessor, containing keyframe output values
  411. */
  412. output: number;
  413. }
  414. /**
  415. * A keyframe animation
  416. */
  417. interface IAnimation extends IChildRootProperty {
  418. /**
  419. * An array of channels, each of which targets an animation's sampler at a node's property
  420. */
  421. channels: IAnimationChannel[];
  422. /**
  423. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  424. */
  425. samplers: IAnimationSampler[];
  426. }
  427. /**
  428. * Metadata about the glTF asset
  429. */
  430. interface IAsset extends IChildRootProperty {
  431. /**
  432. * A copyright message suitable for display to credit the content creator
  433. */
  434. copyright?: string;
  435. /**
  436. * Tool that generated this glTF model. Useful for debugging
  437. */
  438. generator?: string;
  439. /**
  440. * The glTF version that this asset targets
  441. */
  442. version: string;
  443. /**
  444. * The minimum glTF version that this asset targets
  445. */
  446. minVersion?: string;
  447. }
  448. /**
  449. * A buffer points to binary geometry, animation, or skins
  450. */
  451. interface IBuffer extends IChildRootProperty {
  452. /**
  453. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  454. */
  455. uri?: string;
  456. /**
  457. * The length of the buffer in bytes
  458. */
  459. byteLength: number;
  460. }
  461. /**
  462. * A view into a buffer generally representing a subset of the buffer
  463. */
  464. interface IBufferView extends IChildRootProperty {
  465. /**
  466. * The index of the buffer
  467. */
  468. buffer: number;
  469. /**
  470. * The offset into the buffer in bytes
  471. */
  472. byteOffset?: number;
  473. /**
  474. * The lenth of the bufferView in bytes
  475. */
  476. byteLength: number;
  477. /**
  478. * The stride, in bytes
  479. */
  480. byteStride?: number;
  481. }
  482. /**
  483. * An orthographic camera containing properties to create an orthographic projection matrix
  484. */
  485. interface ICameraOrthographic extends IProperty {
  486. /**
  487. * The floating-point horizontal magnification of the view. Must not be zero
  488. */
  489. xmag: number;
  490. /**
  491. * The floating-point vertical magnification of the view. Must not be zero
  492. */
  493. ymag: number;
  494. /**
  495. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  496. */
  497. zfar: number;
  498. /**
  499. * The floating-point distance to the near clipping plane
  500. */
  501. znear: number;
  502. }
  503. /**
  504. * A perspective camera containing properties to create a perspective projection matrix
  505. */
  506. interface ICameraPerspective extends IProperty {
  507. /**
  508. * The floating-point aspect ratio of the field of view
  509. */
  510. aspectRatio?: number;
  511. /**
  512. * The floating-point vertical field of view in radians
  513. */
  514. yfov: number;
  515. /**
  516. * The floating-point distance to the far clipping plane
  517. */
  518. zfar?: number;
  519. /**
  520. * The floating-point distance to the near clipping plane
  521. */
  522. znear: number;
  523. }
  524. /**
  525. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  526. */
  527. interface ICamera extends IChildRootProperty {
  528. /**
  529. * An orthographic camera containing properties to create an orthographic projection matrix
  530. */
  531. orthographic?: ICameraOrthographic;
  532. /**
  533. * A perspective camera containing properties to create a perspective projection matrix
  534. */
  535. perspective?: ICameraPerspective;
  536. /**
  537. * Specifies if the camera uses a perspective or orthographic projection
  538. */
  539. type: CameraType;
  540. }
  541. /**
  542. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  543. */
  544. interface IImage extends IChildRootProperty {
  545. /**
  546. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  547. */
  548. uri?: string;
  549. /**
  550. * The image's MIME type
  551. */
  552. mimeType?: ImageMimeType;
  553. /**
  554. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  555. */
  556. bufferView?: number;
  557. }
  558. /**
  559. * Material Normal Texture Info
  560. */
  561. interface IMaterialNormalTextureInfo extends ITextureInfo {
  562. /**
  563. * The scalar multiplier applied to each normal vector of the normal texture
  564. */
  565. scale?: number;
  566. }
  567. /**
  568. * Material Occlusion Texture Info
  569. */
  570. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  571. /**
  572. * A scalar multiplier controlling the amount of occlusion applied
  573. */
  574. strength?: number;
  575. }
  576. /**
  577. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  578. */
  579. interface IMaterialPbrMetallicRoughness {
  580. /**
  581. * The material's base color factor
  582. */
  583. baseColorFactor?: number[];
  584. /**
  585. * The base color texture
  586. */
  587. baseColorTexture?: ITextureInfo;
  588. /**
  589. * The metalness of the material
  590. */
  591. metallicFactor?: number;
  592. /**
  593. * The roughness of the material
  594. */
  595. roughnessFactor?: number;
  596. /**
  597. * The metallic-roughness texture
  598. */
  599. metallicRoughnessTexture?: ITextureInfo;
  600. }
  601. /**
  602. * The material appearance of a primitive
  603. */
  604. interface IMaterial extends IChildRootProperty {
  605. /**
  606. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  607. */
  608. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  609. /**
  610. * The normal map texture
  611. */
  612. normalTexture?: IMaterialNormalTextureInfo;
  613. /**
  614. * The occlusion map texture
  615. */
  616. occlusionTexture?: IMaterialOcclusionTextureInfo;
  617. /**
  618. * The emissive map texture
  619. */
  620. emissiveTexture?: ITextureInfo;
  621. /**
  622. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  623. */
  624. emissiveFactor?: number[];
  625. /**
  626. * The alpha rendering mode of the material
  627. */
  628. alphaMode?: MaterialAlphaMode;
  629. /**
  630. * The alpha cutoff value of the material
  631. */
  632. alphaCutoff?: number;
  633. /**
  634. * Specifies whether the material is double sided
  635. */
  636. doubleSided?: boolean;
  637. }
  638. /**
  639. * Geometry to be rendered with the given material
  640. */
  641. interface IMeshPrimitive extends IProperty {
  642. /**
  643. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  644. */
  645. attributes: {
  646. [name: string]: number;
  647. };
  648. /**
  649. * The index of the accessor that contains the indices
  650. */
  651. indices?: number;
  652. /**
  653. * The index of the material to apply to this primitive when rendering
  654. */
  655. material?: number;
  656. /**
  657. * The type of primitives to render. All valid values correspond to WebGL enums
  658. */
  659. mode?: MeshPrimitiveMode;
  660. /**
  661. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  662. */
  663. targets?: {
  664. [name: string]: number;
  665. }[];
  666. }
  667. /**
  668. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  669. */
  670. interface IMesh extends IChildRootProperty {
  671. /**
  672. * An array of primitives, each defining geometry to be rendered with a material
  673. */
  674. primitives: IMeshPrimitive[];
  675. /**
  676. * Array of weights to be applied to the Morph Targets
  677. */
  678. weights?: number[];
  679. }
  680. /**
  681. * A node in the node hierarchy
  682. */
  683. interface INode extends IChildRootProperty {
  684. /**
  685. * The index of the camera referenced by this node
  686. */
  687. camera?: number;
  688. /**
  689. * The indices of this node's children
  690. */
  691. children?: number[];
  692. /**
  693. * The index of the skin referenced by this node
  694. */
  695. skin?: number;
  696. /**
  697. * A floating-point 4x4 transformation matrix stored in column-major order
  698. */
  699. matrix?: number[];
  700. /**
  701. * The index of the mesh in this node
  702. */
  703. mesh?: number;
  704. /**
  705. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  706. */
  707. rotation?: number[];
  708. /**
  709. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  710. */
  711. scale?: number[];
  712. /**
  713. * The node's translation along the x, y, and z axes
  714. */
  715. translation?: number[];
  716. /**
  717. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  718. */
  719. weights?: number[];
  720. }
  721. /**
  722. * Texture sampler properties for filtering and wrapping modes
  723. */
  724. interface ISampler extends IChildRootProperty {
  725. /**
  726. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  727. */
  728. magFilter?: TextureMagFilter;
  729. /**
  730. * Minification filter. All valid values correspond to WebGL enums
  731. */
  732. minFilter?: TextureMinFilter;
  733. /**
  734. * S (U) wrapping mode. All valid values correspond to WebGL enums
  735. */
  736. wrapS?: TextureWrapMode;
  737. /**
  738. * T (V) wrapping mode. All valid values correspond to WebGL enums
  739. */
  740. wrapT?: TextureWrapMode;
  741. }
  742. /**
  743. * The root nodes of a scene
  744. */
  745. interface IScene extends IChildRootProperty {
  746. /**
  747. * The indices of each root node
  748. */
  749. nodes: number[];
  750. }
  751. /**
  752. * Joints and matrices defining a skin
  753. */
  754. interface ISkin extends IChildRootProperty {
  755. /**
  756. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  757. */
  758. inverseBindMatrices?: number;
  759. /**
  760. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  761. */
  762. skeleton?: number;
  763. /**
  764. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  765. */
  766. joints: number[];
  767. }
  768. /**
  769. * A texture and its sampler
  770. */
  771. interface ITexture extends IChildRootProperty {
  772. /**
  773. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  774. */
  775. sampler?: number;
  776. /**
  777. * The index of the image used by this texture
  778. */
  779. source: number;
  780. }
  781. /**
  782. * Reference to a texture
  783. */
  784. interface ITextureInfo extends IProperty {
  785. /**
  786. * The index of the texture
  787. */
  788. index: number;
  789. /**
  790. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  791. */
  792. texCoord?: number;
  793. }
  794. /**
  795. * The root object for a glTF asset
  796. */
  797. interface IGLTF extends IProperty {
  798. /**
  799. * An array of accessors. An accessor is a typed view into a bufferView
  800. */
  801. accessors?: IAccessor[];
  802. /**
  803. * An array of keyframe animations
  804. */
  805. animations?: IAnimation[];
  806. /**
  807. * Metadata about the glTF asset
  808. */
  809. asset: IAsset;
  810. /**
  811. * An array of buffers. A buffer points to binary geometry, animation, or skins
  812. */
  813. buffers?: IBuffer[];
  814. /**
  815. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  816. */
  817. bufferViews?: IBufferView[];
  818. /**
  819. * An array of cameras
  820. */
  821. cameras?: ICamera[];
  822. /**
  823. * Names of glTF extensions used somewhere in this asset
  824. */
  825. extensionsUsed?: string[];
  826. /**
  827. * Names of glTF extensions required to properly load this asset
  828. */
  829. extensionsRequired?: string[];
  830. /**
  831. * An array of images. An image defines data used to create a texture
  832. */
  833. images?: IImage[];
  834. /**
  835. * An array of materials. A material defines the appearance of a primitive
  836. */
  837. materials?: IMaterial[];
  838. /**
  839. * An array of meshes. A mesh is a set of primitives to be rendered
  840. */
  841. meshes?: IMesh[];
  842. /**
  843. * An array of nodes
  844. */
  845. nodes?: INode[];
  846. /**
  847. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  848. */
  849. samplers?: ISampler[];
  850. /**
  851. * The index of the default scene
  852. */
  853. scene?: number;
  854. /**
  855. * An array of scenes
  856. */
  857. scenes?: IScene[];
  858. /**
  859. * An array of skins. A skin is defined by joints and matrices
  860. */
  861. skins?: ISkin[];
  862. /**
  863. * An array of textures
  864. */
  865. textures?: ITexture[];
  866. }
  867. /**
  868. * The glTF validation results
  869. * @ignore
  870. */
  871. interface IGLTFValidationResults {
  872. info: {
  873. generator: string;
  874. hasAnimations: boolean;
  875. hasDefaultScene: boolean;
  876. hasMaterials: boolean;
  877. hasMorphTargets: boolean;
  878. hasSkins: boolean;
  879. hasTextures: boolean;
  880. maxAttributesUsed: number;
  881. primitivesCount: number;
  882. };
  883. issues: {
  884. messages: Array<string>;
  885. numErrors: number;
  886. numHints: number;
  887. numInfos: number;
  888. numWarnings: number;
  889. truncated: boolean;
  890. };
  891. mimeType: string;
  892. uri: string;
  893. validatedAt: string;
  894. validatorVersion: string;
  895. }
  896. /**
  897. * The glTF validation options
  898. */
  899. interface IGLTFValidationOptions {
  900. /** Uri to use */
  901. uri?: string;
  902. /** Function used to load external resources */
  903. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  904. /** Boolean indicating that we need to validate accessor data */
  905. validateAccessorData?: boolean;
  906. /** max number of issues allowed */
  907. maxIssues?: number;
  908. /** Ignored issues */
  909. ignoredIssues?: Array<string>;
  910. /** Value to override severy settings */
  911. severityOverrides?: Object;
  912. }
  913. /**
  914. * The glTF validator object
  915. * @internal
  916. */
  917. interface IGLTFValidator {
  918. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  919. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  920. }
  921. /**
  922. * Interfaces from the EXT_lights_image_based extension
  923. */
  924. /** @internal */
  925. interface IEXTLightsImageBased_LightReferenceImageBased {
  926. light: number;
  927. }
  928. /** @internal */
  929. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  930. intensity: number;
  931. rotation: number[];
  932. specularImageSize: number;
  933. specularImages: number[][];
  934. irradianceCoefficients: number[][];
  935. }
  936. /** @internal */
  937. interface IEXTLightsImageBased {
  938. lights: IEXTLightsImageBased_LightImageBased[];
  939. }
  940. /**
  941. * Interfaces from the EXT_mesh_gpu_instancing extension
  942. * !!! Experimental Extension Subject to Changes !!!
  943. */
  944. /** @internal */
  945. interface IEXTMeshGpuInstancing {
  946. mesh?: number;
  947. attributes: { [name: string]: number };
  948. }
  949. /**
  950. * Interfaces from the KHR_draco_mesh_compression extension
  951. */
  952. /** @internal */
  953. interface IKHRDracoMeshCompression {
  954. bufferView: number;
  955. attributes: { [name: string]: number };
  956. }
  957. /**
  958. * Interfaces from the EXT_lights_ies extension
  959. */
  960. /** @internal */
  961. interface IEXTLightsIES_LightReference {
  962. light: number;
  963. color?: number[];
  964. multiplier?: number;
  965. }
  966. /** @internal */
  967. interface IEXTLightsIES_Light extends IChildRootProperty {
  968. uri?: string;
  969. bufferView?: number;
  970. mimeType?: string;
  971. }
  972. /**
  973. * Interfaces from the KHR_lights_punctual extension
  974. */
  975. /** @internal */
  976. const enum KHRLightsPunctual_LightType {
  977. DIRECTIONAL = "directional",
  978. POINT = "point",
  979. SPOT = "spot",
  980. }
  981. /** @internal */
  982. interface IKHRLightsPunctual_LightReference {
  983. light: number;
  984. }
  985. /** @internal */
  986. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  987. type: KHRLightsPunctual_LightType;
  988. color?: number[];
  989. intensity?: number;
  990. range?: number;
  991. spot?: {
  992. innerConeAngle?: number;
  993. outerConeAngle?: number;
  994. };
  995. }
  996. /** @internal */
  997. interface IKHRLightsPunctual {
  998. lights: IKHRLightsPunctual_Light[];
  999. }
  1000. /** @internal */
  1001. interface IKHRMaterialsClearcoat {
  1002. clearcoatFactor?: number;
  1003. clearcoatTexture?: ITextureInfo;
  1004. clearcoatRoughnessFactor?: number;
  1005. clearcoatRoughnessTexture?: ITextureInfo;
  1006. clearcoatNormalTexture?: IMaterialNormalTextureInfo;
  1007. }
  1008. /** @internal */
  1009. interface IKHRMaterialsIridescence {
  1010. iridescenceFactor?: number;
  1011. iridescenceIor?: number;
  1012. iridescenceThicknessMinimum?: number;
  1013. iridescenceThicknessMaximum?: number;
  1014. iridescenceTexture?: ITextureInfo;
  1015. iridescenceThicknessTexture?: ITextureInfo;
  1016. }
  1017. /** @internal */
  1018. interface IKHRMaterialsAnisotropy {
  1019. anisotropyStrength?: number;
  1020. anisotropyRotation?: number;
  1021. anisotropyTexture?: ITextureInfo;
  1022. }
  1023. /**
  1024. * Interfaces from the KHR_materials_ior extension
  1025. */
  1026. /** @internal */
  1027. interface IKHRMaterialsIor {
  1028. ior?: number;
  1029. }
  1030. /**
  1031. * Interfaces from the KHR_materials_volume extension
  1032. */
  1033. /** @internal */
  1034. interface IKHRMaterialsVolume {
  1035. thicknessFactor?: number;
  1036. thicknessTexture?: ITextureInfo;
  1037. attenuationDistance?: number;
  1038. attenuationColor?: number[];
  1039. }
  1040. /**
  1041. * Interfaces from the KHR_materials_dispersion extension
  1042. */
  1043. /** @internal */
  1044. interface IKHRMaterialsDispersion {
  1045. dispersion?: number;
  1046. }
  1047. /**
  1048. * Interfaces from the KHR_materials_specular extension
  1049. */
  1050. /** @internal */
  1051. interface IKHRMaterialsSpecular {
  1052. specularFactor?: number;
  1053. specularColorFactor?: number[];
  1054. specularTexture?: ITextureInfo;
  1055. specularColorTexture?: ITextureInfo;
  1056. }
  1057. /**
  1058. * Interfaces from the KHR_materials_transmission extension
  1059. */
  1060. /** @internal */
  1061. interface IKHRMaterialsTransmission {
  1062. transmissionFactor?: number;
  1063. transmissionTexture?: ITextureInfo;
  1064. }
  1065. /**
  1066. * Interfaces from the KHR_materials_emissive_strength extension
  1067. */
  1068. /** @internal */
  1069. interface IKHRMaterialsEmissiveStrength {
  1070. emissiveStrength: number;
  1071. }
  1072. /**
  1073. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  1074. */
  1075. /** @internal */
  1076. interface IKHRMaterialsPbrSpecularGlossiness {
  1077. diffuseFactor: number[];
  1078. diffuseTexture: ITextureInfo;
  1079. specularFactor: number[];
  1080. glossinessFactor: number;
  1081. specularGlossinessTexture: ITextureInfo;
  1082. }
  1083. /**
  1084. * Interfaces from the KHR_materials_sheen extension
  1085. */
  1086. /** @internal */
  1087. interface IKHRMaterialsSheen {
  1088. sheenColorFactor?: number[];
  1089. sheenColorTexture?: ITextureInfo;
  1090. sheenRoughnessFactor?: number;
  1091. sheenRoughnessTexture?: ITextureInfo;
  1092. }
  1093. /**
  1094. * Interfaces from the KHR_materials_diffuse_transmission extension
  1095. * !!! Experimental Extension Subject to Changes !!!
  1096. */
  1097. /** @internal */
  1098. interface IKHRMaterialsDiffuseTransmission {
  1099. diffuseTransmissionFactor?: number;
  1100. diffuseTransmissionTexture?: ITextureInfo;
  1101. diffuseTransmissionColorFactor?: number[];
  1102. diffuseTransmissionColorTexture?: ITextureInfo;
  1103. }
  1104. /**
  1105. * Interfaces from the KHR_materials_variants extension
  1106. */
  1107. /** @internal */
  1108. interface IKHRMaterialVariants_Mapping extends IProperty {
  1109. mappings: Array<{
  1110. variants: number[];
  1111. material: number;
  1112. }>;
  1113. }
  1114. /** @internal */
  1115. interface IKHRMaterialVariants_Variant extends IProperty {
  1116. name: string;
  1117. }
  1118. /** @internal */
  1119. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  1120. variants: Array<IKHRMaterialVariants_Variant>;
  1121. }
  1122. /**
  1123. * Interfaces from the KHR_texture_basisu extension
  1124. */
  1125. /** @internal */
  1126. interface IKHRTextureBasisU {
  1127. source: number;
  1128. }
  1129. /**
  1130. * Interfaces from the EXT_texture_webp extension
  1131. */
  1132. /** @internal */
  1133. interface IEXTTextureWebP {
  1134. source: number;
  1135. }
  1136. /**
  1137. * Interfaces from the EXT_texture_avif extension
  1138. */
  1139. /** @internal */
  1140. interface IEXTTextureAVIF {
  1141. source: number;
  1142. }
  1143. /**
  1144. * Interfaces from the KHR_texture_transform extension
  1145. */
  1146. /** @internal */
  1147. interface IKHRTextureTransform {
  1148. offset?: number[];
  1149. rotation?: number;
  1150. scale?: number[];
  1151. texCoord?: number;
  1152. }
  1153. /**
  1154. * Interfaces from the KHR_xmp_json_ld extension
  1155. */
  1156. /** @internal */
  1157. interface IKHRXmpJsonLd_Gltf {
  1158. packets: Array<{
  1159. [key: string]: unknown;
  1160. }>;
  1161. }
  1162. /** @internal */
  1163. interface IKHRXmpJsonLd_Node {
  1164. packet: number;
  1165. }
  1166. /**
  1167. * Interfaces from the KHR_animation_pointer extension
  1168. * !!! Experimental Extension Subject to Changes !!!
  1169. */
  1170. /** @hidden */
  1171. interface IKHRAnimationPointer {
  1172. pointer: string;
  1173. }
  1174. /**
  1175. * Interfaces from the MSFT_audio_emitter extension
  1176. */
  1177. /** @internal */
  1178. interface IMSFTAudioEmitter_ClipReference {
  1179. clip: number;
  1180. weight?: number;
  1181. }
  1182. /** @internal */
  1183. interface IMSFTAudioEmitter_EmittersReference {
  1184. emitters: number[];
  1185. }
  1186. /** @internal */
  1187. const enum IMSFTAudioEmitter_DistanceModel {
  1188. linear = "linear",
  1189. inverse = "inverse",
  1190. exponential = "exponential",
  1191. }
  1192. /** @internal */
  1193. interface IMSFTAudioEmitter_Emitter {
  1194. name?: string;
  1195. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  1196. refDistance?: number;
  1197. maxDistance?: number;
  1198. rolloffFactor?: number;
  1199. innerAngle?: number;
  1200. outerAngle?: number;
  1201. loop?: boolean;
  1202. volume?: number;
  1203. clips: IMSFTAudioEmitter_ClipReference[];
  1204. }
  1205. /** @internal */
  1206. const enum IMSFTAudioEmitter_AudioMimeType {
  1207. WAV = "audio/wav",
  1208. }
  1209. /** @internal */
  1210. interface IMSFTAudioEmitter_Clip extends IProperty {
  1211. uri?: string;
  1212. bufferView?: number;
  1213. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  1214. }
  1215. /** @internal */
  1216. const enum IMSFTAudioEmitter_AnimationEventAction {
  1217. play = "play",
  1218. pause = "pause",
  1219. stop = "stop",
  1220. }
  1221. /** @internal */
  1222. interface IMSFTAudioEmitter_AnimationEvent {
  1223. action: IMSFTAudioEmitter_AnimationEventAction;
  1224. emitter: number;
  1225. time: number;
  1226. startOffset?: number;
  1227. }
  1228. /**
  1229. * Interfaces from the MSFT_lod extension
  1230. */
  1231. /** @internal */
  1232. interface IMSFTLOD {
  1233. ids: number[];
  1234. }
  1235. /**
  1236. * Interfaces from the EXT_meshopt_compression extension
  1237. */
  1238. /** @internal */
  1239. interface IEXTMeshoptCompression {
  1240. buffer: number;
  1241. byteOffset?: number;
  1242. byteLength: number;
  1243. byteStride: number;
  1244. count: number;
  1245. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  1246. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  1247. }
  1248. /**
  1249. * Interfaces for the KHR_interactivity extension
  1250. */
  1251. interface IKHRInteractivity {
  1252. /**
  1253. * Holding all of the graphs in the glTF
  1254. */
  1255. graphs: IKHRInteractivity_Graph[];
  1256. /**
  1257. * The graph to run. Defaults to index 0
  1258. */
  1259. graph?: number;
  1260. }
  1261. interface IKHRInteractivity_Graph {
  1262. types?: IKHRInteractivity_Type /* | IKHRInteractivity_CustomType */[]; // should technically behave as a set - no two signatures should match
  1263. variables?: IKHRInteractivity_Variable[];
  1264. events?: IKHRInteractivity_Event[];
  1265. declarations?: IKHRInteractivity_Declaration[];
  1266. nodes?: IKHRInteractivity_Node[];
  1267. }
  1268. /**
  1269. * An index of the types array
  1270. */
  1271. type TypeIndex = number;
  1272. /**
  1273. * An index of the declaration array
  1274. */
  1275. type DeclarationIndex = number;
  1276. /**
  1277. * An index of the nodes array
  1278. */
  1279. type NodeIndex = number;
  1280. /**
  1281. * Value types supported (in js it is either boolean or number)
  1282. */
  1283. type ValueType = (boolean | number)[];
  1284. type ValueSignature = "bool" | "float" | "float2" | "float3" | "float4" | "float2x2" | "float3x3" | "float4x4" | "int" | "custom";
  1285. type ConfigurationValueSignature = "bool" | "int" | "int[]" | "string";
  1286. type ConfigurationValueType = (boolean | number | string)[];
  1287. interface IKHRInteractivity_Event {
  1288. /**
  1289. * The event id is an application-specific event identifier recognized by the execution environment. If the id property is undefined, the event is considered internal to the graph.
  1290. */
  1291. id?: string;
  1292. /**
  1293. * The properties of the values object define ids and the values of those properties define types and optional initial values of the value sockets associated with the event.
  1294. */
  1295. values?:
  1296. | {
  1297. [id: string]: IKHRInteractivity_Variable;
  1298. }
  1299. | undefined;
  1300. }
  1301. interface IKHRInteractivity_Type {
  1302. /**
  1303. * A signature of this type or custom if defined by an external extension
  1304. */
  1305. signature: ValueSignature;
  1306. }
  1307. // interface IKHRInteractivity_CustomType {
  1308. // signature: string;
  1309. // }
  1310. interface IKHRInteractivity_Variable {
  1311. /**
  1312. * Array size depends on the type. primitives have array size 1, rest depending on the object type (2,3,4,16)
  1313. * if value is not provided it should be initialized to the default value of the type according to the specs - NaN for floats, 0 for integers, false for booleans.
  1314. */
  1315. value?: ValueType;
  1316. /**
  1317. * An index in the types array
  1318. */
  1319. type: TypeIndex;
  1320. }
  1321. /**
  1322. * a KHR_Interactivity operation declaration.
  1323. * Declarations are considered equal when their op, extension and input values are equal.
  1324. * If stating an external extension it is possible the declaration is not supported by the engine. In this case the operation will be a no-op
  1325. */
  1326. interface IKHRInteractivity_Declaration {
  1327. /**
  1328. * the operation identifier.
  1329. * Either defined by the interactivity extension or a custom operation by an external extension
  1330. */
  1331. op: string;
  1332. /**
  1333. * If the op is not defined by the interactivity specs, this states the extension that defines the operation
  1334. */
  1335. extension?: string;
  1336. /**
  1337. * If custom operation, this is the output values signatures of the event
  1338. * if undefined the custom operation has no outputs
  1339. */
  1340. outputValueSockets?: { [id: string]: { type: TypeIndex } };
  1341. /**
  1342. * if custom operation, this is the input values signatures of the event
  1343. * If undefined the custom operation has no inputs
  1344. */
  1345. inputValueSockets?: { [id: string]: { type: TypeIndex } };
  1346. }
  1347. interface IKHRInteractivity_Node {
  1348. /**
  1349. * An index in the declarations array
  1350. */
  1351. declaration: DeclarationIndex;
  1352. /**
  1353. * Input value sockets
  1354. */
  1355. values?: { [id: string]: IKHRInteractivity_Variable | IKHRInteractivity_OutputSocketReference };
  1356. /**
  1357. * Output Flow Socket Pointers
  1358. */
  1359. flows?: { [id: string]: IKHRInteractivity_OutputFlow };
  1360. configuration?: { [id: string]: IKHRInteractivity_Configuration };
  1361. }
  1362. interface IKHRInteractivity_OutputSocketReference {
  1363. /**
  1364. * An index in the nodes array
  1365. */
  1366. node: NodeIndex;
  1367. /**
  1368. * Must be defined if the node doesn't have a "value" output socket
  1369. */
  1370. socket?: string;
  1371. /**
  1372. * An optional type that must match the type of the output socket of the target node
  1373. */
  1374. type?: TypeIndex;
  1375. }
  1376. interface IKHRInteractivity_OutputFlow {
  1377. /**
  1378. * An index in the nodes array
  1379. */
  1380. node: NodeIndex;
  1381. /**
  1382. * The socket to connect to in the target node
  1383. * defaults to "in" when undefined.
  1384. */
  1385. socket?: string;
  1386. }
  1387. interface IKHRInteractivity_Configuration {
  1388. /**
  1389. * Array size depends on the type. primitives have array size 1, rest depending on the object type (2,3,4,16)
  1390. */
  1391. value: ConfigurationValueType;
  1392. }
  1393. }