gl-draw 0.15.14 → 0.15.15
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.
- package/dist/core/Lead/Lead.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.module.js +181 -176
- package/dist/index.module2.js +1 -1
- package/dist/index2.js +1 -1
- package/package.json +1 -1
package/dist/index.module2.js
CHANGED
|
@@ -298,7 +298,7 @@ class ft {
|
|
|
298
298
|
this,
|
|
299
299
|
void 0,
|
|
300
300
|
this.disposeMaterialIfNotUsed
|
|
301
|
-
), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
|
|
301
|
+
), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
|
|
302
302
|
const e = new ne();
|
|
303
303
|
e.disposeMaterial = !this.pencil.options.mList, e.track(this), e.dispose();
|
|
304
304
|
}
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,Y=(o,e,t)=>e in o?fe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,O=(o,e)=>{for(var t in e||(e={}))me.call(e,t)&&Y(o,t,e[t]);if(X)for(var t of X(e))ve.call(e,t)&&Y(o,t,e[t]);return o},q=(o,e)=>de(o,pe(e));var ee=(o,e,t)=>new Promise((i,s)=>{var a=l=>{try{n(t.next(l))}catch(u){s(u)}},c=l=>{try{n(t.throw(l))}catch(u){s(u)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,c);n((t=t.apply(o,e)).next())});const r=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),W=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),T=require("d3-array"),K=require("earcut"),ye=require("@turf/boolean-clockwise"),Me=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale"),je=(o,e=1)=>{const t=new r.BufferGeometry;t.setAttribute("position",new r.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new r.Float32BufferAttribute(new Array(e).fill(1),1));const i=o.material,s=new r.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return s.onBeforeCompile=a=>{a.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
3
|
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new r.Points(t,s)},Pe=0,Se=1,Ae=2,Ce=!1;class Q{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[],this.disposeTrack=!0,this.disposeMaterialIfNotUsed=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.lead.objMap.get(t).erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Pe),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createMesh(...e){return this.object3d=new r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:a,objectOptions:c}=this,[,n]=a.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=je(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),j=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(j),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(O({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),a[m]=n.x,a[m+1]=n.y,a[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const a=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=a,a}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof r.Material)return e;if(e instanceof Q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,V=new r.Vector4,N=new r.Vector3,Z=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,k=new r.Box3,R=new r.Sphere,D=new r.Vector4;let L,_;function ae(o,e,t){return D.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),D.multiplyScalar(1/D.w),D.x=_/t.width,D.y=_/t.height,D.applyMatrix4(o.projectionMatrixInverse),D.multiplyScalar(1/D.w),Math.abs(Math.max(D.x,D.y))}function Be(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(a,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;L.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<_*.5&&e.push({point:m,pointOnLine:u,distance:L.origin.distanceTo(m),object:o,face:null,faceIndex:n,uv:null,uv1:null})}}function Ie(o,e,t){const i=e.projectionMatrix,a=o.material.resolution,c=o.matrixWorld,n=o.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;L.at(1,V),V.w=1,V.applyMatrix4(e.matrixWorldInverse),V.applyMatrix4(i),V.multiplyScalar(1/V.w),V.x*=a.x/2,V.y*=a.y/2,V.z=0,N.copy(V),Z.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(Z),M.applyMatrix4(Z),y.z>h&&M.z>h)continue;if(y.z>h){const I=y.z-M.z,P=(y.z-h)/I;y.lerp(M,P)}else if(M.z>h){const I=M.z-y.z,P=(M.z-h)/I;M.lerp(y,P)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=a.x/2,y.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(N,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),j=b>=-1&&b<=1,B=N.distanceTo(ne)<_*.5;if(j&&B){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const I=new r.Vector3,P=new r.Vector3;L.distanceSqToSegment(x.start,x.end,P,I),t.push({point:P,pointOnLine:I,distance:L.origin.distanceTo(P),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ve extends r.Mesh{constructor(e=new be.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const a=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;L=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;_=l.linewidth+a,n.boundingSphere===null&&n.computeBoundingSphere(),R.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=_*.5;else{const h=Math.max(s.near,R.distanceToPoint(L.origin));u=ae(s,h,l.resolution)}if(R.radius+=u,L.intersectsSphere(R)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),k.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=_*.5;else{const h=Math.max(s.near,k.distanceToPoint(L.origin));m=ae(s,h,l.resolution)}k.expandByScalar(m),L.intersectsBox(k)!==!1&&(i?Be(this,t):Ie(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const oe=["encodings_fragment","colorspace_fragment"],De=`
|
|
4
|
+
`},new r.Points(t,s)},Pe=0,Se=1,Ae=2,Ce=!1;class Q{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[],this.disposeTrack=!0,this.disposeMaterialIfNotUsed=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.lead.objMap.get(t).erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Pe),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createMesh(...e){return this.object3d=new r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:a,objectOptions:c}=this,[,n]=a.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=je(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),j=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(j),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(O({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),a[m]=n.x,a[m+1]=n.y,a[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const a=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=a,a}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof r.Material)return e;if(e instanceof Q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,V=new r.Vector4,N=new r.Vector3,Z=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,k=new r.Box3,R=new r.Sphere,D=new r.Vector4;let L,_;function ae(o,e,t){return D.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),D.multiplyScalar(1/D.w),D.x=_/t.width,D.y=_/t.height,D.applyMatrix4(o.projectionMatrixInverse),D.multiplyScalar(1/D.w),Math.abs(Math.max(D.x,D.y))}function Be(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(a,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;L.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<_*.5&&e.push({point:m,pointOnLine:u,distance:L.origin.distanceTo(m),object:o,face:null,faceIndex:n,uv:null,uv1:null})}}function Ie(o,e,t){const i=e.projectionMatrix,a=o.material.resolution,c=o.matrixWorld,n=o.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;L.at(1,V),V.w=1,V.applyMatrix4(e.matrixWorldInverse),V.applyMatrix4(i),V.multiplyScalar(1/V.w),V.x*=a.x/2,V.y*=a.y/2,V.z=0,N.copy(V),Z.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(Z),M.applyMatrix4(Z),y.z>h&&M.z>h)continue;if(y.z>h){const I=y.z-M.z,P=(y.z-h)/I;y.lerp(M,P)}else if(M.z>h){const I=M.z-y.z,P=(M.z-h)/I;M.lerp(y,P)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=a.x/2,y.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(N,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),j=b>=-1&&b<=1,B=N.distanceTo(ne)<_*.5;if(j&&B){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const I=new r.Vector3,P=new r.Vector3;L.distanceSqToSegment(x.start,x.end,P,I),t.push({point:P,pointOnLine:I,distance:L.origin.distanceTo(P),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ve extends r.Mesh{constructor(e=new be.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const a=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;L=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;_=l.linewidth+a,n.boundingSphere===null&&n.computeBoundingSphere(),R.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=_*.5;else{const h=Math.max(s.near,R.distanceToPoint(L.origin));u=ae(s,h,l.resolution)}if(R.radius+=u,L.intersectsSphere(R)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),k.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=_*.5;else{const h=Math.max(s.near,k.distanceToPoint(L.origin));m=ae(s,h,l.resolution)}k.expandByScalar(m),L.intersectsBox(k)!==!1&&(i?Be(this,t):Ie(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const oe=["encodings_fragment","colorspace_fragment"],De=`
|
|
5
5
|
#include <common>
|
|
6
6
|
#include <logdepthbuf_pars_vertex>
|
|
7
7
|
#include <fog_pars_vertex>
|