import { convertFragmentShaderToWebGL2 , convertVertexShaderToWebGL2 } from "@here/harp-utils" ; import * as THREE from "three" ; import { getShaderMaterialDefine , setShaderMaterialDefine } from "./Utils" ; /**
 * [[RawShaderMaterial]] parameters.
 */ export interface RendererMaterialParameters { rendererCapabilities : THREE . WebGLCapabilities ; } export interface RawShaderMaterialParameters extends RendererMaterialParameters , THREE . ShaderMaterialParameters { } /**
 * Base class for all raw shader materials. Ensures WebGL2 compatibility for WebGL1 shaders.
 */ export class RawShaderMaterial extends THREE . RawShaderMaterial { param params constructor ( params ? ) { const isWebGL2 = params ?. rendererCapabilities . isWebGL2 === true ; const shaderParams = params ? { ... params , glslVersion : isWebGL2 ? THREE . GLSL3 : THREE . GLSL1 , vertexShader : isWebGL2 && params . vertexShader ? convertVertexShaderToWebGL2 ( params . vertexShader ) : params . vertexShader , fragmentShader : isWebGL2 && params . fragmentShader ? convertFragmentShaderToWebGL2 ( params . fragmentShader ) : params . fragmentShader } : undefined ; if ( shaderParams ) { delete ( shaderParams as any ) . rendererCapabilities ; } super ( shaderParams ) ; this . invalidateFog ( ) ; this . setOpacity ( shaderParams ?. opacity ) ; } invalidateFog ( ) { if ( this . defines !== undefined && this . fog !== getShaderMaterialDefine ( this , "USE_FOG" ) ) { setShaderMaterialDefine ( this , "USE_FOG" , this . fog ) ; } } param opacity setOpacity ( opacity ? ) { if ( opacity !== undefined ) { this . opacity = opacity ; if ( this . uniforms ?. opacity ) { this . uniforms . opacity . value = opacity ; } } } }