diff --git a/dist/vis.js b/dist/vis.js index c8afdad8..9fc5e0f1 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 4.6.1-SNAPSHOT - * @date 2015-07-24 + * @date 2015-07-27 * * @license * Copyright (C) 2011-2014 Almende B.V, http://almende.com @@ -27653,7 +27653,8 @@ return /******/ (function(modules) { // webpackBootstrap var _this4 = this; if (this.body.nodes[nodeId] !== undefined) { - this.body.nodes[nodeId].move(Number(x), Number(y)); + this.body.nodes[nodeId].x = Number(x); + this.body.nodes[nodeId].y = Number(y); setTimeout(function () { _this4.body.emitter.emit("startSimulation"); }, 0); @@ -28142,19 +28143,6 @@ return /******/ (function(modules) { // webpackBootstrap return this.shape.boundingBox.left < obj.right && this.shape.boundingBox.right > obj.left && this.shape.boundingBox.top < obj.bottom && this.shape.boundingBox.bottom > obj.top; } - /** - * move the node to a new position. - * @param x - * @param y - */ - }, { - key: 'move', - value: function move(x, y) { - this.x = x; - this.y = y; - this.shape.move(x, y); - } - /** * clean all required things on delete. * @returns {*} @@ -28734,10 +28722,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - // possible to overload in the shapes. - }, { - key: 'move', - value: function move(x, y) {} + // possible cleanup for use in shapes }, { key: 'cleanup', value: function cleanup() {} @@ -33051,8 +33036,6 @@ return /******/ (function(modules) { // webpackBootstrap var timestep = this.options.timestep; var forces = this.physicsBody.forces; var velocities = this.physicsBody.velocities; - var x = node.x; - var y = node.y; // store the state so we can revert this.previousStates[nodeId] = { x: node.x, y: node.y, vx: velocities[nodeId].x, vy: velocities[nodeId].y }; @@ -33062,7 +33045,7 @@ return /******/ (function(modules) { // webpackBootstrap var ax = (forces[nodeId].x - dx) / node.options.mass; // acceleration velocities[nodeId].x += ax * timestep; // velocity velocities[nodeId].x = Math.abs(velocities[nodeId].x) > maxVelocity ? velocities[nodeId].x > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].x; - x += velocities[nodeId].x * timestep; // position + node.x += velocities[nodeId].x * timestep; // position } else { forces[nodeId].x = 0; velocities[nodeId].x = 0; @@ -33073,13 +33056,12 @@ return /******/ (function(modules) { // webpackBootstrap var ay = (forces[nodeId].y - dy) / node.options.mass; // acceleration velocities[nodeId].y += ay * timestep; // velocity velocities[nodeId].y = Math.abs(velocities[nodeId].y) > maxVelocity ? velocities[nodeId].y > 0 ? maxVelocity : -maxVelocity : velocities[nodeId].y; - y += velocities[nodeId].y * timestep; // position + node.y += velocities[nodeId].y * timestep; // position } else { forces[nodeId].y = 0; velocities[nodeId].y = 0; } - node.move(x, y); var totalVelocity = Math.sqrt(Math.pow(velocities[nodeId].x, 2) + Math.pow(velocities[nodeId].y, 2)); return totalVelocity; } diff --git a/lib/network/modules/NodesHandler.js b/lib/network/modules/NodesHandler.js index 967bd4f4..68e92e75 100644 --- a/lib/network/modules/NodesHandler.js +++ b/lib/network/modules/NodesHandler.js @@ -434,7 +434,8 @@ class NodesHandler { */ moveNode(nodeId, x, y) { if (this.body.nodes[nodeId] !== undefined) { - this.body.nodes[nodeId].move(Number(x), Number(y)); + this.body.nodes[nodeId].x = Number(x); + this.body.nodes[nodeId].y = Number(y); setTimeout(() => {this.body.emitter.emit("startSimulation")},0); } else { diff --git a/lib/network/modules/PhysicsEngine.js b/lib/network/modules/PhysicsEngine.js index 4d7d9b54..762469a5 100644 --- a/lib/network/modules/PhysicsEngine.js +++ b/lib/network/modules/PhysicsEngine.js @@ -403,8 +403,6 @@ class PhysicsEngine { let timestep = this.options.timestep; let forces = this.physicsBody.forces; let velocities = this.physicsBody.velocities; - let x = node.x; - let y = node.y; // store the state so we can revert this.previousStates[nodeId] = {x:node.x, y:node.y, vx:velocities[nodeId].x, vy:velocities[nodeId].y}; @@ -414,7 +412,7 @@ class PhysicsEngine { let ax = (forces[nodeId].x - dx) / node.options.mass; // acceleration velocities[nodeId].x += ax * timestep; // velocity velocities[nodeId].x = (Math.abs(velocities[nodeId].x) > maxVelocity) ? ((velocities[nodeId].x > 0) ? maxVelocity : -maxVelocity) : velocities[nodeId].x; - x += velocities[nodeId].x * timestep; // position + node.x += velocities[nodeId].x * timestep; // position } else { forces[nodeId].x = 0; @@ -426,14 +424,13 @@ class PhysicsEngine { let ay = (forces[nodeId].y - dy) / node.options.mass; // acceleration velocities[nodeId].y += ay * timestep; // velocity velocities[nodeId].y = (Math.abs(velocities[nodeId].y) > maxVelocity) ? ((velocities[nodeId].y > 0) ? maxVelocity : -maxVelocity) : velocities[nodeId].y; - y += velocities[nodeId].y * timestep; // position + node.y += velocities[nodeId].y * timestep; // position } else { forces[nodeId].y = 0; velocities[nodeId].y = 0; } - node.move(x,y); let totalVelocity = Math.sqrt(Math.pow(velocities[nodeId].x,2) + Math.pow(velocities[nodeId].y,2)); return totalVelocity; } diff --git a/lib/network/modules/components/Node.js b/lib/network/modules/components/Node.js index b05c9420..dabb6348 100644 --- a/lib/network/modules/components/Node.js +++ b/lib/network/modules/components/Node.js @@ -439,17 +439,6 @@ class Node { ); } - /** - * move the node to a new position. - * @param x - * @param y - */ - move(x,y) { - this.x = x; - this.y = y; - this.shape.move(x,y) - } - /** * clean all required things on delete. * @returns {*} diff --git a/lib/network/modules/components/nodes/util/NodeBase.js b/lib/network/modules/components/nodes/util/NodeBase.js index 20f3e45f..8bde8dec 100644 --- a/lib/network/modules/components/nodes/util/NodeBase.js +++ b/lib/network/modules/components/nodes/util/NodeBase.js @@ -68,8 +68,7 @@ class NodeBase { } } - // possible to overload in the shapes. - move(x,y) {} + // possible cleanup for use in shapes cleanup() {} }