Skip to content

Instantly share code, notes, and snippets.

@SamGondelman
Last active May 15, 2019 19:40
Show Gist options
  • Save SamGondelman/2eafc8c4e738c489bef833e8e3509529 to your computer and use it in GitHub Desktop.
Save SamGondelman/2eafc8c4e738c489bef833e8e3509529 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;
var COLORS = [ "red", "green", "blue", "yellow", "purple", "pink" ];
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: COLORS[i],
lifetime: 300
}));
entities.push(Entities.addEntity({
type: "Zone",
name: "Zone " + i,
position: getPos(0, 0),
rotation: MyAvatar.orientation,
dimensions: dimensions,
skyboxMode: "enabled",
skybox: {
color: COLORS[i]
},
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