jnsmalm / pixi3d

The 3D renderer for PixiJS. Seamless integration with 2D applications.
https://pixi3d.org
MIT License
752 stars 43 forks source link

GLTF / GLB files with vertex colours are not rendered. #148

Closed richo0 closed 1 year ago

richo0 commented 1 year ago

Hi,

I just found your project from Hacker News, it's really awesome - thanks for creating this!

I'm having issues loading GLTF files which use vertex colours, they do not render at all.

For example, the code below should render the cherry model in the attached image - however all I see is a black screen and no errors. I'm wondering if the standard fragment shader does not support vertex colours?

Please find attached a zip file of the model attached.

I'd love to use your library on a project I'm working on, however all of the art assets use vertex colours. :-(

Any assistance you might provide would be most appreciated - I love what you've done here!

Cheers, -R

Screenshot 2022-12-22 at 8 02 11 PM

`let app = new PIXI.Application({ backgroundColor: 0x000000, resizeTo: window, antialias: true }); document.body.appendChild(app.view);

    // Using a self executing function just to make the different methods more comparable.
    (async function load() {
      let gltf = await PIXI.Assets.load("cherry.gltf")
      setup(gltf)
    })()

    function setup(gltf) {
       let mesh2 = app.stage.addChild(PIXI3D.Model.from(gltf));

       mesh2.scale.set(1);

       app.ticker.add(() => {
       rotation=rotation+0.1
       mesh2.rotationQuaternion.setEulerAngles(0, rotation,0 )

       scale = scale + ds 
       if (scale > 16){
           ds=-ds
           scale=scale+ds
       }
       if (scale < 0.01){
           ds=-ds
           scale=scale+ds
       }
    //   mesh2.scale.set(-scale)

//     light.intensity=scale
    })
    }

    //let mesh = app.stage.addChild(PIXI3D.Mesh3D.createCube());

    let light = new PIXI3D.Light()
    light.position.set(0,0,50)
    light.range=100
    light.intensity=100
    PIXI3D.LightingEnvironment.main.lights.push(light)
    //mesh.position.y=-1
    let rotation = 0

    let scale = 1
    let ds = 0.01
    //let control = new CameraOrbitControl(app.view);
    //app.ticker.add(() => {
    //mesh.rotationQuaternion.setEulerAngles(rotation, rotation++,0 )
    //})`

cherry.gltf.zip

jnsmalm commented 1 year ago

Hello and thanks!

Vertex colors are supported with standard material.

There seems to be a bug in Pixi3D with that specific gltf file, doesn't want to render it for some reason - I'll investigate this. I tried importing the gltf file in Blender and then exporting it to gltf again and that file worked.

Thanks for reporting, I'll try to fix this as soon as I can.

richo0 commented 1 year ago

Thanks for the quick reply! Really looking forward to using this!

On 22 Dec 2022, at 8:25 PM, Jens Malmborg @.***> wrote:

Hello and thanks!

Vertex colors are supported with standard material.

There seems to be a bug in Pixi3D with that specific gltf file, doesn't want to render it for some reason - I'll investigate this. I tried importing the gltf file in Blender and then exporting it to gltf again and that file worked.

Thanks for reporting, I'll try to fix this as soon as I can.

— Reply to this email directly, view it on GitHub https://github.com/jnsmalm/pixi3d/issues/148#issuecomment-1363265760, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKARHUUEM5E54IHJTJT2ZZ3WOSTKXANCNFSM6AAAAAATHBBWRA. You are receiving this because you authored the thread.

jnsmalm commented 1 year ago

Would it be ok with you if I use this model in automatic tests to make sure this issue won't come back?

richo0 commented 1 year ago

Yes - no problem! Sent from my iPhoneOn 22 Dec 2022, at 9:09 PM, Jens Malmborg @.***> wrote: Would it be ok with you if I use this model in automatic tests to make sure this issue won't come back?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

jnsmalm commented 1 year ago

Created a new version 2.1.1, please let me know if this fixes your issue.

richo0 commented 1 year ago

Works perfectly! Thank you very much!

On 23 Dec 2022, at 12:12 PM, Jens Malmborg @.***> wrote:

Created a new version 2.1.1, please let me know if this fixes your issue.

— Reply to this email directly, view it on GitHub https://github.com/jnsmalm/pixi3d/issues/148#issuecomment-1363860400, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKARHUWO7B3HVP5CILZHWS3WOWCIVANCNFSM6AAAAAATHBBWRA. You are receiving this because you authored the thread.