json-object-editor 0.10.440 → 0.10.444

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build.js +61 -0
  3. package/css/jif/Read Me.txt +5 -5
  4. package/css/jif/demo-files/demo.css +153 -153
  5. package/css/jif/demo-files/demo.js +30 -30
  6. package/css/jif/demo.html +285 -285
  7. package/css/jif/fonts/joeiconfont.svg +24 -24
  8. package/css/jif/ie7/ie7.css +45 -45
  9. package/css/jif/ie7/ie7.js +46 -46
  10. package/css/jif/selection.json +573 -573
  11. package/css/joe.css +15 -9
  12. package/css/joe.min.css +7 -0
  13. package/css/jquery-ui-1.10.4.custom.min.css +5 -5
  14. package/css/jquery-ui.min.css +6 -6
  15. package/css/jquery.timepicker.css +72 -72
  16. package/es5-build/web-components/account-info.js +136 -136
  17. package/es5-build/web-components/capp-components.js +160 -160
  18. package/es5-build/web-components/capp-panel.js +85 -85
  19. package/es5-build/web-components/capp-view.js +73 -73
  20. package/es5-build/web-components/joe-autocomplete.js +149 -149
  21. package/es5-build/web-components/joe-button.js +132 -132
  22. package/es5-build/web-components/joe-card.js +92 -92
  23. package/es5-build/web-components/joe-component.js +74 -74
  24. package/es5-build/web-components/joe-field.js +70 -70
  25. package/es5-build/web-components/joe-list-item.js +176 -176
  26. package/es5-build/web-components/joe-user-cube.js +100 -100
  27. package/es5-build/web-components/report-components.js +133 -133
  28. package/grunt/build +86 -86
  29. package/grunt/package-lock.json +9105 -9105
  30. package/grunt/package.json +47 -47
  31. package/grunt/src +86 -86
  32. package/js/joe.js +12 -8
  33. package/js/joe.min.js +1 -15
  34. package/js/leaflet.js +8 -8
  35. package/js/libs/adapter-latest.js +4400 -4400
  36. package/js/libs/craydent-1.9.2.js +11741 -11741
  37. package/js/libs/craydent-upload-2.0.0.js +394 -394
  38. package/js/libs/hammer.min.208.js +6 -6
  39. package/js/libs/jquery-3.5.1.min.js +2 -2
  40. package/js/libs/moment.min.js +6 -6
  41. package/js/native-shim.js +46 -46
  42. package/js/plugins/c3/c3.min.js +5 -5
  43. package/js/plugins/c3/d3.v3.min.js +4 -4
  44. package/js/plugins/threejs/Detector.js +78 -78
  45. package/js/plugins/threejs/LICENSE +21 -21
  46. package/js/plugins/threejs/MTLLoader.js +417 -417
  47. package/js/plugins/threejs/OBJLoader.js +564 -564
  48. package/js/plugins/threejs/OrbitControls.js +1037 -1037
  49. package/js/plugins/threejs/README.md +9 -9
  50. package/js/plugins/threejs/assets/female-croupier-2013-03-26.mtl +3 -3
  51. package/js/plugins/threejs/index.html +178 -178
  52. package/js/plugins/threejs/three.js +41507 -41507
  53. package/package.json +9 -4
  54. package/server/fields/core.js +1 -1
  55. package/server/modules/Server.js +21 -1
  56. package/server/plugins/chatgpt-assistants.js +359 -359
  57. package/server/plugins/chatgpt-tools.js +79 -79
  58. package/server/plugins/engagementTracker.js +78 -0
  59. package/server/schemas/engagement_event.js +33 -0
  60. package/server/schemas/page.js +18 -1
@@ -1,564 +1,564 @@
1
- /**
2
- * @author mrdoob / http://mrdoob.com/
3
- */
4
-
5
- THREE.OBJLoader = function ( manager ) {
6
-
7
- this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
8
-
9
- this.materials = null;
10
-
11
- this.regexp = {
12
- // v float float float
13
- vertex_pattern : /^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
14
- // vn float float float
15
- normal_pattern : /^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
16
- // vt float float
17
- uv_pattern : /^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
18
- // f vertex vertex vertex
19
- face_vertex : /^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,
20
- // f vertex/uv vertex/uv vertex/uv
21
- face_vertex_uv : /^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,
22
- // f vertex/uv/normal vertex/uv/normal vertex/uv/normal
23
- face_vertex_uv_normal : /^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,
24
- // f vertex//normal vertex//normal vertex//normal
25
- face_vertex_normal : /^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,
26
- // o object_name | g group_name
27
- object_pattern : /^[og]\s*(.+)?/,
28
- // s boolean
29
- smoothing_pattern : /^s\s+(\d+|on|off)/,
30
- // mtllib file_reference
31
- material_library_pattern : /^mtllib /,
32
- // usemtl material_name
33
- material_use_pattern : /^usemtl /
34
- };
35
-
36
- };
37
-
38
- THREE.OBJLoader.prototype = {
39
-
40
- constructor: THREE.OBJLoader,
41
-
42
- load: function ( url, onLoad, onProgress, onError ) {
43
-
44
- var scope = this;
45
-
46
- var loader = new THREE.XHRLoader( scope.manager );
47
- loader.setPath( this.path );
48
- loader.load( url, function ( text ) {
49
-
50
- onLoad( scope.parse( text ) );
51
-
52
- }, onProgress, onError );
53
-
54
- },
55
-
56
- setPath: function ( value ) {
57
-
58
- this.path = value;
59
-
60
- },
61
-
62
- setMaterials: function ( materials ) {
63
-
64
- this.materials = materials;
65
-
66
- },
67
-
68
- _createParserState : function () {
69
-
70
- var state = {
71
- objects : [],
72
- object : {},
73
-
74
- vertices : [],
75
- normals : [],
76
- uvs : [],
77
-
78
- materialLibraries : [],
79
-
80
- startObject: function ( name, fromDeclaration ) {
81
-
82
- // If the current object (initial from reset) is not from a g/o declaration in the parsed
83
- // file. We need to use it for the first parsed g/o to keep things in sync.
84
- if ( this.object && this.object.fromDeclaration === false ) {
85
-
86
- this.object.name = name;
87
- this.object.fromDeclaration = ( fromDeclaration !== false );
88
- return;
89
-
90
- }
91
-
92
- this.object = {
93
- name : name || '',
94
- geometry : {
95
- vertices : [],
96
- normals : [],
97
- uvs : []
98
- },
99
- material : {
100
- name : '',
101
- smooth : true
102
- },
103
- fromDeclaration : ( fromDeclaration !== false )
104
- };
105
-
106
- this.objects.push( this.object );
107
-
108
- },
109
-
110
- parseVertexIndex: function ( value, len ) {
111
-
112
- var index = parseInt( value, 10 );
113
- return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
114
-
115
- },
116
-
117
- parseNormalIndex: function ( value, len ) {
118
-
119
- var index = parseInt( value, 10 );
120
- return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
121
-
122
- },
123
-
124
- parseUVIndex: function ( value, len ) {
125
-
126
- var index = parseInt( value, 10 );
127
- return ( index >= 0 ? index - 1 : index + len / 2 ) * 2;
128
-
129
- },
130
-
131
- addVertex: function ( a, b, c ) {
132
-
133
- var src = this.vertices;
134
- var dst = this.object.geometry.vertices;
135
-
136
- dst.push( src[ a + 0 ] );
137
- dst.push( src[ a + 1 ] );
138
- dst.push( src[ a + 2 ] );
139
- dst.push( src[ b + 0 ] );
140
- dst.push( src[ b + 1 ] );
141
- dst.push( src[ b + 2 ] );
142
- dst.push( src[ c + 0 ] );
143
- dst.push( src[ c + 1 ] );
144
- dst.push( src[ c + 2 ] );
145
-
146
- },
147
-
148
- addVertexLine: function ( a ) {
149
-
150
- var src = this.vertices;
151
- var dst = this.object.geometry.vertices;
152
-
153
- dst.push( src[ a + 0 ] );
154
- dst.push( src[ a + 1 ] );
155
- dst.push( src[ a + 2 ] );
156
-
157
- },
158
-
159
- addNormal : function ( a, b, c ) {
160
-
161
- var src = this.normals;
162
- var dst = this.object.geometry.normals;
163
-
164
- dst.push( src[ a + 0 ] );
165
- dst.push( src[ a + 1 ] );
166
- dst.push( src[ a + 2 ] );
167
- dst.push( src[ b + 0 ] );
168
- dst.push( src[ b + 1 ] );
169
- dst.push( src[ b + 2 ] );
170
- dst.push( src[ c + 0 ] );
171
- dst.push( src[ c + 1 ] );
172
- dst.push( src[ c + 2 ] );
173
-
174
- },
175
-
176
- addUV: function ( a, b, c ) {
177
-
178
- var src = this.uvs;
179
- var dst = this.object.geometry.uvs;
180
-
181
- dst.push( src[ a + 0 ] );
182
- dst.push( src[ a + 1 ] );
183
- dst.push( src[ b + 0 ] );
184
- dst.push( src[ b + 1 ] );
185
- dst.push( src[ c + 0 ] );
186
- dst.push( src[ c + 1 ] );
187
-
188
- },
189
-
190
- addUVLine: function ( a ) {
191
-
192
- var src = this.uvs;
193
- var dst = this.object.geometry.uvs;
194
-
195
- dst.push( src[ a + 0 ] );
196
- dst.push( src[ a + 1 ] );
197
-
198
- },
199
-
200
- addFace: function ( a, b, c, d, ua, ub, uc, ud, na, nb, nc, nd ) {
201
-
202
- var vLen = this.vertices.length;
203
-
204
- var ia = this.parseVertexIndex( a, vLen );
205
- var ib = this.parseVertexIndex( b, vLen );
206
- var ic = this.parseVertexIndex( c, vLen );
207
- var id;
208
-
209
- if ( d === undefined ) {
210
-
211
- this.addVertex( ia, ib, ic );
212
-
213
- } else {
214
-
215
- id = this.parseVertexIndex( d, vLen );
216
-
217
- this.addVertex( ia, ib, id );
218
- this.addVertex( ib, ic, id );
219
-
220
- }
221
-
222
- if ( ua !== undefined ) {
223
-
224
- var uvLen = this.uvs.length;
225
-
226
- ia = this.parseUVIndex( ua, uvLen );
227
- ib = this.parseUVIndex( ub, uvLen );
228
- ic = this.parseUVIndex( uc, uvLen );
229
-
230
- if ( d === undefined ) {
231
-
232
- this.addUV( ia, ib, ic );
233
-
234
- } else {
235
-
236
- id = this.parseUVIndex( ud, uvLen );
237
-
238
- this.addUV( ia, ib, id );
239
- this.addUV( ib, ic, id );
240
-
241
- }
242
-
243
- }
244
-
245
- if ( na !== undefined ) {
246
-
247
- // Normals are many times the same. If so, skip function call and parseInt.
248
- var nLen = this.normals.length;
249
- ia = this.parseNormalIndex( na, nLen );
250
-
251
- ib = na === nb ? ia : this.parseNormalIndex( nb, nLen );
252
- ic = na === nc ? ia : this.parseNormalIndex( nc, nLen );
253
-
254
- if ( d === undefined ) {
255
-
256
- this.addNormal( ia, ib, ic );
257
-
258
- } else {
259
-
260
- id = this.parseNormalIndex( nd, nLen );
261
-
262
- this.addNormal( ia, ib, id );
263
- this.addNormal( ib, ic, id );
264
-
265
- }
266
-
267
- }
268
-
269
- },
270
-
271
- addLineGeometry: function ( vertices, uvs ) {
272
-
273
- this.object.geometry.type = 'Line';
274
-
275
- var vLen = this.vertices.length;
276
- var uvLen = this.uvs.length;
277
-
278
- for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) {
279
-
280
- this.addVertexLine( this.parseVertexIndex( vertices[ vi ], vLen ) );
281
-
282
- }
283
-
284
- for ( var uvi = 0, l = uvs.length; uvi < l; uvi ++ ) {
285
-
286
- this.addUVLine( this.parseUVIndex( uvs[ uvi ], uvLen ) );
287
-
288
- }
289
-
290
- }
291
-
292
- };
293
-
294
- state.startObject( '', false );
295
-
296
- return state;
297
-
298
- },
299
-
300
- parse: function ( text ) {
301
-
302
- console.time( 'OBJLoader' );
303
-
304
- var state = this._createParserState();
305
-
306
- if ( text.indexOf( '\r\n' ) !== - 1 ) {
307
-
308
- // This is faster than String.split with regex that splits on both
309
- text = text.replace( '\r\n', '\n' );
310
-
311
- }
312
-
313
- var lines = text.split( '\n' );
314
- var line = '', lineFirstChar = '', lineSecondChar = '';
315
- var lineLength = 0;
316
- var result = [];
317
-
318
- // Faster to just trim left side of the line. Use if available.
319
- var trimLeft = ( typeof ''.trimLeft === 'function' );
320
-
321
- for ( var i = 0, l = lines.length; i < l; i ++ ) {
322
-
323
- line = lines[ i ];
324
-
325
- line = trimLeft ? line.trimLeft() : line.trim();
326
-
327
- lineLength = line.length;
328
-
329
- if ( lineLength === 0 ) continue;
330
-
331
- lineFirstChar = line.charAt( 0 );
332
-
333
- // @todo invoke passed in handler if any
334
- if ( lineFirstChar === '#' ) continue;
335
-
336
- if ( lineFirstChar === 'v' ) {
337
-
338
- lineSecondChar = line.charAt( 1 );
339
-
340
- if ( lineSecondChar === ' ' && ( result = this.regexp.vertex_pattern.exec( line ) ) !== null ) {
341
-
342
- // 0 1 2 3
343
- // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
344
-
345
- state.vertices.push(
346
- parseFloat( result[ 1 ] ),
347
- parseFloat( result[ 2 ] ),
348
- parseFloat( result[ 3 ] )
349
- );
350
-
351
- } else if ( lineSecondChar === 'n' && ( result = this.regexp.normal_pattern.exec( line ) ) !== null ) {
352
-
353
- // 0 1 2 3
354
- // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
355
-
356
- state.normals.push(
357
- parseFloat( result[ 1 ] ),
358
- parseFloat( result[ 2 ] ),
359
- parseFloat( result[ 3 ] )
360
- );
361
-
362
- } else if ( lineSecondChar === 't' && ( result = this.regexp.uv_pattern.exec( line ) ) !== null ) {
363
-
364
- // 0 1 2
365
- // ["vt 0.1 0.2", "0.1", "0.2"]
366
-
367
- state.uvs.push(
368
- parseFloat( result[ 1 ] ),
369
- parseFloat( result[ 2 ] )
370
- );
371
-
372
- } else {
373
-
374
- throw new Error( "Unexpected vertex/normal/uv line: '" + line + "'" );
375
-
376
- }
377
-
378
- } else if ( lineFirstChar === "f" ) {
379
-
380
- if ( ( result = this.regexp.face_vertex_uv_normal.exec( line ) ) !== null ) {
381
-
382
- // f vertex/uv/normal vertex/uv/normal vertex/uv/normal
383
- // 0 1 2 3 4 5 6 7 8 9 10 11 12
384
- // ["f 1/1/1 2/2/2 3/3/3", "1", "1", "1", "2", "2", "2", "3", "3", "3", undefined, undefined, undefined]
385
-
386
- state.addFace(
387
- result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],
388
- result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ],
389
- result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]
390
- );
391
-
392
- } else if ( ( result = this.regexp.face_vertex_uv.exec( line ) ) !== null ) {
393
-
394
- // f vertex/uv vertex/uv vertex/uv
395
- // 0 1 2 3 4 5 6 7 8
396
- // ["f 1/1 2/2 3/3", "1", "1", "2", "2", "3", "3", undefined, undefined]
397
-
398
- state.addFace(
399
- result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],
400
- result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]
401
- );
402
-
403
- } else if ( ( result = this.regexp.face_vertex_normal.exec( line ) ) !== null ) {
404
-
405
- // f vertex//normal vertex//normal vertex//normal
406
- // 0 1 2 3 4 5 6 7 8
407
- // ["f 1//1 2//2 3//3", "1", "1", "2", "2", "3", "3", undefined, undefined]
408
-
409
- state.addFace(
410
- result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],
411
- undefined, undefined, undefined, undefined,
412
- result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]
413
- );
414
-
415
- } else if ( ( result = this.regexp.face_vertex.exec( line ) ) !== null ) {
416
-
417
- // f vertex vertex vertex
418
- // 0 1 2 3 4
419
- // ["f 1 2 3", "1", "2", "3", undefined]
420
-
421
- state.addFace(
422
- result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]
423
- );
424
-
425
- } else {
426
-
427
- throw new Error( "Unexpected face line: '" + line + "'" );
428
-
429
- }
430
-
431
- } else if ( lineFirstChar === "l" ) {
432
-
433
- var lineParts = line.substring( 1 ).trim().split( " " );
434
- var lineVertices = [], lineUVs = [];
435
-
436
- if ( line.indexOf( "/" ) === - 1 ) {
437
-
438
- lineVertices = lineParts;
439
-
440
- } else {
441
-
442
- for ( var li = 0, llen = lineParts.length; li < llen; li ++ ) {
443
-
444
- var parts = lineParts[ li ].split( "/" );
445
-
446
- if ( parts[ 0 ] !== "" ) lineVertices.push( parts[ 0 ] );
447
- if ( parts[ 1 ] !== "" ) lineUVs.push( parts[ 1 ] );
448
-
449
- }
450
-
451
- }
452
- state.addLineGeometry( lineVertices, lineUVs );
453
-
454
- } else if ( ( result = this.regexp.object_pattern.exec( line ) ) !== null ) {
455
-
456
- // o object_name
457
- // or
458
- // g group_name
459
-
460
- var name = result[ 0 ].substr( 1 ).trim();
461
- state.startObject( name );
462
-
463
- } else if ( this.regexp.material_use_pattern.test( line ) ) {
464
-
465
- // material
466
-
467
- state.object.material.name = line.substring( 7 ).trim();
468
-
469
- } else if ( this.regexp.material_library_pattern.test( line ) ) {
470
-
471
- // mtl file
472
-
473
- state.materialLibraries.push( line.substring( 7 ).trim() );
474
-
475
- } else if ( ( result = this.regexp.smoothing_pattern.exec( line ) ) !== null ) {
476
-
477
- // smooth shading
478
-
479
- var value = result[ 1 ].trim().toLowerCase();
480
- state.object.material.smooth = ( value === '1' || value === 'on' );
481
-
482
- } else {
483
-
484
- // Handle null terminated files without exception
485
- if ( line === '\0' ) continue;
486
-
487
- throw new Error( "Unexpected line: '" + line + "'" );
488
-
489
- }
490
-
491
- }
492
-
493
- var container = new THREE.Group();
494
- container.materialLibraries = [].concat( state.materialLibraries );
495
-
496
- for ( var i = 0, l = state.objects.length; i < l; i ++ ) {
497
-
498
- var object = state.objects[ i ];
499
- var geometry = object.geometry;
500
- var isLine = ( geometry.type === 'Line' );
501
-
502
- // Skip o/g line declarations that did not follow with any faces
503
- if ( geometry.vertices.length === 0 ) continue;
504
-
505
- var buffergeometry = new THREE.BufferGeometry();
506
-
507
- buffergeometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( geometry.vertices ), 3 ) );
508
-
509
- if ( geometry.normals.length > 0 ) {
510
-
511
- buffergeometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( geometry.normals ), 3 ) );
512
-
513
- } else {
514
-
515
- buffergeometry.computeVertexNormals();
516
-
517
- }
518
-
519
- if ( geometry.uvs.length > 0 ) {
520
-
521
- buffergeometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geometry.uvs ), 2 ) );
522
-
523
- }
524
-
525
- var material;
526
-
527
- if ( this.materials !== null ) {
528
-
529
- material = this.materials.create( object.material.name );
530
-
531
- // mtl etc. loaders probably can't create line materials correctly, copy properties to a line material.
532
- if ( isLine && material && ! ( material instanceof THREE.LineBasicMaterial ) ) {
533
-
534
- var materialLine = new THREE.LineBasicMaterial();
535
- materialLine.copy( material );
536
- material = materialLine;
537
-
538
- }
539
-
540
- }
541
-
542
- if ( ! material ) {
543
-
544
- material = ( ! isLine ? new THREE.MeshPhongMaterial() : new THREE.LineBasicMaterial() );
545
- material.name = object.material.name;
546
-
547
- }
548
-
549
- material.shading = object.material.smooth ? THREE.SmoothShading : THREE.FlatShading;
550
-
551
- var mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, material ) : new THREE.Line( buffergeometry, material ) );
552
- mesh.name = object.name;
553
-
554
- container.add( mesh );
555
-
556
- }
557
-
558
- console.timeEnd( 'OBJLoader' );
559
-
560
- return container;
561
-
562
- }
563
-
564
- };
1
+ /**
2
+ * @author mrdoob / http://mrdoob.com/
3
+ */
4
+
5
+ THREE.OBJLoader = function ( manager ) {
6
+
7
+ this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
8
+
9
+ this.materials = null;
10
+
11
+ this.regexp = {
12
+ // v float float float
13
+ vertex_pattern : /^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
14
+ // vn float float float
15
+ normal_pattern : /^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
16
+ // vt float float
17
+ uv_pattern : /^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,
18
+ // f vertex vertex vertex
19
+ face_vertex : /^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,
20
+ // f vertex/uv vertex/uv vertex/uv
21
+ face_vertex_uv : /^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,
22
+ // f vertex/uv/normal vertex/uv/normal vertex/uv/normal
23
+ face_vertex_uv_normal : /^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,
24
+ // f vertex//normal vertex//normal vertex//normal
25
+ face_vertex_normal : /^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,
26
+ // o object_name | g group_name
27
+ object_pattern : /^[og]\s*(.+)?/,
28
+ // s boolean
29
+ smoothing_pattern : /^s\s+(\d+|on|off)/,
30
+ // mtllib file_reference
31
+ material_library_pattern : /^mtllib /,
32
+ // usemtl material_name
33
+ material_use_pattern : /^usemtl /
34
+ };
35
+
36
+ };
37
+
38
+ THREE.OBJLoader.prototype = {
39
+
40
+ constructor: THREE.OBJLoader,
41
+
42
+ load: function ( url, onLoad, onProgress, onError ) {
43
+
44
+ var scope = this;
45
+
46
+ var loader = new THREE.XHRLoader( scope.manager );
47
+ loader.setPath( this.path );
48
+ loader.load( url, function ( text ) {
49
+
50
+ onLoad( scope.parse( text ) );
51
+
52
+ }, onProgress, onError );
53
+
54
+ },
55
+
56
+ setPath: function ( value ) {
57
+
58
+ this.path = value;
59
+
60
+ },
61
+
62
+ setMaterials: function ( materials ) {
63
+
64
+ this.materials = materials;
65
+
66
+ },
67
+
68
+ _createParserState : function () {
69
+
70
+ var state = {
71
+ objects : [],
72
+ object : {},
73
+
74
+ vertices : [],
75
+ normals : [],
76
+ uvs : [],
77
+
78
+ materialLibraries : [],
79
+
80
+ startObject: function ( name, fromDeclaration ) {
81
+
82
+ // If the current object (initial from reset) is not from a g/o declaration in the parsed
83
+ // file. We need to use it for the first parsed g/o to keep things in sync.
84
+ if ( this.object && this.object.fromDeclaration === false ) {
85
+
86
+ this.object.name = name;
87
+ this.object.fromDeclaration = ( fromDeclaration !== false );
88
+ return;
89
+
90
+ }
91
+
92
+ this.object = {
93
+ name : name || '',
94
+ geometry : {
95
+ vertices : [],
96
+ normals : [],
97
+ uvs : []
98
+ },
99
+ material : {
100
+ name : '',
101
+ smooth : true
102
+ },
103
+ fromDeclaration : ( fromDeclaration !== false )
104
+ };
105
+
106
+ this.objects.push( this.object );
107
+
108
+ },
109
+
110
+ parseVertexIndex: function ( value, len ) {
111
+
112
+ var index = parseInt( value, 10 );
113
+ return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
114
+
115
+ },
116
+
117
+ parseNormalIndex: function ( value, len ) {
118
+
119
+ var index = parseInt( value, 10 );
120
+ return ( index >= 0 ? index - 1 : index + len / 3 ) * 3;
121
+
122
+ },
123
+
124
+ parseUVIndex: function ( value, len ) {
125
+
126
+ var index = parseInt( value, 10 );
127
+ return ( index >= 0 ? index - 1 : index + len / 2 ) * 2;
128
+
129
+ },
130
+
131
+ addVertex: function ( a, b, c ) {
132
+
133
+ var src = this.vertices;
134
+ var dst = this.object.geometry.vertices;
135
+
136
+ dst.push( src[ a + 0 ] );
137
+ dst.push( src[ a + 1 ] );
138
+ dst.push( src[ a + 2 ] );
139
+ dst.push( src[ b + 0 ] );
140
+ dst.push( src[ b + 1 ] );
141
+ dst.push( src[ b + 2 ] );
142
+ dst.push( src[ c + 0 ] );
143
+ dst.push( src[ c + 1 ] );
144
+ dst.push( src[ c + 2 ] );
145
+
146
+ },
147
+
148
+ addVertexLine: function ( a ) {
149
+
150
+ var src = this.vertices;
151
+ var dst = this.object.geometry.vertices;
152
+
153
+ dst.push( src[ a + 0 ] );
154
+ dst.push( src[ a + 1 ] );
155
+ dst.push( src[ a + 2 ] );
156
+
157
+ },
158
+
159
+ addNormal : function ( a, b, c ) {
160
+
161
+ var src = this.normals;
162
+ var dst = this.object.geometry.normals;
163
+
164
+ dst.push( src[ a + 0 ] );
165
+ dst.push( src[ a + 1 ] );
166
+ dst.push( src[ a + 2 ] );
167
+ dst.push( src[ b + 0 ] );
168
+ dst.push( src[ b + 1 ] );
169
+ dst.push( src[ b + 2 ] );
170
+ dst.push( src[ c + 0 ] );
171
+ dst.push( src[ c + 1 ] );
172
+ dst.push( src[ c + 2 ] );
173
+
174
+ },
175
+
176
+ addUV: function ( a, b, c ) {
177
+
178
+ var src = this.uvs;
179
+ var dst = this.object.geometry.uvs;
180
+
181
+ dst.push( src[ a + 0 ] );
182
+ dst.push( src[ a + 1 ] );
183
+ dst.push( src[ b + 0 ] );
184
+ dst.push( src[ b + 1 ] );
185
+ dst.push( src[ c + 0 ] );
186
+ dst.push( src[ c + 1 ] );
187
+
188
+ },
189
+
190
+ addUVLine: function ( a ) {
191
+
192
+ var src = this.uvs;
193
+ var dst = this.object.geometry.uvs;
194
+
195
+ dst.push( src[ a + 0 ] );
196
+ dst.push( src[ a + 1 ] );
197
+
198
+ },
199
+
200
+ addFace: function ( a, b, c, d, ua, ub, uc, ud, na, nb, nc, nd ) {
201
+
202
+ var vLen = this.vertices.length;
203
+
204
+ var ia = this.parseVertexIndex( a, vLen );
205
+ var ib = this.parseVertexIndex( b, vLen );
206
+ var ic = this.parseVertexIndex( c, vLen );
207
+ var id;
208
+
209
+ if ( d === undefined ) {
210
+
211
+ this.addVertex( ia, ib, ic );
212
+
213
+ } else {
214
+
215
+ id = this.parseVertexIndex( d, vLen );
216
+
217
+ this.addVertex( ia, ib, id );
218
+ this.addVertex( ib, ic, id );
219
+
220
+ }
221
+
222
+ if ( ua !== undefined ) {
223
+
224
+ var uvLen = this.uvs.length;
225
+
226
+ ia = this.parseUVIndex( ua, uvLen );
227
+ ib = this.parseUVIndex( ub, uvLen );
228
+ ic = this.parseUVIndex( uc, uvLen );
229
+
230
+ if ( d === undefined ) {
231
+
232
+ this.addUV( ia, ib, ic );
233
+
234
+ } else {
235
+
236
+ id = this.parseUVIndex( ud, uvLen );
237
+
238
+ this.addUV( ia, ib, id );
239
+ this.addUV( ib, ic, id );
240
+
241
+ }
242
+
243
+ }
244
+
245
+ if ( na !== undefined ) {
246
+
247
+ // Normals are many times the same. If so, skip function call and parseInt.
248
+ var nLen = this.normals.length;
249
+ ia = this.parseNormalIndex( na, nLen );
250
+
251
+ ib = na === nb ? ia : this.parseNormalIndex( nb, nLen );
252
+ ic = na === nc ? ia : this.parseNormalIndex( nc, nLen );
253
+
254
+ if ( d === undefined ) {
255
+
256
+ this.addNormal( ia, ib, ic );
257
+
258
+ } else {
259
+
260
+ id = this.parseNormalIndex( nd, nLen );
261
+
262
+ this.addNormal( ia, ib, id );
263
+ this.addNormal( ib, ic, id );
264
+
265
+ }
266
+
267
+ }
268
+
269
+ },
270
+
271
+ addLineGeometry: function ( vertices, uvs ) {
272
+
273
+ this.object.geometry.type = 'Line';
274
+
275
+ var vLen = this.vertices.length;
276
+ var uvLen = this.uvs.length;
277
+
278
+ for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) {
279
+
280
+ this.addVertexLine( this.parseVertexIndex( vertices[ vi ], vLen ) );
281
+
282
+ }
283
+
284
+ for ( var uvi = 0, l = uvs.length; uvi < l; uvi ++ ) {
285
+
286
+ this.addUVLine( this.parseUVIndex( uvs[ uvi ], uvLen ) );
287
+
288
+ }
289
+
290
+ }
291
+
292
+ };
293
+
294
+ state.startObject( '', false );
295
+
296
+ return state;
297
+
298
+ },
299
+
300
+ parse: function ( text ) {
301
+
302
+ console.time( 'OBJLoader' );
303
+
304
+ var state = this._createParserState();
305
+
306
+ if ( text.indexOf( '\r\n' ) !== - 1 ) {
307
+
308
+ // This is faster than String.split with regex that splits on both
309
+ text = text.replace( '\r\n', '\n' );
310
+
311
+ }
312
+
313
+ var lines = text.split( '\n' );
314
+ var line = '', lineFirstChar = '', lineSecondChar = '';
315
+ var lineLength = 0;
316
+ var result = [];
317
+
318
+ // Faster to just trim left side of the line. Use if available.
319
+ var trimLeft = ( typeof ''.trimLeft === 'function' );
320
+
321
+ for ( var i = 0, l = lines.length; i < l; i ++ ) {
322
+
323
+ line = lines[ i ];
324
+
325
+ line = trimLeft ? line.trimLeft() : line.trim();
326
+
327
+ lineLength = line.length;
328
+
329
+ if ( lineLength === 0 ) continue;
330
+
331
+ lineFirstChar = line.charAt( 0 );
332
+
333
+ // @todo invoke passed in handler if any
334
+ if ( lineFirstChar === '#' ) continue;
335
+
336
+ if ( lineFirstChar === 'v' ) {
337
+
338
+ lineSecondChar = line.charAt( 1 );
339
+
340
+ if ( lineSecondChar === ' ' && ( result = this.regexp.vertex_pattern.exec( line ) ) !== null ) {
341
+
342
+ // 0 1 2 3
343
+ // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
344
+
345
+ state.vertices.push(
346
+ parseFloat( result[ 1 ] ),
347
+ parseFloat( result[ 2 ] ),
348
+ parseFloat( result[ 3 ] )
349
+ );
350
+
351
+ } else if ( lineSecondChar === 'n' && ( result = this.regexp.normal_pattern.exec( line ) ) !== null ) {
352
+
353
+ // 0 1 2 3
354
+ // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
355
+
356
+ state.normals.push(
357
+ parseFloat( result[ 1 ] ),
358
+ parseFloat( result[ 2 ] ),
359
+ parseFloat( result[ 3 ] )
360
+ );
361
+
362
+ } else if ( lineSecondChar === 't' && ( result = this.regexp.uv_pattern.exec( line ) ) !== null ) {
363
+
364
+ // 0 1 2
365
+ // ["vt 0.1 0.2", "0.1", "0.2"]
366
+
367
+ state.uvs.push(
368
+ parseFloat( result[ 1 ] ),
369
+ parseFloat( result[ 2 ] )
370
+ );
371
+
372
+ } else {
373
+
374
+ throw new Error( "Unexpected vertex/normal/uv line: '" + line + "'" );
375
+
376
+ }
377
+
378
+ } else if ( lineFirstChar === "f" ) {
379
+
380
+ if ( ( result = this.regexp.face_vertex_uv_normal.exec( line ) ) !== null ) {
381
+
382
+ // f vertex/uv/normal vertex/uv/normal vertex/uv/normal
383
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12
384
+ // ["f 1/1/1 2/2/2 3/3/3", "1", "1", "1", "2", "2", "2", "3", "3", "3", undefined, undefined, undefined]
385
+
386
+ state.addFace(
387
+ result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],
388
+ result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ],
389
+ result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]
390
+ );
391
+
392
+ } else if ( ( result = this.regexp.face_vertex_uv.exec( line ) ) !== null ) {
393
+
394
+ // f vertex/uv vertex/uv vertex/uv
395
+ // 0 1 2 3 4 5 6 7 8
396
+ // ["f 1/1 2/2 3/3", "1", "1", "2", "2", "3", "3", undefined, undefined]
397
+
398
+ state.addFace(
399
+ result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],
400
+ result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]
401
+ );
402
+
403
+ } else if ( ( result = this.regexp.face_vertex_normal.exec( line ) ) !== null ) {
404
+
405
+ // f vertex//normal vertex//normal vertex//normal
406
+ // 0 1 2 3 4 5 6 7 8
407
+ // ["f 1//1 2//2 3//3", "1", "1", "2", "2", "3", "3", undefined, undefined]
408
+
409
+ state.addFace(
410
+ result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],
411
+ undefined, undefined, undefined, undefined,
412
+ result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]
413
+ );
414
+
415
+ } else if ( ( result = this.regexp.face_vertex.exec( line ) ) !== null ) {
416
+
417
+ // f vertex vertex vertex
418
+ // 0 1 2 3 4
419
+ // ["f 1 2 3", "1", "2", "3", undefined]
420
+
421
+ state.addFace(
422
+ result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]
423
+ );
424
+
425
+ } else {
426
+
427
+ throw new Error( "Unexpected face line: '" + line + "'" );
428
+
429
+ }
430
+
431
+ } else if ( lineFirstChar === "l" ) {
432
+
433
+ var lineParts = line.substring( 1 ).trim().split( " " );
434
+ var lineVertices = [], lineUVs = [];
435
+
436
+ if ( line.indexOf( "/" ) === - 1 ) {
437
+
438
+ lineVertices = lineParts;
439
+
440
+ } else {
441
+
442
+ for ( var li = 0, llen = lineParts.length; li < llen; li ++ ) {
443
+
444
+ var parts = lineParts[ li ].split( "/" );
445
+
446
+ if ( parts[ 0 ] !== "" ) lineVertices.push( parts[ 0 ] );
447
+ if ( parts[ 1 ] !== "" ) lineUVs.push( parts[ 1 ] );
448
+
449
+ }
450
+
451
+ }
452
+ state.addLineGeometry( lineVertices, lineUVs );
453
+
454
+ } else if ( ( result = this.regexp.object_pattern.exec( line ) ) !== null ) {
455
+
456
+ // o object_name
457
+ // or
458
+ // g group_name
459
+
460
+ var name = result[ 0 ].substr( 1 ).trim();
461
+ state.startObject( name );
462
+
463
+ } else if ( this.regexp.material_use_pattern.test( line ) ) {
464
+
465
+ // material
466
+
467
+ state.object.material.name = line.substring( 7 ).trim();
468
+
469
+ } else if ( this.regexp.material_library_pattern.test( line ) ) {
470
+
471
+ // mtl file
472
+
473
+ state.materialLibraries.push( line.substring( 7 ).trim() );
474
+
475
+ } else if ( ( result = this.regexp.smoothing_pattern.exec( line ) ) !== null ) {
476
+
477
+ // smooth shading
478
+
479
+ var value = result[ 1 ].trim().toLowerCase();
480
+ state.object.material.smooth = ( value === '1' || value === 'on' );
481
+
482
+ } else {
483
+
484
+ // Handle null terminated files without exception
485
+ if ( line === '\0' ) continue;
486
+
487
+ throw new Error( "Unexpected line: '" + line + "'" );
488
+
489
+ }
490
+
491
+ }
492
+
493
+ var container = new THREE.Group();
494
+ container.materialLibraries = [].concat( state.materialLibraries );
495
+
496
+ for ( var i = 0, l = state.objects.length; i < l; i ++ ) {
497
+
498
+ var object = state.objects[ i ];
499
+ var geometry = object.geometry;
500
+ var isLine = ( geometry.type === 'Line' );
501
+
502
+ // Skip o/g line declarations that did not follow with any faces
503
+ if ( geometry.vertices.length === 0 ) continue;
504
+
505
+ var buffergeometry = new THREE.BufferGeometry();
506
+
507
+ buffergeometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( geometry.vertices ), 3 ) );
508
+
509
+ if ( geometry.normals.length > 0 ) {
510
+
511
+ buffergeometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( geometry.normals ), 3 ) );
512
+
513
+ } else {
514
+
515
+ buffergeometry.computeVertexNormals();
516
+
517
+ }
518
+
519
+ if ( geometry.uvs.length > 0 ) {
520
+
521
+ buffergeometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geometry.uvs ), 2 ) );
522
+
523
+ }
524
+
525
+ var material;
526
+
527
+ if ( this.materials !== null ) {
528
+
529
+ material = this.materials.create( object.material.name );
530
+
531
+ // mtl etc. loaders probably can't create line materials correctly, copy properties to a line material.
532
+ if ( isLine && material && ! ( material instanceof THREE.LineBasicMaterial ) ) {
533
+
534
+ var materialLine = new THREE.LineBasicMaterial();
535
+ materialLine.copy( material );
536
+ material = materialLine;
537
+
538
+ }
539
+
540
+ }
541
+
542
+ if ( ! material ) {
543
+
544
+ material = ( ! isLine ? new THREE.MeshPhongMaterial() : new THREE.LineBasicMaterial() );
545
+ material.name = object.material.name;
546
+
547
+ }
548
+
549
+ material.shading = object.material.smooth ? THREE.SmoothShading : THREE.FlatShading;
550
+
551
+ var mesh = ( ! isLine ? new THREE.Mesh( buffergeometry, material ) : new THREE.Line( buffergeometry, material ) );
552
+ mesh.name = object.name;
553
+
554
+ container.add( mesh );
555
+
556
+ }
557
+
558
+ console.timeEnd( 'OBJLoader' );
559
+
560
+ return container;
561
+
562
+ }
563
+
564
+ };