/**
* This class is a workaround to make CustomShaderMaterial support clone.
*/
class CustomShaderMaterial2 extends CustomShaderMaterial {
parameters: iCSMParams;
constructor(parameters: iCSMParams) {
super(parameters);
this.parameters = parameters;
}
clone() {
return new this.constructor(this.parameters).copy(this);
}
}
Problem
Trying to
clone()
CustomShaderMaterial
does not work currently and gives this error:Cause
The reason is that the clone method is inherited from
THREE.Material
and looks like thisBut the constructor looks like this (it destructures its first argument, which is not provided by clone).
Workaround