content/hifi-public/cozza13/cellscience/Scripts/zoom.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

74 lines
No EOL
2.1 KiB
JavaScript

(function(){
var teleport;
var portalDestination;
var animationURL;
function playSound() {
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
};
this.preload = function(entityID) {
this.entityId = entityID;
teleport = SoundCache.getSound("http://dynamoidapps.com.com/HighFidelity/Audio/whoosh.raw");
var properties = Entities.getEntityProperties(entityID);
portalDestination = properties.userData;
animationURL = properties.modelURL;
// print("The portal destination is " + portalDestination);
}
this.enterEntity = function(entityID) {
var data = JSON.parse(Entities.getEntityProperties(this.entityId).userData);
// if (MyAvatar.getAngularVelocity() > 10){
// //MyAvatar.position = ?
// }
// else
if (data != null) {
print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")");
MyAvatar.position = data.location;
this.lookAt(data.target);
// redirectTransitionNodes(data.location);
}
}
this.lookAt = function(targetPosition) {
var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition));
var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, {x:1, y:0, z:0});
var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, {x:0, y:1, z:0});
var rotation = Quat.multiply(yaw, pitch);
MyAvatar.orientation = rotation;
}
this.redirectTransitionNodes = function(location) {
var n = 0;
var arrayFound = Entities.findEntities(MyAvatar.position, 5000);
for (var i = 0; i < arrayFound.length; i++) {
arrayFound[i].userData = location;
}
print("deleted " + arrayFound.length + " entities");
}
this.leaveEntity = function(entityID) {
Entities.editEntity(entityID, {
animationURL: animationURL,
animationSettings: '{ "frameIndex": 1, "running": false }'
});
playSound();
}
this.hoverEnterEntity = function(entityID) {
Entities.editEntity(entityID, {
animationURL: animationURL,
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
});
}
})