constructor()

in src/splats/Splat.ts [21:62]


    constructor(splat: SplatData | undefined = undefined) {
        super();

        this._data = splat || new SplatData();
        this._bounds = new Box3(
            new Vector3(Infinity, Infinity, Infinity),
            new Vector3(-Infinity, -Infinity, -Infinity),
        );

        this.recalculateBounds = () => {
            this._bounds = new Box3(
                new Vector3(Infinity, Infinity, Infinity),
                new Vector3(-Infinity, -Infinity, -Infinity),
            );
            for (let i = 0; i < this._data.vertexCount; i++) {
                this._bounds.expand(
                    new Vector3(
                        this._data.positions[3 * i],
                        this._data.positions[3 * i + 1],
                        this._data.positions[3 * i + 2],
                    ),
                );
            }
        };

        this.applyPosition = () => {
            this.data.translate(this.position);
            this.position = new Vector3();
        };

        this.applyRotation = () => {
            this.data.rotate(this.rotation);
            this.rotation = new Quaternion();
        };

        this.applyScale = () => {
            this.data.scale(this.scale);
            this.scale = new Vector3(1, 1, 1);
        };

        this.recalculateBounds();
    }