Update: CC - Mouse Down (56if6ltmvm.js) 153 bytes modified
parent
3e77cd8226
commit
87aaf45a16
|
@ -2,54 +2,51 @@ if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
var codeSnippet = function(type, rotation, scale, position) {
|
||||||
* First we find our crosshair
|
code = "mesh = " + type + ".clone();\n"
|
||||||
*/
|
|
||||||
var crosshair = GameLib.EntityManager.Instance.findComponentById('jl8hpa2pel');
|
|
||||||
|
|
||||||
/**
|
code += "mesh.position.x = " + position.x + ";\n";
|
||||||
* Target, is the x / y postion of the crosshair on the z=0 plane in the crosshair scene
|
code += "mesh.position.y = " + position.y + ";\n";
|
||||||
*/
|
code += "mesh.position.z = " + position.z + ";\n";
|
||||||
var target = new THREE.Vector3(crosshair.position.x, crosshair.position.y, 0);
|
|
||||||
|
|
||||||
/**
|
code += "mesh.rotation.x = " + rotation.x + ";\n";
|
||||||
* We need the x/y/z position of an imaginary object, at target position, in the game scene
|
code += "mesh.rotation.y = " + rotation.y + ";\n";
|
||||||
*/
|
code += "mesh.rotation.z = " + rotation.z + ";\n";
|
||||||
var mInverse = new THREE.Matrix4().getInverse( crosshair.matrixWorld );
|
|
||||||
particle.position.applyMatrix4( mInverse );
|
|
||||||
|
|
||||||
|
code += "mesh.scale.x = " + scale.x + ";\n";
|
||||||
|
code += "mesh.scale.y = " + scale.y + ";\n";
|
||||||
|
code += "mesh.scale.z = " + scale.z + ";\n";
|
||||||
|
|
||||||
|
code += "mesh.updateInstance();\n\n";
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
var particleEngine = GameLib.EntityManager.Instance.findComponentById('mwnydjz3ez');
|
var code = '';
|
||||||
var particle = GameLib.EntityManager.Instance.findComponentById('ks1yk4yi1n');
|
|
||||||
|
|
||||||
var flamethrower = GameLib.EntityManager.Instance.findComponentById('y548ddx1ff');
|
var meshes = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Mesh);
|
||||||
var worldCamera = GameLib.EntityManager.Instance.findComponentById('zc2pq229fq');
|
|
||||||
|
|
||||||
var end = ;
|
meshes.map(
|
||||||
|
function(mesh) {
|
||||||
|
if (mesh.name.indexOf('Tree - Small Clone') !== -1) {
|
||||||
|
code += codeSnippet('treeSmall', mesh.rotation, mesh.scale, mesh.position);
|
||||||
|
}
|
||||||
|
if (mesh.name.indexOf('Tree - Medium Clone') !== -1) {
|
||||||
|
code += codeSnippet('treeMedium', mesh.rotation, mesh.scale, mesh.position);
|
||||||
|
}
|
||||||
|
if (mesh.name.indexOf('Tree - Large Clone') !== -1) {
|
||||||
|
code += codeSnippet('treeLarge', mesh.rotation, mesh.scale, mesh.position);
|
||||||
|
}
|
||||||
|
if (mesh.name.indexOf('Stone 1 Clone') !== -1) {
|
||||||
|
code += codeSnippet('stone1', mesh.rotation, mesh.scale, mesh.position);
|
||||||
|
}
|
||||||
|
if (mesh.name.indexOf('Stone 2 Clone') !== -1) {
|
||||||
|
code += codeSnippet('stone2', mesh.rotation, mesh.scale, mesh.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
end.unproject(worldCamera.instance);
|
console.log(code);
|
||||||
|
|
||||||
|
|
||||||
//var crosshairPosition = crosshair.position.instance.clone();
|
|
||||||
//var flamethrowerPosition = worldCamera.position.instance.clone();
|
|
||||||
|
|
||||||
var direction = worldCamera.position.instance.clone().sub(end).normalize().negate();
|
|
||||||
|
|
||||||
|
|
||||||
console.log(direction);
|
|
||||||
|
|
||||||
particle.instance.position.x = worldCamera.position.x;// + direction.x * 0.3;
|
|
||||||
particle.instance.position.y = worldCamera.position.y;// + direction.y * 0.3;
|
|
||||||
particle.instance.position.z = worldCamera.position.z;// + direction.z * 0.3;
|
|
||||||
|
|
||||||
var sensitivity = 0.1;
|
|
||||||
|
|
||||||
particle.direction.instance.x = direction.x * sensitivity;
|
|
||||||
particle.direction.instance.y = direction.y * sensitivity;
|
|
||||||
particle.direction.instance.z = direction.z * sensitivity;
|
|
||||||
|
|
||||||
particleEngine.enabled = true;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
//@ sourceURL=mouseDown.js
|
//@ sourceURL=mouseDown.js
|
Loading…
Reference in New Issue