gl-draw 0.11.29 → 0.11.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var Ft=Object.defineProperty,$t=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var lt=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var jt=(r,t,e)=>t in r?Ft(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P=(r,t)=>{for(var e in t||(t={}))Bt.call(t,e)&&jt(r,e,t[e]);if(lt)for(var e of lt(t))Gt.call(t,e)&&jt(r,e,t[e]);return r},ht=(r,t)=>$t(r,Jt(t));var pt=(r,t)=>{var e={};for(var s in r)Bt.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&lt)for(var s of lt(r))t.indexOf(s)<0&&Gt.call(r,s)&&(e[s]=r[s]);return e};var nt=(r,t,e)=>new Promise((s,i)=>{var n=c=>{try{l(e.next(c))}catch(m){i(m)}},o=c=>{try{l(e.throw(c))}catch(m){i(m)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,o);l((e=e.apply(r,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("../BaseObject.js"),Xt=require("../index3.js"),T=require("three"),Yt=require("@tweenjs/tween.js"),Zt=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Kt=require("three/examples/jsm/lines/LineSegments2"),Q=require("../index2.js"),Rt=require("three/examples/jsm/lines/LineSegmentsGeometry"),zt=require("three/examples/jsm/lines/LineMaterial"),Vt=require("../uvGenerator.js"),ut=require("three-bvh-csg");function Ct(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const w=Ct(T),Z=Ct(Yt);class Qt extends J.BaseObject{constructor(t){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=P({type:"2d"},t)}create(){const{position:t,children:e}=this.options,s=document.createElement("div");this.element=s,e&&s.appendChild(e),this.options.type==="3d"?this.createCSS3DObject(s):this.options.type==="3dSprite"?this.createCSS3DSprite(s):this.createCSS2DObject(s),t&&this.object3d.position.copy(t)}setChildren(t){this.options.children=t,this.element.innerHTML="",this.element.appendChild(t)}showAndEnsureVisible(){const t=this.options.children;t&&(t.style.visibility="hidden",this.show(),setTimeout(()=>{t.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const t=this.options.children;if(!t)return;const e=t.getBoundingClientRect(),s=window.innerWidth,i=window.innerHeight;let n=0,o=0;e.left<0?n=-e.left:e.right>s&&(n=s-e.right),e.top<0?o=-e.top:e.bottom>i&&(o=i-e.bottom),e.left+n<0&&(n=-e.left),e.top+o<0&&(o=-e.top),(n!==0||o!==0)&&(t.style.transform=`translate(${n}px, ${o}px)`)}ensureVisible(){const t=this.options.children;if(!t)return;t.style.transform&&(t.style.transform="");const e=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(this.moveElementToViewport(),e.disconnect())})});e.observe(t)}onPointerEvent(t,e){const s=this.drawController.handlePickNode([this],t,e);this.onNodePointerIndex.push(s)}dispose(){this.onNodePointerIndex.forEach(t=>{this.drawController.removePickNode(t)}),super.dispose()}}class te extends J.BaseObject{constructor(t){super(),this.options=P({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},t)}create(){return nt(this,null,function*(){this.createGroup();const{data:t,maxDepth:e,colors:s,material:i,percentDepth:n,activeIndex:o}=this.options,l=Math.max(...t),c=t.reduce((a,h)=>a+h,0);let m=Math.PI/2;t.forEach((a,h)=>{if(a===0)return;const y=Math.PI*2*(a/c),f=s[h],b=n?e*(a/l):e,_=this.createGeometry(b,y),A=i?i.clone():new w.MeshBasicMaterial({color:f});i&&A.color.set(f);const S=new w.Mesh(_,A);S.userData.depth=b,S.userData.index=h,S.rotateZ(m),m+=y,this.add(S)}),o!==-1&&this.setActive(o)})}createGeometry(t,e){const{outRadius:s,innerRadius:i}=this.options,n=new w.Shape;return n.moveTo(s,0),n.lineTo(i,0),n.absarc(0,0,i,0,e,!1),n.absarc(0,0,s,e,0,!0),new w.ExtrudeGeometry(n,{curveSegments:48,depth:t,bevelEnabled:!1})}handlePick(t,e=1.3){const{object:s}=this.pencil.pick(t,this.object3d.children)||{},i=s?this.object3d.children.findIndex(n=>n===s):this.options.activeIndex;return this.setActive(i,e)}setActive(t,e=1.3){const s=this.object3d.children[t];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const n=new Z.Tween(i.scale).to({z:1},100);i.userData.levTween=n,n.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new Z.Tween(s.scale).to({z:e},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new Z.Tween(this.object3d.scale).to({z:1},1e3).easing(Z.Easing.Sinusoidal.InOut).start()}}class ee extends J.BaseObject{constructor(t){super(),this.rectAreaLightUniformsLibInit=!1,this.options=t}create(){var e,s,i,n,o,l,c,m,a,h,y,f,b,_,A,S,B;const t=this.options;if(t.type==="AmbientLight"){const v=new w.AmbientLight(t.color);v.name="环境光",this.object3d=v}else if(t.type==="DirectionalLight"){const v=new w.DirectionalLight(t.color,t.intensity);v.name="平行光",v.target.position.set(0,0,0),this.object3d=v,v.target.name="平行光目标",v.shadow.camera.name="平行光阴影相机",v.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=v}else if(t.type==="PointLight"){const v=new w.PointLight((e=t.color)!=null?e:16777215,(s=t.intensity)!=null?s:1,(i=t.distance)!=null?i:0,(n=t.decay)!=null?n:2);v.name="点光源",this.object3d=v,this.pointLight=v}else if(t.type==="SpotLight"){const v=new w.SpotLight((o=t.color)!=null?o:16777215,(l=t.intensity)!=null?l:1,(c=t.distance)!=null?c:0,(m=t.angle)!=null?m:Math.PI/3,(a=t.penumbra)!=null?a:1,(h=t.decay)!=null?h:2);v.name="聚光灯",this.object3d=v,this.spotLight=v,v.target.name="聚光灯目标"}else if(t.type==="HemisphereLight"){const v=new w.HemisphereLight((y=t.color)!=null?y:16777215,(f=t.groundColor)!=null?f:16777215,(b=t.intensity)!=null?b:1);v.name="半球光",this.object3d=v,this.hemisphereLight=v}else if(t.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Zt.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const v=new w.RectAreaLight((_=t.color)!=null?_:16777215,(A=t.intensity)!=null?A:1,(S=t.width)!=null?S:10,(B=t.height)!=null?B:10);v.name="矩形区域光",this.object3d=v,this.rectAreaLight=v}}render(){const t=this.object3d;t.target&&this.pencil.scene.add(t.target);const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const s=this.spotLight||this.directionalLight;s.position.copy(e),s.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const t=this.object3d;t.target&&this.pencil.scene.remove(t.target),super.dispose()}}function z(r,t=0){const e=r[0].index!==null,s=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),n={},o={},l=r[0].morphTargetsRelative,c=new T.BufferGeometry;let m=0;for(let a=0;a<r.length;++a){const h=r[a];let y=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in h.attributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.attributes[f]),y++}if(y!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". Make sure all geometries have the same number of attributes."),null;if(l!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". The geometry must have either an index or a position attribute"),null;if(t===1)c.addGroup(m,f,a);else if(t===2&&h.groups.length>0)for(let b of h.groups){let _=b.materialIndex;c.addGroup(m+b.start,Math.min(b.count,f),_)}m+=f}}if(e){let a=0;const h=[];for(let y=0;y<r.length;++y){const f=r[y].index;for(let b=0;b<f.count;++b)h.push(f.getX(b)+a);a+=r[y].attributes.position.count}c.setIndex(h)}for(const a in n){const h=Pt(n[a]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;c.setAttribute(a,h)}for(const a in o){const h=o[a][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[a]=[];for(let y=0;y<h;++y){const f=[];for(let _=0;_<o[a].length;++_)f.push(o[a][_][y]);const b=Pt(f);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;c.morphAttributes[a].push(b)}}return t===2?se(c):c}function Pt(r){let t,e,s,i=-1,n=0;for(let m=0;m<r.length;++m){const a=r[m];if(t===void 0&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=a.itemSize),e!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=a.normalized),s!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=a.gpuType),i!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=a.count*e}const o=new t(n),l=new T.BufferAttribute(o,e,s);let c=0;for(let m=0;m<r.length;++m){const a=r[m];if(a.isInterleavedBufferAttribute){const h=c/e;for(let y=0,f=a.count;y<f;y++)for(let b=0;b<e;b++){const _=a.getComponent(y,b);l.setComponent(y+h,b,_)}}else o.set(a.array,c);c+=a.count*e}return i!==void 0&&(l.gpuType=i),l}function se(r){if(r.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),r;let t=r.groups;if(t=t.sort((o,l)=>o.materialIndex!==l.materialIndex?o.materialIndex-l.materialIndex:o.start-l.start),r.getIndex()===null){const o=r.getAttribute("position"),l=[];for(let c=0;c<o.count;c+=3)l.push(c,c+1,c+2);r.setIndex(l)}const e=r.getIndex(),s=[];for(let o=0;o<t.length;o++){const l=t[o],c=l.start,m=c+l.count;for(let a=c;a<m;a++)s.push(e.getX(a))}r.dispose(),r.setIndex(s);let i=0;for(let o=0;o<t.length;o++){const l=t[o];l.start=i,i+=l.count}let n=t[0];r.groups=[n];for(let o=1;o<t.length;o++){const l=t[o];n.materialIndex===l.materialIndex?n.count+=l.count:(n=l,r.groups.push(n))}return r}const It=r=>{const{points:t}=r,e=t.reduce((i,n,o)=>(o<t.length-1&&i.push(n,t[o+1]),i),[]);return new w.BufferGeometry().setFromPoints(e)};let ie=class extends J.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,geometry:s,geometryArr:i,material:n,useGroups:o,setPointWidth:l,lineWidthArr:c,materialParameters:m,instanceCount:a}=this.options;let h=n,y=s;!h&&m&&(h=this.getMaterial(m)),!y&&t?y=It({points:t}):!y&&e?y=z(e.map(b=>It({points:b})),o!=null?o:0):!y&&i&&i.length>1?y=z(i,o!=null?o:0):!y&&i&&i.length===1&&([y]=i);const f=new Rt.LineSegmentsGeometry().fromLineSegments(new w.LineSegments(y));if(this.pencil.options.WebGPUTHREE){a&&(f.instanceCount=a);const b=new Q.LineSegments2(f,h);b.computeLineDistances(),this.object3d=b}else{const b=new Kt.LineSegments2(f,h);b.computeLineDistances(),this.object3d=b}})}getMaterial(t){return new zt.LineMaterial(P({color:new w.Color("#ffffff")},t))}};function mt(r,t,e,s,i){let n;if(r=r.subarray||r.slice?r:r.buffer,e=e.subarray||e.slice?e:e.buffer,r=t?r.subarray?r.subarray(t,i&&t+i):r.slice(t,i&&t+i):r,e.set)e.set(r,s);else for(n=0;n<r.length;n++)e[n+s]=r[n];return e}function ne(r){return r instanceof Float32Array?r:r instanceof w.BufferGeometry?r.getAttribute("position").array:r.map(t=>{const e=Array.isArray(t);return t instanceof w.Vector3?[t.x,t.y,t.z]:t instanceof w.Vector2?[t.x,t.y,0]:e&&t.length===3?[t[0],t[1],t[2]]:e&&t.length===2?[t[0],t[1],0]:t}).flat()}class Nt extends w.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new w.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(t){this.setPoints(t,this.widthCallback)}}})}setMatrixWorld(t){this.matrixWorld=t}setPoints(t,e){if(t=ne(t),this._points=t,this.widthCallback=e!=null?e:null,this.positions=[],this.counters=[],t.length&&t[0]instanceof w.Vector3)for(let s=0;s<t.length;s++){const i=t[s],n=s/(t.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(n),this.counters.push(n)}else for(let s=0;s<t.length;s+=3){const i=s/(t.length-1);this.positions.push(t[s],t[s+1],t[s+2]),this.positions.push(t[s],t[s+1],t[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(t,e){const s=t*6,i=e*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+2]}copyV3(t){const e=t*6;return[this.positions[e],this.positions[e+1],this.positions[e+2]]}process(){const t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let e,s;this.compareV3(0,t-1)?s=this.copyV3(t-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let i=0;i<t;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?e=this.widthCallback(i/(t-1)):e=1,this.width.push(e),this.width.push(e),this.uvs.push(i/(t-1),0),this.uvs.push(i/(t-1),1),i<t-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const n=i*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+3)}i>0&&(s=this.copyV3(i),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(t-1,0)?s=this.copyV3(1):s=this.copyV3(t-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new w.BufferAttribute(new Float32Array(this.positions),3),previous:new w.BufferAttribute(new Float32Array(this.previous),3),next:new w.BufferAttribute(new Float32Array(this.next),3),side:new w.BufferAttribute(new Float32Array(this.side),1),width:new w.BufferAttribute(new Float32Array(this.width),1),uv:new w.BufferAttribute(new Float32Array(this.uvs),2),index:new w.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new w.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:t,y:e,z:s}){const i=this._attributes.position.array,n=this._attributes.previous.array,o=this._attributes.next.array,l=i.length;mt(i,0,n,0,l),mt(i,6,i,0,l-6),i[l-6]=t,i[l-5]=e,i[l-4]=s,i[l-3]=t,i[l-2]=e,i[l-1]=s,mt(i,6,o,0,l-6),o[l-6]=t,o[l-5]=e,o[l-4]=s,o[l-3]=t,o[l-2]=e,o[l-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function re(r,t){const e=new w.Matrix4,s=new w.Ray,i=new w.Sphere,n=new w.Vector3,o=this.geometry;if(i.copy(o.boundingSphere),i.applyMatrix4(this.matrixWorld),!r.ray.intersectSphere(i,n))return;e.copy(this.matrixWorld).invert(),s.copy(r.ray).applyMatrix4(e);const l=new w.Vector3,c=new w.Vector3,m=new w.Vector3,a=this instanceof w.LineSegments?2:1,h=o.index,y=o.attributes;if(h!==null){const f=h.array,b=y.position.array,_=y.width.array;for(let A=0,S=f.length-1;A<S;A+=a){const B=f[A],v=f[A+1];l.fromArray(b,B*3),c.fromArray(b,v*3);const I=_[Math.floor(A/3)]!=null?_[Math.floor(A/3)]:1,X=r.params.Line.threshold+this.material.lineWidth*I/2,C=X*X;if(s.distanceSqToSegment(l,c,n,m)>C)continue;n.applyMatrix4(this.matrixWorld);const O=r.ray.origin.distanceTo(n);O<r.near||O>r.far||(t.push({distance:O,point:m.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=S)}}}const gt=r=>{const{setPointWidth:t,nodes:e}=r,s=new Nt;return s.setPoints(e,t),s};class oe extends J.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{nodes:t,nodesArr:e,geometry:s,geometryArr:i,material:n,useGroups:o,setPointWidth:l,lineWidthArr:c,materialParameters:m}=this.options;let a=n,h=s;!a&&m&&(a=this.getMaterial(m)),!h&&t?h=gt({nodes:t,setPointWidth:l}):!h&&e?h=z(e.map((y,f)=>{let b=l;return!b&&c&&(b=()=>{var _;return(_=c[f])!=null?_:c[0]}),gt({nodes:y,setPointWidth:b})}),o!=null?o:0):!h&&i&&i.length>1?h=z(i,o!=null?o:0):!h&&i&&i.length===1&&([h]=i),this.createMesh(h,a)})}setGeometry(t,e){const s=gt({nodes:t,setPointWidth:e}),i=this.object3d,n=i.geometry;i.geometry=s,n.dispose()}getMaterial(t){const{width:e,height:s}=this.pencil.getSize();return new Q.MeshLineMaterial(P({color:new w.Color("#ffffff"),resolution:new w.Vector2(e,s)},t))}addGeometries(t){const e=this.object3d,s=z([e.geometry,...t]);e.geometry=s}resize(t,e){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(t,e)}useMaterial(t){super.useMaterial(t);const{width:e,height:s}=this.pencil.getSize();this.resize(e,s)}animate({duration:t=1e3,delay:e=0,repeat:s=0,lineLoop:i,onRepeat:n,onUpdate:o,onComplete:l}={}){const{offset:c,offsetLoop:m}=this.material.uniforms;if(this.material.userData.tween)return;const a=i!=null?i:!0;c.value.x=1,m.value=0;let h=0;const y=new Z.Tween(c.value).to({x:-1},t).delay(e).repeat(s).onUpdate(({x:f})=>{a&&f<=0&&m.value===0&&(m.value=1),o&&o(f)}).onRepeat(()=>{h+=1,n&&n(h)}).onComplete(()=>{l&&l()}).start();this.material.userData.tween=y}render(){const{width:t,height:e}=this.pencil.getSize();this.resize(t,e)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),Z.remove(this.material.userData.tween)),super.dispose()}}const Ut=r=>{const l=r,{coordinate:t,startHeight:e,height:s}=l,i=pt(l,["coordinate","startHeight","height"]);let n=e||0;return typeof e!="undefined"&&typeof s!="undefined"&&(n=e+s),new Q.PolygonGeometry([t],ht(P({},i),{startHeight:e,endHeight:n}))};class ae extends J.BaseObject{constructor(t){super(),this.options=P({},t)}create(){const c=this.options,{geometry:t,coordinateArr:e,coordinate:s,material:i,useGroups:n}=c,o=pt(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let l=t;if(!l&&s)l=Ut(P({coordinate:s},o));else if(!l&&e){const m=e.map(a=>Ut(P({coordinate:a},o)));l=z(m,n!=null?n:0)}this.createMesh(l,i)}}class K extends T.BufferGeometry{constructor(t=new T.Shape([new T.Vector2(.5,.5),new T.Vector2(-.5,.5),new T.Vector2(-.5,-.5),new T.Vector2(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const s=this,i=[],n=[];for(let l=0,c=t.length;l<c;l++){const m=t[l];o(m)}this.setAttribute("position",new T.Float32BufferAttribute(i,3)),this.setAttribute("uv",new T.Float32BufferAttribute(n,2)),this.computeVertexNormals();function o(l){var vt,At,St;const c=[],m=e.curveSegments!==void 0?e.curveSegments:12,a=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1;let y=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,b=e.bevelSize!==void 0?e.bevelSize:f-.1,_=e.bevelOffset!==void 0?e.bevelOffset:0,A=e.bevelSegments!==void 0?e.bevelSegments:3;const S=e.extrudePath,B=e.UVGenerator!==void 0?e.UVGenerator:ce,v=(vt=e.hasTop)!=null?vt:!0,I=(At=e.hasBottom)!=null?At:!0,X=(St=e.hasSide)!=null?St:!0;let C,$=!1,O,tt,et,N;S&&(C=S.getSpacedPoints(a),$=!0,y=!1,O=S.computeFrenetFrames(a,!1),tt=new T.Vector3,et=new T.Vector3,N=new T.Vector3),y||(A=0,f=0,b=0,_=0);const yt=l.extractPoints(m);let U=yt.shape;const V=yt.holes;if(!T.ShapeUtils.isClockWise(U)){U=U.reverse();for(let u=0,d=V.length;u<d;u++){const p=V[u];T.ShapeUtils.isClockWise(p)&&(V[u]=p.reverse())}}const st=T.ShapeUtils.triangulateShape(U,V),R=U;for(let u=0,d=V.length;u<d;u++){const p=V[u];U=U.concat(p)}function Y(u,d,p){return d||console.error("THREE.ExtrudeGeometry: vec does not exist"),u.clone().addScaledVector(d,p)}const D=U.length,rt=st.length;function bt(u,d,p){let x,g,M;const L=u.x-d.x,E=u.y-d.y,G=p.x-u.x,j=p.y-u.y,it=L*L+E*E,dt=L*j-E*G;if(Math.abs(dt)>Number.EPSILON){const q=Math.sqrt(it),_t=Math.sqrt(G*G+j*j),Mt=d.x-E/q,Tt=d.y+L/q,kt=p.x-j/_t,qt=p.y+G/_t,Lt=((kt-Mt)*j-(qt-Tt)*G)/(L*j-E*G);x=Mt+L*Lt-u.x,g=Tt+E*Lt-u.y;const Et=x*x+g*g;if(Et<=2)return new T.Vector2(x,g);M=Math.sqrt(Et/2)}else{let q=!1;L>Number.EPSILON?G>Number.EPSILON&&(q=!0):L<-Number.EPSILON?G<-Number.EPSILON&&(q=!0):Math.sign(E)===Math.sign(j)&&(q=!0),q?(x=-E,g=L,M=Math.sqrt(it)):(x=L,g=E,M=Math.sqrt(it/2))}return new T.Vector2(x/M,g/M)}const ot=[];for(let u=0,d=R.length,p=d-1,x=u+1;u<d;u++,p++,x++)p===d&&(p=0),x===d&&(x=0),ot[u]=bt(R[u],R[p],R[x]);const ft=[];let F,at=ot.concat();for(let u=0,d=V.length;u<d;u++){const p=V[u];F=[];for(let x=0,g=p.length,M=g-1,L=x+1;x<g;x++,M++,L++)M===g&&(M=0),L===g&&(L=0),F[x]=bt(p[x],p[M],p[L]);ft.push(F),at=at.concat(F)}for(let u=0;u<A;u++){const d=u/A,p=f*Math.cos(d*Math.PI/2),x=b*Math.sin(d*Math.PI/2)+_;for(let g=0,M=R.length;g<M;g++){const L=Y(R[g],ot[g],x);H(L.x,L.y,-p)}for(let g=0,M=V.length;g<M;g++){const L=V[g];F=ft[g];for(let E=0,G=L.length;E<G;E++){const j=Y(L[E],F[E],x);H(j.x,j.y,-p)}}}const wt=b+_;for(let u=0;u<D;u++){const d=y?Y(U[u],at[u],wt):U[u];$?(et.copy(O.normals[0]).multiplyScalar(d.x),tt.copy(O.binormals[0]).multiplyScalar(d.y),N.copy(C[0]).add(et).add(tt),H(N.x,N.y,N.z)):H(d.x,d.y,0)}for(let u=1;u<=a;u++)for(let d=0;d<D;d++){const p=y?Y(U[d],at[d],wt):U[d];$?(et.copy(O.normals[u]).multiplyScalar(p.x),tt.copy(O.binormals[u]).multiplyScalar(p.y),N.copy(C[u]).add(et).add(tt),H(N.x,N.y,N.z)):H(p.x,p.y,h/a*u)}for(let u=A-1;u>=0;u--){const d=u/A,p=f*Math.cos(d*Math.PI/2),x=b*Math.sin(d*Math.PI/2)+_;for(let g=0,M=R.length;g<M;g++){const L=Y(R[g],ot[g],x);H(L.x,L.y,h+p)}for(let g=0,M=V.length;g<M;g++){const L=V[g];F=ft[g];for(let E=0,G=L.length;E<G;E++){const j=Y(L[E],F[E],x);$?H(j.x,j.y+C[a-1].y,C[a-1].x+p):H(j.x,j.y,h+p)}}}Dt(),X&&Ht();function Dt(){const u=i.length/3;if(y){let d=0,p=D*d;if(I)for(let x=0;x<rt;x++){const g=st[x];ct(g[2]+p,g[1]+p,g[0]+p)}if(d=a+A*2,p=D*d,v)for(let x=0;x<rt;x++){const g=st[x];ct(g[0]+p,g[1]+p,g[2]+p)}}else{if(I)for(let d=0;d<rt;d++){const p=st[d];ct(p[2],p[1],p[0])}if(v)for(let d=0;d<rt;d++){const p=st[d];ct(p[0]+D*a,p[1]+D*a,p[2]+D*a)}}s.addGroup(u,i.length/3-u,0)}function Ht(){const u=i.length/3;let d=0;xt(R,d),d+=R.length;for(let p=0,x=V.length;p<x;p++){const g=V[p];xt(g,d),d+=g.length}s.addGroup(u,i.length/3-u,1)}function xt(u,d){let p=u.length;for(;--p>=0;){const x=p;let g=p-1;g<0&&(g=u.length-1);for(let M=0,L=a+A*2;M<L;M++){const E=D*M,G=D*(M+1),j=d+x+E,it=d+g+E,dt=d+g+G,q=d+x+G;Wt(j,it,dt,q)}}}function H(u,d,p){c.push(u),c.push(d),c.push(p)}function ct(u,d,p){W(u),W(d),W(p);const x=i.length/3,g=B.generateTopUV(s,i,x-3,x-2,x-1);k(g[0]),k(g[1]),k(g[2])}function Wt(u,d,p,x){W(u),W(d),W(x),W(d),W(p),W(x);const g=i.length/3,M=B.generateSideWallUV(s,i,g-6,g-3,g-2,g-1);k(M[0]),k(M[1]),k(M[3]),k(M[1]),k(M[2]),k(M[3])}function W(u){i.push(c[u*3+0]),i.push(c[u*3+1]),i.push(c[u*3+2])}function k(u){n.push(u.x),n.push(u.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,s=this.parameters.options;return le(e,s,t)}static fromJSON(t,e){const s=[];for(let n=0,o=t.shapes.length;n<o;n++){const l=e[t.shapes[n]];s.push(l)}const i=t.options.extrudePath;return console.log(i.type),i!==void 0&&(t.options.extrudePath=new w[`${i.type}Curve`]().fromJSON(i)),new K(s,t.options)}}const ce={generateTopUV:function(r,t,e,s,i){const n=t[e*3],o=t[e*3+1],l=t[s*3],c=t[s*3+1],m=t[i*3],a=t[i*3+1];return[new T.Vector2(n,o),new T.Vector2(l,c),new T.Vector2(m,a)]},generateSideWallUV:function(r,t,e,s,i,n){const o=t[e*3],l=t[e*3+1],c=t[e*3+2],m=t[s*3],a=t[s*3+1],h=t[s*3+2],y=t[i*3],f=t[i*3+1],b=t[i*3+2],_=t[n*3],A=t[n*3+1],S=t[n*3+2];return Math.abs(l-a)<Math.abs(o-m)?[new T.Vector2(o,1-c),new T.Vector2(m,1-h),new T.Vector2(y,1-b),new T.Vector2(_,1-S)]:[new T.Vector2(l,1-c),new T.Vector2(a,1-h),new T.Vector2(f,1-b),new T.Vector2(A,1-S)]}};function le(r,t,e){if(e.shapes=[],Array.isArray(r))for(let s=0,i=r.length;s<i;s++){const n=r[s];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class he extends K{constructor(t,e){super(t,e);const s=new ut.Brush(new K(t,ht(P({},e),{hasTop:!0,hasSide:!0,hasBottom:!1})));s.updateMatrixWorld();const i=new w.Box3().setFromObject(s),n=new w.Vector3;i.getSize(n);const o=new w.Vector3(i.min.x+n.x/2,i.min.y+n.y/2,0);let l=e.topSegments,c=e.box3;if(c){c=c.union(i);const S=new w.Vector3;c.getSize(S);const B=Math.max(n.x/S.x,n.y/S.y);l=Math.ceil(e.topSegments*B)}if(l<4)return this;const m=new w.PlaneGeometry(n.x,n.y,l,l),a=new ut.Brush(m);a.position.set(o.x,o.y,o.z),a.updateMatrixWorld();const y=new ut.Evaluator().evaluate(a,s,ut.INTERSECTION),f=y.geometry.getAttribute("position"),b=new w.Float32BufferAttribute(f.count*2,2);for(let S=0;S<f.count;S++){const B=f.getZ(S);f.setZ(S,e.depth+B)}if(c){const S=c.min,B=c.max,v=new w.Vector3().subVectors(B,S);for(let I=0;I<f.count;I++){const X=f.getX(I),C=f.getY(I),$=(X-S.x)/v.x,O=(C-S.y)/v.y;b.setXY(I,$,O)}y.geometry.setAttribute("uv",b)}f.needsUpdate=!0;const _=new K(t,ht(P({},e),{hasTop:!1})),A=z([y.geometry,_],2);this.copy(A.toNonIndexed())}}const Ot=r=>{const{split:t,depth:e,points:s,box3:i,hasTop:n,hasBottom:o,hasSide:l,sideRepeat:c,topSegments:m}=r,a=m?he:K,h=new a(new w.Shape(s),{depth:e,bevelEnabled:!1,box3:i,UVGenerator:Vt.getUVGenerator({split:t,box3:i,sideRepeat:c}),hasTop:n,hasBottom:o,hasSide:l,topSegments:m});return Vt.claerUVGenerator(),h};class ue extends J.BaseObject{constructor(t){super(),this.options=P({depth:1},t)}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,useGroups:s,depth:i,geometry:n,geometryArr:o,material:l,box3:c,split:m,hasTop:a,hasBottom:h,hasSide:y}=this.options,f=Array.isArray(i)?i:[i],b=Array.isArray(c)?c:[c],_=l;let A=n;_||console.log("material is null"),!A&&t?A=Ot({points:t,depth:f[0],box3:b[0],split:m,hasTop:a,hasBottom:h,hasSide:y}):!A&&e?A=z(e.map((S,B)=>{var v,I;return Ot({points:S,depth:(v=f[B])!=null?v:f[0],box3:(I=b[B])!=null?I:b[0],split:m,hasTop:a,hasBottom:h,hasSide:y})}),s!=null?s:0):!A&&o&&o.length>1?A=z(o,s!=null?s:0):!A&&o&&o.length===1&&([A]=o),this.createMesh(A,_)})}addGeometries(t){const e=this.object3d,s=z([e.geometry,...t]);e.geometry=s}setTextureAnisotropic(t,e){t.anisotropy=e||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const fe=r=>{const{topColor:t,sideColor:e,sideMap:s,createCanvasObjectURL:i,split:n,maxAnisotropy:o}=r;return new Promise(l=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const m=n,a=document.createElement("canvas"),h=a.getContext("2d");a.height=c.height/(1-m),a.width=c.width,m&&t&&(h.fillStyle=t,h.fillRect(0,0,c.width,a.height*m)),s&&c instanceof HTMLImageElement?h.drawImage(c,0,a.height*m,c.width,c.height):e&&(h.fillStyle=e,h.fillRect(0,a.height*m,c.width,c.height)),i&&a.toBlob(f=>{console.log(URL.createObjectURL(f))});const y=new w.CanvasTexture(a);l(y)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=Xt.Group;exports.MeshLineMaterial=Q.MeshLineMaterial;exports.getConicPolygonGeometry=Q.PolygonGeometry;exports.getConicPolygonGeometryMetas=Q.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Rt.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>zt.LineMaterial});exports.ConicPolygon=ae;exports.ExtrudePolygon=ue;exports.Light=ee;exports.Line=oe;exports.Line2=ie;exports.MeshLineGeometry=Nt;exports.MeshLineRaycast=re;exports.Node=Qt;exports.Pie=te;exports.getSplitTexture=fe;
1
+ "use strict";var Ft=Object.defineProperty,$t=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var lt=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var jt=(r,t,e)=>t in r?Ft(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P=(r,t)=>{for(var e in t||(t={}))Bt.call(t,e)&&jt(r,e,t[e]);if(lt)for(var e of lt(t))Gt.call(t,e)&&jt(r,e,t[e]);return r},ht=(r,t)=>$t(r,Jt(t));var pt=(r,t)=>{var e={};for(var s in r)Bt.call(r,s)&&t.indexOf(s)<0&&(e[s]=r[s]);if(r!=null&&lt)for(var s of lt(r))t.indexOf(s)<0&&Gt.call(r,s)&&(e[s]=r[s]);return e};var nt=(r,t,e)=>new Promise((s,i)=>{var n=c=>{try{l(e.next(c))}catch(m){i(m)}},o=c=>{try{l(e.throw(c))}catch(m){i(m)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,o);l((e=e.apply(r,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("../BaseObject.js"),Xt=require("../index3.js"),T=require("three"),Yt=require("@tweenjs/tween.js"),Zt=require("three/examples/jsm/lights/RectAreaLightUniformsLib"),Kt=require("three/examples/jsm/lines/LineSegments2"),Q=require("../index2.js"),Rt=require("three/examples/jsm/lines/LineSegmentsGeometry"),zt=require("three/examples/jsm/lines/LineMaterial"),Vt=require("../uvGenerator.js"),ut=require("three-bvh-csg");function Ct(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const w=Ct(T),Z=Ct(Yt);class Qt extends J.BaseObject{constructor(t){super(),this.objectType="BaseObject#Node",this.onNodePointerIndex=[],this.options=P({type:"2d"},t)}create(){const{position:t,children:e}=this.options,s=document.createElement("div");this.element=s,e&&s.appendChild(e),this.options.type==="3d"?this.createCSS3DObject(s):this.options.type==="3dSprite"?this.createCSS3DSprite(s):this.createCSS2DObject(s),t&&this.object3d.position.copy(t)}setChildren(t){this.options.children=t,this.element.innerHTML="",this.element.appendChild(t)}showAndEnsureVisible(){const t=this.options.children;t&&(t.style.visibility="hidden",this.show(),setTimeout(()=>{t.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const t=this.options.children;if(!t)return;const e=t.getBoundingClientRect(),s=window.innerWidth,i=window.innerHeight;let n=0,o=0;e.left<0?n=-e.left:e.right>s&&(n=s-e.right),e.top<0?o=-e.top:e.bottom>i&&(o=i-e.bottom),e.left+n<0&&(n=-e.left),e.top+o<0&&(o=-e.top),(n!==0||o!==0)&&(t.style.transform=`translate(${n}px, ${o}px)`)}ensureVisible(){const t=this.options.children;if(!t)return;t.style.transform&&(t.style.transform="");const e=new IntersectionObserver(s=>{s.forEach(i=>{i.isIntersecting&&(this.moveElementToViewport(),e.disconnect())})});e.observe(t)}onPointerEvent(t,e){const s=this.drawController.handlePickNode([this],t,e);this.onNodePointerIndex.push(s)}dispose(){this.onNodePointerIndex.forEach(t=>{this.drawController.removePickNode(t)}),super.dispose()}}class te extends J.BaseObject{constructor(t){super(),this.options=P({maxDepth:10,percentDepth:!1,innerRadius:25,outRadius:42,activeIndex:-1},t)}create(){return nt(this,null,function*(){this.createGroup();const{data:t,maxDepth:e,colors:s,material:i,percentDepth:n,activeIndex:o}=this.options,l=Math.max(...t),c=t.reduce((a,h)=>a+h,0);let m=Math.PI/2;t.forEach((a,h)=>{if(a===0)return;const g=Math.PI*2*(a/c),f=s[h],b=n?e*(a/l):e,_=this.createGeometry(b,g),A=i?i.clone():new w.MeshBasicMaterial({color:f});i&&A.color.set(f);const S=new w.Mesh(_,A);S.userData.depth=b,S.userData.index=h,S.rotateZ(m),m+=g,this.add(S)}),o!==-1&&this.setActive(o)})}createGeometry(t,e){const{outRadius:s,innerRadius:i}=this.options,n=new w.Shape;return n.moveTo(s,0),n.lineTo(i,0),n.absarc(0,0,i,0,e,!1),n.absarc(0,0,s,e,0,!0),new w.ExtrudeGeometry(n,{curveSegments:48,depth:t,bevelEnabled:!1})}handlePick(t,e=1.3){const{object:s}=this.pencil.pick(t,this.object3d.children)||{},i=s?this.object3d.children.findIndex(n=>n===s):this.options.activeIndex;return this.setActive(i,e)}setActive(t,e=1.3){const s=this.object3d.children[t];if(this.object3d.children.forEach(i=>{if(!(s&&s===i)&&i.scale.z!==1){if(i.userData.levTween)return;i.userData.enTween&&(i.userData.enTween.stop(),i.userData.enTween=null);const n=new Z.Tween(i.scale).to({z:1},100);i.userData.levTween=n,n.start()}}),s){if(s.userData.enTween)return;s.userData.levTween&&(s.userData.levTween.stop(),s.userData.levTween=null);const i=new Z.Tween(s.scale).to({z:e},100);return s.userData.enTween=i,i.start(),s.userData.index}return-1}render(){this.object3d.scale.z=0,new Z.Tween(this.object3d.scale).to({z:1},1e3).easing(Z.Easing.Sinusoidal.InOut).start()}}class ee extends J.BaseObject{constructor(t){super(),this.rectAreaLightUniformsLibInit=!1,this.options=t}create(){var e,s,i,n,o,l,c,m,a,h,g,f,b,_,A,S,B;const t=this.options;if(t.type==="AmbientLight"){const v=new w.AmbientLight(t.color);v.name="环境光",this.object3d=v}else if(t.type==="DirectionalLight"){const v=new w.DirectionalLight(t.color,t.intensity);v.name="平行光",v.target.position.set(0,0,0),this.object3d=v,v.target.name="平行光目标",v.shadow.camera.name="平行光阴影相机",v.shadow.camera.userData.directionalLightShadow=!0,this.directionalLight=v}else if(t.type==="PointLight"){const v=new w.PointLight((e=t.color)!=null?e:16777215,(s=t.intensity)!=null?s:1,(i=t.distance)!=null?i:0,(n=t.decay)!=null?n:2);v.name="点光源",this.object3d=v,this.pointLight=v}else if(t.type==="SpotLight"){const v=new w.SpotLight((o=t.color)!=null?o:16777215,(l=t.intensity)!=null?l:1,(c=t.distance)!=null?c:0,(m=t.angle)!=null?m:Math.PI/3,(a=t.penumbra)!=null?a:1,(h=t.decay)!=null?h:2);v.name="聚光灯",this.object3d=v,this.spotLight=v,v.target.name="聚光灯目标"}else if(t.type==="HemisphereLight"){const v=new w.HemisphereLight((g=t.color)!=null?g:16777215,(f=t.groundColor)!=null?f:16777215,(b=t.intensity)!=null?b:1);v.name="半球光",this.object3d=v,this.hemisphereLight=v}else if(t.type==="RectAreaLight"){this.rectAreaLightUniformsLibInit||(Zt.RectAreaLightUniformsLib.init(),this.rectAreaLightUniformsLibInit=!0);const v=new w.RectAreaLight((_=t.color)!=null?_:16777215,(A=t.intensity)!=null?A:1,(S=t.width)!=null?S:10,(B=t.height)!=null?B:10);v.name="矩形区域光",this.object3d=v,this.rectAreaLight=v}}render(){const t=this.object3d;t.target&&this.pencil.scene.add(t.target);const e=this.pencil.cameraTarget;if(this.spotLight||this.directionalLight){const s=this.spotLight||this.directionalLight;s.position.copy(e),s.target.position.copy(e)}else this.pointLight&&this.pointLight.position.copy(e)}dispose(){const t=this.object3d;t.target&&this.pencil.scene.remove(t.target),super.dispose()}}function z(r,t=0){const e=r[0].index!==null,s=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),n={},o={},l=r[0].morphTargetsRelative,c=new T.BufferGeometry;let m=0;for(let a=0;a<r.length;++a){const h=r[a];let g=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in h.attributes){if(!s.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;n[f]===void 0&&(n[f]=[]),n[f].push(h.attributes[f]),g++}if(g!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". Make sure all geometries have the same number of attributes."),null;if(l!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+a+". The geometry must have either an index or a position attribute"),null;if(t===1)c.addGroup(m,f,a);else if(t===2&&h.groups.length>0)for(let b of h.groups){let _=b.materialIndex;c.addGroup(m+b.start,Math.min(b.count,f),_)}m+=f}}if(e){let a=0;const h=[];for(let g=0;g<r.length;++g){const f=r[g].index;for(let b=0;b<f.count;++b)h.push(f.getX(b)+a);a+=r[g].attributes.position.count}c.setIndex(h)}for(const a in n){const h=Pt(n[a]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" attribute."),null;c.setAttribute(a,h)}for(const a in o){const h=o[a][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[a]=[];for(let g=0;g<h;++g){const f=[];for(let _=0;_<o[a].length;++_)f.push(o[a][_][g]);const b=Pt(f);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+a+" morphAttribute."),null;c.morphAttributes[a].push(b)}}return t===2?se(c):c}function Pt(r){let t,e,s,i=-1,n=0;for(let m=0;m<r.length;++m){const a=r[m];if(t===void 0&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=a.itemSize),e!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=a.normalized),s!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=a.gpuType),i!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=a.count*e}const o=new t(n),l=new T.BufferAttribute(o,e,s);let c=0;for(let m=0;m<r.length;++m){const a=r[m];if(a.isInterleavedBufferAttribute){const h=c/e;for(let g=0,f=a.count;g<f;g++)for(let b=0;b<e;b++){const _=a.getComponent(g,b);l.setComponent(g+h,b,_)}}else o.set(a.array,c);c+=a.count*e}return i!==void 0&&(l.gpuType=i),l}function se(r){if(r.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),r;let t=r.groups;if(t=t.sort((o,l)=>o.materialIndex!==l.materialIndex?o.materialIndex-l.materialIndex:o.start-l.start),r.getIndex()===null){const o=r.getAttribute("position"),l=[];for(let c=0;c<o.count;c+=3)l.push(c,c+1,c+2);r.setIndex(l)}const e=r.getIndex(),s=[];for(let o=0;o<t.length;o++){const l=t[o],c=l.start,m=c+l.count;for(let a=c;a<m;a++)s.push(e.getX(a))}r.dispose(),r.setIndex(s);let i=0;for(let o=0;o<t.length;o++){const l=t[o];l.start=i,i+=l.count}let n=t[0];r.groups=[n];for(let o=1;o<t.length;o++){const l=t[o];n.materialIndex===l.materialIndex?n.count+=l.count:(n=l,r.groups.push(n))}return r}const It=r=>{const{points:t}=r,e=t.reduce((i,n,o)=>(o<t.length-1&&i.push(n,t[o+1]),i),[]);return new w.BufferGeometry().setFromPoints(e)};let ie=class extends J.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,geometry:s,geometryArr:i,material:n,useGroups:o,setPointWidth:l,lineWidthArr:c,materialParameters:m,instanceCount:a}=this.options;let h=n,g=s;!h&&m&&(h=this.getMaterial(m)),!g&&t?g=It({points:t}):!g&&e?g=z(e.map(b=>It({points:b})),o!=null?o:0):!g&&i&&i.length>1?g=z(i,o!=null?o:0):!g&&i&&i.length===1&&([g]=i);const f=new Rt.LineSegmentsGeometry().fromLineSegments(new w.LineSegments(g));if(this.pencil.options.WebGPUTHREE){a&&(f.instanceCount=a);const b=new Q.LineSegments2(f,h);b.computeLineDistances(),this.object3d=b}else{const b=new Kt.LineSegments2(f,h);b.computeLineDistances(),this.object3d=b}})}getMaterial(t){return new zt.LineMaterial(P({color:new w.Color("#ffffff")},t))}};function mt(r,t,e,s,i){let n;if(r=r.subarray||r.slice?r:r.buffer,e=e.subarray||e.slice?e:e.buffer,r=t?r.subarray?r.subarray(t,i&&t+i):r.slice(t,i&&t+i):r,e.set)e.set(r,s);else for(n=0;n<r.length;n++)e[n+s]=r[n];return e}function ne(r){return r instanceof Float32Array?r:r instanceof w.BufferGeometry?r.getAttribute("position").array:r.map(t=>{const e=Array.isArray(t);return t instanceof w.Vector3?[t.x,t.y,t.z]:t instanceof w.Vector2?[t.x,t.y,0]:e&&t.length===3?[t[0],t[1],t[2]]:e&&t.length===2?[t[0],t[1],0]:t}).flat()}class Nt extends w.BufferGeometry{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new w.Matrix4,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(t){this.setPoints(t,this.widthCallback)}}})}setMatrixWorld(t){this.matrixWorld=t}setPoints(t,e){if(t=ne(t),this._points=t,this.widthCallback=e!=null?e:null,this.positions=[],this.counters=[],t.length&&t[0]instanceof w.Vector3)for(let s=0;s<t.length;s++){const i=t[s],n=s/(t.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(n),this.counters.push(n)}else for(let s=0;s<t.length;s+=3){const i=s/(t.length-1);this.positions.push(t[s],t[s+1],t[s+2]),this.positions.push(t[s],t[s+1],t[s+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(t,e){const s=t*6,i=e*6;return this.positions[s]===this.positions[i]&&this.positions[s+1]===this.positions[i+1]&&this.positions[s+2]===this.positions[i+2]}copyV3(t){const e=t*6;return[this.positions[e],this.positions[e+1],this.positions[e+2]]}process(){const t=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let e,s;this.compareV3(0,t-1)?s=this.copyV3(t-2):s=this.copyV3(0),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);for(let i=0;i<t;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?e=this.widthCallback(i/(t-1)):e=1,this.width.push(e),this.width.push(e),this.uvs.push(i/(t-1),0),this.uvs.push(i/(t-1),1),i<t-1){s=this.copyV3(i),this.previous.push(s[0],s[1],s[2]),this.previous.push(s[0],s[1],s[2]);const n=i*2;this.indices_array.push(n,n+1,n+2),this.indices_array.push(n+2,n+1,n+3)}i>0&&(s=this.copyV3(i),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]))}this.compareV3(t-1,0)?s=this.copyV3(1):s=this.copyV3(t-1),this.next.push(s[0],s[1],s[2]),this.next.push(s[0],s[1],s[2]),!this._attributes||this._attributes.position.count!==this.counters.length?this._attributes={position:new w.BufferAttribute(new Float32Array(this.positions),3),previous:new w.BufferAttribute(new Float32Array(this.previous),3),next:new w.BufferAttribute(new Float32Array(this.next),3),side:new w.BufferAttribute(new Float32Array(this.side),1),width:new w.BufferAttribute(new Float32Array(this.width),1),uv:new w.BufferAttribute(new Float32Array(this.uvs),2),index:new w.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new w.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:t,y:e,z:s}){const i=this._attributes.position.array,n=this._attributes.previous.array,o=this._attributes.next.array,l=i.length;mt(i,0,n,0,l),mt(i,6,i,0,l-6),i[l-6]=t,i[l-5]=e,i[l-4]=s,i[l-3]=t,i[l-2]=e,i[l-1]=s,mt(i,6,o,0,l-6),o[l-6]=t,o[l-5]=e,o[l-4]=s,o[l-3]=t,o[l-2]=e,o[l-1]=s,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}function re(r,t){const e=new w.Matrix4,s=new w.Ray,i=new w.Sphere,n=new w.Vector3,o=this.geometry;if(i.copy(o.boundingSphere),i.applyMatrix4(this.matrixWorld),!r.ray.intersectSphere(i,n))return;e.copy(this.matrixWorld).invert(),s.copy(r.ray).applyMatrix4(e);const l=new w.Vector3,c=new w.Vector3,m=new w.Vector3,a=this instanceof w.LineSegments?2:1,h=o.index,g=o.attributes;if(h!==null){const f=h.array,b=g.position.array,_=g.width.array;for(let A=0,S=f.length-1;A<S;A+=a){const B=f[A],v=f[A+1];l.fromArray(b,B*3),c.fromArray(b,v*3);const I=_[Math.floor(A/3)]!=null?_[Math.floor(A/3)]:1,X=r.params.Line.threshold+this.material.lineWidth*I/2,C=X*X;if(s.distanceSqToSegment(l,c,n,m)>C)continue;n.applyMatrix4(this.matrixWorld);const O=r.ray.origin.distanceTo(n);O<r.near||O>r.far||(t.push({distance:O,point:m.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:void 0,object:this}),A=S)}}}const gt=r=>{const{setPointWidth:t,nodes:e}=r,s=new Nt;return s.setPoints(e,t),s};class oe extends J.BaseObject{constructor(t={}){super(),this.options=P({},t)}get material(){var t;return(t=this.object3d)==null?void 0:t.material}create(){return nt(this,null,function*(){const{nodes:t,nodesArr:e,geometry:s,geometryArr:i,material:n,useGroups:o,setPointWidth:l,lineWidthArr:c,materialParameters:m}=this.options;let a=n,h=s;!a&&m&&(a=this.getMaterial(m)),!h&&t?h=gt({nodes:t,setPointWidth:l}):!h&&e?h=z(e.map((g,f)=>{let b=l;return!b&&c&&(b=()=>{var _;return(_=c[f])!=null?_:c[0]}),gt({nodes:g,setPointWidth:b})}),o!=null?o:0):!h&&i&&i.length>1?h=z(i,o!=null?o:0):!h&&i&&i.length===1&&([h]=i),this.createMesh(h,a)})}setGeometry(t,e){const s=gt({nodes:t,setPointWidth:e}),i=this.object3d,n=i.geometry;i.geometry=s,n.dispose()}getMaterial(t){const{width:e,height:s}=this.pencil.getSize();return new Q.MeshLineMaterial(P({color:new w.Color("#ffffff"),resolution:new w.Vector2(e,s)},t))}addGeometries(t){const e=this.object3d,s=z([e.geometry,...t]);e.geometry=s}resize(t,e){var s,i;(i=(s=this.material)==null?void 0:s.uniforms)==null||i.resolution.value.set(t,e)}useMaterial(t){super.useMaterial(t);const{width:e,height:s}=this.pencil.getSize();this.resize(e,s)}animate({duration:t=1e3,delay:e=0,repeat:s=0,lineLoop:i,onRepeat:n,onUpdate:o,onComplete:l,startShow:c}={}){const{offset:m,offsetLoop:a}=this.material.uniforms;if(this.material.userData.tween)return;const h=i!=null?i:!0;m.value.x=1,a.value=h&&c?1:0;let g=0;const f=new Z.Tween(m.value).to({x:-1},t).delay(e).repeat(s).onUpdate(({x:b})=>{h&&b<=0&&a.value===0&&(a.value=1),o&&o(b)}).onRepeat(()=>{g+=1,n&&n(g)}).onComplete(()=>{l&&l()}).start();this.material.userData.tween=f}render(){const{width:t,height:e}=this.pencil.getSize();this.resize(t,e)}dispose(){this.material.userData.tween&&(this.material.userData.tween.stop(),Z.remove(this.material.userData.tween)),super.dispose()}}const Ut=r=>{const l=r,{coordinate:t,startHeight:e,height:s}=l,i=pt(l,["coordinate","startHeight","height"]);let n=e||0;return typeof e!="undefined"&&typeof s!="undefined"&&(n=e+s),new Q.PolygonGeometry([t],ht(P({},i),{startHeight:e,endHeight:n}))};class ae extends J.BaseObject{constructor(t){super(),this.options=P({},t)}create(){const c=this.options,{geometry:t,coordinateArr:e,coordinate:s,material:i,useGroups:n}=c,o=pt(c,["geometry","coordinateArr","coordinate","material","useGroups"]);let l=t;if(!l&&s)l=Ut(P({coordinate:s},o));else if(!l&&e){const m=e.map(a=>Ut(P({coordinate:a},o)));l=z(m,n!=null?n:0)}this.createMesh(l,i)}}class K extends T.BufferGeometry{constructor(t=new T.Shape([new T.Vector2(.5,.5),new T.Vector2(-.5,.5),new T.Vector2(-.5,-.5),new T.Vector2(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const s=this,i=[],n=[];for(let l=0,c=t.length;l<c;l++){const m=t[l];o(m)}this.setAttribute("position",new T.Float32BufferAttribute(i,3)),this.setAttribute("uv",new T.Float32BufferAttribute(n,2)),this.computeVertexNormals();function o(l){var vt,At,St;const c=[],m=e.curveSegments!==void 0?e.curveSegments:12,a=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1;let g=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,b=e.bevelSize!==void 0?e.bevelSize:f-.1,_=e.bevelOffset!==void 0?e.bevelOffset:0,A=e.bevelSegments!==void 0?e.bevelSegments:3;const S=e.extrudePath,B=e.UVGenerator!==void 0?e.UVGenerator:ce,v=(vt=e.hasTop)!=null?vt:!0,I=(At=e.hasBottom)!=null?At:!0,X=(St=e.hasSide)!=null?St:!0;let C,$=!1,O,tt,et,N;S&&(C=S.getSpacedPoints(a),$=!0,g=!1,O=S.computeFrenetFrames(a,!1),tt=new T.Vector3,et=new T.Vector3,N=new T.Vector3),g||(A=0,f=0,b=0,_=0);const yt=l.extractPoints(m);let U=yt.shape;const V=yt.holes;if(!T.ShapeUtils.isClockWise(U)){U=U.reverse();for(let u=0,d=V.length;u<d;u++){const p=V[u];T.ShapeUtils.isClockWise(p)&&(V[u]=p.reverse())}}const st=T.ShapeUtils.triangulateShape(U,V),R=U;for(let u=0,d=V.length;u<d;u++){const p=V[u];U=U.concat(p)}function Y(u,d,p){return d||console.error("THREE.ExtrudeGeometry: vec does not exist"),u.clone().addScaledVector(d,p)}const D=U.length,rt=st.length;function bt(u,d,p){let x,y,M;const L=u.x-d.x,E=u.y-d.y,G=p.x-u.x,j=p.y-u.y,it=L*L+E*E,dt=L*j-E*G;if(Math.abs(dt)>Number.EPSILON){const q=Math.sqrt(it),_t=Math.sqrt(G*G+j*j),Mt=d.x-E/q,Tt=d.y+L/q,kt=p.x-j/_t,qt=p.y+G/_t,Lt=((kt-Mt)*j-(qt-Tt)*G)/(L*j-E*G);x=Mt+L*Lt-u.x,y=Tt+E*Lt-u.y;const Et=x*x+y*y;if(Et<=2)return new T.Vector2(x,y);M=Math.sqrt(Et/2)}else{let q=!1;L>Number.EPSILON?G>Number.EPSILON&&(q=!0):L<-Number.EPSILON?G<-Number.EPSILON&&(q=!0):Math.sign(E)===Math.sign(j)&&(q=!0),q?(x=-E,y=L,M=Math.sqrt(it)):(x=L,y=E,M=Math.sqrt(it/2))}return new T.Vector2(x/M,y/M)}const ot=[];for(let u=0,d=R.length,p=d-1,x=u+1;u<d;u++,p++,x++)p===d&&(p=0),x===d&&(x=0),ot[u]=bt(R[u],R[p],R[x]);const ft=[];let F,at=ot.concat();for(let u=0,d=V.length;u<d;u++){const p=V[u];F=[];for(let x=0,y=p.length,M=y-1,L=x+1;x<y;x++,M++,L++)M===y&&(M=0),L===y&&(L=0),F[x]=bt(p[x],p[M],p[L]);ft.push(F),at=at.concat(F)}for(let u=0;u<A;u++){const d=u/A,p=f*Math.cos(d*Math.PI/2),x=b*Math.sin(d*Math.PI/2)+_;for(let y=0,M=R.length;y<M;y++){const L=Y(R[y],ot[y],x);H(L.x,L.y,-p)}for(let y=0,M=V.length;y<M;y++){const L=V[y];F=ft[y];for(let E=0,G=L.length;E<G;E++){const j=Y(L[E],F[E],x);H(j.x,j.y,-p)}}}const wt=b+_;for(let u=0;u<D;u++){const d=g?Y(U[u],at[u],wt):U[u];$?(et.copy(O.normals[0]).multiplyScalar(d.x),tt.copy(O.binormals[0]).multiplyScalar(d.y),N.copy(C[0]).add(et).add(tt),H(N.x,N.y,N.z)):H(d.x,d.y,0)}for(let u=1;u<=a;u++)for(let d=0;d<D;d++){const p=g?Y(U[d],at[d],wt):U[d];$?(et.copy(O.normals[u]).multiplyScalar(p.x),tt.copy(O.binormals[u]).multiplyScalar(p.y),N.copy(C[u]).add(et).add(tt),H(N.x,N.y,N.z)):H(p.x,p.y,h/a*u)}for(let u=A-1;u>=0;u--){const d=u/A,p=f*Math.cos(d*Math.PI/2),x=b*Math.sin(d*Math.PI/2)+_;for(let y=0,M=R.length;y<M;y++){const L=Y(R[y],ot[y],x);H(L.x,L.y,h+p)}for(let y=0,M=V.length;y<M;y++){const L=V[y];F=ft[y];for(let E=0,G=L.length;E<G;E++){const j=Y(L[E],F[E],x);$?H(j.x,j.y+C[a-1].y,C[a-1].x+p):H(j.x,j.y,h+p)}}}Dt(),X&&Ht();function Dt(){const u=i.length/3;if(g){let d=0,p=D*d;if(I)for(let x=0;x<rt;x++){const y=st[x];ct(y[2]+p,y[1]+p,y[0]+p)}if(d=a+A*2,p=D*d,v)for(let x=0;x<rt;x++){const y=st[x];ct(y[0]+p,y[1]+p,y[2]+p)}}else{if(I)for(let d=0;d<rt;d++){const p=st[d];ct(p[2],p[1],p[0])}if(v)for(let d=0;d<rt;d++){const p=st[d];ct(p[0]+D*a,p[1]+D*a,p[2]+D*a)}}s.addGroup(u,i.length/3-u,0)}function Ht(){const u=i.length/3;let d=0;xt(R,d),d+=R.length;for(let p=0,x=V.length;p<x;p++){const y=V[p];xt(y,d),d+=y.length}s.addGroup(u,i.length/3-u,1)}function xt(u,d){let p=u.length;for(;--p>=0;){const x=p;let y=p-1;y<0&&(y=u.length-1);for(let M=0,L=a+A*2;M<L;M++){const E=D*M,G=D*(M+1),j=d+x+E,it=d+y+E,dt=d+y+G,q=d+x+G;Wt(j,it,dt,q)}}}function H(u,d,p){c.push(u),c.push(d),c.push(p)}function ct(u,d,p){W(u),W(d),W(p);const x=i.length/3,y=B.generateTopUV(s,i,x-3,x-2,x-1);k(y[0]),k(y[1]),k(y[2])}function Wt(u,d,p,x){W(u),W(d),W(x),W(d),W(p),W(x);const y=i.length/3,M=B.generateSideWallUV(s,i,y-6,y-3,y-2,y-1);k(M[0]),k(M[1]),k(M[3]),k(M[1]),k(M[2]),k(M[3])}function W(u){i.push(c[u*3+0]),i.push(c[u*3+1]),i.push(c[u*3+2])}function k(u){n.push(u.x),n.push(u.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,s=this.parameters.options;return le(e,s,t)}static fromJSON(t,e){const s=[];for(let n=0,o=t.shapes.length;n<o;n++){const l=e[t.shapes[n]];s.push(l)}const i=t.options.extrudePath;return console.log(i.type),i!==void 0&&(t.options.extrudePath=new w[`${i.type}Curve`]().fromJSON(i)),new K(s,t.options)}}const ce={generateTopUV:function(r,t,e,s,i){const n=t[e*3],o=t[e*3+1],l=t[s*3],c=t[s*3+1],m=t[i*3],a=t[i*3+1];return[new T.Vector2(n,o),new T.Vector2(l,c),new T.Vector2(m,a)]},generateSideWallUV:function(r,t,e,s,i,n){const o=t[e*3],l=t[e*3+1],c=t[e*3+2],m=t[s*3],a=t[s*3+1],h=t[s*3+2],g=t[i*3],f=t[i*3+1],b=t[i*3+2],_=t[n*3],A=t[n*3+1],S=t[n*3+2];return Math.abs(l-a)<Math.abs(o-m)?[new T.Vector2(o,1-c),new T.Vector2(m,1-h),new T.Vector2(g,1-b),new T.Vector2(_,1-S)]:[new T.Vector2(l,1-c),new T.Vector2(a,1-h),new T.Vector2(f,1-b),new T.Vector2(A,1-S)]}};function le(r,t,e){if(e.shapes=[],Array.isArray(r))for(let s=0,i=r.length;s<i;s++){const n=r[s];e.shapes.push(n.uuid)}else e.shapes.push(r.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class he extends K{constructor(t,e){super(t,e);const s=new ut.Brush(new K(t,ht(P({},e),{hasTop:!0,hasSide:!0,hasBottom:!1})));s.updateMatrixWorld();const i=new w.Box3().setFromObject(s),n=new w.Vector3;i.getSize(n);const o=new w.Vector3(i.min.x+n.x/2,i.min.y+n.y/2,0);let l=e.topSegments,c=e.box3;if(c){c=c.union(i);const S=new w.Vector3;c.getSize(S);const B=Math.max(n.x/S.x,n.y/S.y);l=Math.ceil(e.topSegments*B)}if(l<4)return this;const m=new w.PlaneGeometry(n.x,n.y,l,l),a=new ut.Brush(m);a.position.set(o.x,o.y,o.z),a.updateMatrixWorld();const g=new ut.Evaluator().evaluate(a,s,ut.INTERSECTION),f=g.geometry.getAttribute("position"),b=new w.Float32BufferAttribute(f.count*2,2);for(let S=0;S<f.count;S++){const B=f.getZ(S);f.setZ(S,e.depth+B)}if(c){const S=c.min,B=c.max,v=new w.Vector3().subVectors(B,S);for(let I=0;I<f.count;I++){const X=f.getX(I),C=f.getY(I),$=(X-S.x)/v.x,O=(C-S.y)/v.y;b.setXY(I,$,O)}g.geometry.setAttribute("uv",b)}f.needsUpdate=!0;const _=new K(t,ht(P({},e),{hasTop:!1})),A=z([g.geometry,_],2);this.copy(A.toNonIndexed())}}const Ot=r=>{const{split:t,depth:e,points:s,box3:i,hasTop:n,hasBottom:o,hasSide:l,sideRepeat:c,topSegments:m}=r,a=m?he:K,h=new a(new w.Shape(s),{depth:e,bevelEnabled:!1,box3:i,UVGenerator:Vt.getUVGenerator({split:t,box3:i,sideRepeat:c}),hasTop:n,hasBottom:o,hasSide:l,topSegments:m});return Vt.claerUVGenerator(),h};class ue extends J.BaseObject{constructor(t){super(),this.options=P({depth:1},t)}create(){return nt(this,null,function*(){const{points:t,pointsArr:e,useGroups:s,depth:i,geometry:n,geometryArr:o,material:l,box3:c,split:m,hasTop:a,hasBottom:h,hasSide:g}=this.options,f=Array.isArray(i)?i:[i],b=Array.isArray(c)?c:[c],_=l;let A=n;_||console.log("material is null"),!A&&t?A=Ot({points:t,depth:f[0],box3:b[0],split:m,hasTop:a,hasBottom:h,hasSide:g}):!A&&e?A=z(e.map((S,B)=>{var v,I;return Ot({points:S,depth:(v=f[B])!=null?v:f[0],box3:(I=b[B])!=null?I:b[0],split:m,hasTop:a,hasBottom:h,hasSide:g})}),s!=null?s:0):!A&&o&&o.length>1?A=z(o,s!=null?s:0):!A&&o&&o.length===1&&([A]=o),this.createMesh(A,_)})}addGeometries(t){const e=this.object3d,s=z([e.geometry,...t]);e.geometry=s}setTextureAnisotropic(t,e){t.anisotropy=e||this.pencil.renderer.capabilities.getMaxAnisotropy()}}const fe=r=>{const{topColor:t,sideColor:e,sideMap:s,createCanvasObjectURL:i,split:n,maxAnisotropy:o}=r;return new Promise(l=>{const c=s?document.createElement("img"):{src:"",onload:()=>{},width:128,height:128};c.onload=()=>{const m=n,a=document.createElement("canvas"),h=a.getContext("2d");a.height=c.height/(1-m),a.width=c.width,m&&t&&(h.fillStyle=t,h.fillRect(0,0,c.width,a.height*m)),s&&c instanceof HTMLImageElement?h.drawImage(c,0,a.height*m,c.width,c.height):e&&(h.fillStyle=e,h.fillRect(0,a.height*m,c.width,c.height)),i&&a.toBlob(f=>{console.log(URL.createObjectURL(f))});const g=new w.CanvasTexture(a);l(g)},s?c.src=s:c instanceof HTMLImageElement||c.onload()})};exports.Group=Xt.Group;exports.MeshLineMaterial=Q.MeshLineMaterial;exports.getConicPolygonGeometry=Q.PolygonGeometry;exports.getConicPolygonGeometryMetas=Q.getMetas;Object.defineProperty(exports,"LineSegmentsGeometry",{enumerable:!0,get:()=>Rt.LineSegmentsGeometry});Object.defineProperty(exports,"Line2Material",{enumerable:!0,get:()=>zt.LineMaterial});exports.ConicPolygon=ae;exports.ExtrudePolygon=ue;exports.Light=ee;exports.Line=oe;exports.Line2=ie;exports.MeshLineGeometry=Nt;exports.MeshLineRaycast=re;exports.Node=Qt;exports.Pie=te;exports.getSplitTexture=fe;
@@ -114,12 +114,12 @@ class _e extends J {
114
114
  let m = Math.PI / 2;
115
115
  t.forEach((o, c) => {
116
116
  if (o === 0) return;
117
- const y = Math.PI * 2 * (o / h), f = s[c], b = n ? e * (o / l) : e, _ = this.createGeometry(b, y), A = i ? i.clone() : new w.MeshBasicMaterial({
117
+ const g = Math.PI * 2 * (o / h), f = s[c], b = n ? e * (o / l) : e, _ = this.createGeometry(b, g), A = i ? i.clone() : new w.MeshBasicMaterial({
118
118
  color: f
119
119
  });
120
120
  i && A.color.set(f);
121
121
  const S = new w.Mesh(_, A);
122
- S.userData.depth = b, S.userData.index = c, S.rotateZ(m), m += y, this.add(S);
122
+ S.userData.depth = b, S.userData.index = c, S.rotateZ(m), m += g, this.add(S);
123
123
  }), r !== -1 && this.setActive(r);
124
124
  });
125
125
  }
@@ -162,7 +162,7 @@ class Me extends J {
162
162
  super(), this.rectAreaLightUniformsLibInit = !1, this.options = t;
163
163
  }
164
164
  create() {
165
- var e, s, i, n, r, l, h, m, o, c, y, f, b, _, A, S, B;
165
+ var e, s, i, n, r, l, h, m, o, c, g, f, b, _, A, S, B;
166
166
  const t = this.options;
167
167
  if (t.type === "AmbientLight") {
168
168
  const v = new w.AmbientLight(t.color);
@@ -190,7 +190,7 @@ class Me extends J {
190
190
  v.name = "聚光灯", this.object3d = v, this.spotLight = v, v.target.name = "聚光灯目标";
191
191
  } else if (t.type === "HemisphereLight") {
192
192
  const v = new w.HemisphereLight(
193
- (y = t.color) != null ? y : 16777215,
193
+ (g = t.color) != null ? g : 16777215,
194
194
  (f = t.groundColor) != null ? f : 16777215,
195
195
  (b = t.intensity) != null ? b : 1
196
196
  );
@@ -227,7 +227,7 @@ function C(a, t = 0) {
227
227
  let m = 0;
228
228
  for (let o = 0; o < a.length; ++o) {
229
229
  const c = a[o];
230
- let y = 0;
230
+ let g = 0;
231
231
  if (e !== (c.index !== null))
232
232
  return console.error(
233
233
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."
@@ -237,9 +237,9 @@ function C(a, t = 0) {
237
237
  return console.error(
238
238
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + '. All geometries must have compatible attributes; make sure "' + f + '" attribute exists among all geometries, or in none of them.'
239
239
  ), null;
240
- n[f] === void 0 && (n[f] = []), n[f].push(c.attributes[f]), y++;
240
+ n[f] === void 0 && (n[f] = []), n[f].push(c.attributes[f]), g++;
241
241
  }
242
- if (y !== s.size)
242
+ if (g !== s.size)
243
243
  return console.error(
244
244
  "THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + o + ". Make sure all geometries have the same number of attributes."
245
245
  ), null;
@@ -281,11 +281,11 @@ function C(a, t = 0) {
281
281
  if (e) {
282
282
  let o = 0;
283
283
  const c = [];
284
- for (let y = 0; y < a.length; ++y) {
285
- const f = a[y].index;
284
+ for (let g = 0; g < a.length; ++g) {
285
+ const f = a[g].index;
286
286
  for (let b = 0; b < f.count; ++b)
287
287
  c.push(f.getX(b) + o);
288
- o += a[y].attributes.position.count;
288
+ o += a[g].attributes.position.count;
289
289
  }
290
290
  h.setIndex(c);
291
291
  }
@@ -301,10 +301,10 @@ function C(a, t = 0) {
301
301
  const c = r[o][0].length;
302
302
  if (c === 0) break;
303
303
  h.morphAttributes = h.morphAttributes || {}, h.morphAttributes[o] = [];
304
- for (let y = 0; y < c; ++y) {
304
+ for (let g = 0; g < c; ++g) {
305
305
  const f = [];
306
306
  for (let _ = 0; _ < r[o].length; ++_)
307
- f.push(r[o][_][y]);
307
+ f.push(r[o][_][g]);
308
308
  const b = Ut(f);
309
309
  if (!b)
310
310
  return console.error(
@@ -343,10 +343,10 @@ function Ut(a) {
343
343
  const o = a[m];
344
344
  if (o.isInterleavedBufferAttribute) {
345
345
  const c = h / e;
346
- for (let y = 0, f = o.count; y < f; y++)
346
+ for (let g = 0, f = o.count; g < f; g++)
347
347
  for (let b = 0; b < e; b++) {
348
- const _ = o.getComponent(y, b);
349
- l.setComponent(y + c, b, _);
348
+ const _ = o.getComponent(g, b);
349
+ l.setComponent(g + c, b, _);
350
350
  }
351
351
  } else
352
352
  r.set(o.array, h);
@@ -412,20 +412,20 @@ let Te = class extends J {
412
412
  materialParameters: m,
413
413
  instanceCount: o
414
414
  } = this.options;
415
- let c = n, y = s;
416
- !c && m && (c = this.getMaterial(m)), !y && t ? y = Vt({
415
+ let c = n, g = s;
416
+ !c && m && (c = this.getMaterial(m)), !g && t ? g = Vt({
417
417
  points: t
418
- }) : !y && e ? y = C(
418
+ }) : !g && e ? g = C(
419
419
  e.map((b) => Vt({
420
420
  points: b
421
421
  })),
422
422
  r != null ? r : 0
423
- ) : !y && i && i.length > 1 ? y = C(
423
+ ) : !g && i && i.length > 1 ? g = C(
424
424
  i,
425
425
  r != null ? r : 0
426
- ) : !y && i && i.length === 1 && ([y] = i);
426
+ ) : !g && i && i.length === 1 && ([g] = i);
427
427
  const f = new te().fromLineSegments(
428
- new w.LineSegments(y)
428
+ new w.LineSegments(g)
429
429
  );
430
430
  if (this.pencil.options.WebGPUTHREE) {
431
431
  o && (f.instanceCount = o);
@@ -547,9 +547,9 @@ function Ee(a, t) {
547
547
  const e = new w.Matrix4(), s = new w.Ray(), i = new w.Sphere(), n = new w.Vector3(), r = this.geometry;
548
548
  if (i.copy(r.boundingSphere), i.applyMatrix4(this.matrixWorld), !a.ray.intersectSphere(i, n)) return;
549
549
  e.copy(this.matrixWorld).invert(), s.copy(a.ray).applyMatrix4(e);
550
- const l = new w.Vector3(), h = new w.Vector3(), m = new w.Vector3(), o = this instanceof w.LineSegments ? 2 : 1, c = r.index, y = r.attributes;
550
+ const l = new w.Vector3(), h = new w.Vector3(), m = new w.Vector3(), o = this instanceof w.LineSegments ? 2 : 1, c = r.index, g = r.attributes;
551
551
  if (c !== null) {
552
- const f = c.array, b = y.position.array, _ = y.width.array;
552
+ const f = c.array, b = g.position.array, _ = g.width.array;
553
553
  for (let A = 0, S = f.length - 1; A < S; A += o) {
554
554
  const B = f[A], v = f[A + 1];
555
555
  l.fromArray(b, B * 3), h.fromArray(b, v * 3);
@@ -605,13 +605,13 @@ class Ge extends J {
605
605
  nodes: t,
606
606
  setPointWidth: l
607
607
  }) : !c && e ? c = C(
608
- e.map((y, f) => {
608
+ e.map((g, f) => {
609
609
  let b = l;
610
610
  return !b && h && (b = () => {
611
611
  var _;
612
612
  return (_ = h[f]) != null ? _ : h[0];
613
613
  }), gt({
614
- nodes: y,
614
+ nodes: g,
615
615
  setPointWidth: b
616
616
  });
617
617
  }),
@@ -659,22 +659,23 @@ class Ge extends J {
659
659
  lineLoop: i,
660
660
  onRepeat: n,
661
661
  onUpdate: r,
662
- onComplete: l
662
+ onComplete: l,
663
+ startShow: h
663
664
  } = {}) {
664
- const { offset: h, offsetLoop: m } = this.material.uniforms;
665
+ const { offset: m, offsetLoop: o } = this.material.uniforms;
665
666
  if (this.material.userData.tween)
666
667
  return;
667
- const o = i != null ? i : !0;
668
- h.value.x = 1, m.value = 0;
669
- let c = 0;
670
- const y = new Z.Tween(h.value).to({ x: -1 }, t).delay(e).repeat(s).onUpdate(({ x: f }) => {
671
- o && f <= 0 && m.value === 0 && (m.value = 1), r && r(f);
668
+ const c = i != null ? i : !0;
669
+ m.value.x = 1, o.value = c && h ? 1 : 0;
670
+ let g = 0;
671
+ const f = new Z.Tween(m.value).to({ x: -1 }, t).delay(e).repeat(s).onUpdate(({ x: b }) => {
672
+ c && b <= 0 && o.value === 0 && (o.value = 1), r && r(b);
672
673
  }).onRepeat(() => {
673
- c += 1, n && n(c);
674
+ g += 1, n && n(g);
674
675
  }).onComplete(() => {
675
676
  l && l();
676
677
  }).start();
677
- this.material.userData.tween = y;
678
+ this.material.userData.tween = f;
678
679
  }
679
680
  render() {
680
681
  const { width: t, height: e } = this.pencil.getSize();
@@ -749,10 +750,10 @@ class K extends Ct {
749
750
  function r(l) {
750
751
  var vt, At, St;
751
752
  const h = [], m = e.curveSegments !== void 0 ? e.curveSegments : 12, o = e.steps !== void 0 ? e.steps : 1, c = e.depth !== void 0 ? e.depth : 1;
752
- let y = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, f = e.bevelThickness !== void 0 ? e.bevelThickness : 0.2, b = e.bevelSize !== void 0 ? e.bevelSize : f - 0.1, _ = e.bevelOffset !== void 0 ? e.bevelOffset : 0, A = e.bevelSegments !== void 0 ? e.bevelSegments : 3;
753
+ let g = e.bevelEnabled !== void 0 ? e.bevelEnabled : !0, f = e.bevelThickness !== void 0 ? e.bevelThickness : 0.2, b = e.bevelSize !== void 0 ? e.bevelSize : f - 0.1, _ = e.bevelOffset !== void 0 ? e.bevelOffset : 0, A = e.bevelSegments !== void 0 ? e.bevelSegments : 3;
753
754
  const S = e.extrudePath, B = e.UVGenerator !== void 0 ? e.UVGenerator : le, v = (vt = e.hasTop) != null ? vt : !0, U = (At = e.hasBottom) != null ? At : !0, X = (St = e.hasSide) != null ? St : !0;
754
755
  let N, $ = !1, z, Q, tt, D;
755
- S && (N = S.getSpacedPoints(o), $ = !0, y = !1, z = S.computeFrenetFrames(o, !1), Q = new dt(), tt = new dt(), D = new dt()), y || (A = 0, f = 0, b = 0, _ = 0);
756
+ S && (N = S.getSpacedPoints(o), $ = !0, g = !1, z = S.computeFrenetFrames(o, !1), Q = new dt(), tt = new dt(), D = new dt()), g || (A = 0, f = 0, b = 0, _ = 0);
756
757
  const yt = l.extractPoints(m);
757
758
  let V = yt.shape;
758
759
  const I = yt.holes;
@@ -773,22 +774,22 @@ class K extends Ct {
773
774
  }
774
775
  const O = V.length, nt = et.length;
775
776
  function bt(u, d, p) {
776
- let x, g, M;
777
+ let x, y, M;
777
778
  const T = u.x - d.x, L = u.y - d.y, j = p.x - u.x, E = p.y - u.y, st = T * T + L * L, ut = T * E - L * j;
778
779
  if (Math.abs(ut) > Number.EPSILON) {
779
780
  const F = Math.sqrt(st), _t = Math.sqrt(
780
781
  j * j + E * E
781
782
  ), Mt = d.x - L / F, Tt = d.y + T / F, Ht = p.x - E / _t, Wt = p.y + j / _t, Lt = ((Ht - Mt) * E - (Wt - Tt) * j) / (T * E - L * j);
782
- x = Mt + T * Lt - u.x, g = Tt + L * Lt - u.y;
783
- const Et = x * x + g * g;
783
+ x = Mt + T * Lt - u.x, y = Tt + L * Lt - u.y;
784
+ const Et = x * x + y * y;
784
785
  if (Et <= 2)
785
- return new G(x, g);
786
+ return new G(x, y);
786
787
  M = Math.sqrt(Et / 2);
787
788
  } else {
788
789
  let F = !1;
789
- T > Number.EPSILON ? j > Number.EPSILON && (F = !0) : T < -Number.EPSILON ? j < -Number.EPSILON && (F = !0) : Math.sign(L) === Math.sign(E) && (F = !0), F ? (x = -L, g = T, M = Math.sqrt(st)) : (x = T, g = L, M = Math.sqrt(st / 2));
790
+ T > Number.EPSILON ? j > Number.EPSILON && (F = !0) : T < -Number.EPSILON ? j < -Number.EPSILON && (F = !0) : Math.sign(L) === Math.sign(E) && (F = !0), F ? (x = -L, y = T, M = Math.sqrt(st)) : (x = T, y = L, M = Math.sqrt(st / 2));
790
791
  }
791
- return new G(x / M, g / M);
792
+ return new G(x / M, y / M);
792
793
  }
793
794
  const rt = [];
794
795
  for (let u = 0, d = R.length, p = d - 1, x = u + 1; u < d; u++, p++, x++)
@@ -798,19 +799,19 @@ class K extends Ct {
798
799
  for (let u = 0, d = I.length; u < d; u++) {
799
800
  const p = I[u];
800
801
  q = [];
801
- for (let x = 0, g = p.length, M = g - 1, T = x + 1; x < g; x++, M++, T++)
802
- M === g && (M = 0), T === g && (T = 0), q[x] = bt(p[x], p[M], p[T]);
802
+ for (let x = 0, y = p.length, M = y - 1, T = x + 1; x < y; x++, M++, T++)
803
+ M === y && (M = 0), T === y && (T = 0), q[x] = bt(p[x], p[M], p[T]);
803
804
  ct.push(q), ot = ot.concat(q);
804
805
  }
805
806
  for (let u = 0; u < A; u++) {
806
807
  const d = u / A, p = f * Math.cos(d * Math.PI / 2), x = b * Math.sin(d * Math.PI / 2) + _;
807
- for (let g = 0, M = R.length; g < M; g++) {
808
- const T = Y(R[g], rt[g], x);
808
+ for (let y = 0, M = R.length; y < M; y++) {
809
+ const T = Y(R[y], rt[y], x);
809
810
  H(T.x, T.y, -p);
810
811
  }
811
- for (let g = 0, M = I.length; g < M; g++) {
812
- const T = I[g];
813
- q = ct[g];
812
+ for (let y = 0, M = I.length; y < M; y++) {
813
+ const T = I[y];
814
+ q = ct[y];
814
815
  for (let L = 0, j = T.length; L < j; L++) {
815
816
  const E = Y(T[L], q[L], x);
816
817
  H(E.x, E.y, -p);
@@ -819,23 +820,23 @@ class K extends Ct {
819
820
  }
820
821
  const wt = b + _;
821
822
  for (let u = 0; u < O; u++) {
822
- const d = y ? Y(V[u], ot[u], wt) : V[u];
823
+ const d = g ? Y(V[u], ot[u], wt) : V[u];
823
824
  $ ? (tt.copy(z.normals[0]).multiplyScalar(d.x), Q.copy(z.binormals[0]).multiplyScalar(d.y), D.copy(N[0]).add(tt).add(Q), H(D.x, D.y, D.z)) : H(d.x, d.y, 0);
824
825
  }
825
826
  for (let u = 1; u <= o; u++)
826
827
  for (let d = 0; d < O; d++) {
827
- const p = y ? Y(V[d], ot[d], wt) : V[d];
828
+ const p = g ? Y(V[d], ot[d], wt) : V[d];
828
829
  $ ? (tt.copy(z.normals[u]).multiplyScalar(p.x), Q.copy(z.binormals[u]).multiplyScalar(p.y), D.copy(N[u]).add(tt).add(Q), H(D.x, D.y, D.z)) : H(p.x, p.y, c / o * u);
829
830
  }
830
831
  for (let u = A - 1; u >= 0; u--) {
831
832
  const d = u / A, p = f * Math.cos(d * Math.PI / 2), x = b * Math.sin(d * Math.PI / 2) + _;
832
- for (let g = 0, M = R.length; g < M; g++) {
833
- const T = Y(R[g], rt[g], x);
833
+ for (let y = 0, M = R.length; y < M; y++) {
834
+ const T = Y(R[y], rt[y], x);
834
835
  H(T.x, T.y, c + p);
835
836
  }
836
- for (let g = 0, M = I.length; g < M; g++) {
837
- const T = I[g];
838
- q = ct[g];
837
+ for (let y = 0, M = I.length; y < M; y++) {
838
+ const T = I[y];
839
+ q = ct[y];
839
840
  for (let L = 0, j = T.length; L < j; L++) {
840
841
  const E = Y(T[L], q[L], x);
841
842
  $ ? H(
@@ -849,17 +850,17 @@ class K extends Ct {
849
850
  Nt(), X && Dt();
850
851
  function Nt() {
851
852
  const u = i.length / 3;
852
- if (y) {
853
+ if (g) {
853
854
  let d = 0, p = O * d;
854
855
  if (U)
855
856
  for (let x = 0; x < nt; x++) {
856
- const g = et[x];
857
- at(g[2] + p, g[1] + p, g[0] + p);
857
+ const y = et[x];
858
+ at(y[2] + p, y[1] + p, y[0] + p);
858
859
  }
859
860
  if (d = o + A * 2, p = O * d, v)
860
861
  for (let x = 0; x < nt; x++) {
861
- const g = et[x];
862
- at(g[0] + p, g[1] + p, g[2] + p);
862
+ const y = et[x];
863
+ at(y[0] + p, y[1] + p, y[2] + p);
863
864
  }
864
865
  } else {
865
866
  if (U)
@@ -884,8 +885,8 @@ class K extends Ct {
884
885
  let d = 0;
885
886
  xt(R, d), d += R.length;
886
887
  for (let p = 0, x = I.length; p < x; p++) {
887
- const g = I[p];
888
- xt(g, d), d += g.length;
888
+ const y = I[p];
889
+ xt(y, d), d += y.length;
889
890
  }
890
891
  s.addGroup(u, i.length / 3 - u, 1);
891
892
  }
@@ -893,10 +894,10 @@ class K extends Ct {
893
894
  let p = u.length;
894
895
  for (; --p >= 0; ) {
895
896
  const x = p;
896
- let g = p - 1;
897
- g < 0 && (g = u.length - 1);
897
+ let y = p - 1;
898
+ y < 0 && (y = u.length - 1);
898
899
  for (let M = 0, T = o + A * 2; M < T; M++) {
899
- const L = O * M, j = O * (M + 1), E = d + x + L, st = d + g + L, ut = d + g + j, F = d + x + j;
900
+ const L = O * M, j = O * (M + 1), E = d + x + L, st = d + y + L, ut = d + y + j, F = d + x + j;
900
901
  Ot(E, st, ut, F);
901
902
  }
902
903
  }
@@ -906,24 +907,24 @@ class K extends Ct {
906
907
  }
907
908
  function at(u, d, p) {
908
909
  W(u), W(d), W(p);
909
- const x = i.length / 3, g = B.generateTopUV(
910
+ const x = i.length / 3, y = B.generateTopUV(
910
911
  s,
911
912
  i,
912
913
  x - 3,
913
914
  x - 2,
914
915
  x - 1
915
916
  );
916
- k(g[0]), k(g[1]), k(g[2]);
917
+ k(y[0]), k(y[1]), k(y[2]);
917
918
  }
918
919
  function Ot(u, d, p, x) {
919
920
  W(u), W(d), W(x), W(d), W(p), W(x);
920
- const g = i.length / 3, M = B.generateSideWallUV(
921
+ const y = i.length / 3, M = B.generateSideWallUV(
921
922
  s,
922
923
  i,
923
- g - 6,
924
- g - 3,
925
- g - 2,
926
- g - 1
924
+ y - 6,
925
+ y - 3,
926
+ y - 2,
927
+ y - 1
927
928
  );
928
929
  k(M[0]), k(M[1]), k(M[3]), k(M[1]), k(M[2]), k(M[3]);
929
930
  }
@@ -962,11 +963,11 @@ const le = {
962
963
  ];
963
964
  },
964
965
  generateSideWallUV: function(a, t, e, s, i, n) {
965
- const r = t[e * 3], l = t[e * 3 + 1], h = t[e * 3 + 2], m = t[s * 3], o = t[s * 3 + 1], c = t[s * 3 + 2], y = t[i * 3], f = t[i * 3 + 1], b = t[i * 3 + 2], _ = t[n * 3], A = t[n * 3 + 1], S = t[n * 3 + 2];
966
+ const r = t[e * 3], l = t[e * 3 + 1], h = t[e * 3 + 2], m = t[s * 3], o = t[s * 3 + 1], c = t[s * 3 + 2], g = t[i * 3], f = t[i * 3 + 1], b = t[i * 3 + 2], _ = t[n * 3], A = t[n * 3 + 1], S = t[n * 3 + 2];
966
967
  return Math.abs(l - o) < Math.abs(r - m) ? [
967
968
  new G(r, 1 - h),
968
969
  new G(m, 1 - c),
969
- new G(y, 1 - b),
970
+ new G(g, 1 - b),
970
971
  new G(_, 1 - S)
971
972
  ] : [
972
973
  new G(l, 1 - h),
@@ -1024,7 +1025,7 @@ class ue extends K {
1024
1025
  l
1025
1026
  ), o = new Pt(m);
1026
1027
  o.position.set(r.x, r.y, r.z), o.updateMatrixWorld();
1027
- const y = new ne().evaluate(o, s, re), f = y.geometry.getAttribute("position"), b = new w.Float32BufferAttribute(
1028
+ const g = new ne().evaluate(o, s, re), f = g.geometry.getAttribute("position"), b = new w.Float32BufferAttribute(
1028
1029
  f.count * 2,
1029
1030
  2
1030
1031
  );
@@ -1038,13 +1039,13 @@ class ue extends K {
1038
1039
  const X = f.getX(U), N = f.getY(U), $ = (X - S.x) / v.x, z = (N - S.y) / v.y;
1039
1040
  b.setXY(U, $, z);
1040
1041
  }
1041
- y.geometry.setAttribute("uv", b);
1042
+ g.geometry.setAttribute("uv", b);
1042
1043
  }
1043
1044
  f.needsUpdate = !0;
1044
1045
  const _ = new K(t, lt(P({}, e), {
1045
1046
  hasTop: !1
1046
1047
  })), A = C(
1047
- [y.geometry, _],
1048
+ [g.geometry, _],
1048
1049
  2
1049
1050
  );
1050
1051
  this.copy(A.toNonIndexed());
@@ -1097,7 +1098,7 @@ class je extends J {
1097
1098
  split: m,
1098
1099
  hasTop: o,
1099
1100
  hasBottom: c,
1100
- hasSide: y
1101
+ hasSide: g
1101
1102
  } = this.options, f = Array.isArray(i) ? i : [i], b = Array.isArray(h) ? h : [h], _ = l;
1102
1103
  let A = n;
1103
1104
  _ || console.log("material is null"), !A && t ? A = Rt({
@@ -1107,7 +1108,7 @@ class je extends J {
1107
1108
  split: m,
1108
1109
  hasTop: o,
1109
1110
  hasBottom: c,
1110
- hasSide: y
1111
+ hasSide: g
1111
1112
  }) : !A && e ? A = C(
1112
1113
  e.map(
1113
1114
  (S, B) => {
@@ -1119,7 +1120,7 @@ class je extends J {
1119
1120
  split: m,
1120
1121
  hasTop: o,
1121
1122
  hasBottom: c,
1122
- hasSide: y
1123
+ hasSide: g
1123
1124
  });
1124
1125
  }
1125
1126
  ),
@@ -1163,8 +1164,8 @@ const Ie = (a) => {
1163
1164
  o.height = h.height / (1 - m), o.width = h.width, m && t && (c.fillStyle = t, c.fillRect(0, 0, h.width, o.height * m)), s && h instanceof HTMLImageElement ? c.drawImage(h, 0, o.height * m, h.width, h.height) : e && (c.fillStyle = e, c.fillRect(0, o.height * m, h.width, h.height)), i && o.toBlob((f) => {
1164
1165
  console.log(URL.createObjectURL(f));
1165
1166
  });
1166
- const y = new w.CanvasTexture(o);
1167
- l(y);
1167
+ const g = new w.CanvasTexture(o);
1168
+ l(g);
1168
1169
  }, s ? h.src = s : h instanceof HTMLImageElement || h.onload();
1169
1170
  });
1170
1171
  };
@@ -25,7 +25,7 @@ export default class Line extends BaseObject {
25
25
  addGeometries(geometries: THREE.BufferGeometry[]): void;
26
26
  resize(w: number, h: number): void;
27
27
  useMaterial(type: string): void;
28
- animate({ duration, delay, repeat, lineLoop, onRepeat, onUpdate, onComplete, }?: {
28
+ animate({ duration, delay, repeat, lineLoop, onRepeat, onUpdate, onComplete, startShow, }?: {
29
29
  duration?: number;
30
30
  delay?: number;
31
31
  repeat?: number;
@@ -33,6 +33,7 @@ export default class Line extends BaseObject {
33
33
  onComplete?: (...args: any[]) => void;
34
34
  onUpdate?: (...args: any[]) => void;
35
35
  onRepeat?: (...args: any[]) => void;
36
+ startShow?: boolean;
36
37
  }): void;
37
38
  render(): void;
38
39
  dispose(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.11.29",
3
+ "version": "0.11.30",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",