ExplodeModifier.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. console.warn( "THREE.ExplodeModifier: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * Make all faces use unique vertices
  4. * so that each face can be separated from others
  5. *
  6. * @author alteredq / http://alteredqualia.com/
  7. */
  8. THREE.ExplodeModifier = function () {
  9. };
  10. THREE.ExplodeModifier.prototype.modify = function ( geometry ) {
  11. var vertices = [];
  12. for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) {
  13. var n = vertices.length;
  14. var face = geometry.faces[ i ];
  15. var a = face.a;
  16. var b = face.b;
  17. var c = face.c;
  18. var va = geometry.vertices[ a ];
  19. var vb = geometry.vertices[ b ];
  20. var vc = geometry.vertices[ c ];
  21. vertices.push( va.clone() );
  22. vertices.push( vb.clone() );
  23. vertices.push( vc.clone() );
  24. face.a = n;
  25. face.b = n + 1;
  26. face.c = n + 2;
  27. }
  28. geometry.vertices = vertices;
  29. };