mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-21 17:07:55 +01:00
some additional details to the preview rendering
This commit is contained in:
parent
69df58c054
commit
a1bac028cd
@ -306,7 +306,7 @@ function previewUp(redrawLess) {
|
||||
numLayers++;
|
||||
}
|
||||
// redrawPreview(redrawLess);
|
||||
redrawRenderedPreview();
|
||||
redrawRenderedPreview(redrawLess);
|
||||
}
|
||||
function previewDown(redrawLess) {
|
||||
// console.log("f:previewDown()");
|
||||
@ -314,7 +314,7 @@ function previewDown(redrawLess) {
|
||||
numLayers--;
|
||||
}
|
||||
// redrawPreview(redrawLess);
|
||||
redrawRenderedPreview();
|
||||
redrawRenderedPreview(redrawLess);
|
||||
}
|
||||
function previewTwistLeft(redrawLess) {
|
||||
if (redrawLess == undefined) redrawLess = false;
|
||||
@ -323,7 +323,7 @@ function previewTwistLeft(redrawLess) {
|
||||
rStep -= twistIncrement;
|
||||
// }
|
||||
// redrawPreview(redrawLess);
|
||||
redrawRenderedPreview();
|
||||
redrawRenderedPreview(redrawLess);
|
||||
}
|
||||
function previewTwistRight(redrawLess) {
|
||||
// console.log("f:previewTwistRight()");
|
||||
@ -331,7 +331,7 @@ function previewTwistRight(redrawLess) {
|
||||
rStep += twistIncrement;
|
||||
// }
|
||||
// redrawPreview(redrawLess);
|
||||
redrawRenderedPreview();
|
||||
redrawRenderedPreview(redrawLess);
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,15 +325,26 @@ function onCanvasMouseMove(e) {
|
||||
|
||||
if (new Date().getTime() - prevRedrawTime > redrawInterval) {
|
||||
// redrawing the whole preview the first X points ensures that the doodleBounds is set well
|
||||
prevRedrawTime = new Date().getTime();
|
||||
if (_points.length < 50) {
|
||||
redrawPreview();
|
||||
} else {
|
||||
// redrawPreview();
|
||||
updatePreview(x, y, true);
|
||||
/*
|
||||
if (_points.length - prevUpdateFullPreview > prevUpdateFullPreviewInterval) {
|
||||
console.log("f:onTouchMove >> passed prevUpdateFullPreviewInterval, updating full preview");
|
||||
redrawPreview();
|
||||
prevUpdateFullPreview = _points.length;
|
||||
} else {
|
||||
updatePreview(x, y, true);
|
||||
}
|
||||
//*/
|
||||
// redrawPreview();
|
||||
}
|
||||
prevRedrawTime = new Date().getTime();
|
||||
}
|
||||
}
|
||||
prevUpdateFullPreview = 0; // 0 is not a timeframe but refers to the _points array
|
||||
prevUpdateFullPreviewInterval = 25; // refers to number of points, not a timeframe
|
||||
|
||||
function onCanvasMouseUp(e) {
|
||||
// console.log("onmouseup");
|
||||
@ -414,13 +425,22 @@ function onCanvasTouchMove(e) {
|
||||
redrawPreview();
|
||||
} else {
|
||||
updatePreview(x, y, true);
|
||||
/*
|
||||
if (_points.length - prevUpdateFullPreview > prevUpdateFullPreviewInterval) {
|
||||
console.log("f:onTouchMove >> passed prevUpdateFullPreviewInterval, updating full preview");
|
||||
redrawPreview();
|
||||
prevUpdateFullPreview = _points.length;
|
||||
} else {
|
||||
updatePreview(x, y, true);
|
||||
}
|
||||
//*/
|
||||
}
|
||||
prevRedrawTime = new Date().getTime();
|
||||
}
|
||||
}
|
||||
|
||||
function onCanvasTouchEnd(e) {
|
||||
// console.log("ontouchend");
|
||||
console.log("f:onCanvasTouchEnd()");
|
||||
console.log("doodleBounds: " + doodleBounds);
|
||||
console.log("doodleTransform: " + doodleTransform);
|
||||
// ctx.stroke();
|
||||
|
@ -203,7 +203,8 @@ function renderToImageDataPreview() {
|
||||
|
||||
// called by the move up/down or twist left/right buttons
|
||||
// it is assumed that the preview has been rendered to an Image object, which will be used to draw the preview with (much better performance)
|
||||
function redrawRenderedPreview() {
|
||||
function redrawRenderedPreview(redrawLess) {
|
||||
if (redrawLess == undefined) redrawLess = false;
|
||||
console.log("f:redrawRenderedPreview()");
|
||||
|
||||
previewCtx.clearRect(0, 0, preview.width, preview.height);
|
||||
@ -221,6 +222,11 @@ function redrawRenderedPreview() {
|
||||
previewCtx.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
if (redrawLess && i%2 != 0 && !(i == 0 || i == Math.floor(numLayers/2) || i == numLayers-1) ) {
|
||||
y -= yStep;
|
||||
r += rStep;
|
||||
continue;
|
||||
}
|
||||
previewCtx.save();
|
||||
|
||||
previewCtx.translate(layerCX,layerOffsetY+layerCY+y);
|
||||
|
Loading…
Reference in New Issue
Block a user