How to use the subtitle.frag function in subtitle

To help you get started, we’ve selected a few subtitle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leon196 / leon196.github.io / Melimelo / js / ui.js View on Github external
this.title = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), material);
	this.add(this.title);

	var subtitleTexture = textures['subtitle'];
	var subtitleImage = subtitleTexture.image;

	var uniforms = {
		time: { value: 0 },
		resolution: { value: [window.innerWidth, window.innerHeight] },
		imageResolution: { value: [subtitleImage.width, subtitleImage.height] },
		target: { value: [0,-1,0] },
		subtitle: { value: subtitleTexture },
	};
	var material = new THREE.ShaderMaterial({
		vertexShader: shaders['subtitle.vert'],
		fragmentShader: shaders['subtitle.frag'],
		uniforms: uniforms,
		side: THREE.DoubleSide,
		transparent: true,
		depthTest: false,
	})
	this.subtitle = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), material);
	this.add(this.subtitle);

	this.resize = function(width, height) {
		this.subtitle.material.uniforms.resolution.value[0] = width;
		this.subtitle.material.uniforms.resolution.value[1] = height;
		this.title.material.uniforms.resolution.value[0] = width;
		this.title.material.uniforms.resolution.value[1] = height;
	}
}