Last active
August 21, 2018 21:03
-
-
Save birarda/138892bffa2dda4e1e15d2bf70cc3c85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testStep = 0; | |
var simpleBox = { | |
type: "Box", | |
color: { | |
red: 255, | |
blue: 0, | |
green: 0 | |
}, | |
localPosition: { | |
x: 0, | |
y: 0.5, | |
z: 0 | |
}, | |
collisionsWillMove: false, | |
ignoreForCollisions: true, | |
}; | |
var boxEntityID = null; | |
Script.setInterval(function(){ | |
simpleBox.parentID = MyAvatar.sessionUUID; | |
simpleBox.parentJointIndex = MyAvatar.getJointIndex("Head"); | |
if (testStep == 0) { | |
// add a red box | |
simpleBox.color = { red: 255, blue: 0, green: 0 }; | |
console.log("Adding red box"); | |
boxEntityID = Entities.addEntity(simpleBox, true); | |
} else if (testStep == 1) { | |
// make it blue | |
simpleBox.color = { red: 0, blue: 255, green: 0 }; | |
console.log("Making box blue"); | |
Entities.editEntity(boxEntityID, simpleBox); | |
} else if (testStep == 2) { | |
// make it green | |
simpleBox.color = { red: 0, blue: 0, green: 255 }; | |
console.log("Making box green"); | |
Entities.editEntity(boxEntityID, simpleBox); | |
} else if (testStep == 3) { | |
console.log("Deleting box"); | |
// delete the box | |
Entities.deleteEntity(boxEntityID); | |
boxEntityID = null; | |
} | |
if (++testStep == 4) { | |
console.log("Restarting the cycle"); | |
testStep = 0; | |
} | |
}, 5000); | |
Script.scriptEnding.connect(function(){ | |
if (boxEntityID) { | |
Entities.deleteEntity(boxEntityID); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment