{"size": 1146, "ext": "js", "max_stars_repo_path": "shader-replacement/src/passes/DepthPass.js", "max_stars_repo_name": "gkjohnson/threejs-merge-vertices", "max_stars_repo_stars_event_min_datetime": "2018-09-14T23:15:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-30T01:30:11.000Z", "max_issues_repo_path": "shader-replacement/src/passes/DepthPass.js", "max_issues_repo_name": "gkjohnson/threejs-merge-vertices", "max_issues_repo_issues_event_min_datetime": "2018-07-25T01:02:36.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T22:50:57.000Z", "max_forks_repo_path": "shader-replacement/src/passes/DepthPass.js", "max_forks_repo_name": "gkjohnson/threejs-merge-vertices", "max_forks_repo_forks_event_min_datetime": "2018-09-14T23:15:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T10:06:20.000Z"}
{"max_stars_count": 321, "max_issues_count": 23, "max_forks_count": 47, "avg_line_length": 26.6511627907, "max_line_length": 126, "alphanum_fraction": 0.6771378709}
import { ShaderReplacement } from '../ShaderReplacement.js';
import { ShaderLib, BasicDepthPacking } from '//cdn.skypack.dev/three@0.130.1/build/three.module.js';

export class DepthPass extends ShaderReplacement {

	constructor() {

		super( {
			defines: {
				DEPTH_PACKING: BasicDepthPacking
			},
			uniforms: {
				...ShaderLib.depth.uniforms,
				alphaMap: { value: null },
				alphaTest: { value: 0 },
				map: { value: null },
				opacity: { value: 1.0 }
			},
			vertexShader: ShaderLib.depth.vertexShader,
			fragmentShader: ShaderLib.depth.fragmentShader
		} );

	}

	updateUniforms( object, material, target ) {

		super.updateUniforms( object, material, target );

		// TODO: Handle displacement map
		// TODO: support packing

		target.setDefine( 'USE_UV', '' );

		target.setDefine( 'ALPHATEST', target.uniforms.alphaTest.value ? target.uniforms.alphaTest.value : undefined );

		target.setDefine( 'USE_ALPHAMAP', ( target.defines.ALPHATEST === 0 || ! target.uniforms.alphaMap.value ) ? undefined : '' );

		target.setDefine( 'USE_MAP', ( target.defines.ALPHATEST === 0 || ! target.uniforms.map.value ) ? undefined : '' );

	}

}
