function draw_line(params) { // Visualize path var geometry = new THREE.BufferGeometry(); var positions = new Float32Array( 2 * 3 ); // 3 vertices per point geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); drawCount = 2; // draw the first 2 points, only geometry.setDrawRange( 0, drawCount ); var material = new THREE.MeshBasicMaterial( { color: params.color, transparent: true , visible: params.visible, opacity: params.opacity }); line = new THREE.Line( geometry, material ); params.container.add(line); var positions = line.geometry.attributes.position.array; positions[0]=params.origin.x; positions[1]=params.force_y || params.origin.y; positions[2]=params.origin.z; positions[3]=params.destination.x; positions[4]=params.force_y || params.destination.y; positions[5]=params.destination.z; return line; } function find_angle(A,B,C) { var AB = Math.sqrt(Math.pow(B.x-A.x,2)+ Math.pow(B.z-A.z,2)); var BC = Math.sqrt(Math.pow(B.x-C.x,2)+ Math.pow(B.z-C.z,2)); var AC = Math.sqrt(Math.pow(C.x-A.x,2)+ Math.pow(C.z-A.z,2)); return Math.acos((BC*BC+AB*AB-AC*AC)/(2*BC*AB)); } function play_multiple(audio, delay) { var new_audio= new Audio(audio.getAttribute('src')); new_audio.volume=audio.volume; if(delay) { window.setTimeout(new_audio.play.bind(new_audio), delay); } else { new_audio.play(); } }