update paths for users and voxels

This commit is contained in:
James B. Pollack 2016-04-26 14:35:24 -07:00
parent 2f069b4051
commit 5cb88b957c
2 changed files with 109 additions and 34 deletions

View file

@ -661,12 +661,8 @@ var usersWindow = (function () {
function onMouseMoveEvent(event) { function onMouseMoveEvent(event) {
if (isMovingScrollbar) { if (isMovingScrollbar) {
if (scrollbarBackgroundPosition.x - WINDOW_MARGIN <= event.x if (scrollbarBackgroundPosition.x - WINDOW_MARGIN <= event.x && event.x <= scrollbarBackgroundPosition.x + SCROLLBAR_BACKGROUND_WIDTH + WINDOW_MARGIN && scrollbarBackgroundPosition.y - WINDOW_MARGIN <= event.y && event.y <= scrollbarBackgroundPosition.y + scrollbarBackgroundHeight + WINDOW_MARGIN) {
&& event.x <= scrollbarBackgroundPosition.x + SCROLLBAR_BACKGROUND_WIDTH + WINDOW_MARGIN scrollbarValue = (event.y - scrollbarBarClickedAt * scrollbarBarHeight - scrollbarBackgroundPosition.y) / (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
&& scrollbarBackgroundPosition.y - WINDOW_MARGIN <= event.y
&& event.y <= scrollbarBackgroundPosition.y + scrollbarBackgroundHeight + WINDOW_MARGIN) {
scrollbarValue = (event.y - scrollbarBarClickedAt * scrollbarBarHeight - scrollbarBackgroundPosition.y)
/ (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
scrollbarValue = Math.min(Math.max(scrollbarValue, 0.0), 1.0); scrollbarValue = Math.min(Math.max(scrollbarValue, 0.0), 1.0);
firstUserToDisplay = Math.floor(scrollbarValue * (linesOfUsers.length - numUsersToDisplay)); firstUserToDisplay = Math.floor(scrollbarValue * (linesOfUsers.length - numUsersToDisplay));
updateOverlayPositions(); updateOverlayPositions();

View file

@ -22,10 +22,14 @@ var onAlpha = 1.0;
var editSphereRadius = 4; var editSphereRadius = 4;
function floorVector(v) { function floorVector(v) {
return {x: Math.floor(v.x), y: Math.floor(v.y), z: Math.floor(v.z)}; return {
x: Math.floor(v.x),
y: Math.floor(v.y),
z: Math.floor(v.z)
};
} }
var toolBar = (function () { var toolBar = (function() {
var that = {}, var that = {},
toolBar, toolBar,
activeButton, activeButton,
@ -36,9 +40,9 @@ var toolBar = (function () {
addTerrainButton; addTerrainButton;
function initialize() { function initialize() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.voxel.toolbar", function (windowDimensions, toolbar) { toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.voxel.toolbar", function(windowDimensions, toolbar) {
return { return {
x: windowDimensions.x - 8*2 - toolbar.width * 2, x: windowDimensions.x - 8 * 2 - toolbar.width * 2,
y: (windowDimensions.y - toolbar.height) / 2 y: (windowDimensions.y - toolbar.height) / 2
}; };
}); });
@ -128,8 +132,11 @@ var toolBar = (function () {
toolBar.showTool(addTerrainButton, doShow); toolBar.showTool(addTerrainButton, doShow);
}; };
that.mousePressEvent = function (event) { that.mousePressEvent = function(event) {
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); var clickedOverlay = Overlays.getOverlayAtPoint({
x: event.x,
y: event.y
});
if (activeButton === toolBar.clicked(clickedOverlay)) { if (activeButton === toolBar.clicked(clickedOverlay)) {
that.setActive(!isActive); that.setActive(!isActive);
@ -187,7 +194,7 @@ var toolBar = (function () {
that.setActive(false); that.setActive(false);
}); });
that.cleanup = function () { that.cleanup = function() {
toolBar.cleanup(); toolBar.cleanup();
}; };
@ -233,7 +240,11 @@ function grabLowestJointY() {
function addTerrainBlock() { function addTerrainBlock() {
var baseLocation = getTerrainAlignedLocation(Vec3.sum(MyAvatar.position, {x:8, y:8, z:8})); var baseLocation = getTerrainAlignedLocation(Vec3.sum(MyAvatar.position, {
x: 8,
y: 8,
z: 8
}));
if (baseLocation.y > MyAvatar.position.y) { if (baseLocation.y > MyAvatar.position.y) {
baseLocation.y -= 16; baseLocation.y -= 16;
} }
@ -243,7 +254,11 @@ function addTerrainBlock() {
// there is already a terrain block under MyAvatar. // there is already a terrain block under MyAvatar.
// try in front of the avatar. // try in front of the avatar.
facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getFront(Camera.getOrientation()))); facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getFront(Camera.getOrientation())));
facingPosition = Vec3.sum(facingPosition, {x:8, y:8, z:8}); facingPosition = Vec3.sum(facingPosition, {
x: 8,
y: 8,
z: 8
});
baseLocation = getTerrainAlignedLocation(facingPosition); baseLocation = getTerrainAlignedLocation(facingPosition);
alreadyThere = lookupTerrainForLocation(baseLocation); alreadyThere = lookupTerrainForLocation(baseLocation);
if (alreadyThere) { if (alreadyThere) {
@ -257,7 +272,15 @@ function addTerrainBlock() {
var AvatarPositionInVoxelCoords = Entities.worldCoordsToVoxelCoords(polyVoxID, MyAvatar.position); var AvatarPositionInVoxelCoords = Entities.worldCoordsToVoxelCoords(polyVoxID, MyAvatar.position);
// TODO -- how to find the avatar's feet? // TODO -- how to find the avatar's feet?
var topY = Math.round(AvatarPositionInVoxelCoords.y) - 4; var topY = Math.round(AvatarPositionInVoxelCoords.y) - 4;
Entities.setVoxelsInCuboid(polyVoxID, {x:0, y:0, z:0}, {x:16, y:topY, z:16}, 255); Entities.setVoxelsInCuboid(polyVoxID, {
x: 0,
y: 0,
z: 0
}, {
x: 16,
y: topY,
z: 16
}, 255);
} }
} }
@ -271,12 +294,20 @@ function addTerrainBlockNearLocation(baseLocation) {
type: "PolyVox", type: "PolyVox",
name: "terrain", name: "terrain",
position: baseLocation, position: baseLocation,
dimensions: { x:16, y:16, z:16 }, dimensions: {
voxelVolumeSize: {x:16, y:64, z:16}, x: 16,
y: 16,
z: 16
},
voxelVolumeSize: {
x: 16,
y: 64,
z: 16
},
voxelSurfaceStyle: 0, voxelSurfaceStyle: 0,
xTextureURL: "http://headache.hungry.com/~seth/hifi/dirt.jpeg", xTextureURL: Script.resolvePath("assets/images/textures/dirt.jpg"),
yTextureURL: "http://headache.hungry.com/~seth/hifi/grass.png", yTextureURL: Script.resolvePath("assets/images/textures/grass.png"),
zTextureURL: "http://headache.hungry.com/~seth/hifi/dirt.jpeg" zTextureURL: Script.resolvePath("assets/images/textures/dirt.jpg")
}); });
////////// //////////
@ -284,12 +315,36 @@ function addTerrainBlockNearLocation(baseLocation) {
////////// //////////
// link neighbors to this plot // link neighbors to this plot
imXNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:16, y:0, z:0})); imXNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
imYNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:16, z:0})); x: 16,
imZNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16})); y: 0,
imXPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:-16, y:0, z:0})); z: 0
imYPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:-16, z:0})); }));
imZPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:-16})); imYNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 16,
z: 0
}));
imZNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 0,
z: 16
}));
imXPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: -16,
y: 0,
z: 0
}));
imYPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: -16,
z: 0
}));
imZPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 0,
z: -16
}));
if (imXNNeighborFor) { if (imXNNeighborFor) {
var properties = Entities.getEntityProperties(imXNNeighborFor); var properties = Entities.getEntityProperties(imXNNeighborFor);
@ -326,12 +381,36 @@ function addTerrainBlockNearLocation(baseLocation) {
// link this plot to its neighbors // link this plot to its neighbors
var properties = Entities.getEntityProperties(polyVoxID); var properties = Entities.getEntityProperties(polyVoxID);
properties.xNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:-16, y:0, z:0})); properties.xNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
properties.yNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:-16, z:0})); x: -16,
properties.zNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:-16})); y: 0,
properties.xPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:16, y:0, z:0})); z: 0
properties.yPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:16, z:0})); }));
properties.zPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16})); properties.yNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: -16,
z: 0
}));
properties.zNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 0,
z: -16
}));
properties.xPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 16,
y: 0,
z: 0
}));
properties.yPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 16,
z: 0
}));
properties.zPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {
x: 0,
y: 0,
z: 16
}));
Entities.editEntity(polyVoxID, properties); Entities.editEntity(polyVoxID, properties);
return polyVoxID; return polyVoxID;
@ -467,4 +546,4 @@ function cleanup() {
Controller.mousePressEvent.connect(mousePressEvent); Controller.mousePressEvent.connect(mousePressEvent);
Controller.keyPressEvent.connect(keyPressEvent); Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent);
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);