playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.42k stars 1.32k forks source link

GSplatComponent API improvements #6734

Open willeastcott opened 1 month ago

willeastcott commented 1 month ago

Check out: https://playcanvas.github.io/#/loaders/gsplat

To create the 3DGS entity, the example does:

    const createSplatInstance = (resource, px, py, pz, scale, vertex, fragment) => {
        const splat = resource.instantiate({
            debugRender: false,
            fragment: fragment,
            vertex: vertex
        });
        splat.setLocalPosition(px, py, pz);
        splat.setLocalScale(scale, scale, scale);
        app.root.addChild(splat);
        return splat;
    };

    const biker = createSplatInstance(assets.biker.resource, -1.5, 0.05, 0, 0.7);

Is there any reason this can't adhere to our standard addComponent style? Here's a sketch:

    const biker = new pc.Entity();
    biker.addComponent('gsplat', {
        asset: assets.biker,
        debugRender: false,
        fragment: fragment,
        vertex: vertex
    });
    biker.setLocalPosition(px, py, pz);
    biker.setLocalScale(scale, scale, scale);
    app.root.addChild(biker);
willeastcott commented 1 month ago

Interestingly enough, debugRender doesn't actually seem to do anything!