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.
196 lines
4.4 KiB
JavaScript
196 lines
4.4 KiB
JavaScript
Script.include(["pd_utils.js"]);
|
|
|
|
function createModel()
|
|
{
|
|
print("createModel");
|
|
var position = {x:5, y:0, z:0};
|
|
var createProperties = {
|
|
type: "Model",
|
|
position: position,
|
|
modelURL: "http://nerdchallenge.com/hifi/mechPod.fbx",
|
|
animationIsPlaying: false
|
|
};
|
|
|
|
var entityID = Entities.addEntity(createProperties);
|
|
var postCreateProps = Entities.getEntityProperties(entityID);
|
|
Entities.editEntity(entityID, { dimensions: postCreateProps.naturalDimensions});
|
|
print("Created entityID: " + entityID);
|
|
return entityID;
|
|
}
|
|
|
|
function createBox(pos, dims, rot)
|
|
{
|
|
print("creating box");
|
|
var createProperties = {
|
|
type: "Box",
|
|
position: pos,
|
|
dimensions: dims,
|
|
rotation: rot,
|
|
color: {red:255, green:255, blue:0}
|
|
};
|
|
|
|
var entityID = Entities.addEntity(createProperties);
|
|
print("Created entityID: " + entityID);
|
|
return entityID;
|
|
}
|
|
|
|
function createOverlay_beta(message)
|
|
{
|
|
var newOverlay = Overlays.addOverlay("text", {
|
|
alpha: 1.0,
|
|
text: message,
|
|
font: { size: fontSize },
|
|
x: 40,
|
|
y: 15,
|
|
width: 320,
|
|
height:128,
|
|
backgroundColor: { red: 0, green: 0, blue: 0},
|
|
backgroundAlpha: 0.9,
|
|
color: { red: 255, green: 0, blue: 0},
|
|
topMargin: 18,
|
|
leftMargin: 8,
|
|
bottomMargin: 8,
|
|
rightMargin: 8,
|
|
lineHeight: 80,
|
|
visible: true
|
|
});
|
|
|
|
return newOverlay;
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeOverlay_beta(overlay, message) {
|
|
Overlays.editOverlay(overlay, {text: message});
|
|
}
|
|
|
|
var uiTitle = {};
|
|
var uiMessage = "This is a line of text that should emerge. It will keep going as long as I need it to. It could have lots of stuff in it.";
|
|
var letterIndex = 0;
|
|
var uiMessageAccumulator = "";
|
|
var lineLength = 0;
|
|
var fontSize = 20;
|
|
var textIsPrinting = false;
|
|
|
|
function scriptEnding()
|
|
{
|
|
Overlays.deleteOverlay(uiTitle);
|
|
}
|
|
|
|
var totalTime = 0;
|
|
var textDisplayInterval = 0.025;
|
|
|
|
function scriptUpdate(deltaTime)
|
|
{
|
|
totalTime += deltaTime;
|
|
if (textIsPrinting && totalTime > textDisplayInterval)
|
|
{
|
|
displayNextCharacter();
|
|
totalTime = 0;
|
|
}
|
|
}
|
|
|
|
function onKeyPress(event)
|
|
{
|
|
textIsPrinting = true;
|
|
}
|
|
|
|
var blipSound = SoundCache.getSound("http://nerdchallenge.com/hifi/sounds/textClick1.wav");
|
|
|
|
|
|
function displayNextCharacter()
|
|
{
|
|
if (letterIndex >= uiMessage.length)
|
|
{
|
|
textIsPrinting = false;
|
|
letterIndex = 0;
|
|
return;
|
|
}
|
|
|
|
var panelWidth = 320; // Set by panel
|
|
var fontWidthTweak = 0.5;
|
|
lineLength++;
|
|
var currentLineWidth = lineLength * fontSize * fontWidthTweak;
|
|
|
|
//Overlays.deleteOverlay(uiTitle);
|
|
|
|
var letter = uiMessage.charAt(letterIndex);
|
|
|
|
if (letter == " " && currentLineWidth > panelWidth)
|
|
{
|
|
letter = "\n";
|
|
lineLength = 0;
|
|
}
|
|
uiMessageAccumulator += letter;
|
|
letterIndex++;
|
|
|
|
Audio.playSound(blipSound, { position: MyAvatar.position, volume: 0.5 });
|
|
changeOverlay_beta(uiTitle, uiMessageAccumulator);
|
|
}
|
|
|
|
function test_deconstruct()
|
|
{
|
|
//Overlays.del
|
|
}
|
|
|
|
function createImageOverlay(message)
|
|
{
|
|
//var imageUrl = "http://hifi-public.s3.amazonaws.com/images/close-small-light.svg";
|
|
var imageUrl = "http://nerdchallenge.com/hifi/images/scannerFrame.png";
|
|
var overlay = Overlays.addOverlay("image", {
|
|
x: 430,
|
|
y: 430,
|
|
width: 250,
|
|
height: 250,
|
|
text:message,
|
|
// subImage: {
|
|
// x: this.buttonWidth,
|
|
// y: this.buttonHeight,
|
|
// width: this.buttonWidth,
|
|
// height: this.buttonHeight
|
|
// },
|
|
imageURL: imageUrl,
|
|
visible: true,
|
|
alpha: 1
|
|
});
|
|
var textOverlay = Overlays.addOverlay("text3d", {
|
|
x: 430,
|
|
y: 430,
|
|
width: 250,
|
|
height: 250,
|
|
font: { size: 14 },
|
|
text: "Fun Message",
|
|
color: { red: 0, green: 0, blue: 0},
|
|
// subImage: {
|
|
// x: this.buttonWidth,
|
|
// y: this.buttonHeight,
|
|
// width: this.buttonWidth,
|
|
// height: this.buttonHeight
|
|
// },
|
|
//imageURL: imageUrl,
|
|
visible: true,
|
|
alpha: 1.0,
|
|
backgroundAlpha: 0.7
|
|
});
|
|
|
|
}
|
|
|
|
|
|
Script.scriptEnding.connect(test_deconstruct);
|
|
|
|
createImageOverlay("My Message");
|
|
|
|
printDebug(Camera.mode);
|
|
//createBox({x:0, y:0, z:5}, {x:5, y:15, z:5}, {x:45,y:0,z:0});
|
|
//var radarMessage = createOverlay("RADAR\n8 MINERALS LOCATED");
|
|
// printDebug("Test Script Running");
|
|
//
|
|
// var uiTitle = createOverlay_beta("SCANNER TEST TEXT\n is!");
|
|
// Controller.keyPressEvent.connect(onKeyPress);
|
|
// Script.scriptEnding.connect(scriptEnding);
|
|
// Script.update.connect(scriptUpdate);
|
|
// printDebug("TEST done");
|
|
|
|
//changeOverlay(radarMessage, "FUCK!");
|
|
|