
import { _decorator, Component, Node, MeshRenderer, primitives, utils } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('PlaneMesh')
export class PlaneMesh extends Component {
    @property
    public segmentX = 100;

    @property
    public segmentY = 100;

    @property
    public width =30;

    @property
    public length =30;


    

    public start() {
        const renderer = this.node.getComponent(MeshRenderer);
        if (!renderer) {
            return;
        }
        const plane: primitives.IGeometry = primitives.plane({
            width: this.width,
            length: this.length,
            widthSegments: this.segmentX,
            lengthSegments: this.segmentY,
        });

        renderer.mesh = utils.createMesh(plane);
    }
}

