CircleHollowBuilder.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * CircleHollowBuilder.js
  3. *
  4. * @author realor
  5. */
  6. import { ObjectBuilder } from './ObjectBuilder.js'
  7. import { CircleBuilder } from './CircleBuilder.js'
  8. import { ProfileGeometry } from '../core/ProfileGeometry.js'
  9. import * as THREE from '../lib/three.module.js'
  10. class CircleHollowBuilder extends CircleBuilder {
  11. constructor(radius = 1, wallThickness = 0.1, segments = 32) {
  12. super()
  13. this.radius = radius
  14. this.wallThickness = wallThickness
  15. this.segments = segments
  16. }
  17. performBuild(profile) {
  18. const shape = new THREE.Shape()
  19. this.drawCircle(shape, this.radius, this.segments)
  20. const hole = new THREE.Path()
  21. this.drawCircle(hole, this.radius - this.wallThickness, this.segments)
  22. shape.holes.push(hole)
  23. profile.updateGeometry(new ProfileGeometry(shape))
  24. return true
  25. }
  26. copy(source) {
  27. super.copy(source)
  28. this.wallThickness = source.wallThickness
  29. return this
  30. }
  31. }
  32. ObjectBuilder.addClass(CircleHollowBuilder)
  33. export { CircleHollowBuilder }