Showing the changes to scripts/system/controllers/controllerModules (14 of 80 files). Show all
Unified · Split
| @@ -1,15 +1,13 @@ | ||
| 1 | 1 | "use strict"; |
| 2 | 2 | |
| 3 | −// nearTrigger.js | |
| 3 | +// disableOtherModule.js | |
| 4 | 4 | // |
| 5 | 5 | // Distributed under the Apache License, Version 2.0. |
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | 8 | |
| 9 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, | |
| 10 | − enableDispatcherModule, disableDispatcherModule, getGrabbableData, Vec3, | |
| 11 | − TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS, | |
| 12 | − getEnabledModuleByName | |
| 9 | +/* global Script, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, | |
| 10 | + makeDispatcherModuleParameters, makeRunningValues, getEnabledModuleByName, Messages | |
| 13 | 11 | */ |
| 14 | 12 | |
| 15 | 13 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -20,7 +18,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 4 unmodified lines | ||
| 20 | 18 | this.disableModules = false; |
| 21 | 19 | this.parameters = makeDispatcherModuleParameters( |
| 22 | 20 | 90, |
| 23 | − this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"], | |
| 21 | + this.hand === RIGHT_HAND ? | |
| 22 | + ["rightHand", "rightHandEquip", "rightHandTrigger"] : | |
| 23 | + ["leftHand", "leftHandEquip", "leftHandTrigger"], | |
| 24 | 24 | [], |
| 25 | 25 | 100); |
| 26 | 26 | |
| @@ -37,11 +37,11 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 10 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | if (teleportModule) { |
| 39 | 39 | var ready = teleportModule.isReady(controllerData); |
| 40 | − if (ready) { | |
| 40 | + if (ready.active) { | |
| 41 | 41 | return makeRunningValues(false, [], []); |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | − if (!this.disablemodules) { | |
| 44 | + if (!this.disableModules) { | |
| 45 | 45 | return makeRunningValues(false, [], []); |
| 46 | 46 | } |
| 47 | 47 | return makeRunningValues(true, [], []); |
| @@ -61,7 +61,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 13 unmodified lines | ||
| 61 | 61 | } |
| 62 | 62 | if (message === 'right') { |
| 63 | 63 | rightDisableModules.disableModules = true; |
| 64 | − | |
| 65 | 64 | } |
| 66 | 65 | if (message === 'both' || message === 'none') { |
| 67 | 66 | if (message === 'both') { |
| @@ -75,7 +74,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 7 unmodified lines | ||
| 75 | 74 | } |
| 76 | 75 | } |
| 77 | 76 | }; |
| 78 | − | |
| 77 | + | |
| 79 | 78 | Messages.subscribe('Hifi-Hand-Disabler'); |
| 80 | 79 | this.cleanup = function() { |
| 81 | 80 | disableDispatcherModule("LeftDisableModules"); |
| @@ -602,11 +602,8 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa · 601 unmodified lines | ||
| 602 | 602 | }; |
| 603 | 603 | |
| 604 | 604 | this.isTargetIDValid = function() { |
| 605 | − var entityProperties = Entities.getEntityProperties(this.targetEntityID); | |
| 606 | − for (var propertry in entityProperties) { | |
| 607 | − return true; | |
| 608 | − } | |
| 609 | − return false; | |
| 605 | + var entityProperties = Entities.getEntityProperties(this.targetEntityID, ["type"]); | |
| 606 | + return "type" in entityProperties; | |
| 610 | 607 | }; |
| 611 | 608 | |
| 612 | 609 | this.isReady = function (controllerData, deltaTime) { |
| @@ -13,7 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, |
| 14 | 14 | PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, |
| 15 | 15 | AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, |
| 16 | − getControllerWorldLocation, projectOntoEntityXYPlane | |
| 16 | + getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays | |
| 17 | 17 | |
| 18 | 18 | */ |
| 19 | 19 | |
| @@ -236,10 +236,10 @@ Script.include("/~/system/libraries/controllers.js"); · 216 unmodified lines | ||
| 236 | 236 | this.actionID = null; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | − // XXX | |
| 240 | − // if (this.actionID !== null) { | |
| 241 | − // this.callEntityMethodOnGrabbed("startDistanceGrab"); | |
| 242 | − // } | |
| 239 | + if (this.actionID !== null) { | |
| 240 | + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; | |
| 241 | + Entities.callEntityMethod(this.grabbedThingID, "startDistanceGrab", args); | |
| 242 | + } | |
| 243 | 243 | |
| 244 | 244 | Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); |
| 245 | 245 | this.previousRoomControllerPosition = roomControllerPosition; |
| @@ -271,8 +271,8 @@ Script.include("/~/system/libraries/controllers.js"); · 25 unmodified lines | ||
| 271 | 271 | var handMoved = Vec3.multiply(worldHandDelta, radius); |
| 272 | 272 | this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, handMoved); |
| 273 | 273 | |
| 274 | − // XXX | |
| 275 | − // this.callEntityMethodOnGrabbed("continueDistantGrab"); | |
| 274 | + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; | |
| 275 | + Entities.callEntityMethod(this.grabbedThingID, "continueDistanceGrab", args); | |
| 276 | 276 | |
| 277 | 277 | // Update radialVelocity |
| 278 | 278 | var lastVelocity = Vec3.multiply(worldHandDelta, 1.0 / deltaObjectTime); |
| @@ -335,6 +335,10 @@ Script.include("/~/system/libraries/controllers.js"); · 56 unmodified lines | ||
| 335 | 335 | this.distanceHolding = false; |
| 336 | 336 | this.distanceRotating = false; |
| 337 | 337 | Entities.deleteAction(this.grabbedThingID, this.actionID); |
| 338 | + | |
| 339 | + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; | |
| 340 | + Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args); | |
| 341 | + | |
| 338 | 342 | this.actionID = null; |
| 339 | 343 | this.grabbedThingID = null; |
| 340 | 344 | }; |
| @@ -343,7 +347,8 @@ Script.include("/~/system/libraries/controllers.js"); · 2 unmodified lines | ||
| 343 | 347 | var intersection = controllerData.rayPicks[this.hand]; |
| 344 | 348 | var entityProperty = Entities.getEntityProperties(intersection.objectID); |
| 345 | 349 | var entityType = entityProperty.type; |
| 346 | − if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") || intersection.type === RayPick.INTERSECTED_OVERLAY) { | |
| 350 | + if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") || | |
| 351 | + intersection.type === RayPick.INTERSECTED_OVERLAY) { | |
| 347 | 352 | return true; |
| 348 | 353 | } |
| 349 | 354 | return false; |
| @@ -354,7 +359,8 @@ Script.include("/~/system/libraries/controllers.js"); · 4 unmodified lines | ||
| 354 | 359 | this.distanceHolding = false; |
| 355 | 360 | |
| 356 | 361 | var worldControllerRotation = getControllerWorldLocation(this.handToController(), true).orientation; |
| 357 | − var controllerRotationDelta = Quat.multiply(worldControllerRotation, Quat.inverse(this.previousWorldControllerRotation)); | |
| 362 | + var controllerRotationDelta = | |
| 363 | + Quat.multiply(worldControllerRotation, Quat.inverse(this.previousWorldControllerRotation)); | |
| 358 | 364 | // Rotate entity by twice the delta rotation. |
| 359 | 365 | controllerRotationDelta = Quat.multiply(controllerRotationDelta, controllerRotationDelta); |
| 360 | 366 | |
| @@ -426,7 +432,8 @@ Script.include("/~/system/libraries/controllers.js"); · 65 unmodified lines | ||
| 426 | 432 | }; |
| 427 | 433 | |
| 428 | 434 | this.run = function (controllerData) { |
| 429 | − if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.notPointingAtEntity(controllerData) || this.isPointingAtUI(controllerData)) { | |
| 435 | + if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || | |
| 436 | + this.notPointingAtEntity(controllerData) || this.isPointingAtUI(controllerData)) { | |
| 430 | 437 | this.endNearGrabAction(); |
| 431 | 438 | this.laserPointerOff(); |
| 432 | 439 | return makeRunningValues(false, [], []); |
| @@ -471,6 +478,7 @@ Script.include("/~/system/libraries/controllers.js"); · 38 unmodified lines | ||
| 471 | 478 | for (var j = 0; j < nearGrabReadiness.length; j++) { |
| 472 | 479 | if (nearGrabReadiness[j].active) { |
| 473 | 480 | this.laserPointerOff(); |
| 481 | + this.endNearGrabAction(); | |
| 474 | 482 | return makeRunningValues(false, [], []); |
| 475 | 483 | } |
| 476 | 484 | } |
| @@ -555,7 +563,7 @@ Script.include("/~/system/libraries/controllers.js"); · 78 unmodified lines | ||
| 555 | 563 | joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", |
| 556 | 564 | filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, |
| 557 | 565 | maxDistance: PICK_MAX_DISTANCE, |
| 558 | − posOffset: getGrabPointSphereOffset(this.handToController()), | |
| 566 | + posOffset: getGrabPointSphereOffset(this.handToController(), true), | |
| 559 | 567 | renderStates: renderStates, |
| 560 | 568 | faceAvatar: true, |
| 561 | 569 | defaultRenderStates: defaultRenderStates |
| @@ -6,14 +6,10 @@ · 5 unmodified lines | ||
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | 8 | |
| 9 | −/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat, | |
| 10 | − getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID, | |
| 11 | − enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable, | |
| 12 | − makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, | |
| 9 | +/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, MyAvatar, getGrabPointSphereOffset, | |
| 10 | + makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, | |
| 13 | 11 | PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, |
| 14 | − AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, | |
| 15 | − getControllerWorldLocation, projectOntoEntityXYPlane, getGrabbableData | |
| 16 | − | |
| 12 | + AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData | |
| 17 | 13 | */ |
| 18 | 14 | |
| 19 | 15 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -202,7 +198,7 @@ Script.include("/~/system/libraries/controllers.js"); · 182 unmodified lines | ||
| 202 | 198 | joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", |
| 203 | 199 | filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, |
| 204 | 200 | maxDistance: PICK_MAX_DISTANCE, |
| 205 | − posOffset: getGrabPointSphereOffset(this.handToController()), | |
| 201 | + posOffset: getGrabPointSphereOffset(this.handToController(), true), | |
| 206 | 202 | renderStates: renderStates, |
| 207 | 203 | faceAvatar: true, |
| 208 | 204 | defaultRenderStates: defaultRenderStates |
| @@ -5,13 +5,12 @@ · 4 unmodified lines | ||
| 5 | 5 | // Distributed under the Apache License, Version 2.0. |
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, | |
| 9 | − NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues, | |
| 10 | − Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC, | |
| 11 | − AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset, | |
| 12 | − COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, | |
| 13 | − DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, | |
| 14 | − isInEditMode | |
| 8 | +/* jslint bitwise: true */ | |
| 9 | + | |
| 10 | +/* global Script, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, makeRunningValues, | |
| 11 | + Messages, makeDispatcherModuleParameters, AVATAR_SELF_ID, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, | |
| 12 | + COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, | |
| 13 | + getEnabledModuleByName, PICK_MAX_DISTANCE, isInEditMode, LaserPointers, RayPick | |
| 15 | 14 | */ |
| 16 | 15 | |
| 17 | 16 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -239,7 +238,7 @@ Script.include("/~/system/libraries/utils.js"); · 221 unmodified lines | ||
| 239 | 238 | joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", |
| 240 | 239 | filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, |
| 241 | 240 | maxDistance: PICK_MAX_DISTANCE, |
| 242 | − posOffset: getGrabPointSphereOffset(this.handToController()), | |
| 241 | + posOffset: getGrabPointSphereOffset(this.handToController(), true), | |
| 243 | 242 | renderStates: renderStates, |
| 244 | 243 | faceAvatar: true, |
| 245 | 244 | defaultRenderStates: defaultRenderStates |
| @@ -111,6 +111,9 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 110 unmodified lines | ||
| 111 | 111 | grabbedEntity: this.targetEntityID, |
| 112 | 112 | joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand" |
| 113 | 113 | })); |
| 114 | + | |
| 115 | + var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; | |
| 116 | + Entities.callEntityMethod(this.targetEntityID, "startNearGrab", args); | |
| 114 | 117 | }; |
| 115 | 118 | |
| 116 | 119 | // this is for when the action is going to time-out |
| @@ -147,10 +150,10 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 30 unmodified lines | ||
| 147 | 150 | this.getTargetProps = function (controllerData) { |
| 148 | 151 | // nearbyEntityProperties is already sorted by distance from controller |
| 149 | 152 | var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; |
| 153 | + var sensorScaleFactor = MyAvatar.sensorToWorldScale; | |
| 150 | 154 | for (var i = 0; i < nearbyEntityProperties.length; i++) { |
| 151 | 155 | var props = nearbyEntityProperties[i]; |
| 152 | − var handPosition = controllerData.controllerLocations[this.hand].position; | |
| 153 | − if (props.distance > NEAR_GRAB_RADIUS) { | |
| 156 | + if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) { | |
| 154 | 157 | break; |
| 155 | 158 | } |
| 156 | 159 | if (entityIsGrabbable(props) || entityIsCloneable(props)) { |
| @@ -173,7 +176,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 16 unmodified lines | ||
| 173 | 176 | this.targetEntityID = null; |
| 174 | 177 | |
| 175 | 178 | var targetProps = this.getTargetProps(controllerData); |
| 176 | − if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 179 | + if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && | |
| 180 | + controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 177 | 181 | return makeRunningValues(false, [], []); |
| 178 | 182 | } |
| 179 | 183 | |
| @@ -192,7 +196,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines | ||
| 192 | 196 | |
| 193 | 197 | this.run = function (controllerData) { |
| 194 | 198 | if (this.actionID) { |
| 195 | − if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 199 | + if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && | |
| 200 | + controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 196 | 201 | this.endNearGrabAction(); |
| 197 | 202 | this.hapticTargetID = null; |
| 198 | 203 | return makeRunningValues(false, [], []); |
| @@ -6,11 +6,10 @@ · 5 unmodified lines | ||
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | 8 | |
| 9 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, | |
| 10 | − getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, | |
| 11 | − propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, | |
| 12 | − makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, | |
| 13 | − findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE | |
| 9 | +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, | |
| 10 | + enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, | |
| 11 | + TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent, | |
| 12 | + Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE | |
| 14 | 13 | */ |
| 15 | 14 | |
| 16 | 15 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -147,11 +146,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 130 unmodified lines | ||
| 147 | 146 | this.getTargetProps = function (controllerData) { |
| 148 | 147 | // nearbyEntityProperties is already sorted by length from controller |
| 149 | 148 | var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; |
| 149 | + var sensorScaleFactor = MyAvatar.sensorToWorldScale; | |
| 150 | 150 | for (var i = 0; i < nearbyEntityProperties.length; i++) { |
| 151 | 151 | var props = nearbyEntityProperties[i]; |
| 152 | 152 | var handPosition = controllerData.controllerLocations[this.hand].position; |
| 153 | 153 | var distance = Vec3.distance(props.position, handPosition); |
| 154 | − if (distance > NEAR_GRAB_RADIUS) { | |
| 154 | + if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) { | |
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | 157 | if (entityIsGrabbable(props)) { |
| @@ -176,7 +176,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 18 unmodified lines | ||
| 176 | 176 | this.grabbing = false; |
| 177 | 177 | |
| 178 | 178 | var targetProps = this.getTargetProps(controllerData); |
| 179 | − if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 179 | + if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && | |
| 180 | + controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 180 | 181 | return makeRunningValues(false, [], []); |
| 181 | 182 | } |
| 182 | 183 | |
| @@ -195,7 +196,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines | ||
| 195 | 196 | |
| 196 | 197 | this.run = function (controllerData, deltaTime) { |
| 197 | 198 | if (this.grabbing) { |
| 198 | − if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 199 | + if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && | |
| 200 | + controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) { | |
| 199 | 201 | this.endNearParentingGrabEntity(); |
| 200 | 202 | this.hapticTargetID = null; |
| 201 | 203 | return makeRunningValues(false, [], []); |
| @@ -6,14 +6,14 @@ · 5 unmodified lines | ||
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | 8 | |
| 9 | −/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, | |
| 10 | − getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, | |
| 11 | − Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, | |
| 12 | − makeDispatcherModuleParameters, Overlays, makeRunningValues | |
| 9 | +/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, | |
| 10 | + enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, | |
| 11 | + makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings, | |
| 12 | + NEAR_GRAB_RADIUS | |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| 16 | −var GRAB_RADIUS = 0.35; | |
| 16 | +Script.include("/~/system/libraries/utils.js"); | |
| 17 | 17 | |
| 18 | 18 | (function() { |
| 19 | 19 | |
| @@ -120,6 +120,11 @@ var GRAB_RADIUS = 0.35; · 100 unmodified lines | ||
| 120 | 120 | } |
| 121 | 121 | Overlays.editOverlay(this.grabbedThingID, reparentProps); |
| 122 | 122 | |
| 123 | + // resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix | |
| 124 | + if (this.grabbedThingID === HMD.tabletID) { | |
| 125 | + resizeTablet(getTabletWidthFromSettings(), reparentProps.parentJointIndex); | |
| 126 | + } | |
| 127 | + | |
| 123 | 128 | Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({ |
| 124 | 129 | action: 'grab', |
| 125 | 130 | grabbedEntity: this.grabbedThingID, |
| @@ -140,17 +145,23 @@ var GRAB_RADIUS = 0.35; · 14 unmodified lines | ||
| 140 | 145 | parentID: this.previousParentID[this.grabbedThingID], |
| 141 | 146 | parentJointIndex: this.previousParentJointIndex[this.grabbedThingID] |
| 142 | 147 | }); |
| 148 | + | |
| 149 | + // resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix | |
| 150 | + if (this.grabbedThingID === HMD.tabletID) { | |
| 151 | + resizeTablet(getTabletWidthFromSettings(), this.previousParentJointIndex[this.grabbedThingID]); | |
| 152 | + } | |
| 143 | 153 | } |
| 144 | 154 | |
| 145 | 155 | this.grabbedThingID = null; |
| 146 | 156 | }; |
| 147 | 157 | |
| 148 | 158 | this.getTargetID = function(overlays, controllerData) { |
| 159 | + var sensorScaleFactor = MyAvatar.sensorToWorldScale; | |
| 149 | 160 | for (var i = 0; i < overlays.length; i++) { |
| 150 | 161 | var overlayPosition = Overlays.getProperty(overlays[i], "position"); |
| 151 | 162 | var handPosition = controllerData.controllerLocations[this.hand].position; |
| 152 | 163 | var distance = Vec3.distance(overlayPosition, handPosition); |
| 153 | − if (distance <= GRAB_RADIUS) { | |
| 164 | + if (distance <= NEAR_GRAB_RADIUS * sensorScaleFactor) { | |
| 154 | 165 | return overlays[i]; |
| 155 | 166 | } |
| 156 | 167 | } |
| @@ -6,9 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | 8 | |
| 9 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, | |
| 10 | − enableDispatcherModule, disableDispatcherModule, getGrabbableData, Vec3, | |
| 11 | − TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS | |
| 9 | +/* global Script, Entities, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, getGrabbableData, | |
| 10 | + Vec3, TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS | |
| 12 | 11 | */ |
| 13 | 12 | |
| 14 | 13 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -37,11 +36,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 22 unmodified lines | ||
| 37 | 36 | this.getTargetProps = function (controllerData) { |
| 38 | 37 | // nearbyEntityProperties is already sorted by length from controller |
| 39 | 38 | var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; |
| 39 | + var sensorScaleFactor = MyAvatar.sensorToWorldScale; | |
| 40 | 40 | for (var i = 0; i < nearbyEntityProperties.length; i++) { |
| 41 | 41 | var props = nearbyEntityProperties[i]; |
| 42 | 42 | var handPosition = controllerData.controllerLocations[this.hand].position; |
| 43 | 43 | var distance = Vec3.distance(props.position, handPosition); |
| 44 | − if (distance > NEAR_GRAB_RADIUS) { | |
| 44 | + if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) { | |
| 45 | 45 | continue; |
| 46 | 46 | } |
| 47 | 47 | if (entityWantsNearTrigger(props)) { |
| @@ -63,7 +63,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 15 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | this.endNearTrigger = function (controllerData) { |
| 65 | 65 | var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID]; |
| 66 | − Entities.callEntityMethod(this.targetEntityID, "endNearTrigger", args); | |
| 66 | + Entities.callEntityMethod(this.targetEntityID, "stopNearTrigger", args); | |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | 69 | this.isReady = function (controllerData) { |
| @@ -5,13 +5,11 @@ · 4 unmodified lines | ||
| 5 | 5 | // Distributed under the Apache License, Version 2.0. |
| 6 | 6 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 7 | 7 | |
| 8 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, | |
| 9 | − NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues, | |
| 10 | − Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC, | |
| 11 | − AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset, | |
| 12 | − COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, | |
| 13 | − DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, | |
| 14 | − DISPATCHER_PROPERTIES | |
| 8 | +/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, NULL_UUID, enableDispatcherModule, disableDispatcherModule, | |
| 9 | + makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, AVATAR_SELF_ID, HMD, | |
| 10 | + INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, | |
| 11 | + COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, | |
| 12 | + TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, LaserPointers, RayPick, ContextOverlay | |
| 15 | 13 | */ |
| 16 | 14 | |
| 17 | 15 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -528,7 +526,7 @@ Script.include("/~/system/libraries/controllers.js"); · 510 unmodified lines | ||
| 528 | 526 | joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", |
| 529 | 527 | filter: RayPick.PICK_OVERLAYS, |
| 530 | 528 | maxDistance: PICK_MAX_DISTANCE, |
| 531 | − posOffset: getGrabPointSphereOffset(this.handToController()), | |
| 529 | + posOffset: getGrabPointSphereOffset(this.handToController(), true), | |
| 532 | 530 | renderStates: renderStates, |
| 533 | 531 | faceAvatar: true, |
| 534 | 532 | defaultRenderStates: defaultRenderStates |
| @@ -7,9 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | // Distributed under the Apache License, Version 2.0. |
| 8 | 8 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 9 | 9 | |
| 10 | −/* global getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, | |
| 11 | − Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, | |
| 12 | − setGrabCommunications, Menu, HMD, isInEditMode, AvatarList */ | |
| 10 | +/* global Script, Vec3, MyAvatar, RIGHT_HAND */ | |
| 13 | 11 | /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ |
| 14 | 12 | |
| 15 | 13 | (function () { |
| @@ -37,7 +35,8 @@ · 21 unmodified lines | ||
| 37 | 35 | }; |
| 38 | 36 | |
| 39 | 37 | this.triggersPressed = function(controllerData) { |
| 40 | − if (controllerData.triggerClicks[this.hand] && controllerData.secondaryValues[this.hand] > dispatcherUtils.BUMPER_ON_VALUE) { | |
| 38 | + if (controllerData.triggerClicks[this.hand] && | |
| 39 | + controllerData.secondaryValues[this.hand] > dispatcherUtils.BUMPER_ON_VALUE) { | |
| 41 | 40 | return true; |
| 42 | 41 | } |
| 43 | 42 | return false; |
| @@ -58,7 +57,8 @@ · 14 unmodified lines | ||
| 58 | 57 | var otherModule = this.getOtherModule(); |
| 59 | 58 | if (this.triggersPressed(controllerData) && otherModule.triggersPressed(controllerData)) { |
| 60 | 59 | if (this.hand === dispatcherUtils.RIGHT_HAND) { |
| 61 | − var scalingCurrentDistance = Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position, | |
| 60 | + var scalingCurrentDistance = | |
| 61 | + Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position, | |
| 62 | 62 | controllerData.controllerLocations[this.otherHand()].position)); |
| 63 | 63 | |
| 64 | 64 | var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale; |
| @@ -8,7 +8,8 @@ · 7 unmodified lines | ||
| 8 | 8 | /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, |
| 9 | 9 | NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues, |
| 10 | 10 | Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC, |
| 11 | − AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset | |
| 11 | + AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset, | |
| 12 | + getEnabledModuleByName | |
| 12 | 13 | */ |
| 13 | 14 | |
| 14 | 15 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -356,7 +357,7 @@ Script.include("/~/system/libraries/controllers.js"); · 341 unmodified lines | ||
| 356 | 357 | this.stylusTip = getControllerWorldLocation(this.handToController(), true); |
| 357 | 358 | |
| 358 | 359 | // translate tip forward according to constant. |
| 359 | − var TIP_OFFSET = {x: 0, y: WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, z: 0}; | |
| 360 | + var TIP_OFFSET = Vec3.multiply(MyAvatar.sensorToWorldScale, {x: 0, y: WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, z: 0}); | |
| 360 | 361 | this.stylusTip.position = Vec3.sum(this.stylusTip.position, |
| 361 | 362 | Vec3.multiplyQbyV(this.stylusTip.orientation, TIP_OFFSET)); |
| 362 | 363 | } |
| @@ -380,17 +381,17 @@ Script.include("/~/system/libraries/controllers.js"); · 17 unmodified lines | ||
| 380 | 381 | return; |
| 381 | 382 | } |
| 382 | 383 | |
| 384 | + var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 }; | |
| 385 | + var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90); | |
| 386 | + var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 }); | |
| 387 | + | |
| 383 | 388 | var stylusProperties = { |
| 384 | 389 | name: "stylus", |
| 385 | 390 | url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", |
| 386 | 391 | loadPriority: 10.0, |
| 387 | − localPosition: Vec3.sum({ | |
| 388 | − x: 0.0, | |
| 389 | − y: WEB_TOUCH_Y_OFFSET, | |
| 390 | − z: 0.0 | |
| 391 | − }, getGrabPointSphereOffset(this.handToController())), | |
| 392 | − localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }), | |
| 393 | − dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }, | |
| 392 | + position: Vec3.sum(this.stylusTip.position, modelPositionOffset), | |
| 393 | + rotation: modelOrientation, | |
| 394 | + dimensions: Vec3.multiply(MyAvatar.sensorToWorldScale, { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }), | |
| 394 | 395 | solid: true, |
| 395 | 396 | visible: true, |
| 396 | 397 | ignoreRayIntersection: true, |
| @@ -527,9 +528,11 @@ Script.include("/~/system/libraries/controllers.js"); · 130 unmodified lines | ||
| 527 | 528 | hysteresisOffset = 0.05; |
| 528 | 529 | } |
| 529 | 530 | |
| 530 | − this.isNearStylusTarget = isNearStylusTarget(stylusTargets, EDGE_BORDER + hysteresisOffset, | |
| 531 | − TABLET_MIN_TOUCH_DISTANCE - hysteresisOffset, | |
| 532 | − WEB_DISPLAY_STYLUS_DISTANCE + hysteresisOffset); | |
| 531 | + var sensorScaleFactor = MyAvatar.sensorToWorldScale; | |
| 532 | + this.isNearStylusTarget = isNearStylusTarget(stylusTargets, | |
| 533 | + (EDGE_BORDER + hysteresisOffset) * sensorScaleFactor, | |
| 534 | + (TABLET_MIN_TOUCH_DISTANCE - hysteresisOffset) * sensorScaleFactor, | |
| 535 | + (WEB_DISPLAY_STYLUS_DISTANCE + hysteresisOffset) * sensorScaleFactor); | |
| 533 | 536 | |
| 534 | 537 | if (this.isNearStylusTarget) { |
| 535 | 538 | if (!this.useFingerInsteadOfStylus) { |
| @@ -544,8 +547,12 @@ Script.include("/~/system/libraries/controllers.js"); · 8 unmodified lines | ||
| 544 | 547 | |
| 545 | 548 | var nearestStylusTarget = calculateNearestStylusTarget(stylusTargets); |
| 546 | 549 | |
| 547 | − if (nearestStylusTarget && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE && | |
| 548 | − nearestStylusTarget.distance < TABLET_MAX_HOVER_DISTANCE) { | |
| 550 | + var SCALED_TABLET_MIN_TOUCH_DISTANCE = TABLET_MIN_TOUCH_DISTANCE * sensorScaleFactor; | |
| 551 | + var SCALED_TABLET_MAX_TOUCH_DISTANCE = TABLET_MAX_TOUCH_DISTANCE * sensorScaleFactor; | |
| 552 | + var SCALED_TABLET_MAX_HOVER_DISTANCE = TABLET_MAX_HOVER_DISTANCE * sensorScaleFactor; | |
| 553 | + | |
| 554 | + if (nearestStylusTarget && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE && | |
| 555 | + nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE) { | |
| 549 | 556 | |
| 550 | 557 | this.requestTouchFocus(nearestStylusTarget); |
| 551 | 558 | |
| @@ -559,8 +566,8 @@ Script.include("/~/system/libraries/controllers.js"); · 7 unmodified lines | ||
| 559 | 566 | |
| 560 | 567 | // filter out presses when tip is moving away from tablet. |
| 561 | 568 | // ensure that stylus is within bounding box by checking normalizedPosition |
| 562 | − if (nearestStylusTarget.valid && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE && | |
| 563 | − nearestStylusTarget.distance < TABLET_MAX_TOUCH_DISTANCE && | |
| 569 | + if (nearestStylusTarget.valid && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE && | |
| 570 | + nearestStylusTarget.distance < SCALED_TABLET_MAX_TOUCH_DISTANCE && | |
| 564 | 571 | Vec3.dot(this.stylusTip.velocity, nearestStylusTarget.normal) < 0 && |
| 565 | 572 | nearestStylusTarget.normalizedPosition.x >= 0 && nearestStylusTarget.normalizedPosition.x <= 1 && |
| 566 | 573 | nearestStylusTarget.normalizedPosition.y >= 0 && nearestStylusTarget.normalizedPosition.y <= 1) { |
| @@ -647,7 +654,8 @@ Script.include("/~/system/libraries/controllers.js"); · 80 unmodified lines | ||
| 647 | 654 | }; |
| 648 | 655 | |
| 649 | 656 | this.overlayLaserActive = function(controllerData) { |
| 650 | − var overlayLaserModule = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightOverlayLaserInput" : "LeftOverlayLaserInput"); | |
| 657 | + var overlayLaserModule = | |
| 658 | + getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightOverlayLaserInput" : "LeftOverlayLaserInput"); | |
| 651 | 659 | if (overlayLaserModule) { |
| 652 | 660 | return overlayLaserModule.isReady(controllerData).active; |
| 653 | 661 | } |
| @@ -8,11 +8,11 @@ · 7 unmodified lines | ||
| 8 | 8 | // Distributed under the Apache License, Version 2.0. |
| 9 | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | 10 | |
| 11 | +/* jslint bitwise: true */ | |
| 11 | 12 | |
| 12 | −/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, | |
| 13 | − getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, | |
| 14 | − Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions, | |
| 15 | − Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic | |
| 13 | +/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID, | |
| 14 | + enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3, | |
| 15 | + LaserPointers, RayPick, HMD, Uuid, AvatarList | |
| 16 | 16 | */ |
| 17 | 17 | /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ |
| 18 | 18 | |
| @@ -111,7 +111,7 @@ var seatEnd = { · 92 unmodified lines | ||
| 111 | 111 | url: SEAT_MODEL_URL, |
| 112 | 112 | dimensions: TARGET_MODEL_DIMENSIONS, |
| 113 | 113 | ignoreRayIntersection: true |
| 114 | −} | |
| 114 | +}; | |
| 115 | 115 | |
| 116 | 116 | var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, |
| 117 | 117 | {name: "teleport", path: teleportPath, end: teleportEnd}, |
| @@ -228,8 +228,8 @@ function Teleporter(hand) { · 110 unmodified lines | ||
| 228 | 228 | |
| 229 | 229 | this.buttonPress = function(value) { |
| 230 | 230 | _this.buttonValue = value; |
| 231 | − } | |
| 232 | − | |
| 231 | + }; | |
| 232 | + | |
| 233 | 233 | this.parameters = makeDispatcherModuleParameters( |
| 234 | 234 | 80, |
| 235 | 235 | this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], |
| @@ -247,9 +247,36 @@ function Teleporter(hand) { · 11 unmodified lines | ||
| 247 | 247 | _this.state = TELEPORTER_STATES.TARGETTING; |
| 248 | 248 | } |
| 249 | 249 | }, COOL_IN_DURATION); |
| 250 | + | |
| 251 | + // pad scale with avatar size | |
| 252 | + var AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS = Vec3.multiply(MyAvatar.sensorToWorldScale, TARGET_MODEL_DIMENSIONS); | |
| 253 | + | |
| 254 | + if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) { | |
| 255 | + cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; | |
| 256 | + teleportEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; | |
| 257 | + seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; | |
| 258 | + | |
| 259 | + teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, | |
| 260 | + {name: "teleport", path: teleportPath, end: teleportEnd}, | |
| 261 | + {name: "seat", path: seatPath, end: seatEnd}]; | |
| 262 | + | |
| 263 | + LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]); | |
| 264 | + LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]); | |
| 265 | + LaserPointers.editRenderState(this.teleportRayHeadVisible, "cancel", teleportRenderStates[0]); | |
| 266 | + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "cancel", teleportRenderStates[0]); | |
| 267 | + | |
| 268 | + LaserPointers.editRenderState(this.teleportRayHandVisible, "teleport", teleportRenderStates[1]); | |
| 269 | + LaserPointers.editRenderState(this.teleportRayHandInvisible, "teleport", teleportRenderStates[1]); | |
| 270 | + LaserPointers.editRenderState(this.teleportRayHeadVisible, "teleport", teleportRenderStates[1]); | |
| 271 | + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "teleport", teleportRenderStates[1]); | |
| 272 | + | |
| 273 | + LaserPointers.editRenderState(this.teleportRayHandVisible, "seat", teleportRenderStates[2]); | |
| 274 | + LaserPointers.editRenderState(this.teleportRayHandInvisible, "seat", teleportRenderStates[2]); | |
| 275 | + LaserPointers.editRenderState(this.teleportRayHeadVisible, "seat", teleportRenderStates[2]); | |
| 276 | + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "seat", teleportRenderStates[2]); | |
| 277 | + } | |
| 250 | 278 | }; |
| 251 | 279 | |
| 252 | − | |
| 253 | 280 | this.isReady = function(controllerData, deltaTime) { |
| 254 | 281 | var otherModule = this.getOtherModule(); |
| 255 | 282 | if (_this.buttonValue !== 0 && !otherModule.active) { |
| @@ -259,7 +286,7 @@ function Teleporter(hand) { · 3 unmodified lines | ||
| 259 | 286 | } |
| 260 | 287 | return makeRunningValues(false, [], []); |
| 261 | 288 | }; |
| 262 | − | |
| 289 | + | |
| 263 | 290 | this.run = function(controllerData, deltaTime) { |
| 264 | 291 | //_this.state = TELEPORTER_STATES.TARGETTING; |
| 265 | 292 | |
| @@ -301,7 +328,6 @@ function Teleporter(hand) { · 35 unmodified lines | ||
| 301 | 328 | } else { |
| 302 | 329 | result = LaserPointers.getPrevRayPickResult(_this.teleportRayHandVisible); |
| 303 | 330 | } |
| 304 | − | |
| 305 | 331 | teleportLocationType = getTeleportTargetType(result); |
| 306 | 332 | } |
| 307 | 333 | |
| @@ -327,7 +353,7 @@ function Teleporter(hand) { · 19 unmodified lines | ||
| 327 | 353 | if (_this.buttonValue !== 0) { |
| 328 | 354 | return makeRunningValues(true, [], []); |
| 329 | 355 | } |
| 330 | − | |
| 356 | + | |
| 331 | 357 | if (target === TARGET.NONE || target === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) { |
| 332 | 358 | // Do nothing |
| 333 | 359 | } else if (target === TARGET.SEAT) { |
| @@ -362,7 +388,7 @@ function Teleporter(hand) { · 28 unmodified lines | ||
| 362 | 388 | } |
| 363 | 389 | }; |
| 364 | 390 | } |
| 365 | − | |
| 391 | + | |
| 366 | 392 | // related to repositioning the avatar after you teleport |
| 367 | 393 | var FOOT_JOINT_NAMES = ["RightToe_End", "RightToeBase", "RightFoot"]; |
| 368 | 394 | var DEFAULT_ROOT_TO_FOOT_OFFSET = 0.5; |
| @@ -475,7 +501,7 @@ function Teleporter(hand) { · 106 unmodified lines | ||
| 475 | 501 | disableDispatcherModule("RightTeleporter"); |
| 476 | 502 | } |
| 477 | 503 | Script.scriptEnding.connect(cleanup); |
| 478 | − | |
| 504 | + | |
| 479 | 505 | var setIgnoreEntities = function() { |
| 480 | 506 | LaserPointers.setIgnoreEntities(teleporter.teleportRayRightVisible, ignoredEntities); |
| 481 | 507 | LaserPointers.setIgnoreEntities(teleporter.teleportRayRightInvisible, ignoredEntities); |
| @@ -483,8 +509,8 @@ function Teleporter(hand) { · 1 unmodified line | ||
| 483 | 509 | LaserPointers.setIgnoreEntities(teleporter.teleportRayLeftInvisible, ignoredEntities); |
| 484 | 510 | LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadVisible, ignoredEntities); |
| 485 | 511 | LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadInvisible, ignoredEntities); |
| 486 | − } | |
| 487 | − | |
| 512 | + }; | |
| 513 | + | |
| 488 | 514 | var isDisabled = false; |
| 489 | 515 | var handleTeleportMessages = function(channel, message, sender) { |
| 490 | 516 | if (sender === MyAvatar.sessionUUID) { |
| @@ -501,7 +527,9 @@ function Teleporter(hand) { · 10 unmodified lines | ||
| 501 | 527 | if (message === 'none') { |
| 502 | 528 | isDisabled = false; |
| 503 | 529 | } |
| 504 | − } else if (channel === 'Hifi-Teleport-Ignore-Add' && !Uuid.isNull(message) && ignoredEntities.indexOf(message) === -1) { | |
| 530 | + } else if (channel === 'Hifi-Teleport-Ignore-Add' && | |
| 531 | + !Uuid.isNull(message) && | |
| 532 | + ignoredEntities.indexOf(message) === -1) { | |
| 505 | 533 | ignoredEntities.push(message); |
| 506 | 534 | setIgnoreEntities(); |
| 507 | 535 | } else if (channel === 'Hifi-Teleport-Ignore-Remove' && !Uuid.isNull(message)) { |
| @@ -513,7 +541,7 @@ function Teleporter(hand) { · 5 unmodified lines | ||
| 513 | 541 | } |
| 514 | 542 | } |
| 515 | 543 | }; |
| 516 | − | |
| 544 | + | |
| 517 | 545 | Messages.subscribe('Hifi-Teleport-Disabler'); |
| 518 | 546 | Messages.subscribe('Hifi-Teleport-Ignore-Add'); |
| 519 | 547 | Messages.subscribe('Hifi-Teleport-Ignore-Remove'); |
| @@ -7,13 +7,10 @@ · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | /* jslint bitwise: true */ |
| 9 | 9 | |
| 10 | −/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat, | |
| 11 | − getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID, | |
| 12 | − enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable, | |
| 13 | − makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, | |
| 10 | +/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Vec3, Quat, getGrabPointSphereOffset, | |
| 11 | + makeRunningValues, Entities, NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, | |
| 14 | 12 | PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, |
| 15 | − AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC | |
| 16 | − | |
| 13 | + AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, ZERO_VEC, Overlays | |
| 17 | 14 | */ |
| 18 | 15 | |
| 19 | 16 | Script.include("/~/system/libraries/controllerDispatcherUtils.js"); |
| @@ -459,7 +456,7 @@ Script.include("/~/system/libraries/controllers.js"); · 439 unmodified lines | ||
| 459 | 456 | joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", |
| 460 | 457 | filter: RayPick.PICK_ENTITIES, |
| 461 | 458 | maxDistance: PICK_MAX_DISTANCE, |
| 462 | − posOffset: getGrabPointSphereOffset(this.handToController()), | |
| 459 | + posOffset: getGrabPointSphereOffset(this.handToController(), true), | |
| 463 | 460 | renderStates: renderStates, |
| 464 | 461 | faceAvatar: true, |
| 465 | 462 | defaultRenderStates: defaultRenderStates |