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 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. _testFinish,
  3. Box3B,
  4. HemisphereLight2,
  5. IObject3D,
  6. Mesh,
  7. Object3DWidgetsPlugin,
  8. PhysicalMaterial,
  9. PlaneGeometry,
  10. ThreeViewer,
  11. Vector3,
  12. } from 'threepipe'
  13. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  14. async function init() {
  15. const viewer = new ThreeViewer({
  16. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  17. msaa: true,
  18. dropzone: {
  19. allowedExtensions: ['gltf', 'glb', 'hdr', 'obj', 'fbx', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr'],
  20. addOptions: {
  21. disposeSceneObjects: true,
  22. autoSetEnvironment: true, // when hdr/exr is dropped
  23. },
  24. },
  25. plugins: [Object3DWidgetsPlugin],
  26. })
  27. // viewer.scene.addObject(new HemisphereLight(0xffffff, 0x444444, 10))
  28. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/ShadowmappableMesh.glb', {
  29. autoCenter: true,
  30. autoScale: true,
  31. })
  32. const ground = new Mesh(
  33. new PlaneGeometry(100, 100)
  34. .rotateX(-Math.PI / 2)
  35. .translate(0, new Box3B().expandByObject(result!).getSize(new Vector3()).y / -2, 0),
  36. new PhysicalMaterial({
  37. color: '#ffffff',
  38. })
  39. )
  40. viewer.scene.addObject(ground)
  41. const light = viewer.scene.addObject(new HemisphereLight2(0x0000ff, 0xff0000, 20))
  42. const ui = viewer.addPluginSync(TweakpaneUiPlugin, true)
  43. ui.appendChild(light.uiConfig, {expanded: true})
  44. }
  45. init().then(_testFinish)