Update: CC - Mouse Move - Moorcow (ud33b2z225.js) 805 bytes modified
parent
0da84c218a
commit
0d97c9df17
|
@ -2,77 +2,73 @@ if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var camera = GameLib.EntityManager.Instance.findComponentById('k9ain64rlp');
|
if (!this.initialized) {
|
||||||
camera.lookAt.x = (-1 * (window.innerWidth / 2 - data.event.x)) * 0.025;//(window.clientWidth/ 2) + data.event.x;
|
this.initialized = true;
|
||||||
camera.lookAt.y = (((window.innerHeight / 2 - data.event.y)) * 0.05);
|
}
|
||||||
camera.updateInstance();
|
|
||||||
|
|
||||||
var cursorCamera = GameLib.EntityManager.Instance.findComponentById('3c8ff7zgk8');
|
this.mouse.x = (event.offsetX / event.target.width ) * 2 - 1;
|
||||||
|
this.mouse.y = -(event.offsetY / event.target.height) * 2 + 1;
|
||||||
|
|
||||||
var mousePosition = new THREE.Vector3(
|
this.camera.lookAt.x = this.mouse.x;
|
||||||
(-1 * (window.innerWidth / 2 - data.event.x)) ,
|
this.camera.lookAt.y = this.mouse.y;
|
||||||
(window.innerHeight / 2 - data.event.y) * 1.66667,
|
this.camera.updateInstance();
|
||||||
0
|
|
||||||
|
this.raycaster.instance.setFromCamera(
|
||||||
|
this.mouse,
|
||||||
|
this.camera.instance
|
||||||
);
|
);
|
||||||
|
|
||||||
mousePosition.unproject(cursorCamera.instance);
|
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
|
||||||
|
|
||||||
var cursor = GameLib.EntityManager.Instance.findComponentById('1eh5eu30m6');
|
this.cursor.position.x = mouse.x;
|
||||||
cursor.position.x = mousePosition.x;
|
this.cursor.position.y = mouse.y;
|
||||||
cursor.position.y = mousePosition.y;
|
this.cursor.updateInstance();
|
||||||
//cursor.position.x = (-1 * (window.innerWidth / 2 - data.event.x)) * 0.025;
|
|
||||||
//cursor.position.y = (((window.innerHeight / 2 - data.event.y)) * 0.05);
|
|
||||||
cursor.updateInstance();
|
|
||||||
|
|
||||||
var thrower = GameLib.EntityManager.Instance.findComponentById('zldh9sdfuc');
|
this.thrower.instance.lookAt(
|
||||||
|
|
||||||
thrower.instance.lookAt(
|
|
||||||
new THREE.Vector3(
|
new THREE.Vector3(
|
||||||
cursor.position.x,
|
this.cursor.position.x,
|
||||||
cursor.position.y,
|
this.cursor.position.y,
|
||||||
cursor.position.z
|
this.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
|
* First we find our crosshair
|
||||||
*/
|
*/
|
||||||
//var crosshair = GameLib.EntityManager.Instance.findComponentById('oxpg88pgzv');
|
//var crosshair = GameLib.EntityManager.Instance.findComponentById('oxpg88pgzv');
|
||||||
var sphere = GameLib.EntityManager.Instance.findComponentById('ijir4gkqya');
|
/var sphere = GameLib.EntityManager.Instance.findComponentById('ijir4gkqya');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target, is the x / y postion of the crosshair on the z=0 plane in the crosshair scene
|
* Target, is the x / y postion of the crosshair on the z=0 plane in the crosshair scene
|
||||||
*/
|
*/
|
||||||
var target = new THREE.Vector3(
|
//var target = new THREE.Vector3(
|
||||||
(-1 * (window.innerWidth / 2 - data.event.x)) ,
|
// (-1 * (window.innerWidth / 2 - data.event.x)) ,
|
||||||
(window.innerHeight / 2 - data.event.y) ,
|
// (window.innerHeight / 2 - data.event.y) ,
|
||||||
0
|
// 0
|
||||||
);
|
//);
|
||||||
|
/*
|
||||||
sphere.instance.position.copy(target);//instance.applyMatrix4( mInverse );
|
sphere.instance.position.copy(target);//instance.applyMatrix4( mInverse );
|
||||||
sphere.position.x = sphere.instance.position.x;
|
sphere.position.x = sphere.instance.position.x;
|
||||||
sphere.position.y = sphere.instance.position.y;
|
sphere.position.y = sphere.instance.position.y;
|
||||||
sphere.position.z = sphere.instance.position.z;
|
sphere.position.z = sphere.instance.position.z;
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* Now we get the position of the crosshair, in our world scene space
|
* Now we get the position of the crosshair, in our world scene space
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
target.unproject(camera.instance);
|
target.unproject(camera.instance);
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* We want to shoot in the other direction
|
* We want to shoot in the other direction
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
target.normalize();
|
target.normalize();
|
||||||
|
|
||||||
target.z *= -1;
|
target.z *= -1;
|
||||||
|
*/
|
||||||
|
|
||||||
//target.sub(thrower.position.instance).normalize();
|
//target.sub(thrower.position.instance).normalize();
|
||||||
|
/*
|
||||||
var raycaster = new THREE.Raycaster();
|
var raycaster = new THREE.Raycaster();
|
||||||
|
|
||||||
raycaster.ray = new THREE.Ray(
|
raycaster.ray = new THREE.Ray(
|
||||||
|
@ -115,18 +111,7 @@ if (intersects.length > 0) {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
|
||||||
* But we also, want the direction from the thrower to the crosshair
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//@ sourceURL=mouseMove.js
|
//@ sourceURL=mouseMove.js
|
Loading…
Reference in New Issue