threepipe
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {_testFinish, GLTFAnimationPlugin, HemisphereLight, ImportAddOptions, IObject3D, ThreeViewer} from 'threepipe'
  2. import {
  3. AMFLoadPlugin,
  4. BVHLoadPlugin,
  5. ColladaLoadPlugin,
  6. GCodeLoadPlugin,
  7. LDrawLoadPlugin,
  8. MDDLoadPlugin,
  9. PCDLoadPlugin,
  10. TDSLoadPlugin,
  11. ThreeMFLoadPlugin,
  12. TiltLoadPlugin,
  13. VOXLoadPlugin,
  14. VRMLLoadPlugin,
  15. VTKLoadPlugin,
  16. XYZLoadPlugin,
  17. } from '@threepipe/plugin-extra-importers'
  18. async function init() {
  19. const viewer = new ThreeViewer({
  20. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  21. msaa: true,
  22. dropzone: {
  23. addOptions: {
  24. disposeSceneObjects: true,
  25. },
  26. },
  27. })
  28. viewer.addPluginsSync([
  29. GLTFAnimationPlugin,
  30. TDSLoadPlugin,
  31. ThreeMFLoadPlugin,
  32. ColladaLoadPlugin,
  33. AMFLoadPlugin,
  34. GCodeLoadPlugin,
  35. BVHLoadPlugin,
  36. VOXLoadPlugin,
  37. MDDLoadPlugin,
  38. PCDLoadPlugin,
  39. TiltLoadPlugin,
  40. VRMLLoadPlugin,
  41. LDrawLoadPlugin,
  42. VTKLoadPlugin,
  43. XYZLoadPlugin,
  44. ])
  45. viewer.getPlugin(GLTFAnimationPlugin)!.autoplayOnLoad = true
  46. viewer.scene.mainCamera.autoNearFar = false
  47. viewer.scene.setBackgroundColor('#555555')
  48. viewer.scene.addObject(new HemisphereLight(0xffffff, 0x444444, 2))
  49. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  50. const urls = [
  51. 'https://threejs.org/examples/models/3ds/portalgun/portalgun.3ds',
  52. 'https://threejs.org/examples/models/3mf/cube_gears.3mf',
  53. 'https://threejs.org/examples/models/collada/elf/elf.dae',
  54. 'https://threejs.org/examples/models/amf/rook.amf',
  55. 'https://threejs.org/examples/models/gcode/benchy.gcode',
  56. 'https://threejs.org/examples/models/bvh/pirouette.bvh',
  57. 'https://threejs.org/examples/models/vox/monu10.vox',
  58. 'https://threejs.org/examples/models/mdd/cube.mdd',
  59. 'https://threejs.org/examples/models/pcd/binary/Zaghetto.pcd',
  60. 'https://threejs.org/examples/models/tilt/BRUSH_DOME.tilt',
  61. 'https://threejs.org/examples/models/ldraw/officialLibrary/models/car.ldr_Packed.mpd',
  62. 'https://threejs.org/examples/models/vtk/bunny.vtk',
  63. 'https://threejs.org/examples/models/vtk/cube_binary.vtp',
  64. 'https://threejs.org/examples/models/xyz/helix_201.xyz',
  65. ]
  66. const options: ImportAddOptions = {
  67. autoScale: true,
  68. autoCenter: true,
  69. autoScaleRadius: 0.5,
  70. clearSceneObjects: false,
  71. }
  72. const models = await Promise.allSettled(urls.map(async url =>
  73. viewer.load<IObject3D>(url, options).then(res => {
  74. if (!res) return
  75. const i = urls.indexOf(url)
  76. res.position.set(i % 4 - 1.5, 0, Math.floor(i / 4) - 1.5).multiplyScalar(1)
  77. res.setDirty()
  78. return res
  79. })))
  80. console.log(models)
  81. }
  82. init().finally(_testFinish)