Refactoring Ball for FloatingObject

This commit is contained in:
Luis Fernando Molina committed 2018-05-03 20:27:32 +02:00
1 parent 31d47ce6f4
commit a28f21040f
6 files changed
+128 -156

No files matched your search

Binary file not shown.
+3 -3
View File
@@ -210,7 +210,7 @@ function newCanvas() {
There are four types of elements that can be dragged.
1. Panels.
2. Floating Elements (Currently only Balls).
2. Floating Elements (Currently only FloatingObjects).
3. Charts.
4. The Viewport.
@@ -338,7 +338,7 @@ function newCanvas() {
if (ballDragStarted === true) {
if (thisObject.floatingSpace.isInsideBall(floatingObjectBeingDragged, event.pageX, event.pageY) === false) {
if (thisObject.floatingSpace.isInsideFloatingObject(floatingObjectBeingDragged, event.pageX, event.pageY) === false) {
/* This means that the user stop moving the mouse and the ball ball out of the pointer.
In this case we cancell the drag operation . */
@@ -379,7 +379,7 @@ function newCanvas() {
browserCanvas.style.cursor = "grabbing";
thisObject.eventHandler.raiseEvent("Dragging", undefined);
let targetBall = thisObject.floatingSpace.isInside(event.pageX, event.pageY);
let targetFloatingObject = thisObject.floatingSpace.isInside(event.pageX, event.pageY);
if (ballDragStarted) {
-28
View File
@@ -165,9 +165,6 @@ maxDate.setDate(maxDate.getDate() + 10);
const MAX_PLOTABLE_DATE = maxDate;
var smallBalls = []; // Array of small circles for debugging purposes.
function dashboardStart() {
setTimeout(start, DEBUG_START_UP_DELAY);
@@ -196,28 +193,3 @@ function start() {
}
function drawSmallBall() {
for (var i = 0; i < smallBalls.length; i++) {
x = smallBalls[i][0];
y = smallBalls[i][1];
radius = smallBalls[i][2];
fillStyle = smallBalls[i][3];
browserCanvasContext.beginPath();
browserCanvasContext.moveTo(x, y);
browserCanvasContext.arc(x, y, radius, 0, Math.PI * 2, true);
browserCanvasContext.closePath();
browserCanvasContext.fillStyle = fillStyle;
browserCanvasContext.fill();
}
}
+3 -3
View File
@@ -31,8 +31,8 @@ function newFloatingObject() {
radomizeCurrentPosition: radomizeCurrentPosition,
radomizeCurrentSpeed: radomizeCurrentSpeed,
drawBackground: drawBackgrond, // Function to draw the floating object elements on the canvas layer.
drawForeground: drawForeground, // Function to draw the floating object elements on the floating objects layer.
drawBackground: drawBackgrond, // Function to draw the floating object elements on the canvas layer.
drawForeground: drawForeground, // Function to draw the floating object elements on the floating objects layer.
updateMass: updateMass, // Function to update the mass when the zoom level changed.
updateRadius: updateRadius, // Function to update the radius when the zoom level changed.
@@ -181,7 +181,7 @@ function newFloatingObject() {
if (thisObject.currentRadius > 0.5) {
/* Main Ball */
/* Main FloatingObject */
var alphaA;
+119 -119
View File
@@ -7,17 +7,17 @@ function newFloatingSpace() {
let thisObject = {
floatingObjects: undefined, // This is the array of floatingObjects being displayed
createNewBall: createNewBall,
destroyBall: destroyBall,
createNewFloatingObject: createNewFloatingObject,
destroyFloatingObject: destroyFloatingObject,
createBubbleSet: createBubbleSet,
destroyBubbleSet: destroyBubbleSet,
physicsLoop: physicsLoop,
isInside: isInside,
isInsideBall: isInsideBall,
isInsideFloatingObject: isInsideFloatingObject,
initialize: initialize
};
let createdBalls = [];
let createdFloatingObjects = [];
let bubbleSets = [];
return thisObject;
@@ -29,49 +29,49 @@ function newFloatingSpace() {
}
function createNewBall(pInput, pContainer) {
function createNewFloatingObject(pInput, pContainer) {
/* This function is used to create new floatingObjects */
var ball = newFloatingObject();
var floatingObject = newFloatingObject();
ball.input = pInput;
floatingObject.input = pInput;
ball.container = pContainer;
floatingObject.container = pContainer;
ball.friction = .995;
floatingObject.friction = .995;
ball.initializeMass(15);
ball.initializeRadius(30);
ball.initializeImageSize(50);
floatingObject.initializeMass(15);
floatingObject.initializeRadius(30);
floatingObject.initializeImageSize(50);
ball.fillStyle = 'rgba(255, 255, 255, 0.5)';
ball.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
floatingObject.fillStyle = 'rgba(255, 255, 255, 0.5)';
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
createdBalls.push(ball);
createdFloatingObjects.push(floatingObject);
ball.handle = Math.floor((Math.random() * 10000000) + 1);
floatingObject.handle = Math.floor((Math.random() * 10000000) + 1);
return ball.handle;
return floatingObject.handle;
}
function destroyBall(pBallHandle) {
function destroyFloatingObject(pFloatingObjectHandle) {
for (let i = 0; i < createdBalls.length; i++) {
for (let i = 0; i < createdFloatingObjects.length; i++) {
let ball = createdBalls[i];
let floatingObject = createdFloatingObjects[i];
if (ball.handle === pBallHandle) {
createdBalls.splice(i, 1); // Delete item from array.
if (floatingObject.handle === pFloatingObjectHandle) {
createdFloatingObjects.splice(i, 1); // Delete item from array.
return;
}
}
for (let i = 0; i < thisObject.floatingObjects.length; i++) {
let ball = thisObject.floatingObjects[i];
let floatingObject = thisObject.floatingObjects[i];
if (ball.handle === pBallHandle) {
if (floatingObject.handle === pFloatingObjectHandle) {
thisObject.floatingObjects.splice(i, 1); // Delete item from array.
return;
}
@@ -117,66 +117,66 @@ function newFloatingSpace() {
for (let i = 0; i < thisObject.floatingObjects.length; i++) {
let ball = thisObject.floatingObjects[i];
let floatingObject = thisObject.floatingObjects[i];
/* Change position based on speed */
ball.currentPosition.x = ball.currentPosition.x + ball.currentSpeed.x;
ball.currentPosition.y = ball.currentPosition.y + ball.currentSpeed.y;
floatingObject.currentPosition.x = floatingObject.currentPosition.x + floatingObject.currentSpeed.x;
floatingObject.currentPosition.y = floatingObject.currentPosition.y + floatingObject.currentSpeed.y;
/* Apply some friction to desacelerate */
ball.currentSpeed.x = ball.currentSpeed.x * ball.friction; // Desaceleration factor.
ball.currentSpeed.y = ball.currentSpeed.y * ball.friction; // Desaceleration factor.
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x * floatingObject.friction; // Desaceleration factor.
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y * floatingObject.friction; // Desaceleration factor.
// Gives a minimun speed towards their taget.
if (ball.currentPosition.x < ball.input.position.x) {
ball.currentSpeed.x = ball.currentSpeed.x + .005;
if (floatingObject.currentPosition.x < floatingObject.input.position.x) {
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + .005;
} else {
ball.currentSpeed.x = ball.currentSpeed.x - .005;
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x - .005;
}
if (ball.currentPosition.y < ball.input.position.y) {
ball.currentSpeed.y = ball.currentSpeed.y + .005;
if (floatingObject.currentPosition.y < floatingObject.input.position.y) {
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + .005;
} else {
ball.currentSpeed.y = ball.currentSpeed.y - .005;
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y - .005;
}
// Lets put a maximun speed also.
const MAX_SPEED = 50;
if (ball.currentSpeed.x > MAX_SPEED) {
ball.currentSpeed.x = MAX_SPEED;
if (floatingObject.currentSpeed.x > MAX_SPEED) {
floatingObject.currentSpeed.x = MAX_SPEED;
}
if (ball.currentSpeed.y > MAX_SPEED) {
ball.currentSpeed.y = MAX_SPEED;
if (floatingObject.currentSpeed.y > MAX_SPEED) {
floatingObject.currentSpeed.y = MAX_SPEED;
}
if (ball.currentSpeed.x < -MAX_SPEED) {
ball.currentSpeed.x = -MAX_SPEED;
if (floatingObject.currentSpeed.x < -MAX_SPEED) {
floatingObject.currentSpeed.x = -MAX_SPEED;
}
if (ball.currentSpeed.y < -MAX_SPEED) {
ball.currentSpeed.y = -MAX_SPEED;
if (floatingObject.currentSpeed.y < -MAX_SPEED) {
floatingObject.currentSpeed.y = -MAX_SPEED;
}
// The radius also have a target.
if (ball.currentRadius < ball.targetRadius) {
ball.currentRadius = ball.currentRadius + .5;
if (floatingObject.currentRadius < floatingObject.targetRadius) {
floatingObject.currentRadius = floatingObject.currentRadius + .5;
} else {
ball.currentRadius = ball.currentRadius - .5;
floatingObject.currentRadius = floatingObject.currentRadius - .5;
}
// The imageSize also have a target.
if (ball.currentImageSize < ball.targetImageSize) {
ball.currentImageSize = ball.currentImageSize + 1;
if (floatingObject.currentImageSize < floatingObject.targetImageSize) {
floatingObject.currentImageSize = floatingObject.currentImageSize + 1;
} else {
ball.currentImageSize = ball.currentImageSize - 1;
floatingObject.currentImageSize = floatingObject.currentImageSize - 1;
}
/* Collision Control */
@@ -194,66 +194,66 @@ function newFloatingSpace() {
repulsionForce(i);
gravityForce(ball);
gravityForce(floatingObject);
}
/* We draw all the thisObject.floatingObjects. */
for (let i = 0; i < thisObject.floatingObjects.length; i++) {
let ball = thisObject.floatingObjects[i];
ball.drawBackground();
let floatingObject = thisObject.floatingObjects[i];
floatingObject.drawBackground();
}
for (let i = 0; i < thisObject.floatingObjects.length; i++) {
let ball = thisObject.floatingObjects[thisObject.floatingObjects.length - i - 1];
ball.drawForeground();
let floatingObject = thisObject.floatingObjects[thisObject.floatingObjects.length - i - 1];
floatingObject.drawForeground();
}
/* Finally we check if any of the created Balls where enabled to run under the Physics Engine. */
/* Finally we check if any of the created FloatingObjects where enabled to run under the Physics Engine. */
for (let i = 0; i < createdBalls.length; i++) {
for (let i = 0; i < createdFloatingObjects.length; i++) {
let ball = createdBalls[i];
let floatingObject = createdFloatingObjects[i];
if (ball.input.visible === true) {
if (floatingObject.input.visible === true) {
/* The first time that the ball becomes visible, we need to do this. */
/* The first time that the floatingObject becomes visible, we need to do this. */
ball.radomizeCurrentPosition(ball.input.position);
ball.radomizeCurrentSpeed();
floatingObject.radomizeCurrentPosition(floatingObject.input.position);
floatingObject.radomizeCurrentSpeed();
thisObject.floatingObjects.push(ball);
createdBalls.splice(i, 1); // Delete item from array.
thisObject.floatingObjects.push(floatingObject);
createdFloatingObjects.splice(i, 1); // Delete item from array.
return; // Only one at the time.
}
}
}
function gravityForce(ball) {
function gravityForce(floatingObject) {
/* We simulate a kind of gravity towards the target point of each ball. This force will make the ball to keep pushing to reach that point. */
/* We simulate a kind of gravity towards the target point of each floatingObject. This force will make the floatingObject to keep pushing to reach that point. */
const coulomb = .00001;
const minForce = 0.01;
var d = Math.sqrt(Math.pow(ball.input.position.x - ball.currentPosition.x, 2) + Math.pow(ball.input.position.y - ball.currentPosition.y, 2)); // ... we calculate the distance ...
var d = Math.sqrt(Math.pow(floatingObject.input.position.x - floatingObject.currentPosition.x, 2) + Math.pow(floatingObject.input.position.y - floatingObject.currentPosition.y, 2)); // ... we calculate the distance ...
var force = coulomb * d * d / ball.currentMass; // In this case the mass of the ball affects the gravity force that it receives, that gives priority to target position to bigger floatingObjects.
var force = coulomb * d * d / floatingObject.currentMass; // In this case the mass of the floatingObject affects the gravity force that it receives, that gives priority to target position to bigger floatingObjects.
if (force < minForce) { // We need this attraction force to overcome the friction we imposed to the system.
force = minForce;
}
var pos1 = {
x: ball.currentPosition.x,
y: ball.currentPosition.y
x: floatingObject.currentPosition.x,
y: floatingObject.currentPosition.y
};
var pos2 = {
x: ball.input.position.x,
y: ball.input.position.y
x: floatingObject.input.position.x,
y: floatingObject.input.position.y
};
var posDiff = { // Next we need the vector resulting from the 2 positions.
@@ -273,28 +273,28 @@ function newFloatingSpace() {
/* We add the force vector to the speed vector */
ball.currentSpeed.x = ball.currentSpeed.x + forceVector.x;
ball.currentSpeed.y = ball.currentSpeed.y + forceVector.y;
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + forceVector.x;
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + forceVector.y;
}
function repulsionForce(currentBall) {
function repulsionForce(currentFloatingObject) {
/* We generate a repulsion force between floatingObjects, that prevents them to be collisioning so often. */
const coulomb = 2;
var ball1 = thisObject.floatingObjects[currentBall];
var floatingObject1 = thisObject.floatingObjects[currentFloatingObject];
for (var i = 0; i < thisObject.floatingObjects.length; i++) { // The force to be applied is considering all other floatingObjects...
if (i !== currentBall) { // ... except for the current one.
if (i !== currentFloatingObject) { // ... except for the current one.
var ball2 = thisObject.floatingObjects[i]; // So, for each ball...
var floatingObject2 = thisObject.floatingObjects[i]; // So, for each floatingObject...
var d = Math.sqrt(Math.pow(ball2.currentPosition.x - ball1.currentPosition.x, 2) + Math.pow(ball2.currentPosition.y - ball1.currentPosition.y, 2)); // ... we calculate the distance ...
var d = Math.sqrt(Math.pow(floatingObject2.currentPosition.x - floatingObject1.currentPosition.x, 2) + Math.pow(floatingObject2.currentPosition.y - floatingObject1.currentPosition.y, 2)); // ... we calculate the distance ...
var force = coulomb * ball2.currentMass / (d * d); // ... and with it the repulsion force.
var force = coulomb * floatingObject2.currentMass / (d * d); // ... and with it the repulsion force.
/* We need to put a hard limit to this force, in order to to eject very little floatingObjects to the infinite and beyond. */
@@ -303,13 +303,13 @@ function newFloatingSpace() {
}
var pos1 = {
x: ball1.currentPosition.x,
y: ball1.currentPosition.y
x: floatingObject1.currentPosition.x,
y: floatingObject1.currentPosition.y
};
var pos2 = {
x: ball2.currentPosition.x,
y: ball2.currentPosition.y
x: floatingObject2.currentPosition.x,
y: floatingObject2.currentPosition.y
};
var posDiff = { // Next we need the vector resulting from the 2 positions.
@@ -327,10 +327,10 @@ function newFloatingSpace() {
y: unitVector.y * force
};
/* We substract the force vector to the speed vector of the current ball */
/* We substract the force vector to the speed vector of the current floatingObject */
ball1.currentSpeed.x = ball1.currentSpeed.x - forceVector.x;
ball1.currentSpeed.y = ball1.currentSpeed.y - forceVector.y;
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x;
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y;
}
@@ -338,13 +338,13 @@ function newFloatingSpace() {
}
function colliding(ball1, ball2) {
function colliding(floatingObject1, floatingObject2) {
/* This function detects weather 2 floatingObjects collide with each other. */
var r1 = ball1.currentRadius;
var r2 = ball2.currentRadius;
var r1 = floatingObject1.currentRadius;
var r2 = floatingObject2.currentRadius;
var distance = Math.sqrt(Math.pow(ball2.currentPosition.x - ball1.currentPosition.x, 2) + Math.pow(ball2.currentPosition.y - ball1.currentPosition.y, 2));
var distance = Math.sqrt(Math.pow(floatingObject2.currentPosition.x - floatingObject1.currentPosition.x, 2) + Math.pow(floatingObject2.currentPosition.y - floatingObject1.currentPosition.y, 2));
if (distance > (r1 + r2)) {
// No solutions, the circles are too far apart.
@@ -366,10 +366,10 @@ function newFloatingSpace() {
/* This function detects weather the point x,y is inside any of the floatingObjects. */
for (var i = 0; i < thisObject.floatingObjects.length; i++) {
var ball = thisObject.floatingObjects[i];
var distance = Math.sqrt(Math.pow(ball.currentPosition.x - x, 2) + Math.pow(ball.currentPosition.y - y, 2));
var floatingObject = thisObject.floatingObjects[i];
var distance = Math.sqrt(Math.pow(floatingObject.currentPosition.x - x, 2) + Math.pow(floatingObject.currentPosition.y - y, 2));
if (distance < ball.currentRadius) {
if (distance < floatingObject.currentRadius) {
return i;
}
}
@@ -377,15 +377,15 @@ function newFloatingSpace() {
}
function isInsideBall(ballIndex, x, y) {
function isInsideFloatingObject(floatingObjectIndex, x, y) {
/* This function detects weather the point x,y is inside one particular floatingObjects. */
var ball = thisObject.floatingObjects[ballIndex];
var distance = Math.sqrt(Math.pow(ball.currentPosition.x - x, 2) + Math.pow(ball.currentPosition.y - y, 2));
var floatingObject = thisObject.floatingObjects[floatingObjectIndex];
var distance = Math.sqrt(Math.pow(floatingObject.currentPosition.x - x, 2) + Math.pow(floatingObject.currentPosition.y - y, 2));
if (distance < ball.currentRadius) {
if (distance < floatingObject.currentRadius) {
return true;
}
@@ -397,45 +397,45 @@ function newFloatingSpace() {
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}
function resolveCollision(ball1, ball2) {
function resolveCollision(floatingObject1, floatingObject2) {
/* This function changes speed and position of floatingObjects that are in collision */
var collisionision_angle = Math.atan2((ball2.currentPosition.y - ball1.currentPosition.y), (ball2.currentPosition.x - ball1.currentPosition.x));
var collisionision_angle = Math.atan2((floatingObject2.currentPosition.y - floatingObject1.currentPosition.y), (floatingObject2.currentPosition.x - floatingObject1.currentPosition.x));
var speed1 = Math.sqrt(ball1.currentSpeed.x * ball1.currentSpeed.x + ball1.currentSpeed.y * ball1.currentSpeed.y); // Magnitude of Speed Vector for ball 1
var speed2 = Math.sqrt(ball2.currentSpeed.x * ball2.currentSpeed.x + ball2.currentSpeed.y * ball2.currentSpeed.y); // Magnitude of Speed Vector for ball 2
var speed1 = Math.sqrt(floatingObject1.currentSpeed.x * floatingObject1.currentSpeed.x + floatingObject1.currentSpeed.y * floatingObject1.currentSpeed.y); // Magnitude of Speed Vector for floatingObject 1
var speed2 = Math.sqrt(floatingObject2.currentSpeed.x * floatingObject2.currentSpeed.x + floatingObject2.currentSpeed.y * floatingObject2.currentSpeed.y); // Magnitude of Speed Vector for floatingObject 2
var direction_1 = Math.atan2(ball1.currentSpeed.y, ball1.currentSpeed.x);
var direction_2 = Math.atan2(ball2.currentSpeed.y, ball2.currentSpeed.x);
var direction_1 = Math.atan2(floatingObject1.currentSpeed.y, floatingObject1.currentSpeed.x);
var direction_2 = Math.atan2(floatingObject2.currentSpeed.y, floatingObject2.currentSpeed.x);
var new_xspeed_1 = speed1 * Math.cos(direction_1 - collisionision_angle);
var new_yspeed_1 = speed1 * Math.sin(direction_1 - collisionision_angle);
var new_xspeed_2 = speed2 * Math.cos(direction_2 - collisionision_angle);
var new_yspeed_2 = speed2 * Math.sin(direction_2 - collisionision_angle);
var final_xspeed_1 = ((ball1.currentMass - ball2.currentMass) * new_xspeed_1 + (ball2.currentMass + ball2.currentMass) * new_xspeed_2) / (ball1.currentMass + ball2.currentMass);
var final_xspeed_2 = ((ball1.currentMass + ball1.currentMass) * new_xspeed_1 + (ball2.currentMass - ball1.currentMass) * new_xspeed_2) / (ball1.currentMass + ball2.currentMass);
var final_xspeed_1 = ((floatingObject1.currentMass - floatingObject2.currentMass) * new_xspeed_1 + (floatingObject2.currentMass + floatingObject2.currentMass) * new_xspeed_2) / (floatingObject1.currentMass + floatingObject2.currentMass);
var final_xspeed_2 = ((floatingObject1.currentMass + floatingObject1.currentMass) * new_xspeed_1 + (floatingObject2.currentMass - floatingObject1.currentMass) * new_xspeed_2) / (floatingObject1.currentMass + floatingObject2.currentMass);
var final_yspeed_1 = new_yspeed_1;
var final_yspeed_2 = new_yspeed_2;
var cosAngle = Math.cos(collisionision_angle);
var sinAngle = Math.sin(collisionision_angle);
ball1.currentSpeed.x = cosAngle * final_xspeed_1 - sinAngle * final_yspeed_1;
ball1.currentSpeed.y = sinAngle * final_xspeed_1 + cosAngle * final_yspeed_1;
floatingObject1.currentSpeed.x = cosAngle * final_xspeed_1 - sinAngle * final_yspeed_1;
floatingObject1.currentSpeed.y = sinAngle * final_xspeed_1 + cosAngle * final_yspeed_1;
ball2.currentSpeed.x = cosAngle * final_xspeed_2 - sinAngle * final_yspeed_2;
ball2.currentSpeed.y = sinAngle * final_xspeed_2 + cosAngle * final_yspeed_2;
floatingObject2.currentSpeed.x = cosAngle * final_xspeed_2 - sinAngle * final_yspeed_2;
floatingObject2.currentSpeed.y = sinAngle * final_xspeed_2 + cosAngle * final_yspeed_2;
var pos1 = {
x: ball1.currentPosition.x,
y: ball1.currentPosition.y
x: floatingObject1.currentPosition.x,
y: floatingObject1.currentPosition.y
};
var pos2 = {
x: ball2.currentPosition.x,
y: ball2.currentPosition.y
x: floatingObject2.currentPosition.x,
y: floatingObject2.currentPosition.y
};
// get the mtd
@@ -444,10 +444,10 @@ function newFloatingSpace() {
y: pos1.y - pos2.y
};
var d = Math.sqrt(Math.pow(ball2.currentPosition.x - ball1.currentPosition.x, 2) + Math.pow(ball2.currentPosition.y - ball1.currentPosition.y, 2));
var d = Math.sqrt(Math.pow(floatingObject2.currentPosition.x - floatingObject1.currentPosition.x, 2) + Math.pow(floatingObject2.currentPosition.y - floatingObject1.currentPosition.y, 2));
// minimum translation distance to push floatingObjects apart after intersecting
var scalar = (((ball1.currentRadius + ball2.currentRadius) - d) / d);
var scalar = (((floatingObject1.currentRadius + floatingObject2.currentRadius) - d) / d);
var minTD = {
x: posDiff.x * scalar,
@@ -456,8 +456,8 @@ function newFloatingSpace() {
// resolve intersection --
// computing inverse mass quantities
var im1 = 1 / ball1.currentMass;
var im2 = 1 / ball2.currentMass;
var im1 = 1 / floatingObject1.currentMass;
var im2 = 1 / floatingObject2.currentMass;
// push-pull them apart based off their mass
@@ -466,8 +466,8 @@ function newFloatingSpace() {
pos2.x = pos2.x - minTD.x * (im2 / (im1 + im2));
pos2.y = pos2.y - minTD.y * (im2 / (im1 + im2));
ball1.currentPosition = pos1;
ball2.currentPosition = pos2;
floatingObject1.currentPosition = pos1;
floatingObject2.currentPosition = pos2;
}
}
+3 -3
View File
@@ -305,7 +305,7 @@
productPlotter.panels.push(plotterPanelHandle);
}
/* Create The Profie Picture Ball */
/* Create The Profie Picture FloatingObject */
if (productPlotter.plotter.profile !== undefined) {
@@ -315,7 +315,7 @@
productPlotter.plotter.profile.downLabel = pProductCard.bot.displayName;
productPlotter.plotter.profile.imageId = imageId;
productPlotter.profile = canvas.floatingSpace.createNewBall(productPlotter.plotter.profile, thisObject.container)
productPlotter.profile = canvas.floatingSpace.createNewFloatingObject(productPlotter.plotter.profile, thisObject.container)
}
@@ -369,7 +369,7 @@
if (productPlotters[i].profile !== undefined) {
canvas.floatingSpace.destroyBall(productPlotters[i].profile);
canvas.floatingSpace.destroyFloatingObject(productPlotters[i].profile);
}