From 4e528b3a7ee11516b3e2235898fac6068a0eaf31 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Tue, 7 Nov 2017 11:23:13 +0100 Subject: [PATCH] Update: CC - Mouse Move - Moorcow (fsilsam72g.js) 174 bytes modified --- fsilsam72g.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fsilsam72g.js b/fsilsam72g.js index 1afe281..705ac4b 100644 --- a/fsilsam72g.js +++ b/fsilsam72g.js @@ -3,15 +3,15 @@ camera.lookAt.x = (-1 * (window.innerWidth / 2 - data.event.x)) * 0.025;//(windo camera.lookAt.y = (((window.innerHeight / 2 - data.event.y)) * 0.05) - 8; camera.updateInstance(); -var cameraCursor = GameLib.EntityManager.Instance.findComponentById('b78qx660fo'); +var cursorCamera = GameLib.EntityManager.Instance.findComponentById('b78qx660fo'); var mousePosition = new THREE.Vector3( (-1 * (window.innerWidth / 2 - data.event.x)) , - (window.innerHeight / 2 - data.event.y) , + (window.innerHeight / 2 - data.event.y) * 1.66667, 0 ); -mousePosition.unproject(cameraCursor.instance); +mousePosition.unproject(cursorCamera.instance); var cursor = GameLib.EntityManager.Instance.findComponentById('oxpg88pgzv'); cursor.position.x = mousePosition.x; @@ -21,9 +21,14 @@ cursor.position.y = mousePosition.y; cursor.updateInstance(); var thrower = GameLib.EntityManager.Instance.findComponentById('01viz3rw6l'); -thrower.rotation.x = 0.5 + cursor.position.y * 0.12; -thrower.rotation.y = Math.PI + (cursor.position.x * -0.1); -thrower.updateInstance(); + +//thrower.instance.lookAt.x = cursor.position.x; +//thrower.instance.lookAt.y = cursor.position.y; +//thrower.instance.lookAt.z = cursor.position.z; + +//thrower.rotation.x = 0.5 + cursor.position.y * 0.12; +//thrower.rotation.y = Math.PI + (cursor.position.x * -0.1); +//thrower.updateInstance(); /** * First we find our crosshair @@ -35,8 +40,8 @@ var sphere = GameLib.EntityManager.Instance.findComponentById('dpol2u3xbm'); * Target, is the x / y postion of the crosshair on the z=0 plane in the crosshair scene */ var target = new THREE.Vector3( - (-1 * (window.innerWidth / 2 - data.event.clientX)) , - (window.innerHeight / 2 - data.event.clientY) , + (-1 * (window.innerWidth / 2 - data.event.x)) , + (window.innerHeight / 2 - data.event.y) , 0.5 ); @@ -48,17 +53,18 @@ target.unproject(camera.instance); /** * We want to shoot in the other direction */ +target.normalize(); + target.z *= -1; -target.normalize(); //target.sub(thrower.position.instance).normalize(); var raycaster = new THREE.Raycaster(); raycaster.ray = new THREE.Ray( - thrower.position.instance, - target + cursor.position.instance, + target.instance ); var intersects = raycaster.intersectObjects( @@ -89,8 +95,8 @@ if (intersects.length > 0) { /** * We need the x/y/z position of an imaginary object, at target position, in the game scene */ -var mInverse = new THREE.Matrix4().getInverse( crosshair.instance.matrixWorld ); -sphere.instance.position.copy(target);//.applyMatrix4( mInverse ); +//var mInverse = new THREE.Matrix4().getInverse( crosshair.instance.matrixWorld ); +sphere.instance.position.copy(target);//instance.applyMatrix4( mInverse ); sphere.position.x = sphere.instance.position.x; sphere.position.y = sphere.instance.position.y; sphere.position.z = sphere.instance.position.z;