SceneUtils.js 646 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. */
  4. THREE.SceneUtils = {
  5. createMultiMaterialObject: function ( geometry, materials ) {
  6. var group = new THREE.Group();
  7. for ( var i = 0, l = materials.length; i < l; i ++ ) {
  8. group.add( new THREE.Mesh( geometry, materials[ i ] ) );
  9. }
  10. return group;
  11. },
  12. detach: function ( child, parent, scene ) {
  13. child.applyMatrix( parent.matrixWorld );
  14. parent.remove( child );
  15. scene.add( child );
  16. },
  17. attach: function ( child, scene, parent ) {
  18. child.applyMatrix( new THREE.Matrix4().getInverse( parent.matrixWorld ) );
  19. scene.remove( child );
  20. parent.add( child );
  21. }
  22. };