File: OBJLoader2.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (205 lines) | stat: -rw-r--r-- 6,443 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!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">A loader for loading a <em>.obj</em> resource.<br />
			The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format
			that represents 3D geometry in a human readable format as, the position of each vertex, the UV position of
			each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of
			vertices, and texture vertices.
		</p>

		<h2>Examples</h2>

		<code>
		// instantiate the loader
		let loader = new THREE.OBJLoader2();

		// function called on successful load
		function callbackOnLoad ( object3d ) {
			scene.add( object3d );
		}

		// load a resource from provided URL synchronously
		loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null );
		</code>

		[example:webgl_loader_obj2] - Simple example <br>
		[example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel]))<br>


		<h2>Constructor</h2>

		<h3>[name]( [param:LoadingManager manager] )</h3>
		<p>
			[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br>
		</p>
		<p>
			Creates a new [name]. Use it to load OBJ data from files or to parse OBJ data from arraybuffer or text.
		</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:Object3D parse]( [param:arraybuffer content]|[param:String content] )</h3>
		<p>
			[[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
		</p>
		<p>
			Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D baseObject3d].
		</p>


		<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:Function onMeshAlter] )</h3>
		<p>
			[page:String url] - A string containing the path/URL of the file to be loaded.<br>
			[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
			[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>
			[page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
			[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
		</p>
		<p>
			Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.
		</p>


		<h3>[method:OBJLoader2 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:OBJLoader2 addMaterialPerSmoothingGroup] ( [param:boolean materialPerSmoothingGroup] )</h3>
		<p>
			[page:boolean materialPerSmoothingGroup]
		</p>
		<p>
			Tells whether a material shall be created per smoothing group.
		</p>


		<h3>[method:OBJLoader2 setUseOAsMesh] ( [param:boolean useOAsMesh] )</h3>
		<p>
			[page:boolean useOAsMesh]
		</p>
		<p>
			Usually 'o' is meta-information and does not result in creation of new meshes, but mesh creation on occurrence of "o" can be enforced.
		</p>


		<h3>[method:OBJLoader2 setUseIndices]( [param:Boolean useIndices] )</h3>
		<p>
			[page:Boolean useIndices]
		</p>
		<p>
			Instructs loaders to create indexed [page:BufferGeometry].
		</p>


		<h3>[method:OBJLoader2 setDisregardNormals]( [param:Boolean disregardNormals] )</h3>
		<p>
			[page:Boolean disregardNormals]
		</p>
		<p>
			Tells whether normals should be completely disregarded and regenerated.
		</p>


		<h3>[method:OBJLoader2 setModelName] ( [param:String modelName] )</h3>
		<p>
			[page:String modelName]
		</p>
		<p>
			Set the name of the model.
		</p>


		<h3>[method:OBJLoader2 setBaseObject3d] ( [param:Object3d baseObject3d] )</h3>
		<p>
			[page:Object3D baseObject3d - Object already attached to scenegraph where new meshes will be attached to
		</p>
		<p>
			Set the node where the loaded objects will be attached directly.
		</p>


		<h3>[method:OBJLoader2 setMaterials] ( [param:Object materials] )</h3>
		<p>
			[page:Object materials] -  materials Object with named [page:Material Materials]
		</p>
		<p>
			Add materials as associated array.
		</p>


		<h3>[method:OBJLoader2 setCallbackOnLoad] ( [param:Function onLoad] )</h3>
		<p>
			[page:Function onLoad]
		</p>
		<p>
			Register a function that is called when parsing was completed.
		</p>


		<h3>[method:OBJLoader2 setCallbackOnAssetAvailable] ( [param:Function onAssetAvailable] )</h3>
		<p>
			[page:Function onAssetAvailable]
		</p>
		<p>
			Register a function that is called once an asset (mesh/material) becomes available.
		</p>


		<h3>[method:OBJLoader2 setCallbackOnProgress] ( [param:Function onProgress] )</h3>
		<p>
			[page:Function onProgress]
		</p>
		<p>
			Register a function that is used to report overall processing progress.
		</p>


		<h3>[method:OBJLoader2 setCallbackOnError] ( [param:Function onError] )</h3>
		<p>
			[page:Function onError]
		</p>
		<p>
			Register an error handler function that is called if errors occur. It can decide to just log or to throw an exception.
		</p>


		<h3>[method:OBJLoader2 setCallbackOnMeshAlter] ( [param:Function onMeshAlter] )</h3>
		<p>
			[page:Function onMeshAlter]
		</p>
		<p>
			Register a function that is called once a single mesh is available and it could be altered by the supplied function.
		</p>


		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader2.js examples/jsm/loaders/OBJLoader2.js]
		</p>
	</body>
</html>