Controlling background video visibility using THREE.Vector3 and OrbitControls.js

假如想象 提交于 2019-12-11 17:21:52

问题


i have this example that stackoverflow user Marquizzo helped me develop. What it'd like to change is that instead of background color changing based on camera position I would like to have a short looped video background that becomes visible only in the position that right now in the example makes the background go gradually black.

Additional features would be audio volume increasing in the same way and also activiating an invisible hotspot (also only in the same range of camera position) to click/tap that redirects to another page.

Below is the code that affects the background color right now:

var vantagePoint = new THREE.Vector3(6.8, 0.6, -1.8);
var distance = 100;
var normalized = 1;
var endColor = new THREE.Color(0xffffff);
var startColor = new THREE.Color(0x000000);
scene.background = startColor;



function animate() {
		
		distance = vantagePoint.distanceTo(camera.position);
   normalized = THREE.Math.smoothstep(distance, 0.3, 2); // Converts [1, 100] => [0, 1]

   // Resets the color on each frame
   startColor.set(0xf000000);
   startColor.lerp(endColor, normalized);

	render();
	requestAnimationFrame( animate );

	


	}

来源:https://stackoverflow.com/questions/54639391/controlling-background-video-visibility-using-three-vector3-and-orbitcontrols-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!