import { RegisterComponent } from '@feng3d/ecs'; import { GridHelper } from '../../thirdparty/three/imports'; import { Component3D } from '../core/Component3D'; import { LineBasicMaterial3D } from '../materials/LineBasicMaterial3D'; declare module '@feng3d/ecs' { interface ComponentMap { GridHelper3D: GridHelper3D; } } /** * 包装`three`中`GridHelper`。 */ @RegisterComponent({ name: 'GridHelper3D' }) export class GridHelper3D extends Component3D { _helper: GridHelper; material: LineBasicMaterial3D; size = 10; divisions = 10; color1 = 0x444444; color2 = 0x888888; init() { super.init(); this._helper = new GridHelper(this.size, this.divisions, this.color1, this.color2); this.material = new LineBasicMaterial3D(); this.material._material = this._helper.material as any; this._entity._group.add(this._helper); } destroy(): void { this._entity._group.remove(this._helper); this._helper.dispose(); this._helper = null; super.destroy(); } }