提交 015c1216 编写于 作者: M Mugen87

Examples: Inherit from Loader III.

上级 857e491c
......@@ -9,6 +9,7 @@
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc"> A loader for <em>glTF 2.0</em> resources. <br /><br />
......@@ -161,9 +162,10 @@
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -176,27 +178,6 @@
Begin loading from url and call the callback function with the parsed response content.
</p>
<h3>[method:GLTFLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the .gltf/.glb file.
</p>
<h3>[method:GLTFLoader setResourcePath]( [param:String path] )</h3>
<p>
[page:String path] — Base path for loading additional resources e.g. textures and .bin data.
</p>
<p>
Set the base path for additional resources.
</p>
<h3>[method:null setCrossOrigin]( [param:String value] )</h3>
<p>
[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
</p>
<h3>[method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )</h3>
<p>
[page:DRACOLoader dracoLoader] — Instance of THREE.DRACOLoader, to be used for decoding assets compressed with the KHR_draco_mesh_compression extension.
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p class="desc">Supporting classes for file loaders and web worker based loaders.</p>
<h2>Sub-Classes</h2>
[page:LoaderSupport.Builder]<br>
[page:LoaderSupport.LoadedMeshUserOverride]<br>
[page:LoaderSupport.WorkerSupport]<br>
[page:LoaderSupport.WorkerRunnerRefImpl]<br>
[page:LoaderSupport.WorkerDirector]<br>
[page:LoaderSupport.ResourceDescriptor]<br>
[page:LoaderSupport.PrepData]<br>
[page:LoaderSupport.Callbacks]<br>
[page:LoaderSupport.Validator]<br>
<h2>Example</h2>
[example:webgl_loader_obj2_meshspray] - Example using [page:LoaderSupport.LoaderWorkerDirector] and [page:LoaderSupport.LoaderWorkerSupport].<br>
<h2>Classes</h2>
<br>
<a name="Builder"></a><h1>Builder</h1>
<h2>Constructor</h2>
<h3>Builder()</h3>
<p>
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.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging] ( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null init] ()</h3>
<p>
Initializes the Builder (currently only default material initialisation).
</p>
<h3>[method:null setMaterials] ( Array of [param:Material materials] )</h3>
<p>
Array of [page:Material materials] - Array of [page:Material Materials]
</p>
<p>
Set materials loaded by any supplier of an Array of [page:Material Materials].
</p>
<h3>[method:Array processPayload] ( Object payload )</h3>
<p>
[page:Object payload] - Raw Mesh or Material descriptions.
</p>
<p>
Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility).
</p>
<h3>[method:Array buildMeshes] ( Object meshPayload )</h3>
<p>
[page:Object meshPayload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Builds one or multiple meshes from the data described in the payload (buffers, params, material info).
</p>
<h3>[method:null updateMaterials] ( Object materialPayload )</h3>
<p>
[page:Object materialPayload] - Material update instructions
</p>
<p>
Updates the materials with contained material objects (sync) or from alteration instructions (async).
</p>
<h3>[method:Object getMaterialsJSON] ()</h3>
<p>
Returns the mapping object of material name and corresponding jsonified material.
</p>
<h3>[method:Object getMaterials] ()</h3>
<p>
Returns the mapping object of material name and corresponding material.
</p>
<br>
<br>
<a name="LoadedMeshUserOverride"></a><h1>LoadedMeshUserOverride</h1>
<h2>Constructor</h2>
<h3>LoadedMeshUserOverride( [param:Boolean disregardMesh], [param:BufferGeometry bufferGeometry] )</h3>
<p>
[page:Boolean disregardMesh] - Tell implementation to completely disregard this mesh<br>
[page:Boolean alteredMesh] - Tell implementation that mesh(es) have been altered or added
</p>
<p>
Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes.
</p>
<h2>Methods</h2>
<h3>[method:null addMesh] ( [param:Mesh mesh] )</h3>
<p>
[page:Mesh mesh] - Mesh
</p>
<p>
Add a mesh created within callback.
</p>
<h3>[method:boolean isDisregardMesh] ()</h3>
<p>
Answers if mesh shall be disregarded completely.
</p>
<h3>[method:boolean providesAlteredMeshes] ()</h3>
<p>
Answers if new mesh(es) were created.
</p>
<br>
<br>
<a name="WorkerSupport"></a><h1>WorkerSupport</h1>
<h2>Constructor</h2>
<h3>WorkerSupport()</h3>
<p>
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.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )</h3>
<p>
[page:Boolean forceWorkerDataCopy] True or false.
</p>
<p>
Forces all ArrayBuffers to be transferred to worker to be copied.
</p>
<h3>[method:null validate] ( [param:Function functionCodeBuilder], Array of [param:String libLocations], [param:String libPath], [param:LoaderSupport.WorkerRunnerRefImpl runnerImpl] )</h3>
<p>
[page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.<br>
Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.<br>
[page:String libPath] - Base path used for loading libraries.<br>
[page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
</p>
<p>
Validate the status of worker code and the derived worker.
</p>
<h3>[method:null setTerminateRequested] ( [param:Boolean terminateRequested] )</h3>
<p>
[page:Boolean terminateRequested] - True or false.
</p>
<p>
Request termination of worker once parser is finished.
</p>
<h3>[method:null setCallbacks] ( [param:Function builder], [param:Function onLoad] )</h3>
<p>
[page:Function builder] - The builder function. Default is [page:LoaderSupport.Builder].<br>
[page:Function onLoad] - The function that is called when parsing is complete.
</p>
<p>
Specify functions that should be build when new raw mesh data becomes available and when the parser is finished.
</p>
<h3>[method:null run] ( [param:Object payload] )</h3>
<p>
[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Runs the parser with the provided configuration.
</p>
<br>
<br>
<a name="WorkerRunnerRefImpl"></a><h1>WorkerRunnerRefImpl</h1>
<h2>Constructor</h2>
<h3>WorkerRunnerRefImpl()</h3>
<p>
Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker.
</p>
<h2>Methods</h2>
<h3>[method:null applyProperties] ( [param:Object parser], [param:Object params] )</h3>
<p>
[page:Object parser] - The parser instance<br>
[page:Object params] - The parameter object
</p>
<p>
Applies values from parameter object via set functions or via direct assignment.
</p>
<h3>[method:null run] ( [param:Object payload] )</h3>
<p>
[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Configures the Parser implementation according the supplied configuration object.
</p>
<br>
<br>
<a name="WorkerDirector"></a><h1>WorkerDirector</h1>
<h2>Constructor</h2>
<h3>WorkerDirector( [param:String classDef] )</h3>
<p>
[page:String classDef] - Class definition to be used for construction
</p>
<p>
Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).<br>
- Workflow:<br>
- prepareWorkers<br>
- enqueueForRun<br>
- processQueue<br>
- tearDown
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )</h3>
<p>
[page:Boolean forceWorkerDataCopy] True or false.
</p>
<p>
Forces all ArrayBuffers to be transferred to worker to be copied.
</p>
<h3>[method:null prepareWorkers]( [param:WWOBJLoader2.Callbacks globalCallbacks], [param:Number maxQueueSize], [param:Number maxWebWorkers] )</h3>
<p>
[page:LoaderSupport.Callbacks globalCallbacks] - Register global callbacks used by all web workers<br>
[page:Number maxQueueSize] - Set the maximum size of the instruction queue (1-1024)<br>
[page:Number maxWebWorkers] - Set the maximum amount of workers (1-16)
</p>
<p>
Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
</p>
<h3>[method:null enqueueForRun]( [param:LoaderSupport.PrepData runParams] )</h3>
<p>
[page:LoaderSupport.PrepData runParams]
</p>
<p>
Store run instructions in internal instructionQueue.
</p>
<h3>[method:null processQueue]()</h3>
<p>
Process the instructionQueue until it is depleted.
</p>
<h3>[method:null tearDown]( [param:Function callbackOnFinishedProcessing] )</h3>
<p>
[page:Function callbackOnFinishedProcessing] - Function called once all workers finished processing.
</p>
<p>
Terminate all workers.
</p>
<h3>[method:null getMaxQueueSize]()</h3>
<p>
Returns the maximum length of the instruction queue.
</p>
<h3>[method:null getMaxWebWorkers]()</h3>
<p>
Returns the maximum number of workers.
</p>
<h3>[method:Boolean isRunning]()</h3>
<p>
Returns if any workers are running.
</p>
<h3>[method:null setCrossOrigin]( [param:String crossOrigin] )</h3>
<p>
[page:String crossOrigin] - CORS value
</p>
<p>
Sets the CORS string to be used.
</p>
<br>
<br>
<a name="ResourceDescriptor"></a><h1>ResourceDescriptor</h1>
<h2>Constructor</h2>
<h3>ResourceDescriptor( [param:String url], [param:String extension] )</h3>
<p>
[page:String url] - URL to the file<br>
[page:String extension] - The file extension (type)
</p>
<p>
A resource description used by [page:LoaderSupport.PrepData] and others.
</p>
<h2>Methods</h2>
<h3>[method:null setContent]( [param:Object content )</h3>
<p>
[page:Object content] - The file content as ArrayBuffer or text
</p>
<p>
Set the content of this resource
</p>
<h3>[method:null setResourcePath] ( [param:String resourcePath] )</h3>
<p>
[page:String resourcePath] - URL
</p>
<p>
Allows to specify resourcePath for dependencies of specified resource.
</p>
<br>
<br>
<a name="PrepData"></a><h1>PrepData</h1>
<h2>Constructor</h2>
<h3>PrepData( [param:String modelName] )</h3>
<p>
[page:String modelName] - Overall name of the model
</p>
<p>
Configuration instructions to be used by run method.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:Callbacks getCallbacks]()</h3>
<p>
Returns all callbacks as [page:LoaderSupport.Callbacks].
</p>
<h3>[method:null addResource]( [param:LoaderSupport.ResourceDescriptor resource] )</h3>
<p>
[page:LoaderSupport.ResourceDescriptor resource] Adds a [page:LoaderSupport.ResourceDescriptor]
</p>
<p>
Add a resource description.
</p>
<h3>[method:null checkResourceDescriptorFiles] ( [param:LoaderSupport.ResourceDescriptor resources], [param:Object fileDesc] )</h3>
<p>
[page:LoaderSupport.ResourceDescriptor resources] - Array of [page:LoaderSupport.ResourceDescriptor]<br>
[page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
</p>
<p>
Identify files or content of interest from an Array of [page:LoaderSupport.ResourceDescriptor].
Returns Object with each "ext" and the corresponding [page:LoaderSupport.ResourceDescriptor]
</p>
<h3>[method:PrepData clone] ()</h3>
<p>
Clones this object and returns it afterwards. Callbacks and resources are not cloned deep (references!).
</p>
<br>
<br>
<a name="Callbacks"></a><h1>Callbacks</h1>
<h2>Constructor</h2>
<h3>Callbacks()</h3>
<p>
Callbacks utilized by loaders and builder.
</p>
<h2>Methods</h2>
<h3>[method:null setCallbackOnProgress]( [param:Function callbackOnProgress] )</h3>
<p>
[page:Function callbackOnProgress] - Callback function for described functionality
</p>
<p>
Register callback function that is invoked by internal function "announceProgress" to print feedback.
</p>
<h3>[method:null setCallbackOnReportError]( [param:Function callbackOnReportError] )</h3>
<p>
[page:Function callbackOnReportError] - Callback function for described functionality
</p>
<p>
Register callback function that is invoked when an error is reported.
</p>
<h3>[method:null setCallbackOnMeshAlter]( [param:Function callbackOnMeshAlter] )</h3>
<p>
[page:Function callbackOnMeshAlter] - Callback function for described functionality
</p>
<p>
Register callback function that is called every time a mesh was loaded.
Use [page:LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).
</p>
<h3>[method:null setCallbackOnLoad]( [param:Function callbackOnLoad] )</h3>
<p>
[page:Function callbackOnLoad] - Callback function for described functionality
</p>
<p>
Register callback function that is called once loading of the complete OBJ file is completed.
</p>
<h3>[method:null setCallbackOnLoadMaterials]( [param:Function callbackOnLoadMaterials] )</h3>
<p>
[page:Function callbackOnLoadMaterials] - Callback function for described functionality
</p>
<p>
Register callback function that is called when materials have been loaded.
</p>
<br>
<br>
<a name="Validator"></a><h1>Validator</h1>
<h2>Constructor</h2>
<h3>Validator()</h3>
<p>
Validation functions.
</p>
<h2>Methods</h2>
<h3>[method:Boolean isValid]( [param:Object input] )</h3>
<p>
[page:Object input] - Can be anything
</p>
<p>
If given input is null or undefined, false is returned otherwise true.
</p>
<h3>[method:null verifyInput]( [param:Object input], [param:Object defaultValue] )</h3>
<p>
[page:Object input] - Can be anything<br>
[page:Object defaultValue] - Can be anything
</p>
<p>
If given input is null or undefined, the defaultValue is returned otherwise the given input.
</p>
<br>
<br>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/LoaderSupport.js examples/js/loaders/LoaderSupport.js]
</p>
</body>
</html>
......@@ -9,6 +9,7 @@
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc"> A loader for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br />
......@@ -66,9 +67,10 @@
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -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].
</p>
<h3>[method:MMDLoader setCrossOrigin]( [param:String crossOrigin] )</h3>
<p>
[page:String crossOrigin] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
</p>
<h3>[method:MMDLoader setAnimationPath]( [param:String animationPath] )</h3>
<p>
[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.
</p>
<h3>[method:MMDLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Sets the base path or URL from which to load files.
</p>
<h3>[method:MMDLoader setResourcePath]( [param:String resourcePath] )</h3>
<p>
[page:String resourcePath] — Base path for loading additional resources e.g. textures.
</p>
<p>
Set the base path for additional resources like textures.
</p>
<h2>Source</h2>
<p>
......
......@@ -8,6 +8,7 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
......@@ -27,10 +28,10 @@
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -43,35 +44,6 @@
Begin loading from url and return the loaded material.
</p>
<h3>[method:MTLLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — required<br />
</p>
<p>
Set base path for MTL file.
</p>
<h3>[method:MTLLoader setResourcePath]( [param:String path] )</h3>
<p>
[page:String path] — required<br />
</p>
<p>
Set base path for additional resources like textures. If set, this path will be used as the base path.
</p>
<h3>[method:MTLLoader setCrossOrigin]( [param:String value] )</h3>
<p>
[page:String value] — required<br />
</p>
<p>
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"*.
</p>
<h3>[method:MTLLoader setMaterialOptions]( [param:Object options] )</h3>
<p>
[page:Object options] — required
......
......@@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc">A loader for loading a <em>.tga</em> resource. <br />
......@@ -62,8 +64,11 @@
Creates a new [name].
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -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).
</p>
<h3>[method:TGALoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the file.
</p>
<h2>Source</h2>
<p>
......
......@@ -9,6 +9,7 @@
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc"> A loader for <em>glTF 2.0</em> resources. <br /><br />
......@@ -161,9 +162,10 @@
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -176,27 +178,6 @@
Begin loading from url and call the callback function with the parsed response content.
</p>
<h3>[method:GLTFLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the .gltf/.glb file.
</p>
<h3>[method:GLTFLoader setResourcePath]( [param:String path] )</h3>
<p>
[page:String path] — Base path for loading additional resources e.g. textures and .bin data.
</p>
<p>
Set the base path for additional resources.
</p>
<h3>[method:null setCrossOrigin]( [param:String value] )</h3>
<p>
[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
</p>
<h3>[method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )</h3>
<p>
[page:DRACOLoader dracoLoader] — Instance of THREE.DRACOLoader, to be used for decoding assets compressed with the KHR_draco_mesh_compression extension.
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p class="desc">Supporting classes for file loaders and web worker based loaders.</p>
<h2>Sub-Classes</h2>
[page:LoaderSupport.Builder]<br>
[page:LoaderSupport.LoadedMeshUserOverride]<br>
[page:LoaderSupport.WorkerSupport]<br>
[page:LoaderSupport.WorkerRunnerRefImpl]<br>
[page:LoaderSupport.WorkerDirector]<br>
[page:LoaderSupport.ResourceDescriptor]<br>
[page:LoaderSupport.PrepData]<br>
[page:LoaderSupport.Callbacks]<br>
[page:LoaderSupport.Validator]<br>
<h2>Example</h2>
[example:webgl_loader_obj2_meshspray] - Example using [page:LoaderSupport.LoaderWorkerDirector] and [page:LoaderSupport.LoaderWorkerSupport].<br>
<h2>Classes</h2>
<br>
<a name="Builder"></a><h1>Builder</h1>
<h2>Constructor</h2>
<h3>Builder()</h3>
<p>
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.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging] ( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null init] ()</h3>
<p>
Initializes the Builder (currently only default material initialisation).
</p>
<h3>[method:null setMaterials] ( Array of [param:Material materials] )</h3>
<p>
Array of [page:Material materials] - Array of [page:Material Materials]
</p>
<p>
Set materials loaded by any supplier of an Array of [page:Material Materials].
</p>
<h3>[method:Array processPayload] ( Object payload )</h3>
<p>
[page:Object payload] - Raw Mesh or Material descriptions.
</p>
<p>
Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility).
</p>
<h3>[method:Array buildMeshes] ( Object meshPayload )</h3>
<p>
[page:Object meshPayload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Builds one or multiple meshes from the data described in the payload (buffers, params, material info).
</p>
<h3>[method:null updateMaterials] ( Object materialPayload )</h3>
<p>
[page:Object materialPayload] - Material update instructions
</p>
<p>
Updates the materials with contained material objects (sync) or from alteration instructions (async).
</p>
<h3>[method:Object getMaterialsJSON] ()</h3>
<p>
Returns the mapping object of material name and corresponding jsonified material.
</p>
<h3>[method:Object getMaterials] ()</h3>
<p>
Returns the mapping object of material name and corresponding material.
</p>
<br>
<br>
<a name="LoadedMeshUserOverride"></a><h1>LoadedMeshUserOverride</h1>
<h2>Constructor</h2>
<h3>LoadedMeshUserOverride( [param:Boolean disregardMesh], [param:BufferGeometry bufferGeometry] )</h3>
<p>
[page:Boolean disregardMesh] - Tell implementation to completely disregard this mesh<br>
[page:Boolean alteredMesh] - Tell implementation that mesh(es) have been altered or added
</p>
<p>
Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes.
</p>
<h2>Methods</h2>
<h3>[method:null addMesh] ( [param:Mesh mesh] )</h3>
<p>
[page:Mesh mesh] - Mesh
</p>
<p>
Add a mesh created within callback.
</p>
<h3>[method:boolean isDisregardMesh] ()</h3>
<p>
Answers if mesh shall be disregarded completely.
</p>
<h3>[method:boolean providesAlteredMeshes] ()</h3>
<p>
Answers if new mesh(es) were created.
</p>
<br>
<br>
<a name="WorkerSupport"></a><h1>WorkerSupport</h1>
<h2>Constructor</h2>
<h3>WorkerSupport()</h3>
<p>
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.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )</h3>
<p>
[page:Boolean forceWorkerDataCopy] True or false.
</p>
<p>
Forces all ArrayBuffers to be transferred to worker to be copied.
</p>
<h3>[method:null validate] ( [param:Function functionCodeBuilder], Array of [param:String libLocations], [param:String libPath], [param:LoaderSupport.WorkerRunnerRefImpl runnerImpl] )</h3>
<p>
[page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.<br>
Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.<br>
[page:String libPath] - Base path used for loading libraries.<br>
[page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
</p>
<p>
Validate the status of worker code and the derived worker.
</p>
<h3>[method:null setTerminateRequested] ( [param:Boolean terminateRequested] )</h3>
<p>
[page:Boolean terminateRequested] - True or false.
</p>
<p>
Request termination of worker once parser is finished.
</p>
<h3>[method:null setCallbacks] ( [param:Function builder], [param:Function onLoad] )</h3>
<p>
[page:Function builder] - The builder function. Default is [page:LoaderSupport.Builder].<br>
[page:Function onLoad] - The function that is called when parsing is complete.
</p>
<p>
Specify functions that should be build when new raw mesh data becomes available and when the parser is finished.
</p>
<h3>[method:null run] ( [param:Object payload] )</h3>
<p>
[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Runs the parser with the provided configuration.
</p>
<br>
<br>
<a name="WorkerRunnerRefImpl"></a><h1>WorkerRunnerRefImpl</h1>
<h2>Constructor</h2>
<h3>WorkerRunnerRefImpl()</h3>
<p>
Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker.
</p>
<h2>Methods</h2>
<h3>[method:null applyProperties] ( [param:Object parser], [param:Object params] )</h3>
<p>
[page:Object parser] - The parser instance<br>
[page:Object params] - The parameter object
</p>
<p>
Applies values from parameter object via set functions or via direct assignment.
</p>
<h3>[method:null run] ( [param:Object payload] )</h3>
<p>
[page:Object payload] - Raw mesh description (buffers, params, materials) used to build one to many meshes.
</p>
<p>
Configures the Parser implementation according the supplied configuration object.
</p>
<br>
<br>
<a name="WorkerDirector"></a><h1>WorkerDirector</h1>
<h2>Constructor</h2>
<h3>WorkerDirector( [param:String classDef] )</h3>
<p>
[page:String classDef] - Class definition to be used for construction
</p>
<p>
Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).<br>
- Workflow:<br>
- prepareWorkers<br>
- enqueueForRun<br>
- processQueue<br>
- tearDown
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:null setForceWorkerDataCopy]( [param:Boolean forceWorkerDataCopy] )</h3>
<p>
[page:Boolean forceWorkerDataCopy] True or false.
</p>
<p>
Forces all ArrayBuffers to be transferred to worker to be copied.
</p>
<h3>[method:null prepareWorkers]( [param:WWOBJLoader2.Callbacks globalCallbacks], [param:Number maxQueueSize], [param:Number maxWebWorkers] )</h3>
<p>
[page:LoaderSupport.Callbacks globalCallbacks] - Register global callbacks used by all web workers<br>
[page:Number maxQueueSize] - Set the maximum size of the instruction queue (1-1024)<br>
[page:Number maxWebWorkers] - Set the maximum amount of workers (1-16)
</p>
<p>
Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
</p>
<h3>[method:null enqueueForRun]( [param:LoaderSupport.PrepData runParams] )</h3>
<p>
[page:LoaderSupport.PrepData runParams]
</p>
<p>
Store run instructions in internal instructionQueue.
</p>
<h3>[method:null processQueue]()</h3>
<p>
Process the instructionQueue until it is depleted.
</p>
<h3>[method:null tearDown]( [param:Function callbackOnFinishedProcessing] )</h3>
<p>
[page:Function callbackOnFinishedProcessing] - Function called once all workers finished processing.
</p>
<p>
Terminate all workers.
</p>
<h3>[method:null getMaxQueueSize]()</h3>
<p>
Returns the maximum length of the instruction queue.
</p>
<h3>[method:null getMaxWebWorkers]()</h3>
<p>
Returns the maximum number of workers.
</p>
<h3>[method:Boolean isRunning]()</h3>
<p>
Returns if any workers are running.
</p>
<h3>[method:null setCrossOrigin]( [param:String crossOrigin] )</h3>
<p>
[page:String crossOrigin] - CORS value
</p>
<p>
Sets the CORS string to be used.
</p>
<br>
<br>
<a name="ResourceDescriptor"></a><h1>ResourceDescriptor</h1>
<h2>Constructor</h2>
<h3>ResourceDescriptor( [param:String url], [param:String extension] )</h3>
<p>
[page:String url] - URL to the file<br>
[page:String extension] - The file extension (type)
</p>
<p>
A resource description used by [page:LoaderSupport.PrepData] and others.
</p>
<h2>Methods</h2>
<h3>[method:null setContent]( [param:Object content )</h3>
<p>
[page:Object content] - The file content as ArrayBuffer or text
</p>
<p>
Set the content of this resource
</p>
<h3>[method:null setResourcePath] ( [param:String resourcePath] )</h3>
<p>
[page:String resourcePath] - URL
</p>
<p>
Allows to specify resourcePath for dependencies of specified resource.
</p>
<br>
<br>
<a name="PrepData"></a><h1>PrepData</h1>
<h2>Constructor</h2>
<h3>PrepData( [param:String modelName] )</h3>
<p>
[page:String modelName] - Overall name of the model
</p>
<p>
Configuration instructions to be used by run method.
</p>
<h2>Methods</h2>
<h3>[method:null setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
<p>
[page:Boolean enabled] True or false.<br>
[page:Boolean debug] True or false.
</p>
<p>
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
</p>
<h3>[method:Callbacks getCallbacks]()</h3>
<p>
Returns all callbacks as [page:LoaderSupport.Callbacks].
</p>
<h3>[method:null addResource]( [param:LoaderSupport.ResourceDescriptor resource] )</h3>
<p>
[page:LoaderSupport.ResourceDescriptor resource] Adds a [page:LoaderSupport.ResourceDescriptor]
</p>
<p>
Add a resource description.
</p>
<h3>[method:null checkResourceDescriptorFiles] ( [param:LoaderSupport.ResourceDescriptor resources], [param:Object fileDesc] )</h3>
<p>
[page:LoaderSupport.ResourceDescriptor resources] - Array of [page:LoaderSupport.ResourceDescriptor]<br>
[page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
</p>
<p>
Identify files or content of interest from an Array of [page:LoaderSupport.ResourceDescriptor].
Returns Object with each "ext" and the corresponding [page:LoaderSupport.ResourceDescriptor]
</p>
<h3>[method:PrepData clone] ()</h3>
<p>
Clones this object and returns it afterwards. Callbacks and resources are not cloned deep (references!).
</p>
<br>
<br>
<a name="Callbacks"></a><h1>Callbacks</h1>
<h2>Constructor</h2>
<h3>Callbacks()</h3>
<p>
Callbacks utilized by loaders and builder.
</p>
<h2>Methods</h2>
<h3>[method:null setCallbackOnProgress]( [param:Function callbackOnProgress] )</h3>
<p>
[page:Function callbackOnProgress] - Callback function for described functionality
</p>
<p>
Register callback function that is invoked by internal function "announceProgress" to print feedback.
</p>
<h3>[method:null setCallbackOnReportError]( [param:Function callbackOnReportError] )</h3>
<p>
[page:Function callbackOnReportError] - Callback function for described functionality
</p>
<p>
Register callback function that is invoked when an error is reported.
</p>
<h3>[method:null setCallbackOnMeshAlter]( [param:Function callbackOnMeshAlter] )</h3>
<p>
[page:Function callbackOnMeshAlter] - Callback function for described functionality
</p>
<p>
Register callback function that is called every time a mesh was loaded.
Use [page:LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).
</p>
<h3>[method:null setCallbackOnLoad]( [param:Function callbackOnLoad] )</h3>
<p>
[page:Function callbackOnLoad] - Callback function for described functionality
</p>
<p>
Register callback function that is called once loading of the complete OBJ file is completed.
</p>
<h3>[method:null setCallbackOnLoadMaterials]( [param:Function callbackOnLoadMaterials] )</h3>
<p>
[page:Function callbackOnLoadMaterials] - Callback function for described functionality
</p>
<p>
Register callback function that is called when materials have been loaded.
</p>
<br>
<br>
<a name="Validator"></a><h1>Validator</h1>
<h2>Constructor</h2>
<h3>Validator()</h3>
<p>
Validation functions.
</p>
<h2>Methods</h2>
<h3>[method:Boolean isValid]( [param:Object input] )</h3>
<p>
[page:Object input] - Can be anything
</p>
<p>
If given input is null or undefined, false is returned otherwise true.
</p>
<h3>[method:null verifyInput]( [param:Object input], [param:Object defaultValue] )</h3>
<p>
[page:Object input] - Can be anything<br>
[page:Object defaultValue] - Can be anything
</p>
<p>
If given input is null or undefined, the defaultValue is returned otherwise the given input.
</p>
<br>
<br>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/LoaderSupport.js examples/js/loaders/LoaderSupport.js]
</p>
</body>
</html>
......@@ -9,6 +9,7 @@
</head>
<body>
[page:Loader] &rarr;
<h1>MMD加载器([name])</h1>
<p class="desc">一个用于加载<a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a>资源的加载器。<br /><br />
......@@ -65,10 +66,11 @@
创建一个新的[name]。
</p>
<h2>属性</h2>
<h2>属性</h2>
<p>共有属性请参见其基类[page:Loader]。</p>
<h2>方法</h2>
<h2>方法</h2>
<p>共有方法请参见其基类[page:Loader]。</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -102,12 +104,7 @@
[page:Function onError] — (可选)如果加载过程中发生错误时被调用的函数,该函数接受一个错误来作为参数。<br />
</p>
<p>
开始从URL中加载PMD/PMX模型文件和VMD动画文件(可能有多个文件),并使用一个[page:Object] —— 包含有已解析的[page:SkinnedMesh]和适应[page:SkinnedMesh]的[page:AnimationClip],来触发回调函数。
</p>
<h3>[method:MMDLoader setCrossOrigin]( [param:String crossOrigin] )</h3>
<p>
[page:String crossOrigin] — crossOrigin字符串,用于实现CORS,以便从一个允许CORS的其它域加载url。
开始从URL中加载PMD/PMX模型文件和VMD动画文件(可能有多个文件),并使用一个[page:Object] —— 包含有已解析的[page:SkinnedMesh]和适应[page:SkinnedMesh]的[page:AnimationClip],来触发回调函数。
</p>
<h3>[method:MMDLoader setAnimationPath]( [param:String animationPath] )</h3>
......@@ -118,22 +115,6 @@
设置额外资源(例如贴图)的基础路径。
</p>
<h3>[method:MMDLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — 基础路径。
</p>
<p>
设置用于加载文件的基础路径或URL。
</p>
<h3>[method:MMDLoader setResourcePath]( [param:String resourcePath] )</h3>
<p>
[page:String resourcePath] — 用于加载额外资源(例如贴图)的基础路径。
</p>
<p>
设置额外资源(例如贴图)的基础路径。
</p>
<h2>源代码</h2>
<p>
......
......@@ -8,6 +8,7 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
......@@ -27,10 +28,10 @@
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -43,35 +44,6 @@
Begin loading from url and return the loaded material.
</p>
<h3>[method:MTLLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — required<br />
</p>
<p>
Set base path for MTL file.
</p>
<h3>[method:MTLLoader setResourcePath]( [param:String path] )</h3>
<p>
[page:String path] — required<br />
</p>
<p>
Set base path for additional resources like textures. If set, this path will be used as the base path.
</p>
<h3>[method:MTLLoader setCrossOrigin]( [param:String value] )</h3>
<p>
[page:String value] — required<br />
</p>
<p>
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"*.
</p>
<h3>[method:MTLLoader setMaterialOptions]( [param:Object options] )</h3>
<p>
[page:Object options] — required
......
......@@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;
<h1>[name]</h1>
<p class="desc">A loader for loading a <em>.tga</em> resource. <br />
......@@ -62,8 +64,11 @@
Creates a new [name].
</p>
<h2>Properties</h2>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
......@@ -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).
</p>
<h3>[method:TGALoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the file.
</p>
<h2>Source</h2>
<p>
......
......@@ -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",
......
......@@ -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 {
......
......@@ -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
......
......@@ -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
......
......@@ -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 = {
}
}
};
} );
......@@ -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;
}
};
} );
......@@ -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 */
......
......@@ -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;
}
......
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;
......
......@@ -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 {
......
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;
}
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;
}
......@@ -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
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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 };
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;
}
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;
}
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;
}
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;
......
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;
......
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;
}
......@@ -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 };
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;
}
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;
}
......@@ -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 */
......
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;
}
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册