added isLocked() to lock the ground plane in hq

This commit is contained in:
ZappoMan 2014-05-18 20:31:55 -07:00
parent 0c4727d459
commit 31ae7ceaff

View file

@ -117,13 +117,18 @@ function controller(wichSide) {
this.grab = function (modelID, properties) { this.grab = function (modelID, properties) {
print("Grabbing " + modelID.id); if (this.isLocked(properties)) {
this.grabbing = true; print("Model locked " + modelID.id);
this.modelID = modelID; } else {
print("Grabbing " + modelID.id);
this.oldModelPosition = properties.position; this.grabbing = true;
this.oldModelRotation = properties.modelRotation; this.modelID = modelID;
this.oldModelRadius = properties.radius;
this.oldModelPosition = properties.position;
this.oldModelRotation = properties.modelRotation;
this.oldModelRadius = properties.radius;
}
} }
this.release = function () { this.release = function () {
@ -144,8 +149,24 @@ function controller(wichSide) {
this.pressed = false; this.pressed = false;
} }
} }
this.isLocked = function (properties) {
// special case to lock the ground plane model in hq.
if (location.hostname == "hq.highfidelity.io" &&
properties.modelURL == "https://s3-us-west-1.amazonaws.com/highfidelity-public/ozan/Terrain_Reduce_forAlpha.fbx") {
return true;
}
return false;
}
this.checkModel = function (properties) { this.checkModel = function (properties) {
// special case to lock the ground plane model in hq.
if (location.hostname == "hq.highfidelity.io" &&
properties.modelURL == "https://s3-us-west-1.amazonaws.com/highfidelity-public/ozan/Terrain_Reduce_forAlpha.fbx") {
return { valid: false };
}
// P P - Model // P P - Model
// /| A - Palm // /| A - Palm
// / | d B - unit vector toward tip // / | d B - unit vector toward tip
@ -285,15 +306,18 @@ function controller(wichSide) {
} }
var properties = Models.getModelProperties(foundModels[i]); var properties = Models.getModelProperties(foundModels[i]);
print("Checking properties: " + properties.id + " " + properties.isKnownID); if (this.isLocked(properties)) {
print("Model locked " + properties.id);
var check = this.checkModel(properties); } else {
if (check.valid) { print("Checking properties: " + properties.id + " " + properties.isKnownID);
this.grab(foundModels[i], properties); var check = this.checkModel(properties);
this.x = check.x; if (check.valid) {
this.y = check.y; this.grab(foundModels[i], properties);
this.z = check.z; this.x = check.x;
return; this.y = check.y;
this.z = check.z;
return;
}
} }
} }
} }
@ -463,51 +487,54 @@ function mousePressEvent(event) {
} }
var properties = Models.getModelProperties(foundModels[i]); var properties = Models.getModelProperties(foundModels[i]);
print("Checking properties: " + properties.id + " " + properties.isKnownID); if (this.isLocked(properties)) {
print("Model locked " + properties.id);
} else {
print("Checking properties: " + properties.id + " " + properties.isKnownID);
// P P - Model
// /| A - Palm
// / | d B - unit vector toward tip
// / | X - base of the perpendicular line
// A---X----->B d - distance fom axis
// x x - distance from A
//
// |X-A| = (P-A).B
// X == A + ((P-A).B)B
// d = |P-X|
// P P - Model var A = pickRay.origin;
// /| A - Palm var B = Vec3.normalize(pickRay.direction);
// / | d B - unit vector toward tip var P = properties.position;
// / | X - base of the perpendicular line
// A---X----->B d - distance fom axis
// x x - distance from A
//
// |X-A| = (P-A).B
// X == A + ((P-A).B)B
// d = |P-X|
var A = pickRay.origin; var x = Vec3.dot(Vec3.subtract(P, A), B);
var B = Vec3.normalize(pickRay.direction); var X = Vec3.sum(A, Vec3.multiply(B, x));
var P = properties.position; var d = Vec3.length(Vec3.subtract(P, X));
var x = Vec3.dot(Vec3.subtract(P, A), B); if (d < properties.radius && 0 < x && x < LASER_LENGTH_FACTOR) {
var X = Vec3.sum(A, Vec3.multiply(B, x)); modelSelected = true;
var d = Vec3.length(Vec3.subtract(P, X)); selectedModelID = foundModels[i];
selectedModelProperties = properties;
if (d < properties.radius && 0 < x && x < LASER_LENGTH_FACTOR) {
modelSelected = true;
selectedModelID = foundModels[i];
selectedModelProperties = properties;
selectedModelProperties.oldRadius = selectedModelProperties.radius; selectedModelProperties.oldRadius = selectedModelProperties.radius;
selectedModelProperties.oldPosition = { selectedModelProperties.oldPosition = {
x: selectedModelProperties.position.x, x: selectedModelProperties.position.x,
y: selectedModelProperties.position.y, y: selectedModelProperties.position.y,
z: selectedModelProperties.position.z, z: selectedModelProperties.position.z,
}; };
selectedModelProperties.oldRotation = { selectedModelProperties.oldRotation = {
x: selectedModelProperties.modelRotation.x, x: selectedModelProperties.modelRotation.x,
y: selectedModelProperties.modelRotation.y, y: selectedModelProperties.modelRotation.y,
z: selectedModelProperties.modelRotation.z, z: selectedModelProperties.modelRotation.z,
w: selectedModelProperties.modelRotation.w, w: selectedModelProperties.modelRotation.w,
}; };
orientation = MyAvatar.orientation; orientation = MyAvatar.orientation;
intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation)); intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation));
print("Clicked on " + selectedModelID.id + " " + modelSelected);
return; print("Clicked on " + selectedModelID.id + " " + modelSelected);
return;
}
} }
} }
} }