Skip to content

Instantly share code, notes, and snippets.

@SamGondelman
Created May 10, 2019 21:54
Show Gist options
  • Save SamGondelman/96e16158b47d8c5478589440d5801c0d to your computer and use it in GitHub Desktop.
Save SamGondelman/96e16158b47d8c5478589440d5801c0d to your computer and use it in GitHub Desktop.
(function() { // BEGIN LOCAL_SCOPE
var entities = [];
function getPos(x, y) {
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(0, Quat.getFront(MyAvatar.orientation)));
return Vec3.sum(Vec3.sum(center, Vec3.multiply(Quat.getRight(MyAvatar.orientation), x)), Vec3.multiply(Quat.getUp(MyAvatar.orientation), y));
}
var NUM_ZONES = 6;
for (var i = 0; i < NUM_ZONES; i++) {
var dimensions = 5.0 * (i + 1);
entities.push(Entities.addEntity({
type: "Box",
position: getPos(0, -2.0 - i * 0.1),
rotation: MyAvatar.orientation,
dimensions: { x: dimensions, y: 0.1, z: dimensions },
color: (i % 2 == 0) ? "blue" : "red",
lifetime: 300
}));
entities.push(Entities.addEntity({
type: "Zone",
name: "Zone " + i,
position: getPos(0, 0),
rotation: MyAvatar.orientation,
dimensions: dimensions,
skyboxMode: i < (NUM_ZONES - 2) ? "inherit" : "enabled",
skybox: {
color: (i % 2 == 0) ? "blue" : "red"
},
lifetime: 300
}));
}
function cleanup() {
for (var i = 0; i < entities.length; i++) {
Entities.deleteEntity(entities[i]);
}
}
Script.scriptEnding.connect(cleanup);
}()); // END LOCAL_SCOPE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment