three-stdlib 2.21.8 → 2.21.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Loader{constructor(t){super(t),this.defaultDPI=90,this.defaultUnit="px"}load(e,r,n,o){const i=this,s=new t.FileLoader(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(t){try{r(i.parse(t))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),n,o)}parse(e){const r=this;function n(t,e,r,n,i,s,c,a){if(0==e||0==r)return void t.lineTo(a.x,a.y);n=n*Math.PI/180,e=Math.abs(e),r=Math.abs(r);const l=(c.x-a.x)/2,u=(c.y-a.y)/2,y=Math.cos(n)*l+Math.sin(n)*u,f=-Math.sin(n)*l+Math.cos(n)*u;let h=e*e,p=r*r;const x=y*y,d=f*f,b=x/h+d/p;if(b>1){const t=Math.sqrt(b);h=(e*=t)*e,p=(r*=t)*r}const g=h*d+p*x,m=(h*p-g)/g;let A=Math.sqrt(Math.max(0,m));i===s&&(A=-A);const k=A*e*f/r,w=-A*r*y/e,v=Math.cos(n)*k-Math.sin(n)*w+(c.x+a.x)/2,M=Math.sin(n)*k+Math.cos(n)*w+(c.y+a.y)/2,P=o(1,0,(y-k)/e,(f-w)/r),T=o((y-k)/e,(f-w)/r,(-y-k)/e,(-f-w)/r)%(2*Math.PI);t.currentPath.absellipse(v,M,e,r,P,P+T,0===s,n)}function o(t,e,r,n){const o=t*r+e*n,i=Math.sqrt(t*t+e*e)*Math.sqrt(r*r+n*n);let s=Math.acos(Math.max(-1,Math.min(1,o/i)));return t*n-e*r<0&&(s=-s),s}function i(t,e){e=Object.assign({},e);let r={};if(t.hasAttribute("class")){const e=t.getAttribute("class").split(/\s/).filter(Boolean).map((t=>t.trim()));for(let t=0;t<e.length;t++)r=Object.assign(r,p["."+e[t]])}function n(n,o,i){void 0===i&&(i=function(t){return t.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),t}),t.hasAttribute(n)&&(e[o]=i(t.getAttribute(n))),r[n]&&(e[o]=i(r[n])),t.style&&""!==t.style[n]&&(e[o]=i(t.style[n]))}function o(t){return Math.max(0,Math.min(1,u(t)))}function i(t){return Math.max(0,u(t))}return t.hasAttribute("id")&&(r=Object.assign(r,p["#"+t.getAttribute("id")])),n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("stroke-linejoin","strokeLineJoin"),n("stroke-linecap","strokeLineCap"),n("stroke-miterlimit","strokeMiterLimit",i),n("visibility","visibility"),e}function s(t,e){return t-(e-t)}function c(t,e,r){if("string"!=typeof t)throw new TypeError("Invalid input: "+typeof t);const n={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};let o=0,i=!0,s="",c="";const a=[];function l(t,e,r){const n=new SyntaxError('Unexpected character "'+t+'" at index '+e+".");throw n.partial=r,n}function u(){""!==s&&(""===c?a.push(Number(s)):a.push(Number(s)*Math.pow(10,Number(c)))),s="",c=""}let y;const f=t.length;for(let h=0;h<f;h++)if(y=t[h],Array.isArray(e)&&e.includes(a.length%r)&&n.FLAGS.test(y))o=1,s=y,u();else{if(0===o){if(n.WHITESPACE.test(y))continue;if(n.DIGIT.test(y)||n.SIGN.test(y)){o=1,s=y;continue}if(n.POINT.test(y)){o=2,s=y;continue}n.COMMA.test(y)&&(i&&l(y,h,a),i=!0)}if(1===o){if(n.DIGIT.test(y)){s+=y;continue}if(n.POINT.test(y)){s+=y,o=2;continue}if(n.EXP.test(y)){o=3;continue}n.SIGN.test(y)&&1===s.length&&n.SIGN.test(s[0])&&l(y,h,a)}if(2===o){if(n.DIGIT.test(y)){s+=y;continue}if(n.EXP.test(y)){o=3;continue}n.POINT.test(y)&&"."===s[s.length-1]&&l(y,h,a)}if(3===o){if(n.DIGIT.test(y)){c+=y;continue}if(n.SIGN.test(y)){if(""===c){c+=y;continue}1===c.length&&n.SIGN.test(c)&&l(y,h,a)}}n.WHITESPACE.test(y)?(u(),o=0,i=!1):n.COMMA.test(y)?(u(),o=0,i=!0):n.SIGN.test(y)?(u(),o=1,s=y):n.POINT.test(y)?(u(),o=2,s=y):l(y,h,a)}return u(),a}const a=["mm","cm","in","pt","pc","px"],l={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:12,pc:1,px:-1},px:{px:1}};function u(t){let e,n="px";if("string"==typeof t||t instanceof String)for(let e=0,r=a.length;e<r;e++){const r=a[e];if(t.endsWith(r)){n=r,t=t.substring(0,t.length-r.length);break}}return"px"===n&&"px"!==r.defaultUnit?e=l.in[r.defaultUnit]/r.defaultDPI:(e=l[n][r.defaultUnit],e<0&&(e=l[n].in*r.defaultDPI)),e*parseFloat(t)}function y(t){const e=t.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function f(t){const e=t.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}const h=[],p={},x=[],d=new t.Matrix3,b=new t.Matrix3,g=new t.Matrix3,m=new t.Matrix3,A=new t.Vector2,k=new t.Vector3,w=new t.Matrix3,v=(new DOMParser).parseFromString(e,"image/svg+xml");!function e(r,o){if(1!==r.nodeType)return;const a=function(e){if(!(e.hasAttribute("transform")||"use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))))return null;const r=function(e){const r=new t.Matrix3,n=d;if("use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))){const t=u(e.getAttribute("x")),n=u(e.getAttribute("y"));r.translate(t,n)}if(e.hasAttribute("transform")){const t=e.getAttribute("transform").split(")");for(let e=t.length-1;e>=0;e--){const o=t[e].trim();if(""===o)continue;const i=o.indexOf("("),s=o.length;if(i>0&&i<s){const t=o.substr(0,i),e=c(o.substr(i+1,s-i-1));switch(n.identity(),t){case"translate":if(e.length>=1){const t=e[0];let r=t;e.length>=2&&(r=e[1]),n.translate(t,r)}break;case"rotate":if(e.length>=1){let t=0,r=0,o=0;t=-e[0]*Math.PI/180,e.length>=3&&(r=e[1],o=e[2]),b.identity().translate(-r,-o),g.identity().rotate(t),m.multiplyMatrices(g,b),b.identity().translate(r,o),n.multiplyMatrices(b,m)}break;case"scale":if(e.length>=1){const t=e[0];let r=t;e.length>=2&&(r=e[1]),n.scale(t,r)}break;case"skewX":1===e.length&&n.set(1,Math.tan(e[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":1===e.length&&n.set(1,0,0,Math.tan(e[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":6===e.length&&n.set(e[0],e[2],e[4],e[1],e[3],e[5],0,0,1)}}r.premultiply(n)}}return r}(e);x.length>0&&r.premultiply(x[x.length-1]);return w.copy(r),x.push(r),r}(r);let l=!0,v=null;switch(r.nodeName){case"svg":break;case"style":!function(t){if(!t.sheet||!t.sheet.cssRules||!t.sheet.cssRules.length)return;for(let e=0;e<t.sheet.cssRules.length;e++){const r=t.sheet.cssRules[e];if(1!==r.type)continue;const n=r.selectorText.split(/,/gm).filter(Boolean).map((t=>t.trim()));for(let t=0;t<n.length;t++)p[n[t]]=Object.assign(p[n[t]]||{},r.style)}}(r);break;case"g":o=i(r,o);break;case"path":o=i(r,o),r.hasAttribute("d")&&(v=function(e){const r=new t.ShapePath,o=new t.Vector2,i=new t.Vector2,a=new t.Vector2;let l=!0,u=!1;const y=e.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let t=0,e=y.length;t<e;t++){const e=y[t],f=e.charAt(0),h=e.substr(1).trim();let p;switch(!0===l&&(u=!0,l=!1),f){case"M":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x=p[t+0],o.y=p[t+1],i.x=o.x,i.y=o.y,0===t?r.moveTo(o.x,o.y):r.lineTo(o.x,o.y),0===t&&a.copy(o);break;case"H":p=c(h);for(let t=0,e=p.length;t<e;t++)o.x=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"V":p=c(h);for(let t=0,e=p.length;t<e;t++)o.y=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"L":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x=p[t+0],o.y=p[t+1],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"C":p=c(h);for(let t=0,e=p.length;t<e;t+=6)r.bezierCurveTo(p[t+0],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5]),i.x=p[t+2],i.y=p[t+3],o.x=p[t+4],o.y=p[t+5],0===t&&!0===u&&a.copy(o);break;case"S":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.bezierCurveTo(s(o.x,i.x),s(o.y,i.y),p[t+0],p[t+1],p[t+2],p[t+3]),i.x=p[t+0],i.y=p[t+1],o.x=p[t+2],o.y=p[t+3],0===t&&!0===u&&a.copy(o);break;case"Q":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.quadraticCurveTo(p[t+0],p[t+1],p[t+2],p[t+3]),i.x=p[t+0],i.y=p[t+1],o.x=p[t+2],o.y=p[t+3],0===t&&!0===u&&a.copy(o);break;case"T":p=c(h);for(let t=0,e=p.length;t<e;t+=2){const e=s(o.x,i.x),n=s(o.y,i.y);r.quadraticCurveTo(e,n,p[t+0],p[t+1]),i.x=e,i.y=n,o.x=p[t+0],o.y=p[t+1],0===t&&!0===u&&a.copy(o)}break;case"A":p=c(h,[3,4],7);for(let t=0,e=p.length;t<e;t+=7){if(p[t+5]==o.x&&p[t+6]==o.y)continue;const e=o.clone();o.x=p[t+5],o.y=p[t+6],i.x=o.x,i.y=o.y,n(r,p[t],p[t+1],p[t+2],p[t+3],p[t+4],e,o),0===t&&!0===u&&a.copy(o)}break;case"m":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x+=p[t+0],o.y+=p[t+1],i.x=o.x,i.y=o.y,0===t?r.moveTo(o.x,o.y):r.lineTo(o.x,o.y),0===t&&a.copy(o);break;case"h":p=c(h);for(let t=0,e=p.length;t<e;t++)o.x+=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"v":p=c(h);for(let t=0,e=p.length;t<e;t++)o.y+=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"l":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x+=p[t+0],o.y+=p[t+1],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"c":p=c(h);for(let t=0,e=p.length;t<e;t+=6)r.bezierCurveTo(o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3],o.x+p[t+4],o.y+p[t+5]),i.x=o.x+p[t+2],i.y=o.y+p[t+3],o.x+=p[t+4],o.y+=p[t+5],0===t&&!0===u&&a.copy(o);break;case"s":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.bezierCurveTo(s(o.x,i.x),s(o.y,i.y),o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3]),i.x=o.x+p[t+0],i.y=o.y+p[t+1],o.x+=p[t+2],o.y+=p[t+3],0===t&&!0===u&&a.copy(o);break;case"q":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.quadraticCurveTo(o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3]),i.x=o.x+p[t+0],i.y=o.y+p[t+1],o.x+=p[t+2],o.y+=p[t+3],0===t&&!0===u&&a.copy(o);break;case"t":p=c(h);for(let t=0,e=p.length;t<e;t+=2){const e=s(o.x,i.x),n=s(o.y,i.y);r.quadraticCurveTo(e,n,o.x+p[t+0],o.y+p[t+1]),i.x=e,i.y=n,o.x=o.x+p[t+0],o.y=o.y+p[t+1],0===t&&!0===u&&a.copy(o)}break;case"a":p=c(h,[3,4],7);for(let t=0,e=p.length;t<e;t+=7){if(0==p[t+5]&&0==p[t+6])continue;const e=o.clone();o.x+=p[t+5],o.y+=p[t+6],i.x=o.x,i.y=o.y,n(r,p[t],p[t+1],p[t+2],p[t+3],p[t+4],e,o),0===t&&!0===u&&a.copy(o)}break;case"Z":case"z":r.currentPath.autoClose=!0,r.currentPath.curves.length>0&&(o.copy(a),r.currentPath.currentPoint.copy(o),l=!0);break;default:console.warn(e)}u=!1}return r}(r));break;case"rect":o=i(r,o),v=function(e){const r=u(e.getAttribute("x")||0),n=u(e.getAttribute("y")||0),o=u(e.getAttribute("rx")||e.getAttribute("ry")||0),i=u(e.getAttribute("ry")||e.getAttribute("rx")||0),s=u(e.getAttribute("width")),c=u(e.getAttribute("height")),a=.448084975506,l=new t.ShapePath;l.moveTo(r+o,n),l.lineTo(r+s-o,n),(0!==o||0!==i)&&l.bezierCurveTo(r+s-o*a,n,r+s,n+i*a,r+s,n+i);l.lineTo(r+s,n+c-i),(0!==o||0!==i)&&l.bezierCurveTo(r+s,n+c-i*a,r+s-o*a,n+c,r+s-o,n+c);l.lineTo(r+o,n+c),(0!==o||0!==i)&&l.bezierCurveTo(r+o*a,n+c,r,n+c-i*a,r,n+c-i);l.lineTo(r,n+i),(0!==o||0!==i)&&l.bezierCurveTo(r,n+i*a,r+o*a,n,r+o,n);return l}(r);break;case"polygon":o=i(r,o),v=function(e){function r(t,e,r){const n=u(e),s=u(r);0===i?o.moveTo(n,s):o.lineTo(n,s),i++}const n=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(n,r),o.currentPath.autoClose=!0,o}(r);break;case"polyline":o=i(r,o),v=function(e){function r(t,e,r){const n=u(e),s=u(r);0===i?o.moveTo(n,s):o.lineTo(n,s),i++}const n=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(n,r),o.currentPath.autoClose=!1,o}(r);break;case"circle":o=i(r,o),v=function(e){const r=u(e.getAttribute("cx")||0),n=u(e.getAttribute("cy")||0),o=u(e.getAttribute("r")||0),i=new t.Path;i.absarc(r,n,o,0,2*Math.PI);const s=new t.ShapePath;return s.subPaths.push(i),s}(r);break;case"ellipse":o=i(r,o),v=function(e){const r=u(e.getAttribute("cx")||0),n=u(e.getAttribute("cy")||0),o=u(e.getAttribute("rx")||0),i=u(e.getAttribute("ry")||0),s=new t.Path;s.absellipse(r,n,o,i,0,2*Math.PI);const c=new t.ShapePath;return c.subPaths.push(s),c}(r);break;case"line":o=i(r,o),v=function(e){const r=u(e.getAttribute("x1")||0),n=u(e.getAttribute("y1")||0),o=u(e.getAttribute("x2")||0),i=u(e.getAttribute("y2")||0),s=new t.ShapePath;return s.moveTo(r,n),s.lineTo(o,i),s.currentPath.autoClose=!1,s}(r);break;case"defs":l=!1;break;case"use":o=i(r,o);const a=r.href.baseVal.substring(1),y=r.viewportElement.getElementById(a);y?e(y,o):console.warn("SVGLoader: 'use node' references non-existent node id: "+a)}if(v&&(void 0!==o.fill&&"none"!==o.fill&&v.color.setStyle(o.fill),function(t,e){function r(t){k.set(t.x,t.y,1).applyMatrix3(e),t.set(k.x,k.y)}const n=function(t){return 0!==t.elements[1]||0!==t.elements[3]}(e),o=t.subPaths;for(let t=0,i=o.length;t<i;t++){const i=o[t].curves;for(let t=0;t<i.length;t++){const o=i[t];o.isLineCurve?(r(o.v1),r(o.v2)):o.isCubicBezierCurve?(r(o.v0),r(o.v1),r(o.v2),r(o.v3)):o.isQuadraticBezierCurve?(r(o.v0),r(o.v1),r(o.v2)):o.isEllipseCurve&&(n&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),A.set(o.aX,o.aY),r(A),o.aX=A.x,o.aY=A.y,o.xRadius*=y(e),o.yRadius*=f(e))}}}(v,w),h.push(v),v.userData={node:r,style:o}),l){const t=r.childNodes;for(let r=0;r<t.length;r++)e(t[r],o)}a&&(x.pop(),x.length>0?w.copy(x[x.length-1]):w.identity())}(v.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4});return{paths:h,xml:v.documentElement}}static createShapes(e){const r=999999999,n=0,o=1,i=2,s=3,c=4,a=5,l=6,u={loc:n,t:0};function y(t,e,r,o){const s=t.x,c=e.x,a=r.x,l=o.x,y=t.y,h=e.y,p=r.y,x=o.y,d=(l-a)*(y-p)-(x-p)*(s-a),b=(x-p)*(c-s)-(l-a)*(h-y),g=d/b,m=((c-s)*(y-p)-(h-y)*(s-a))/b;if(0===b&&0!==d||g<=0||g>=1||m<0||m>1)return null;if(0===d&&0===b){for(let a=0;a<2;a++){if(f(0===a?r:o,t,e),u.loc==n){const t=0===a?r:o;return{x:t.x,y:t.y,t:u.t}}if(u.loc==i){return{x:+(s+u.t*(c-s)).toPrecision(10),y:+(y+u.t*(h-y)).toPrecision(10),t:u.t}}}return null}for(let i=0;i<2;i++)if(f(0===i?r:o,t,e),u.loc==n){const t=0===i?r:o;return{x:t.x,y:t.y,t:u.t}}return{x:+(s+g*(c-s)).toPrecision(10),y:+(y+g*(h-y)).toPrecision(10),t:g}}function f(t,e,r){const y=r.x-e.x,f=r.y-e.y,h=t.x-e.x,p=t.y-e.y,x=y*p-h*f;if(t.x===e.x&&t.y===e.y)return u.loc=n,void(u.t=0);if(t.x===r.x&&t.y===r.y)return u.loc=o,void(u.t=1);if(x<-Number.EPSILON)return void(u.loc=s);if(x>Number.EPSILON)return void(u.loc=c);if(y*h<0||f*p<0)return void(u.loc=a);if(Math.sqrt(y*y+f*f)<Math.sqrt(h*h+p*p))return void(u.loc=l);let d;d=0!==y?h/y:p/f,u.loc=i,u.t=d}function h(e,r,n){const o=new t.Vector2;r.getCenter(o);const i=[];return n.forEach((r=>{if(r.boundingBox.containsPoint(o)){(function(e,r){const n=[],o=[];for(let i=1;i<e.length;i++){const s=e[i-1],c=e[i];for(let e=1;e<r.length;e++){const i=y(s,c,r[e-1],r[e]);null!==i&&void 0===n.find((t=>t.t<=i.t+Number.EPSILON&&t.t>=i.t-Number.EPSILON))&&(n.push(i),o.push(new t.Vector2(i.x,i.y)))}}return o})(e,r.points).forEach((t=>{i.push({identifier:r.identifier,isCW:r.isCW,point:t})}))}})),i.sort(((t,e)=>t.point.x-e.point.x)),i}let p=0,x=r,d=-999999999,b=e.subPaths.map((e=>{const n=e.getPoints();let o=-999999999,i=r,s=-999999999,c=r;for(let t=0;t<n.length;t++){const e=n[t];e.y>o&&(o=e.y),e.y<i&&(i=e.y),e.x>s&&(s=e.x),e.x<c&&(c=e.x)}return d<=s&&(d=s+1),x>=c&&(x=c-1),{curves:e.curves,points:n,isCW:t.ShapeUtils.isClockWise(n),identifier:p++,boundingBox:new t.Box2(new t.Vector2(c,i),new t.Vector2(s,o))}}));b=b.filter((t=>t.points.length>1));const g=b.map((r=>function(e,r,n,o,i){null!=i&&""!==i||(i="nonzero");const s=new t.Vector2;e.boundingBox.getCenter(s);const c=h([new t.Vector2(n,s.y),new t.Vector2(o,s.y)],e.boundingBox,r);c.sort(((t,e)=>t.point.x-e.point.x));const a=[],l=[];c.forEach((t=>{t.identifier===e.identifier?a.push(t):l.push(t)}));const u=a[0].point.x,y=[];let f=0;for(;f<l.length&&l[f].point.x<u;)y.length>0&&y[y.length-1]===l[f].identifier?y.pop():y.push(l[f].identifier),f++;if(y.push(e.identifier),"evenodd"===i){const t=y.length%2==0,r=y[y.length-2];return{identifier:e.identifier,isHole:t,for:r}}if("nonzero"===i){let t=!0,n=null,o=null;for(let e=0;e<y.length;e++){const i=y[e];t?(o=r[i].isCW,t=!1,n=i):o!==r[i].isCW&&(o=r[i].isCW,t=!0)}return{identifier:e.identifier,isHole:t,for:n}}console.warn('fill-rule: "'+i+'" is currently not implemented.')}(r,b,x,d,e.userData.style.fillRule))),m=[];return b.forEach((e=>{if(!g[e.identifier].isHole){const r=new t.Shape;r.curves=e.curves;g.filter((t=>t.isHole&&t.for===e.identifier)).forEach((e=>{const n=b[e.identifier],o=new t.Path;o.curves=n.curves,r.holes.push(o)})),m.push(r)}})),m}static getStrokeStyle(t,e,r,n,o){return{strokeColor:e=void 0!==e?e:"#000",strokeWidth:t=void 0!==t?t:1,strokeLineJoin:r=void 0!==r?r:"miter",strokeLineCap:n=void 0!==n?n:"butt",strokeMiterLimit:o=void 0!==o?o:4}}static pointsToStroke(r,n,o,i){const s=[],c=[],a=[];if(0===e.pointsToStrokeWithBuffers(r,n,o,i,s,c,a))return null;const l=new t.BufferGeometry;return l.setAttribute("position",new t.Float32BufferAttribute(s,3)),l.setAttribute("normal",new t.Float32BufferAttribute(c,3)),l.setAttribute("uv",new t.Float32BufferAttribute(a,2)),l}static pointsToStrokeWithBuffers(e,r,n,o,i,s,c,a){const l=new t.Vector2,u=new t.Vector2,y=new t.Vector2,f=new t.Vector2,h=new t.Vector2,p=new t.Vector2,x=new t.Vector2,d=new t.Vector2,b=new t.Vector2,g=new t.Vector2,m=new t.Vector2,A=new t.Vector2,k=new t.Vector2,w=new t.Vector2,v=new t.Vector2,M=new t.Vector2,P=new t.Vector2;n=void 0!==n?n:12,o=void 0!==o?o:.001,a=void 0!==a?a:0;const T=(e=function(t){let e=!1;for(let r=1,n=t.length-1;r<n;r++)if(t[r].distanceTo(t[r+1])<o){e=!0;break}if(!e)return t;const r=[];r.push(t[0]);for(let e=1,n=t.length-1;e<n;e++)t[e].distanceTo(t[e+1])>=o&&r.push(t[e]);return r.push(t[t.length-1]),r}(e)).length;if(T<2)return 0;const S=e[0].equals(e[T-1]);let V,C,I=e[0];const E=r.strokeWidth/2,L=1/(T-1);let N,O,z,G,W=0,q=!1,B=0,D=3*a,R=2*a;H(e[0],e[1],l).multiplyScalar(E),d.copy(e[0]).sub(l),b.copy(e[0]).add(l),g.copy(d),m.copy(b);for(let t=1;t<T;t++){V=e[t],C=t===T-1?S?e[1]:void 0:e[t+1];const n=l;if(H(I,V,n),y.copy(n).multiplyScalar(E),A.copy(V).sub(y),k.copy(V).add(y),N=W+L,O=!1,void 0!==C){H(V,C,u),y.copy(u).multiplyScalar(E),w.copy(V).sub(y),v.copy(V).add(y),z=!0,y.subVectors(C,I),n.dot(y)<0&&(z=!1),1===t&&(q=z),y.subVectors(C,V),y.normalize();const e=Math.abs(n.dot(y));if(0!==e){const t=E/e;y.multiplyScalar(-t),f.subVectors(V,I),h.copy(f).setLength(t).add(y),M.copy(h).negate();const n=h.length(),o=f.length();f.divideScalar(o),p.subVectors(C,V);const i=p.length();switch(p.divideScalar(i),f.dot(M)<o&&p.dot(M)<i&&(O=!0),P.copy(h).add(V),M.add(V),G=!1,O?z?(v.copy(M),k.copy(M)):(w.copy(M),A.copy(M)):U(),r.strokeLineJoin){case"bevel":X(z,O,N);break;case"round":J(z,O),z?j(V,A,w,N,0):j(V,v,k,N,1);break;case"miter":case"miter-clip":default:const t=E*r.strokeMiterLimit/n;if(t<1){if("miter-clip"!==r.strokeLineJoin){X(z,O,N);break}J(z,O),z?(p.subVectors(P,A).multiplyScalar(t).add(A),x.subVectors(P,w).multiplyScalar(t).add(w),F(A,N,0),F(p,N,0),F(V,N,.5),F(V,N,.5),F(p,N,0),F(x,N,0),F(V,N,.5),F(x,N,0),F(w,N,0)):(p.subVectors(P,k).multiplyScalar(t).add(k),x.subVectors(P,v).multiplyScalar(t).add(v),F(k,N,1),F(p,N,1),F(V,N,.5),F(V,N,.5),F(p,N,1),F(x,N,1),F(V,N,.5),F(x,N,1),F(v,N,1))}else O?(z?(F(b,W,1),F(d,W,0),F(P,N,0),F(b,W,1),F(P,N,0),F(M,N,1)):(F(b,W,1),F(d,W,0),F(P,N,1),F(d,W,0),F(M,N,0),F(P,N,1)),z?w.copy(P):v.copy(P)):z?(F(A,N,0),F(P,N,0),F(V,N,.5),F(V,N,.5),F(P,N,0),F(w,N,0)):(F(k,N,1),F(P,N,1),F(V,N,.5),F(V,N,.5),F(P,N,1),F(v,N,1)),G=!0}}else U()}else U();S||t!==T-1||Y(e[0],g,m,z,!0,W),W=N,I=V,d.copy(w),b.copy(v)}if(S){if(O&&i){let t=P,e=M;q!==z&&(t=M,e=P),z?(G||q)&&(e.toArray(i,0),e.toArray(i,9),G&&t.toArray(i,3)):!G&&q||(e.toArray(i,3),e.toArray(i,9),G&&t.toArray(i,0))}}else Y(V,A,k,z,!1,N);return B;function H(t,e,r){return r.subVectors(e,t),r.set(-r.y,r.x).normalize()}function F(t,e,r){i&&(i[D]=t.x,i[D+1]=t.y,i[D+2]=0,s&&(s[D]=0,s[D+1]=0,s[D+2]=1),D+=3,c&&(c[R]=e,c[R+1]=r,R+=2)),B+=3}function j(t,e,r,o,i){l.copy(e).sub(t).normalize(),u.copy(r).sub(t).normalize();let s=Math.PI;const c=l.dot(u);Math.abs(c)<1&&(s=Math.abs(Math.acos(c))),s/=n,y.copy(e);for(let e=0,r=n-1;e<r;e++)f.copy(y).rotateAround(t,s),F(y,o,i),F(f,o,i),F(t,o,.5),y.copy(f);F(f,o,i),F(r,o,i),F(t,o,.5)}function U(){F(b,W,1),F(d,W,0),F(A,N,0),F(b,W,1),F(A,N,1),F(k,N,0)}function X(t,e,r){e?t?(F(b,W,1),F(d,W,0),F(A,N,0),F(b,W,1),F(A,N,0),F(M,N,1),F(A,r,0),F(w,r,0),F(M,r,.5)):(F(b,W,1),F(d,W,0),F(k,N,1),F(d,W,0),F(M,N,0),F(k,N,1),F(k,r,1),F(v,r,0),F(M,r,.5)):t?(F(A,r,0),F(w,r,0),F(V,r,.5)):(F(k,r,1),F(v,r,0),F(V,r,.5))}function J(t,e){e&&(t?(F(b,W,1),F(d,W,0),F(A,N,0),F(b,W,1),F(A,N,0),F(M,N,1),F(A,W,0),F(V,N,.5),F(M,N,1),F(V,N,.5),F(w,W,0),F(M,N,1)):(F(b,W,1),F(d,W,0),F(k,N,1),F(d,W,0),F(M,N,0),F(k,N,1),F(k,W,1),F(M,N,0),F(V,N,.5),F(V,N,.5),F(M,N,0),F(v,W,1)))}function Y(t,e,n,o,s,c){switch(r.strokeLineCap){case"round":s?j(t,n,e,c,.5):j(t,e,n,c,.5);break;case"square":if(s)l.subVectors(e,t),u.set(l.y,-l.x),y.addVectors(l,u).add(t),f.subVectors(u,l).add(t),o?(y.toArray(i,3),f.toArray(i,0),f.toArray(i,9)):(y.toArray(i,3),y.toArray(i,9),f.toArray(i,0));else{l.subVectors(n,t),u.set(l.y,-l.x),y.addVectors(l,u).add(t),f.subVectors(u,l).add(t);const e=i.length;o?(y.toArray(i,e-3),f.toArray(i,e-6),f.toArray(i,e-12)):(y.toArray(i,e-6),f.toArray(i,e-3),f.toArray(i,e-12))}}}}}exports.SVGLoader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Loader{constructor(t){super(t),this.defaultDPI=90,this.defaultUnit="px"}load(e,r,n,o){const i=this,s=new t.FileLoader(i.manager);s.setPath(i.path),s.setRequestHeader(i.requestHeader),s.setWithCredentials(i.withCredentials),s.load(e,(function(t){try{r(i.parse(t))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),n,o)}parse(e){const r=this;function n(t,e,r,n,i,s,c,a){if(0==e||0==r)return void t.lineTo(a.x,a.y);n=n*Math.PI/180,e=Math.abs(e),r=Math.abs(r);const l=(c.x-a.x)/2,u=(c.y-a.y)/2,y=Math.cos(n)*l+Math.sin(n)*u,f=-Math.sin(n)*l+Math.cos(n)*u;let h=e*e,p=r*r;const x=y*y,d=f*f,b=x/h+d/p;if(b>1){const t=Math.sqrt(b);h=(e*=t)*e,p=(r*=t)*r}const g=h*d+p*x,m=(h*p-g)/g;let k=Math.sqrt(Math.max(0,m));i===s&&(k=-k);const A=k*e*f/r,w=-k*r*y/e,v=Math.cos(n)*A-Math.sin(n)*w+(c.x+a.x)/2,M=Math.sin(n)*A+Math.cos(n)*w+(c.y+a.y)/2,P=o(1,0,(y-A)/e,(f-w)/r),T=o((y-A)/e,(f-w)/r,(-y-A)/e,(-f-w)/r)%(2*Math.PI);t.currentPath.absellipse(v,M,e,r,P,P+T,0===s,n)}function o(t,e,r,n){const o=t*r+e*n,i=Math.sqrt(t*t+e*e)*Math.sqrt(r*r+n*n);let s=Math.acos(Math.max(-1,Math.min(1,o/i)));return t*n-e*r<0&&(s=-s),s}function i(t,e){e=Object.assign({},e);let r={};if(t.hasAttribute("class")){const e=t.getAttribute("class").split(/\s/).filter(Boolean).map((t=>t.trim()));for(let t=0;t<e.length;t++)r=Object.assign(r,p["."+e[t]])}function n(n,o,i){void 0===i&&(i=function(t){return t.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),t}),t.hasAttribute(n)&&(e[o]=i(t.getAttribute(n))),r[n]&&(e[o]=i(r[n])),t.style&&""!==t.style[n]&&(e[o]=i(t.style[n]))}function o(t){return Math.max(0,Math.min(1,u(t)))}function i(t){return Math.max(0,u(t))}return t.hasAttribute("id")&&(r=Object.assign(r,p["#"+t.getAttribute("id")])),n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("stroke-linejoin","strokeLineJoin"),n("stroke-linecap","strokeLineCap"),n("stroke-miterlimit","strokeMiterLimit",i),n("visibility","visibility"),e}function s(t,e){return t-(e-t)}function c(t,e,r){if("string"!=typeof t)throw new TypeError("Invalid input: "+typeof t);const n={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};let o=0,i=!0,s="",c="";const a=[];function l(t,e,r){const n=new SyntaxError('Unexpected character "'+t+'" at index '+e+".");throw n.partial=r,n}function u(){""!==s&&(""===c?a.push(Number(s)):a.push(Number(s)*Math.pow(10,Number(c)))),s="",c=""}let y;const f=t.length;for(let h=0;h<f;h++)if(y=t[h],Array.isArray(e)&&e.includes(a.length%r)&&n.FLAGS.test(y))o=1,s=y,u();else{if(0===o){if(n.WHITESPACE.test(y))continue;if(n.DIGIT.test(y)||n.SIGN.test(y)){o=1,s=y;continue}if(n.POINT.test(y)){o=2,s=y;continue}n.COMMA.test(y)&&(i&&l(y,h,a),i=!0)}if(1===o){if(n.DIGIT.test(y)){s+=y;continue}if(n.POINT.test(y)){s+=y,o=2;continue}if(n.EXP.test(y)){o=3;continue}n.SIGN.test(y)&&1===s.length&&n.SIGN.test(s[0])&&l(y,h,a)}if(2===o){if(n.DIGIT.test(y)){s+=y;continue}if(n.EXP.test(y)){o=3;continue}n.POINT.test(y)&&"."===s[s.length-1]&&l(y,h,a)}if(3===o){if(n.DIGIT.test(y)){c+=y;continue}if(n.SIGN.test(y)){if(""===c){c+=y;continue}1===c.length&&n.SIGN.test(c)&&l(y,h,a)}}n.WHITESPACE.test(y)?(u(),o=0,i=!1):n.COMMA.test(y)?(u(),o=0,i=!0):n.SIGN.test(y)?(u(),o=1,s=y):n.POINT.test(y)?(u(),o=2,s=y):l(y,h,a)}return u(),a}const a=["mm","cm","in","pt","pc","px"],l={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:12,pc:1,px:-1},px:{px:1}};function u(t){let e,n="px";if("string"==typeof t||t instanceof String)for(let e=0,r=a.length;e<r;e++){const r=a[e];if(t.endsWith(r)){n=r,t=t.substring(0,t.length-r.length);break}}return"px"===n&&"px"!==r.defaultUnit?e=l.in[r.defaultUnit]/r.defaultDPI:(e=l[n][r.defaultUnit],e<0&&(e=l[n].in*r.defaultDPI)),e*parseFloat(t)}function y(t){const e=t.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function f(t){const e=t.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}const h=[],p={},x=[],d=new t.Matrix3,b=new t.Matrix3,g=new t.Matrix3,m=new t.Matrix3,k=new t.Vector2,A=new t.Vector3,w=new t.Matrix3,v=(new DOMParser).parseFromString(e,"image/svg+xml");!function e(r,o){if(1!==r.nodeType)return;const a=function(e){if(!(e.hasAttribute("transform")||"use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))))return null;const r=function(e){const r=new t.Matrix3,n=d;if("use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))){const t=u(e.getAttribute("x")),n=u(e.getAttribute("y"));r.translate(t,n)}if(e.hasAttribute("transform")){const t=e.getAttribute("transform").split(")");for(let e=t.length-1;e>=0;e--){const o=t[e].trim();if(""===o)continue;const i=o.indexOf("("),s=o.length;if(i>0&&i<s){const t=o.substr(0,i),e=c(o.substr(i+1,s-i-1));switch(n.identity(),t){case"translate":if(e.length>=1){const t=e[0];let r=t;e.length>=2&&(r=e[1]),n.translate(t,r)}break;case"rotate":if(e.length>=1){let t=0,r=0,o=0;t=-e[0]*Math.PI/180,e.length>=3&&(r=e[1],o=e[2]),b.identity().translate(-r,-o),g.identity().rotate(t),m.multiplyMatrices(g,b),b.identity().translate(r,o),n.multiplyMatrices(b,m)}break;case"scale":if(e.length>=1){const t=e[0];let r=t;e.length>=2&&(r=e[1]),n.scale(t,r)}break;case"skewX":1===e.length&&n.set(1,Math.tan(e[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":1===e.length&&n.set(1,0,0,Math.tan(e[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":6===e.length&&n.set(e[0],e[2],e[4],e[1],e[3],e[5],0,0,1)}}r.premultiply(n)}}return r}(e);x.length>0&&r.premultiply(x[x.length-1]);return w.copy(r),x.push(r),r}(r);let l=!0,v=null;switch(r.nodeName){case"svg":break;case"style":!function(t){if(!t.sheet||!t.sheet.cssRules||!t.sheet.cssRules.length)return;for(let e=0;e<t.sheet.cssRules.length;e++){const r=t.sheet.cssRules[e];if(1!==r.type)continue;const n=r.selectorText.split(/,/gm).filter(Boolean).map((t=>t.trim()));for(let t=0;t<n.length;t++)p[n[t]]=Object.assign(p[n[t]]||{},r.style)}}(r);break;case"g":o=i(r,o);break;case"path":o=i(r,o),r.hasAttribute("d")&&(v=function(e){const r=new t.ShapePath,o=new t.Vector2,i=new t.Vector2,a=new t.Vector2;let l=!0,u=!1;const y=e.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let t=0,e=y.length;t<e;t++){const e=y[t],f=e.charAt(0),h=e.substr(1).trim();let p;switch(!0===l&&(u=!0,l=!1),f){case"M":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x=p[t+0],o.y=p[t+1],i.x=o.x,i.y=o.y,0===t?r.moveTo(o.x,o.y):r.lineTo(o.x,o.y),0===t&&a.copy(o);break;case"H":p=c(h);for(let t=0,e=p.length;t<e;t++)o.x=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"V":p=c(h);for(let t=0,e=p.length;t<e;t++)o.y=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"L":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x=p[t+0],o.y=p[t+1],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"C":p=c(h);for(let t=0,e=p.length;t<e;t+=6)r.bezierCurveTo(p[t+0],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5]),i.x=p[t+2],i.y=p[t+3],o.x=p[t+4],o.y=p[t+5],0===t&&!0===u&&a.copy(o);break;case"S":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.bezierCurveTo(s(o.x,i.x),s(o.y,i.y),p[t+0],p[t+1],p[t+2],p[t+3]),i.x=p[t+0],i.y=p[t+1],o.x=p[t+2],o.y=p[t+3],0===t&&!0===u&&a.copy(o);break;case"Q":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.quadraticCurveTo(p[t+0],p[t+1],p[t+2],p[t+3]),i.x=p[t+0],i.y=p[t+1],o.x=p[t+2],o.y=p[t+3],0===t&&!0===u&&a.copy(o);break;case"T":p=c(h);for(let t=0,e=p.length;t<e;t+=2){const e=s(o.x,i.x),n=s(o.y,i.y);r.quadraticCurveTo(e,n,p[t+0],p[t+1]),i.x=e,i.y=n,o.x=p[t+0],o.y=p[t+1],0===t&&!0===u&&a.copy(o)}break;case"A":p=c(h,[3,4],7);for(let t=0,e=p.length;t<e;t+=7){if(p[t+5]==o.x&&p[t+6]==o.y)continue;const e=o.clone();o.x=p[t+5],o.y=p[t+6],i.x=o.x,i.y=o.y,n(r,p[t],p[t+1],p[t+2],p[t+3],p[t+4],e,o),0===t&&!0===u&&a.copy(o)}break;case"m":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x+=p[t+0],o.y+=p[t+1],i.x=o.x,i.y=o.y,0===t?r.moveTo(o.x,o.y):r.lineTo(o.x,o.y),0===t&&a.copy(o);break;case"h":p=c(h);for(let t=0,e=p.length;t<e;t++)o.x+=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"v":p=c(h);for(let t=0,e=p.length;t<e;t++)o.y+=p[t],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"l":p=c(h);for(let t=0,e=p.length;t<e;t+=2)o.x+=p[t+0],o.y+=p[t+1],i.x=o.x,i.y=o.y,r.lineTo(o.x,o.y),0===t&&!0===u&&a.copy(o);break;case"c":p=c(h);for(let t=0,e=p.length;t<e;t+=6)r.bezierCurveTo(o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3],o.x+p[t+4],o.y+p[t+5]),i.x=o.x+p[t+2],i.y=o.y+p[t+3],o.x+=p[t+4],o.y+=p[t+5],0===t&&!0===u&&a.copy(o);break;case"s":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.bezierCurveTo(s(o.x,i.x),s(o.y,i.y),o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3]),i.x=o.x+p[t+0],i.y=o.y+p[t+1],o.x+=p[t+2],o.y+=p[t+3],0===t&&!0===u&&a.copy(o);break;case"q":p=c(h);for(let t=0,e=p.length;t<e;t+=4)r.quadraticCurveTo(o.x+p[t+0],o.y+p[t+1],o.x+p[t+2],o.y+p[t+3]),i.x=o.x+p[t+0],i.y=o.y+p[t+1],o.x+=p[t+2],o.y+=p[t+3],0===t&&!0===u&&a.copy(o);break;case"t":p=c(h);for(let t=0,e=p.length;t<e;t+=2){const e=s(o.x,i.x),n=s(o.y,i.y);r.quadraticCurveTo(e,n,o.x+p[t+0],o.y+p[t+1]),i.x=e,i.y=n,o.x=o.x+p[t+0],o.y=o.y+p[t+1],0===t&&!0===u&&a.copy(o)}break;case"a":p=c(h,[3,4],7);for(let t=0,e=p.length;t<e;t+=7){if(0==p[t+5]&&0==p[t+6])continue;const e=o.clone();o.x+=p[t+5],o.y+=p[t+6],i.x=o.x,i.y=o.y,n(r,p[t],p[t+1],p[t+2],p[t+3],p[t+4],e,o),0===t&&!0===u&&a.copy(o)}break;case"Z":case"z":r.currentPath.autoClose=!0,r.currentPath.curves.length>0&&(o.copy(a),r.currentPath.currentPoint.copy(o),l=!0);break;default:console.warn(e)}u=!1}return r}(r));break;case"rect":o=i(r,o),v=function(e){const r=u(e.getAttribute("x")||0),n=u(e.getAttribute("y")||0),o=u(e.getAttribute("rx")||e.getAttribute("ry")||0),i=u(e.getAttribute("ry")||e.getAttribute("rx")||0),s=u(e.getAttribute("width")),c=u(e.getAttribute("height")),a=.448084975506,l=new t.ShapePath;l.moveTo(r+o,n),l.lineTo(r+s-o,n),(0!==o||0!==i)&&l.bezierCurveTo(r+s-o*a,n,r+s,n+i*a,r+s,n+i);l.lineTo(r+s,n+c-i),(0!==o||0!==i)&&l.bezierCurveTo(r+s,n+c-i*a,r+s-o*a,n+c,r+s-o,n+c);l.lineTo(r+o,n+c),(0!==o||0!==i)&&l.bezierCurveTo(r+o*a,n+c,r,n+c-i*a,r,n+c-i);l.lineTo(r,n+i),(0!==o||0!==i)&&l.bezierCurveTo(r,n+i*a,r+o*a,n,r+o,n);return l}(r);break;case"polygon":o=i(r,o),v=function(e){function r(t,e,r){const n=u(e),s=u(r);0===i?o.moveTo(n,s):o.lineTo(n,s),i++}const n=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(n,r),o.currentPath.autoClose=!0,o}(r);break;case"polyline":o=i(r,o),v=function(e){function r(t,e,r){const n=u(e),s=u(r);0===i?o.moveTo(n,s):o.lineTo(n,s),i++}const n=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(n,r),o.currentPath.autoClose=!1,o}(r);break;case"circle":o=i(r,o),v=function(e){const r=u(e.getAttribute("cx")||0),n=u(e.getAttribute("cy")||0),o=u(e.getAttribute("r")||0),i=new t.Path;i.absarc(r,n,o,0,2*Math.PI);const s=new t.ShapePath;return s.subPaths.push(i),s}(r);break;case"ellipse":o=i(r,o),v=function(e){const r=u(e.getAttribute("cx")||0),n=u(e.getAttribute("cy")||0),o=u(e.getAttribute("rx")||0),i=u(e.getAttribute("ry")||0),s=new t.Path;s.absellipse(r,n,o,i,0,2*Math.PI);const c=new t.ShapePath;return c.subPaths.push(s),c}(r);break;case"line":o=i(r,o),v=function(e){const r=u(e.getAttribute("x1")||0),n=u(e.getAttribute("y1")||0),o=u(e.getAttribute("x2")||0),i=u(e.getAttribute("y2")||0),s=new t.ShapePath;return s.moveTo(r,n),s.lineTo(o,i),s.currentPath.autoClose=!1,s}(r);break;case"defs":case"mask":l=!1;break;case"use":o=i(r,o);const a=r.href.baseVal.substring(1),y=r.viewportElement.getElementById(a);y?e(y,o):console.warn("SVGLoader: 'use node' references non-existent node id: "+a)}if(v&&(void 0!==o.fill&&"none"!==o.fill&&v.color.setStyle(o.fill),function(t,e){function r(t){A.set(t.x,t.y,1).applyMatrix3(e),t.set(A.x,A.y)}const n=function(t){return 0!==t.elements[1]||0!==t.elements[3]}(e),o=t.subPaths;for(let t=0,i=o.length;t<i;t++){const i=o[t].curves;for(let t=0;t<i.length;t++){const o=i[t];o.isLineCurve?(r(o.v1),r(o.v2)):o.isCubicBezierCurve?(r(o.v0),r(o.v1),r(o.v2),r(o.v3)):o.isQuadraticBezierCurve?(r(o.v0),r(o.v1),r(o.v2)):o.isEllipseCurve&&(n&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),k.set(o.aX,o.aY),r(k),o.aX=k.x,o.aY=k.y,o.xRadius*=y(e),o.yRadius*=f(e))}}}(v,w),h.push(v),v.userData={node:r,style:o}),l){const t=r.childNodes;for(let r=0;r<t.length;r++)e(t[r],o)}a&&(x.pop(),x.length>0?w.copy(x[x.length-1]):w.identity())}(v.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4});return{paths:h,xml:v.documentElement}}static createShapes(e){const r=999999999,n=0,o=1,i=2,s=3,c=4,a=5,l=6,u={loc:n,t:0};function y(t,e,r,o){const s=t.x,c=e.x,a=r.x,l=o.x,y=t.y,h=e.y,p=r.y,x=o.y,d=(l-a)*(y-p)-(x-p)*(s-a),b=(x-p)*(c-s)-(l-a)*(h-y),g=d/b,m=((c-s)*(y-p)-(h-y)*(s-a))/b;if(0===b&&0!==d||g<=0||g>=1||m<0||m>1)return null;if(0===d&&0===b){for(let a=0;a<2;a++){if(f(0===a?r:o,t,e),u.loc==n){const t=0===a?r:o;return{x:t.x,y:t.y,t:u.t}}if(u.loc==i){return{x:+(s+u.t*(c-s)).toPrecision(10),y:+(y+u.t*(h-y)).toPrecision(10),t:u.t}}}return null}for(let i=0;i<2;i++)if(f(0===i?r:o,t,e),u.loc==n){const t=0===i?r:o;return{x:t.x,y:t.y,t:u.t}}return{x:+(s+g*(c-s)).toPrecision(10),y:+(y+g*(h-y)).toPrecision(10),t:g}}function f(t,e,r){const y=r.x-e.x,f=r.y-e.y,h=t.x-e.x,p=t.y-e.y,x=y*p-h*f;if(t.x===e.x&&t.y===e.y)return u.loc=n,void(u.t=0);if(t.x===r.x&&t.y===r.y)return u.loc=o,void(u.t=1);if(x<-Number.EPSILON)return void(u.loc=s);if(x>Number.EPSILON)return void(u.loc=c);if(y*h<0||f*p<0)return void(u.loc=a);if(Math.sqrt(y*y+f*f)<Math.sqrt(h*h+p*p))return void(u.loc=l);let d;d=0!==y?h/y:p/f,u.loc=i,u.t=d}function h(e,r,n){const o=new t.Vector2;r.getCenter(o);const i=[];return n.forEach((r=>{if(r.boundingBox.containsPoint(o)){(function(e,r){const n=[],o=[];for(let i=1;i<e.length;i++){const s=e[i-1],c=e[i];for(let e=1;e<r.length;e++){const i=y(s,c,r[e-1],r[e]);null!==i&&void 0===n.find((t=>t.t<=i.t+Number.EPSILON&&t.t>=i.t-Number.EPSILON))&&(n.push(i),o.push(new t.Vector2(i.x,i.y)))}}return o})(e,r.points).forEach((t=>{i.push({identifier:r.identifier,isCW:r.isCW,point:t})}))}})),i.sort(((t,e)=>t.point.x-e.point.x)),i}let p=0,x=r,d=-999999999,b=e.subPaths.map((e=>{const n=e.getPoints();let o=-999999999,i=r,s=-999999999,c=r;for(let t=0;t<n.length;t++){const e=n[t];e.y>o&&(o=e.y),e.y<i&&(i=e.y),e.x>s&&(s=e.x),e.x<c&&(c=e.x)}return d<=s&&(d=s+1),x>=c&&(x=c-1),{curves:e.curves,points:n,isCW:t.ShapeUtils.isClockWise(n),identifier:p++,boundingBox:new t.Box2(new t.Vector2(c,i),new t.Vector2(s,o))}}));b=b.filter((t=>t.points.length>1));const g=b.map((r=>function(e,r,n,o,i){null!=i&&""!==i||(i="nonzero");const s=new t.Vector2;e.boundingBox.getCenter(s);const c=h([new t.Vector2(n,s.y),new t.Vector2(o,s.y)],e.boundingBox,r);c.sort(((t,e)=>t.point.x-e.point.x));const a=[],l=[];c.forEach((t=>{t.identifier===e.identifier?a.push(t):l.push(t)}));const u=a[0].point.x,y=[];let f=0;for(;f<l.length&&l[f].point.x<u;)y.length>0&&y[y.length-1]===l[f].identifier?y.pop():y.push(l[f].identifier),f++;if(y.push(e.identifier),"evenodd"===i){const t=y.length%2==0,r=y[y.length-2];return{identifier:e.identifier,isHole:t,for:r}}if("nonzero"===i){let t=!0,n=null,o=null;for(let e=0;e<y.length;e++){const i=y[e];t?(o=r[i].isCW,t=!1,n=i):o!==r[i].isCW&&(o=r[i].isCW,t=!0)}return{identifier:e.identifier,isHole:t,for:n}}console.warn('fill-rule: "'+i+'" is currently not implemented.')}(r,b,x,d,e.userData.style.fillRule))),m=[];return b.forEach((e=>{if(!g[e.identifier].isHole){const r=new t.Shape;r.curves=e.curves;g.filter((t=>t.isHole&&t.for===e.identifier)).forEach((e=>{const n=b[e.identifier],o=new t.Path;o.curves=n.curves,r.holes.push(o)})),m.push(r)}})),m}static getStrokeStyle(t,e,r,n,o){return{strokeColor:e=void 0!==e?e:"#000",strokeWidth:t=void 0!==t?t:1,strokeLineJoin:r=void 0!==r?r:"miter",strokeLineCap:n=void 0!==n?n:"butt",strokeMiterLimit:o=void 0!==o?o:4}}static pointsToStroke(r,n,o,i){const s=[],c=[],a=[];if(0===e.pointsToStrokeWithBuffers(r,n,o,i,s,c,a))return null;const l=new t.BufferGeometry;return l.setAttribute("position",new t.Float32BufferAttribute(s,3)),l.setAttribute("normal",new t.Float32BufferAttribute(c,3)),l.setAttribute("uv",new t.Float32BufferAttribute(a,2)),l}static pointsToStrokeWithBuffers(e,r,n,o,i,s,c,a){const l=new t.Vector2,u=new t.Vector2,y=new t.Vector2,f=new t.Vector2,h=new t.Vector2,p=new t.Vector2,x=new t.Vector2,d=new t.Vector2,b=new t.Vector2,g=new t.Vector2,m=new t.Vector2,k=new t.Vector2,A=new t.Vector2,w=new t.Vector2,v=new t.Vector2,M=new t.Vector2,P=new t.Vector2;n=void 0!==n?n:12,o=void 0!==o?o:.001,a=void 0!==a?a:0;const T=(e=function(t){let e=!1;for(let r=1,n=t.length-1;r<n;r++)if(t[r].distanceTo(t[r+1])<o){e=!0;break}if(!e)return t;const r=[];r.push(t[0]);for(let e=1,n=t.length-1;e<n;e++)t[e].distanceTo(t[e+1])>=o&&r.push(t[e]);return r.push(t[t.length-1]),r}(e)).length;if(T<2)return 0;const S=e[0].equals(e[T-1]);let V,C,I=e[0];const E=r.strokeWidth/2,L=1/(T-1);let N,O,z,G,W=0,q=!1,B=0,D=3*a,R=2*a;H(e[0],e[1],l).multiplyScalar(E),d.copy(e[0]).sub(l),b.copy(e[0]).add(l),g.copy(d),m.copy(b);for(let t=1;t<T;t++){V=e[t],C=t===T-1?S?e[1]:void 0:e[t+1];const n=l;if(H(I,V,n),y.copy(n).multiplyScalar(E),k.copy(V).sub(y),A.copy(V).add(y),N=W+L,O=!1,void 0!==C){H(V,C,u),y.copy(u).multiplyScalar(E),w.copy(V).sub(y),v.copy(V).add(y),z=!0,y.subVectors(C,I),n.dot(y)<0&&(z=!1),1===t&&(q=z),y.subVectors(C,V),y.normalize();const e=Math.abs(n.dot(y));if(0!==e){const t=E/e;y.multiplyScalar(-t),f.subVectors(V,I),h.copy(f).setLength(t).add(y),M.copy(h).negate();const n=h.length(),o=f.length();f.divideScalar(o),p.subVectors(C,V);const i=p.length();switch(p.divideScalar(i),f.dot(M)<o&&p.dot(M)<i&&(O=!0),P.copy(h).add(V),M.add(V),G=!1,O?z?(v.copy(M),A.copy(M)):(w.copy(M),k.copy(M)):U(),r.strokeLineJoin){case"bevel":X(z,O,N);break;case"round":J(z,O),z?j(V,k,w,N,0):j(V,v,A,N,1);break;case"miter":case"miter-clip":default:const t=E*r.strokeMiterLimit/n;if(t<1){if("miter-clip"!==r.strokeLineJoin){X(z,O,N);break}J(z,O),z?(p.subVectors(P,k).multiplyScalar(t).add(k),x.subVectors(P,w).multiplyScalar(t).add(w),F(k,N,0),F(p,N,0),F(V,N,.5),F(V,N,.5),F(p,N,0),F(x,N,0),F(V,N,.5),F(x,N,0),F(w,N,0)):(p.subVectors(P,A).multiplyScalar(t).add(A),x.subVectors(P,v).multiplyScalar(t).add(v),F(A,N,1),F(p,N,1),F(V,N,.5),F(V,N,.5),F(p,N,1),F(x,N,1),F(V,N,.5),F(x,N,1),F(v,N,1))}else O?(z?(F(b,W,1),F(d,W,0),F(P,N,0),F(b,W,1),F(P,N,0),F(M,N,1)):(F(b,W,1),F(d,W,0),F(P,N,1),F(d,W,0),F(M,N,0),F(P,N,1)),z?w.copy(P):v.copy(P)):z?(F(k,N,0),F(P,N,0),F(V,N,.5),F(V,N,.5),F(P,N,0),F(w,N,0)):(F(A,N,1),F(P,N,1),F(V,N,.5),F(V,N,.5),F(P,N,1),F(v,N,1)),G=!0}}else U()}else U();S||t!==T-1||Y(e[0],g,m,z,!0,W),W=N,I=V,d.copy(w),b.copy(v)}if(S){if(O&&i){let t=P,e=M;q!==z&&(t=M,e=P),z?(G||q)&&(e.toArray(i,0),e.toArray(i,9),G&&t.toArray(i,3)):!G&&q||(e.toArray(i,3),e.toArray(i,9),G&&t.toArray(i,0))}}else Y(V,k,A,z,!1,N);return B;function H(t,e,r){return r.subVectors(e,t),r.set(-r.y,r.x).normalize()}function F(t,e,r){i&&(i[D]=t.x,i[D+1]=t.y,i[D+2]=0,s&&(s[D]=0,s[D+1]=0,s[D+2]=1),D+=3,c&&(c[R]=e,c[R+1]=r,R+=2)),B+=3}function j(t,e,r,o,i){l.copy(e).sub(t).normalize(),u.copy(r).sub(t).normalize();let s=Math.PI;const c=l.dot(u);Math.abs(c)<1&&(s=Math.abs(Math.acos(c))),s/=n,y.copy(e);for(let e=0,r=n-1;e<r;e++)f.copy(y).rotateAround(t,s),F(y,o,i),F(f,o,i),F(t,o,.5),y.copy(f);F(f,o,i),F(r,o,i),F(t,o,.5)}function U(){F(b,W,1),F(d,W,0),F(k,N,0),F(b,W,1),F(k,N,1),F(A,N,0)}function X(t,e,r){e?t?(F(b,W,1),F(d,W,0),F(k,N,0),F(b,W,1),F(k,N,0),F(M,N,1),F(k,r,0),F(w,r,0),F(M,r,.5)):(F(b,W,1),F(d,W,0),F(A,N,1),F(d,W,0),F(M,N,0),F(A,N,1),F(A,r,1),F(v,r,0),F(M,r,.5)):t?(F(k,r,0),F(w,r,0),F(V,r,.5)):(F(A,r,1),F(v,r,0),F(V,r,.5))}function J(t,e){e&&(t?(F(b,W,1),F(d,W,0),F(k,N,0),F(b,W,1),F(k,N,0),F(M,N,1),F(k,W,0),F(V,N,.5),F(M,N,1),F(V,N,.5),F(w,W,0),F(M,N,1)):(F(b,W,1),F(d,W,0),F(A,N,1),F(d,W,0),F(M,N,0),F(A,N,1),F(A,W,1),F(M,N,0),F(V,N,.5),F(V,N,.5),F(M,N,0),F(v,W,1)))}function Y(t,e,n,o,s,c){switch(r.strokeLineCap){case"round":s?j(t,n,e,c,.5):j(t,e,n,c,.5);break;case"square":if(s)l.subVectors(e,t),u.set(l.y,-l.x),y.addVectors(l,u).add(t),f.subVectors(u,l).add(t),o?(y.toArray(i,3),f.toArray(i,0),f.toArray(i,9)):(y.toArray(i,3),y.toArray(i,9),f.toArray(i,0));else{l.subVectors(n,t),u.set(l.y,-l.x),y.addVectors(l,u).add(t),f.subVectors(u,l).add(t);const e=i.length;o?(y.toArray(i,e-3),f.toArray(i,e-6),f.toArray(i,e-12)):(y.toArray(i,e-6),f.toArray(i,e-3),f.toArray(i,e-12))}}}}}exports.SVGLoader=e;
@@ -90,6 +90,10 @@ class SVGLoader extends Loader {
90
90
  traverseChildNodes = false;
91
91
  break;
92
92
 
93
+ case 'mask':
94
+ traverseChildNodes = false;
95
+ break;
96
+
93
97
  case 'use':
94
98
  style = parseStyle(node, style);
95
99
  const usedNodeId = node.href.baseVal.substring(1);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e);const s=(e=1)=>{const n=new Float32Array(4096*e*4),r=new t.DataTexture(n,1024,4*e,t.RGBAFormat,t.FloatType);return r.wrapS=t.RepeatWrapping,r.wrapT=t.RepeatWrapping,r.magFilter=t.NearestFilter,r.needsUpdate=!0,r},i=(e,t,n=0)=>{const r=Math.floor(1024);t.arcLengthDivisions=r/2,t.updateArcLengths();const s=t.getSpacedPoints(r),i=t.computeFrenetFrames(r,!0);for(let t=0;t<r;t++){const r=Math.floor(t/1024),o=t%1024;let f=s[t];a(e,o,f.x,f.y,f.z,0+r+4*n),f=i.tangents[t],a(e,o,f.x,f.y,f.z,1+r+4*n),f=i.normals[t],a(e,o,f.x,f.y,f.z,2+r+4*n),f=i.binormals[t],a(e,o,f.x,f.y,f.z,3+r+4*n)}e.needsUpdate=!0},a=(e,t,n,r,s,i)=>{const a=e.image,{data:o}=a,f=4096*i;o[4*t+f+0]=n,o[4*t+f+1]=r,o[4*t+f+2]=s,o[4*t+f+3]=1},o=e=>({spineTexture:{value:e},pathOffset:{type:"f",value:0},pathSegment:{type:"f",value:1},spineOffset:{type:"f",value:161},spineLength:{type:"f",value:400},flow:{type:"i",value:1}});function f(e,t,n=1){e.__ok||(e.__ok=!0,e.onBeforeCompile=e=>{if(e.__modified)return;e.__modified=!0,Object.assign(e.uniforms,t);const r=`\n\t\tuniform sampler2D spineTexture;\n\t\tuniform float pathOffset;\n\t\tuniform float pathSegment;\n\t\tuniform float spineOffset;\n\t\tuniform float spineLength;\n\t\tuniform int flow;\n\n\t\tfloat textureLayers = ${4*n}.;\n\t\tfloat textureStacks = 1.;\n\n\t\t${e.vertexShader}\n\t\t`.replace("#include <beginnormal_vertex>","").replace("#include <defaultnormal_vertex>","").replace("#include <begin_vertex>","").replace(/void\s*main\s*\(\)\s*\{/,"\n void main() {\n #include <beginnormal_vertex>\n\n vec4 worldPos = modelMatrix * vec4(position, 1.);\n\n bool bend = flow > 0;\n float xWeight = bend ? 0. : 1.;\n\n #ifdef USE_INSTANCING\n float pathOffsetFromInstanceMatrix = instanceMatrix[3][2];\n float spineLengthFromInstanceMatrix = instanceMatrix[3][0];\n float spinePortion = bend ? (worldPos.x + spineOffset) / spineLengthFromInstanceMatrix : 0.;\n float mt = (spinePortion * pathSegment + pathOffset + pathOffsetFromInstanceMatrix)*textureStacks;\n #else\n float spinePortion = bend ? (worldPos.x + spineOffset) / spineLength : 0.;\n float mt = (spinePortion * pathSegment + pathOffset)*textureStacks;\n #endif\n\n mt = mod(mt, textureStacks);\n float rowOffset = floor(mt);\n\n #ifdef USE_INSTANCING\n rowOffset += instanceMatrix[3][1] * 4.;\n #endif\n\n vec3 spinePos = texture2D(spineTexture, vec2(mt, (0. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 a = texture2D(spineTexture, vec2(mt, (1. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 b = texture2D(spineTexture, vec2(mt, (2. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 c = texture2D(spineTexture, vec2(mt, (3. + rowOffset + 0.5) / textureLayers)).xyz;\n mat3 basis = mat3(a, b, c);\n\n vec3 transformed = basis\n * vec3(worldPos.x * xWeight, worldPos.y * 1., worldPos.z * 1.)\n + spinePos;\n\n vec3 transformedNormal = normalMatrix * (basis * objectNormal);\n\t\t\t").replace("#include <project_vertex>","vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n\t\t\t\tgl_Position = projectionMatrix * mvPosition;");e.vertexShader=r})}class l{constructor(e,n=1){r.default(this,"curveArray",void 0),r.default(this,"curveLengthArray",void 0),r.default(this,"object3D",void 0),r.default(this,"splineTexure",void 0),r.default(this,"uniforms",void 0);const i=e.clone(),a=s(n),l=o(a);i.traverse((e=>{(e instanceof t.Mesh||e instanceof t.InstancedMesh)&&(e.material=e.material.clone(),f(e.material,l,n))})),this.curveArray=new Array(n),this.curveLengthArray=new Array(n),this.object3D=i,this.splineTexure=a,this.uniforms=l}updateCurve(e,t){if(e>=this.curveArray.length)throw Error("Index out of range for Flow");const n=t.getLength();this.uniforms.spineLength.value=n,this.curveLengthArray[e]=n,this.curveArray[e]=t,i(this.splineTexure,t,e)}moveAlongCurve(e){this.uniforms.pathOffset.value+=e}}const u=new t.Matrix4;exports.Flow=l,exports.InstancedFlow=class extends l{constructor(e,n,s,i){const a=new t.InstancedMesh(s,i,e);a.instanceMatrix.setUsage(t.DynamicDrawUsage),super(a,n),r.default(this,"offsets",void 0),r.default(this,"whichCurve",void 0),this.offsets=new Array(e).fill(0),this.whichCurve=new Array(e).fill(0)}writeChanges(e){u.makeTranslation(this.curveLengthArray[this.whichCurve[e]],this.whichCurve[e],this.offsets[e]),this.object3D.setMatrixAt(e,u),this.object3D.instanceMatrix.needsUpdate=!0}moveIndividualAlongCurve(e,t){this.offsets[e]+=t,this.writeChanges(e)}setCurve(e,t){if(isNaN(t))throw Error("curve index being set is Not a Number (NaN)");this.whichCurve[e]=t,this.writeChanges(e)}},exports.getUniforms=o,exports.initSplineTexture=s,exports.modifyShader=f,exports.updateSplineTexture=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e);const s=(e=1)=>{const n=new Float32Array(4096*e*4),r=new t.DataTexture(n,1024,4*e,t.RGBAFormat,t.FloatType);return r.wrapS=t.RepeatWrapping,r.wrapT=t.RepeatWrapping,r.magFilter=t.NearestFilter,r.needsUpdate=!0,r},i=(e,t,n=0)=>{const r=Math.floor(1024);t.arcLengthDivisions=r/2,t.updateArcLengths();const s=t.getSpacedPoints(r),i=t.computeFrenetFrames(r,!0);for(let t=0;t<r;t++){const r=Math.floor(t/1024),o=t%1024;let f=s[t];a(e,o,f.x,f.y,f.z,0+r+4*n),f=i.tangents[t],a(e,o,f.x,f.y,f.z,1+r+4*n),f=i.normals[t],a(e,o,f.x,f.y,f.z,2+r+4*n),f=i.binormals[t],a(e,o,f.x,f.y,f.z,3+r+4*n)}e.needsUpdate=!0},a=(e,t,n,r,s,i)=>{const a=e.image,{data:o}=a,f=4096*i;o[4*t+f+0]=n,o[4*t+f+1]=r,o[4*t+f+2]=s,o[4*t+f+3]=1},o=e=>({spineTexture:{value:e},pathOffset:{type:"f",value:0},pathSegment:{type:"f",value:1},spineOffset:{type:"f",value:161},spineLength:{type:"f",value:400},flow:{type:"i",value:1}});function f(e,t,n=1){e.__ok||(e.__ok=!0,e.onBeforeCompile=e=>{if(e.__modified)return;e.__modified=!0,Object.assign(e.uniforms,t);const r=`\n\t\tuniform sampler2D spineTexture;\n\t\tuniform float pathOffset;\n\t\tuniform float pathSegment;\n\t\tuniform float spineOffset;\n\t\tuniform float spineLength;\n\t\tuniform int flow;\n\n\t\tfloat textureLayers = ${4*n}.;\n\t\tfloat textureStacks = 1.;\n\n\t\t${e.vertexShader}\n\t\t`.replace("#include <beginnormal_vertex>","").replace("#include <defaultnormal_vertex>","").replace("#include <begin_vertex>","").replace(/void\s*main\s*\(\)\s*\{/,"\n void main() {\n #include <beginnormal_vertex>\n\n vec4 worldPos = modelMatrix * vec4(position, 1.);\n\n bool bend = flow > 0;\n float xWeight = bend ? 0. : 1.;\n\n #ifdef USE_INSTANCING\n float pathOffsetFromInstanceMatrix = instanceMatrix[3][2];\n float spineLengthFromInstanceMatrix = instanceMatrix[3][0];\n float spinePortion = bend ? (worldPos.x + spineOffset) / spineLengthFromInstanceMatrix : 0.;\n float mt = (spinePortion * pathSegment + pathOffset + pathOffsetFromInstanceMatrix)*textureStacks;\n #else\n float spinePortion = bend ? (worldPos.x + spineOffset) / spineLength : 0.;\n float mt = (spinePortion * pathSegment + pathOffset)*textureStacks;\n #endif\n\n mt = mod(mt, textureStacks);\n float rowOffset = floor(mt);\n\n #ifdef USE_INSTANCING\n rowOffset += instanceMatrix[3][1] * 4.;\n #endif\n\n vec3 spinePos = texture2D(spineTexture, vec2(mt, (0. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 a = texture2D(spineTexture, vec2(mt, (1. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 b = texture2D(spineTexture, vec2(mt, (2. + rowOffset + 0.5) / textureLayers)).xyz;\n vec3 c = texture2D(spineTexture, vec2(mt, (3. + rowOffset + 0.5) / textureLayers)).xyz;\n mat3 basis = mat3(a, b, c);\n\n vec3 transformed = basis\n * vec3(worldPos.x * xWeight, worldPos.y * 1., worldPos.z * 1.)\n + spinePos;\n\n vec3 transformedNormal = normalMatrix * (basis * objectNormal);\n\t\t\t").replace("#include <project_vertex>","vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n\t\t\t\tgl_Position = projectionMatrix * mvPosition;");e.vertexShader=r})}class l{constructor(e,n=1){r.default(this,"curveArray",void 0),r.default(this,"curveLengthArray",void 0),r.default(this,"object3D",void 0),r.default(this,"splineTexure",void 0),r.default(this,"uniforms",void 0);const i=e.clone(),a=s(n),l=o(a);i.traverse((e=>{(e instanceof t.Mesh||e instanceof t.InstancedMesh)&&(e.material=e.material.clone(),f(e.material,l,n))})),this.curveArray=new Array(n),this.curveLengthArray=new Array(n),this.object3D=i,this.splineTexure=a,this.uniforms=l}updateCurve(e,t){if(e>=this.curveArray.length)throw Error("Index out of range for Flow");const n=t.getLength();this.uniforms.spineLength.value=n,this.curveLengthArray[e]=n,this.curveArray[e]=t,i(this.splineTexure,t,e)}moveAlongCurve(e){this.uniforms.pathOffset.value+=e}}const u=new t.Matrix4;exports.Flow=l,exports.InstancedFlow=class extends l{constructor(e,n,s,i){const a=new t.InstancedMesh(s,i,e);a.instanceMatrix.setUsage(t.DynamicDrawUsage),a.frustumCulled=!1,super(a,n),r.default(this,"offsets",void 0),r.default(this,"whichCurve",void 0),this.offsets=new Array(e).fill(0),this.whichCurve=new Array(e).fill(0)}writeChanges(e){u.makeTranslation(this.curveLengthArray[this.whichCurve[e]],this.whichCurve[e],this.offsets[e]),this.object3D.setMatrixAt(e,u),this.object3D.instanceMatrix.needsUpdate=!0}moveIndividualAlongCurve(e,t){this.offsets[e]+=t,this.writeChanges(e)}setCurve(e,t){if(isNaN(t))throw Error("curve index being set is Not a Number (NaN)");this.whichCurve[e]=t,this.writeChanges(e)}},exports.getUniforms=o,exports.initSplineTexture=s,exports.modifyShader=f,exports.updateSplineTexture=i;
@@ -234,6 +234,7 @@ class InstancedFlow extends Flow {
234
234
  constructor(count, curveCount, geometry, material) {
235
235
  const mesh = new InstancedMesh(geometry, material, count);
236
236
  mesh.instanceMatrix.setUsage(DynamicDrawUsage);
237
+ mesh.frustumCulled = false;
237
238
  super(mesh, curveCount);
238
239
 
239
240
  _defineProperty(this, "offsets", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.21.8",
3
+ "version": "2.21.9",
4
4
  "private": false,
5
5
  "description": "stand-alone library of threejs examples",
6
6
  "main": "index.cjs.js",