PageSourceSearch

https://www.robotmesh.com/studio/content/jsx/threejs/LegacyJSONLoader.js

js robotmesh.com collected 2026-09-24 12:52:29 UTC 20,220 bytes, 821 lines download raw bytes

1/**
2 * @author mrdoob / http://mrdoob.com/
3 * @author alteredq / http://alteredqualia.com/
4 */
5
6THREE.LegacyJSONLoader = ( function () {
7
8	function LegacyJSONLoader( manager ) {
9
10		if ( typeof manager === 'boolean' ) {
11
12			console.warn( 'THREE.JSONLoader: showStatus parameter has been removed from constructor.' );
13			manager = undefined;
14
15		}
16
17		THREE.Loader.call( this, manager );
18
19		this.withCredentials = false;
20
21	}
22
23	LegacyJSONLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
24
25		constructor: LegacyJSONLoader,
26
27		load: function ( url, onLoad, onProgress, onError ) {
28
29			var scope = this;
30
31			var path = ( this.path === '' ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
32
33			var loader = new THREE.FileLoader( this.manager );
34			loader.setPath( this.path );
35			loader.setWithCredentials( this.withCredentials );
36			loader.load( url, function ( text ) {
37
38				var json = JSON.parse( text );
39				var metadata = json.metadata;
40
41				if ( metadata !== undefined ) {
42
43					var type = metadata.type;
44
45					if ( type !== undefined ) {
46
47						if ( type.toLowerCase() === 'object' ) {
48
49							console.error( 'THREE.JSONLoader: ' + url + ' should be loaded with THREE.ObjectLoader instead.' );
50							return;
51
52						}
53
54					}
55
56				}
57
58				var object = scope.parse( json, path );
59				onLoad( object.geometry, object.materials );
60
61			}, onProgress, onError );
62
63		},
64
65		parse: ( function () {
66
67			var _BlendingMode = {
68				NoBlending: THREE.NoBlending,
69				NormalBlending: THREE.NormalBlending,
70				AdditiveBlending: THREE.AdditiveBlending,
71				SubtractiveBlending: THREE.SubtractiveBlending,
72				MultiplyBlending: THREE.MultiplyBlending,
73				CustomBlending: THREE.CustomBlending
74			};
75
76			var _color = new THREE.Color();
77			var _textureLoader = new THREE.TextureLoader();
78			var _materialLoader = new THREE.MaterialLoader();
79
80			function initMaterials( materials, texturePath, crossOrigin, manager ) {
81
82				var array = [];
83
84				for ( var i = 0; i < materials.length; ++ i ) {
85
86					array[ i ] = createMaterial( materials[ i ], texturePath, crossOrigin, manager );
87
88				}
89
90				return array;
91
92			}
93
94			function createMaterial( m, texturePath, crossOrigin, manager ) {
95
96				// convert from old material format
97
98				var textures = {};
99
100				//
101
102				var json = {
103					uuid: THREE.Math.generateUUID(),
104					type: 'MeshLambertMaterial'
105				};
106
107				for ( var name in m ) {
108
109					var value = m[ name ];
110
111					switch ( name ) {
112
113						case 'DbgColor':
114						case 'DbgIndex':
115						case 'opticalDensity':
116						case 'illumination':
117							break;
118						case 'DbgName':
119							json.name = value;
120							break;
121						case 'blending':
122							json.blending = _BlendingMode[ value ];
123							break;
124						case 'colorAmbient':
125						case 'mapAmbient':
126							console.warn( 'THREE.LegacyJSONLoader.createMaterial:', name, 'is no longer supported.' );
127							break;
128						case 'colorDiffuse':
129							json.color = _color.fromArray( value ).getHex();
130							break;
131						case 'colorSpecular':
132							json.specular = _color.fromArray( value ).getHex();
133							break;
134						case 'colorEmissive':
135							json.emissive = _color.fromArray( value ).getHex();
136							break;
137						case 'specularCoef':
138							json.shininess = value;
139							break;
140						case 'shading':
141							if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial';
142							if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';
143							if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial';
144							break;
145						case 'mapDiffuse':
146							json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin, manager );
147							break;
148						case 'mapDiffuseRepeat':
149						case 'mapDiffuseOffset':
150						case 'mapDiffuseWrap':
151						case 'mapDiffuseAnisotropy':
152							break;
153						case 'mapEmissive':
154							json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin, manager );
155							break;
156						case 'mapEmissiveRepeat':
157						case 'mapEmissiveOffset':
158						case 'mapEmissiveWrap':
159						case 'mapEmissiveAnisotropy':
160							break;
161						case 'mapLight':
162							json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin, manager );
163							break;
164						case 'mapLightRepeat':
165						case 'mapLightOffset':
166						case 'mapLightWrap':
167						case 'mapLightAnisotropy':
168							break;
169						case 'mapAO':
170							json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin, manager );
171							break;
172						case 'mapAORepeat':
173						case 'mapAOOffset':
174						case 'mapAOWrap':
175						case 'mapAOAnisotropy':
176							break;
177						case 'mapBump':
178							json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin, manager );
179							break;
180						case 'mapBumpScale':
181							json.bumpScale = value;
182							break;
183						case 'mapBumpRepeat':
184						case 'mapBumpOffset':
185						case 'mapBumpWrap':
186						case 'mapBumpAnisotropy':
187							break;
188						case 'mapNormal':
189							json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin, manager );
190							break;
191						case 'mapNormalFactor':
192							json.normalScale = value;
193							break;
194						case 'mapNormalRepeat':
195						case 'mapNormalOffset':
196						case 'mapNormalWrap':
197						case 'mapNormalAnisotropy':
198							break;
199						case 'mapSpecular':
200							json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin, manager );
201							break;
202						case 'mapSpecularRepeat':
203						case 'mapSpecularOffset':
204						case 'mapSpecularWrap':
205						case 'mapSpecularAnisotropy':
206							break;
207						case 'mapMetalness':
208							json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin, manager );
209							break;
210						case 'mapMetalnessRepeat':
211						case 'mapMetalnessOffset':
212						case 'mapMetalnessWrap':
213						case 'mapMetalnessAnisotropy':
214							break;
215						case 'mapRoughness':
216							json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin, manager );
217							break;
218						case 'mapRoughnessRepeat':
219						case 'mapRoughnessOffset':
220						case 'mapRoughnessWrap':
221						case 'mapRoughnessAnisotropy':
222							break;
223						case 'mapAlpha':
224							json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin, manager );
225							break;
226						case 'mapAlphaRepeat':
227						case 'mapAlphaOffset':
228						case 'mapAlphaWrap':
229						case 'mapAlphaAnisotropy':
230							break;
231						case 'flipSided':
232							json.side = THREE.BackSide;
233							break;
234						case 'doubleSided':
235							json.side = THREE.DoubleSide;
236							break;
237						case 'transparency':
238							console.warn( 'THREE.LegacyJSONLoader.createMaterial: transparency has been renamed to opacity' );
239							json.opacity = value;
240							break;
241						case 'depthTest':
242						case 'depthWrite':
243						case 'colorWrite':
244						case 'opacity':
245						case 'reflectivity':
246						case 'transparent':
247						case 'visible':
248						case 'wireframe':
249							json[ name ] = value;
250							break;
251						case 'vertexColors':
252							if ( value === true ) json.vertexColors = THREE.VertexColors;
253							if ( value === 'face' ) json.vertexColors = THREE.FaceColors;
254							break;
255						default:
256							console.error( 'THREE.LegacyJSONLoader.createMaterial: Unsupported', name, value );
257							break;
258
259					}
260
261				}
262
263				if ( json.type === 'MeshBasicMaterial' ) delete json.emissive;
264				if ( json.type !== 'MeshPhongMaterial' ) delete json.specular;
265
266				if ( json.opacity < 1 ) json.transparent = true;
267
268				_materialLoader.setTextures( textures );
269
270				return _materialLoader.parse( json );
271
272			}
273
274			function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin, manager ) {
275
276				var fullPath = texturePath + path;
277				var loader = manager.getHandler( fullPath );
278
279				var texture;
280
281				if ( loader !== null ) {
282
283					texture = loader.load( fullPath );
284
285				} else {
286
287					_textureLoader.setCrossOrigin( crossOrigin );
288					texture = _textureLoader.load( fullPath );
289
290				}
291
292				if ( repeat !== undefined ) {
293
294					texture.repeat.fromArray( repeat );
295
296					if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
297					if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
298
299				}
300
301				if ( offset !== undefined ) {
302
303					texture.offset.fromArray( offset );
304
305				}
306
307				if ( wrap !== undefined ) {
308
309					if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = THREE.RepeatWrapping;
310					if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = THREE.MirroredRepeatWrapping;
311
312					if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = THREE.RepeatWrapping;
313					if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = THREE.MirroredRepeatWrapping;
314
315				}
316
317				if ( anisotropy !== undefined ) {
318
319					texture.anisotropy = anisotropy;
320
321				}
322
323				var uuid = THREE.Math.generateUUID();
324
325				textures[ uuid ] = texture;
326
327				return uuid;
328
329			}
330
331			function parseModel( json, geometry ) {
332
333				function isBitSet( value, position ) {
334
335					return value & ( 1 << position );
336
337				}
338
339				var i, j, fi,
340
341					offset, zLength,
342
343					colorIndex, normalIndex, uvIndex, materialIndex,
344
345					type,
346					isQuad,
347					hasMaterial,
348					hasFaceVertexUv,
349					hasFaceNormal, hasFaceVertexNormal,
350					hasFaceColor, hasFaceVertexColor,
351
352					vertex, face, faceA, faceB, hex, normal,
353
354					uvLayer, uv, u, v,
355
356					faces = json.faces,
357					vertices = json.vertices,
358					normals = json.normals,
359					colors = json.colors,
360
361					scale = json.scale,
362
363					nUvLayers = 0;
364
365
366				if ( json.uvs !== undefined ) {
367
368					// disregard empty arrays
369
370					for ( i = 0; i < json.uvs.length; i ++ ) {
371
372						if ( json.uvs[ i ].length ) nUvLayers ++;
373
374					}
375
376					for ( i = 0; i < nUvLayers; i ++ ) {
377
378						geometry.faceVertexUvs[ i ] = [];
379
380					}
381
382				}
383
384				offset = 0;
385				zLength = vertices.length;
386
387				while ( offset < zLength ) {
388
389					vertex = new THREE.Vector3();
390
391					vertex.x = vertices[ offset ++ ] * scale;
392					vertex.y = vertices[ offset ++ ] * scale;
393					vertex.z = vertices[ offset ++ ] * scale;
394
395					geometry.vertices.push( vertex );
396
397				}
398
399				offset = 0;
400				zLength = faces.length;
401
402				while ( offset < zLength ) {
403
404					type = faces[ offset ++ ];
405
406					isQuad = isBitSet( type, 0 );
407					hasMaterial = isBitSet( type, 1 );
408					hasFaceVertexUv = isBitSet( type, 3 );
409					hasFaceNormal = isBitSet( type, 4 );
410					hasFaceVertexNormal = isBitSet( type, 5 );
411					hasFaceColor = isBitSet( type, 6 );
412					hasFaceVertexColor = isBitSet( type, 7 );
413
414					// console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
415
416					if ( isQuad ) {
417
418						faceA = new THREE.Face3();
419						faceA.a = faces[ offset ];
420						faceA.b = faces[ offset + 1 ];
421						faceA.c = faces[ offset + 3 ];
422
423						faceB = new THREE.Face3();
424						faceB.a = faces[ offset + 1 ];
425						faceB.b = faces[ offset + 2 ];
426						faceB.c = faces[ offset + 3 ];
427
428						offset += 4;
429
430						if ( hasMaterial ) {
431
432							materialIndex = faces[ offset ++ ];
433							faceA.materialIndex = materialIndex;
434							faceB.materialIndex = materialIndex;
435
436						}
437
438						// to get face <=> uv index correspondence
439
440						fi = geometry.faces.length;
441
442						if ( hasFaceVertexUv ) {
443
444							for ( i = 0; i < nUvLayers; i ++ ) {
445
446								uvLayer = json.uvs[ i ];
447
448								geometry.faceVertexUvs[ i ][ fi ] = [];
449								geometry.faceVertexUvs[ i ][ fi + 1 ] = [];
450
451								for ( j = 0; j < 4; j ++ ) {
452
453									uvIndex = faces[ offset ++ ];
454
455									u = uvLayer[ uvIndex * 2 ];
456									v = uvLayer[ uvIndex * 2 + 1 ];
457
458									uv = new THREE.Vector2( u, v );
459
460									if ( j !== 2 ) geometry.faceVertexUvs[ i ][ fi ].push( uv );
461									if ( j !== 0 ) geometry.faceVertexUvs[ i ][ fi + 1 ].push( uv );
462
463								}
464
465							}
466
467						}
468
469						if ( hasFaceNormal ) {
470
471							normalIndex = faces[ offset ++ ] * 3;
472
473							faceA.normal.set(
474								normals[ normalIndex ++ ],
475								normals[ normalIndex ++ ],
476								normals[ normalIndex ]
477							);
478
479							faceB.normal.copy( faceA.normal );
480
481						}
482
483						if ( hasFaceVertexNormal ) {
484
485							for ( i = 0; i < 4; i ++ ) {
486
487								normalIndex = faces[ offset ++ ] * 3;
488
489								normal = new THREE.Vector3(
490									normals[ normalIndex ++ ],
491									normals[ normalIndex ++ ],
492									normals[ normalIndex ]
493								);
494
495
496								if ( i !== 2 ) faceA.vertexNormals.push( normal );
497								if ( i !== 0 ) faceB.vertexNormals.push( normal );
498
499							}
500
501						}
502
503
504						if ( hasFaceColor ) {
505
506							colorIndex = faces[ offset ++ ];
507							hex = colors[ colorIndex ];
508
509							faceA.color.setHex( hex );
510							faceB.color.setHex( hex );
511
512						}
513
514
515						if ( hasFaceVertexColor ) {
516
517							for ( i = 0; i < 4; i ++ ) {
518
519								colorIndex = faces[ offset ++ ];
520								hex = colors[ colorIndex ];
521
522								if ( i !== 2 ) faceA.vertexColors.push( new THREE.Color( hex ) );
523								if ( i !== 0 ) faceB.vertexColors.push( new THREE.Color( hex ) );
524
525							}
526
527						}
528
529						geometry.faces.push( faceA );
530						geometry.faces.push( faceB );
531
532					} else {
533
534						face = new THREE.Face3();
535						face.a = faces[ offset ++ ];
536						face.b = faces[ offset ++ ];
537						face.c = faces[ offset ++ ];
538
539						if ( hasMaterial ) {
540
541							materialIndex = faces[ offset ++ ];
542							face.materialIndex = materialIndex;
543
544						}
545
546						// to get face <=> uv index correspondence
547
548						fi = geometry.faces.length;
549
550						if ( hasFaceVertexUv ) {
551
552							for ( i = 0; i < nUvLayers; i ++ ) {
553
554								uvLayer = json.uvs[ i ];
555
556								geometry.faceVertexUvs[ i ][ fi ] = [];
557
558								for ( j = 0; j < 3; j ++ ) {
559
560									uvIndex = faces[ offset ++ ];
561
562									u = uvLayer[ uvIndex * 2 ];
563									v = uvLayer[ uvIndex * 2 + 1 ];
564
565									uv = new THREE.Vector2( u, v );
566
567									geometry.faceVertexUvs[ i ][ fi ].push( uv );
568
569								}
570
571							}
572
573						}
574
575						if ( hasFaceNormal ) {
576
577							normalIndex = faces[ offset ++ ] * 3;
578
579							face.normal.set(
580								normals[ normalIndex ++ ],
581								normals[ normalIndex ++ ],
582								normals[ normalIndex ]
583							);
584
585						}
586
587						if ( hasFaceVertexNormal ) {
588
589							for ( i = 0; i < 3; i ++ ) {
590
591								normalIndex = faces[ offset ++ ] * 3;
592
593								normal = new THREE.Vector3(
594									normals[ normalIndex ++ ],
595									normals[ normalIndex ++ ],
596									normals[ normalIndex ]
597								);
598
599								face.vertexNormals.push( normal );
600
601							}
602
603						}
604
605
606						if ( hasFaceColor ) {
607
608							colorIndex = faces[ offset ++ ];
609							face.color.setHex( colors[ colorIndex ] );
610
611						}
612
613
614						if ( hasFaceVertexColor ) {
615
616							for ( i = 0; i < 3; i ++ ) {
617
618								colorIndex = faces[ offset ++ ];
619								face.vertexColors.push( new THREE.Color( colors[ colorIndex ] ) );
620
621							}
622
623						}
624
625						geometry.faces.push( face );
626
627					}
628
629				}
630
631			}
632
633			function parseSkin( json, geometry ) {
634
635				var influencesPerVertex = ( json.influencesPerVertex !== undefined ) ? json.influencesPerVertex : 2;
636
637				if ( json.skinWeights ) {
638
639					for ( var i = 0, l = json.skinWeights.length; i < l; i += influencesPerVertex ) {
640
641						var x = json.skinWeights[ i ];
642						var y = ( influencesPerVertex > 1 ) ? json.skinWeights[ i + 1 ] : 0;
643						var z = ( influencesPerVertex > 2 ) ? json.skinWeights[ i + 2 ] : 0;
644						var w = ( influencesPerVertex > 3 ) ? json.skinWeights[ i + 3 ] : 0;
645
646						geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) );
647
648					}
649
650				}
651
652				if ( json.skinIndices ) {
653
654					for ( var i = 0, l = json.skinIndices.length; i < l; i += influencesPerVertex ) {
655
656						var a = json.skinIndices[ i ];
657						var b = ( influencesPerVertex > 1 ) ? json.skinIndices[ i + 1 ] : 0;
658						var c = ( influencesPerVertex > 2 ) ? json.skinIndices[ i + 2 ] : 0;
659						var d = ( influencesPerVertex > 3 ) ? json.skinIndices[ i + 3 ] : 0;
660
661						geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) );
662
663					}
664
665				}
666
667				geometry.bones = json.bones;
668
669				if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) {
670
671					console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' +
672						geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' );
673
674				}
675
676			}
677
678			function parseMorphing( json, geometry ) {
679
680				var scale = json.scale;
681
682				if ( json.morphTargets !== undefined ) {
683
684					for ( var i = 0, l = json.morphTargets.length; i < l; i ++ ) {
685
686						geometry.morphTargets[ i ] = {};
687						geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
688						geometry.morphTargets[ i ].vertices = [];
689
690						var dstVertices = geometry.morphTargets[ i ].vertices;
691						var srcVertices = json.morphTargets[ i ].vertices;
692
693						for ( var v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
694
695							var vertex = new THREE.Vector3();
696							vertex.x = srcVertices[ v ] * scale;
697							vertex.y = srcVertices[ v + 1 ] * scale;
698							vertex.z = srcVertices[ v + 2 ] * scale;
699
700							dstVertices.push( vertex );
701
702						}
703
704					}
705
706				}
707
708				if ( json.morphColors !== undefined && json.morphColors.length > 0 ) {
709
710					console.warn( 'THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.' );
711
712					var faces = geometry.faces;
713					var morphColors = json.morphColors[ 0 ].colors;
714
715					for ( var i = 0, l = faces.length; i < l; i ++ ) {
716
717						faces[ i ].color.fromArray( morphColors, i * 3 );
718
719					}
720
721				}
722
723			}
724
725			function parseAnimations( json, geometry ) {
726
727				var outputAnimations = [];
728
729				// parse old style Bone/Hierarchy animations
730				var animations = [];
731
732				if ( json.animation !== undefined ) {
733
734					animations.push( json.animation );
735
736				}
737
738				if ( json.animations !== undefined ) {
739
740					if ( json.animations.length ) {
741
742						animations = animations.concat( json.animations );
743
744					} else {
745
746						animations.push( json.animations );
747
748					}
749
750				}
751
752				for ( var i = 0; i < animations.length; i ++ ) {
753
754					var clip = THREE.AnimationClip.parseAnimation( animations[ i ], geometry.bones );
755					if ( clip ) outputAnimations.push( clip );
756
757				}
758
759				// parse implicit morph animations
760				if ( geometry.morphTargets ) {
761
762					// TODO: Figure out what an appropraite FPS is for morph target animations -- defaulting to 10, but really it is completely arbitrary.
763					var morphAnimationClips = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( geometry.morphTargets, 10 );
764					outputAnimations = outputAnimations.concat( morphAnimationClips );
765
766				}
767
768				if ( outputAnimations.length > 0 ) geometry.animations = outputAnimations;
769
770			}
771
772			return function parse( json, path ) {
773
774				if ( json.data !== undefined ) {
775
776					// Geometry 4.0 spec
777					json = json.data;
778
779				}
780
781				if ( json.scale !== undefined ) {
782
783					json.scale = 1.0 / json.scale;
784
785				} else {
786
787					json.scale = 1.0;
788
789				}
790
791				var geometry = new THREE.Geometry();
792
793				parseModel( json, geometry );
794				parseSkin( json, geometry );
795				parseMorphing( json, geometry );
796				parseAnimations( json, geometry );
797
798				geometry.computeFaceNormals();
799				geometry.computeBoundingSphere();
800
801				if ( json.materials === undefined || json.materials.length === 0 ) {
802
803					return { geometry: geometry };
804
805				} else {
806
807					var materials = initMaterials( json.materials, this.resourcePath || path, this.crossOrigin, this.manager );
808
809					return { geometry: geometry, materials: materials };
810
811				}
812
813			};
814
815		} )()
816
817	} );
818
819	return LegacyJSONLoader;
820
821} )();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.