mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
fixing hyper link for entities
This commit is contained in:
parent
1f4aed31f1
commit
05fb3cfd9a
3 changed files with 97 additions and 2 deletions
|
@ -0,0 +1,93 @@
|
|||
"use strict";
|
||||
|
||||
// nearActionGrabEntity.js
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
|
||||
getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule,
|
||||
propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
|
||||
Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
|
||||
TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity,
|
||||
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE
|
||||
*/
|
||||
|
||||
(function() {
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
Script.include("/~/system/libraries/controllers.js");
|
||||
|
||||
function NearGrabHyperLinkEntity(hand) {
|
||||
this.hand = hand;
|
||||
this.targetEntityID = null;
|
||||
this.hyperlink = "";
|
||||
|
||||
this.parameters = makeDispatcherModuleParameters(
|
||||
485,
|
||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||
[],
|
||||
100);
|
||||
|
||||
|
||||
this.getTargetProps = function(controllerData) {
|
||||
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
|
||||
var props = nearbyEntitiesProperties[i];
|
||||
if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
||||
continue;
|
||||
}
|
||||
if (props.href !== "" && props.href !== undefined) {
|
||||
return props;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
this.isReady = function(controllerData) {
|
||||
this.targetEntityID = null;
|
||||
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
|
||||
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
var targetProps = this.getTargetProps(controllerData);
|
||||
if (targetProps) {
|
||||
this.hyperlink = targetProps.href;
|
||||
this.targetEntityID = targetProps.id;
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
||||
this.run = function(controllerData) {
|
||||
if ((controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
|
||||
controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) || this.hyperlink === "") {
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
if (controllerData.triggerClicks[this.hand] ||
|
||||
controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
|
||||
AddressManager.handleLookupString(this.hyperlink);
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
};
|
||||
}
|
||||
|
||||
var leftNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(LEFT_HAND);
|
||||
var rightNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(RIGHT_HAND);
|
||||
|
||||
enableDispatcherModule("LeftNearGrabHyperLink", leftNearGrabHyperLinkEntity);
|
||||
enableDispatcherModule("RightNearGrabHyperLink", rightNearGrabHyperLinkEntity);
|
||||
|
||||
function cleanup() {
|
||||
disableDispatcherModule("LeftNearGrabHyperLink");
|
||||
disableDispactherModule("RightNearGrabHyperLink");
|
||||
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
}());
|
|
@ -31,7 +31,8 @@ var CONTOLLER_SCRIPTS = [
|
|||
"controllerModules/scaleAvatar.js",
|
||||
"controllerModules/hudOverlayPointer.js",
|
||||
"controllerModules/mouseHMD.js",
|
||||
"controllerModules/scaleEntity.js"
|
||||
"controllerModules/scaleEntity.js",
|
||||
"controllerModules/nearGrabHyperLinkEntity.js"
|
||||
];
|
||||
|
||||
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
|
||||
|
|
|
@ -105,7 +105,8 @@ DISPATCHER_PROPERTIES = [
|
|||
"density",
|
||||
"dimensions",
|
||||
"userData",
|
||||
"type"
|
||||
"type",
|
||||
"href"
|
||||
];
|
||||
|
||||
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
|
||||
|
|
Loading…
Reference in a new issue