Quellcode durchsuchen

Not much

master
Pete Shadbolt vor 8 Jahren
Ursprung
Commit
41a83246f2
2 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. +15
    -5
      static/scripts/editor.js
  2. +1
    -1
      static/scripts/gui.js

+ 15
- 5
static/scripts/editor.js Datei anzeigen

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


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


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


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


// Gets a reference to the node nearest to the mouse cursor // Gets a reference to the node nearest to the mouse cursor
editor.nearestNode = function(ray) { 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; return undefined;
@@ -54,8 +62,10 @@ editor.makeGimbal = function(center) {
new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 0, -1) new THREE.Vector3(0, 0, -1)
]; ];
editor.gimbalVertices = pointGeometry.vertices;
var tips = new THREE.Points(pointGeometry, materials.tip); var tips = new THREE.Points(pointGeometry, materials.tip);


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


+ 1
- 1
static/scripts/gui.js Datei anzeigen

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


// Someone resized the window // Someone resized the window


Laden…
Abbrechen
Speichern