mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Merge pull request #9420 from sethalves/tablet-ui-model-stylus
Tablet ui model stylus
This commit is contained in:
commit
a1efb7695b
1 changed files with 13 additions and 60 deletions
|
@ -65,7 +65,8 @@ var WEB_STYLUS_COLOR = { red: 0, green: 240, blue: 0 };
|
||||||
var WEB_STYLUS_TIP_COLOR = { red: 0, green: 0, blue: 240 };
|
var WEB_STYLUS_TIP_COLOR = { red: 0, green: 0, blue: 240 };
|
||||||
var WEB_STYLUS_ALPHA = 1.0;
|
var WEB_STYLUS_ALPHA = 1.0;
|
||||||
var WEB_DISPLAY_STYLUS_DISTANCE = 0.5;
|
var WEB_DISPLAY_STYLUS_DISTANCE = 0.5;
|
||||||
var WEB_TOUCH_DISTANCE = 0.2;
|
var WEB_STYLUS_LENGTH = 0.2;
|
||||||
|
var WEB_TOUCH_Y_OFFSET = 0.05; // how far forward (or back with a negative number) to slide stylus in hand
|
||||||
|
|
||||||
//
|
//
|
||||||
// distant manipulation
|
// distant manipulation
|
||||||
|
@ -947,7 +948,7 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showModelStylus = function() {
|
this.showStylus = function() {
|
||||||
if (this.stylus) {
|
if (this.stylus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -956,13 +957,13 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var stylusProperties = {
|
var stylusProperties = {
|
||||||
// url: Script.resourcesPath() + "meshes/tablet-stylus-skinny.fbx",
|
|
||||||
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
|
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
|
||||||
localPosition: Vec3.sum({ x: 0.0, y: WEB_TOUCH_DISTANCE / 2.0, z: 0.0 },
|
localPosition: Vec3.sum({ x: 0.0,
|
||||||
|
y: WEB_TOUCH_Y_OFFSET,
|
||||||
|
z: 0.0 },
|
||||||
getGrabPointSphereOffset(this.handToController())),
|
getGrabPointSphereOffset(this.handToController())),
|
||||||
// localRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
||||||
localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }),
|
localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }),
|
||||||
// dimensions: { x: 0.01, y: WEB_TOUCH_DISTANCE - WEB_TOUCH_SPHERE_RADIUS, z: 0.01 },
|
dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH },
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
|
@ -975,56 +976,6 @@ function MyController(hand) {
|
||||||
this.stylus = Overlays.addOverlay("model", stylusProperties);
|
this.stylus = Overlays.addOverlay("model", stylusProperties);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.showPrimStylus = function() {
|
|
||||||
if (this.stylus) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!MyAvatar.sessionUUID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var stylusTipProperties = {
|
|
||||||
localPosition: Vec3.sum({ x: 0, y: WEB_TOUCH_DISTANCE - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 },
|
|
||||||
getGrabPointSphereOffset(this.handToController())),
|
|
||||||
localRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
||||||
dimensions: WEB_TOUCH_SPHERE_RADIUS,
|
|
||||||
color: WEB_STYLUS_TIP_COLOR,
|
|
||||||
alpha: WEB_STYLUS_ALPHA,
|
|
||||||
solid: true,
|
|
||||||
visible: true,
|
|
||||||
ignoreRayIntersection: true,
|
|
||||||
drawInFront: false,
|
|
||||||
parentID: MyAvatar.sessionUUID,
|
|
||||||
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
|
||||||
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
|
|
||||||
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND")
|
|
||||||
};
|
|
||||||
this.stylusTip = Overlays.addOverlay("sphere", stylusTipProperties);
|
|
||||||
|
|
||||||
var stylusProperties = {
|
|
||||||
localPosition: Vec3.sum({ x: 0.0, y: WEB_TOUCH_DISTANCE / 2.0, z: 0.0 },
|
|
||||||
getGrabPointSphereOffset(this.handToController())),
|
|
||||||
localRotation: { x: 0, y: 0, z: 0, w: 1 },
|
|
||||||
dimensions: { x: 0.01, y: WEB_TOUCH_DISTANCE - WEB_TOUCH_SPHERE_RADIUS, z: 0.01 },
|
|
||||||
color: WEB_STYLUS_COLOR,
|
|
||||||
alpha: WEB_STYLUS_ALPHA,
|
|
||||||
solid: true,
|
|
||||||
visible: true,
|
|
||||||
ignoreRayIntersection: true,
|
|
||||||
drawInFront: false,
|
|
||||||
parentID: MyAvatar.sessionUUID,
|
|
||||||
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
|
||||||
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
|
|
||||||
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND")
|
|
||||||
};
|
|
||||||
this.stylus = Overlays.addOverlay("cube", stylusProperties);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.showStylus = function() {
|
|
||||||
return this.showPrimStylus();
|
|
||||||
// return this.showModelStylus();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.hideStylus = function() {
|
this.hideStylus = function() {
|
||||||
if (!this.stylus) {
|
if (!this.stylus) {
|
||||||
return;
|
return;
|
||||||
|
@ -1263,7 +1214,7 @@ function MyController(hand) {
|
||||||
if (nearWeb) {
|
if (nearWeb) {
|
||||||
this.showStylus();
|
this.showStylus();
|
||||||
var rayPickInfo = this.calcRayPickInfo(this.hand);
|
var rayPickInfo = this.calcRayPickInfo(this.hand);
|
||||||
if (rayPickInfo.distance < WEB_TOUCH_DISTANCE) {
|
if (rayPickInfo.distance < WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
|
||||||
if (this.handleStylusOnWebEntity(rayPickInfo)) {
|
if (this.handleStylusOnWebEntity(rayPickInfo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1662,7 +1613,7 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rayPickInfo.distance >= WEB_TOUCH_DISTANCE) {
|
if (rayPickInfo.distance >= WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
|
||||||
if (this.handleLaserOnWebEntity(rayPickInfo)) {
|
if (this.handleLaserOnWebEntity(rayPickInfo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2761,7 +2712,8 @@ function MyController(hand) {
|
||||||
getControllerWorldLocation(this.handToController(), true));
|
getControllerWorldLocation(this.handToController(), true));
|
||||||
if (intersectInfo) {
|
if (intersectInfo) {
|
||||||
|
|
||||||
if (this.state == STATE_ENTITY_STYLUS_TOUCHING && intersectInfo.distance > WEB_TOUCH_DISTANCE) {
|
if (this.state == STATE_ENTITY_STYLUS_TOUCHING &&
|
||||||
|
intersectInfo.distance > WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
|
||||||
this.grabbedEntity = null;
|
this.grabbedEntity = null;
|
||||||
this.setState(STATE_OFF, "pulled away from web entity");
|
this.setState(STATE_OFF, "pulled away from web entity");
|
||||||
return;
|
return;
|
||||||
|
@ -2879,7 +2831,8 @@ function MyController(hand) {
|
||||||
handLaserIntersectOverlay(this.grabbedOverlay, getControllerWorldLocation(this.handToController(), true));
|
handLaserIntersectOverlay(this.grabbedOverlay, getControllerWorldLocation(this.handToController(), true));
|
||||||
if (intersectInfo) {
|
if (intersectInfo) {
|
||||||
|
|
||||||
if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && intersectInfo.distance > WEB_TOUCH_DISTANCE) {
|
if (this.state == STATE_OVERLAY_STYLUS_TOUCHING &&
|
||||||
|
intersectInfo.distance > WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
|
||||||
this.grabbedEntity = null;
|
this.grabbedEntity = null;
|
||||||
this.setState(STATE_OFF, "pulled away from overlay");
|
this.setState(STATE_OFF, "pulled away from overlay");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue