use 'tractor' instead of 'spring' in JS files

This commit is contained in:
Andrew Meadows 2017-05-16 08:35:54 -07:00
parent e6accb61b0
commit d705f529a0
5 changed files with 42 additions and 42 deletions

View file

@ -1,6 +1,6 @@
// shopItemGrab.js
//
// Semplified and coarse version of handControllerGrab.js with the addition of the ownerID concept.
// Simplified and coarse version of handControllerGrab.js with the addition of the ownerID concept.
// This grab is the only one which should run in the vrShop. It allows only near grab and add the feature of checking the ownerID. (See shopGrapSwapperEntityScript.js)
//
@ -63,8 +63,8 @@ var NEAR_GRABBING_KINEMATIC = true; // force objects to be kinematic when near-g
// equip
//
var EQUIP_SPRING_SHUTOFF_DISTANCE = 0.05;
var EQUIP_SPRING_TIMEFRAME = 0.4; // how quickly objects move to their new position
var EQUIP_TRACTOR_SHUTOFF_DISTANCE = 0.05;
var EQUIP_TRACTOR_TIMEFRAME = 0.4; // how quickly objects move to their new position
//
// other constants
@ -121,7 +121,7 @@ var STATE_EQUIP_SEARCHING = 11;
var STATE_EQUIP = 12
var STATE_CONTINUE_EQUIP_BD = 13; // equip while bumper is still held down
var STATE_CONTINUE_EQUIP = 14;
var STATE_EQUIP_SPRING = 16;
var STATE_EQUIP_TRACTOR = 16;
function stateToName(state) {
@ -152,8 +152,8 @@ function stateToName(state) {
return "continue_equip_bd";
case STATE_CONTINUE_EQUIP:
return "continue_equip";
case STATE_EQUIP_SPRING:
return "state_equip_spring";
case STATE_EQUIP_TRACTOR:
return "state_equip_tractor";
}
return "unknown";
@ -216,7 +216,7 @@ function MyController(hand) {
case STATE_EQUIP:
this.nearGrabbing();
break;
case STATE_EQUIP_SPRING:
case STATE_EQUIP_TRACTOR:
this.pullTowardEquipPosition()
break;
case STATE_CONTINUE_NEAR_GRABBING:
@ -404,14 +404,14 @@ function MyController(hand) {
return;
} else if (!properties.locked) {
var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null);
if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items
this.grabbedEntity = intersection.entityID;
if (this.state == STATE_SEARCHING) {
this.setState(STATE_NEAR_GRABBING);
} else { // equipping
if (typeof grabbableData.spatialKey !== 'undefined') {
this.setState(STATE_EQUIP_SPRING);
this.setState(STATE_EQUIP_TRACTOR);
} else {
this.setState(STATE_EQUIP);
}
@ -558,7 +558,7 @@ function MyController(hand) {
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
// use a spring to pull the object to where it will be when equipped
// use a tractor to pull the object to where it will be when equipped
var relativeRotation = {
x: 0.0,
y: 0.0,
@ -582,34 +582,34 @@ function MyController(hand) {
var offset = Vec3.multiplyQbyV(targetRotation, relativePosition);
var targetPosition = Vec3.sum(handPosition, offset);
if (typeof this.equipSpringID === 'undefined' ||
this.equipSpringID === null ||
this.equipSpringID === NULL_ACTION_ID) {
this.equipSpringID = Entities.addAction("spring", this.grabbedEntity, {
if (typeof this.equipTractorID === 'undefined' ||
this.equipTractorID === null ||
this.equipTractorID === NULL_ACTION_ID) {
this.equipTractorID = Entities.addAction("tractor", this.grabbedEntity, {
targetPosition: targetPosition,
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
linearTimeScale: EQUIP_TRACTOR_TIMEFRAME,
targetRotation: targetRotation,
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
angularTimeScale: EQUIP_TRACTOR_TIMEFRAME,
ttl: ACTION_TTL
});
if (this.equipSpringID === NULL_ACTION_ID) {
this.equipSpringID = null;
if (this.equipTractorID === NULL_ACTION_ID) {
this.equipTractorID = null;
this.setState(STATE_OFF);
return;
}
} else {
Entities.updateAction(this.grabbedEntity, this.equipSpringID, {
Entities.updateAction(this.grabbedEntity, this.equipTractorID, {
targetPosition: targetPosition,
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
linearTimeScale: EQUIP_TRACTOR_TIMEFRAME,
targetRotation: targetRotation,
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
angularTimeScale: EQUIP_TRACTOR_TIMEFRAME,
ttl: ACTION_TTL
});
}
if (Vec3.distance(grabbedProperties.position, targetPosition) < EQUIP_SPRING_SHUTOFF_DISTANCE) {
Entities.deleteAction(this.grabbedEntity, this.equipSpringID);
this.equipSpringID = null;
if (Vec3.distance(grabbedProperties.position, targetPosition) < EQUIP_TRACTOR_SHUTOFF_DISTANCE) {
Entities.deleteAction(this.grabbedEntity, this.equipTractorID);
this.equipTractorID = null;
this.setState(STATE_EQUIP);
}
};
@ -862,4 +862,4 @@ function cleanup() {
}
Script.scriptEnding.connect(cleanup);
Script.update.connect(update);
Script.update.connect(update);

View file

@ -28,7 +28,7 @@
function coneTwistAndSpringLeverTest(params) {
function coneTwistAndTractorLeverTest(params) {
var pos = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: -0.5, z: -2}));
var lifetime = params.lifetime;
@ -84,10 +84,10 @@
tag: "cone-twist test"
});
Entities.addAction("spring", leverID, {
Entities.addAction("tractor", leverID, {
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
angularTimeScale: 0.2,
tag: "cone-twist test spring"
tag: "cone-twist test tractor"
});
@ -349,11 +349,11 @@
userData: "{ \"grabbableKey\": { \"grabbable\": true, \"kinematic\": false } }"
});
Entities.addAction("spring", headID, {
Entities.addAction("tractor", headID, {
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
angularTimeScale: 2.0,
otherID: bodyID,
tag: "cone-twist test spring"
tag: "cone-twist test tractor"
});
@ -705,7 +705,7 @@
if (event["dynamics-tests-command"]) {
var commandToFunctionMap = {
"cone-twist-and-spring-lever-test": coneTwistAndSpringLeverTest,
"cone-twist-and-tractor-lever-test": coneTwistAndTractorLeverTest,
"door-vs-world-test": doorVSWorldTest,
"hinge-chain-test": hingeChainTest,
"slider-vs-world-test": sliderVSWorldTest,

View file

@ -113,4 +113,4 @@
};
return new SpringHold();
});
});

View file

@ -2,7 +2,7 @@
// touch.js
//
// Sample file using spring action, haptic vibration, and color change to demonstrate two spheres
// Sample file using tractor action, haptic vibration, and color change to demonstrate two spheres
// That can give a sense of touch to the holders.
// Create two standard spheres, make them grabbable, and attach this entity script. Grab them and touch them together.
//
@ -53,7 +53,7 @@
_this = this;
}
function updateSpringAction(timescale) {
function updateTractorAction(timescale) {
var targetProps = Entities.getEntityProperties(_this.entityID);
//
// Look for nearby entities to touch
@ -113,7 +113,7 @@
var success = Entities.updateAction(_this.copy, _this.actionID, props);
}
function createSpringAction(timescale) {
function createTractorAction(timescale) {
var targetProps = Entities.getEntityProperties(_this.entityID);
var props = {
@ -123,7 +123,7 @@
angularTimeScale: timescale,
ttl: ACTION_TTL
};
_this.actionID = Entities.addAction("spring", _this.copy, props);
_this.actionID = Entities.addAction("tractor", _this.copy, props);
return;
}
@ -170,7 +170,7 @@
});
}
function deleteSpringAction() {
function deleteTractorAction() {
Entities.deleteAction(_this.copy, _this.actionID);
}
@ -188,19 +188,19 @@
},
startNearGrab: function(entityID, data) {
createCopy();
createSpringAction(TIMESCALE);
createTractorAction(TIMESCALE);
makeOriginalInvisible();
setHand(Entities.getEntityProperties(_this.entityID).position);
},
continueNearGrab: function() {
updateSpringAction(TIMESCALE);
updateTractorAction(TIMESCALE);
},
releaseGrab: function() {
deleteSpringAction();
deleteTractorAction();
deleteCopy();
makeOriginalVisible();
}
};
return new TouchExample();
});
});

View file

@ -89,7 +89,7 @@ LookAtTarget = function(sourceEntityID) {
}
});
if (!actionFound) {
Entities.addAction('spring', _sourceEntityID, getNewActionProperties());
Entities.addAction('tractor', _sourceEntityID, getNewActionProperties());
}
}
};