TProfileBuilder.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * TProfileBuilder.js
  3. *
  4. * @author realor
  5. */
  6. import { ObjectBuilder } from './ObjectBuilder.js'
  7. import { ProfileBuilder } from './ProfileBuilder.js'
  8. import { ProfileGeometry } from '../core/ProfileGeometry.js'
  9. import * as THREE from '../lib/three.module.js'
  10. class TProfileBuilder extends ProfileBuilder {
  11. constructor(flangeWidth = 1, height = 1, webThickness = 0.1, flangeThickness = 0.1) {
  12. super()
  13. this.flangeWidth = flangeWidth
  14. this.height = height
  15. this.webThickness = webThickness
  16. this.flangeThickness = flangeThickness
  17. }
  18. performBuild(profile) {
  19. const shape = new THREE.Shape()
  20. const xs = 0.5 * this.flangeWidth
  21. const ys = 0.5 * this.height
  22. const xt = 0.5 * this.webThickness
  23. const yt = this.flangeThickness
  24. shape.moveTo(xt, -ys)
  25. shape.lineTo(xt, ys - yt)
  26. shape.lineTo(xs, ys - yt)
  27. shape.lineTo(xs, ys)
  28. shape.lineTo(-xs, ys)
  29. shape.lineTo(-xs, ys - yt)
  30. shape.lineTo(-xt, ys - yt)
  31. shape.lineTo(-xt, -ys)
  32. shape.closePath()
  33. profile.updateGeometry(new ProfileGeometry(shape))
  34. return true
  35. }
  36. copy(source) {
  37. this.flangeWidth = source.flangeWidth
  38. this.height = source.height
  39. this.webThickness = source.webThickness
  40. this.flangeThickness = source.flangeThickness
  41. return this
  42. }
  43. }
  44. ObjectBuilder.addClass(TProfileBuilder)
  45. export { TProfileBuilder }