Bläddra i källkod

Not much

master
Pete Shadbolt 8 år sedan
förälder
incheckning
41a83246f2
2 ändrade filer med 16 tillägg och 6 borttagningar
  1. +15
    -5
      static/scripts/editor.js
  2. +1
    -1
      static/scripts/gui.js

+ 15
- 5
static/scripts/editor.js Visa fil

@@ -1,5 +1,6 @@
var editor = {};
editor.nearest = undefined;
editor.gimbalVertices = [];

editor.onFreeMove = function() {
var n = editor.nearestNode(mouse.ray);
@@ -16,14 +17,14 @@ editor.onFreeMove = function() {

editor.onClick = function() {
var n = editor.nearestNode(mouse.ray);
if (n) {
//if (n.type=="node") {
var p = abj.meta[n].position;
editor.gimbal.position.set(p.x, p.y, p.z);
gui.controls.target.set(p.x, p.y, p.z);
gui.hideNodeMessage();
editor.nearest = undefined;
gui.render();
}
//}
};

editor.prepare = function() {
@@ -34,9 +35,16 @@ editor.prepare = function() {

// Gets a reference to the node nearest to the mouse cursor
editor.nearestNode = function(ray) {
for (var i in abj.meta) {
if (ray.distanceSqToPoint(abj.meta[i].position) < 0.03) {
return i;
for (var i=0; i < editor.gimbalVertices.length; ++i) {
if (ray.distanceSqToPoint(editor.gimbalVertices[i]) < 0.03) {
//return {type: "gimbal", node: i};
}
}

for (var j in abj.meta) {
if (ray.distanceSqToPoint(abj.meta[j].position) < 0.03) {
//return {type: "node", node: i};
return j;
}
}
return undefined;
@@ -54,8 +62,10 @@ editor.makeGimbal = function(center) {
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 0, -1)
];
editor.gimbalVertices = pointGeometry.vertices;
var tips = new THREE.Points(pointGeometry, materials.tip);

editor.gimbal.add(tips);
gui.scene.add(editor.gimbal);
};


+ 1
- 1
static/scripts/gui.js Visa fil

@@ -17,7 +17,7 @@ gui.prepare = function() {
gui.controls.target.set(0, 0, 0);
gui.controls.rotateSpeed = 0.2;
gui.controls.userPanSpeed = 0.1;
gui.camera.position.set(4, 4, 10);
gui.camera.position.set(0, 0, 10);
};

// Someone resized the window


Laddar…
Avbryt
Spara