mirror of
https://github.com/overte-org/overte.git
synced 2025-04-11 13:42:38 +02:00
refactor code a bit
This commit is contained in:
parent
21c688390c
commit
b600000307
1 changed files with 18 additions and 9 deletions
|
@ -231,7 +231,6 @@ function grabLowestJointY() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
function addTerrainBlock() {
|
||||
var baseLocation = getTerrainAlignedLocation(Vec3.sum(MyAvatar.position, {x:8, y:8, z:8}));
|
||||
if (baseLocation.y > MyAvatar.position.y) {
|
||||
|
@ -247,10 +246,26 @@ function addTerrainBlock() {
|
|||
baseLocation = getTerrainAlignedLocation(facingPosition);
|
||||
alreadyThere = lookupTerrainForLocation(baseLocation);
|
||||
if (alreadyThere) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var polyVoxID = addTerrainBlockNearLocation(baseLocation);
|
||||
|
||||
if (polyVoxID) {
|
||||
var AvatarPositionInVoxelCoords = Entities.worldCoordsToVoxelCoords(polyVoxID, MyAvatar.position);
|
||||
// TODO -- how to find the avatar's feet?
|
||||
var topY = Math.round(AvatarPositionInVoxelCoords.y) - 4;
|
||||
Entities.setVoxelsInCuboid(polyVoxID, {x:0, y:0, z:0}, {x:16, y:topY, z:16}, 255);
|
||||
}
|
||||
}
|
||||
|
||||
function addTerrainBlockNearLocation(baseLocation) {
|
||||
var alreadyThere = lookupTerrainForLocation(baseLocation);
|
||||
if (alreadyThere) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var polyVoxID = Entities.addEntity({
|
||||
type: "PolyVox",
|
||||
name: "terrain",
|
||||
|
@ -263,12 +278,6 @@ function addTerrainBlock() {
|
|||
zTextureURL: "http://headache.hungry.com/~seth/hifi/dirt.jpeg"
|
||||
});
|
||||
|
||||
var AvatarPositionInVoxelCoords = Entities.worldCoordsToVoxelCoords(polyVoxID, MyAvatar.position);
|
||||
// TODO -- how to find the avatar's feet?
|
||||
var topY = Math.round(AvatarPositionInVoxelCoords.y) - 4;
|
||||
Entities.setVoxelsInCuboid(polyVoxID, {x:0, y:0, z:0}, {x:16, y:topY, z:16}, 255);
|
||||
|
||||
|
||||
//////////
|
||||
// stitch together the terrain with x/y/z NeighorID properties
|
||||
//////////
|
||||
|
@ -324,7 +333,7 @@ function addTerrainBlock() {
|
|||
properties.zPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16}));
|
||||
Entities.editEntity(polyVoxID, properties);
|
||||
|
||||
return true;
|
||||
return polyVoxID;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue