uil 4.0.0 → 4.0.1

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 (43) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -5
  3. package/examples/js/BufferGeometryUtils.js +0 -921
  4. package/examples/js/SimplexNoise.js +0 -324
  5. package/examples/js/controls/OrbitControls.js +0 -1215
  6. package/examples/js/controls/OrbitControls_.js +0 -1042
  7. package/examples/js/libs/sea3d.min.js +0 -373
  8. package/examples/js/libs/three.min.js +0 -6
  9. package/examples/js/math.js +0 -447
  10. package/examples/js/objects/Landscape.js +0 -778
  11. package/examples/js/objects/Lensflare.js +0 -372
  12. package/examples/js/objects/SuperSky.js +0 -297
  13. package/examples/js/objects/Water.js +0 -329
  14. package/src/Uil.js +0 -6
  15. package/src/Uil_dev.js +0 -15
  16. package/src/core/Gui.js +0 -807
  17. package/src/core/Proto.js +0 -679
  18. package/src/core/Roots.js +0 -864
  19. package/src/core/Tools.js +0 -830
  20. package/src/core/V2.js +0 -131
  21. package/src/core/add.js +0 -85
  22. package/src/polyfills.js +0 -85
  23. package/src/proto/Bool.js +0 -147
  24. package/src/proto/Button.js +0 -357
  25. package/src/proto/Circular.js +0 -230
  26. package/src/proto/Color.js +0 -411
  27. package/src/proto/Empty.js +0 -15
  28. package/src/proto/Fps.js +0 -327
  29. package/src/proto/Graph.js +0 -310
  30. package/src/proto/Grid.js +0 -297
  31. package/src/proto/Group.js +0 -430
  32. package/src/proto/Item.js +0 -120
  33. package/src/proto/Joystick.js +0 -241
  34. package/src/proto/Knob.js +0 -262
  35. package/src/proto/List.js +0 -789
  36. package/src/proto/Numeric.js +0 -417
  37. package/src/proto/Pad2D.js +0 -268
  38. package/src/proto/Rubric.js +0 -0
  39. package/src/proto/Select.js +0 -178
  40. package/src/proto/Selector.js +0 -13
  41. package/src/proto/Slide.js +0 -267
  42. package/src/proto/TextInput.js +0 -181
  43. package/src/proto/Title.js +0 -61
@@ -1,921 +0,0 @@
1
- THREE.BufferGeometryUtils = {
2
-
3
- computeTangents: function ( geometry ) {
4
-
5
- geometry.computeTangents();
6
- console.warn( 'THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.' );
7
-
8
- },
9
-
10
- /**
11
- * @param {Array<THREE.BufferGeometry>} geometries
12
- * @param {Boolean} useGroups
13
- * @return {THREE.BufferGeometry}
14
- */
15
- mergeBufferGeometries: function ( geometries, useGroups ) {
16
-
17
- var isIndexed = geometries[ 0 ].index !== null;
18
-
19
- var attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) );
20
- var morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) );
21
-
22
- var attributes = {};
23
- var morphAttributes = {};
24
-
25
- var morphTargetsRelative = geometries[ 0 ].morphTargetsRelative;
26
-
27
- var mergedGeometry = new THREE.BufferGeometry();
28
-
29
- var offset = 0;
30
-
31
- for ( var i = 0; i < geometries.length; ++ i ) {
32
-
33
- var geometry = geometries[ i ];
34
- var attributesCount = 0;
35
-
36
- // ensure that all geometries are indexed, or none
37
-
38
- if ( isIndexed !== ( geometry.index !== null ) ) {
39
-
40
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' );
41
- return null;
42
-
43
- }
44
-
45
- // gather attributes, exit early if they're different
46
-
47
- for ( var name in geometry.attributes ) {
48
-
49
- if ( ! attributesUsed.has( name ) ) {
50
-
51
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' );
52
- return null;
53
-
54
- }
55
-
56
- if ( attributes[ name ] === undefined ) attributes[ name ] = [];
57
-
58
- attributes[ name ].push( geometry.attributes[ name ] );
59
-
60
- attributesCount ++;
61
-
62
- }
63
-
64
- // ensure geometries have the same number of attributes
65
-
66
- if ( attributesCount !== attributesUsed.size ) {
67
-
68
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' );
69
- return null;
70
-
71
- }
72
-
73
- // gather morph attributes, exit early if they're different
74
-
75
- if ( morphTargetsRelative !== geometry.morphTargetsRelative ) {
76
-
77
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' );
78
- return null;
79
-
80
- }
81
-
82
- for ( var name in geometry.morphAttributes ) {
83
-
84
- if ( ! morphAttributesUsed.has( name ) ) {
85
-
86
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.' );
87
- return null;
88
-
89
- }
90
-
91
- if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = [];
92
-
93
- morphAttributes[ name ].push( geometry.morphAttributes[ name ] );
94
-
95
- }
96
-
97
- // gather .userData
98
-
99
- mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || [];
100
- mergedGeometry.userData.mergedUserData.push( geometry.userData );
101
-
102
- if ( useGroups ) {
103
-
104
- var count;
105
-
106
- if ( isIndexed ) {
107
-
108
- count = geometry.index.count;
109
-
110
- } else if ( geometry.attributes.position !== undefined ) {
111
-
112
- count = geometry.attributes.position.count;
113
-
114
- } else {
115
-
116
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' );
117
- return null;
118
-
119
- }
120
-
121
- mergedGeometry.addGroup( offset, count, i );
122
-
123
- offset += count;
124
-
125
- }
126
-
127
- }
128
-
129
- // merge indices
130
-
131
- if ( isIndexed ) {
132
-
133
- var indexOffset = 0;
134
- var mergedIndex = [];
135
-
136
- for ( var i = 0; i < geometries.length; ++ i ) {
137
-
138
- var index = geometries[ i ].index;
139
-
140
- for ( var j = 0; j < index.count; ++ j ) {
141
-
142
- mergedIndex.push( index.getX( j ) + indexOffset );
143
-
144
- }
145
-
146
- indexOffset += geometries[ i ].attributes.position.count;
147
-
148
- }
149
-
150
- mergedGeometry.setIndex( mergedIndex );
151
-
152
- }
153
-
154
- // merge attributes
155
-
156
- for ( var name in attributes ) {
157
-
158
- var mergedAttribute = this.mergeBufferAttributes( attributes[ name ] );
159
-
160
- if ( ! mergedAttribute ) {
161
-
162
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' );
163
- return null;
164
-
165
- }
166
-
167
- mergedGeometry.setAttribute( name, mergedAttribute );
168
-
169
- }
170
-
171
- // merge morph attributes
172
-
173
- for ( var name in morphAttributes ) {
174
-
175
- var numMorphTargets = morphAttributes[ name ][ 0 ].length;
176
-
177
- if ( numMorphTargets === 0 ) break;
178
-
179
- mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
180
- mergedGeometry.morphAttributes[ name ] = [];
181
-
182
- for ( var i = 0; i < numMorphTargets; ++ i ) {
183
-
184
- var morphAttributesToMerge = [];
185
-
186
- for ( var j = 0; j < morphAttributes[ name ].length; ++ j ) {
187
-
188
- morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] );
189
-
190
- }
191
-
192
- var mergedMorphAttribute = this.mergeBufferAttributes( morphAttributesToMerge );
193
-
194
- if ( ! mergedMorphAttribute ) {
195
-
196
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' );
197
- return null;
198
-
199
- }
200
-
201
- mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute );
202
-
203
- }
204
-
205
- }
206
-
207
- return mergedGeometry;
208
-
209
- },
210
-
211
- /**
212
- * @param {Array<THREE.BufferAttribute>} attributes
213
- * @return {THREE.BufferAttribute}
214
- */
215
- mergeBufferAttributes: function ( attributes ) {
216
-
217
- var TypedArray;
218
- var itemSize;
219
- var normalized;
220
- var arrayLength = 0;
221
-
222
- for ( var i = 0; i < attributes.length; ++ i ) {
223
-
224
- var attribute = attributes[ i ];
225
-
226
- if ( attribute.isInterleavedBufferAttribute ) {
227
-
228
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' );
229
- return null;
230
-
231
- }
232
-
233
- if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
234
- if ( TypedArray !== attribute.array.constructor ) {
235
-
236
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' );
237
- return null;
238
-
239
- }
240
-
241
- if ( itemSize === undefined ) itemSize = attribute.itemSize;
242
- if ( itemSize !== attribute.itemSize ) {
243
-
244
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' );
245
- return null;
246
-
247
- }
248
-
249
- if ( normalized === undefined ) normalized = attribute.normalized;
250
- if ( normalized !== attribute.normalized ) {
251
-
252
- console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' );
253
- return null;
254
-
255
- }
256
-
257
- arrayLength += attribute.array.length;
258
-
259
- }
260
-
261
- var array = new TypedArray( arrayLength );
262
- var offset = 0;
263
-
264
- for ( var i = 0; i < attributes.length; ++ i ) {
265
-
266
- array.set( attributes[ i ].array, offset );
267
-
268
- offset += attributes[ i ].array.length;
269
-
270
- }
271
-
272
- return new THREE.BufferAttribute( array, itemSize, normalized );
273
-
274
- },
275
-
276
- /**
277
- * @param {Array<THREE.BufferAttribute>} attributes
278
- * @return {Array<THREE.InterleavedBufferAttribute>}
279
- */
280
- interleaveAttributes: function ( attributes ) {
281
-
282
- // Interleaves the provided attributes into an InterleavedBuffer and returns
283
- // a set of InterleavedBufferAttributes for each attribute
284
- var TypedArray;
285
- var arrayLength = 0;
286
- var stride = 0;
287
-
288
- // calculate the the length and type of the interleavedBuffer
289
- for ( var i = 0, l = attributes.length; i < l; ++ i ) {
290
-
291
- var attribute = attributes[ i ];
292
-
293
- if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
294
- if ( TypedArray !== attribute.array.constructor ) {
295
-
296
- console.error( 'AttributeBuffers of different types cannot be interleaved' );
297
- return null;
298
-
299
- }
300
-
301
- arrayLength += attribute.array.length;
302
- stride += attribute.itemSize;
303
-
304
- }
305
-
306
- // Create the set of buffer attributes
307
- var interleavedBuffer = new THREE.InterleavedBuffer( new TypedArray( arrayLength ), stride );
308
- var offset = 0;
309
- var res = [];
310
- var getters = [ 'getX', 'getY', 'getZ', 'getW' ];
311
- var setters = [ 'setX', 'setY', 'setZ', 'setW' ];
312
-
313
- for ( var j = 0, l = attributes.length; j < l; j ++ ) {
314
-
315
- var attribute = attributes[ j ];
316
- var itemSize = attribute.itemSize;
317
- var count = attribute.count;
318
- var iba = new THREE.InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, attribute.normalized );
319
- res.push( iba );
320
-
321
- offset += itemSize;
322
-
323
- // Move the data for each attribute into the new interleavedBuffer
324
- // at the appropriate offset
325
- for ( var c = 0; c < count; c ++ ) {
326
-
327
- for ( var k = 0; k < itemSize; k ++ ) {
328
-
329
- iba[ setters[ k ] ]( c, attribute[ getters[ k ] ]( c ) );
330
-
331
- }
332
-
333
- }
334
-
335
- }
336
-
337
- return res;
338
-
339
- },
340
-
341
- /**
342
- * @param {Array<THREE.BufferGeometry>} geometry
343
- * @return {number}
344
- */
345
- estimateBytesUsed: function ( geometry ) {
346
-
347
- // Return the estimated memory used by this geometry in bytes
348
- // Calculate using itemSize, count, and BYTES_PER_ELEMENT to account
349
- // for InterleavedBufferAttributes.
350
- var mem = 0;
351
- for ( var name in geometry.attributes ) {
352
-
353
- var attr = geometry.getAttribute( name );
354
- mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT;
355
-
356
- }
357
-
358
- var indices = geometry.getIndex();
359
- mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;
360
- return mem;
361
-
362
- },
363
-
364
- /**
365
- * @param {THREE.BufferGeometry} geometry
366
- * @param {number} tolerance
367
- * @return {THREE.BufferGeometry>}
368
- */
369
- mergeVertices: function ( geometry, tolerance = 1e-4 ) {
370
-
371
- tolerance = Math.max( tolerance, Number.EPSILON );
372
-
373
- // Generate an index buffer if the geometry doesn't have one, or optimize it
374
- // if it's already available.
375
- var hashToIndex = {};
376
- var indices = geometry.getIndex();
377
- var positions = geometry.getAttribute( 'position' );
378
- var vertexCount = indices ? indices.count : positions.count;
379
-
380
- // next value for triangle indices
381
- var nextIndex = 0;
382
-
383
- // attributes and new attribute arrays
384
- var attributeNames = Object.keys( geometry.attributes );
385
- var attrArrays = {};
386
- var morphAttrsArrays = {};
387
- var newIndices = [];
388
- var getters = [ 'getX', 'getY', 'getZ', 'getW' ];
389
-
390
- // initialize the arrays
391
- for ( var i = 0, l = attributeNames.length; i < l; i ++ ) {
392
-
393
- var name = attributeNames[ i ];
394
-
395
- attrArrays[ name ] = [];
396
-
397
- var morphAttr = geometry.morphAttributes[ name ];
398
- if ( morphAttr ) {
399
-
400
- morphAttrsArrays[ name ] = new Array( morphAttr.length ).fill().map( () => [] );
401
-
402
- }
403
-
404
- }
405
-
406
- // convert the error tolerance to an amount of decimal places to truncate to
407
- var decimalShift = Math.log10( 1 / tolerance );
408
- var shiftMultiplier = Math.pow( 10, decimalShift );
409
- for ( var i = 0; i < vertexCount; i ++ ) {
410
-
411
- var index = indices ? indices.getX( i ) : i;
412
-
413
- // Generate a hash for the vertex attributes at the current index 'i'
414
- var hash = '';
415
- for ( var j = 0, l = attributeNames.length; j < l; j ++ ) {
416
-
417
- var name = attributeNames[ j ];
418
- var attribute = geometry.getAttribute( name );
419
- var itemSize = attribute.itemSize;
420
-
421
- for ( var k = 0; k < itemSize; k ++ ) {
422
-
423
- // double tilde truncates the decimal value
424
- hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier ) },`;
425
-
426
- }
427
-
428
- }
429
-
430
- // Add another reference to the vertex if it's already
431
- // used by another index
432
- if ( hash in hashToIndex ) {
433
-
434
- newIndices.push( hashToIndex[ hash ] );
435
-
436
- } else {
437
-
438
- // copy data to the new index in the attribute arrays
439
- for ( var j = 0, l = attributeNames.length; j < l; j ++ ) {
440
-
441
- var name = attributeNames[ j ];
442
- var attribute = geometry.getAttribute( name );
443
- var morphAttr = geometry.morphAttributes[ name ];
444
- var itemSize = attribute.itemSize;
445
- var newarray = attrArrays[ name ];
446
- var newMorphArrays = morphAttrsArrays[ name ];
447
-
448
- for ( var k = 0; k < itemSize; k ++ ) {
449
-
450
- var getterFunc = getters[ k ];
451
- newarray.push( attribute[ getterFunc ]( index ) );
452
-
453
- if ( morphAttr ) {
454
-
455
- for ( var m = 0, ml = morphAttr.length; m < ml; m ++ ) {
456
-
457
- newMorphArrays[ m ].push( morphAttr[ m ][ getterFunc ]( index ) );
458
-
459
- }
460
-
461
- }
462
-
463
- }
464
-
465
- }
466
-
467
- hashToIndex[ hash ] = nextIndex;
468
- newIndices.push( nextIndex );
469
- nextIndex ++;
470
-
471
- }
472
-
473
- }
474
-
475
- // Generate typed arrays from new attribute arrays and update
476
- // the attributeBuffers
477
- const result = geometry.clone();
478
- for ( var i = 0, l = attributeNames.length; i < l; i ++ ) {
479
-
480
- var name = attributeNames[ i ];
481
- var oldAttribute = geometry.getAttribute( name );
482
-
483
- var buffer = new oldAttribute.array.constructor( attrArrays[ name ] );
484
- var attribute = new THREE.BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized );
485
-
486
- result.setAttribute( name, attribute );
487
-
488
- // Update the attribute arrays
489
- if ( name in morphAttrsArrays ) {
490
-
491
- for ( var j = 0; j < morphAttrsArrays[ name ].length; j ++ ) {
492
-
493
- var oldMorphAttribute = geometry.morphAttributes[ name ][ j ];
494
-
495
- var buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] );
496
- var morphAttribute = new THREE.BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized );
497
- result.morphAttributes[ name ][ j ] = morphAttribute;
498
-
499
- }
500
-
501
- }
502
-
503
- }
504
-
505
- // indices
506
-
507
- result.setIndex( newIndices );
508
-
509
- return result;
510
-
511
- },
512
-
513
- /**
514
- * @param {THREE.BufferGeometry} geometry
515
- * @param {number} drawMode
516
- * @return {THREE.BufferGeometry>}
517
- */
518
- toTrianglesDrawMode: function ( geometry, drawMode ) {
519
-
520
- if ( drawMode === THREE.TrianglesDrawMode ) {
521
-
522
- console.warn( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.' );
523
- return geometry;
524
-
525
- }
526
-
527
- if ( drawMode === THREE.TriangleFanDrawMode || drawMode === THREE.TriangleStripDrawMode ) {
528
-
529
- var index = geometry.getIndex();
530
-
531
- // generate index if not present
532
-
533
- if ( index === null ) {
534
-
535
- var indices = [];
536
-
537
- var position = geometry.getAttribute( 'position' );
538
-
539
- if ( position !== undefined ) {
540
-
541
- for ( var i = 0; i < position.count; i ++ ) {
542
-
543
- indices.push( i );
544
-
545
- }
546
-
547
- geometry.setIndex( indices );
548
- index = geometry.getIndex();
549
-
550
- } else {
551
-
552
- console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
553
- return geometry;
554
-
555
- }
556
-
557
- }
558
-
559
- //
560
-
561
- var numberOfTriangles = index.count - 2;
562
- var newIndices = [];
563
-
564
- if ( drawMode === THREE.TriangleFanDrawMode ) {
565
-
566
- // gl.TRIANGLE_FAN
567
-
568
- for ( var i = 1; i <= numberOfTriangles; i ++ ) {
569
-
570
- newIndices.push( index.getX( 0 ) );
571
- newIndices.push( index.getX( i ) );
572
- newIndices.push( index.getX( i + 1 ) );
573
-
574
- }
575
-
576
- } else {
577
-
578
- // gl.TRIANGLE_STRIP
579
-
580
- for ( var i = 0; i < numberOfTriangles; i ++ ) {
581
-
582
- if ( i % 2 === 0 ) {
583
-
584
- newIndices.push( index.getX( i ) );
585
- newIndices.push( index.getX( i + 1 ) );
586
- newIndices.push( index.getX( i + 2 ) );
587
-
588
- } else {
589
-
590
- newIndices.push( index.getX( i + 2 ) );
591
- newIndices.push( index.getX( i + 1 ) );
592
- newIndices.push( index.getX( i ) );
593
-
594
- }
595
-
596
- }
597
-
598
- }
599
-
600
- if ( ( newIndices.length / 3 ) !== numberOfTriangles ) {
601
-
602
- console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
603
-
604
- }
605
-
606
- // build final geometry
607
-
608
- var newGeometry = geometry.clone();
609
- newGeometry.setIndex( newIndices );
610
- newGeometry.clearGroups();
611
-
612
- return newGeometry;
613
-
614
- } else {
615
-
616
- console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode );
617
- return geometry;
618
-
619
- }
620
-
621
- },
622
-
623
- /**
624
- * Calculates the morphed attributes of a morphed/skinned BufferGeometry.
625
- * Helpful for Raytracing or Decals.
626
- * @param {Mesh | Line | Points} object An instance of Mesh, Line or Points.
627
- * @return {Object} An Object with original position/normal attributes and morphed ones.
628
- */
629
- computeMorphedAttributes: function ( object ) {
630
-
631
- if ( object.geometry.isBufferGeometry !== true ) {
632
-
633
- console.error( 'THREE.BufferGeometryUtils: Geometry is not of type THREE.BufferGeometry.' );
634
- return null;
635
-
636
- }
637
-
638
- var _vA = new THREE.Vector3();
639
- var _vB = new THREE.Vector3();
640
- var _vC = new THREE.Vector3();
641
-
642
- var _tempA = new THREE.Vector3();
643
- var _tempB = new THREE.Vector3();
644
- var _tempC = new THREE.Vector3();
645
-
646
- var _morphA = new THREE.Vector3();
647
- var _morphB = new THREE.Vector3();
648
- var _morphC = new THREE.Vector3();
649
-
650
- function _calculateMorphedAttributeData(
651
- object,
652
- material,
653
- attribute,
654
- morphAttribute,
655
- morphTargetsRelative,
656
- a,
657
- b,
658
- c,
659
- modifiedAttributeArray
660
- ) {
661
-
662
- _vA.fromBufferAttribute( attribute, a );
663
- _vB.fromBufferAttribute( attribute, b );
664
- _vC.fromBufferAttribute( attribute, c );
665
-
666
- var morphInfluences = object.morphTargetInfluences;
667
-
668
- if ( material.morphTargets && morphAttribute && morphInfluences ) {
669
-
670
- _morphA.set( 0, 0, 0 );
671
- _morphB.set( 0, 0, 0 );
672
- _morphC.set( 0, 0, 0 );
673
-
674
- for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) {
675
-
676
- var influence = morphInfluences[ i ];
677
- var morph = morphAttribute[ i ];
678
-
679
- if ( influence === 0 ) continue;
680
-
681
- _tempA.fromBufferAttribute( morph, a );
682
- _tempB.fromBufferAttribute( morph, b );
683
- _tempC.fromBufferAttribute( morph, c );
684
-
685
- if ( morphTargetsRelative ) {
686
-
687
- _morphA.addScaledVector( _tempA, influence );
688
- _morphB.addScaledVector( _tempB, influence );
689
- _morphC.addScaledVector( _tempC, influence );
690
-
691
- } else {
692
-
693
- _morphA.addScaledVector( _tempA.sub( _vA ), influence );
694
- _morphB.addScaledVector( _tempB.sub( _vB ), influence );
695
- _morphC.addScaledVector( _tempC.sub( _vC ), influence );
696
-
697
- }
698
-
699
- }
700
-
701
- _vA.add( _morphA );
702
- _vB.add( _morphB );
703
- _vC.add( _morphC );
704
-
705
- }
706
-
707
- if ( object.isSkinnedMesh ) {
708
-
709
- object.boneTransform( a, _vA );
710
- object.boneTransform( b, _vB );
711
- object.boneTransform( c, _vC );
712
-
713
- }
714
-
715
- modifiedAttributeArray[ a * 3 + 0 ] = _vA.x;
716
- modifiedAttributeArray[ a * 3 + 1 ] = _vA.y;
717
- modifiedAttributeArray[ a * 3 + 2 ] = _vA.z;
718
- modifiedAttributeArray[ b * 3 + 0 ] = _vB.x;
719
- modifiedAttributeArray[ b * 3 + 1 ] = _vB.y;
720
- modifiedAttributeArray[ b * 3 + 2 ] = _vB.z;
721
- modifiedAttributeArray[ c * 3 + 0 ] = _vC.x;
722
- modifiedAttributeArray[ c * 3 + 1 ] = _vC.y;
723
- modifiedAttributeArray[ c * 3 + 2 ] = _vC.z;
724
-
725
- }
726
-
727
- var geometry = object.geometry;
728
- var material = object.material;
729
-
730
- var a, b, c;
731
- var index = geometry.index;
732
- var positionAttribute = geometry.attributes.position;
733
- var morphPosition = geometry.morphAttributes.position;
734
- var morphTargetsRelative = geometry.morphTargetsRelative;
735
- var normalAttribute = geometry.attributes.normal;
736
- var morphNormal = geometry.morphAttributes.position;
737
-
738
- var groups = geometry.groups;
739
- var drawRange = geometry.drawRange;
740
- var i, j, il, jl;
741
- var group, groupMaterial;
742
- var start, end;
743
-
744
- var modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize );
745
- var modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize );
746
-
747
- if ( index !== null ) {
748
-
749
- // indexed buffer geometry
750
-
751
- if ( Array.isArray( material ) ) {
752
-
753
- for ( i = 0, il = groups.length; i < il; i ++ ) {
754
-
755
- group = groups[ i ];
756
- groupMaterial = material[ group.materialIndex ];
757
-
758
- start = Math.max( group.start, drawRange.start );
759
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
760
-
761
- for ( j = start, jl = end; j < jl; j += 3 ) {
762
-
763
- a = index.getX( j );
764
- b = index.getX( j + 1 );
765
- c = index.getX( j + 2 );
766
-
767
- _calculateMorphedAttributeData(
768
- object,
769
- groupMaterial,
770
- positionAttribute,
771
- morphPosition,
772
- morphTargetsRelative,
773
- a, b, c,
774
- modifiedPosition
775
- );
776
-
777
- _calculateMorphedAttributeData(
778
- object,
779
- groupMaterial,
780
- normalAttribute,
781
- morphNormal,
782
- morphTargetsRelative,
783
- a, b, c,
784
- modifiedNormal
785
- );
786
-
787
- }
788
-
789
- }
790
-
791
- } else {
792
-
793
- start = Math.max( 0, drawRange.start );
794
- end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
795
-
796
- for ( i = start, il = end; i < il; i += 3 ) {
797
-
798
- a = index.getX( i );
799
- b = index.getX( i + 1 );
800
- c = index.getX( i + 2 );
801
-
802
- _calculateMorphedAttributeData(
803
- object,
804
- material,
805
- positionAttribute,
806
- morphPosition,
807
- morphTargetsRelative,
808
- a, b, c,
809
- modifiedPosition
810
- );
811
-
812
- _calculateMorphedAttributeData(
813
- object,
814
- material,
815
- normalAttribute,
816
- morphNormal,
817
- morphTargetsRelative,
818
- a, b, c,
819
- modifiedNormal
820
- );
821
-
822
- }
823
-
824
- }
825
-
826
- } else if ( positionAttribute !== undefined ) {
827
-
828
- // non-indexed buffer geometry
829
-
830
- if ( Array.isArray( material ) ) {
831
-
832
- for ( i = 0, il = groups.length; i < il; i ++ ) {
833
-
834
- group = groups[ i ];
835
- groupMaterial = material[ group.materialIndex ];
836
-
837
- start = Math.max( group.start, drawRange.start );
838
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
839
-
840
- for ( j = start, jl = end; j < jl; j += 3 ) {
841
-
842
- a = j;
843
- b = j + 1;
844
- c = j + 2;
845
-
846
- _calculateMorphedAttributeData(
847
- object,
848
- groupMaterial,
849
- positionAttribute,
850
- morphPosition,
851
- morphTargetsRelative,
852
- a, b, c,
853
- modifiedPosition
854
- );
855
-
856
- _calculateMorphedAttributeData(
857
- object,
858
- groupMaterial,
859
- normalAttribute,
860
- morphNormal,
861
- morphTargetsRelative,
862
- a, b, c,
863
- modifiedNormal
864
- );
865
-
866
- }
867
-
868
- }
869
-
870
- } else {
871
-
872
- start = Math.max( 0, drawRange.start );
873
- end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
874
-
875
- for ( i = start, il = end; i < il; i += 3 ) {
876
-
877
- a = i;
878
- b = i + 1;
879
- c = i + 2;
880
-
881
- _calculateMorphedAttributeData(
882
- object,
883
- material,
884
- positionAttribute,
885
- morphPosition,
886
- morphTargetsRelative,
887
- a, b, c,
888
- modifiedPosition
889
- );
890
-
891
- _calculateMorphedAttributeData(
892
- object,
893
- material,
894
- normalAttribute,
895
- morphNormal,
896
- morphTargetsRelative,
897
- a, b, c,
898
- modifiedNormal
899
- );
900
-
901
- }
902
-
903
- }
904
-
905
- }
906
-
907
- var morphedPositionAttribute = new THREE.Float32BufferAttribute( modifiedPosition, 3 );
908
- var morphedNormalAttribute = new THREE.Float32BufferAttribute( modifiedNormal, 3 );
909
-
910
- return {
911
-
912
- positionAttribute: positionAttribute,
913
- normalAttribute: normalAttribute,
914
- morphedPositionAttribute: morphedPositionAttribute,
915
- morphedNormalAttribute: morphedNormalAttribute
916
-
917
- };
918
-
919
- }
920
-
921
- };