added lifetime to painted lines to prevent huge model.json files when lots of people draw in one domain. Got rid of gaps in lines when switching line entities

This commit is contained in:
Eric Levin 2015-06-12 11:58:43 -07:00
parent b11b1d408b
commit 7ee609396c

View file

@ -12,8 +12,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
Script.include('lineRider.js') Script.include('lineRider.js')
var MAX_POINTS_PER_LINE = 80; var MAX_POINTS_PER_LINE = 30;
var LINE_LIFETIME = 60 * 5 //5 minute lifetime
var colorPalette = [{ var colorPalette = [{
red: 236, red: 236,
@ -120,10 +120,12 @@ function MousePaint() {
y: 10, y: 10,
z: 10 z: 10
}, },
lineWidth: LINE_WIDTH lineWidth: LINE_WIDTH,
lifetime: LINE_LIFETIME
}); });
points = []; points = [];
if (point) { if (point) {
points.push(point); points.push(point);
path.push(point); path.push(point);
} }
@ -133,22 +135,22 @@ function MousePaint() {
function mouseMoveEvent(event) { function mouseMoveEvent(event) {
if (!isDrawing) {
return;
}
var pickRay = Camera.computePickRay(event.x, event.y); var pickRay = Camera.computePickRay(event.x, event.y);
var addVector = Vec3.multiply(Vec3.normalize(pickRay.direction), DRAWING_DISTANCE); var addVector = Vec3.multiply(Vec3.normalize(pickRay.direction), DRAWING_DISTANCE);
var point = Vec3.sum(Camera.getPosition(), addVector); var point = Vec3.sum(Camera.getPosition(), addVector);
points.push(point);
path.push(point);
Entities.editEntity(line, { Entities.editEntity(line, {
linePoints: points linePoints: points
}); });
Entities.editEntity(brush, { Entities.editEntity(brush, {
position: point position: point
}); });
if (!isDrawing) {
return;
}
points.push(point);
path.push(point);
if (points.length === MAX_POINTS_PER_LINE) { if (points.length === MAX_POINTS_PER_LINE) {
//We need to start a new line! //We need to start a new line!
@ -253,7 +255,6 @@ function HydraPaint() {
var maxLineWidth = 10; var maxLineWidth = 10;
var currentLineWidth = minLineWidth; var currentLineWidth = minLineWidth;
var MIN_PAINT_TRIGGER_THRESHOLD = .01; var MIN_PAINT_TRIGGER_THRESHOLD = .01;
var LINE_LIFETIME = 20;
var COLOR_CHANGE_TIME_FACTOR = 0.1; var COLOR_CHANGE_TIME_FACTOR = 0.1;
var RIGHT_BUTTON_1 = 7 var RIGHT_BUTTON_1 = 7
@ -330,7 +331,7 @@ function HydraPaint() {
z: 10 z: 10
}, },
lineWidth: 5, lineWidth: 5,
// lifetime: LINE_LIFETIME lifetime: LINE_LIFETIME
}); });
this.points = []; this.points = [];
if (point) { if (point) {