import { watcher } from '@feng3d/watcher'; import { BoxGeometry } from '../../thirdparty/three/imports'; import { BufferGeometry3D } from '../core/BufferGeometry3D'; export class BoxGeometry3D extends BufferGeometry3D { width = 1; height = 1; depth = 1; widthSegments = 1; heightSegments = 1; depthSegments = 1; get _geometry() { if (!this.__geometry) { this.__geometry = new BoxGeometry(this.width, this.height, this.depth, this.widthSegments, this.heightSegments, this.depthSegments); } return this.__geometry; } declare protected __geometry: BoxGeometry; constructor() { super(); watcher.watchs(this as BoxGeometry3D, ['width', 'height', 'depth', 'widthSegments', 'heightSegments', 'depthSegments'], this._invalidate, this); } destroy() { watcher.unwatchs(this as BoxGeometry3D, ['width', 'height', 'depth', 'widthSegments', 'heightSegments', 'depthSegments'], this._invalidate, this); } toNonIndexed() { const geometry = this._geometry.toNonIndexed(); const geometry3D = BufferGeometry3D.get(geometry); return geometry3D; } }