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.

script.ts 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {
  2. _testFinish, _testStart,
  3. BufferGeometry,
  4. BufferGeometry2,
  5. Color,
  6. GLTFLoader2,
  7. IMaterial,
  8. IObject3D,
  9. LineSegmentsGeometry,
  10. LineSegmentsGeometry2,
  11. LoadingScreenPlugin,
  12. Object3D,
  13. ThreeViewer,
  14. } from 'threepipe'
  15. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  16. async function init() {
  17. const viewer = new ThreeViewer({
  18. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  19. msaa: true,
  20. plugins: [LoadingScreenPlugin],
  21. dropzone: true,
  22. })
  23. viewer.scene.autoNearFarEnabled = false
  24. GLTFLoader2.UseMeshLines = true
  25. viewer.scene.backgroundColor = new Color(0x333333)
  26. // await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  27. const obj1 = await viewer.load<IObject3D>('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/refs/heads/main/Models/MeshPrimitiveModes/glTF/MeshPrimitiveModes.gltf', {
  28. autoScale: true,
  29. autoCenter: true,
  30. useMeshLines: true,
  31. })
  32. const obj2 = await viewer.load<IObject3D>('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/refs/heads/main/Models/MeshPrimitiveModes/glTF/MeshPrimitiveModes.gltf', {
  33. autoScale: true,
  34. autoCenter: true,
  35. useMeshLines: false,
  36. })
  37. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  38. const mats: IMaterial[] = []
  39. const o1: IObject3D[] = []
  40. const o2: IObject3D[] = []
  41. const p1 = viewer.scene.addObject(new Object3D()).translateY(0.75)
  42. const p2 = viewer.scene.addObject(new Object3D()).translateY(-0.75)
  43. p1.scale.setScalar(0.6)
  44. p2.scale.setScalar(0.6)
  45. obj1?.traverse(o=>{
  46. if (o.materials?.[0].isLineMaterial) {
  47. mats.push(o.materials[0])
  48. o1.push(o)
  49. }
  50. })
  51. obj2?.traverse(o=>{
  52. if (o.materials?.[0].isUnlitLineMaterial) {
  53. mats.push(o.materials[0])
  54. o2.push(o)
  55. }
  56. })
  57. o1.forEach(o=>p1.add(o))
  58. o2.forEach(o=>p2.add(o))
  59. obj1?.dispose(true)
  60. obj2?.dispose(true)
  61. mats.map(m=>{
  62. if (!m.appliedMeshes.size) return
  63. m.linewidth = 10
  64. ui.appendChild(m.uiConfig)
  65. })
  66. console.log(LineSegmentsGeometry)
  67. console.log(LineSegmentsGeometry2)
  68. console.log(BufferGeometry)
  69. console.log(BufferGeometry2)
  70. }
  71. _testStart()
  72. init().finally(_testFinish)