Skip to content

Commit 827e3e1

Browse files
authored
Merge pull request #13156 from kaisalmen/OBJLoader2_V230
OBJLoader2 V2.3.1: Parser Verification, Point and Line support, moved generic functions to LoaderBase
2 parents e899044 + 6d3f13f commit 827e3e1

File tree

13 files changed

+1600
-873
lines changed

13 files changed

+1600
-873
lines changed

docs/examples/loaders/LoaderSupport.html

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ <h2>Methods</h2>
158158

159159
<h3>[method:null validate] ( [page:Function functionCodeBuilder], Array of [page:String libLocations], [page:String libPath], [page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] )</h3>
160160
<div>
161-
[page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingelton that allows stringification of objects and singletons.<br>
161+
[page:Function functionCodeBuilder] - Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons.<br>
162162
Array of [page:String libLocations] - URL of libraries that shall be added to worker code relative to libPath.<br>
163163
[page:String libPath] - Base path used for loading libraries.<br>
164164
[page:LoaderSupport.WorkerRunnerRefImpl runnerImpl] - The default worker parser wrapper implementation (communication and execution). An extended class could be passed here.
@@ -405,12 +405,35 @@ <h3>LoaderBase( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger
405405
[page:LoaderSupport.ConsoleLogger logger] - logger to be used
406406
</div>
407407
<div>
408-
Base class to be used by loaders.
408+
Base class to be used by Loaders that provide load, parse, parseAsync and run
409409
</div>
410410

411411

412412
<h2>Methods</h2>
413-
413+
414+
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
415+
<div>
416+
[page:String url] - A string containing the path/URL of the file to be loaded.<br>
417+
[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
418+
[page:Function onProgress] - (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br>
419+
[page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
420+
[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
421+
[page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
422+
</div>
423+
<div>
424+
Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.
425+
</div>
426+
427+
<h3>[method:ConsoleLogger checkResourceDescriptorFiles] ( [page:THREE.LoaderSupport.ResourceDescriptor resources], [page:Object fileDesc] )</h3>
428+
<div>
429+
[page:THREE.LoaderSupport.ResourceDescriptor resources] - Array of {@link THREE.LoaderSupport.ResourceDescriptor}
430+
[page:Object fileDesc] - Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean))
431+
</div>
432+
<div>
433+
Identify files or content of interest from an Array of {@link THREE.LoaderSupport.ResourceDescriptor}. Returns Object with each "ext" and the corresponding {@link THREE.LoaderSupport.ResourceDescriptor}
434+
</div>
435+
436+
414437
<h3>[method:ConsoleLogger getLogger] ()</h3>
415438
<div>
416439
Returns [page:LoaderSupport.ConsoleLogger].
@@ -608,36 +631,40 @@ <h3>[method:Boolean isEnabled]()</h3>
608631
</div>
609632

610633

611-
<h3>[method:null logDebug]( [page:String message] )</h3>
634+
<h3>[method:null logDebug]( [page:String message], Array of [page:String additional] )</h3>
612635
<div>
613636
[page:String message] - Message to log
637+
Array of [page:String additional] - Array of [page:String strings] containing additional content to be logged
614638
</div>
615639
<div>
616640
Log a debug message if enabled and debug is set.
617641
</div>
618642

619643

620-
<h3>[method:null logInfo]( [page:String message] )</h3>
644+
<h3>[method:null logInfo]( [page:String message], Array of [page:String additional] )</h3>
621645
<div>
622646
[page:String message] - Message to log
647+
Array of [page:String additional] - Array of [page:String strings] containing additional content to be logged
623648
</div>
624649
<div>
625650
Log an info message if enabled.
626651
</div>
627652

628653

629-
<h3>[method:null logWarn]( [page:String message] )</h3>
654+
<h3>[method:null logWarn]( [page:String message], Array of [page:String additional] )</h3>
630655
<div>
631656
[page:String message] - Message to log
657+
Array of [page:String additional] - Array of [page:String strings] containing additional content to be logged
632658
</div>
633659
<div>
634660
Log a warn message (always).
635661
</div>
636662

637663

638-
<h3>[method:null logError]( [page:String message] )</h3>
664+
<h3>[method:null logError]( [page:String message], Array of [page:String additional] )</h3>
639665
<div>
640666
[page:String message] - Message to log
667+
Array of [page:String additional] - Array of [page:String strings] containing additional content to be logged
641668
</div>
642669
<div>
643670
Log an error message (always).

docs/examples/loaders/OBJLoader2.html

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<h1>[name]</h1>
1313

14-
<div class="desc">A loader for loading a <em>.obj</em> resource. <br />
14+
<div class="desc">A loader for loading a <em>.obj</em> resource.<br />
1515
The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format
1616
that represents 3D geometry in a human redeable format as, the position of each vertex, the UV position of
1717
each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of
@@ -42,7 +42,7 @@ <h2>Constructor</h2>
4242

4343
<h3>[name]( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )</h3>
4444
<div>
45-
[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
45+
[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br>
4646
[page:LoaderSupport.ConsoleLogger logger] - logger to be used
4747
</div>
4848
<div>
@@ -71,19 +71,8 @@ <h3>[method:Object3D parseAsync]( [page:arraybuffer content], [page:Function onL
7171
</div>
7272

7373

74-
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
75-
<div>
76-
[page:String url] - A string containing the path/URL of the <em>.obj</em> file.<br>
77-
[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
78-
[page:Function onProgress] - (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br>
79-
[page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
80-
[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
81-
[page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
82-
</div>
83-
<div>
84-
Use this convenient method to load an OBJ file at the given URL. By default the fileLoader uses an arraybuffer.
85-
</div>
86-
74+
<h3>[method:null load] => [page:LoaderSupport.LoaderBase.load]</h3>
75+
8776

8877
<h3>[method:null run]( [page:LoaderSupport.PrepData params], [page:LoaderSupport.WorkerSupport workerSupportExternal] )</h3>
8978
<div>
@@ -94,7 +83,10 @@ <h3>[method:null run]( [page:LoaderSupport.PrepData params], [page:LoaderSupport
9483
Run the loader according the provided instructions.
9584
</div>
9685

97-
86+
87+
<h3>[method:Object checkResourceDescriptorFiles] => [page:LoaderSupport.LoaderBase.checkResourceDescriptorFiles]</h3>
88+
89+
9890
<h3>[method:null setMaterialPerSmoothingGroup] ( [page:boolean materialPerSmoothingGroup] )</h3>
9991
<div>
10092
[page:boolean materialPerSmoothingGroup]
@@ -164,7 +156,21 @@ <h3>[method:null setDisregardNormals]( [page:Boolean disregardNormals] )</h3>
164156
<div>
165157
Tells whether normals should be completely disregarded and regenerated.
166158
</div>
159+
160+
161+
<h3>[method:null loadMtl]( [page:String url], [page:Object content], [page:Function callbackOnLoad], [page:String crossOrigin], [page:Object materialOptions]) </h3>
162+
<div>
163+
[page:String url] - URL to the file
164+
[page:Object content] - The file content as arraybuffer or text
165+
[page:Function callbackOnLoad] - Callback to be called after successful load
166+
[page:String crossOrigin] - (optional) CORS value
167+
[page:Function materialOptions] - (optional) Set material loading options for MTLLoader
168+
</div>
169+
<div>
170+
Utility method for loading an mtl file according resource description. Provide url or content..
171+
</div>
167172

173+
168174
<h2>Source</h2>
169175

170176
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]

0 commit comments

Comments
 (0)