three-stdlib 2.6.3 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/{Nodes-ec4e1143.js → Nodes-894ac9dc.js} +0 -0
  2. package/{Nodes-427f68b0.js → Nodes-af575af7.js} +0 -0
  3. package/controls/ArcballControls.cjs.js +1 -1
  4. package/controls/ArcballControls.d.ts +161 -0
  5. package/controls/ArcballControls.js +554 -285
  6. package/controls/OrbitControls.cjs.js +1 -1
  7. package/controls/OrbitControls.d.ts +1 -0
  8. package/controls/OrbitControls.js +13 -2
  9. package/controls/TransformControls.cjs.js +1 -1
  10. package/controls/TransformControls.d.ts +2 -1
  11. package/controls/TransformControls.js +25 -26
  12. package/geometries/TeapotGeometry.js +2 -2
  13. package/geometries/TextGeometry.cjs.js +1 -0
  14. package/geometries/TextGeometry.d.ts +16 -0
  15. package/geometries/TextGeometry.js +26 -0
  16. package/index.cjs.js +1 -1
  17. package/index.d.ts +2 -0
  18. package/index.js +2 -0
  19. package/loaders/AMFLoader.js +1 -3
  20. package/loaders/ColladaLoader.cjs.js +1 -1
  21. package/loaders/ColladaLoader.js +58 -35
  22. package/loaders/EXRLoader.cjs.js +1 -1
  23. package/loaders/EXRLoader.js +197 -262
  24. package/loaders/FBXLoader.cjs.js +1 -1
  25. package/loaders/FBXLoader.js +41 -90
  26. package/loaders/FontLoader.cjs.js +1 -0
  27. package/loaders/FontLoader.d.ts +32 -0
  28. package/loaders/FontLoader.js +139 -0
  29. package/loaders/GLTFLoader.cjs.js +1 -1
  30. package/loaders/GLTFLoader.js +161 -75
  31. package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
  32. package/loaders/HDRCubeTextureLoader.js +2 -2
  33. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  34. package/loaders/RGBELoader.cjs.js +1 -1
  35. package/loaders/RGBELoader.js +10 -9
  36. package/loaders/RGBMLoader.cjs.js +1 -1
  37. package/loaders/RGBMLoader.js +181 -257
  38. package/loaders/STLLoader.js +7 -7
  39. package/loaders/SVGLoader.cjs.js +1 -1
  40. package/loaders/SVGLoader.js +46 -30
  41. package/loaders/VRMLLoader.cjs.js +1 -1
  42. package/loaders/VRMLLoader.js +2 -1
  43. package/nodes/accessors/CameraNode.js +12 -12
  44. package/nodes/accessors/PositionNode.js +3 -3
  45. package/nodes/accessors/ReflectNode.js +3 -3
  46. package/nodes/core/FunctionNode.js +3 -3
  47. package/nodes/core/InputNode.js +3 -3
  48. package/nodes/core/Node.js +6 -6
  49. package/nodes/core/TempNode.js +6 -6
  50. package/nodes/effects/BlurNode.js +3 -3
  51. package/nodes/math/MathNode.js +3 -3
  52. package/nodes/utils/VelocityNode.js +6 -6
  53. package/package.json +2 -2
  54. package/renderers/nodes/accessors/UVNode.js +1 -3
  55. package/renderers/nodes/core/AttributeNode.js +1 -3
  56. package/renderers/nodes/core/Node.js +4 -12
  57. package/renderers/nodes/core/NodeBuilder.js +6 -18
  58. package/webxr/ARButton.js +6 -6
  59. package/webxr/VRButton.js +6 -6
@@ -135,13 +135,13 @@ class STLLoader extends Loader {
135
135
  && reader.getUint8(index + 5) == 0x3d
136
136
  /*'='*/
137
137
  ) {
138
- hasColors = true;
139
- colors = new Float32Array(faces * 3 * 3);
140
- defaultR = reader.getUint8(index + 6) / 255;
141
- defaultG = reader.getUint8(index + 7) / 255;
142
- defaultB = reader.getUint8(index + 8) / 255;
143
- alpha = reader.getUint8(index + 9) / 255;
144
- }
138
+ hasColors = true;
139
+ colors = new Float32Array(faces * 3 * 3);
140
+ defaultR = reader.getUint8(index + 6) / 255;
141
+ defaultG = reader.getUint8(index + 7) / 255;
142
+ defaultB = reader.getUint8(index + 8) / 255;
143
+ alpha = reader.getUint8(index + 9) / 255;
144
+ }
145
145
  }
146
146
 
147
147
  const dataOffset = 84;
@@ -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,n,r,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{n(i.parse(t))}catch(t){o?o(t):console.error(t),i.manager.itemError(e)}}),r,o)}parse(e){const n=this;function r(t,e,n,r,i,s,c,a){if(0==e||0==n)return void t.lineTo(a.x,a.y);r=r*Math.PI/180,e=Math.abs(e),n=Math.abs(n);const l=(c.x-a.x)/2,u=(c.y-a.y)/2,y=Math.cos(r)*l+Math.sin(r)*u,f=-Math.sin(r)*l+Math.cos(r)*u;let h=e*e,p=n*n;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=(n*=t)*n}const g=h*d+p*x,m=(h*p-g)/g;let k=Math.sqrt(Math.max(0,m));i===s&&(k=-k);const w=k*e*f/n,A=-k*n*y/e,v=Math.cos(r)*w-Math.sin(r)*A+(c.x+a.x)/2,M=Math.sin(r)*w+Math.cos(r)*A+(c.y+a.y)/2,P=o(1,0,(y-w)/e,(f-A)/n),T=o((y-w)/e,(f-A)/n,(-y-w)/e,(-f-A)/n)%(2*Math.PI);t.currentPath.absellipse(v,M,e,n,P,P+T,0===s,r)}function o(t,e,n,r){const o=t*n+e*r,i=Math.sqrt(t*t+e*e)*Math.sqrt(n*n+r*r);let s=Math.acos(Math.max(-1,Math.min(1,o/i)));return t*r-e*n<0&&(s=-s),s}function i(t,e){e=Object.assign({},e);let n={};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++)n=Object.assign(n,p["."+e[t]])}function r(r,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(r)&&(e[o]=i(t.getAttribute(r))),n[r]&&(e[o]=i(n[r])),t.style&&""!==t.style[r]&&(e[o]=i(t.style[r]))}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")&&(n=Object.assign(n,p["#"+t.getAttribute("id")])),r("fill","fill"),r("fill-opacity","fillOpacity",o),r("opacity","opacity",o),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",o),r("stroke-width","strokeWidth",i),r("stroke-linejoin","strokeLineJoin"),r("stroke-linecap","strokeLineCap"),r("stroke-miterlimit","strokeMiterLimit",i),r("visibility","visibility"),e}function s(t,e){return t-(e-t)}function c(t,e,n){if("string"!=typeof t)throw new TypeError("Invalid input: "+typeof t);const r={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,n){const r=new SyntaxError('Unexpected character "'+t+'" at index '+e+".");throw r.partial=n,r}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%n)&&r.FLAGS.test(y))o=1,s=y,u();else{if(0===o){if(r.WHITESPACE.test(y))continue;if(r.DIGIT.test(y)||r.SIGN.test(y)){o=1,s=y;continue}if(r.POINT.test(y)){o=2,s=y;continue}r.COMMA.test(y)&&(i&&l(y,h,a),i=!0)}if(1===o){if(r.DIGIT.test(y)){s+=y;continue}if(r.POINT.test(y)){s+=y,o=2;continue}if(r.EXP.test(y)){o=3;continue}r.SIGN.test(y)&&1===s.length&&r.SIGN.test(s[0])&&l(y,h,a)}if(2===o){if(r.DIGIT.test(y)){s+=y;continue}if(r.EXP.test(y)){o=3;continue}r.POINT.test(y)&&"."===s[s.length-1]&&l(y,h,a)}if(3===o){if(r.DIGIT.test(y)){c+=y;continue}if(r.SIGN.test(y)){if(""===c){c+=y;continue}1===c.length&&r.SIGN.test(c)&&l(y,h,a)}}r.WHITESPACE.test(y)?(u(),o=0,i=!1):r.COMMA.test(y)?(u(),o=0,i=!0):r.SIGN.test(y)?(u(),o=1,s=y):r.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,r="px";if("string"==typeof t||t instanceof String)for(let e=0,n=a.length;e<n;e++){const n=a[e];if(t.endsWith(n)){r=n,t=t.substring(0,t.length-n.length);break}}return"px"===r&&"px"!==n.defaultUnit?e=l.in[n.defaultUnit]/n.defaultDPI:(e=l[r][n.defaultUnit],e<0&&(e=l[r].in*n.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,w=new t.Vector3,A=new t.Matrix3,v=(new DOMParser).parseFromString(e,"image/svg+xml");!function e(n,o){if(1!==n.nodeType)return;const a=function(e){if(!(e.hasAttribute("transform")||"use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))))return null;const n=function(e){const n=new t.Matrix3,r=d;if("use"===e.nodeName&&(e.hasAttribute("x")||e.hasAttribute("y"))){const t=u(e.getAttribute("x")),r=u(e.getAttribute("y"));n.translate(t,r)}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(r.identity(),t){case"translate":if(e.length>=1){const t=e[0];let n=t;e.length>=2&&(n=e[1]),r.translate(t,n)}break;case"rotate":if(e.length>=1){let t=0,n=0,o=0;t=-e[0]*Math.PI/180,e.length>=3&&(n=e[1],o=e[2]),b.identity().translate(-n,-o),g.identity().rotate(t),m.multiplyMatrices(g,b),b.identity().translate(n,o),r.multiplyMatrices(b,m)}break;case"scale":if(e.length>=1){const t=e[0];let n=t;e.length>=2&&(n=e[1]),r.scale(t,n)}break;case"skewX":1===e.length&&r.set(1,Math.tan(e[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":1===e.length&&r.set(1,0,0,Math.tan(e[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":6===e.length&&r.set(e[0],e[2],e[4],e[1],e[3],e[5],0,0,1)}}n.premultiply(r)}}return n}(e);x.length>0&&n.premultiply(x[x.length-1]);return A.copy(n),x.push(n),n}(n);let l=!0,v=null;switch(n.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 n=t.sheet.cssRules[e];if(1!==n.type)continue;const r=n.selectorText.split(/,/gm).filter(Boolean).map((t=>t.trim()));for(let t=0;t<r.length;t++)p[r[t]]=Object.assign(p[r[t]]||{},n.style)}}(n);break;case"g":o=i(n,o);break;case"path":o=i(n,o),n.hasAttribute("d")&&(v=function(e){const n=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?n.moveTo(o.x,o.y):n.lineTo(o.x,o.y),0===t&&!0===u&&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,n.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,n.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,n.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)n.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)n.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)n.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),r=s(o.y,i.y);n.quadraticCurveTo(e,r,p[t+0],p[t+1]),i.x=e,i.y=r,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,r(n,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?n.moveTo(o.x,o.y):n.lineTo(o.x,o.y),0===t&&!0===u&&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,n.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,n.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,n.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)n.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)n.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)n.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),r=s(o.y,i.y);n.quadraticCurveTo(e,r,o.x+p[t+0],o.y+p[t+1]),i.x=e,i.y=r,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,r(n,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":n.currentPath.autoClose=!0,n.currentPath.curves.length>0&&(o.copy(a),n.currentPath.currentPoint.copy(o),l=!0);break;default:console.warn(e)}u=!1}return n}(n));break;case"rect":o=i(n,o),v=function(e){const n=u(e.getAttribute("x")||0),r=u(e.getAttribute("y")||0),o=u(e.getAttribute("rx")||0),i=u(e.getAttribute("ry")||0),s=u(e.getAttribute("width")),c=u(e.getAttribute("height")),a=new t.ShapePath;a.moveTo(n+2*o,r),a.lineTo(n+s-2*o,r),(0!==o||0!==i)&&a.bezierCurveTo(n+s,r,n+s,r,n+s,r+2*i);a.lineTo(n+s,r+c-2*i),(0!==o||0!==i)&&a.bezierCurveTo(n+s,r+c,n+s,r+c,n+s-2*o,r+c);a.lineTo(n+2*o,r+c),(0!==o||0!==i)&&a.bezierCurveTo(n,r+c,n,r+c,n,r+c-2*i);a.lineTo(n,r+2*i),(0!==o||0!==i)&&a.bezierCurveTo(n,r,n,r,n+2*o,r);return a}(n);break;case"polygon":o=i(n,o),v=function(e){function n(t,e,n){const r=u(e),s=u(n);0===i?o.moveTo(r,s):o.lineTo(r,s),i++}const r=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(r,n),o.currentPath.autoClose=!0,o}(n);break;case"polyline":o=i(n,o),v=function(e){function n(t,e,n){const r=u(e),s=u(n);0===i?o.moveTo(r,s):o.lineTo(r,s),i++}const r=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,o=new t.ShapePath;let i=0;return e.getAttribute("points").replace(r,n),o.currentPath.autoClose=!1,o}(n);break;case"circle":o=i(n,o),v=function(e){const n=u(e.getAttribute("cx")||0),r=u(e.getAttribute("cy")||0),o=u(e.getAttribute("r")||0),i=new t.Path;i.absarc(n,r,o,0,2*Math.PI);const s=new t.ShapePath;return s.subPaths.push(i),s}(n);break;case"ellipse":o=i(n,o),v=function(e){const n=u(e.getAttribute("cx")||0),r=u(e.getAttribute("cy")||0),o=u(e.getAttribute("rx")||0),i=u(e.getAttribute("ry")||0),s=new t.Path;s.absellipse(n,r,o,i,0,2*Math.PI);const c=new t.ShapePath;return c.subPaths.push(s),c}(n);break;case"line":o=i(n,o),v=function(e){const n=u(e.getAttribute("x1")||0),r=u(e.getAttribute("y1")||0),o=u(e.getAttribute("x2")||0),i=u(e.getAttribute("y2")||0),s=new t.ShapePath;return s.moveTo(n,r),s.lineTo(o,i),s.currentPath.autoClose=!1,s}(n);break;case"defs":l=!1;break;case"use":o=i(n,o);const a=n.href.baseVal.substring(1),y=n.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 n(t){w.set(t.x,t.y,1).applyMatrix3(e),t.set(w.x,w.y)}const r=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?(n(o.v1),n(o.v2)):o.isCubicBezierCurve?(n(o.v0),n(o.v1),n(o.v2),n(o.v3)):o.isQuadraticBezierCurve?(n(o.v0),n(o.v1),n(o.v2)):o.isEllipseCurve&&(r&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),k.set(o.aX,o.aY),n(k),o.aX=k.x,o.aY=k.y,o.xRadius*=y(e),o.yRadius*=f(e))}}}(v,A),h.push(v),v.userData={node:n,style:o}),l){const t=n.childNodes;for(let n=0;n<t.length;n++)e(t[n],o)}a&&(x.pop(),x.length>0?A.copy(x[x.length-1]):A.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 n=999999999,r=0,o=1,i=2,s=3,c=4,a=5,l=6,u={loc:r,t:0};function y(t,e,n,o){const s=t.x,c=e.x,a=n.x,l=o.x,y=t.y,h=e.y,p=n.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?n:o,t,e),u.loc==r){const t=0===a?n: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?n:o,t,e),u.loc==r){const t=0===i?n: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,n){const y=n.x-e.x,f=n.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=r,void(u.t=0);if(t.x===n.x&&t.y===n.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,n,r){const o=new t.Vector2;n.getCenter(o);const i=[];return r.forEach((n=>{if(n.boundingBox.containsPoint(o)){(function(e,n){const r=[],o=[];for(let i=1;i<e.length;i++){const s=e[i-1],c=e[i];for(let e=1;e<n.length;e++){const i=y(s,c,n[e-1],n[e]);null!==i&&void 0===r.find((t=>t.t<=i.t+Number.EPSILON&&t.t>=i.t-Number.EPSILON))&&(r.push(i),o.push(new t.Vector2(i.x,i.y)))}}return o})(e,n.points).forEach((t=>{i.push({identifier:n.identifier,isCW:n.isCW,point:t})}))}})),i.sort(((t,e)=>t.point.x-e.point.x)),i}let p=0,x=n,d=-999999999,b=e.subPaths.map((e=>{const r=e.getPoints();let o=-999999999,i=n,s=-999999999,c=n;for(let t=0;t<r.length;t++){const e=r[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),{points:r,isCW:t.ShapeUtils.isClockWise(r),identifier:p++,boundingBox:new t.Box2(new t.Vector2(c,i),new t.Vector2(s,o))}}));b=b.filter((t=>t.points.length>0));const g=b.map((n=>function(e,n,r,o,i){null!=i&&""!==i||(i="nonzero");const s=new t.Vector2;e.boundingBox.getCenter(s);const c=h([new t.Vector2(r,s.y),new t.Vector2(o,s.y)],e.boundingBox,n);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,n=y[y.length-2];return{identifier:e.identifier,isHole:t,for:n}}if("nonzero"===i){let t=!0,r=null,o=null;for(let e=0;e<y.length;e++){const i=y[e];t?(o=n[i].isCW,t=!1,r=i):o!==n[i].isCW&&(o=n[i].isCW,t=!0)}return{identifier:e.identifier,isHole:t,for:r}}console.warn('fill-rule: "'+i+'" is currently not implemented.')}(n,b,x,d,e.userData.style.fillRule))),m=[];return b.forEach((e=>{if(!g[e.identifier].isHole){const n=new t.Shape(e.points);g.filter((t=>t.isHole&&t.for===e.identifier)).forEach((e=>{const r=b[e.identifier];n.holes.push(new t.Path(r.points))})),m.push(n)}})),m}static getStrokeStyle(t,e,n,r,o){return{strokeColor:e=void 0!==e?e:"#000",strokeWidth:t=void 0!==t?t:1,strokeLineJoin:n=void 0!==n?n:"miter",strokeLineCap:r=void 0!==r?r:"butt",strokeMiterLimit:o=void 0!==o?o:4}}static pointsToStroke(n,r,o,i){const s=[],c=[],a=[];if(0===e.pointsToStrokeWithBuffers(n,r,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,n,r,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,w=new t.Vector2,A=new t.Vector2,v=new t.Vector2,M=new t.Vector2,P=new t.Vector2;r=void 0!==r?r:12,o=void 0!==o?o:.001,a=void 0!==a?a:0;const T=(e=function(t){let e=!1;for(let n=1,r=t.length-1;n<r;n++)if(t[n].distanceTo(t[n+1])<o){e=!0;break}if(!e)return t;const n=[];n.push(t[0]);for(let e=1,r=t.length-1;e<r;e++)t[e].distanceTo(t[e+1])>=o&&n.push(t[e]);return n.push(t[t.length-1]),n}(e)).length;if(T<2)return 0;const S=e[0].equals(e[T-1]);let V,C,I=e[0];const E=n.strokeWidth/2,L=1/(T-1);let N,O,z,G,W=0,q=!1,B=0,D=3*a,H=2*a;R(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 r=l;if(R(I,V,r),y.copy(r).multiplyScalar(E),k.copy(V).sub(y),w.copy(V).add(y),N=W+L,O=!1,void 0!==C){R(V,C,u),y.copy(u).multiplyScalar(E),A.copy(V).sub(y),v.copy(V).add(y),z=!0,y.subVectors(C,I),r.dot(y)<0&&(z=!1),1===t&&(q=z),y.subVectors(C,V),y.normalize();const e=Math.abs(r.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 r=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),w.copy(M)):(A.copy(M),k.copy(M)):U(),n.strokeLineJoin){case"bevel":X(z,O,N);break;case"round":J(z,O),z?j(V,k,A,N,0):j(V,v,w,N,1);break;case"miter":case"miter-clip":default:const t=E*n.strokeMiterLimit/r;if(t<1){if("miter-clip"!==n.strokeLineJoin){X(z,O,N);break}J(z,O),z?(p.subVectors(P,k).multiplyScalar(t).add(k),x.subVectors(P,A).multiplyScalar(t).add(A),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(A,N,0)):(p.subVectors(P,w).multiplyScalar(t).add(w),x.subVectors(P,v).multiplyScalar(t).add(v),F(w,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?A.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(A,N,0)):(F(w,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(A),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,w,z,!1,N);return B;function R(t,e,n){return n.subVectors(e,t),n.set(-n.y,n.x).normalize()}function F(t,e,n){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[H]=e,c[H+1]=n,H+=2)),B+=3}function j(t,e,n,o,i){l.copy(e).sub(t).normalize(),u.copy(n).sub(t).normalize();let s=Math.PI;const c=l.dot(u);Math.abs(c)<1&&(s=Math.abs(Math.acos(c))),s/=r,y.copy(e);for(let e=0,n=r-1;e<n;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(n,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(w,N,0)}function X(t,e,n){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,n,0),F(A,n,0),F(M,n,.5)):(F(b,W,1),F(d,W,0),F(w,N,1),F(d,W,0),F(M,N,0),F(w,N,1),F(w,n,1),F(v,n,0),F(M,n,.5)):t?(F(k,n,0),F(A,n,0),F(V,n,.5)):(F(w,n,1),F(v,n,0),F(V,n,.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(A,W,0),F(M,N,1)):(F(b,W,1),F(d,W,0),F(w,N,1),F(d,W,0),F(M,N,0),F(w,N,1),F(w,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,r,o,s,c){switch(n.strokeLineCap){case"round":s?j(t,r,e,c,.5):j(t,e,r,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(r,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 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;
@@ -176,7 +176,7 @@ class SVGLoader extends Loader {
176
176
  path.lineTo(point.x, point.y);
177
177
  }
178
178
 
179
- if (j === 0 && doSetFirstPoint === true) firstPoint.copy(point);
179
+ if (j === 0) firstPoint.copy(point);
180
180
  }
181
181
 
182
182
  break;
@@ -311,7 +311,7 @@ class SVGLoader extends Loader {
311
311
  path.lineTo(point.x, point.y);
312
312
  }
313
313
 
314
- if (j === 0 && doSetFirstPoint === true) firstPoint.copy(point);
314
+ if (j === 0) firstPoint.copy(point);
315
315
  }
316
316
 
317
317
  break;
@@ -543,26 +543,42 @@ class SVGLoader extends Loader {
543
543
  function parseRectNode(node) {
544
544
  const x = parseFloatWithUnits(node.getAttribute('x') || 0);
545
545
  const y = parseFloatWithUnits(node.getAttribute('y') || 0);
546
- const rx = parseFloatWithUnits(node.getAttribute('rx') || 0);
547
- const ry = parseFloatWithUnits(node.getAttribute('ry') || 0);
546
+ const rx = parseFloatWithUnits(node.getAttribute('rx') || node.getAttribute('ry') || 0);
547
+ const ry = parseFloatWithUnits(node.getAttribute('ry') || node.getAttribute('rx') || 0);
548
548
  const w = parseFloatWithUnits(node.getAttribute('width'));
549
- const h = parseFloatWithUnits(node.getAttribute('height'));
550
- const path = new ShapePath();
551
- path.moveTo(x + 2 * rx, y);
552
- path.lineTo(x + w - 2 * rx, y);
553
- if (rx !== 0 || ry !== 0) path.bezierCurveTo(x + w, y, x + w, y, x + w, y + 2 * ry);
554
- path.lineTo(x + w, y + h - 2 * ry);
555
- if (rx !== 0 || ry !== 0) path.bezierCurveTo(x + w, y + h, x + w, y + h, x + w - 2 * rx, y + h);
556
- path.lineTo(x + 2 * rx, y + h);
549
+ const h = parseFloatWithUnits(node.getAttribute('height')); // Ellipse arc to Bezier approximation Coefficient (Inversed). See:
550
+ // https://spencermortensen.com/articles/bezier-circle/
551
+
552
+ const bci = 1 - 0.551915024494;
553
+ const path = new ShapePath(); // top left
554
+
555
+ path.moveTo(x + rx, y); // top right
556
+
557
+ path.lineTo(x + w - rx, y);
557
558
 
558
559
  if (rx !== 0 || ry !== 0) {
559
- path.bezierCurveTo(x, y + h, x, y + h, x, y + h - 2 * ry);
560
- }
560
+ path.bezierCurveTo(x + w - rx * bci, y, x + w, y + ry * bci, x + w, y + ry);
561
+ } // bottom right
561
562
 
562
- path.lineTo(x, y + 2 * ry);
563
+
564
+ path.lineTo(x + w, y + h - ry);
563
565
 
564
566
  if (rx !== 0 || ry !== 0) {
565
- path.bezierCurveTo(x, y, x, y, x + 2 * rx, y);
567
+ path.bezierCurveTo(x + w, y + h - ry * bci, x + w - rx * bci, y + h, x + w - rx, y + h);
568
+ } // bottom left
569
+
570
+
571
+ path.lineTo(x + rx, y + h);
572
+
573
+ if (rx !== 0 || ry !== 0) {
574
+ path.bezierCurveTo(x + rx * bci, y + h, x, y + h - ry * bci, x, y + h - ry);
575
+ } // back to top left
576
+
577
+
578
+ path.lineTo(x, y + ry);
579
+
580
+ if (rx !== 0 || ry !== 0) {
581
+ path.bezierCurveTo(x, y + ry * bci, x + rx * bci, y, x + rx, y);
566
582
  }
567
583
 
568
584
  return path;
@@ -666,13 +682,10 @@ class SVGLoader extends Loader {
666
682
  }
667
683
 
668
684
  function addStyle(svgName, jsName, adjustFunction) {
669
- if (adjustFunction === undefined) {
670
- adjustFunction = function copy(v) {
671
- if (v.startsWith('url')) console.warn('SVGLoader: url access in attributes is not implemented.');
672
- return v;
673
- };
674
- }
675
-
685
+ if (adjustFunction === undefined) adjustFunction = function copy(v) {
686
+ if (v.startsWith('url')) console.warn('SVGLoader: url access in attributes is not implemented.');
687
+ return v;
688
+ };
676
689
  if (node.hasAttribute(svgName)) style[jsName] = adjustFunction(node.getAttribute(svgName));
677
690
  if (stylesheetStyles[svgName]) style[jsName] = adjustFunction(stylesheetStyles[svgName]);
678
691
  if (node.style && node.style[svgName] !== '') style[jsName] = adjustFunction(node.style[svgName]);
@@ -688,6 +701,7 @@ class SVGLoader extends Loader {
688
701
 
689
702
  addStyle('fill', 'fill');
690
703
  addStyle('fill-opacity', 'fillOpacity', clamp);
704
+ addStyle('fill-rule', 'fillRule');
691
705
  addStyle('opacity', 'opacity', clamp);
692
706
  addStyle('stroke', 'stroke');
693
707
  addStyle('stroke-opacity', 'strokeOpacity', clamp);
@@ -1476,13 +1490,14 @@ class SVGLoader extends Loader {
1476
1490
  }
1477
1491
 
1478
1492
  return {
1493
+ curves: p.curves,
1479
1494
  points: points,
1480
1495
  isCW: ShapeUtils.isClockWise(points),
1481
1496
  identifier: identifier++,
1482
1497
  boundingBox: new Box2(new Vector2(minX, minY), new Vector2(maxX, maxY))
1483
1498
  };
1484
1499
  });
1485
- simplePaths = simplePaths.filter(sp => sp.points.length > 0); // check if path is solid or a hole
1500
+ simplePaths = simplePaths.filter(sp => sp.points.length > 1); // check if path is solid or a hole
1486
1501
 
1487
1502
  const isAHole = simplePaths.map(p => isHoleTo(p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule));
1488
1503
  const shapesToReturn = [];
@@ -1490,11 +1505,14 @@ class SVGLoader extends Loader {
1490
1505
  const amIAHole = isAHole[p.identifier];
1491
1506
 
1492
1507
  if (!amIAHole.isHole) {
1493
- const shape = new Shape(p.points);
1508
+ const shape = new Shape();
1509
+ shape.curves = p.curves;
1494
1510
  const holes = isAHole.filter(h => h.isHole && h.for === p.identifier);
1495
1511
  holes.forEach(h => {
1496
- const path = simplePaths[h.identifier];
1497
- shape.holes.push(new Path(path.points));
1512
+ const hole = simplePaths[h.identifier];
1513
+ const path = new Path();
1514
+ path.curves = hole.curves;
1515
+ shape.holes.push(path);
1498
1516
  });
1499
1517
  shapesToReturn.push(shape);
1500
1518
  }
@@ -1606,9 +1624,7 @@ class SVGLoader extends Loader {
1606
1624
  if (isClosed) {
1607
1625
  // Skip duplicated initial point
1608
1626
  nextPoint = points[1];
1609
- } else {
1610
- nextPoint = undefined;
1611
- }
1627
+ } else nextPoint = undefined;
1612
1628
  } else {
1613
1629
  nextPoint = points[iPoint + 1];
1614
1630
  } // Normal of previous segment in tempV2_1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("chevrotain");class n extends e.Loader{constructor(e){super(e)}load(t,n,r,o){const a=this,s=""===a.path?e.LoaderUtils.extractUrlBase(t):a.path,l=new e.FileLoader(a.manager);l.setPath(a.path),l.setRequestHeader(a.requestHeader),l.setWithCredentials(a.withCredentials),l.load(t,(function(e){try{n(a.parse(e,s))}catch(e){o?o(e):console.error(e),a.manager.itemError(t)}}),r,o)}parse(n,l){const i={};function c(e){e.DEF&&(i[e.DEF]=e);const t=e.fields;for(let e=0,n=t.length;e<n;e++){const n=t[e];if("node"===n.type){const e=n.values;for(let t=0,n=e.length;t<n;t++)c(e[t])}}}function u(t){return t.USE?function(e){const t=u(i[e]);return t.isObject3D||t.isMaterial?t.clone():t}(t.USE):(void 0!==t.build||(t.build=function(t){const n=t.name;let r;switch(n){case"Group":case"Transform":case"Collision":r=function(t){const n=new e.Group,r=t.fields;for(let t=0,o=r.length;t<o;t++){const o=r[t],a=o.name,s=o.values;switch(a){case"bboxCenter":case"bboxSize":case"center":break;case"children":p(s,n);break;case"collide":break;case"rotation":const t=new e.Vector3(s[0],s[1],s[2]),r=s[3];n.quaternion.setFromAxisAngle(t,r);break;case"scale":n.scale.set(s[0],s[1],s[2]);break;case"scaleOrientation":break;case"translation":n.position.set(s[0],s[1],s[2]);break;case"proxy":break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return n}(t);break;case"Background":r=function(t){const n=new e.Group;let r,o,a,s;const l=t.fields;for(let e=0,t=l.length;e<t;e++){const t=l[e],n=t.name,i=t.values;switch(n){case"groundAngle":r=i;break;case"groundColor":o=i;break;case"backUrl":case"bottomUrl":case"frontUrl":case"leftUrl":case"rightUrl":case"topUrl":break;case"skyAngle":a=i;break;case"skyColor":s=i;break;default:console.warn("THREE.VRMLLoader: Unknown field:",n)}}const i=1e4;if(s){const t=new e.SphereGeometry(i,32,16),r=new e.MeshBasicMaterial({fog:!1,side:e.BackSide,depthWrite:!1,depthTest:!1});s.length>3?(N(t,i,a,I(s),!0),r.vertexColors=!0):r.color.setRGB(s[0],s[1],s[2]);const o=new e.Mesh(t,r);n.add(o)}if(o&&o.length>0){const t=new e.SphereGeometry(i,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),a=new e.MeshBasicMaterial({fog:!1,side:e.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});N(t,i,r,I(o),!1);const s=new e.Mesh(t,a);n.add(s)}return n.renderOrder=-1/0,n}(t);break;case"Shape":r=function(t){const n=t.fields;let r,o,a=new e.MeshBasicMaterial({color:0});for(let e=0,t=n.length;e<t;e++){const t=n[e],o=t.name,s=t.values;switch(o){case"appearance":null!==s[0]&&(a=u(s[0]));break;case"geometry":null!==s[0]&&(r=u(s[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}if(r&&r.attributes.position){const t=r._type;if("points"===t){const t=new e.PointsMaterial({color:16777215});void 0!==r.attributes.color?t.vertexColors=!0:a.isMeshPhongMaterial&&t.color.copy(a.emissive),o=new e.Points(r,t)}else if("line"===t){const t=new e.LineBasicMaterial({color:16777215});void 0!==r.attributes.color?t.vertexColors=!0:a.isMeshPhongMaterial&&t.color.copy(a.emissive),o=new e.LineSegments(r,t)}else void 0!==r._solid&&(a.side=r._solid?e.FrontSide:e.DoubleSide),void 0!==r.attributes.color&&(a.vertexColors=!0),o=new e.Mesh(r,a)}else o=new e.Object3D,o.visible=!1;return o}(t);break;case"Appearance":r=function(t){let n,r=new e.MeshPhongMaterial;const o=t.fields;for(let t=0,a=o.length;t<a;t++){const a=o[t],s=a.name,l=a.values;switch(s){case"material":if(null!==l[0]){const e=u(l[0]);e.diffuseColor&&r.color.copy(e.diffuseColor),e.emissiveColor&&r.emissive.copy(e.emissiveColor),e.shininess&&(r.shininess=e.shininess),e.specularColor&&r.specular.copy(e.specularColor),e.transparency&&(r.opacity=1-e.transparency),e.transparency>0&&(r.transparent=!0)}else r=new e.MeshBasicMaterial({color:0});break;case"texture":const t=l[0];null!==t&&("ImageTexture"!==t.name&&"PixelTexture"!==t.name||(r.map=u(t)));break;case"textureTransform":null!==l[0]&&(n=u(l[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}if(r.map){if(r.map.__type){switch(r.map.__type){case s.INTENSITY_ALPHA:r.opacity=1;break;case s.RGB:r.color.set(16777215);break;case s.RGBA:r.color.set(16777215),r.opacity=1}delete r.map.__type}n&&(r.map.center.copy(n.center),r.map.rotation=n.rotation,r.map.repeat.copy(n.scale),r.map.offset.copy(n.translation))}return r}(t);break;case"Material":r=function(t){const n={},r=t.fields;for(let t=0,o=r.length;t<o;t++){const o=r[t],a=o.name,s=o.values;switch(a){case"ambientIntensity":break;case"diffuseColor":n.diffuseColor=new e.Color(s[0],s[1],s[2]);break;case"emissiveColor":n.emissiveColor=new e.Color(s[0],s[1],s[2]);break;case"shininess":n.shininess=s[0];break;case"specularColor":n.emissiveColor=new e.Color(s[0],s[1],s[2]);break;case"transparency":n.transparency=s[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return n}(t);break;case"ImageTexture":r=function(t){let n,r=e.RepeatWrapping,o=e.RepeatWrapping;const a=t.fields;for(let t=0,s=a.length;t<s;t++){const s=a[t],l=s.name,i=s.values;switch(l){case"url":const t=i[0];t&&(n=B.load(t));break;case"repeatS":!1===i[0]&&(r=e.ClampToEdgeWrapping);break;case"repeatT":!1===i[0]&&(o=e.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}n&&(n.wrapS=r,n.wrapT=o);return n}(t);break;case"PixelTexture":r=function(t){let n,r=e.RepeatWrapping,o=e.RepeatWrapping;const a=t.fields;for(let t=0,s=a.length;t<s;t++){const s=a[t],l=s.name,i=s.values;switch(l){case"image":const t=i[0],a=i[1],s=i[2],c=2===s||4===s,u=d(s),p=new Uint8Array(t*a*(!0===c?4:3)),h={r:0,g:0,b:0,a:0};for(let e=3,t=0,n=i.length;e<n;e++,t++)if(f(i[e],u,h),!0===c){const e=4*t;p[e+0]=h.r,p[e+1]=h.g,p[e+2]=h.b,p[e+3]=h.a}else{const e=3*t;p[e+0]=h.r,p[e+1]=h.g,p[e+2]=h.b}n=new e.DataTexture(p,t,a,!0===c?e.RGBAFormat:e.RGBFormat),n.__type=u;break;case"repeatS":!1===i[0]&&(r=e.ClampToEdgeWrapping);break;case"repeatT":!1===i[0]&&(o=e.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}n&&(n.wrapS=r,n.wrapT=o);return n}(t);break;case"TextureTransform":r=function(t){const n={center:new e.Vector2,rotation:new e.Vector2,scale:new e.Vector2,translation:new e.Vector2},r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"center":n.center.set(a[0],a[1]);break;case"rotation":n.rotation=a[0];break;case"scale":n.scale.set(a[0],a[1]);break;case"translation":n.translation.set(a[0],a[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return n}(t);break;case"IndexedFaceSet":r=function(t){let n,r,o,a,s,l,i,c,f=!0,d=!0,p=0,m=!0,g=!0;const k=t.fields;for(let e=0,t=k.length;e<t;e++){const t=k[e],h=t.name,b=t.values;switch(h){case"color":const e=b[0];null!==e&&(n=u(e));break;case"coord":const t=b[0];null!==t&&(r=u(t));break;case"normal":const x=b[0];null!==x&&(o=u(x));break;case"texCoord":const k=b[0];null!==k&&(a=u(k));break;case"ccw":f=b[0];break;case"colorIndex":s=b;break;case"colorPerVertex":m=b[0];break;case"convex":break;case"coordIndex":l=b;break;case"creaseAngle":p=b[0];break;case"normalIndex":i=b;break;case"normalPerVertex":g=b[0];break;case"solid":d=b[0];break;case"texCoordIndex":c=b;break;default:console.warn("THREE.VRMLLoader: Unknown field:",h)}}if(void 0===l)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new e.BufferGeometry;const w=h(l,f);let L,E,y;if(n)if(!0===m)if(s&&s.length>0){L=S(w,h(s,f),n,3)}else L=U(w,new e.Float32BufferAttribute(n,3));else if(s&&s.length>0){L=A(w,b(x(n,s),l))}else{L=A(w,b(n,l))}if(o)if(!0===g)if(i&&i.length>0){E=S(w,h(i,f),o,3)}else E=U(w,new e.Float32BufferAttribute(o,3));else if(i&&i.length>0){E=A(w,b(x(o,i),l))}else{E=A(w,b(o,l))}else E=v(w,r,p);if(a)if(c&&c.length>0){y=S(w,h(c,f),a,2)}else y=U(w,new e.Float32BufferAttribute(a,2));const T=new e.BufferGeometry,R=U(w,new e.Float32BufferAttribute(r,3));T.setAttribute("position",R),T.setAttribute("normal",E),L&&T.setAttribute("color",L);y&&T.setAttribute("uv",y);return T._solid=d,T._type="mesh",T}(t);break;case"IndexedLineSet":r=function(t){let n,r,o,a,s=!0;const l=t.fields;for(let e=0,t=l.length;e<t;e++){const t=l[e],i=t.name,c=t.values;switch(i){case"color":const e=c[0];null!==e&&(n=u(e));break;case"coord":const t=c[0];null!==t&&(r=u(t));break;case"colorIndex":o=c;break;case"colorPerVertex":s=c[0];break;case"coordIndex":a=c;break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}let i;const c=m(a);if(n)if(!0===s)if(o.length>0){i=S(c,m(o),n,3)}else i=U(c,new e.Float32BufferAttribute(n,3));else if(o.length>0){i=R(c,g(x(n,o),a))}else{i=R(c,g(n,a))}const f=new e.BufferGeometry,d=U(c,new e.Float32BufferAttribute(r,3));f.setAttribute("position",d),i&&f.setAttribute("color",i);return f._type="line",f}(t);break;case"PointSet":r=function(t){let n,r;const o=t.fields;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.name,s=t.values;switch(a){case"color":const e=s[0];null!==e&&(n=u(e));break;case"coord":const t=s[0];null!==t&&(r=u(t));break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}const a=new e.BufferGeometry;a.setAttribute("position",new e.Float32BufferAttribute(r,3)),n&&a.setAttribute("color",new e.Float32BufferAttribute(n,3));return a._type="points",a}(t);break;case"Box":r=function(t){const n=new e.Vector3(2,2,2),r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"size":n.x=a[0],n.y=a[1],n.z=a[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return new e.BoxGeometry(n.x,n.y,n.z)}(t);break;case"Cone":r=function(t){let n=1,r=2,o=!1;const a=t.fields;for(let e=0,t=a.length;e<t;e++){const t=a[e],s=t.name,l=t.values;switch(s){case"bottom":o=!l[0];break;case"bottomRadius":n=l[0];break;case"height":r=l[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}return new e.ConeGeometry(n,r,16,1,o)}(t);break;case"Cylinder":r=function(t){let n=1,r=2;const o=t.fields;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.name,s=t.values;switch(a){case"bottom":break;case"radius":n=s[0];break;case"height":r=s[0];break;case"side":case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return new e.CylinderGeometry(n,n,r,16,1)}(t);break;case"Sphere":r=function(t){let n=1;const r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"radius":n=a[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return new e.SphereGeometry(n,16,16)}(t);break;case"ElevationGrid":r=function(t){let n,r,o,a,s=!0,l=!0,i=!0,c=!0,f=0,d=2,p=2,h=1,b=1;const x=t.fields;for(let e=0,t=x.length;e<t;e++){const t=x[e],m=t.name,g=t.values;switch(m){case"color":const e=g[0];null!==e&&(n=u(e));break;case"normal":const t=g[0];null!==t&&(r=u(t));break;case"texCoord":const x=g[0];null!==x&&(o=u(x));break;case"height":a=g;break;case"ccw":c=g[0];break;case"colorPerVertex":s=g[0];break;case"creaseAngle":f=g[0];break;case"normalPerVertex":l=g[0];break;case"solid":i=g[0];break;case"xDimension":d=g[0];break;case"xSpacing":h=g[0];break;case"zDimension":p=g[0];break;case"zSpacing":b=g[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",m)}}const m=[],g=[],k=[],w=[];for(let e=0;e<p;e++)for(let t=0;t<d;t++){const i=e*d+t,c=h*e,u=a[i],f=b*t;if(m.push(c,u,f),n&&!0===s){const e=n[3*i+0],t=n[3*i+1],r=n[3*i+2];k.push(e,t,r)}if(r&&!0===l){const e=r[3*i+0],t=r[3*i+1],n=r[3*i+2];g.push(e,t,n)}if(o){const e=o[2*i+0],t=o[2*i+1];w.push(e,t)}else w.push(e/(d-1),t/(p-1))}const L=[];for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const n=e+t*d,r=e+(t+1)*d,o=e+1+(t+1)*d,a=e+1+t*d;!0===c?(L.push(n,o,r),L.push(o,n,a)):(L.push(n,r,o),L.push(o,a,n))}const E=U(L,new e.Float32BufferAttribute(m,3)),y=U(L,new e.Float32BufferAttribute(w,2));let T,S;if(n)if(!1===s){for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const r=e+t*(d-1),o=n[3*r+0],a=n[3*r+1],s=n[3*r+2];k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s)}T=new e.Float32BufferAttribute(k,3)}else T=U(L,new e.Float32BufferAttribute(k,3));if(r)if(!1===l){for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const n=e+t*(d-1),o=r[3*n+0],a=r[3*n+1],s=r[3*n+2];g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s)}S=new e.Float32BufferAttribute(g,3)}else S=U(L,new e.Float32BufferAttribute(g,3));else S=v(L,m,f);const A=new e.BufferGeometry;A.setAttribute("position",E),A.setAttribute("normal",S),A.setAttribute("uv",y),T&&A.setAttribute("color",T);return A._solid=i,A._type="mesh",A}(t);break;case"Extrusion":r=function(t){let n,r,o=[1,1,1,-1,-1,-1,-1,1,1,1],a=[0,0,0,0,1,0],s=!0,l=!0,i=0,c=!0,u=!0;const f=t.fields;for(let e=0,t=f.length;e<t;e++){const t=f[e],d=t.name,p=t.values;switch(d){case"beginCap":s=p[0];break;case"ccw":l=p[0];break;case"convex":break;case"creaseAngle":i=p[0];break;case"crossSection":o=p;break;case"endCap":c=p[0];break;case"orientation":r=p;break;case"scale":n=p;break;case"solid":u=p[0];break;case"spine":a=p;break;default:console.warn("THREE.VRMLLoader: Unknown field:",d)}}const d=o[0]===o[o.length-2]&&o[1]===o[o.length-1],p=[],h=new e.Vector3,b=new e.Vector3,x=new e.Vector3,m=new e.Vector3,g=new e.Quaternion;for(let e=0,t=0,s=0,l=a.length;e<l;e+=3,t+=2,s+=4){h.fromArray(a,e),b.x=n?n[t+0]:1,b.y=1,b.z=n?n[t+1]:1,x.x=r?r[s+0]:0,x.y=r?r[s+1]:0,x.z=r?r[s+2]:1;const l=r?r[s+3]:0;for(let e=0,t=o.length;e<t;e+=2)m.x=o[e+0],m.y=0,m.z=o[e+1],m.multiply(b),g.setFromAxisAngle(x,l),m.applyQuaternion(g),m.add(h),p.push(m.x,m.y,m.z)}const k=[],w=a.length/3,L=o.length/2;for(let e=0;e<w-1;e++)for(let t=0;t<L-1;t++){const n=t+e*L;let r=t+1+e*L;const o=t+(e+1)*L;let a=t+1+(e+1)*L;t===L-2&&!0===d&&(r=e*L,a=(e+1)*L),!0===l?(k.push(n,r,o),k.push(o,r,a)):(k.push(n,o,r),k.push(o,a,r))}if(!0===s||!0===c){const t=[];for(let n=0,r=o.length;n<r;n+=2)t.push(new e.Vector2(o[n],o[n+1]));const n=e.ShapeUtils.triangulateShape(t,[]),r=[];for(let e=0,t=n.length;e<t;e++){const t=n[e];r.push(t[0],t[1],t[2])}if(!0===s)for(let e=0,t=r.length;e<t;e+=3)!0===l?k.push(r[e+0],r[e+1],r[e+2]):k.push(r[e+0],r[e+2],r[e+1]);if(!0===c){const e=L*(w-1);for(let t=0,n=r.length;t<n;t+=3)!0===l?k.push(e+r[t+0],e+r[t+2],e+r[t+1]):k.push(e+r[t+0],e+r[t+1],e+r[t+2])}}const E=U(k,new e.Float32BufferAttribute(p,3)),y=v(k,p,i),T=new e.BufferGeometry;return T.setAttribute("position",E),T.setAttribute("normal",y),T._solid=u,T._type="mesh",T}(t);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":r=function(e){return e.fields[0].values}(t);break;case"WorldInfo":r=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,a=r.values;switch(o){case"title":t.title=a[0];break;case"info":t.info=a;break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(t);break;case"Anchor":case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",n)}void 0!==r&&void 0!==t.DEF&&!0===r.hasOwnProperty("name")&&(r.name=t.DEF);return r}(t)),t.build)}function f(e,t,n){let r;switch(t){case s.INTENSITY:r=parseInt(e),n.r=r,n.g=r,n.b=r;break;case s.INTENSITY_ALPHA:r=parseInt("0x"+e.substring(2,4)),n.r=r,n.g=r,n.b=r,n.a=parseInt("0x"+e.substring(4,6));break;case s.RGB:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8));break;case s.RGBA:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=parseInt("0x"+e.substring(8,10))}}function d(e){let t;switch(e){case 1:t=s.INTENSITY;break;case 2:t=s.INTENSITY_ALPHA;break;case 3:t=s.RGB;break;case 4:t=s.RGBA}return t}function p(t,n){for(let r=0,o=t.length;r<o;r++){const o=u(t[r]);o instanceof e.Object3D&&n.add(o)}}function h(e,t){const n=[];let r=0;for(let o=0,a=e.length;o<a;o++){const s=e[r],l=e[o+(t?1:2)],i=e[o+(t?2:1)];n.push(s,l,i),(-1===e[o+3]||o+3>=a)&&(o+=3,r=o+1)}return n}function b(e,t){const n=[];let r=0;for(let o=0,a=t.length;o<a;o++){const s=3*r,l=e[s],i=e[s+1],c=e[s+2];n.push(l,i,c),(-1===t[o+3]||o+3>=a)&&(o+=3,r++)}return n}function x(e,t){const n=[];for(let r=0,o=t.length;r<o;r++){const o=3*t[r],a=e[o],s=e[o+1],l=e[o+2];n.push(a,s,l)}return n}function m(e){const t=[];for(let n=0,r=e.length;n<r;n++){const o=e[n],a=e[n+1];t.push(o,a),(-1===e[n+2]||n+2>=r)&&(n+=2)}return t}function g(e,t){const n=[];let r=0;for(let o=0,a=t.length;o<a;o++){const s=3*r,l=e[s],i=e[s+1],c=e[s+2];n.push(l,i,c),(-1===t[o+2]||o+2>=a)&&(o+=2,r++)}return n}const k=new e.Vector3,w=new e.Vector3,L=new e.Vector3,E=new e.Vector2,y=new e.Vector2,T=new e.Vector2;function S(t,n,r,o){const a=[];for(let e=0,s=t.length;e<s;e+=3){const t=n[e],s=n[e+1],l=n[e+2];2===o?(E.fromArray(r,t*o),y.fromArray(r,s*o),T.fromArray(r,l*o),a.push(E.x,E.y),a.push(y.x,y.y),a.push(T.x,T.y)):(k.fromArray(r,t*o),w.fromArray(r,s*o),L.fromArray(r,l*o),a.push(k.x,k.y,k.z),a.push(w.x,w.y,w.z),a.push(L.x,L.y,L.z))}return new e.Float32BufferAttribute(a,o)}function A(t,n){const r=[];for(let e=0,o=0,a=t.length;e<a;e+=3,o++)k.fromArray(n,3*o),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z);return new e.Float32BufferAttribute(r,3)}function R(t,n){const r=[];for(let e=0,o=0,a=t.length;e<a;e+=2,o++)k.fromArray(n,3*o),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z);return new e.Float32BufferAttribute(r,3)}function U(t,n){const r=n.array,o=n.itemSize,a=new r.constructor(t.length*o);let s=0,l=0;for(let e=0,n=t.length;e<n;e++){s=t[e]*o;for(let e=0;e<o;e++)a[l++]=r[s++]}return new e.Float32BufferAttribute(a,o)}const C=new e.Vector3,M=new e.Vector3;function v(t,n,r){const o=[],s={};for(let e=0,r=t.length;e<r;e+=3){const r=t[e],l=t[e+1],i=t[e+2],c=new a(r,l,i);k.fromArray(n,3*r),w.fromArray(n,3*l),L.fromArray(n,3*i),M.subVectors(L,w),C.subVectors(k,w),M.cross(C),M.normalize(),c.normal.copy(M),void 0===s[r]&&(s[r]=[]),void 0===s[l]&&(s[l]=[]),void 0===s[i]&&(s[i]=[]),s[r].push(c.normal),s[l].push(c.normal),s[i].push(c.normal),o.push(c)}const l=[];for(let e=0,t=o.length;e<t;e++){const t=o[e],a=V(s[t.a],t.normal,r),i=V(s[t.b],t.normal,r),c=V(s[t.c],t.normal,r);k.fromArray(n,3*t.a),w.fromArray(n,3*t.b),L.fromArray(n,3*t.c),l.push(a.x,a.y,a.z),l.push(i.x,i.y,i.z),l.push(c.x,c.y,c.z)}return new e.Float32BufferAttribute(l,3)}function V(t,n,r){const o=new e.Vector3;if(0===r)o.copy(n);else for(let e=0,a=t.length;e<a;e++)t[e].angleTo(n)<r&&o.add(t[e]);return o.normalize()}function I(t){const n=[];for(let r=0,o=t.length;r<o;r+=3)n.push(new e.Color(t[r],t[r+1],t[r+2]));return n}function N(t,n,r,o,a){const s=[],l=!0===a?0:Math.PI;for(let t=0,i=o.length;t<i;t++){let o=0===t?0:r[t-1];o=!0===a?o:l-o;const i=new e.Vector3;i.setFromSphericalCoords(n,o,0),s.push(i)}const i=t.index,c=t.attributes.position,u=new e.BufferAttribute(new Float32Array(3*t.attributes.position.count),3),f=new e.Vector3,d=new e.Color;for(let e=0;e<i.count;e++){const t=i.getX(e);let n,r;f.fromBufferAttribute(c,t);let l=1;for(let e=1;e<s.length;e++){n=e-1,r=e;const t=s[n],o=s[r];if(!0===a){if(f.y<=t.y&&f.y>o.y){l=Math.abs(t.y-f.y)/Math.abs(t.y-o.y);break}}else if(f.y>=t.y&&f.y<o.y){l=Math.abs(t.y-f.y)/Math.abs(t.y-o.y);break}}const p=o[n],h=o[r];d.copy(p).lerp(h,l),u.setXYZ(t,d.r,d.g,d.b)}t.setAttribute("color",u)}const B=new e.TextureLoader(this.manager);if(B.setPath(this.resourcePath||l).setCrossOrigin(this.crossOrigin),-1===n.indexOf("#VRML V2.0"))throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");return function(t){const n=t.nodes,r=new e.Scene;for(let e=0,t=n.length;e<t;e++){c(n[e])}for(let t=0,o=n.length;t<o;t++){const o=n[t],a=u(o);a instanceof e.Object3D&&r.add(a),"WorldInfo"===o.name&&(r.userData.worldInfo=a)}return r}(function(e){const n=function(){const e=t.createToken({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),n=t.createToken({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,longer_alt:e}),r=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],o=t.createToken({name:"Version",pattern:/#VRML.*/,longer_alt:n}),a=t.createToken({name:"NodeName",pattern:new RegExp(r.join("|")),longer_alt:n}),s=t.createToken({name:"DEF",pattern:/DEF/,longer_alt:n}),l=t.createToken({name:"USE",pattern:/USE/,longer_alt:n}),i=t.createToken({name:"ROUTE",pattern:/ROUTE/,longer_alt:n}),c=t.createToken({name:"TO",pattern:/TO/,longer_alt:n}),u=t.createToken({name:"StringLiteral",pattern:/"(:?[^\\"\n\r]+|\\(:?[bfnrtv"\\/]|u[0-9a-fA-F]{4}))*"/}),f=t.createToken({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),d=t.createToken({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),p=t.createToken({name:"TrueLiteral",pattern:/TRUE/}),h=t.createToken({name:"FalseLiteral",pattern:/FALSE/}),b=t.createToken({name:"NullLiteral",pattern:/NULL/}),x=t.createToken({name:"LSquare",pattern:/\[/}),m=t.createToken({name:"RSquare",pattern:/]/}),g=t.createToken({name:"LCurly",pattern:/{/}),k=t.createToken({name:"RCurly",pattern:/}/}),w=t.createToken({name:"Comment",pattern:/#.*/,group:t.Lexer.SKIPPED}),L=[t.createToken({name:"WhiteSpace",pattern:/[ ,\s]/,group:t.Lexer.SKIPPED}),a,s,l,i,c,p,h,b,o,n,e,u,f,d,x,m,g,k,w],E={};for(let e=0,t=L.length;e<t;e++){const t=L[e];E[t.name]=t}return{tokens:L,tokenVocabulary:E}}(),a=new r(n.tokens),s=new o(n.tokenVocabulary),l=function(e){function t(){e.call(this),this.validateVisitor()}function n(e,t){const n={type:null,values:[]};if(t.node){n.type="node";for(let r=0,o=t.node.length;r<o;r++){const o=t.node[r];n.values.push(e.visit(o))}}if(t.use){n.type="use";for(let r=0,o=t.use.length;r<o;r++){const o=t.use[r];n.values.push(e.visit(o))}}if(t.StringLiteral){n.type="string";for(let e=0,r=t.StringLiteral.length;e<r;e++){const r=t.StringLiteral[e];n.values.push(r.image.replace(/'|"/g,""))}}if(t.NumberLiteral){n.type="number";for(let e=0,r=t.NumberLiteral.length;e<r;e++){const r=t.NumberLiteral[e];n.values.push(parseFloat(r.image))}}if(t.HexLiteral){n.type="hex";for(let e=0,r=t.HexLiteral.length;e<r;e++){const r=t.HexLiteral[e];n.values.push(r.image)}}if(t.TrueLiteral){n.type="boolean";for(let e=0,r=t.TrueLiteral.length;e<r;e++){"TRUE"===t.TrueLiteral[e].image&&n.values.push(!0)}}if(t.FalseLiteral){n.type="boolean";for(let e=0,r=t.FalseLiteral.length;e<r;e++){"FALSE"===t.FalseLiteral[e].image&&n.values.push(!1)}}return t.NullLiteral&&(n.type="null",t.NullLiteral.forEach((function(){n.values.push(null)}))),n}return t.prototype=Object.assign(Object.create(e.prototype),{constructor:t,vrml:function(e){const t={version:this.visit(e.version),nodes:[],routes:[]};for(let n=0,r=e.node.length;n<r;n++){const r=e.node[n];t.nodes.push(this.visit(r))}if(e.route)for(let n=0,r=e.route.length;n<r;n++){const r=e.route[n];t.routes.push(this.visit(r))}return t},version:function(e){return e.Version[0].image},node:function(e){const t={name:e.NodeName[0].image,fields:[]};if(e.field)for(let n=0,r=e.field.length;n<r;n++){const r=e.field[n];t.fields.push(this.visit(r))}return e.def&&(t.DEF=this.visit(e.def[0])),t},field:function(e){const t={name:e.Identifier[0].image,type:null,values:null};let n;return e.singleFieldValue&&(n=this.visit(e.singleFieldValue[0])),e.multiFieldValue&&(n=this.visit(e.multiFieldValue[0])),t.type=n.type,t.values=n.values,t},def:function(e){return(e.Identifier||e.NodeName)[0].image},use:function(e){return{USE:(e.Identifier||e.NodeName)[0].image}},singleFieldValue:function(e){return n(this,e)},multiFieldValue:function(e){return n(this,e)},route:function(e){return{FROM:e.RouteIdentifier[0].image,TO:e.RouteIdentifier[1].image}}}),new t}(s.getBaseCstVisitorConstructor()),i=a.lex(e);s.input=i.tokens;const c=s.vrml();if(s.errors.length>0)throw console.error(s.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return l.visit(c)}(n))}}class r{constructor(e){this.lexer=new t.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}class o extends t.CstParser{constructor(e){super(e);const t=this,n=e.Version,r=e.LCurly,o=e.RCurly,a=e.LSquare,s=e.RSquare,l=e.Identifier,i=e.RouteIdentifier,c=e.StringLiteral,u=e.HexLiteral,f=e.NumberLiteral,d=e.TrueLiteral,p=e.FalseLiteral,h=e.NullLiteral,b=e.DEF,x=e.USE,m=e.ROUTE,g=e.TO,k=e.NodeName;t.RULE("vrml",(function(){t.SUBRULE(t.version),t.AT_LEAST_ONE((function(){t.SUBRULE(t.node)})),t.MANY((function(){t.SUBRULE(t.route)}))})),t.RULE("version",(function(){t.CONSUME(n)})),t.RULE("node",(function(){t.OPTION((function(){t.SUBRULE(t.def)})),t.CONSUME(k),t.CONSUME(r),t.MANY((function(){t.SUBRULE(t.field)})),t.CONSUME(o)})),t.RULE("field",(function(){t.CONSUME(l),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])})),t.RULE("def",(function(){t.CONSUME(b),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(k)}}])})),t.RULE("use",(function(){t.CONSUME(x),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(k)}}])})),t.RULE("singleFieldValue",(function(){t.AT_LEAST_ONE((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(h)}}])}))})),t.RULE("multiFieldValue",(function(){t.CONSUME(a),t.MANY((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}}])})),t.CONSUME(s)})),t.RULE("route",(function(){t.CONSUME(m),t.CONSUME(i),t.CONSUME(g),t.CONSUME2(i)})),this.performSelfAnalysis()}}class a{constructor(t,n,r){this.a=t,this.b=n,this.c=r,this.normal=new e.Vector3}}const s={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};exports.VRMLLoader=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("chevrotain");class n extends e.Loader{constructor(e){super(e)}load(t,n,r,o){const a=this,s=""===a.path?e.LoaderUtils.extractUrlBase(t):a.path,l=new e.FileLoader(a.manager);l.setPath(a.path),l.setRequestHeader(a.requestHeader),l.setWithCredentials(a.withCredentials),l.load(t,(function(e){try{n(a.parse(e,s))}catch(e){o?o(e):console.error(e),a.manager.itemError(t)}}),r,o)}parse(n,l){const i={};function c(e){e.DEF&&(i[e.DEF]=e);const t=e.fields;for(let e=0,n=t.length;e<n;e++){const n=t[e];if("node"===n.type){const e=n.values;for(let t=0,n=e.length;t<n;t++)c(e[t])}}}function u(t){return t.USE?function(e){const t=u(i[e]);return t.isObject3D||t.isMaterial?t.clone():t}(t.USE):(void 0!==t.build||(t.build=function(t){const n=t.name;let r;switch(n){case"Group":case"Transform":case"Collision":r=function(t){const n=new e.Group,r=t.fields;for(let t=0,o=r.length;t<o;t++){const o=r[t],a=o.name,s=o.values;switch(a){case"bboxCenter":case"bboxSize":case"center":break;case"children":p(s,n);break;case"collide":break;case"rotation":const t=new e.Vector3(s[0],s[1],s[2]),r=s[3];n.quaternion.setFromAxisAngle(t,r);break;case"scale":n.scale.set(s[0],s[1],s[2]);break;case"scaleOrientation":break;case"translation":n.position.set(s[0],s[1],s[2]);break;case"proxy":break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return n}(t);break;case"Background":r=function(t){const n=new e.Group;let r,o,a,s;const l=t.fields;for(let e=0,t=l.length;e<t;e++){const t=l[e],n=t.name,i=t.values;switch(n){case"groundAngle":r=i;break;case"groundColor":o=i;break;case"backUrl":case"bottomUrl":case"frontUrl":case"leftUrl":case"rightUrl":case"topUrl":break;case"skyAngle":a=i;break;case"skyColor":s=i;break;default:console.warn("THREE.VRMLLoader: Unknown field:",n)}}const i=1e4;if(s){const t=new e.SphereGeometry(i,32,16),r=new e.MeshBasicMaterial({fog:!1,side:e.BackSide,depthWrite:!1,depthTest:!1});s.length>3?(N(t,i,a,I(s),!0),r.vertexColors=!0):r.color.setRGB(s[0],s[1],s[2]);const o=new e.Mesh(t,r);n.add(o)}if(o&&o.length>0){const t=new e.SphereGeometry(i,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),a=new e.MeshBasicMaterial({fog:!1,side:e.BackSide,vertexColors:!0,depthWrite:!1,depthTest:!1});N(t,i,r,I(o),!1);const s=new e.Mesh(t,a);n.add(s)}return n.renderOrder=-1/0,n}(t);break;case"Shape":r=function(t){const n=t.fields;let r,o,a=new e.MeshBasicMaterial({color:0});for(let e=0,t=n.length;e<t;e++){const t=n[e],o=t.name,s=t.values;switch(o){case"appearance":null!==s[0]&&(a=u(s[0]));break;case"geometry":null!==s[0]&&(r=u(s[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}if(r&&r.attributes.position){const t=r._type;if("points"===t){const t=new e.PointsMaterial({color:16777215});void 0!==r.attributes.color?t.vertexColors=!0:a.isMeshPhongMaterial&&t.color.copy(a.emissive),o=new e.Points(r,t)}else if("line"===t){const t=new e.LineBasicMaterial({color:16777215});void 0!==r.attributes.color?t.vertexColors=!0:a.isMeshPhongMaterial&&t.color.copy(a.emissive),o=new e.LineSegments(r,t)}else void 0!==r._solid&&(a.side=r._solid?e.FrontSide:e.DoubleSide),void 0!==r.attributes.color&&(a.vertexColors=!0),o=new e.Mesh(r,a)}else o=new e.Object3D,o.visible=!1;return o}(t);break;case"Appearance":r=function(t){let n,r=new e.MeshPhongMaterial;const o=t.fields;for(let t=0,a=o.length;t<a;t++){const a=o[t],s=a.name,l=a.values;switch(s){case"material":if(null!==l[0]){const e=u(l[0]);e.diffuseColor&&r.color.copy(e.diffuseColor),e.emissiveColor&&r.emissive.copy(e.emissiveColor),e.shininess&&(r.shininess=e.shininess),e.specularColor&&r.specular.copy(e.specularColor),e.transparency&&(r.opacity=1-e.transparency),e.transparency>0&&(r.transparent=!0)}else r=new e.MeshBasicMaterial({color:0});break;case"texture":const t=l[0];null!==t&&("ImageTexture"!==t.name&&"PixelTexture"!==t.name||(r.map=u(t)));break;case"textureTransform":null!==l[0]&&(n=u(l[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}if(r.map){if(r.map.__type){switch(r.map.__type){case s.INTENSITY_ALPHA:r.opacity=1;break;case s.RGB:r.color.set(16777215);break;case s.RGBA:r.color.set(16777215),r.opacity=1}delete r.map.__type}n&&(r.map.center.copy(n.center),r.map.rotation=n.rotation,r.map.repeat.copy(n.scale),r.map.offset.copy(n.translation))}return r}(t);break;case"Material":r=function(t){const n={},r=t.fields;for(let t=0,o=r.length;t<o;t++){const o=r[t],a=o.name,s=o.values;switch(a){case"ambientIntensity":break;case"diffuseColor":n.diffuseColor=new e.Color(s[0],s[1],s[2]);break;case"emissiveColor":n.emissiveColor=new e.Color(s[0],s[1],s[2]);break;case"shininess":n.shininess=s[0];break;case"specularColor":n.emissiveColor=new e.Color(s[0],s[1],s[2]);break;case"transparency":n.transparency=s[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return n}(t);break;case"ImageTexture":r=function(t){let n,r=e.RepeatWrapping,o=e.RepeatWrapping;const a=t.fields;for(let t=0,s=a.length;t<s;t++){const s=a[t],l=s.name,i=s.values;switch(l){case"url":const t=i[0];t&&(n=B.load(t));break;case"repeatS":!1===i[0]&&(r=e.ClampToEdgeWrapping);break;case"repeatT":!1===i[0]&&(o=e.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}n&&(n.wrapS=r,n.wrapT=o);return n}(t);break;case"PixelTexture":r=function(t){let n,r=e.RepeatWrapping,o=e.RepeatWrapping;const a=t.fields;for(let t=0,s=a.length;t<s;t++){const s=a[t],l=s.name,i=s.values;switch(l){case"image":const t=i[0],a=i[1],s=i[2],c=2===s||4===s,u=d(s),p=new Uint8Array(t*a*(!0===c?4:3)),h={r:0,g:0,b:0,a:0};for(let e=3,t=0,n=i.length;e<n;e++,t++)if(f(i[e],u,h),!0===c){const e=4*t;p[e+0]=h.r,p[e+1]=h.g,p[e+2]=h.b,p[e+3]=h.a}else{const e=3*t;p[e+0]=h.r,p[e+1]=h.g,p[e+2]=h.b}n=new e.DataTexture(p,t,a,!0===c?e.RGBAFormat:e.RGBFormat),n.needsUpdate=!0,n.__type=u;break;case"repeatS":!1===i[0]&&(r=e.ClampToEdgeWrapping);break;case"repeatT":!1===i[0]&&(o=e.ClampToEdgeWrapping);break;default:console.warn("THREE.VRMLLoader: Unknown field:",l)}}n&&(n.wrapS=r,n.wrapT=o);return n}(t);break;case"TextureTransform":r=function(t){const n={center:new e.Vector2,rotation:new e.Vector2,scale:new e.Vector2,translation:new e.Vector2},r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"center":n.center.set(a[0],a[1]);break;case"rotation":n.rotation=a[0];break;case"scale":n.scale.set(a[0],a[1]);break;case"translation":n.translation.set(a[0],a[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return n}(t);break;case"IndexedFaceSet":r=function(t){let n,r,o,a,s,l,i,c,f=!0,d=!0,p=0,m=!0,g=!0;const k=t.fields;for(let e=0,t=k.length;e<t;e++){const t=k[e],h=t.name,b=t.values;switch(h){case"color":const e=b[0];null!==e&&(n=u(e));break;case"coord":const t=b[0];null!==t&&(r=u(t));break;case"normal":const x=b[0];null!==x&&(o=u(x));break;case"texCoord":const k=b[0];null!==k&&(a=u(k));break;case"ccw":f=b[0];break;case"colorIndex":s=b;break;case"colorPerVertex":m=b[0];break;case"convex":break;case"coordIndex":l=b;break;case"creaseAngle":p=b[0];break;case"normalIndex":i=b;break;case"normalPerVertex":g=b[0];break;case"solid":d=b[0];break;case"texCoordIndex":c=b;break;default:console.warn("THREE.VRMLLoader: Unknown field:",h)}}if(void 0===l)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new e.BufferGeometry;const w=h(l,f);let L,E,y;if(n)if(!0===m)if(s&&s.length>0){L=S(w,h(s,f),n,3)}else L=U(w,new e.Float32BufferAttribute(n,3));else if(s&&s.length>0){L=A(w,b(x(n,s),l))}else{L=A(w,b(n,l))}if(o)if(!0===g)if(i&&i.length>0){E=S(w,h(i,f),o,3)}else E=U(w,new e.Float32BufferAttribute(o,3));else if(i&&i.length>0){E=A(w,b(x(o,i),l))}else{E=A(w,b(o,l))}else E=v(w,r,p);if(a)if(c&&c.length>0){y=S(w,h(c,f),a,2)}else y=U(w,new e.Float32BufferAttribute(a,2));const T=new e.BufferGeometry,R=U(w,new e.Float32BufferAttribute(r,3));T.setAttribute("position",R),T.setAttribute("normal",E),L&&T.setAttribute("color",L);y&&T.setAttribute("uv",y);return T._solid=d,T._type="mesh",T}(t);break;case"IndexedLineSet":r=function(t){let n,r,o,a,s=!0;const l=t.fields;for(let e=0,t=l.length;e<t;e++){const t=l[e],i=t.name,c=t.values;switch(i){case"color":const e=c[0];null!==e&&(n=u(e));break;case"coord":const t=c[0];null!==t&&(r=u(t));break;case"colorIndex":o=c;break;case"colorPerVertex":s=c[0];break;case"coordIndex":a=c;break;default:console.warn("THREE.VRMLLoader: Unknown field:",i)}}let i;const c=m(a);if(n)if(!0===s)if(o.length>0){i=S(c,m(o),n,3)}else i=U(c,new e.Float32BufferAttribute(n,3));else if(o.length>0){i=R(c,g(x(n,o),a))}else{i=R(c,g(n,a))}const f=new e.BufferGeometry,d=U(c,new e.Float32BufferAttribute(r,3));f.setAttribute("position",d),i&&f.setAttribute("color",i);return f._type="line",f}(t);break;case"PointSet":r=function(t){let n,r;const o=t.fields;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.name,s=t.values;switch(a){case"color":const e=s[0];null!==e&&(n=u(e));break;case"coord":const t=s[0];null!==t&&(r=u(t));break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}const a=new e.BufferGeometry;a.setAttribute("position",new e.Float32BufferAttribute(r,3)),n&&a.setAttribute("color",new e.Float32BufferAttribute(n,3));return a._type="points",a}(t);break;case"Box":r=function(t){const n=new e.Vector3(2,2,2),r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"size":n.x=a[0],n.y=a[1],n.z=a[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return new e.BoxGeometry(n.x,n.y,n.z)}(t);break;case"Cone":r=function(t){let n=1,r=2,o=!1;const a=t.fields;for(let e=0,t=a.length;e<t;e++){const t=a[e],s=t.name,l=t.values;switch(s){case"bottom":o=!l[0];break;case"bottomRadius":n=l[0];break;case"height":r=l[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",s)}}return new e.ConeGeometry(n,r,16,1,o)}(t);break;case"Cylinder":r=function(t){let n=1,r=2;const o=t.fields;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.name,s=t.values;switch(a){case"bottom":break;case"radius":n=s[0];break;case"height":r=s[0];break;case"side":case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",a)}}return new e.CylinderGeometry(n,n,r,16,1)}(t);break;case"Sphere":r=function(t){let n=1;const r=t.fields;for(let e=0,t=r.length;e<t;e++){const t=r[e],o=t.name,a=t.values;switch(o){case"radius":n=a[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return new e.SphereGeometry(n,16,16)}(t);break;case"ElevationGrid":r=function(t){let n,r,o,a,s=!0,l=!0,i=!0,c=!0,f=0,d=2,p=2,h=1,b=1;const x=t.fields;for(let e=0,t=x.length;e<t;e++){const t=x[e],m=t.name,g=t.values;switch(m){case"color":const e=g[0];null!==e&&(n=u(e));break;case"normal":const t=g[0];null!==t&&(r=u(t));break;case"texCoord":const x=g[0];null!==x&&(o=u(x));break;case"height":a=g;break;case"ccw":c=g[0];break;case"colorPerVertex":s=g[0];break;case"creaseAngle":f=g[0];break;case"normalPerVertex":l=g[0];break;case"solid":i=g[0];break;case"xDimension":d=g[0];break;case"xSpacing":h=g[0];break;case"zDimension":p=g[0];break;case"zSpacing":b=g[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",m)}}const m=[],g=[],k=[],w=[];for(let e=0;e<p;e++)for(let t=0;t<d;t++){const i=e*d+t,c=h*e,u=a[i],f=b*t;if(m.push(c,u,f),n&&!0===s){const e=n[3*i+0],t=n[3*i+1],r=n[3*i+2];k.push(e,t,r)}if(r&&!0===l){const e=r[3*i+0],t=r[3*i+1],n=r[3*i+2];g.push(e,t,n)}if(o){const e=o[2*i+0],t=o[2*i+1];w.push(e,t)}else w.push(e/(d-1),t/(p-1))}const L=[];for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const n=e+t*d,r=e+(t+1)*d,o=e+1+(t+1)*d,a=e+1+t*d;!0===c?(L.push(n,o,r),L.push(o,n,a)):(L.push(n,r,o),L.push(o,a,n))}const E=U(L,new e.Float32BufferAttribute(m,3)),y=U(L,new e.Float32BufferAttribute(w,2));let T,S;if(n)if(!1===s){for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const r=e+t*(d-1),o=n[3*r+0],a=n[3*r+1],s=n[3*r+2];k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s),k.push(o,a,s)}T=new e.Float32BufferAttribute(k,3)}else T=U(L,new e.Float32BufferAttribute(k,3));if(r)if(!1===l){for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const n=e+t*(d-1),o=r[3*n+0],a=r[3*n+1],s=r[3*n+2];g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s),g.push(o,a,s)}S=new e.Float32BufferAttribute(g,3)}else S=U(L,new e.Float32BufferAttribute(g,3));else S=v(L,m,f);const A=new e.BufferGeometry;A.setAttribute("position",E),A.setAttribute("normal",S),A.setAttribute("uv",y),T&&A.setAttribute("color",T);return A._solid=i,A._type="mesh",A}(t);break;case"Extrusion":r=function(t){let n,r,o=[1,1,1,-1,-1,-1,-1,1,1,1],a=[0,0,0,0,1,0],s=!0,l=!0,i=0,c=!0,u=!0;const f=t.fields;for(let e=0,t=f.length;e<t;e++){const t=f[e],d=t.name,p=t.values;switch(d){case"beginCap":s=p[0];break;case"ccw":l=p[0];break;case"convex":break;case"creaseAngle":i=p[0];break;case"crossSection":o=p;break;case"endCap":c=p[0];break;case"orientation":r=p;break;case"scale":n=p;break;case"solid":u=p[0];break;case"spine":a=p;break;default:console.warn("THREE.VRMLLoader: Unknown field:",d)}}const d=o[0]===o[o.length-2]&&o[1]===o[o.length-1],p=[],h=new e.Vector3,b=new e.Vector3,x=new e.Vector3,m=new e.Vector3,g=new e.Quaternion;for(let e=0,t=0,s=0,l=a.length;e<l;e+=3,t+=2,s+=4){h.fromArray(a,e),b.x=n?n[t+0]:1,b.y=1,b.z=n?n[t+1]:1,x.x=r?r[s+0]:0,x.y=r?r[s+1]:0,x.z=r?r[s+2]:1;const l=r?r[s+3]:0;for(let e=0,t=o.length;e<t;e+=2)m.x=o[e+0],m.y=0,m.z=o[e+1],m.multiply(b),g.setFromAxisAngle(x,l),m.applyQuaternion(g),m.add(h),p.push(m.x,m.y,m.z)}const k=[],w=a.length/3,L=o.length/2;for(let e=0;e<w-1;e++)for(let t=0;t<L-1;t++){const n=t+e*L;let r=t+1+e*L;const o=t+(e+1)*L;let a=t+1+(e+1)*L;t===L-2&&!0===d&&(r=e*L,a=(e+1)*L),!0===l?(k.push(n,r,o),k.push(o,r,a)):(k.push(n,o,r),k.push(o,a,r))}if(!0===s||!0===c){const t=[];for(let n=0,r=o.length;n<r;n+=2)t.push(new e.Vector2(o[n],o[n+1]));const n=e.ShapeUtils.triangulateShape(t,[]),r=[];for(let e=0,t=n.length;e<t;e++){const t=n[e];r.push(t[0],t[1],t[2])}if(!0===s)for(let e=0,t=r.length;e<t;e+=3)!0===l?k.push(r[e+0],r[e+1],r[e+2]):k.push(r[e+0],r[e+2],r[e+1]);if(!0===c){const e=L*(w-1);for(let t=0,n=r.length;t<n;t+=3)!0===l?k.push(e+r[t+0],e+r[t+2],e+r[t+1]):k.push(e+r[t+0],e+r[t+1],e+r[t+2])}}const E=U(k,new e.Float32BufferAttribute(p,3)),y=v(k,p,i),T=new e.BufferGeometry;return T.setAttribute("position",E),T.setAttribute("normal",y),T._solid=u,T._type="mesh",T}(t);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":r=function(e){return e.fields[0].values}(t);break;case"WorldInfo":r=function(e){const t={},n=e.fields;for(let e=0,r=n.length;e<r;e++){const r=n[e],o=r.name,a=r.values;switch(o){case"title":t.title=a[0];break;case"info":t.info=a;break;default:console.warn("THREE.VRMLLoader: Unknown field:",o)}}return t}(t);break;case"Anchor":case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",n)}void 0!==r&&void 0!==t.DEF&&!0===r.hasOwnProperty("name")&&(r.name=t.DEF);return r}(t)),t.build)}function f(e,t,n){let r;switch(t){case s.INTENSITY:r=parseInt(e),n.r=r,n.g=r,n.b=r;break;case s.INTENSITY_ALPHA:r=parseInt("0x"+e.substring(2,4)),n.r=r,n.g=r,n.b=r,n.a=parseInt("0x"+e.substring(4,6));break;case s.RGB:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8));break;case s.RGBA:n.r=parseInt("0x"+e.substring(2,4)),n.g=parseInt("0x"+e.substring(4,6)),n.b=parseInt("0x"+e.substring(6,8)),n.a=parseInt("0x"+e.substring(8,10))}}function d(e){let t;switch(e){case 1:t=s.INTENSITY;break;case 2:t=s.INTENSITY_ALPHA;break;case 3:t=s.RGB;break;case 4:t=s.RGBA}return t}function p(t,n){for(let r=0,o=t.length;r<o;r++){const o=u(t[r]);o instanceof e.Object3D&&n.add(o)}}function h(e,t){const n=[];let r=0;for(let o=0,a=e.length;o<a;o++){const s=e[r],l=e[o+(t?1:2)],i=e[o+(t?2:1)];n.push(s,l,i),(-1===e[o+3]||o+3>=a)&&(o+=3,r=o+1)}return n}function b(e,t){const n=[];let r=0;for(let o=0,a=t.length;o<a;o++){const s=3*r,l=e[s],i=e[s+1],c=e[s+2];n.push(l,i,c),(-1===t[o+3]||o+3>=a)&&(o+=3,r++)}return n}function x(e,t){const n=[];for(let r=0,o=t.length;r<o;r++){const o=3*t[r],a=e[o],s=e[o+1],l=e[o+2];n.push(a,s,l)}return n}function m(e){const t=[];for(let n=0,r=e.length;n<r;n++){const o=e[n],a=e[n+1];t.push(o,a),(-1===e[n+2]||n+2>=r)&&(n+=2)}return t}function g(e,t){const n=[];let r=0;for(let o=0,a=t.length;o<a;o++){const s=3*r,l=e[s],i=e[s+1],c=e[s+2];n.push(l,i,c),(-1===t[o+2]||o+2>=a)&&(o+=2,r++)}return n}const k=new e.Vector3,w=new e.Vector3,L=new e.Vector3,E=new e.Vector2,y=new e.Vector2,T=new e.Vector2;function S(t,n,r,o){const a=[];for(let e=0,s=t.length;e<s;e+=3){const t=n[e],s=n[e+1],l=n[e+2];2===o?(E.fromArray(r,t*o),y.fromArray(r,s*o),T.fromArray(r,l*o),a.push(E.x,E.y),a.push(y.x,y.y),a.push(T.x,T.y)):(k.fromArray(r,t*o),w.fromArray(r,s*o),L.fromArray(r,l*o),a.push(k.x,k.y,k.z),a.push(w.x,w.y,w.z),a.push(L.x,L.y,L.z))}return new e.Float32BufferAttribute(a,o)}function A(t,n){const r=[];for(let e=0,o=0,a=t.length;e<a;e+=3,o++)k.fromArray(n,3*o),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z);return new e.Float32BufferAttribute(r,3)}function R(t,n){const r=[];for(let e=0,o=0,a=t.length;e<a;e+=2,o++)k.fromArray(n,3*o),r.push(k.x,k.y,k.z),r.push(k.x,k.y,k.z);return new e.Float32BufferAttribute(r,3)}function U(t,n){const r=n.array,o=n.itemSize,a=new r.constructor(t.length*o);let s=0,l=0;for(let e=0,n=t.length;e<n;e++){s=t[e]*o;for(let e=0;e<o;e++)a[l++]=r[s++]}return new e.Float32BufferAttribute(a,o)}const C=new e.Vector3,M=new e.Vector3;function v(t,n,r){const o=[],s={};for(let e=0,r=t.length;e<r;e+=3){const r=t[e],l=t[e+1],i=t[e+2],c=new a(r,l,i);k.fromArray(n,3*r),w.fromArray(n,3*l),L.fromArray(n,3*i),M.subVectors(L,w),C.subVectors(k,w),M.cross(C),M.normalize(),c.normal.copy(M),void 0===s[r]&&(s[r]=[]),void 0===s[l]&&(s[l]=[]),void 0===s[i]&&(s[i]=[]),s[r].push(c.normal),s[l].push(c.normal),s[i].push(c.normal),o.push(c)}const l=[];for(let e=0,t=o.length;e<t;e++){const t=o[e],a=V(s[t.a],t.normal,r),i=V(s[t.b],t.normal,r),c=V(s[t.c],t.normal,r);k.fromArray(n,3*t.a),w.fromArray(n,3*t.b),L.fromArray(n,3*t.c),l.push(a.x,a.y,a.z),l.push(i.x,i.y,i.z),l.push(c.x,c.y,c.z)}return new e.Float32BufferAttribute(l,3)}function V(t,n,r){const o=new e.Vector3;if(0===r)o.copy(n);else for(let e=0,a=t.length;e<a;e++)t[e].angleTo(n)<r&&o.add(t[e]);return o.normalize()}function I(t){const n=[];for(let r=0,o=t.length;r<o;r+=3)n.push(new e.Color(t[r],t[r+1],t[r+2]));return n}function N(t,n,r,o,a){const s=[],l=!0===a?0:Math.PI;for(let t=0,i=o.length;t<i;t++){let o=0===t?0:r[t-1];o=!0===a?o:l-o;const i=new e.Vector3;i.setFromSphericalCoords(n,o,0),s.push(i)}const i=t.index,c=t.attributes.position,u=new e.BufferAttribute(new Float32Array(3*t.attributes.position.count),3),f=new e.Vector3,d=new e.Color;for(let e=0;e<i.count;e++){const t=i.getX(e);let n,r;f.fromBufferAttribute(c,t);let l=1;for(let e=1;e<s.length;e++){n=e-1,r=e;const t=s[n],o=s[r];if(!0===a){if(f.y<=t.y&&f.y>o.y){l=Math.abs(t.y-f.y)/Math.abs(t.y-o.y);break}}else if(f.y>=t.y&&f.y<o.y){l=Math.abs(t.y-f.y)/Math.abs(t.y-o.y);break}}const p=o[n],h=o[r];d.copy(p).lerp(h,l),u.setXYZ(t,d.r,d.g,d.b)}t.setAttribute("color",u)}const B=new e.TextureLoader(this.manager);if(B.setPath(this.resourcePath||l).setCrossOrigin(this.crossOrigin),-1===n.indexOf("#VRML V2.0"))throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");return function(t){const n=t.nodes,r=new e.Scene;for(let e=0,t=n.length;e<t;e++){c(n[e])}for(let t=0,o=n.length;t<o;t++){const o=n[t],a=u(o);a instanceof e.Object3D&&r.add(a),"WorldInfo"===o.name&&(r.userData.worldInfo=a)}return r}(function(e){const n=function(){const e=t.createToken({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),n=t.createToken({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/,longer_alt:e}),r=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],o=t.createToken({name:"Version",pattern:/#VRML.*/,longer_alt:n}),a=t.createToken({name:"NodeName",pattern:new RegExp(r.join("|")),longer_alt:n}),s=t.createToken({name:"DEF",pattern:/DEF/,longer_alt:n}),l=t.createToken({name:"USE",pattern:/USE/,longer_alt:n}),i=t.createToken({name:"ROUTE",pattern:/ROUTE/,longer_alt:n}),c=t.createToken({name:"TO",pattern:/TO/,longer_alt:n}),u=t.createToken({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),f=t.createToken({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),d=t.createToken({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),p=t.createToken({name:"TrueLiteral",pattern:/TRUE/}),h=t.createToken({name:"FalseLiteral",pattern:/FALSE/}),b=t.createToken({name:"NullLiteral",pattern:/NULL/}),x=t.createToken({name:"LSquare",pattern:/\[/}),m=t.createToken({name:"RSquare",pattern:/]/}),g=t.createToken({name:"LCurly",pattern:/{/}),k=t.createToken({name:"RCurly",pattern:/}/}),w=t.createToken({name:"Comment",pattern:/#.*/,group:t.Lexer.SKIPPED}),L=[t.createToken({name:"WhiteSpace",pattern:/[ ,\s]/,group:t.Lexer.SKIPPED}),a,s,l,i,c,p,h,b,o,n,e,u,f,d,x,m,g,k,w],E={};for(let e=0,t=L.length;e<t;e++){const t=L[e];E[t.name]=t}return{tokens:L,tokenVocabulary:E}}(),a=new r(n.tokens),s=new o(n.tokenVocabulary),l=function(e){function t(){e.call(this),this.validateVisitor()}function n(e,t){const n={type:null,values:[]};if(t.node){n.type="node";for(let r=0,o=t.node.length;r<o;r++){const o=t.node[r];n.values.push(e.visit(o))}}if(t.use){n.type="use";for(let r=0,o=t.use.length;r<o;r++){const o=t.use[r];n.values.push(e.visit(o))}}if(t.StringLiteral){n.type="string";for(let e=0,r=t.StringLiteral.length;e<r;e++){const r=t.StringLiteral[e];n.values.push(r.image.replace(/'|"/g,""))}}if(t.NumberLiteral){n.type="number";for(let e=0,r=t.NumberLiteral.length;e<r;e++){const r=t.NumberLiteral[e];n.values.push(parseFloat(r.image))}}if(t.HexLiteral){n.type="hex";for(let e=0,r=t.HexLiteral.length;e<r;e++){const r=t.HexLiteral[e];n.values.push(r.image)}}if(t.TrueLiteral){n.type="boolean";for(let e=0,r=t.TrueLiteral.length;e<r;e++){"TRUE"===t.TrueLiteral[e].image&&n.values.push(!0)}}if(t.FalseLiteral){n.type="boolean";for(let e=0,r=t.FalseLiteral.length;e<r;e++){"FALSE"===t.FalseLiteral[e].image&&n.values.push(!1)}}return t.NullLiteral&&(n.type="null",t.NullLiteral.forEach((function(){n.values.push(null)}))),n}return t.prototype=Object.assign(Object.create(e.prototype),{constructor:t,vrml:function(e){const t={version:this.visit(e.version),nodes:[],routes:[]};for(let n=0,r=e.node.length;n<r;n++){const r=e.node[n];t.nodes.push(this.visit(r))}if(e.route)for(let n=0,r=e.route.length;n<r;n++){const r=e.route[n];t.routes.push(this.visit(r))}return t},version:function(e){return e.Version[0].image},node:function(e){const t={name:e.NodeName[0].image,fields:[]};if(e.field)for(let n=0,r=e.field.length;n<r;n++){const r=e.field[n];t.fields.push(this.visit(r))}return e.def&&(t.DEF=this.visit(e.def[0])),t},field:function(e){const t={name:e.Identifier[0].image,type:null,values:null};let n;return e.singleFieldValue&&(n=this.visit(e.singleFieldValue[0])),e.multiFieldValue&&(n=this.visit(e.multiFieldValue[0])),t.type=n.type,t.values=n.values,t},def:function(e){return(e.Identifier||e.NodeName)[0].image},use:function(e){return{USE:(e.Identifier||e.NodeName)[0].image}},singleFieldValue:function(e){return n(this,e)},multiFieldValue:function(e){return n(this,e)},route:function(e){return{FROM:e.RouteIdentifier[0].image,TO:e.RouteIdentifier[1].image}}}),new t}(s.getBaseCstVisitorConstructor()),i=a.lex(e);s.input=i.tokens;const c=s.vrml();if(s.errors.length>0)throw console.error(s.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return l.visit(c)}(n))}}class r{constructor(e){this.lexer=new t.Lexer(e)}lex(e){const t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}}class o extends t.CstParser{constructor(e){super(e);const t=this,n=e.Version,r=e.LCurly,o=e.RCurly,a=e.LSquare,s=e.RSquare,l=e.Identifier,i=e.RouteIdentifier,c=e.StringLiteral,u=e.HexLiteral,f=e.NumberLiteral,d=e.TrueLiteral,p=e.FalseLiteral,h=e.NullLiteral,b=e.DEF,x=e.USE,m=e.ROUTE,g=e.TO,k=e.NodeName;t.RULE("vrml",(function(){t.SUBRULE(t.version),t.AT_LEAST_ONE((function(){t.SUBRULE(t.node)})),t.MANY((function(){t.SUBRULE(t.route)}))})),t.RULE("version",(function(){t.CONSUME(n)})),t.RULE("node",(function(){t.OPTION((function(){t.SUBRULE(t.def)})),t.CONSUME(k),t.CONSUME(r),t.MANY((function(){t.SUBRULE(t.field)})),t.CONSUME(o)})),t.RULE("field",(function(){t.CONSUME(l),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])})),t.RULE("def",(function(){t.CONSUME(b),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(k)}}])})),t.RULE("use",(function(){t.CONSUME(x),t.OR([{ALT:function(){t.CONSUME(l)}},{ALT:function(){t.CONSUME(k)}}])})),t.RULE("singleFieldValue",(function(){t.AT_LEAST_ONE((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(p)}},{ALT:function(){t.CONSUME(h)}}])}))})),t.RULE("multiFieldValue",(function(){t.CONSUME(a),t.MANY((function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(f)}},{ALT:function(){t.CONSUME(h)}}])})),t.CONSUME(s)})),t.RULE("route",(function(){t.CONSUME(m),t.CONSUME(i),t.CONSUME(g),t.CONSUME2(i)})),this.performSelfAnalysis()}}class a{constructor(t,n,r){this.a=t,this.b=n,this.c=r,this.normal=new e.Vector3}}const s={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};exports.VRMLLoader=n;
@@ -110,7 +110,7 @@ class VRMLLoader extends Loader {
110
110
 
111
111
  const StringLiteral = createToken({
112
112
  name: 'StringLiteral',
113
- pattern: /"(:?[^\\"\n\r]+|\\(:?[bfnrtv"\\/]|u[0-9a-fA-F]{4}))*"/
113
+ pattern: /"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/
114
114
  });
115
115
  const HexLiteral = createToken({
116
116
  name: 'HexLiteral',
@@ -1040,6 +1040,7 @@ class VRMLLoader extends Loader {
1040
1040
  }
1041
1041
 
1042
1042
  texture = new DataTexture(data, width, height, useAlpha === true ? RGBAFormat : RGBFormat);
1043
+ texture.needsUpdate = true;
1043
1044
  texture.__type = textureType; // needed for material modifications
1044
1045
 
1045
1046
  break;
@@ -47,9 +47,9 @@ CameraNode.prototype.setScope = function (scope) {
47
47
  }
48
48
  };
49
49
 
50
- CameraNode.prototype.getType = function ()
51
- /* builder */
52
- {
50
+ CameraNode.prototype.getType = function
51
+ /* builder */
52
+ () {
53
53
  switch (this.scope) {
54
54
  case CameraNode.DEPTH:
55
55
  return 'f';
@@ -58,9 +58,9 @@ CameraNode.prototype.getType = function ()
58
58
  return this.type;
59
59
  };
60
60
 
61
- CameraNode.prototype.getUnique = function ()
62
- /* builder */
63
- {
61
+ CameraNode.prototype.getUnique = function
62
+ /* builder */
63
+ () {
64
64
  switch (this.scope) {
65
65
  case CameraNode.DEPTH:
66
66
  case CameraNode.TO_VERTEX:
@@ -70,9 +70,9 @@ CameraNode.prototype.getUnique = function ()
70
70
  return false;
71
71
  };
72
72
 
73
- CameraNode.prototype.getShared = function ()
74
- /* builder */
75
- {
73
+ CameraNode.prototype.getShared = function
74
+ /* builder */
75
+ () {
76
76
  switch (this.scope) {
77
77
  case CameraNode.POSITION:
78
78
  return false;
@@ -102,9 +102,9 @@ CameraNode.prototype.generate = function (builder, output) {
102
102
  return builder.format(result, this.getType(builder), output);
103
103
  };
104
104
 
105
- CameraNode.prototype.onUpdateFrame = function ()
106
- /* frame */
107
- {
105
+ CameraNode.prototype.onUpdateFrame = function
106
+ /* frame */
107
+ () {
108
108
  switch (this.scope) {
109
109
  case CameraNode.DEPTH:
110
110
  var camera = this.camera;
@@ -23,9 +23,9 @@ PositionNode.prototype.getType = function () {
23
23
  return this.type;
24
24
  };
25
25
 
26
- PositionNode.prototype.getShared = function ()
27
- /* builder */
28
- {
26
+ PositionNode.prototype.getShared = function
27
+ /* builder */
28
+ () {
29
29
  switch (this.scope) {
30
30
  case PositionNode.LOCAL:
31
31
  case PositionNode.WORLD:
@@ -18,9 +18,9 @@ ReflectNode.prototype.getUnique = function (builder) {
18
18
  return !builder.context.viewNormal;
19
19
  };
20
20
 
21
- ReflectNode.prototype.getType = function ()
22
- /* builder */
23
- {
21
+ ReflectNode.prototype.getType = function
22
+ /* builder */
23
+ () {
24
24
  switch (this.scope) {
25
25
  case ReflectNode.SPHERE:
26
26
  return 'v2';
@@ -16,9 +16,9 @@ FunctionNode.prototype.constructor = FunctionNode;
16
16
  FunctionNode.prototype.nodeType = 'Function';
17
17
  FunctionNode.prototype.useKeywords = true;
18
18
 
19
- FunctionNode.prototype.getShared = function ()
20
- /* builder, output */
21
- {
19
+ FunctionNode.prototype.getShared = function
20
+ /* builder, output */
21
+ () {
22
22
  return !this.isMethod;
23
23
  };
24
24
 
@@ -16,9 +16,9 @@ InputNode.prototype.setReadonly = function (value) {
16
16
  return this;
17
17
  };
18
18
 
19
- InputNode.prototype.getReadonly = function ()
20
- /* builder */
21
- {
19
+ InputNode.prototype.getReadonly = function
20
+ /* builder */
21
+ () {
22
22
  return this.readonly;
23
23
  };
24
24
 
@@ -53,9 +53,9 @@ Node.prototype = {
53
53
 
54
54
  return this.generate(builder, output, uuid);
55
55
  },
56
- generate: function ()
57
- /* builder, output, uuid, type, ns */
58
- {// This method needs to be implemented in subclasses
56
+ generate: function
57
+ /* builder, output, uuid, type, ns */
58
+ () {// This method needs to be implemented in subclasses
59
59
  },
60
60
  getHash: function () {
61
61
  var hash = '{';
@@ -93,9 +93,9 @@ Node.prototype = {
93
93
  this.name = name;
94
94
  return this;
95
95
  },
96
- getName: function ()
97
- /* builder */
98
- {
96
+ getName: function
97
+ /* builder */
98
+ () {
99
99
  return this.name;
100
100
  },
101
101
  getType: function (builder, output) {
@@ -59,9 +59,9 @@ TempNode.prototype.getShared = function (builder, output) {
59
59
  return output !== 'sampler2D' && output !== 'samplerCube' && this.shared;
60
60
  };
61
61
 
62
- TempNode.prototype.getUnique = function ()
63
- /* builder, output */
64
- {
62
+ TempNode.prototype.getUnique = function
63
+ /* builder, output */
64
+ () {
65
65
  return this.unique;
66
66
  };
67
67
 
@@ -70,9 +70,9 @@ TempNode.prototype.setLabel = function (name) {
70
70
  return this;
71
71
  };
72
72
 
73
- TempNode.prototype.getLabel = function ()
74
- /* builder */
75
- {
73
+ TempNode.prototype.getLabel = function
74
+ /* builder */
75
+ () {
76
76
  return this.label;
77
77
  };
78
78
 
@@ -31,9 +31,9 @@ BlurNode.prototype.constructor = BlurNode;
31
31
  BlurNode.prototype.nodeType = 'Blur';
32
32
  BlurNode.prototype.hashProperties = ['blurX', 'blurY'];
33
33
 
34
- BlurNode.prototype.updateFrame = function ()
35
- /* frame */
36
- {
34
+ BlurNode.prototype.updateFrame = function
35
+ /* frame */
36
+ () {
37
37
  if (this.size) {
38
38
  this.horizontal.value = this.radius.x / this.size.x;
39
39
  this.vertical.value = this.radius.y / this.size.y;
@@ -54,9 +54,9 @@ MathNode.prototype.constructor = MathNode;
54
54
  MathNode.prototype.nodeType = 'Math';
55
55
  MathNode.prototype.hashProperties = ['method'];
56
56
 
57
- MathNode.prototype.getNumInputs = function ()
58
- /*builder*/
59
- {
57
+ MathNode.prototype.getNumInputs = function
58
+ /*builder*/
59
+ () {
60
60
  switch (this.method) {
61
61
  case MathNode.MIX:
62
62
  case MathNode.CLAMP: