123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /*
- * LProfileBuilder.js
- *
- * @author realor
- */
- import { ObjectBuilder } from './ObjectBuilder.js'
- import { ProfileBuilder } from './ProfileBuilder.js'
- import { ProfileGeometry } from '../core/ProfileGeometry.js'
- import * as THREE from '../lib/three.module.js'
- class LProfileBuilder extends ProfileBuilder {
- constructor(width = 1, height = 1, thickness = 0.1) {
- super()
- this.width = width
- this.height = height
- this.thickness = thickness
- }
- performBuild(profile) {
- const shape = new THREE.Shape()
- const xs = 0.5 * this.width
- const ys = 0.5 * this.height
- const t = this.thickness
- shape.moveTo(-xs + t, -ys + t)
- shape.lineTo(-xs + t, ys)
- shape.lineTo(-xs, ys)
- shape.lineTo(-xs, -ys)
- shape.lineTo(xs, -ys)
- shape.lineTo(xs, -ys + t)
- shape.closePath()
- profile.updateGeometry(new ProfileGeometry(shape))
- return true
- }
- copy(source) {
- this.width = source.width
- this.height = source.height
- this.thickness = source.thickness
- return this
- }
- }
- ObjectBuilder.addClass(LProfileBuilder)
- export { LProfileBuilder }
|