|
@@ -67,8 +67,62 @@ import {
|
|
|
} from 'three';
|
|
} from 'three';
|
|
|
import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * A loader for the glTF 2.0 format.
|
|
|
|
|
+ *
|
|
|
|
|
+ * [glTF]{@link https://www.khronos.org/gltf/} (GL Transmission Format) is an [open format specification]{@link https://github.com/KhronosGroup/glTF/tree/main/specification/2.0}
|
|
|
|
|
+ * for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb)
|
|
|
|
|
+ * format. External filesstore textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver
|
|
|
|
|
+ * one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights,
|
|
|
|
|
+ * and/or cameras.
|
|
|
|
|
+ *
|
|
|
|
|
+ * `GLTFLoader` uses {@link ImageBitmapLoader} whenever possible. Be advised that image bitmaps are not
|
|
|
|
|
+ * automatically GC-collected when they are no longer referenced, and they require special handling during
|
|
|
|
|
+ * the disposal process.
|
|
|
|
|
+ *
|
|
|
|
|
+ * `GLTFLoader` supports the following glTF 2.0 extensions:
|
|
|
|
|
+ * - KHR_draco_mesh_compression
|
|
|
|
|
+ * - KHR_materials_clearcoat
|
|
|
|
|
+ * - KHR_materials_dispersion
|
|
|
|
|
+ * - KHR_materials_ior
|
|
|
|
|
+ * - KHR_materials_specular
|
|
|
|
|
+ * - KHR_materials_transmission
|
|
|
|
|
+ * - KHR_materials_iridescence
|
|
|
|
|
+ * - KHR_materials_unlit
|
|
|
|
|
+ * - KHR_materials_volume
|
|
|
|
|
+ * - KHR_mesh_quantization
|
|
|
|
|
+ * - KHR_lights_punctual
|
|
|
|
|
+ * - KHR_texture_basisu
|
|
|
|
|
+ * - KHR_texture_transform
|
|
|
|
|
+ * - EXT_texture_webp
|
|
|
|
|
+ * - EXT_meshopt_compression
|
|
|
|
|
+ * - EXT_mesh_gpu_instancing
|
|
|
|
|
+ *
|
|
|
|
|
+ * The following glTF 2.0 extension is supported by an external user plugin:
|
|
|
|
|
+ * - [KHR_materials_variants]{@link https://github.com/takahirox/three-gltf-extensions}
|
|
|
|
|
+ * - [MSFT_texture_dds]{@link https://github.com/takahirox/three-gltf-extensions}
|
|
|
|
|
+ *
|
|
|
|
|
+ * ```js
|
|
|
|
|
+ * const loader = new GLTFLoader();
|
|
|
|
|
+ *
|
|
|
|
|
+ * // Optional: Provide a DRACOLoader instance to decode compressed mesh data
|
|
|
|
|
+ * const dracoLoader = new DRACOLoader();
|
|
|
|
|
+ * dracoLoader.setDecoderPath( '/examples/jsm/libs/draco/' );
|
|
|
|
|
+ * loader.setDRACOLoader( dracoLoader );
|
|
|
|
|
+ *
|
|
|
|
|
+ * const gltf = await loader.loadAsync( 'models/gltf/duck/duck.gltf' );
|
|
|
|
|
+ * scene.add( gltf.scene );
|
|
|
|
|
+ * ```
|
|
|
|
|
+ *
|
|
|
|
|
+ * @augments Loader
|
|
|
|
|
+ */
|
|
|
class GLTFLoader extends Loader {
|
|
class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Constructs a new glTF loader.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {LoadingManager} [manager] - The loading manager.
|
|
|
|
|
+ */
|
|
|
constructor( manager ) {
|
|
constructor( manager ) {
|
|
|
|
|
|
|
|
super( manager );
|
|
super( manager );
|
|
@@ -183,6 +237,15 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Starts loading from the given URL and passes the loaded glTF asset
|
|
|
|
|
+ * to the `onLoad()` callback.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
|
|
|
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
|
|
|
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
|
|
|
+ * @param {onErrorCallback} onError - Executed when errors occur.
|
|
|
|
|
+ */
|
|
|
load( url, onLoad, onProgress, onError ) {
|
|
load( url, onLoad, onProgress, onError ) {
|
|
|
|
|
|
|
|
const scope = this;
|
|
const scope = this;
|
|
@@ -260,6 +323,13 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the given Draco loader to this loader. Required for decoding assets
|
|
|
|
|
+ * compressed with the `KHR_draco_mesh_compression` extension.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
|
|
|
+ * @return {GLTFLoader} A reference to this loader.
|
|
|
|
|
+ */
|
|
|
setDRACOLoader( dracoLoader ) {
|
|
setDRACOLoader( dracoLoader ) {
|
|
|
|
|
|
|
|
this.dracoLoader = dracoLoader;
|
|
this.dracoLoader = dracoLoader;
|
|
@@ -267,6 +337,13 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
|
|
|
+ * compressed textures.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
|
|
|
+ * @return {GLTFLoader} A reference to this loader.
|
|
|
|
|
+ */
|
|
|
setKTX2Loader( ktx2Loader ) {
|
|
setKTX2Loader( ktx2Loader ) {
|
|
|
|
|
|
|
|
this.ktx2Loader = ktx2Loader;
|
|
this.ktx2Loader = ktx2Loader;
|
|
@@ -274,6 +351,13 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the given meshop decoder. Required for decoding assets
|
|
|
|
|
+ * compressed with the `EXT_meshopt_compression` extension.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
|
|
|
+ * @return {GLTFLoader} A reference to this loader.
|
|
|
|
|
+ */
|
|
|
setMeshoptDecoder( meshoptDecoder ) {
|
|
setMeshoptDecoder( meshoptDecoder ) {
|
|
|
|
|
|
|
|
this.meshoptDecoder = meshoptDecoder;
|
|
this.meshoptDecoder = meshoptDecoder;
|
|
@@ -281,6 +365,14 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Registers a plugin callback. This API is internally used to implement the various
|
|
|
|
|
+ * glTF extensions but can also used by third-party code to add additional logic
|
|
|
|
|
+ * to the loader.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
|
|
|
+ * @return {GLTFLoader} A reference to this loader.
|
|
|
|
|
+ */
|
|
|
register( callback ) {
|
|
register( callback ) {
|
|
|
|
|
|
|
|
if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
|
|
if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
|
|
@@ -293,6 +385,12 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Unregisters a plugin callback.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {Function} callback - The callback function to unregister.
|
|
|
|
|
+ * @return {GLTFLoader} A reference to this loader.
|
|
|
|
|
+ */
|
|
|
unregister( callback ) {
|
|
unregister( callback ) {
|
|
|
|
|
|
|
|
if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
|
|
if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
|
|
@@ -305,6 +403,14 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Parses the given FBX data and returns the resulting group.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {string|ArrayBuffer} data - The raw glTF data.
|
|
|
|
|
+ * @param {string} path - The URL base path.
|
|
|
|
|
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
|
|
|
+ * @param {onErrorCallback} onError - Executed when errors occur.
|
|
|
|
|
+ */
|
|
|
parse( data, path, onLoad, onError ) {
|
|
parse( data, path, onLoad, onError ) {
|
|
|
|
|
|
|
|
let json;
|
|
let json;
|
|
@@ -428,6 +534,14 @@ class GLTFLoader extends Loader {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Async version of {@link GLTFLoader#parse}.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @async
|
|
|
|
|
+ * @param {string|ArrayBuffer} data - The raw glTF data.
|
|
|
|
|
+ * @param {string} path - The URL base path.
|
|
|
|
|
+ * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
|
|
|
+ */
|
|
|
parseAsync( data, path ) {
|
|
parseAsync( data, path ) {
|
|
|
|
|
|
|
|
const scope = this;
|
|
const scope = this;
|
|
@@ -511,6 +625,8 @@ const EXTENSIONS = {
|
|
|
* Punctual Lights Extension
|
|
* Punctual Lights Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFLightsExtension {
|
|
class GLTFLightsExtension {
|
|
|
|
|
|
|
@@ -647,6 +763,8 @@ class GLTFLightsExtension {
|
|
|
* Unlit Materials Extension
|
|
* Unlit Materials Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsUnlitExtension {
|
|
class GLTFMaterialsUnlitExtension {
|
|
|
|
|
|
|
@@ -700,6 +818,8 @@ class GLTFMaterialsUnlitExtension {
|
|
|
* Materials Emissive Strength Extension
|
|
* Materials Emissive Strength Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsEmissiveStrengthExtension {
|
|
class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
|
|
|
|
@@ -739,6 +859,8 @@ class GLTFMaterialsEmissiveStrengthExtension {
|
|
|
* Clearcoat Materials Extension
|
|
* Clearcoat Materials Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsClearcoatExtension {
|
|
class GLTFMaterialsClearcoatExtension {
|
|
|
|
|
|
|
@@ -823,6 +945,8 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
* Materials dispersion Extension
|
|
* Materials dispersion Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsDispersionExtension {
|
|
class GLTFMaterialsDispersionExtension {
|
|
|
|
|
|
|
@@ -869,6 +993,8 @@ class GLTFMaterialsDispersionExtension {
|
|
|
* Iridescence Materials Extension
|
|
* Iridescence Materials Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsIridescenceExtension {
|
|
class GLTFMaterialsIridescenceExtension {
|
|
|
|
|
|
|
@@ -957,6 +1083,8 @@ class GLTFMaterialsIridescenceExtension {
|
|
|
* Sheen Materials Extension
|
|
* Sheen Materials Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsSheenExtension {
|
|
class GLTFMaterialsSheenExtension {
|
|
|
|
|
|
|
@@ -1033,6 +1161,8 @@ class GLTFMaterialsSheenExtension {
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
|
* Draft: https://github.com/KhronosGroup/glTF/pull/1698
|
|
* Draft: https://github.com/KhronosGroup/glTF/pull/1698
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsTransmissionExtension {
|
|
class GLTFMaterialsTransmissionExtension {
|
|
|
|
|
|
|
@@ -1091,6 +1221,8 @@ class GLTFMaterialsTransmissionExtension {
|
|
|
* Materials Volume Extension
|
|
* Materials Volume Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsVolumeExtension {
|
|
class GLTFMaterialsVolumeExtension {
|
|
|
|
|
|
|
@@ -1150,6 +1282,8 @@ class GLTFMaterialsVolumeExtension {
|
|
|
* Materials ior Extension
|
|
* Materials ior Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsIorExtension {
|
|
class GLTFMaterialsIorExtension {
|
|
|
|
|
|
|
@@ -1196,6 +1330,8 @@ class GLTFMaterialsIorExtension {
|
|
|
* Materials specular Extension
|
|
* Materials specular Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsSpecularExtension {
|
|
class GLTFMaterialsSpecularExtension {
|
|
|
|
|
|
|
@@ -1260,6 +1396,8 @@ class GLTFMaterialsSpecularExtension {
|
|
|
* Materials bump Extension
|
|
* Materials bump Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsBumpExtension {
|
|
class GLTFMaterialsBumpExtension {
|
|
|
|
|
|
|
@@ -1314,6 +1452,8 @@ class GLTFMaterialsBumpExtension {
|
|
|
* Materials anisotropy Extension
|
|
* Materials anisotropy Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMaterialsAnisotropyExtension {
|
|
class GLTFMaterialsAnisotropyExtension {
|
|
|
|
|
|
|
@@ -1378,6 +1518,8 @@ class GLTFMaterialsAnisotropyExtension {
|
|
|
* BasisU Texture Extension
|
|
* BasisU Texture Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFTextureBasisUExtension {
|
|
class GLTFTextureBasisUExtension {
|
|
|
|
|
|
|
@@ -1429,6 +1571,8 @@ class GLTFTextureBasisUExtension {
|
|
|
* WebP Texture Extension
|
|
* WebP Texture Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFTextureWebPExtension {
|
|
class GLTFTextureWebPExtension {
|
|
|
|
|
|
|
@@ -1514,6 +1658,8 @@ class GLTFTextureWebPExtension {
|
|
|
* AVIF Texture Extension
|
|
* AVIF Texture Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFTextureAVIFExtension {
|
|
class GLTFTextureAVIFExtension {
|
|
|
|
|
|
|
@@ -1597,6 +1743,8 @@ class GLTFTextureAVIFExtension {
|
|
|
* meshopt BufferView Compression Extension
|
|
* meshopt BufferView Compression Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMeshoptCompression {
|
|
class GLTFMeshoptCompression {
|
|
|
|
|
|
|
@@ -1682,6 +1830,7 @@ class GLTFMeshoptCompression {
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMeshGpuInstancing {
|
|
class GLTFMeshGpuInstancing {
|
|
|
|
|
|
|
@@ -1910,6 +2059,8 @@ class GLTFBinaryExtension {
|
|
|
* DRACO Mesh Compression Extension
|
|
* DRACO Mesh Compression Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFDracoMeshCompressionExtension {
|
|
class GLTFDracoMeshCompressionExtension {
|
|
|
|
|
|
|
@@ -1993,6 +2144,8 @@ class GLTFDracoMeshCompressionExtension {
|
|
|
* Texture Transform Extension
|
|
* Texture Transform Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFTextureTransformExtension {
|
|
class GLTFTextureTransformExtension {
|
|
|
|
|
|
|
@@ -2052,6 +2205,8 @@ class GLTFTextureTransformExtension {
|
|
|
* Mesh Quantization Extension
|
|
* Mesh Quantization Extension
|
|
|
*
|
|
*
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
class GLTFMeshQuantizationExtension {
|
|
class GLTFMeshQuantizationExtension {
|
|
|
|
|
|
|
@@ -2254,6 +2409,7 @@ const ALPHA_MODES = {
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {Object<string, Material>} cache
|
|
* @param {Object<string, Material>} cache
|
|
|
* @return {Material}
|
|
* @return {Material}
|
|
|
*/
|
|
*/
|
|
@@ -2295,6 +2451,8 @@ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {Object3D|Material|BufferGeometry|Object} object
|
|
* @param {Object3D|Material|BufferGeometry|Object} object
|
|
|
* @param {GLTF.definition} gltfDef
|
|
* @param {GLTF.definition} gltfDef
|
|
|
*/
|
|
*/
|
|
@@ -2319,6 +2477,7 @@ function assignExtrasToUserData( object, gltfDef ) {
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {BufferGeometry} geometry
|
|
* @param {BufferGeometry} geometry
|
|
|
* @param {Array<GLTF.Target>} targets
|
|
* @param {Array<GLTF.Target>} targets
|
|
|
* @param {GLTFParser} parser
|
|
* @param {GLTFParser} parser
|
|
@@ -2406,6 +2565,8 @@ function addMorphTargets( geometry, targets, parser ) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {Mesh} mesh
|
|
* @param {Mesh} mesh
|
|
|
* @param {GLTF.Mesh} meshDef
|
|
* @param {GLTF.Mesh} meshDef
|
|
|
*/
|
|
*/
|
|
@@ -2694,6 +2855,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Marks the special nodes/meshes in json for efficient parse.
|
|
* Marks the special nodes/meshes in json for efficient parse.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
*/
|
|
*/
|
|
|
_markDefs() {
|
|
_markDefs() {
|
|
|
|
|
|
|
@@ -2755,6 +2918,7 @@ class GLTFParser {
|
|
|
*
|
|
*
|
|
|
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {Object} cache
|
|
* @param {Object} cache
|
|
|
* @param {Object3D} index
|
|
* @param {Object3D} index
|
|
|
*/
|
|
*/
|
|
@@ -2775,6 +2939,7 @@ class GLTFParser {
|
|
|
/**
|
|
/**
|
|
|
* Returns a reference to a shared resource, cloning it if necessary.
|
|
* Returns a reference to a shared resource, cloning it if necessary.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {Object} cache
|
|
* @param {Object} cache
|
|
|
* @param {number} index
|
|
* @param {number} index
|
|
|
* @param {Object} object
|
|
* @param {Object} object
|
|
@@ -2851,6 +3016,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Requests the specified dependency asynchronously, with caching.
|
|
* Requests the specified dependency asynchronously, with caching.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {string} type
|
|
* @param {string} type
|
|
|
* @param {number} index
|
|
* @param {number} index
|
|
|
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
@@ -2959,6 +3126,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {string} type
|
|
* @param {string} type
|
|
|
* @return {Promise<Array<Object>>}
|
|
* @return {Promise<Array<Object>>}
|
|
|
*/
|
|
*/
|
|
@@ -2987,6 +3156,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} bufferIndex
|
|
* @param {number} bufferIndex
|
|
|
* @return {Promise<ArrayBuffer>}
|
|
* @return {Promise<ArrayBuffer>}
|
|
|
*/
|
|
*/
|
|
@@ -3024,6 +3195,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} bufferViewIndex
|
|
* @param {number} bufferViewIndex
|
|
|
* @return {Promise<ArrayBuffer>}
|
|
* @return {Promise<ArrayBuffer>}
|
|
|
*/
|
|
*/
|
|
@@ -3043,6 +3216,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} accessorIndex
|
|
* @param {number} accessorIndex
|
|
|
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
|
*/
|
|
*/
|
|
@@ -3182,6 +3357,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} textureIndex
|
|
* @param {number} textureIndex
|
|
|
* @return {Promise<THREE.Texture|null>}
|
|
* @return {Promise<THREE.Texture|null>}
|
|
|
*/
|
|
*/
|
|
@@ -3352,6 +3529,7 @@ class GLTFParser {
|
|
|
/**
|
|
/**
|
|
|
* Asynchronously assigns a texture to the given material parameters.
|
|
* Asynchronously assigns a texture to the given material parameters.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {Object} materialParams
|
|
* @param {Object} materialParams
|
|
|
* @param {string} mapName
|
|
* @param {string} mapName
|
|
|
* @param {Object} mapDef
|
|
* @param {Object} mapDef
|
|
@@ -3407,6 +3585,8 @@ class GLTFParser {
|
|
|
* but reuse of the same glTF material may require multiple threejs materials
|
|
* but reuse of the same glTF material may require multiple threejs materials
|
|
|
* to accommodate different primitive types, defines, etc. New materials will
|
|
* to accommodate different primitive types, defines, etc. New materials will
|
|
|
* be created if necessary, and reused from a cache.
|
|
* be created if necessary, and reused from a cache.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
|
*/
|
|
*/
|
|
|
assignFinalMaterial( mesh ) {
|
|
assignFinalMaterial( mesh ) {
|
|
@@ -3507,6 +3687,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} materialIndex
|
|
* @param {number} materialIndex
|
|
|
* @return {Promise<Material>}
|
|
* @return {Promise<Material>}
|
|
|
*/
|
|
*/
|
|
@@ -3667,6 +3849,7 @@ class GLTFParser {
|
|
|
/**
|
|
/**
|
|
|
* When Object3D instances are targeted by animation, they need unique names.
|
|
* When Object3D instances are targeted by animation, they need unique names.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {string} originalName
|
|
* @param {string} originalName
|
|
|
* @return {string}
|
|
* @return {string}
|
|
|
*/
|
|
*/
|
|
@@ -3693,6 +3876,7 @@ class GLTFParser {
|
|
|
*
|
|
*
|
|
|
* Creates BufferGeometries from primitives.
|
|
* Creates BufferGeometries from primitives.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @private
|
|
|
* @param {Array<GLTF.Primitive>} primitives
|
|
* @param {Array<GLTF.Primitive>} primitives
|
|
|
* @return {Promise<Array<BufferGeometry>>}
|
|
* @return {Promise<Array<BufferGeometry>>}
|
|
|
*/
|
|
*/
|
|
@@ -3760,6 +3944,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} meshIndex
|
|
* @param {number} meshIndex
|
|
|
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
|
*/
|
|
*/
|
|
@@ -3908,6 +4094,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} cameraIndex
|
|
* @param {number} cameraIndex
|
|
|
* @return {Promise<THREE.Camera>}
|
|
* @return {Promise<THREE.Camera>}
|
|
|
*/
|
|
*/
|
|
@@ -3944,6 +4132,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} skinIndex
|
|
* @param {number} skinIndex
|
|
|
* @return {Promise<Skeleton>}
|
|
* @return {Promise<Skeleton>}
|
|
|
*/
|
|
*/
|
|
@@ -4014,6 +4204,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} animationIndex
|
|
* @param {number} animationIndex
|
|
|
* @return {Promise<AnimationClip>}
|
|
* @return {Promise<AnimationClip>}
|
|
|
*/
|
|
*/
|
|
@@ -4141,6 +4333,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} nodeIndex
|
|
* @param {number} nodeIndex
|
|
|
* @return {Promise<Object3D>}
|
|
* @return {Promise<Object3D>}
|
|
|
*/
|
|
*/
|
|
@@ -4348,6 +4542,8 @@ class GLTFParser {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {number} sceneIndex
|
|
* @param {number} sceneIndex
|
|
|
* @return {Promise<Group>}
|
|
* @return {Promise<Group>}
|
|
|
*/
|
|
*/
|
|
@@ -4562,6 +4758,8 @@ class GLTFParser {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {BufferGeometry} geometry
|
|
* @param {BufferGeometry} geometry
|
|
|
* @param {GLTF.Primitive} primitiveDef
|
|
* @param {GLTF.Primitive} primitiveDef
|
|
|
* @param {GLTFParser} parser
|
|
* @param {GLTFParser} parser
|
|
@@ -4677,6 +4875,8 @@ function computeBounds( geometry, primitiveDef, parser ) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @private
|
|
|
* @param {BufferGeometry} geometry
|
|
* @param {BufferGeometry} geometry
|
|
|
* @param {GLTF.Primitive} primitiveDef
|
|
* @param {GLTF.Primitive} primitiveDef
|
|
|
* @param {GLTFParser} parser
|
|
* @param {GLTFParser} parser
|
|
@@ -4742,4 +4942,17 @@ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Loader result of `GLTFLoader`.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @typedef {Object} GLTFLoader~LoadObject
|
|
|
|
|
+ * @property {Array<AnimationClip>} animations - An array of animation clips.
|
|
|
|
|
+ * @property {Object} asset - Meta data about the loaded asset.
|
|
|
|
|
+ * @property {Array<Camera>} cameras - An array of cameras.
|
|
|
|
|
+ * @property {GLTFParser} parser - A reference to the internal parser.
|
|
|
|
|
+ * @property {Group} scene - The default scene.
|
|
|
|
|
+ * @property {Array<Group>} scenes - glTF assets might define multiple scenes.
|
|
|
|
|
+ * @property {Object} userData - Additional data.
|
|
|
|
|
+ **/
|
|
|
|
|
+
|
|
|
export { GLTFLoader };
|
|
export { GLTFLoader };
|