New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

d3-force-3d

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-force-3d - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

dist/d3-force-3d.js

@@ -1,2 +0,2 @@

// https://github.com/vasturiano/d3-force-3d v1.1.1 Copyright 2018 Vasco Asturiano
// https://github.com/vasturiano/d3-force-3d v1.1.2 Copyright 2018 Vasco Asturiano
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-binarytree'), require('d3-quadtree'), require('d3-octree'), require('d3-collection'), require('d3-dispatch'), require('d3-timer')) :

@@ -1,2 +0,2 @@

// https://github.com/vasturiano/d3-force-3d v1.1.1 Copyright 2018 Vasco Asturiano
// https://github.com/vasturiano/d3-force-3d v1.1.2 Copyright 2018 Vasco Asturiano
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-binarytree"),require("d3-quadtree"),require("d3-octree"),require("d3-collection"),require("d3-dispatch"),require("d3-timer")):"function"==typeof define&&define.amd?define(["exports","d3-binarytree","d3-quadtree","d3-octree","d3-collection","d3-dispatch","d3-timer"],t):t(n.d3=n.d3||{},n.d3,n.d3,n.d3,n.d3,n.d3,n.d3)}(this,function(n,t,e,r,i,u,o){"use strict";function f(n){return function(){return n}}function a(){return 1e-6*(Math.random()-.5)}function c(n){return n.x+n.vx}function l(n){return n.y+n.vy}function h(n){return n.z+n.vz}function v(n){return n.index}function y(n,t){var e=n.get(t);if(!e)throw new Error("missing: "+t);return e}var d=3;function s(n){return n.x}function g(n){return n.y}function x(n){return n.z}var z=10,p=Math.PI*(3-Math.sqrt(5)),M=Math.PI/24;n.forceCenter=function(n,t,e){var r;function i(){var i,u,o=r.length,f=0,a=0,c=0;for(i=0;i<o;++i)f+=(u=r[i]).x||0,a+=u.y||0,c+=u.z||0;for(f=f/o-n,a=a/o-t,c=c/o-e,i=0;i<o;++i)u=r[i],f&&(u.x-=f),a&&(u.y-=a),c&&(u.z-=c)}return null==n&&(n=0),null==t&&(t=0),null==e&&(e=0),i.initialize=function(n){r=n},i.x=function(t){return arguments.length?(n=+t,i):n},i.y=function(n){return arguments.length?(t=+n,i):t},i.z=function(n){return arguments.length?(e=+n,i):e},i},n.forceCollide=function(n){var i,u,o,v=1,y=1;function d(){for(var n,f,d,g,x,z,p,M,q=i.length,w=0;w<y;++w)for(f=(1===u?t.binarytree(i,c):2===u?e.quadtree(i,c,l):3===u?r.octree(i,c,l,h):null).visitAfter(s),n=0;n<q;++n)d=i[n],p=o[d.index],M=p*p,g=d.x+d.vx,u>1&&(x=d.y+d.vy),u>2&&(z=d.z+d.vz),f.visit(N);function N(n,t,e,r,i,o,f){var c=[t,e,r,i,o,f],l=c[0],h=c[1],y=c[2],s=c[u],q=c[u+1],w=c[u+2],N=n.data,m=n.r,A=p+m;if(!N)return l>g+A||s<g-A||u>1&&(h>x+A||q<x-A)||u>2&&(y>z+A||w<z-A);if(N.index>d.index){var b=g-N.x-N.vx,k=u>1?x-N.y-N.vy:0,j=u>2?z-N.z-N.vz:0,D=b*b+k*k+j*j;D<A*A&&(0===b&&(D+=(b=a())*b),u>1&&0===k&&(D+=(k=a())*k),u>2&&0===j&&(D+=(j=a())*j),D=(A-(D=Math.sqrt(D)))/D*v,d.vx+=(b*=D)*(A=(m*=m)/(M+m)),u>1&&(d.vy+=(k*=D)*A),u>2&&(d.vz+=(j*=D)*A),N.vx-=b*(A=1-A),u>1&&(N.vy-=k*A),u>2&&(N.vz-=j*A))}}}function s(n){if(n.data)return n.r=o[n.data.index];for(var t=n.r=0;t<Math.pow(2,u);++t)n[t]&&n[t].r>n.r&&(n.r=n[t].r)}function g(){if(i){var t,e,r=i.length;for(o=new Array(r),t=0;t<r;++t)e=i[t],o[e.index]=+n(e,t,i)}}return"function"!=typeof n&&(n=f(null==n?1:+n)),d.initialize=function(n,t){i=n,u=t,g()},d.iterations=function(n){return arguments.length?(y=+n,d):y},d.strength=function(n){return arguments.length?(v=+n,d):v},d.radius=function(t){return arguments.length?(n="function"==typeof t?t:f(+t),g(),d):n},d},n.forceLink=function(n){var t,e,r,u,o,c,l=v,h=function(n){return 1/Math.min(o[n.source.index],o[n.target.index])},d=f(30),s=1;function g(r){for(var i=0,o=n.length;i<s;++i)for(var f,l,h,v,y,d=0,g=0,x=0,z=0;d<o;++d)l=(f=n[d]).source,g=(h=f.target).x+h.vx-l.x-l.vx||a(),u>1&&(x=h.y+h.vy-l.y-l.vy||a()),u>2&&(z=h.z+h.vz-l.z-l.vz||a()),g*=v=((v=Math.sqrt(g*g+x*x+z*z))-e[d])/v*r*t[d],x*=v,z*=v,h.vx-=g*(y=c[d]),u>1&&(h.vy-=x*y),u>2&&(h.vz-=z*y),l.vx+=g*(y=1-y),u>1&&(l.vy+=x*y),u>2&&(l.vz+=z*y)}function x(){if(r){var u,f,a=r.length,h=n.length,v=i.map(r,l);for(u=0,o=new Array(a);u<h;++u)(f=n[u]).index=u,"object"!=typeof f.source&&(f.source=y(v,f.source)),"object"!=typeof f.target&&(f.target=y(v,f.target)),o[f.source.index]=(o[f.source.index]||0)+1,o[f.target.index]=(o[f.target.index]||0)+1;for(u=0,c=new Array(h);u<h;++u)f=n[u],c[u]=o[f.source.index]/(o[f.source.index]+o[f.target.index]);t=new Array(h),z(),e=new Array(h),p()}}function z(){if(r)for(var e=0,i=n.length;e<i;++e)t[e]=+h(n[e],e,n)}function p(){if(r)for(var t=0,i=n.length;t<i;++t)e[t]=+d(n[t],t,n)}return null==n&&(n=[]),g.initialize=function(n,t){r=n,u=t,x()},g.links=function(t){return arguments.length?(n=t,x(),g):n},g.id=function(n){return arguments.length?(l=n,g):l},g.iterations=function(n){return arguments.length?(s=+n,g):s},g.strength=function(n){return arguments.length?(h="function"==typeof n?n:f(+n),z(),g):h},g.distance=function(n){return arguments.length?(d="function"==typeof n?n:f(+n),p(),g):d},g},n.forceManyBody=function(){var n,i,u,o,c,l=f(-30),h=1,v=1/0,y=.81;function d(f){var a,c=n.length,l=(1===i?t.binarytree(n,s):2===i?e.quadtree(n,s,g):3===i?r.octree(n,s,g,x):null).visitAfter(p);for(o=f,a=0;a<c;++a)u=n[a],l.visit(M)}function z(){if(n){var t,e,r=n.length;for(c=new Array(r),t=0;t<r;++t)e=n[t],c[e.index]=+l(e,t,n)}}function p(n){var t,e,r,u,o,f,a=0,l=0;if(n.length){for(r=u=o=f=0;f<4;++f)(t=n[f])&&(e=Math.abs(t.value))&&(a+=t.value,l+=e,r+=e*(t.x||0),u+=e*(t.y||0),o+=e*(t.z||0));n.x=r/l,i>1&&(n.y=u/l),i>2&&(n.z=o/l)}else{(t=n).x=t.data.x,i>1&&(t.y=t.data.y),i>2&&(t.z=t.data.z);do{a+=c[t.data.index]}while(t=t.next)}n.value=a}function M(n,t,e,r,f){if(!n.value)return!0;var l=[e,r,f][i-1],d=n.x-u.x,s=i>1?n.y-u.y:0,g=i>2?n.z-u.z:0,x=l-t,z=d*d+s*s+g*g;if(x*x/y<z)return z<v&&(0===d&&(z+=(d=a())*d),i>1&&0===s&&(z+=(s=a())*s),i>2&&0===g&&(z+=(g=a())*g),z<h&&(z=Math.sqrt(h*z)),u.vx+=d*n.value*o/z,i>1&&(u.vy+=s*n.value*o/z),i>2&&(u.vz+=g*n.value*o/z)),!0;if(!(n.length||z>=v)){(n.data!==u||n.next)&&(0===d&&(z+=(d=a())*d),i>1&&0===s&&(z+=(s=a())*s),i>2&&0===g&&(z+=(g=a())*g),z<h&&(z=Math.sqrt(h*z)));do{n.data!==u&&(x=c[n.data.index]*o/z,u.vx+=d*x,i>1&&(u.vy+=s*x),i>2&&(u.vz+=g*x))}while(n=n.next)}}return d.initialize=function(t,e){n=t,i=e,z()},d.strength=function(n){return arguments.length?(l="function"==typeof n?n:f(+n),z(),d):l},d.distanceMin=function(n){return arguments.length?(h=n*n,d):Math.sqrt(h)},d.distanceMax=function(n){return arguments.length?(v=n*n,d):Math.sqrt(v)},d.theta=function(n){return arguments.length?(y=n*n,d):Math.sqrt(y)},d},n.forceRadial=function(n,t,e,r){var i,u,o,a,c=f(.1);function l(n){for(var f=0,c=i.length;f<c;++f){var l=i[f],h=l.x-t||1e-6,v=(l.y||0)-e||1e-6,y=(l.z||0)-r||1e-6,d=Math.sqrt(h*h+v*v+y*y),s=(a[f]-d)*o[f]*n/d;l.vx+=h*s,u>1&&(l.vy+=v*s),u>2&&(l.vz+=y*s)}}function h(){if(i){var t,e=i.length;for(o=new Array(e),a=new Array(e),t=0;t<e;++t)a[t]=+n(i[t],t,i),o[t]=isNaN(a[t])?0:+c(i[t],t,i)}}return"function"!=typeof n&&(n=f(+n)),null==t&&(t=0),null==e&&(e=0),null==r&&(r=0),l.initialize=function(n,t){i=n,u=t,h()},l.strength=function(n){return arguments.length?(c="function"==typeof n?n:f(+n),h(),l):c},l.radius=function(t){return arguments.length?(n="function"==typeof t?t:f(+t),h(),l):n},l.x=function(n){return arguments.length?(t=+n,l):t},l.y=function(n){return arguments.length?(e=+n,l):e},l.z=function(n){return arguments.length?(r=+n,l):r},l},n.forceSimulation=function(n,t){t=t||2;var e,r=Math.min(d,Math.max(1,Math.round(t))),f=1,a=.001,c=1-Math.pow(a,1/300),l=0,h=.6,v=i.map(),y=o.timer(g),s=u.dispatch("tick","end");function g(){x(),s.call("tick",e),f<a&&(y.stop(),s.call("end",e))}function x(){var t,e,i=n.length;for(f+=(l-f)*c,v.each(function(n){n(f)}),t=0;t<i;++t)null==(e=n[t]).fx?e.x+=e.vx*=h:(e.x=e.fx,e.vx=0),r>1&&(null==e.fy?e.y+=e.vy*=h:(e.y=e.fy,e.vy=0)),r>2&&(null==e.fz?e.z+=e.vz*=h:(e.z=e.fz,e.vz=0))}function q(){for(var t,e=0,i=n.length;e<i;++e){if((t=n[e]).index=e,isNaN(t.x)||r>1&&isNaN(t.y)||r>2&&isNaN(t.z)){var u=z*(r>2?Math.cbrt(e):r>1?Math.sqrt(e):e),o=e*p,f=e*M;t.x=u*(r>1?Math.cos(o):1),r>1&&(t.y=u*Math.sin(o)),r>2&&(t.z=u*Math.sin(f))}(isNaN(t.vx)||r>1&&isNaN(t.vy)||r>2&&isNaN(t.vz))&&(t.vx=0,r>1&&(t.vy=0),r>2&&(t.vz=0))}}function w(t){return t.initialize&&t.initialize(n,r),t}return null==n&&(n=[]),q(),e={tick:x,restart:function(){return y.restart(g),e},stop:function(){return y.stop(),e},numDimensions:function(n){return arguments.length?(r=Math.min(d,Math.max(1,Math.round(n))),v.each(w),e):r},nodes:function(t){return arguments.length?(n=t,q(),v.each(w),e):n},alpha:function(n){return arguments.length?(f=+n,e):f},alphaMin:function(n){return arguments.length?(a=+n,e):a},alphaDecay:function(n){return arguments.length?(c=+n,e):+c},alphaTarget:function(n){return arguments.length?(l=+n,e):l},velocityDecay:function(n){return arguments.length?(h=1-n,e):1-h},force:function(n,t){return arguments.length>1?(null==t?v.remove(n):v.set(n,w(t)),e):v.get(n)},find:function(){var t,e,i,u,o,f,a=Array.prototype.slice.call(arguments),c=a.shift()||0,l=(r>1?a.shift():null)||0,h=(r>2?a.shift():null)||0,v=a.shift()||1/0,y=0,d=n.length;for(v*=v,y=0;y<d;++y)(u=(t=c-(o=n[y]).x)*t+(e=l-(o.y||0))*e+(i=h-(o.z||0))*i)<v&&(f=o,v=u);return f},on:function(n,t){return arguments.length>1?(s.on(n,t),e):s.on(n)}}},n.forceX=function(n){var t,e,r,i=f(.1);function u(n){for(var i,u=0,o=t.length;u<o;++u)(i=t[u]).vx+=(r[u]-i.x)*e[u]*n}function o(){if(t){var u,o=t.length;for(e=new Array(o),r=new Array(o),u=0;u<o;++u)e[u]=isNaN(r[u]=+n(t[u],u,t))?0:+i(t[u],u,t)}}return"function"!=typeof n&&(n=f(null==n?0:+n)),u.initialize=function(n){t=n,o()},u.strength=function(n){return arguments.length?(i="function"==typeof n?n:f(+n),o(),u):i},u.x=function(t){return arguments.length?(n="function"==typeof t?t:f(+t),o(),u):n},u},n.forceY=function(n){var t,e,r,i=f(.1);function u(n){for(var i,u=0,o=t.length;u<o;++u)(i=t[u]).vy+=(r[u]-i.y)*e[u]*n}function o(){if(t){var u,o=t.length;for(e=new Array(o),r=new Array(o),u=0;u<o;++u)e[u]=isNaN(r[u]=+n(t[u],u,t))?0:+i(t[u],u,t)}}return"function"!=typeof n&&(n=f(null==n?0:+n)),u.initialize=function(n){t=n,o()},u.strength=function(n){return arguments.length?(i="function"==typeof n?n:f(+n),o(),u):i},u.y=function(t){return arguments.length?(n="function"==typeof t?t:f(+t),o(),u):n},u},n.forceZ=function(n){var t,e,r,i=f(.1);function u(n){for(var i,u=0,o=t.length;u<o;++u)(i=t[u]).vz+=(r[u]-i.z)*e[u]*n}function o(){if(t){var u,o=t.length;for(e=new Array(o),r=new Array(o),u=0;u<o;++u)e[u]=isNaN(r[u]=+n(t[u],u,t))?0:+i(t[u],u,t)}}return"function"!=typeof n&&(n=f(null==n?0:+n)),u.initialize=function(n){t=n,o()},u.strength=function(n){return arguments.length?(i="function"==typeof n?n:f(+n),o(),u):i},u.z=function(t){return arguments.length?(n="function"==typeof t?t:f(+t),o(),u):n},u},Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-force-3d",
"version": "1.1.1",
"version": "1.1.2",
"description": "Force-directed graph layout in 1D, 2D or 3D using velocity Verlet integration.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -29,9 +29,15 @@ # d3-force-3d

If you use NPM, `npm install d3-force-3d`. Otherwise, download the [latest release](https://github.com/vasturiano/d3-force-3d/releases/latest). You can also load directly from the global [npmJS](https://npmjs.com) registry, as a bundled [standalone library](https://unpkg.com/d3-force-3d/build/d3-force-3d.bundle.min.js). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_force` global is exported:
If you use NPM, `npm install d3-force-3d`. You can also load directly from the global [npmJS](https://npmjs.com) registry, as a bundled [standalone library](https://unpkg.com/d3-force-3d). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
<script src="https://unpkg.com/d3-force-3d/build/d3-force-3d.bundle.min.js"></script>
<script src="https://d3js.org/d3-collection.v1.min.js"></script>
<script src="https://d3js.org/d3-dispatch.v1.min.js"></script>
<script src="https://d3js.org/d3-timer.v1.min.js"></script>
<script src="https://d3js.org/d3-quadtree.v1.min.js"></script>
<script src="https://unpkg.com/d3-binarytree"></script>
<script src="https://unpkg.com/d3-octree"></script>
<script src="https://unpkg.com/d3-force-3d"></script>
<script>
var simulation = d3_force.forceSimulation(nodes);
var simulation = d3.forceSimulation(nodes);

@@ -38,0 +44,0 @@ </script>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc