mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 20:39:55 +02:00
editVoxels reformat
This commit is contained in:
parent
956fe71d34
commit
1c89d8f3ed
1 changed files with 255 additions and 255 deletions
|
@ -157,50 +157,50 @@ var editToolsOn = true; // starts out off
|
|||
var previewAsVoxel = false;
|
||||
|
||||
var voxelPreview = Overlays.addOverlay("cube", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
size: 1,
|
||||
color: { red: 255, green: 0, blue: 0},
|
||||
alpha: 1,
|
||||
solid: false,
|
||||
visible: false,
|
||||
lineWidth: 4
|
||||
});
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
size: 1,
|
||||
color: { red: 255, green: 0, blue: 0},
|
||||
alpha: 1,
|
||||
solid: false,
|
||||
visible: false,
|
||||
lineWidth: 4
|
||||
});
|
||||
|
||||
var linePreviewTop = Overlays.addOverlay("line3d", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
|
||||
var linePreviewBottom = Overlays.addOverlay("line3d", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
|
||||
var linePreviewLeft = Overlays.addOverlay("line3d", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
|
||||
var linePreviewRight = Overlays.addOverlay("line3d", {
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
position: { x: 0, y: 0, z: 0},
|
||||
end: { x: 0, y: 0, z: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1,
|
||||
visible: false,
|
||||
lineWidth: previewLineWidth
|
||||
});
|
||||
|
||||
|
||||
// these will be used below
|
||||
|
@ -238,16 +238,16 @@ for (s = 0; s < numColors; s++) {
|
|||
}
|
||||
|
||||
swatches[s] = Overlays.addOverlay("image", {
|
||||
x: swatchX,
|
||||
y: swatchesY,
|
||||
width: swatchWidth + extraWidth,
|
||||
height: swatchHeight,
|
||||
subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight },
|
||||
imageURL: toolIconUrl + "swatches.svg",
|
||||
color: colors[s],
|
||||
alpha: 1,
|
||||
visible: editToolsOn
|
||||
});
|
||||
x: swatchX,
|
||||
y: swatchesY,
|
||||
width: swatchWidth + extraWidth,
|
||||
height: swatchHeight,
|
||||
subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight },
|
||||
imageURL: toolIconUrl + "swatches.svg",
|
||||
color: colors[s],
|
||||
alpha: 1,
|
||||
visible: editToolsOn
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,28 +267,28 @@ var eyedropperToolAt = 2;
|
|||
var pasteModeColor = { red: 132, green: 61, blue: 255 };
|
||||
|
||||
var voxelTool = Overlays.addOverlay("image", {
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "voxel-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "voxel-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
|
||||
var recolorTool = Overlays.addOverlay("image", {
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "paint-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "paint-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
|
||||
var eyedropperTool = Overlays.addOverlay("image", {
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "eyedropper-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
x: 0, y: 0, width: toolWidth, height: toolHeight,
|
||||
subImage: { x: 0, y: toolHeight, width: toolWidth, height: toolHeight },
|
||||
imageURL: toolIconUrl + "eyedropper-tool.svg",
|
||||
visible: false,
|
||||
alpha: 0.9
|
||||
});
|
||||
|
||||
// This will create a couple of image overlays that make a "slider", we will demonstrate how to trap mouse messages to
|
||||
// move the slider
|
||||
|
@ -301,12 +301,12 @@ var sliderOffsetX = 17;
|
|||
var sliderX = swatchesX - swatchWidth - sliderOffsetX;
|
||||
var sliderY = windowDimensions.y - sliderHeight + 1;
|
||||
var slider = Overlays.addOverlay("image", {
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight},
|
||||
imageURL: toolIconUrl + "voxel-size-slider-bg.svg",
|
||||
alpha: 1,
|
||||
visible: false
|
||||
});
|
||||
// alternate form of expressing bounds
|
||||
bounds: { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight},
|
||||
imageURL: toolIconUrl + "voxel-size-slider-bg.svg",
|
||||
alpha: 1,
|
||||
visible: false
|
||||
});
|
||||
|
||||
// The slider is handled in the mouse event callbacks.
|
||||
var isMovingSlider = false;
|
||||
|
@ -320,14 +320,14 @@ var thumbX = (minThumbX + maxThumbX) / 2;
|
|||
var thumbOffsetY = 11;
|
||||
var thumbY = sliderY + thumbOffsetY;
|
||||
var thumb = Overlays.addOverlay("image", {
|
||||
x: sliderX + thumbX,
|
||||
y: thumbY,
|
||||
width: 17,
|
||||
height: 17,
|
||||
imageURL: toolIconUrl + "voxel-size-slider-handle.svg",
|
||||
alpha: 1,
|
||||
visible: false
|
||||
});
|
||||
x: sliderX + thumbX,
|
||||
y: thumbY,
|
||||
width: 17,
|
||||
height: 17,
|
||||
imageURL: toolIconUrl + "voxel-size-slider-handle.svg",
|
||||
alpha: 1,
|
||||
visible: false
|
||||
});
|
||||
|
||||
var pointerVoxelScale = Math.floor(MAX_VOXEL_SCALE + MIN_VOXEL_SCALE) / 2; // this is the voxel scale used for click to add or delete
|
||||
var pointerVoxelScaleSet = false; // if voxel scale has not yet been set, we use the intersection size
|
||||
|
@ -533,13 +533,13 @@ function calculateVoxelFromIntersection(intersection, operation) {
|
|||
var wantDebug = false;
|
||||
if (wantDebug) {
|
||||
print(">>>>> calculateVoxelFromIntersection().... intersection voxel.red/green/blue=" + intersection.voxel.red + ", "
|
||||
+ intersection.voxel.green + ", " + intersection.voxel.blue);
|
||||
+ intersection.voxel.green + ", " + intersection.voxel.blue);
|
||||
print(" intersection voxel.x/y/z/s=" + intersection.voxel.x + ", "
|
||||
+ intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s);
|
||||
+ intersection.voxel.y + ", " + intersection.voxel.z+ ": " + intersection.voxel.s);
|
||||
print(" intersection face=" + intersection.face);
|
||||
print(" intersection distance=" + intersection.distance);
|
||||
print(" intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
||||
+ intersection.intersection.y + ", " + intersection.intersection.z);
|
||||
+ intersection.intersection.y + ", " + intersection.intersection.z);
|
||||
}
|
||||
|
||||
var voxelSize;
|
||||
|
@ -678,12 +678,12 @@ function showPreviewVoxel() {
|
|||
if (whichColor == -1) {
|
||||
// Copy mode - use clicked voxel color
|
||||
voxelColor = { red: intersection.voxel.red,
|
||||
green: intersection.voxel.green,
|
||||
blue: intersection.voxel.blue };
|
||||
green: intersection.voxel.green,
|
||||
blue: intersection.voxel.blue };
|
||||
} else {
|
||||
voxelColor = { red: colors[whichColor].red,
|
||||
green: colors[whichColor].green,
|
||||
blue: colors[whichColor].blue };
|
||||
green: colors[whichColor].green,
|
||||
blue: colors[whichColor].blue };
|
||||
}
|
||||
|
||||
var guidePosition;
|
||||
|
@ -709,24 +709,24 @@ function showPreviewLines() {
|
|||
|
||||
// X axis
|
||||
Overlays.editOverlay(linePreviewBottom, {
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x + pasteVoxel.voxelSize, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z },
|
||||
visible: true
|
||||
});
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x + pasteVoxel.voxelSize, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z },
|
||||
visible: true
|
||||
});
|
||||
|
||||
// Y axis
|
||||
Overlays.editOverlay(linePreviewRight, {
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y + pasteVoxel.voxelSize, z: pasteVoxel.origin.z },
|
||||
visible: true
|
||||
});
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y + pasteVoxel.voxelSize, z: pasteVoxel.origin.z },
|
||||
visible: true
|
||||
});
|
||||
|
||||
// Z axis
|
||||
Overlays.editOverlay(linePreviewTop, {
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z - pasteVoxel.voxelSize },
|
||||
visible: true
|
||||
});
|
||||
position: pasteVoxel.origin,
|
||||
end: {x: pasteVoxel.origin.x, y: pasteVoxel.origin.y, z: pasteVoxel.origin.z - pasteVoxel.voxelSize },
|
||||
visible: true
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -878,7 +878,7 @@ function mousePressEvent(event) {
|
|||
thumbClickOffsetX = event.x - (sliderX + thumbX); // this should be the position of the mouse relative to the thumb
|
||||
clickedOnSomething = true;
|
||||
|
||||
Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", });
|
||||
//Overlays.editOverlay(thumb, { imageURL: toolIconUrl + "voxel-size-slider-handle.svg", });
|
||||
|
||||
} else if (clickedOverlay == voxelTool) {
|
||||
modeSwitchSound.play(0);
|
||||
|
@ -990,19 +990,19 @@ function mousePressEvent(event) {
|
|||
if (whichColor == -1) {
|
||||
// Copy mode - use clicked voxel color
|
||||
newColor = {
|
||||
red: intersection.voxel.red,
|
||||
green: intersection.voxel.green,
|
||||
red: intersection.voxel.red,
|
||||
green: intersection.voxel.green,
|
||||
blue: intersection.voxel.blue };
|
||||
} else {
|
||||
newColor = {
|
||||
red: colors[whichColor].red,
|
||||
green: colors[whichColor].green,
|
||||
red: colors[whichColor].red,
|
||||
green: colors[whichColor].green,
|
||||
blue: colors[whichColor].blue };
|
||||
}
|
||||
|
||||
voxelDetails = calculateVoxelFromIntersection(intersection,"add");
|
||||
Voxels.setVoxel(voxelDetails.x, voxelDetails.y, voxelDetails.z, voxelDetails.s,
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
lastVoxelPosition = { x: voxelDetails.x, y: voxelDetails.y, z: voxelDetails.z };
|
||||
lastVoxelColor = { red: newColor.red, green: newColor.green, blue: newColor.blue };
|
||||
lastVoxelScale = voxelDetails.s;
|
||||
|
@ -1036,13 +1036,13 @@ function keyPressEvent(event) {
|
|||
if (color == -1) color = 0;
|
||||
var newPosition = getNewVoxelPosition();
|
||||
var newVoxel = {
|
||||
x: newPosition.x,
|
||||
y: newPosition.y ,
|
||||
z: newPosition.z,
|
||||
s: NEW_VOXEL_SIZE,
|
||||
red: colors[color].red,
|
||||
green: colors[color].green,
|
||||
blue: colors[color].blue };
|
||||
x: newPosition.x,
|
||||
y: newPosition.y ,
|
||||
z: newPosition.z,
|
||||
s: NEW_VOXEL_SIZE,
|
||||
red: colors[color].red,
|
||||
green: colors[color].green,
|
||||
blue: colors[color].blue };
|
||||
Voxels.eraseVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s);
|
||||
Voxels.setVoxel(newVoxel.x, newVoxel.y, newVoxel.z, newVoxel.s, newVoxel.red, newVoxel.green, newVoxel.blue);
|
||||
setAudioPosition();
|
||||
|
@ -1173,8 +1173,8 @@ function mouseMoveEvent(event) {
|
|||
if (!isExtruding) {
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var lastVoxelDistance = { x: pickRay.origin.x - lastVoxelPosition.x,
|
||||
y: pickRay.origin.y - lastVoxelPosition.y,
|
||||
z: pickRay.origin.z - lastVoxelPosition.z };
|
||||
y: pickRay.origin.y - lastVoxelPosition.y,
|
||||
z: pickRay.origin.z - lastVoxelPosition.z };
|
||||
var distance = Vec3.length(lastVoxelDistance);
|
||||
var mouseSpot = { x: pickRay.direction.x * distance, y: pickRay.direction.y * distance, z: pickRay.direction.z * distance };
|
||||
mouseSpot.x += pickRay.origin.x;
|
||||
|
@ -1200,7 +1200,7 @@ function mouseMoveEvent(event) {
|
|||
if (Math.sqrt(dx*dx + dy*dy) > PIXELS_PER_EXTRUDE_VOXEL) {
|
||||
lastVoxelPosition = Vec3.sum(lastVoxelPosition, extrudeDirection);
|
||||
Voxels.setVoxel(lastVoxelPosition.x, lastVoxelPosition.y, lastVoxelPosition.z,
|
||||
extrudeScale, lastVoxelColor.red, lastVoxelColor.green, lastVoxelColor.blue);
|
||||
extrudeScale, lastVoxelColor.red, lastVoxelColor.green, lastVoxelColor.blue);
|
||||
mouseX = event.x;
|
||||
mouseY = event.y;
|
||||
}
|
||||
|
@ -1254,21 +1254,21 @@ function moveTools() {
|
|||
}
|
||||
|
||||
Overlays.editOverlay(swatches[s], {
|
||||
x: swatchX,
|
||||
y: swatchesY,
|
||||
subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight },
|
||||
color: colors[s],
|
||||
alpha: 1,
|
||||
visible: editToolsOn
|
||||
});
|
||||
x: swatchX,
|
||||
y: swatchesY,
|
||||
subImage: { x: imageFromX, y: imageFromY, width: swatchWidth + extraWidth, height: swatchHeight },
|
||||
color: colors[s],
|
||||
alpha: 1,
|
||||
visible: editToolsOn
|
||||
});
|
||||
}
|
||||
|
||||
// move the tools
|
||||
toolsY = (windowDimensions.y - toolsHeight) / 2;
|
||||
|
||||
var voxelToolOffset = 1,
|
||||
recolorToolOffset = 1,
|
||||
eyedropperToolOffset = 1;
|
||||
recolorToolOffset = 1,
|
||||
eyedropperToolOffset = 1;
|
||||
|
||||
var voxelToolColor = WHITE_COLOR;
|
||||
|
||||
|
@ -1284,23 +1284,23 @@ function moveTools() {
|
|||
}
|
||||
|
||||
Overlays.editOverlay(voxelTool, {
|
||||
subImage: { x: 0, y: toolHeight * voxelToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * voxelToolAt), width: toolWidth, height: toolHeight,
|
||||
color: voxelToolColor,
|
||||
visible: editToolsOn
|
||||
});
|
||||
subImage: { x: 0, y: toolHeight * voxelToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * voxelToolAt), width: toolWidth, height: toolHeight,
|
||||
color: voxelToolColor,
|
||||
visible: editToolsOn
|
||||
});
|
||||
|
||||
Overlays.editOverlay(recolorTool, {
|
||||
subImage: { x: 0, y: toolHeight * recolorToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * recolorToolAt), width: toolWidth, height: toolHeight,
|
||||
visible: editToolsOn
|
||||
});
|
||||
subImage: { x: 0, y: toolHeight * recolorToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * recolorToolAt), width: toolWidth, height: toolHeight,
|
||||
visible: editToolsOn
|
||||
});
|
||||
|
||||
Overlays.editOverlay(eyedropperTool, {
|
||||
subImage: { x: 0, y: toolHeight * eyedropperToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * eyedropperToolAt), width: toolWidth, height: toolHeight,
|
||||
visible: editToolsOn
|
||||
});
|
||||
subImage: { x: 0, y: toolHeight * eyedropperToolOffset, width: toolWidth, height: toolHeight },
|
||||
x: toolsX, y: toolsY + ((toolHeight + toolVerticalSpacing) * eyedropperToolAt), width: toolWidth, height: toolHeight,
|
||||
visible: editToolsOn
|
||||
});
|
||||
|
||||
sliderX = swatchesX + swatchesWidth - sliderOffsetX;
|
||||
sliderY = windowDimensions.y - sliderHeight + 1;
|
||||
|
@ -1338,7 +1338,7 @@ function checkControllers() {
|
|||
|
||||
Voxels.eraseVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE);
|
||||
Voxels.setVoxel(fingerTipPosition.x, fingerTipPosition.y, fingerTipPosition.z, FINGERTIP_VOXEL_SIZE,
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
newColor.red, newColor.green, newColor.blue);
|
||||
|
||||
lastFingerAddVoxel = fingerTipPosition;
|
||||
}
|
||||
|
@ -1367,9 +1367,9 @@ function update(deltaTime) {
|
|||
var forwardVector = Quat.getFront(MyAvatar.orientation);
|
||||
var targetPosition = Vec3.sum(position, Vec3.multiply(forwardVector, importScale));
|
||||
var newPosition = {
|
||||
x: Math.floor(targetPosition.x / importScale) * importScale,
|
||||
y: Math.floor(targetPosition.y / importScale) * importScale,
|
||||
z: Math.floor(targetPosition.z / importScale) * importScale
|
||||
x: Math.floor(targetPosition.x / importScale) * importScale,
|
||||
y: Math.floor(targetPosition.y / importScale) * importScale,
|
||||
z: Math.floor(targetPosition.z / importScale) * importScale
|
||||
}
|
||||
moveImport(newPosition);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue