Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

three-fatline

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-fatline - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

dist/three-fatline.js

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

// Version 0.1.0 three-fatline - https://github.com/vasturiano/three-fatline
// Version 0.1.1 three-fatline - https://github.com/vasturiano/three-fatline
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three')) :

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

// Version 0.1.0 three-fatline - https://github.com/vasturiano/three-fatline
// Version 0.1.1 three-fatline - https://github.com/vasturiano/three-fatline
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],e):e((t=t||self).THREE=t.THREE||{},t.THREE)}(this,function(t,e){"use strict";const n=window.THREE?window.THREE:{Box3:e.Box3,BufferGeometry:e.BufferGeometry,Float32BufferAttribute:e.Float32BufferAttribute,InstancedBufferGeometry:e.InstancedBufferGeometry,InstancedInterleavedBuffer:e.InstancedInterleavedBuffer,InterleavedBufferAttribute:e.InterleavedBufferAttribute,Sphere:e.Sphere,Vector3:e.Vector3,WireframeGeometry:e.WireframeGeometry},i=function(){n.InstancedBufferGeometry.call(this),this.type="LineSegmentsGeometry";new n.BufferGeometry;this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.addAttribute("position",new n.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.addAttribute("uv",new n.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))};var r,o;i.prototype=Object.assign(Object.create(n.InstancedBufferGeometry.prototype),{constructor:i,isLineSegmentsGeometry:!0,applyMatrix:function(t){var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(t.applyToBufferAttribute(e),t.applyToBufferAttribute(n),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new n.InstancedInterleavedBuffer(e,6,1);return this.addAttribute("instanceStart",new n.InterleavedBufferAttribute(i,3,0)),this.addAttribute("instanceEnd",new n.InterleavedBufferAttribute(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new n.InstancedInterleavedBuffer(e,6,1);return this.addAttribute("instanceColorStart",new n.InterleavedBufferAttribute(i,3,0)),this.addAttribute("instanceColorEnd",new n.InterleavedBufferAttribute(i,3,3)),this},fromWireframeGeometry:function(t){return this.setPositions(t.attributes.position.array),this},fromEdgesGeometry:function(t){return this.setPositions(t.attributes.position.array),this},fromMesh:function(t){return this.fromWireframeGeometry(new n.WireframeGeometry(t.geometry)),this},fromLineSegements:function(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this},computeBoundingBox:(o=new n.Box3,function(){null===this.boundingBox&&(this.boundingBox=new n.Box3);var t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),o.setFromBufferAttribute(e),this.boundingBox.union(o))}),computeBoundingSphere:(r=new n.Vector3,function(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere),null===this.boundingBox&&this.computeBoundingBox();var t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var o=0,a=0,s=t.count;a<s;a++)r.fromBufferAttribute(t,a),o=Math.max(o,i.distanceToSquared(r)),r.fromBufferAttribute(e,a),o=Math.max(o,i.distanceToSquared(r));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error("LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}),toJSON:function(){},clone:function(){},copy:function(t){return this}});const a=window.THREE?window.THREE:{};Object.assign(a,{LineSegmentsGeometry:i});const s=function(){a.LineSegmentsGeometry.call(this),this.type="LineGeometry"};s.prototype=Object.assign(Object.create(a.LineSegmentsGeometry.prototype),{constructor:s,isLineGeometry:!0,setPositions:function(t){for(var e=t.length-3,n=new Float32Array(2*e),i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return a.LineSegmentsGeometry.prototype.setPositions.call(this,n),this},setColors:function(t){for(var e=t.length-3,n=new Float32Array(2*e),i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return a.LineSegmentsGeometry.prototype.setColors.call(this,n),this},fromLine:function(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this},copy:function(t){return this}});const c=window.THREE?window.THREE:{ShaderLib:e.ShaderLib,ShaderMaterial:e.ShaderMaterial,UniformsLib:e.UniformsLib,UniformsUtils:e.UniformsUtils,Vector2:e.Vector2};c.UniformsLib.line={linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};const u=function(t){c.ShaderMaterial.call(this,{type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)};(u.prototype=Object.create(c.ShaderMaterial.prototype)).constructor=u,u.prototype.isLineMaterial=!0,u.prototype.copy=function(t){return c.ShaderMaterial.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.resolution=t.resolution,this};const f=window.THREE?window.THREE:{InstancedInterleavedBuffer:e.InstancedInterleavedBuffer,InterleavedBufferAttribute:e.InterleavedBufferAttribute,Mesh:e.Mesh,Vector3:e.Vector3};Object.assign(f,{LineMaterial:u,LineSegmentsGeometry:i});const d=function(t,e){f.Mesh.call(this),this.type="LineSegments2",this.geometry=void 0!==t?t:new f.LineSegmentsGeometry,this.material=void 0!==e?e:new f.LineMaterial({color:16777215*Math.random()})};var l,m;d.prototype=Object.assign(Object.create(f.Mesh.prototype),{constructor:d,isLineSegments2:!0,computeLineDistances:(l=new f.Vector3,m=new f.Vector3,function(){for(var t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.data.count),r=0,o=0,a=e.data.count;r<a;r++,o+=2)l.fromBufferAttribute(e,r),m.fromBufferAttribute(n,r),i[o]=0===o?0:i[o-1],i[o+1]=i[o]+l.distanceTo(m);var s=new f.InstancedInterleavedBuffer(i,2,1);return t.addAttribute("instanceDistanceStart",new f.InterleavedBufferAttribute(s,1,0)),t.addAttribute("instanceDistanceEnd",new f.InterleavedBufferAttribute(s,1,1)),this}),copy:function(t){return this}});const p=window.THREE?window.THREE:{};Object.assign(p,{LineGeometry:s,LineMaterial:u,LineSegments2:d});const h=function(t,e){p.LineSegments2.call(this),this.type="Line2",this.geometry=void 0!==t?t:new p.LineGeometry,this.material=void 0!==e?e:new p.LineMaterial({color:16777215*Math.random()})};h.prototype=Object.assign(Object.create(p.LineSegments2.prototype),{constructor:h,isLine2:!0,copy:function(t){return this}});const v=window.THREE?window.THREE:{InstancedInterleavedBuffer:e.InstancedInterleavedBuffer,InterleavedBufferAttribute:e.InterleavedBufferAttribute,Mesh:e.Mesh,Vector3:e.Vector3};Object.assign(v,{LineMaterial:u,LineSegmentsGeometry:i});const y=function(t,e){v.Mesh.call(this),this.type="Wireframe",this.geometry=void 0!==t?t:new v.LineSegmentsGeometry,this.material=void 0!==e?e:new v.LineMaterial({color:16777215*Math.random()})};y.prototype=Object.assign(Object.create(v.Mesh.prototype),{constructor:y,isWireframe:!0,computeLineDistances:function(){var t=new v.Vector3,e=new v.Vector3;return function(){for(var n=this.geometry,i=n.attributes.instanceStart,r=n.attributes.instanceEnd,o=new Float32Array(2*i.data.count),a=0,s=0,c=i.data.count;a<c;a++,s+=2)t.fromBufferAttribute(i,a),e.fromBufferAttribute(r,a),o[s]=0===s?0:o[s-1],o[s+1]=o[s]+t.distanceTo(e);var u=new v.InstancedInterleavedBuffer(o,2,1);return n.addAttribute("instanceDistanceStart",new v.InterleavedBufferAttribute(u,1,0)),n.addAttribute("instanceDistanceEnd",new v.InterleavedBufferAttribute(u,1,1)),this}}(),copy:function(t){return this}});const g=window.THREE?window.THREE:{WireframeGeometry:e.WireframeGeometry};Object.assign(g,{LineSegmentsGeometry:i});const b=function(t){g.LineSegmentsGeometry.call(this),this.type="WireframeGeometry2",this.fromWireframeGeometry(new g.WireframeGeometry(t))};b.prototype=Object.assign(Object.create(g.LineSegmentsGeometry.prototype),{constructor:b,isWireframeGeometry2:!0,copy:function(t){return this}}),t.Line2=h,t.LineGeometry=s,t.LineMaterial=u,t.LineSegments2=d,t.LineSegmentsGeometry=i,t.Wireframe=y,t.WireframeGeometry2=b,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "three-fatline",
"version": "0.1.0",
"version": "0.1.1",
"description": "A ThreeJS Line object with variable width",

@@ -5,0 +5,0 @@ "unpkg": "dist/three-fatline.min.js",

@@ -5,2 +5,2 @@ # three-fatline

See the [example](https://vasturiano.github.io/three.fatline/example/fat-lines/) ([source](https://github.com/vasturiano/three-fatline/blob/master/example/fat-lines/index.html))
See the [example](https://vasturiano.github.io/three-fatline/example/fat-lines/) ([source](https://github.com/vasturiano/three-fatline/blob/master/example/fat-lines/index.html))
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