Lights are not working on glTF model

In the viewer https://playcanvas.github.io/playcanvas-gltf/viewer/index.html, I can see the model with lights but I can’t seem to get them to show up when I use either the playcanvas-gltf module or the app.assets.loadFromUrlAndFilename API.

Hi @DANIEL_SSEJJEMBA,

Are you able to share a project sample or some code on how you are doing the loading? Not sure what may be wrong here.

const json = assetRes.resource
        const assetLights = readLights(json)
        const modelRes = JSON.parse(json)
        /* global DracoDecoderModule : true */
        /* eslint no-undef: "error" */
        const decoderModule = DracoDecoderModule({})
        loadGltf(
            modelRes,
            app.graphicsDevice,
            (e, res) => {
                if (e) {
                    alert(e)
                    return
                }
                // Wrap the model as an asset and add to the asset registry
                const asset = new pc.Asset('gltf', 'model', {
                    url: '',
                })
                asset.resource = res.model
                asset.loaded = true
                app.assets.add(asset)

                // Add the loaded scene to the hierarchy
                const gltf = new pc.Entity('gltf')
                gltf.addComponent('model', {
                    type: 'asset',
                    asset,
                })

                gltf.addComponent('rigidbody', {
                    type: pc.BODYTYPE_DYNAMIC,
                })

                gltf.addComponent('collision', {
                    type: 'mesh',
                    asset,
                })

                this.originController.appendToOrigin(gltf)
            },
            {
                basePath: this.blockParams.content.basePath,
                decoderModule,
            }
        )

Probably the glTF model with lights uses KHR_lights_punctual extension.
However, PlayCanvas doesn’t seem to support the KHR_lights_punctual extension yet.


1 Like

Ohh I see… thanks… I have built a custom lights parser… works well for me…

1 Like