pmndrs / lamina

🍰 An extensible, layer based shader material for ThreeJS
MIT License
1.01k stars 41 forks source link

Transmission property not working in vanilla version. #24

Closed supermoos closed 2 years ago

supermoos commented 2 years ago

I'm making a new material like this:

export class JourneySphereMaterial extends LayerMaterial {
    constructor() {
        super({
            color: 'white',
            lighting: 'physical',
            transmission: 1,
            // @ts-ignore
            thickness: 0,
            roughness: 0.42,
            metalness: 0.19,
        });
//Transmission only works if this is set, should work in init properties too?
        this.transmission = 1;
    }
}

However some properties like thickness gives a typescript error, and transmission isn't even set on the material created. I have to set it manually with that last line in the example for it to take effect.

FarazzShaikh commented 2 years ago

The constructor issue should be fixed in 1.1.11

About the types, the MeshPhysicalMaterialParameters type from @types/three seems to not have thickness as a property, the only option is to open an issue in ThreeJS and use ts-ignore

Also, LayerMaterial and all derived classes are of type Material and will give you type errors if you try to do LayerMaterial.transmission for example. This is because transmission is a property on the MeshPhysicalMaterial class and not on the base Material class. Only option here is to cast your material to MeshPhysicalMaterial