SceneUtils.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. console.warn( "THREE.SceneUtils: 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. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.SceneUtils = {
  6. createMeshesFromInstancedMesh: function ( instancedMesh ) {
  7. var group = new THREE.Group();
  8. var count = instancedMesh.count;
  9. var geometry = instancedMesh.geometry;
  10. var material = instancedMesh.material;
  11. for ( var i = 0; i < count; i ++ ) {
  12. var mesh = new THREE.Mesh( geometry, material );
  13. instancedMesh.getMatrixAt( i, mesh.matrix );
  14. mesh.matrix.decompose( mesh.position, mesh.quaternion, mesh.scale );
  15. group.add( mesh );
  16. }
  17. group.copy( instancedMesh );
  18. group.updateMatrixWorld(); // ensure correct world matrices of meshes
  19. return group;
  20. },
  21. createMultiMaterialObject: function ( geometry, materials ) {
  22. var group = new THREE.Group();
  23. for ( var i = 0, l = materials.length; i < l; i ++ ) {
  24. group.add( new THREE.Mesh( geometry, materials[ i ] ) );
  25. }
  26. return group;
  27. },
  28. detach: function ( child, parent, scene ) {
  29. console.warn( 'THREE.SceneUtils: detach() has been deprecated. Use scene.attach( child ) instead.' );
  30. scene.attach( child );
  31. },
  32. attach: function ( child, scene, parent ) {
  33. console.warn( 'THREE.SceneUtils: attach() has been deprecated. Use parent.attach( child ) instead.' );
  34. parent.attach( child );
  35. }
  36. };