three-forcegraph
Advanced tools
Comparing version 1.36.1 to 1.37.0
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var three$2 = require('three'); | ||
var d3Force3d = require('d3-force-3d'); | ||
var graph = _interopDefault(require('ngraph.graph')); | ||
var forcelayout = _interopDefault(require('ngraph.forcelayout')); | ||
var forcelayout3d = _interopDefault(require('ngraph.forcelayout3d')); | ||
var Kapsule = _interopDefault(require('kapsule')); | ||
var accessorFn = _interopDefault(require('accessor-fn')); | ||
var graph = require('ngraph.graph'); | ||
var forcelayout = require('ngraph.forcelayout'); | ||
var Kapsule = require('kapsule'); | ||
var accessorFn = require('accessor-fn'); | ||
var d3Array = require('d3-array'); | ||
var dataJoint = _interopDefault(require('data-joint')); | ||
var dataJoint = require('data-joint'); | ||
var d3Scale = require('d3-scale'); | ||
var d3ScaleChromatic = require('d3-scale-chromatic'); | ||
var tinyColor = _interopDefault(require('tinycolor2')); | ||
var tinyColor = require('tinycolor2'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var graph__default = /*#__PURE__*/_interopDefaultLegacy(graph); | ||
var forcelayout__default = /*#__PURE__*/_interopDefaultLegacy(forcelayout); | ||
var Kapsule__default = /*#__PURE__*/_interopDefaultLegacy(Kapsule); | ||
var accessorFn__default = /*#__PURE__*/_interopDefaultLegacy(accessorFn); | ||
var dataJoint__default = /*#__PURE__*/_interopDefaultLegacy(dataJoint); | ||
var tinyColor__default = /*#__PURE__*/_interopDefaultLegacy(tinyColor); | ||
function _typeof(obj) { | ||
@@ -340,3 +346,3 @@ "@babel/helpers - typeof"; | ||
return dataJoint(data, scene.children.filter(objFilter), function (obj) { | ||
return dataJoint__default['default'](data, scene.children.filter(objFilter), function (obj) { | ||
return scene.add(obj); | ||
@@ -352,7 +358,7 @@ }, function (obj) { | ||
var colorStr2Hex = function colorStr2Hex(str) { | ||
return isNaN(str) ? parseInt(tinyColor(str).toHex(), 16) : str; | ||
return isNaN(str) ? parseInt(tinyColor__default['default'](str).toHex(), 16) : str; | ||
}; | ||
var colorAlpha = function colorAlpha(str) { | ||
return isNaN(str) ? tinyColor(str).getAlpha() : 1; | ||
return isNaN(str) ? tinyColor__default['default'](str).getAlpha() : 1; | ||
}; | ||
@@ -486,5 +492,4 @@ | ||
var ngraph = { | ||
graph: graph, | ||
forcelayout: forcelayout, | ||
forcelayout3d: forcelayout3d | ||
graph: graph__default['default'], | ||
forcelayout: forcelayout__default['default'] | ||
}; | ||
@@ -496,3 +501,3 @@ | ||
var applyMatrix4Fn = new three.BufferGeometry().applyMatrix4 ? 'applyMatrix4' : 'applyMatrix'; | ||
var ForceGraph = Kapsule({ | ||
var ForceGraph = Kapsule__default['default']({ | ||
props: { | ||
@@ -703,3 +708,13 @@ jsonUrl: { | ||
}, | ||
ngraphPhysics: {}, | ||
ngraphPhysics: { | ||
"default": { | ||
// defaults from https://github.com/anvaka/ngraph.physics.simulator/blob/master/index.js | ||
timeStep: 20, | ||
gravity: -1.2, | ||
theta: 0.8, | ||
springLength: 30, | ||
springCoefficient: 0.0008, | ||
dragCoefficient: 0.02 | ||
} | ||
}, | ||
warmupTicks: { | ||
@@ -806,6 +821,6 @@ "default": 0, | ||
var linkWidthAccessor = accessorFn(state.linkWidth); | ||
var linkCurvatureAccessor = accessorFn(state.linkCurvature); | ||
var linkCurveRotationAccessor = accessorFn(state.linkCurveRotation); | ||
var linkThreeObjectExtendAccessor = accessorFn(state.linkThreeObjectExtend); | ||
var linkWidthAccessor = accessorFn__default['default'](state.linkWidth); | ||
var linkCurvatureAccessor = accessorFn__default['default'](state.linkCurvature); | ||
var linkCurveRotationAccessor = accessorFn__default['default'](state.linkCurveRotation); | ||
var linkThreeObjectExtendAccessor = accessorFn__default['default'](state.linkThreeObjectExtend); | ||
state.graphData.links.forEach(function (link) { | ||
@@ -957,5 +972,5 @@ var lineObj = link.__lineObj; | ||
// update link arrow position | ||
var arrowRelPosAccessor = accessorFn(state.linkDirectionalArrowRelPos); | ||
var arrowLengthAccessor = accessorFn(state.linkDirectionalArrowLength); | ||
var nodeValAccessor = accessorFn(state.nodeVal); | ||
var arrowRelPosAccessor = accessorFn__default['default'](state.linkDirectionalArrowRelPos); | ||
var arrowLengthAccessor = accessorFn__default['default'](state.linkDirectionalArrowLength); | ||
var nodeValAccessor = accessorFn__default['default'](state.nodeVal); | ||
state.graphData.links.forEach(function (link) { | ||
@@ -1012,3 +1027,3 @@ var arrowObj = link.__arrowObj; | ||
// update link particle positions | ||
var particleSpeedAccessor = accessorFn(state.linkDirectionalParticleSpeed); | ||
var particleSpeedAccessor = accessorFn__default['default'](state.linkDirectionalParticleSpeed); | ||
state.graphData.links.forEach(function (link) { | ||
@@ -1078,8 +1093,8 @@ var cyclePhotons = link.__photonsObj && link.__photonsObj.children; | ||
var particleWidthAccessor = accessorFn(state.linkDirectionalParticleWidth); | ||
var particleWidthAccessor = accessorFn__default['default'](state.linkDirectionalParticleWidth); | ||
var photonR = Math.ceil(particleWidthAccessor(link) * 10) / 10 / 2; | ||
var numSegments = state.linkDirectionalParticleResolution; | ||
var particleGeometry = new three.SphereBufferGeometry(photonR, numSegments, numSegments); | ||
var linkColorAccessor = accessorFn(state.linkColor); | ||
var particleColorAccessor = accessorFn(state.linkDirectionalParticleColor); | ||
var linkColorAccessor = accessorFn__default['default'](state.linkColor); | ||
var particleColorAccessor = accessorFn__default['default'](state.linkDirectionalParticleColor); | ||
var photonColor = particleColorAccessor(link) || linkColorAccessor(link) || '#f0f0f0'; | ||
@@ -1155,3 +1170,3 @@ var materialColor = new three.Color(colorStr2Hex(photonColor)); | ||
// Auto add color to uncolored nodes | ||
autoColorObjects(state.graphData.nodes, accessorFn(state.nodeAutoColorBy), state.nodeColor); | ||
autoColorObjects(state.graphData.nodes, accessorFn__default['default'](state.nodeAutoColorBy), state.nodeColor); | ||
} | ||
@@ -1161,3 +1176,3 @@ | ||
// Auto add color to uncolored links | ||
autoColorObjects(state.graphData.links, accessorFn(state.linkAutoColorBy), state.linkColor); | ||
autoColorObjects(state.graphData.links, accessorFn__default['default'](state.linkAutoColorBy), state.linkColor); | ||
} // Digest nodes WebGL objects | ||
@@ -1167,7 +1182,7 @@ | ||
if (state._flushObjects || hasAnyPropChanged(['graphData', 'nodeThreeObject', 'nodeThreeObjectExtend', 'nodeVal', 'nodeColor', 'nodeVisibility', 'nodeRelSize', 'nodeResolution', 'nodeOpacity'])) { | ||
var customObjectAccessor = accessorFn(state.nodeThreeObject); | ||
var customObjectExtendAccessor = accessorFn(state.nodeThreeObjectExtend); | ||
var valAccessor = accessorFn(state.nodeVal); | ||
var colorAccessor = accessorFn(state.nodeColor); | ||
var visibilityAccessor = accessorFn(state.nodeVisibility); | ||
var customObjectAccessor = accessorFn__default['default'](state.nodeThreeObject); | ||
var customObjectExtendAccessor = accessorFn__default['default'](state.nodeThreeObjectExtend); | ||
var valAccessor = accessorFn__default['default'](state.nodeVal); | ||
var colorAccessor = accessorFn__default['default'](state.nodeColor); | ||
var visibilityAccessor = accessorFn__default['default'](state.nodeVisibility); | ||
var sphereGeometries = {}; // indexed by node value | ||
@@ -1249,13 +1264,13 @@ | ||
if (state._flushObjects || hasAnyPropChanged(['graphData', 'linkThreeObject', 'linkThreeObjectExtend', 'linkMaterial', 'linkColor', 'linkWidth', 'linkVisibility', 'linkResolution', 'linkOpacity', 'linkDirectionalArrowLength', 'linkDirectionalArrowColor', 'linkDirectionalArrowResolution', 'linkDirectionalParticles', 'linkDirectionalParticleWidth', 'linkDirectionalParticleColor', 'linkDirectionalParticleResolution'])) { | ||
var _customObjectAccessor = accessorFn(state.linkThreeObject); | ||
var _customObjectAccessor = accessorFn__default['default'](state.linkThreeObject); | ||
var _customObjectExtendAccessor = accessorFn(state.linkThreeObjectExtend); | ||
var _customObjectExtendAccessor = accessorFn__default['default'](state.linkThreeObjectExtend); | ||
var customMaterialAccessor = accessorFn(state.linkMaterial); | ||
var customMaterialAccessor = accessorFn__default['default'](state.linkMaterial); | ||
var _visibilityAccessor = accessorFn(state.linkVisibility); | ||
var _visibilityAccessor = accessorFn__default['default'](state.linkVisibility); | ||
var _colorAccessor = accessorFn(state.linkColor); | ||
var _colorAccessor = accessorFn__default['default'](state.linkColor); | ||
var widthAccessor = accessorFn(state.linkWidth); | ||
var widthAccessor = accessorFn__default['default'](state.linkWidth); | ||
var cylinderGeometries = {}; // indexed by link width | ||
@@ -1384,4 +1399,4 @@ | ||
if (state.linkDirectionalArrowLength || changedProps.hasOwnProperty('linkDirectionalArrowLength')) { | ||
var arrowLengthAccessor = accessorFn(state.linkDirectionalArrowLength); | ||
var arrowColorAccessor = accessorFn(state.linkDirectionalArrowColor); | ||
var arrowLengthAccessor = accessorFn__default['default'](state.linkDirectionalArrowLength); | ||
var arrowColorAccessor = accessorFn__default['default'](state.linkDirectionalArrowColor); | ||
threeDigest(visibleLinks.filter(arrowLengthAccessor), state.graphScene, { | ||
@@ -1421,5 +1436,5 @@ objBindAttr: '__arrowObj', | ||
if (state.linkDirectionalParticles || changedProps.hasOwnProperty('linkDirectionalParticles')) { | ||
var particlesAccessor = accessorFn(state.linkDirectionalParticles); | ||
var particleWidthAccessor = accessorFn(state.linkDirectionalParticleWidth); | ||
var particleColorAccessor = accessorFn(state.linkDirectionalParticleColor); | ||
var particlesAccessor = accessorFn__default['default'](state.linkDirectionalParticles); | ||
var particleWidthAccessor = accessorFn__default['default'](state.linkDirectionalParticleWidth); | ||
var particleColorAccessor = accessorFn__default['default'](state.linkDirectionalParticleColor); | ||
var particleMaterials = {}; // indexed by link color | ||
@@ -1572,3 +1587,5 @@ | ||
}); | ||
layout = ngraph['forcelayout' + (state.numDimensions === 2 ? '' : '3d')](_graph, state.ngraphPhysics || undefined); | ||
layout = ngraph.forcelayout(_graph, _objectSpread2({ | ||
dimensions: state.numDimensions | ||
}, state.ngraphPhysics)); | ||
layout.graph = _graph; // Attach graph reference to layout | ||
@@ -1575,0 +1592,0 @@ } |
@@ -5,3 +5,2 @@ import { Group, Mesh, MeshLambertMaterial, Color, BufferGeometry, BufferAttribute, Matrix4, Vector3, SphereBufferGeometry, CylinderBufferGeometry, TubeBufferGeometry, ConeBufferGeometry, Line, LineBasicMaterial, QuadraticBezierCurve3, CubicBezierCurve3, Box3 } from 'three'; | ||
import forcelayout from 'ngraph.forcelayout'; | ||
import forcelayout3d from 'ngraph.forcelayout3d'; | ||
import Kapsule from 'kapsule'; | ||
@@ -482,4 +481,3 @@ import accessorFn from 'accessor-fn'; | ||
graph: graph, | ||
forcelayout: forcelayout, | ||
forcelayout3d: forcelayout3d | ||
forcelayout: forcelayout | ||
}; | ||
@@ -697,3 +695,13 @@ | ||
}, | ||
ngraphPhysics: {}, | ||
ngraphPhysics: { | ||
"default": { | ||
// defaults from https://github.com/anvaka/ngraph.physics.simulator/blob/master/index.js | ||
timeStep: 20, | ||
gravity: -1.2, | ||
theta: 0.8, | ||
springLength: 30, | ||
springCoefficient: 0.0008, | ||
dragCoefficient: 0.02 | ||
} | ||
}, | ||
warmupTicks: { | ||
@@ -1556,3 +1564,5 @@ "default": 0, | ||
}); | ||
layout = ngraph['forcelayout' + (state.numDimensions === 2 ? '' : '3d')](_graph, state.ngraphPhysics || undefined); | ||
layout = ngraph.forcelayout(_graph, _objectSpread2({ | ||
dimensions: state.numDimensions | ||
}, state.ngraphPhysics)); | ||
layout.graph = _graph; // Attach graph reference to layout | ||
@@ -1559,0 +1569,0 @@ } |
{ | ||
"name": "three-forcegraph", | ||
"version": "1.36.1", | ||
"version": "1.37.0", | ||
"description": "Force-directed graph as a ThreeJS 3d object", | ||
@@ -42,12 +42,11 @@ "unpkg": "dist/three-forcegraph.min.js", | ||
"accessor-fn": "^1.3.0", | ||
"d3-array": "^2.4.0", | ||
"d3-force-3d": "^2.1.0", | ||
"d3-scale": "^3.2.1", | ||
"d3-scale-chromatic": "^1.5.0", | ||
"d3-array": "^2.8.0", | ||
"d3-force-3d": "^2.2.0", | ||
"d3-scale": "^3.2.3", | ||
"d3-scale-chromatic": "^2.0.0", | ||
"data-joint": "^1.2.3", | ||
"kapsule": "^1.13.3", | ||
"ngraph.forcelayout": "^1.0.1", | ||
"ngraph.forcelayout3d": "^1.0.1", | ||
"ngraph.forcelayout": "^3.0.0", | ||
"ngraph.graph": "^19.1.0", | ||
"tinycolor2": "^1.4.1" | ||
"tinycolor2": "^1.4.2" | ||
}, | ||
@@ -58,16 +57,16 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@rollup/plugin-commonjs": "^13.0.0", | ||
"@rollup/plugin-node-resolve": "^8.1.0", | ||
"@babel/core": "^7.12.3", | ||
"@babel/plugin-proposal-class-properties": "^7.12.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"@rollup/plugin-commonjs": "^16.0.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@types/three": ">=0.103.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.20.0", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-dts": "^1.4.7", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"typescript": "^3.9.6" | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-dts": "^1.4.13", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.0.5" | ||
} | ||
} |
@@ -94,3 +94,3 @@ ThreeJS Force-Directed Graph | ||
| <b>d3Force</b>(<i>str</i>, [<i>fn</i>]) | Getter/setter for the internal forces that control the d3 simulation engine. Follows the same interface as `d3-force-3d`'s [simulation.force](https://github.com/vasturiano/d3-force-3d#simulation_force). Three forces are included by default: `'link'` (based on [forceLink](https://github.com/vasturiano/d3-force-3d#forceLink)), `'charge'` (based on [forceManyBody](https://github.com/vasturiano/d3-force-3d#forceManyBody)) and `'center'` (based on [forceCenter](https://github.com/vasturiano/d3-force-3d#forceCenter)). Each of these forces can be reconfigured, or new forces can be added to the system. This method is only applicable if using the d3 simulation engine. | | | ||
| <b>ngraphPhysics</b>([<i>object</i>]) | Specify custom physics configuration for ngraph, according to its [configuration object](https://github.com/anvaka/ngraph.forcelayout#configuring-physics) syntax. This method is only applicable if using the ngraph simulation engine. | *ngraph default* | | ||
| <b>ngraphPhysics</b>([<i>object</i>]) | Specify custom physics configuration for ngraph, according to its [configuration object](https://github.com/anvaka/ngraph.forcelayout#physics-simulator) syntax. This method is only applicable if using the ngraph simulation engine. | *ngraph default* | | ||
| <b>warmupTicks</b>([<i>int</i>]) | Getter/setter for number of layout engine cycles to dry-run at ignition before starting to render. | 0 | | ||
@@ -97,0 +97,0 @@ | <b>cooldownTicks</b>([<i>int</i>]) | Getter/setter for how many build-in frames to render before stopping and freezing the layout engine. | Infinity | |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
1024228
10184
1
16
+ Addedd3-scale-chromatic@2.0.0(transitive)
+ Addedngraph.forcelayout@3.3.1(transitive)
- Removedngraph.forcelayout3d@^1.0.1
- Removedd3-color@1.4.1(transitive)
- Removedd3-interpolate@1.4.0(transitive)
- Removedd3-scale-chromatic@1.5.0(transitive)
- Removedngraph.expose@1.0.0(transitive)
- Removedngraph.forcelayout@1.2.0(transitive)
- Removedngraph.forcelayout3d@1.2.0(transitive)
- Removedngraph.quadtreebh@1.0.0(transitive)
- Removedngraph.quadtreebh3d@1.0.0(transitive)
Updatedd3-array@^2.8.0
Updatedd3-force-3d@^2.2.0
Updatedd3-scale@^3.2.3
Updatedd3-scale-chromatic@^2.0.0
Updatedngraph.forcelayout@^3.0.0
Updatedtinycolor2@^1.4.2