mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-08 05:06:55 +02:00
use 'tractor' instead of 'spring' in JS files
This commit is contained in:
parent
e6accb61b0
commit
d705f529a0
5 changed files with 42 additions and 42 deletions
|
@ -1,6 +1,6 @@
|
||||||
// shopItemGrab.js
|
// 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)
|
// 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
|
// equip
|
||||||
//
|
//
|
||||||
|
|
||||||
var EQUIP_SPRING_SHUTOFF_DISTANCE = 0.05;
|
var EQUIP_TRACTOR_SHUTOFF_DISTANCE = 0.05;
|
||||||
var EQUIP_SPRING_TIMEFRAME = 0.4; // how quickly objects move to their new position
|
var EQUIP_TRACTOR_TIMEFRAME = 0.4; // how quickly objects move to their new position
|
||||||
|
|
||||||
//
|
//
|
||||||
// other constants
|
// other constants
|
||||||
|
@ -121,7 +121,7 @@ var STATE_EQUIP_SEARCHING = 11;
|
||||||
var STATE_EQUIP = 12
|
var STATE_EQUIP = 12
|
||||||
var STATE_CONTINUE_EQUIP_BD = 13; // equip while bumper is still held down
|
var STATE_CONTINUE_EQUIP_BD = 13; // equip while bumper is still held down
|
||||||
var STATE_CONTINUE_EQUIP = 14;
|
var STATE_CONTINUE_EQUIP = 14;
|
||||||
var STATE_EQUIP_SPRING = 16;
|
var STATE_EQUIP_TRACTOR = 16;
|
||||||
|
|
||||||
|
|
||||||
function stateToName(state) {
|
function stateToName(state) {
|
||||||
|
@ -152,8 +152,8 @@ function stateToName(state) {
|
||||||
return "continue_equip_bd";
|
return "continue_equip_bd";
|
||||||
case STATE_CONTINUE_EQUIP:
|
case STATE_CONTINUE_EQUIP:
|
||||||
return "continue_equip";
|
return "continue_equip";
|
||||||
case STATE_EQUIP_SPRING:
|
case STATE_EQUIP_TRACTOR:
|
||||||
return "state_equip_spring";
|
return "state_equip_tractor";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
@ -216,7 +216,7 @@ function MyController(hand) {
|
||||||
case STATE_EQUIP:
|
case STATE_EQUIP:
|
||||||
this.nearGrabbing();
|
this.nearGrabbing();
|
||||||
break;
|
break;
|
||||||
case STATE_EQUIP_SPRING:
|
case STATE_EQUIP_TRACTOR:
|
||||||
this.pullTowardEquipPosition()
|
this.pullTowardEquipPosition()
|
||||||
break;
|
break;
|
||||||
case STATE_CONTINUE_NEAR_GRABBING:
|
case STATE_CONTINUE_NEAR_GRABBING:
|
||||||
|
@ -404,14 +404,14 @@ function MyController(hand) {
|
||||||
return;
|
return;
|
||||||
} else if (!properties.locked) {
|
} else if (!properties.locked) {
|
||||||
var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null);
|
var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null);
|
||||||
|
|
||||||
if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items
|
if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
if (this.state == STATE_SEARCHING) {
|
if (this.state == STATE_SEARCHING) {
|
||||||
this.setState(STATE_NEAR_GRABBING);
|
this.setState(STATE_NEAR_GRABBING);
|
||||||
} else { // equipping
|
} else { // equipping
|
||||||
if (typeof grabbableData.spatialKey !== 'undefined') {
|
if (typeof grabbableData.spatialKey !== 'undefined') {
|
||||||
this.setState(STATE_EQUIP_SPRING);
|
this.setState(STATE_EQUIP_TRACTOR);
|
||||||
} else {
|
} else {
|
||||||
this.setState(STATE_EQUIP);
|
this.setState(STATE_EQUIP);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ function MyController(hand) {
|
||||||
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
|
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
|
||||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
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 = {
|
var relativeRotation = {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
|
@ -582,34 +582,34 @@ function MyController(hand) {
|
||||||
var offset = Vec3.multiplyQbyV(targetRotation, relativePosition);
|
var offset = Vec3.multiplyQbyV(targetRotation, relativePosition);
|
||||||
var targetPosition = Vec3.sum(handPosition, offset);
|
var targetPosition = Vec3.sum(handPosition, offset);
|
||||||
|
|
||||||
if (typeof this.equipSpringID === 'undefined' ||
|
if (typeof this.equipTractorID === 'undefined' ||
|
||||||
this.equipSpringID === null ||
|
this.equipTractorID === null ||
|
||||||
this.equipSpringID === NULL_ACTION_ID) {
|
this.equipTractorID === NULL_ACTION_ID) {
|
||||||
this.equipSpringID = Entities.addAction("spring", this.grabbedEntity, {
|
this.equipTractorID = Entities.addAction("tractor", this.grabbedEntity, {
|
||||||
targetPosition: targetPosition,
|
targetPosition: targetPosition,
|
||||||
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
linearTimeScale: EQUIP_TRACTOR_TIMEFRAME,
|
||||||
targetRotation: targetRotation,
|
targetRotation: targetRotation,
|
||||||
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
angularTimeScale: EQUIP_TRACTOR_TIMEFRAME,
|
||||||
ttl: ACTION_TTL
|
ttl: ACTION_TTL
|
||||||
});
|
});
|
||||||
if (this.equipSpringID === NULL_ACTION_ID) {
|
if (this.equipTractorID === NULL_ACTION_ID) {
|
||||||
this.equipSpringID = null;
|
this.equipTractorID = null;
|
||||||
this.setState(STATE_OFF);
|
this.setState(STATE_OFF);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Entities.updateAction(this.grabbedEntity, this.equipSpringID, {
|
Entities.updateAction(this.grabbedEntity, this.equipTractorID, {
|
||||||
targetPosition: targetPosition,
|
targetPosition: targetPosition,
|
||||||
linearTimeScale: EQUIP_SPRING_TIMEFRAME,
|
linearTimeScale: EQUIP_TRACTOR_TIMEFRAME,
|
||||||
targetRotation: targetRotation,
|
targetRotation: targetRotation,
|
||||||
angularTimeScale: EQUIP_SPRING_TIMEFRAME,
|
angularTimeScale: EQUIP_TRACTOR_TIMEFRAME,
|
||||||
ttl: ACTION_TTL
|
ttl: ACTION_TTL
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vec3.distance(grabbedProperties.position, targetPosition) < EQUIP_SPRING_SHUTOFF_DISTANCE) {
|
if (Vec3.distance(grabbedProperties.position, targetPosition) < EQUIP_TRACTOR_SHUTOFF_DISTANCE) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.equipSpringID);
|
Entities.deleteAction(this.grabbedEntity, this.equipTractorID);
|
||||||
this.equipSpringID = null;
|
this.equipTractorID = null;
|
||||||
this.setState(STATE_EQUIP);
|
this.setState(STATE_EQUIP);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -862,4 +862,4 @@ function cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
|
@ -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 pos = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: -0.5, z: -2}));
|
||||||
var lifetime = params.lifetime;
|
var lifetime = params.lifetime;
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@
|
||||||
tag: "cone-twist test"
|
tag: "cone-twist test"
|
||||||
});
|
});
|
||||||
|
|
||||||
Entities.addAction("spring", leverID, {
|
Entities.addAction("tractor", leverID, {
|
||||||
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
|
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
|
||||||
angularTimeScale: 0.2,
|
angularTimeScale: 0.2,
|
||||||
tag: "cone-twist test spring"
|
tag: "cone-twist test tractor"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -349,11 +349,11 @@
|
||||||
userData: "{ \"grabbableKey\": { \"grabbable\": true, \"kinematic\": false } }"
|
userData: "{ \"grabbableKey\": { \"grabbable\": true, \"kinematic\": false } }"
|
||||||
});
|
});
|
||||||
|
|
||||||
Entities.addAction("spring", headID, {
|
Entities.addAction("tractor", headID, {
|
||||||
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
|
targetRotation: { x: 0, y: 0, z: 0, w: 1 },
|
||||||
angularTimeScale: 2.0,
|
angularTimeScale: 2.0,
|
||||||
otherID: bodyID,
|
otherID: bodyID,
|
||||||
tag: "cone-twist test spring"
|
tag: "cone-twist test tractor"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@
|
||||||
|
|
||||||
if (event["dynamics-tests-command"]) {
|
if (event["dynamics-tests-command"]) {
|
||||||
var commandToFunctionMap = {
|
var commandToFunctionMap = {
|
||||||
"cone-twist-and-spring-lever-test": coneTwistAndSpringLeverTest,
|
"cone-twist-and-tractor-lever-test": coneTwistAndTractorLeverTest,
|
||||||
"door-vs-world-test": doorVSWorldTest,
|
"door-vs-world-test": doorVSWorldTest,
|
||||||
"hinge-chain-test": hingeChainTest,
|
"hinge-chain-test": hingeChainTest,
|
||||||
"slider-vs-world-test": sliderVSWorldTest,
|
"slider-vs-world-test": sliderVSWorldTest,
|
||||||
|
|
|
@ -113,4 +113,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return new SpringHold();
|
return new SpringHold();
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// touch.js
|
// 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.
|
// 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.
|
// Create two standard spheres, make them grabbable, and attach this entity script. Grab them and touch them together.
|
||||||
//
|
//
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSpringAction(timescale) {
|
function updateTractorAction(timescale) {
|
||||||
var targetProps = Entities.getEntityProperties(_this.entityID);
|
var targetProps = Entities.getEntityProperties(_this.entityID);
|
||||||
//
|
//
|
||||||
// Look for nearby entities to touch
|
// Look for nearby entities to touch
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
var success = Entities.updateAction(_this.copy, _this.actionID, props);
|
var success = Entities.updateAction(_this.copy, _this.actionID, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSpringAction(timescale) {
|
function createTractorAction(timescale) {
|
||||||
|
|
||||||
var targetProps = Entities.getEntityProperties(_this.entityID);
|
var targetProps = Entities.getEntityProperties(_this.entityID);
|
||||||
var props = {
|
var props = {
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
angularTimeScale: timescale,
|
angularTimeScale: timescale,
|
||||||
ttl: ACTION_TTL
|
ttl: ACTION_TTL
|
||||||
};
|
};
|
||||||
_this.actionID = Entities.addAction("spring", _this.copy, props);
|
_this.actionID = Entities.addAction("tractor", _this.copy, props);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSpringAction() {
|
function deleteTractorAction() {
|
||||||
Entities.deleteAction(_this.copy, _this.actionID);
|
Entities.deleteAction(_this.copy, _this.actionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,19 +188,19 @@
|
||||||
},
|
},
|
||||||
startNearGrab: function(entityID, data) {
|
startNearGrab: function(entityID, data) {
|
||||||
createCopy();
|
createCopy();
|
||||||
createSpringAction(TIMESCALE);
|
createTractorAction(TIMESCALE);
|
||||||
makeOriginalInvisible();
|
makeOriginalInvisible();
|
||||||
setHand(Entities.getEntityProperties(_this.entityID).position);
|
setHand(Entities.getEntityProperties(_this.entityID).position);
|
||||||
},
|
},
|
||||||
continueNearGrab: function() {
|
continueNearGrab: function() {
|
||||||
updateSpringAction(TIMESCALE);
|
updateTractorAction(TIMESCALE);
|
||||||
},
|
},
|
||||||
releaseGrab: function() {
|
releaseGrab: function() {
|
||||||
deleteSpringAction();
|
deleteTractorAction();
|
||||||
deleteCopy();
|
deleteCopy();
|
||||||
makeOriginalVisible();
|
makeOriginalVisible();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new TouchExample();
|
return new TouchExample();
|
||||||
});
|
});
|
||||||
|
|
|
@ -89,7 +89,7 @@ LookAtTarget = function(sourceEntityID) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!actionFound) {
|
if (!actionFound) {
|
||||||
Entities.addAction('spring', _sourceEntityID, getNewActionProperties());
|
Entities.addAction('tractor', _sourceEntityID, getNewActionProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue