mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +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++;
|
numLayers++;
|
||||||
}
|
}
|
||||||
// redrawPreview(redrawLess);
|
// redrawPreview(redrawLess);
|
||||||
redrawRenderedPreview();
|
redrawRenderedPreview(redrawLess);
|
||||||
}
|
}
|
||||||
function previewDown(redrawLess) {
|
function previewDown(redrawLess) {
|
||||||
// console.log("f:previewDown()");
|
// console.log("f:previewDown()");
|
||||||
@ -314,7 +314,7 @@ function previewDown(redrawLess) {
|
|||||||
numLayers--;
|
numLayers--;
|
||||||
}
|
}
|
||||||
// redrawPreview(redrawLess);
|
// redrawPreview(redrawLess);
|
||||||
redrawRenderedPreview();
|
redrawRenderedPreview(redrawLess);
|
||||||
}
|
}
|
||||||
function previewTwistLeft(redrawLess) {
|
function previewTwistLeft(redrawLess) {
|
||||||
if (redrawLess == undefined) redrawLess = false;
|
if (redrawLess == undefined) redrawLess = false;
|
||||||
@ -323,7 +323,7 @@ function previewTwistLeft(redrawLess) {
|
|||||||
rStep -= twistIncrement;
|
rStep -= twistIncrement;
|
||||||
// }
|
// }
|
||||||
// redrawPreview(redrawLess);
|
// redrawPreview(redrawLess);
|
||||||
redrawRenderedPreview();
|
redrawRenderedPreview(redrawLess);
|
||||||
}
|
}
|
||||||
function previewTwistRight(redrawLess) {
|
function previewTwistRight(redrawLess) {
|
||||||
// console.log("f:previewTwistRight()");
|
// console.log("f:previewTwistRight()");
|
||||||
@ -331,7 +331,7 @@ function previewTwistRight(redrawLess) {
|
|||||||
rStep += twistIncrement;
|
rStep += twistIncrement;
|
||||||
// }
|
// }
|
||||||
// redrawPreview(redrawLess);
|
// redrawPreview(redrawLess);
|
||||||
redrawRenderedPreview();
|
redrawRenderedPreview(redrawLess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,15 +325,26 @@ function onCanvasMouseMove(e) {
|
|||||||
|
|
||||||
if (new Date().getTime() - prevRedrawTime > redrawInterval) {
|
if (new Date().getTime() - prevRedrawTime > redrawInterval) {
|
||||||
// redrawing the whole preview the first X points ensures that the doodleBounds is set well
|
// redrawing the whole preview the first X points ensures that the doodleBounds is set well
|
||||||
|
prevRedrawTime = new Date().getTime();
|
||||||
if (_points.length < 50) {
|
if (_points.length < 50) {
|
||||||
redrawPreview();
|
redrawPreview();
|
||||||
} else {
|
} 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);
|
updatePreview(x, y, true);
|
||||||
}
|
}
|
||||||
prevRedrawTime = new Date().getTime();
|
//*/
|
||||||
|
// redrawPreview();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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) {
|
function onCanvasMouseUp(e) {
|
||||||
// console.log("onmouseup");
|
// console.log("onmouseup");
|
||||||
@ -414,13 +425,22 @@ function onCanvasTouchMove(e) {
|
|||||||
redrawPreview();
|
redrawPreview();
|
||||||
} else {
|
} else {
|
||||||
updatePreview(x, y, true);
|
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();
|
prevRedrawTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasTouchEnd(e) {
|
function onCanvasTouchEnd(e) {
|
||||||
// console.log("ontouchend");
|
console.log("f:onCanvasTouchEnd()");
|
||||||
console.log("doodleBounds: " + doodleBounds);
|
console.log("doodleBounds: " + doodleBounds);
|
||||||
console.log("doodleTransform: " + doodleTransform);
|
console.log("doodleTransform: " + doodleTransform);
|
||||||
// ctx.stroke();
|
// ctx.stroke();
|
||||||
|
@ -203,7 +203,8 @@ function renderToImageDataPreview() {
|
|||||||
|
|
||||||
// called by the move up/down or twist left/right buttons
|
// 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)
|
// 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()");
|
console.log("f:redrawRenderedPreview()");
|
||||||
|
|
||||||
previewCtx.clearRect(0, 0, preview.width, preview.height);
|
previewCtx.clearRect(0, 0, preview.width, preview.height);
|
||||||
@ -221,6 +222,11 @@ function redrawRenderedPreview() {
|
|||||||
previewCtx.globalAlpha = globalAlpha;
|
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.save();
|
||||||
|
|
||||||
previewCtx.translate(layerCX,layerOffsetY+layerCY+y);
|
previewCtx.translate(layerCX,layerOffsetY+layerCY+y);
|
||||||
|
Loading…
Reference in New Issue
Block a user