import { insert_after } from "../../../../../core/primitives/strings/insert_after.js";

/**
 *
 * @param {string} base
 * @returns {string}
 */
export function fp_build_vertex_shader(base) {


    const a = `
    #define attribute in
    #define varying out
    #define texture2D texture
    
    varying vec3 v_world_position;
    ` + base;


    const v1 = insert_after(a, '#include <worldpos_vertex>', `
        #if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
            // worldPosition comes from 'worldpos_vertex' shader chunk
            v_world_position = worldPosition.xyz;
        #else
            v_world_position = ( modelMatrix * vec4( transformed, 1.0 )).xyz;
        #endif
    `);

    return v1;
}
