From 015c121691e05461e029de397664f7898b20844d Mon Sep 17 00:00:00 2001
From: Mugen87 A loader for glTF 2.0 resources. See the base [page:Loader] class for common properties. See the base [page:Loader] class for common methods.
@@ -176,27 +178,6 @@
Begin loading from url and call the callback function with the parsed response content.
- [page:String path] — Base path.
-
- Set the base path for the .gltf/.glb file.
-
- [page:String path] — Base path for loading additional resources e.g. textures and .bin data.
-
- Set the base path for additional resources.
-
- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
-
[page:DRACOLoader dracoLoader] — Instance of THREE.DRACOLoader, to be used for decoding assets compressed with the KHR_draco_mesh_compression extension.
diff --git a/docs/examples/en/loaders/LoaderSupport.html b/docs/examples/en/loaders/LoaderSupport.html
deleted file mode 100644
index eaf18174b8..0000000000
--- a/docs/examples/en/loaders/LoaderSupport.html
+++ /dev/null
@@ -1,543 +0,0 @@
-
-
- Supporting classes for file loaders and web worker based loaders.
- Builds one or many [page:Mesh] from one raw set of Arraybuffers, materialGroup descriptions and further parameters.
- Supports vertex, vertexColor, normal, uv and index buffers.
-
- [page:Boolean enabled] True or false.
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
-
- Initializes the Builder (currently only default material initialisation).
-
- Array of [page:Material materials] - Array of [page:Material Materials]
-
- Set materials loaded by any supplier of an Array of [page:Material Materials].
-
- [page:Object payload] - Raw Mesh or Material descriptions.
-
- Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility).
-
- [page:Object meshPayload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
-
- Builds one or multiple meshes from the data described in the payload (buffers, params, material info).
-
- [page:Object materialPayload] - Material update instructions
-
- Updates the materials with contained material objects (sync) or from alteration instructions (async).
-
- Returns the mapping object of material name and corresponding jsonified material.
-
- Returns the mapping object of material name and corresponding material.
-
- [page:Boolean disregardMesh] - Tell implementation to completely disregard this mesh
- Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes.
-
- [page:Mesh mesh] - Mesh
-
- Add a mesh created within callback.
-
- Answers if mesh shall be disregarded completely.
-
- Answers if new mesh(es) were created.
-
- This class provides means to transform existing parser code into a web worker.
- It defines a simple communication protocol which allows to configure the worker and receive raw mesh data during execution.
-
- [page:Boolean enabled] True or false.
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
-
- [page:Boolean forceWorkerDataCopy] True or false.
-
- Forces all ArrayBuffers to be transferred to worker to be copied.
-
- [page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.
- Validate the status of worker code and the derived worker.
-
- [page:Boolean terminateRequested] - True or false.
-
- Request termination of worker once parser is finished.
-
- [page:Function builder] - The builder function. Default is [page:LoaderSupport.Builder].
- Specify functions that should be build when new raw mesh data becomes available and when the parser is finished.
-
- [page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
-
- Runs the parser with the provided configuration.
-
- Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker.
-
- [page:Object parser] - The parser instance
- Applies values from parameter object via set functions or via direct assignment.
-
- [page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
-
- Configures the Parser implementation according the supplied configuration object.
-
- [page:String classDef] - Class definition to be used for construction
-
- Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).
- [page:Boolean enabled] True or false.
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
-
- [page:Boolean forceWorkerDataCopy] True or false.
-
- Forces all ArrayBuffers to be transferred to worker to be copied.
-
- [page:LoaderSupport.Callbacks globalCallbacks] - Register global callbacks used by all web workers
- Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
-
- [page:LoaderSupport.PrepData runParams]
-
- Store run instructions in internal instructionQueue.
-
- Process the instructionQueue until it is depleted.
-
- [page:Function callbackOnFinishedProcessing] - Function called once all workers finished processing.
-
- Terminate all workers.
-
- Returns the maximum length of the instruction queue.
-
- Returns the maximum number of workers.
-
- Returns if any workers are running.
-
- [page:String crossOrigin] - CORS value
-
- Sets the CORS string to be used.
-
- [page:String url] - URL to the file
- A resource description used by [page:LoaderSupport.PrepData] and others.
-
- [page:Object content] - The file content as ArrayBuffer or text
-
- Set the content of this resource
-
- [page:String resourcePath] - URL
-
- Allows to specify resourcePath for dependencies of specified resource.
-
- [page:String modelName] - Overall name of the model
-
- Configuration instructions to be used by run method.
-
- [page:Boolean enabled] True or false.
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
-
- Returns all callbacks as [page:LoaderSupport.Callbacks].
-
- [page:LoaderSupport.ResourceDescriptor resource] Adds a [page:LoaderSupport.ResourceDescriptor]
-
- Add a resource description.
-
- [page:LoaderSupport.ResourceDescriptor resources] - Array of [page:LoaderSupport.ResourceDescriptor]
- Identify files or content of interest from an Array of [page:LoaderSupport.ResourceDescriptor].
- Returns Object with each "ext" and the corresponding [page:LoaderSupport.ResourceDescriptor]
-
- Clones this object and returns it afterwards. Callbacks and resources are not cloned deep (references!).
-
- Callbacks utilized by loaders and builder.
-
- [page:Function callbackOnProgress] - Callback function for described functionality
-
- Register callback function that is invoked by internal function "announceProgress" to print feedback.
-
- [page:Function callbackOnReportError] - Callback function for described functionality
-
- Register callback function that is invoked when an error is reported.
-
- [page:Function callbackOnMeshAlter] - Callback function for described functionality
-
- Register callback function that is called every time a mesh was loaded.
- Use [page:LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).
-
- [page:Function callbackOnLoad] - Callback function for described functionality
-
- Register callback function that is called once loading of the complete OBJ file is completed.
-
- [page:Function callbackOnLoadMaterials] - Callback function for described functionality
-
- Register callback function that is called when materials have been loaded.
-
- Validation functions.
-
- [page:Object input] - Can be anything
-
- If given input is null or undefined, false is returned otherwise true.
-
- [page:Object input] - Can be anything
- If given input is null or undefined, the defaultValue is returned otherwise the given input.
-
- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/LoaderSupport.js examples/js/loaders/LoaderSupport.js]
- A loader for MMD resources. See the base [page:Loader] class for common properties. See the base [page:Loader] class for common methods.
@@ -105,11 +107,6 @@
Begin loading PMD/PMX model file and VMD motion file(s) from urls and fire the callback function with an [page:Object] containing parsed [page:SkinnedMesh] and [page:AnimationClip] fitting to the [page:SkinnedMesh].
- [page:String crossOrigin] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
-
[page:String animationPath] — Base path for loading animation data (VMD/VPD files).
@@ -118,22 +115,6 @@
Set the base path for additional resources like textures.
- [page:String path] — Base path.
-
- Sets the base path or URL from which to load files.
-
- [page:String resourcePath] — Base path for loading additional resources e.g. textures.
-
- Set the base path for additional resources like textures.
-
diff --git a/docs/examples/en/loaders/MTLLoader.html b/docs/examples/en/loaders/MTLLoader.html
index 8028dcec1f..cb33f2009f 100644
--- a/docs/examples/en/loaders/MTLLoader.html
+++ b/docs/examples/en/loaders/MTLLoader.html
@@ -8,6 +8,7 @@
[name]
@@ -161,9 +162,10 @@
Properties
-
+ Methods
+ [method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )
[method:GLTFLoader setPath]( [param:String path] )
- [method:GLTFLoader setResourcePath]( [param:String path] )
- [method:null setCrossOrigin]( [param:String value] )
- [method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )
[name]
-
- Sub-Classes
- [page:LoaderSupport.Builder]
- [page:LoaderSupport.LoadedMeshUserOverride]
- [page:LoaderSupport.WorkerSupport]
- [page:LoaderSupport.WorkerRunnerRefImpl]
- [page:LoaderSupport.WorkerDirector]
- [page:LoaderSupport.ResourceDescriptor]
- [page:LoaderSupport.PrepData]
- [page:LoaderSupport.Callbacks]
- [page:LoaderSupport.Validator]
-
-
- Example
-
- [example:webgl_loader_obj2_meshspray] - Example using [page:LoaderSupport.LoaderWorkerDirector] and [page:LoaderSupport.LoaderWorkerSupport].
-
- Classes
-
-
- Builder
- Constructor
-
- Builder()
- Methods
-
- [method:null setLogging] ( [param:Boolean enabled], [param:Boolean debug] )
-
- [page:Boolean debug] True or false.
- [method:null init] ()
- [method:null setMaterials] ( Array of [param:Material materials] )
- [method:Array processPayload] ( Object payload )
- [method:Array buildMeshes] ( Object meshPayload )
- [method:null updateMaterials] ( Object materialPayload )
- [method:Object getMaterialsJSON] ()
- [method:Object getMaterials] ()
-
-
-
-
- LoadedMeshUserOverride
- Constructor
-
- LoadedMeshUserOverride( [param:Boolean disregardMesh], [param:BufferGeometry bufferGeometry] )
-
- [page:Boolean alteredMesh] - Tell implementation that mesh(es) have been altered or added
- Methods
-
- [method:null addMesh] ( [param:Mesh mesh] )
- [method:boolean isDisregardMesh] ()
- [method:boolean providesAlteredMeshes] ()
-
-
-
-
- WorkerSupport
- Constructor
-
- WorkerSupport()
- Methods
-
- [method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )
-
- [page:Boolean debug] True or false.
- [method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )
- [method:null validate] ( [param:Function functionCodeBuilder], Array of [param:String libLocations], [param:String libPath], [param:LoaderSupport.WorkerRunnerRefImpl runnerImpl] )
-
- Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.
- [page:String libPath] - Base path used for loading libraries.
- [page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
- [method:null setTerminateRequested] ( [param:Boolean terminateRequested] )
- [method:null setCallbacks] ( [param:Function builder], [param:Function onLoad] )
-
- [page:Function onLoad] - The function that is called when parsing is complete.
- [method:null run] ( [param:Object payload] )
-
-
-
-
- WorkerRunnerRefImpl
- Constructor
-
- WorkerRunnerRefImpl()
- Methods
-
- [method:null applyProperties] ( [param:Object parser], [param:Object params] )
-
- [page:Object params] - The parameter object
- [method:null run] ( [param:Object payload] )
-
-
-
-
- WorkerDirector
- Constructor
-
- WorkerDirector( [param:String classDef] )
-
- - Workflow:
- - prepareWorkers
- - enqueueForRun
- - processQueue
- - tearDown
- Methods
-
- [method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )
-
- [page:Boolean debug] True or false.
- [method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )
- [method:null prepareWorkers]( [param:WWOBJLoader2.Callbacks globalCallbacks], [param:Number maxQueueSize], [param:Number maxWebWorkers] )
-
- [page:Number maxQueueSize] - Set the maximum size of the instruction queue (1-1024)
- [page:Number maxWebWorkers] - Set the maximum amount of workers (1-16)
- [method:null enqueueForRun]( [param:LoaderSupport.PrepData runParams] )
- [method:null processQueue]()
- [method:null tearDown]( [param:Function callbackOnFinishedProcessing] )
- [method:null getMaxQueueSize]()
- [method:null getMaxWebWorkers]()
- [method:Boolean isRunning]()
- [method:null setCrossOrigin]( [param:String crossOrigin] )
-
-
-
-
- ResourceDescriptor
- Constructor
-
- ResourceDescriptor( [param:String url], [param:String extension] )
-
- [page:String extension] - The file extension (type)
- Methods
-
- [method:null setContent]( [param:Object content )
- [method:null setResourcePath] ( [param:String resourcePath] )
-
-
-
-
- PrepData
- Constructor
-
- PrepData( [param:String modelName] )
- Methods
-
- [method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )
-
- [page:Boolean debug] True or false.
- [method:Callbacks getCallbacks]()
- [method:null addResource]( [param:LoaderSupport.ResourceDescriptor resource] )
- [method:null checkResourceDescriptorFiles] ( [param:LoaderSupport.ResourceDescriptor resources], [param:Object fileDesc] )
-
- [page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
- [method:PrepData clone] ()
-
-
-
-
- Callbacks
- Constructor
-
- Callbacks()
- Methods
-
- [method:null setCallbackOnProgress]( [param:Function callbackOnProgress] )
- [method:null setCallbackOnReportError]( [param:Function callbackOnReportError] )
- [method:null setCallbackOnMeshAlter]( [param:Function callbackOnMeshAlter] )
- [method:null setCallbackOnLoad]( [param:Function callbackOnLoad] )
- [method:null setCallbackOnLoadMaterials]( [param:Function callbackOnLoadMaterials] )
-
-
-
-
- Validator
- Constructor
-
- Validator()
- Methods
-
- [method:Boolean isValid]( [param:Object input] )
- [method:null verifyInput]( [param:Object input], [param:Object defaultValue] )
-
- [page:Object defaultValue] - Can be anything
-
-
-
- Source
-
- [name]
@@ -66,9 +67,10 @@
Properties
-
+ Methods
+ [method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )
[method:MMDLoader setCrossOrigin]( [param:String crossOrigin] )
- [method:MMDLoader setAnimationPath]( [param:String animationPath] )
[method:MMDLoader setPath]( [param:String path] )
- [method:MMDLoader setResourcePath]( [param:String resourcePath] )
- Source
[name]
@@ -27,10 +28,10 @@
See the base [page:Loader] class for common properties.
See the base [page:Loader] class for common methods.
@@ -43,35 +44,6 @@ Begin loading from url and return the loaded material.
- -
- [page:String path] — required
-
- Set base path for MTL file. -
- - -
- [page:String path] — required
-
- Set base path for additional resources like textures. If set, this path will be used as the base path. -
- - -
- [page:String value] — required
-
- If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin] - attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*. -
- -[page:Object options] — required diff --git a/docs/examples/en/loaders/TGALoader.html b/docs/examples/en/loaders/TGALoader.html index 834d4e22f2..969b383e50 100644 --- a/docs/examples/en/loaders/TGALoader.html +++ b/docs/examples/en/loaders/TGALoader.html @@ -8,6 +8,8 @@
+ [page:Loader] → +A loader for loading a .tga resource.
@@ -62,8 +64,11 @@
Creates a new [name].
See the base [page:Loader] class for common properties.
See the base [page:Loader] class for common methods.
@@ -76,14 +81,6 @@ Begin loading from url and pass the loaded [page:DataTexture texture] to onLoad. The [page:DataTexture texture] is also directly returned for immediate use (but may not be fully loaded).
-- [page:String path] — Base path. -
-- Set the base path for the file. -
-diff --git a/docs/examples/zh/loaders/GLTFLoader.html b/docs/examples/zh/loaders/GLTFLoader.html index 2f0c0def41..0e5fe0583b 100644 --- a/docs/examples/zh/loaders/GLTFLoader.html +++ b/docs/examples/zh/loaders/GLTFLoader.html @@ -9,6 +9,7 @@
[page:Loader] → + A loader for glTF 2.0 resources.
@@ -161,9 +162,10 @@
See the base [page:Loader] class for common properties.
See the base [page:Loader] class for common methods.
@@ -176,27 +178,6 @@ Begin loading from url and call the callback function with the parsed response content.
-- [page:String path] — Base path. -
-- Set the base path for the .gltf/.glb file. -
- -- [page:String path] — Base path for loading additional resources e.g. textures and .bin data. -
-- Set the base path for additional resources. -
- -- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. -
-[page:DRACOLoader dracoLoader] — Instance of THREE.DRACOLoader, to be used for decoding assets compressed with the KHR_draco_mesh_compression extension. diff --git a/docs/examples/zh/loaders/LoaderSupport.html b/docs/examples/zh/loaders/LoaderSupport.html deleted file mode 100644 index eaf18174b8..0000000000 --- a/docs/examples/zh/loaders/LoaderSupport.html +++ /dev/null @@ -1,543 +0,0 @@ - - -
- -Supporting classes for file loaders and web worker based loaders.
- -- Builds one or many [page:Mesh] from one raw set of Arraybuffers, materialGroup descriptions and further parameters. - Supports vertex, vertexColor, normal, uv and index buffers. -
- - -
- [page:Boolean enabled] True or false.
- [page:Boolean debug] True or false.
-
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging. -
- - -- Initializes the Builder (currently only default material initialisation). -
- - -- Array of [page:Material materials] - Array of [page:Material Materials] -
-- Set materials loaded by any supplier of an Array of [page:Material Materials]. -
- - -- [page:Object payload] - Raw Mesh or Material descriptions. -
-- Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility). -
- - -- [page:Object meshPayload] - Raw mesh description (buffers, params, materials) used to build one to many meshes. -
-- Builds one or multiple meshes from the data described in the payload (buffers, params, material info). -
- - -- [page:Object materialPayload] - Material update instructions -
-- Updates the materials with contained material objects (sync) or from alteration instructions (async). -
- - -- Returns the mapping object of material name and corresponding jsonified material. -
- - -- Returns the mapping object of material name and corresponding material. -
-
- [page:Boolean disregardMesh] - Tell implementation to completely disregard this mesh
- [page:Boolean alteredMesh] - Tell implementation that mesh(es) have been altered or added
-
- Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes. -
- - -- [page:Mesh mesh] - Mesh -
-- Add a mesh created within callback. -
- - -- Answers if mesh shall be disregarded completely. -
- - -- Answers if new mesh(es) were created. -
-- This class provides means to transform existing parser code into a web worker. - It defines a simple communication protocol which allows to configure the worker and receive raw mesh data during execution. -
- - -
- [page:Boolean enabled] True or false.
- [page:Boolean debug] True or false.
-
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging. -
- - -- [page:Boolean forceWorkerDataCopy] True or false. -
-- Forces all ArrayBuffers to be transferred to worker to be copied. -
- - -
- [page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.
- Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.
- [page:String libPath] - Base path used for loading libraries.
- [page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
-
- Validate the status of worker code and the derived worker. -
- - -- [page:Boolean terminateRequested] - True or false. -
-- Request termination of worker once parser is finished. -
- - -
- [page:Function builder] - The builder function. Default is [page:LoaderSupport.Builder].
- [page:Function onLoad] - The function that is called when parsing is complete.
-
- Specify functions that should be build when new raw mesh data becomes available and when the parser is finished. -
- - -- [page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes. -
-- Runs the parser with the provided configuration. -
-- Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker. -
- - -
- [page:Object parser] - The parser instance
- [page:Object params] - The parameter object
-
- Applies values from parameter object via set functions or via direct assignment. -
- - -- [page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes. -
-- Configures the Parser implementation according the supplied configuration object. -
-- [page:String classDef] - Class definition to be used for construction -
-
- Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).
- - Workflow:
- - prepareWorkers
- - enqueueForRun
- - processQueue
- - tearDown
-
- [page:Boolean enabled] True or false.
- [page:Boolean debug] True or false.
-
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging. -
- - -- [page:Boolean forceWorkerDataCopy] True or false. -
-- Forces all ArrayBuffers to be transferred to worker to be copied. -
- - -
- [page:LoaderSupport.Callbacks globalCallbacks] - Register global callbacks used by all web workers
- [page:Number maxQueueSize] - Set the maximum size of the instruction queue (1-1024)
- [page:Number maxWebWorkers] - Set the maximum amount of workers (1-16)
-
- Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers. -
- - -- [page:LoaderSupport.PrepData runParams] -
-- Store run instructions in internal instructionQueue. -
- - -- Process the instructionQueue until it is depleted. -
- - -- [page:Function callbackOnFinishedProcessing] - Function called once all workers finished processing. -
-- Terminate all workers. -
- - -- Returns the maximum length of the instruction queue. -
- - -- Returns the maximum number of workers. -
- -- Returns if any workers are running. -
- - -- [page:String crossOrigin] - CORS value -
-- Sets the CORS string to be used. -
-
- [page:String url] - URL to the file
- [page:String extension] - The file extension (type)
-
- A resource description used by [page:LoaderSupport.PrepData] and others. -
- -- [page:Object content] - The file content as ArrayBuffer or text -
-- Set the content of this resource -
- - -- [page:String resourcePath] - URL -
-- Allows to specify resourcePath for dependencies of specified resource. -
-- [page:String modelName] - Overall name of the model -
-- Configuration instructions to be used by run method. -
- - -
- [page:Boolean enabled] True or false.
- [page:Boolean debug] True or false.
-
- Enable or disable logging in general (except warn and error), plus enable or disable debug logging. -
- - -- Returns all callbacks as [page:LoaderSupport.Callbacks]. -
- - -- [page:LoaderSupport.ResourceDescriptor resource] Adds a [page:LoaderSupport.ResourceDescriptor] -
-- Add a resource description. -
- - -
- [page:LoaderSupport.ResourceDescriptor resources] - Array of [page:LoaderSupport.ResourceDescriptor]
- [page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
-
- Identify files or content of interest from an Array of [page:LoaderSupport.ResourceDescriptor]. - Returns Object with each "ext" and the corresponding [page:LoaderSupport.ResourceDescriptor] -
- - -- Clones this object and returns it afterwards. Callbacks and resources are not cloned deep (references!). -
-- Callbacks utilized by loaders and builder. -
- - -- [page:Function callbackOnProgress] - Callback function for described functionality -
-- Register callback function that is invoked by internal function "announceProgress" to print feedback. -
- -- [page:Function callbackOnReportError] - Callback function for described functionality -
-- Register callback function that is invoked when an error is reported. -
- -- [page:Function callbackOnMeshAlter] - Callback function for described functionality -
-- Register callback function that is called every time a mesh was loaded. - Use [page:LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh). -
- - -- [page:Function callbackOnLoad] - Callback function for described functionality -
-- Register callback function that is called once loading of the complete OBJ file is completed. -
- -- [page:Function callbackOnLoadMaterials] - Callback function for described functionality -
-- Register callback function that is called when materials have been loaded. -
-- Validation functions. -
- - -- [page:Object input] - Can be anything -
-- If given input is null or undefined, false is returned otherwise true. -
- - -
- [page:Object input] - Can be anything
- [page:Object defaultValue] - Can be anything
-
- If given input is null or undefined, the defaultValue is returned otherwise the given input. -
-- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/LoaderSupport.js examples/js/loaders/LoaderSupport.js] -
- - - diff --git a/docs/examples/zh/loaders/MMDLoader.html b/docs/examples/zh/loaders/MMDLoader.html index 431aef4a74..b4ad1bd84e 100644 --- a/docs/examples/zh/loaders/MMDLoader.html +++ b/docs/examples/zh/loaders/MMDLoader.html @@ -9,6 +9,7 @@ [page:Loader] → +一个用于加载MMD资源的加载器。
@@ -65,10 +66,11 @@
创建一个新的[name]。
共有属性请参见其基类[page:Loader]。
-共有方法请参见其基类[page:Loader]。
@@ -102,12 +104,7 @@
[page:Function onError] — (可选)如果加载过程中发生错误时被调用的函数,该函数接受一个错误来作为参数。
- 开始从URL中加载PMD/PMX模型文件和VMD动画文件(可能有多个文件),并使用一个[page:Object] —— 包含有已解析的[page:SkinnedMesh]和适应[page:SkinnedMesh]的[page:AnimationClip],来触发回调函数。 -
- -- [page:String crossOrigin] — crossOrigin字符串,用于实现CORS,以便从一个允许CORS的其它域加载url。 + 开始从URL中加载PMD/PMX模型文件和VMD动画文件(可能有多个文件),并使用一个[page:Object] —— 包含有已解析的[page:SkinnedMesh]和适应[page:SkinnedMesh]的[page:AnimationClip],来触发回调函数。
- [page:String path] — 基础路径。 -
-- 设置用于加载文件的基础路径或URL。 -
- -- [page:String resourcePath] — 用于加载额外资源(例如贴图)的基础路径。 -
-- 设置额外资源(例如贴图)的基础路径。 -
-diff --git a/docs/examples/zh/loaders/MTLLoader.html b/docs/examples/zh/loaders/MTLLoader.html index 8028dcec1f..cb33f2009f 100644 --- a/docs/examples/zh/loaders/MTLLoader.html +++ b/docs/examples/zh/loaders/MTLLoader.html @@ -8,6 +8,7 @@
+ [page:Loader] →See the base [page:Loader] class for common properties.
See the base [page:Loader] class for common methods.
@@ -43,35 +44,6 @@ Begin loading from url and return the loaded material.
- -
- [page:String path] — required
-
- Set base path for MTL file. -
- - -
- [page:String path] — required
-
- Set base path for additional resources like textures. If set, this path will be used as the base path. -
- - -
- [page:String value] — required
-
- If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin] - attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*. -
- -[page:Object options] — required diff --git a/docs/examples/zh/loaders/TGALoader.html b/docs/examples/zh/loaders/TGALoader.html index 834d4e22f2..969b383e50 100644 --- a/docs/examples/zh/loaders/TGALoader.html +++ b/docs/examples/zh/loaders/TGALoader.html @@ -8,6 +8,8 @@
+ [page:Loader] → +A loader for loading a .tga resource.
@@ -62,8 +64,11 @@
Creates a new [name].
See the base [page:Loader] class for common properties.
See the base [page:Loader] class for common methods.
@@ -76,14 +81,6 @@ Begin loading from url and pass the loaded [page:DataTexture texture] to onLoad. The [page:DataTexture texture] is also directly returned for immediate use (but may not be fully loaded).
-- [page:String path] — Base path. -
-- Set the base path for the file. -
-diff --git a/docs/list.js b/docs/list.js index fd191b0d7d..06a3cc3565 100644 --- a/docs/list.js +++ b/docs/list.js @@ -372,7 +372,6 @@ var list = { "MTLLoader": "examples/en/loaders/MTLLoader", "OBJLoader": "examples/en/loaders/OBJLoader", "OBJLoader2": "examples/en/loaders/OBJLoader2", - "LoaderSupport": "examples/en/loaders/LoaderSupport", "PCDLoader": "examples/en/loaders/PCDLoader", "PDBLoader": "examples/en/loaders/PDBLoader", "PRWMLoader": "examples/en/loaders/PRWMLoader", @@ -809,7 +808,6 @@ var list = { "MTLLoader": "examples/zh/loaders/MTLLoader", "OBJLoader": "examples/zh/loaders/OBJLoader", "OBJLoader2": "examples/zh/loaders/OBJLoader2", - "LoaderSupport": "examples/zh/loaders/LoaderSupport", "PCDLoader": "examples/zh/loaders/PCDLoader", "PDBLoader": "examples/zh/loaders/PDBLoader", "PRWMLoader": "examples/zh/loaders/PRWMLoader", diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index c071cec524..bd8c0c86fb 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -10,29 +10,28 @@ THREE.GLTFLoader = ( function () { function GLTFLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); + this.dracoLoader = null; this.ddsLoader = null; } - GLTFLoader.prototype = { + GLTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: GLTFLoader, - crossOrigin: 'anonymous', - load: function ( url, onLoad, onProgress, onError ) { var scope = this; var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -97,27 +96,6 @@ THREE.GLTFLoader = ( function () { }, - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - - setPath: function ( value ) { - - this.path = value; - return this; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - setDRACOLoader: function ( dracoLoader ) { this.dracoLoader = dracoLoader; @@ -236,7 +214,7 @@ THREE.GLTFLoader = ( function () { } - }; + } ); /* GLTFREGISTRY */ @@ -726,7 +704,7 @@ THREE.GLTFLoader = ( function () { materialParams.vertexShader = shader.vertexShader; materialParams.fragmentShader = fragmentShader; materialParams.uniforms = uniforms; - materialParams.defines = { 'STANDARD': '' } + materialParams.defines = { 'STANDARD': '' }; materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 ); materialParams.opacity = 1.0; @@ -1187,11 +1165,11 @@ THREE.GLTFLoader = ( function () { // Invalid URL if ( typeof url !== 'string' || url === '' ) return ''; - + // Host Relative URL if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) { - path = path.replace( /(^https?:\/\/[^\/]+).*/i , '$1' ); + path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); } @@ -1899,7 +1877,7 @@ THREE.GLTFLoader = ( function () { } - bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, (byteOffset % byteStride) / elementBytes, normalized ); + bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized ); } else { diff --git a/examples/js/loaders/MMDLoader.js b/examples/js/loaders/MMDLoader.js index f825c732e7..6ade921f86 100644 --- a/examples/js/loaders/MMDLoader.js +++ b/examples/js/loaders/MMDLoader.js @@ -36,7 +36,7 @@ THREE.MMDLoader = ( function () { */ function MMDLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); this.loader = new THREE.FileLoader( this.manager ); @@ -46,23 +46,10 @@ THREE.MMDLoader = ( function () { } - MMDLoader.prototype = { + MMDLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: MMDLoader, - crossOrigin: 'anonymous', - - /** - * @param {string} crossOrigin - * @return {THREE.MMDLoader} - */ - setCrossOrigin: function ( crossOrigin ) { - - this.crossOrigin = crossOrigin; - return this; - - }, - /** * @param {string} animationPath * @return {THREE.MMDLoader} @@ -74,28 +61,6 @@ THREE.MMDLoader = ( function () { }, - /** - * @param {string} path - * @return {THREE.MMDLoader} - */ - setPath: function ( path ) { - - this.path = path; - return this; - - }, - - /** - * @param {string} resourcePath - * @return {THREE.MMDLoader} - */ - setResoucePath: function ( resourcePath ) { - - this.resourcePath = resourcePath; - return this; - - }, - // Load MMD assets as Three.js Object /** @@ -114,11 +79,11 @@ THREE.MMDLoader = ( function () { var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -340,7 +305,7 @@ THREE.MMDLoader = ( function () { } - }; + } ); // Utilities diff --git a/examples/js/loaders/MTLLoader.js b/examples/js/loaders/MTLLoader.js index 4e7d9159a0..4620dfa95d 100644 --- a/examples/js/loaders/MTLLoader.js +++ b/examples/js/loaders/MTLLoader.js @@ -6,16 +6,14 @@ THREE.MTLLoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); }; -THREE.MTLLoader.prototype = { +THREE.MTLLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: THREE.MTLLoader, - crossOrigin: 'anonymous', - /** * Loads and parses a MTL asset from a URL. * @@ -33,7 +31,7 @@ THREE.MTLLoader.prototype = { var scope = this; - var path = ( this.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path; + var path = ( this.path === '' ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path; var loader = new THREE.FileLoader( this.manager ); loader.setPath( this.path ); @@ -45,58 +43,6 @@ THREE.MTLLoader.prototype = { }, - /** - * Set base path for resolving references. - * If set this path will be prepended to each loaded and found reference. - * - * @see setResourcePath - * @param {String} path - * @return {THREE.MTLLoader} - * - * @example - * mtlLoader.setPath( 'assets/obj/' ); - * mtlLoader.load( 'my.mtl', ... ); - */ - setPath: function ( path ) { - - this.path = path; - return this; - - }, - - /** - * Set base path for additional resources like textures. - * - * @see setPath - * @param {String} path - * @return {THREE.MTLLoader} - * - * @example - * mtlLoader.setPath( 'assets/obj/' ); - * mtlLoader.setResourcePath( 'assets/textures/' ); - * mtlLoader.load( 'my.mtl', ... ); - */ - setResourcePath: function ( path ) { - - this.resourcePath = path; - return this; - - }, - - setTexturePath: function ( path ) { - - console.warn( 'THREE.MTLLoader: .setTexturePath() has been renamed to .setResourcePath().' ); - return this.setResourcePath( path ); - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - setMaterialOptions: function ( value ) { this.materialOptions = value; @@ -174,7 +120,7 @@ THREE.MTLLoader.prototype = { } -}; +} ); /** * Create a new THREE-MTLLoader.MaterialCreator diff --git a/examples/js/loaders/NRRDLoader.js b/examples/js/loaders/NRRDLoader.js index 1eaa5b53c1..28edafc8f0 100644 --- a/examples/js/loaders/NRRDLoader.js +++ b/examples/js/loaders/NRRDLoader.js @@ -4,12 +4,11 @@ THREE.NRRDLoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - + THREE.Loader.call( this, manager ); }; -THREE.NRRDLoader.prototype = { +THREE.NRRDLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: THREE.NRRDLoader, @@ -28,13 +27,6 @@ THREE.NRRDLoader.prototype = { }, - setPath: function ( value ) { - - this.path = value; - return this; - - }, - parse: function ( data ) { // this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X @@ -62,7 +54,7 @@ THREE.NRRDLoader.prototype = { switch ( type ) { - // 1 byte data types + // 1 byte data types case 'uchar': break; case 'schar': @@ -600,4 +592,4 @@ THREE.NRRDLoader.prototype = { } } -}; +} ); diff --git a/examples/js/loaders/TGALoader.js b/examples/js/loaders/TGALoader.js index b84c95941f..368d9723ed 100644 --- a/examples/js/loaders/TGALoader.js +++ b/examples/js/loaders/TGALoader.js @@ -6,11 +6,11 @@ THREE.TGALoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); }; -THREE.TGALoader.prototype = { +THREE.TGALoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: THREE.TGALoader, @@ -60,7 +60,7 @@ THREE.TGALoader.prototype = { } break; - // check colormap type + // check colormap type case TGA_TYPE_RGB: case TGA_TYPE_GREY: @@ -73,12 +73,12 @@ THREE.TGALoader.prototype = { } break; - // What the need of a file without data ? + // What the need of a file without data ? case TGA_TYPE_NO_DATA: console.error( 'THREE.TGALoader: No data.' ); - // Invalid type ? + // Invalid type ? default: console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type ); @@ -471,7 +471,7 @@ THREE.TGALoader.prototype = { flags: content[ offset ++ ] }; - // check tga if it is valid format + // check tga if it is valid format tgaCheckHeader( header ); @@ -538,13 +538,6 @@ THREE.TGALoader.prototype = { return useOffscreen ? canvas.transferToImageBitmap() : canvas; - }, - - setPath: function ( value ) { - - this.path = value; - return this; - } -}; +} ); diff --git a/examples/js/loaders/deprecated/LegacyGLTFLoader.js b/examples/js/loaders/deprecated/LegacyGLTFLoader.js index 7d8cb23b16..ee9bbe8793 100644 --- a/examples/js/loaders/deprecated/LegacyGLTFLoader.js +++ b/examples/js/loaders/deprecated/LegacyGLTFLoader.js @@ -9,27 +9,25 @@ THREE.LegacyGLTFLoader = ( function () { function LegacyGLTFLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); } - LegacyGLTFLoader.prototype = { + LegacyGLTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { constructor: LegacyGLTFLoader, - crossOrigin: 'anonymous', - load: function ( url, onLoad, onProgress, onError ) { var scope = this; var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -52,26 +50,6 @@ THREE.LegacyGLTFLoader = ( function () { }, - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - - setPath: function ( value ) { - - this.path = value; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - parse: function ( data, path, callback ) { var content; @@ -121,7 +99,7 @@ THREE.LegacyGLTFLoader = ( function () { } - }; + } ); /* GLTFREGISTRY */ diff --git a/examples/js/loaders/deprecated/LegacyJSONLoader.js b/examples/js/loaders/deprecated/LegacyJSONLoader.js index 5fb0b94d98..713cf4658d 100644 --- a/examples/js/loaders/deprecated/LegacyJSONLoader.js +++ b/examples/js/loaders/deprecated/LegacyJSONLoader.js @@ -14,21 +14,21 @@ THREE.LegacyJSONLoader = ( function () { } - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + THREE.Loader.call( this, manager ); this.withCredentials = false; } - Object.assign( LegacyJSONLoader.prototype, { + LegacyJSONLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), { - crossOrigin: 'anonymous', + constructor: LegacyJSONLoader, load: function ( url, onLoad, onProgress, onError ) { var scope = this; - var path = ( this.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path; + var path = ( this.path === '' ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path; var loader = new THREE.FileLoader( this.manager ); loader.setPath( this.path ); @@ -62,27 +62,6 @@ THREE.LegacyJSONLoader = ( function () { }, - setPath: function ( value ) { - - this.path = value; - return this; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - parse: ( function () { var _BlendingMode = { @@ -144,7 +123,7 @@ THREE.LegacyJSONLoader = ( function () { break; case 'colorAmbient': case 'mapAmbient': - console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); + console.warn( 'THREE.LegacyJSONLoader.createMaterial:', name, 'is no longer supported.' ); break; case 'colorDiffuse': json.color = _color.fromArray( value ).getHex(); @@ -256,7 +235,7 @@ THREE.LegacyJSONLoader = ( function () { json.side = THREE.DoubleSide; break; case 'transparency': - console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); + console.warn( 'THREE.LegacyJSONLoader.createMaterial: transparency has been renamed to opacity' ); json.opacity = value; break; case 'depthTest': @@ -274,7 +253,7 @@ THREE.LegacyJSONLoader = ( function () { if ( value === 'face' ) json.vertexColors = THREE.FaceColors; break; default: - console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); + console.error( 'THREE.LegacyJSONLoader.createMaterial: Unsupported', name, value ); break; } diff --git a/examples/jsm/loaders/GLTFLoader.d.ts b/examples/jsm/loaders/GLTFLoader.d.ts index 0222c47b62..e7c89ae8ec 100644 --- a/examples/jsm/loaders/GLTFLoader.d.ts +++ b/examples/jsm/loaders/GLTFLoader.d.ts @@ -1,6 +1,7 @@ import { AnimationClip, Camera, + Loader, LoadingManager, Scene } from '../../../src/Three'; @@ -16,19 +17,12 @@ export interface GLTF { asset: object; } -export class GLTFLoader { +export class GLTFLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; dracoLoader: DRACOLoader | null; ddsLoader: DDSLoader | null; - path: string; - crossOrigin: string; - resourcePath: string; load(url: string, onLoad: (gltf: GLTF) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : GLTFLoader; - setResourcePath(path: string) : GLTFLoader; - setCrossOrigin(value: string): GLTFLoader; setDRACOLoader(dracoLoader: DRACOLoader): GLTFLoader; setDDSLoader(ddsLoader: DDSLoader): GLTFLoader; parse(data: ArrayBuffer | string, path: string, onLoad: (gltf: GLTF) => void, onError?: (event: ErrorEvent) => void) : void; diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 472c68531b..adf5cddce4 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -13,7 +13,6 @@ import { BufferGeometry, ClampToEdgeWrapping, Color, - DefaultLoadingManager, DirectionalLight, DoubleSide, FileLoader, @@ -75,29 +74,28 @@ var GLTFLoader = ( function () { function GLTFLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); + this.dracoLoader = null; this.ddsLoader = null; } - GLTFLoader.prototype = { + GLTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: GLTFLoader, - crossOrigin: 'anonymous', - load: function ( url, onLoad, onProgress, onError ) { var scope = this; var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -162,27 +160,6 @@ var GLTFLoader = ( function () { }, - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - - setPath: function ( value ) { - - this.path = value; - return this; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - setDRACOLoader: function ( dracoLoader ) { this.dracoLoader = dracoLoader; @@ -301,7 +278,7 @@ var GLTFLoader = ( function () { } - }; + } ); /* GLTFREGISTRY */ @@ -791,7 +768,7 @@ var GLTFLoader = ( function () { materialParams.vertexShader = shader.vertexShader; materialParams.fragmentShader = fragmentShader; materialParams.uniforms = uniforms; - materialParams.defines = { 'STANDARD': '' } + materialParams.defines = { 'STANDARD': '' }; materialParams.color = new Color( 1.0, 1.0, 1.0 ); materialParams.opacity = 1.0; @@ -1252,11 +1229,11 @@ var GLTFLoader = ( function () { // Invalid URL if ( typeof url !== 'string' || url === '' ) return ''; - + // Host Relative URL if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) { - path = path.replace( /(^https?:\/\/[^\/]+).*/i , '$1' ); + path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); } @@ -1964,7 +1941,7 @@ var GLTFLoader = ( function () { } - bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, (byteOffset % byteStride) / elementBytes, normalized ); + bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized ); } else { diff --git a/examples/jsm/loaders/MD2Loader.d.ts b/examples/jsm/loaders/MD2Loader.d.ts index 5aef9caa26..ab3a702112 100644 --- a/examples/jsm/loaders/MD2Loader.d.ts +++ b/examples/jsm/loaders/MD2Loader.d.ts @@ -1,14 +1,12 @@ import { BufferGeometry, + Loader, LoadingManager } from '../../../src/Three'; -export class MD2Loader { +export class MD2Loader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - setPath(path: string): this; parse(data: ArrayBuffer): BufferGeometry; } diff --git a/examples/jsm/loaders/MMDLoader.d.ts b/examples/jsm/loaders/MMDLoader.d.ts index 1aaa53d0fe..70de07275d 100644 --- a/examples/jsm/loaders/MMDLoader.d.ts +++ b/examples/jsm/loaders/MMDLoader.d.ts @@ -1,6 +1,7 @@ import { AnimationClip, FileLoader, + Loader, LoadingManager, SkinnedMesh } from '../../../src/Three'; @@ -10,17 +11,13 @@ export interface MMDLoaderAnimationObject { mesh: SkinnedMesh; } -export class MMDLoader { +export class MMDLoader extends Loader { constructor(manager?: LoadingManager); animationBuilder: object; animationPath: string; - crossOrigin: string; loader: FileLoader; - manager: LoadingManager; meshBuilder: object; - path: string; parser: object | null; - resourcePath: string; load(url: string, onLoad: (mesh: SkinnedMesh) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadAnimation(url: string, onLoad: (object: SkinnedMesh | AnimationClip) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; @@ -30,7 +27,4 @@ export class MMDLoader { loadVPD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; loadWithAnimation(url: string, vmdUrl: string | string[], onLoad: (object: MMDLoaderAnimationObject) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; setAnimationPath(animationPath: string): this; - setCrossOrigin(crossOrigin: string): this; - setPath(path: string): this; - setResoucePath(resourcePath: string): this; } diff --git a/examples/jsm/loaders/MMDLoader.js b/examples/jsm/loaders/MMDLoader.js index 4547a9e25f..629196c769 100644 --- a/examples/jsm/loaders/MMDLoader.js +++ b/examples/jsm/loaders/MMDLoader.js @@ -36,7 +36,6 @@ import { BufferGeometry, Color, CustomBlending, - DefaultLoadingManager, DoubleSide, DstAlphaFactor, Euler, @@ -73,7 +72,7 @@ var MMDLoader = ( function () { */ function MMDLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); this.loader = new FileLoader( this.manager ); @@ -83,23 +82,10 @@ var MMDLoader = ( function () { } - MMDLoader.prototype = { + MMDLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: MMDLoader, - crossOrigin: 'anonymous', - - /** - * @param {string} crossOrigin - * @return {MMDLoader} - */ - setCrossOrigin: function ( crossOrigin ) { - - this.crossOrigin = crossOrigin; - return this; - - }, - /** * @param {string} animationPath * @return {MMDLoader} @@ -111,28 +97,6 @@ var MMDLoader = ( function () { }, - /** - * @param {string} path - * @return {MMDLoader} - */ - setPath: function ( path ) { - - this.path = path; - return this; - - }, - - /** - * @param {string} resourcePath - * @return {MMDLoader} - */ - setResoucePath: function ( resourcePath ) { - - this.resourcePath = resourcePath; - return this; - - }, - // Load MMD assets as Three.js Object /** @@ -151,11 +115,11 @@ var MMDLoader = ( function () { var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -377,7 +341,7 @@ var MMDLoader = ( function () { } - }; + } ); // Utilities diff --git a/examples/jsm/loaders/MTLLoader.d.ts b/examples/jsm/loaders/MTLLoader.d.ts index 43f8b10a5a..c5399dd782 100644 --- a/examples/jsm/loaders/MTLLoader.d.ts +++ b/examples/jsm/loaders/MTLLoader.d.ts @@ -2,7 +2,7 @@ import { Material, LoadingManager, Mapping, - EventDispatcher, + Loader, BufferGeometry, Side, Texture, @@ -39,20 +39,13 @@ export interface MaterialCreatorOptions { invertTrProperty?: boolean; } -export class MTLLoader extends EventDispatcher { +export class MTLLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; materialOptions: MaterialCreatorOptions; - path: string; - texturePath: string; - crossOrigin: boolean; load(url: string, onLoad: (materialCreator: MaterialCreator) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; parse(text: string) : MaterialCreator; - setPath(path: string) : void; - setTexturePath(path: string) : void; setBaseUrl(path: string) : void; - setCrossOrigin(value: boolean) : void; setMaterialOptions(value: MaterialCreatorOptions) : void; } diff --git a/examples/jsm/loaders/MTLLoader.js b/examples/jsm/loaders/MTLLoader.js index c1441d295e..6d79a0e363 100644 --- a/examples/jsm/loaders/MTLLoader.js +++ b/examples/jsm/loaders/MTLLoader.js @@ -19,16 +19,14 @@ import { var MTLLoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); }; -MTLLoader.prototype = { +MTLLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: MTLLoader, - crossOrigin: 'anonymous', - /** * Loads and parses a MTL asset from a URL. * @@ -46,7 +44,7 @@ MTLLoader.prototype = { var scope = this; - var path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path; + var path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path; var loader = new FileLoader( this.manager ); loader.setPath( this.path ); @@ -58,58 +56,6 @@ MTLLoader.prototype = { }, - /** - * Set base path for resolving references. - * If set this path will be prepended to each loaded and found reference. - * - * @see setResourcePath - * @param {String} path - * @return {MTLLoader} - * - * @example - * mtlLoader.setPath( 'assets/obj/' ); - * mtlLoader.load( 'my.mtl', ... ); - */ - setPath: function ( path ) { - - this.path = path; - return this; - - }, - - /** - * Set base path for additional resources like textures. - * - * @see setPath - * @param {String} path - * @return {MTLLoader} - * - * @example - * mtlLoader.setPath( 'assets/obj/' ); - * mtlLoader.setResourcePath( 'assets/textures/' ); - * mtlLoader.load( 'my.mtl', ... ); - */ - setResourcePath: function ( path ) { - - this.resourcePath = path; - return this; - - }, - - setTexturePath: function ( path ) { - - console.warn( 'THREE.MTLLoader: .setTexturePath() has been renamed to .setResourcePath().' ); - return this.setResourcePath( path ); - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - setMaterialOptions: function ( value ) { this.materialOptions = value; @@ -187,7 +133,7 @@ MTLLoader.prototype = { } -}; +} ); /** * Create a new THREE-MTLLoader.MaterialCreator diff --git a/examples/jsm/loaders/NRRDLoader.js b/examples/jsm/loaders/NRRDLoader.js index c440d63717..f0afb4ef37 100644 --- a/examples/jsm/loaders/NRRDLoader.js +++ b/examples/jsm/loaders/NRRDLoader.js @@ -3,8 +3,8 @@ */ import { - DefaultLoadingManager, FileLoader, + Loader, Matrix4, Vector3 } from "../../../build/three.module.js"; @@ -13,12 +13,11 @@ import { Volume } from "../misc/Volume.js"; var NRRDLoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; - + Loader.call( this, manager ); }; -NRRDLoader.prototype = { +NRRDLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: NRRDLoader, @@ -37,13 +36,6 @@ NRRDLoader.prototype = { }, - setPath: function ( value ) { - - this.path = value; - return this; - - }, - parse: function ( data ) { // this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X @@ -71,7 +63,7 @@ NRRDLoader.prototype = { switch ( type ) { - // 1 byte data types + // 1 byte data types case 'uchar': break; case 'schar': @@ -609,6 +601,6 @@ NRRDLoader.prototype = { } } -}; +} ); export { NRRDLoader }; diff --git a/examples/jsm/loaders/OBJLoader.d.ts b/examples/jsm/loaders/OBJLoader.d.ts index f1ce41fa50..e5d715292c 100644 --- a/examples/jsm/loaders/OBJLoader.d.ts +++ b/examples/jsm/loaders/OBJLoader.d.ts @@ -1,5 +1,6 @@ import { Material, + Loader, LoadingManager, Group } from '../../../src/Three'; @@ -7,14 +8,11 @@ import { MaterialCreator } from './MTLLoader'; -export class OBJLoader { +export class OBJLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; materials: MaterialCreator; - path: string; load(url: string, onLoad: (group: Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; parse(data: string) : Group; - setPath(value: string) : this; setMaterials(materials: MaterialCreator) : this; } diff --git a/examples/jsm/loaders/PCDLoader.d.ts b/examples/jsm/loaders/PCDLoader.d.ts index 775748df91..ddd1b15789 100644 --- a/examples/jsm/loaders/PCDLoader.d.ts +++ b/examples/jsm/loaders/PCDLoader.d.ts @@ -1,17 +1,14 @@ import { Points, + Lodaer, LoadingManager } from '../../../src/Three'; -export class PCDLoader { +export class PCDLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; littleEndian: boolean; - path: string; load(url: string, onLoad: (points: Points) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : this; - parse(data: ArrayBuffer | string, url: string) : Points; } diff --git a/examples/jsm/loaders/PDBLoader.d.ts b/examples/jsm/loaders/PDBLoader.d.ts index 1cdc7ac480..86e037670a 100644 --- a/examples/jsm/loaders/PDBLoader.d.ts +++ b/examples/jsm/loaders/PDBLoader.d.ts @@ -1,5 +1,6 @@ import { BufferGeometry, + Loader, LoadingManager } from '../../../src/Three'; @@ -13,13 +14,9 @@ export interface PDB { } -export class PDBLoader { +export class PDBLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (pdb: PDB) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : this; - parse(text: string) : PDB; } diff --git a/examples/jsm/loaders/PRWMLoader.d.ts b/examples/jsm/loaders/PRWMLoader.d.ts index ed8dd552f7..41ad6d492e 100644 --- a/examples/jsm/loaders/PRWMLoader.d.ts +++ b/examples/jsm/loaders/PRWMLoader.d.ts @@ -1,16 +1,14 @@ import { BufferGeometry, + Loader, LoadingManager } from '../../../src/Three'; -export class PRWMLoader { +export class PRWMLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : this; parse(data: ArrayBuffer) : BufferGeometry; static isBigEndianPlatform(): boolean; diff --git a/examples/jsm/loaders/SVGLoader.d.ts b/examples/jsm/loaders/SVGLoader.d.ts index ab2450af11..076317de10 100644 --- a/examples/jsm/loaders/SVGLoader.d.ts +++ b/examples/jsm/loaders/SVGLoader.d.ts @@ -1,4 +1,5 @@ import { + Loader, LoadingManager, ShapePath, BufferGeometry, @@ -18,14 +19,10 @@ export interface StrokeStyle { strokeMiterLimit: number; } -export class SVGLoader { +export class SVGLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (data: SVGResult) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : this; - parse(text: string) : SVGResult; static getStrokeStyle(width: number, color: string, lineJoin: string, lineCap: string, miterLimit: number): StrokeStyle; diff --git a/examples/jsm/loaders/TGALoader.d.ts b/examples/jsm/loaders/TGALoader.d.ts index cf4481a8bc..1fe0f5258c 100644 --- a/examples/jsm/loaders/TGALoader.d.ts +++ b/examples/jsm/loaders/TGALoader.d.ts @@ -1,16 +1,12 @@ import { Texture, + Loader, LoadingManager } from '../../../src/Three'; - -export class TGALoader { +export class TGALoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (texture: Texture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void; - setPath(path: string) : this; - parse(data: ArrayBuffer) : Texture; } diff --git a/examples/jsm/loaders/TGALoader.js b/examples/jsm/loaders/TGALoader.js index b47435a599..ea499afe9d 100644 --- a/examples/jsm/loaders/TGALoader.js +++ b/examples/jsm/loaders/TGALoader.js @@ -5,18 +5,18 @@ */ import { - DefaultLoadingManager, FileLoader, + Loader, Texture } from "../../../build/three.module.js"; var TGALoader = function ( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); }; -TGALoader.prototype = { +TGALoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: TGALoader, @@ -66,7 +66,7 @@ TGALoader.prototype = { } break; - // check colormap type + // check colormap type case TGA_TYPE_RGB: case TGA_TYPE_GREY: @@ -79,12 +79,12 @@ TGALoader.prototype = { } break; - // What the need of a file without data ? + // What the need of a file without data ? case TGA_TYPE_NO_DATA: console.error( 'THREE.TGALoader: No data.' ); - // Invalid type ? + // Invalid type ? default: console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type ); @@ -477,7 +477,7 @@ TGALoader.prototype = { flags: content[ offset ++ ] }; - // check tga if it is valid format + // check tga if it is valid format tgaCheckHeader( header ); @@ -544,15 +544,8 @@ TGALoader.prototype = { return useOffscreen ? canvas.transferToImageBitmap() : canvas; - }, - - setPath: function ( value ) { - - this.path = value; - return this; - } -}; +} ); export { TGALoader }; diff --git a/examples/jsm/loaders/VTKLoader.d.ts b/examples/jsm/loaders/VTKLoader.d.ts index c0d5c4f2fe..c7c411d822 100644 --- a/examples/jsm/loaders/VTKLoader.d.ts +++ b/examples/jsm/loaders/VTKLoader.d.ts @@ -1,15 +1,12 @@ import { BufferGeometry, + Loader, LoadingManager } from '../../../src/Three'; -export class VRMLLoader { +export class VRMLLoader extends Loader { constructor(manager?: LoadingManager); - manager: LoadingManager; - path: string; load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - setPath(path: string): this; - parse(data: ArrayBuffer | string, path: string): BufferGeometry; } diff --git a/examples/jsm/loaders/deprecated/LegacyGLTFLoader.d.ts b/examples/jsm/loaders/deprecated/LegacyGLTFLoader.d.ts index d150ad815b..bd3a611b0f 100644 --- a/examples/jsm/loaders/deprecated/LegacyGLTFLoader.d.ts +++ b/examples/jsm/loaders/deprecated/LegacyGLTFLoader.d.ts @@ -1,6 +1,7 @@ import { AnimationClip, Camera, + Loader, LoadingManager, Scene } from '../../../../src/Three'; @@ -12,16 +13,9 @@ export interface GLTF { cameras: Camera[]; } -export class LegacyGLTFLoader { +export class LegacyGLTFLoader extends Loader { constructor(manager?: LoadingManager); - crossOrigin: string; - manager: LoadingManager; - path: string; - resourcePath: string; load(url: string, onLoad: (gltf: GLTF) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - setPath(path: string): this; - setResourcePath(path: string): this; - setCrossOrigin(value: string): this; parse(data: ArrayBuffer | string, path: string, callback: (gltf: GLTF) => void): void; } diff --git a/examples/jsm/loaders/deprecated/LegacyGLTFLoader.js b/examples/jsm/loaders/deprecated/LegacyGLTFLoader.js index 19ef4053d7..5c59cae59c 100644 --- a/examples/jsm/loaders/deprecated/LegacyGLTFLoader.js +++ b/examples/jsm/loaders/deprecated/LegacyGLTFLoader.js @@ -19,7 +19,6 @@ import { ClampToEdgeWrapping, Color, CustomBlending, - DefaultLoadingManager, DirectionalLight, DoubleSide, DstAlphaFactor, @@ -100,27 +99,25 @@ var LegacyGLTFLoader = ( function () { function LegacyGLTFLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); } - LegacyGLTFLoader.prototype = { + LegacyGLTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), { constructor: LegacyGLTFLoader, - crossOrigin: 'anonymous', - load: function ( url, onLoad, onProgress, onError ) { var scope = this; var resourcePath; - if ( this.resourcePath !== undefined ) { + if ( this.resourcePath !== '' ) { resourcePath = this.resourcePath; - } else if ( this.path !== undefined ) { + } else if ( this.path !== '' ) { resourcePath = this.path; @@ -143,26 +140,6 @@ var LegacyGLTFLoader = ( function () { }, - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - - setPath: function ( value ) { - - this.path = value; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - parse: function ( data, path, callback ) { var content; @@ -212,7 +189,7 @@ var LegacyGLTFLoader = ( function () { } - }; + } ); /* GLTFREGISTRY */ diff --git a/examples/jsm/loaders/deprecated/LegacyJSONLoader.d.ts b/examples/jsm/loaders/deprecated/LegacyJSONLoader.d.ts index 9dc8ada786..33d442ef95 100644 --- a/examples/jsm/loaders/deprecated/LegacyJSONLoader.d.ts +++ b/examples/jsm/loaders/deprecated/LegacyJSONLoader.d.ts @@ -1,5 +1,6 @@ import { Geometry, + Loader, LoadingManager, Material } from '../../../../src/Three'; @@ -9,17 +10,10 @@ export interface LegacyJSONLoaderResult { materials: Material[]; } -export class LegacyJSONLoader { +export class LegacyJSONLoader extends Loader { constructor(manager?: LoadingManager); - crossOrigin: string; - manager: LoadingManager; - path: string; - resourcePath: string; withCredentials: boolean; load(url: string, onLoad: (object: LegacyJSONLoaderResult) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; - setCrossOrigin(value: string): this; - setPath(value: string): this; - setResourcePath(value: string): this; parse(json: object, path: string): LegacyJSONLoaderResult; } diff --git a/examples/jsm/loaders/deprecated/LegacyJSONLoader.js b/examples/jsm/loaders/deprecated/LegacyJSONLoader.js index 8f7537db51..def0ab0ff4 100644 --- a/examples/jsm/loaders/deprecated/LegacyJSONLoader.js +++ b/examples/jsm/loaders/deprecated/LegacyJSONLoader.js @@ -9,7 +9,6 @@ import { BackSide, Color, CustomBlending, - DefaultLoadingManager, DoubleSide, Face3, FaceColors, @@ -43,21 +42,21 @@ var LegacyJSONLoader = ( function () { } - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); this.withCredentials = false; } - Object.assign( LegacyJSONLoader.prototype, { + LegacyJSONLoader.prototype = Object.assign( Object.create( Loader.prototype ), { - crossOrigin: 'anonymous', + constructor: LegacyJSONLoader, load: function ( url, onLoad, onProgress, onError ) { var scope = this; - var path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path; + var path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path; var loader = new FileLoader( this.manager ); loader.setPath( this.path ); @@ -91,27 +90,6 @@ var LegacyJSONLoader = ( function () { }, - setPath: function ( value ) { - - this.path = value; - return this; - - }, - - setResourcePath: function ( value ) { - - this.resourcePath = value; - return this; - - }, - - setCrossOrigin: function ( value ) { - - this.crossOrigin = value; - return this; - - }, - parse: ( function () { var _BlendingMode = { @@ -173,7 +151,7 @@ var LegacyJSONLoader = ( function () { break; case 'colorAmbient': case 'mapAmbient': - console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); + console.warn( 'THREE.LegacyJSONLoader.createMaterial:', name, 'is no longer supported.' ); break; case 'colorDiffuse': json.color = _color.fromArray( value ).getHex(); @@ -285,7 +263,7 @@ var LegacyJSONLoader = ( function () { json.side = DoubleSide; break; case 'transparency': - console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); + console.warn( 'THREE.LegacyJSONLoader.createMaterial: transparency has been renamed to opacity' ); json.opacity = value; break; case 'depthTest': @@ -303,7 +281,7 @@ var LegacyJSONLoader = ( function () { if ( value === 'face' ) json.vertexColors = FaceColors; break; default: - console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); + console.error( 'THREE.LegacyJSONLoader.createMaterial: Unsupported', name, value ); break; } -- GitLab