@thatopen/components 2.4.0-alpha.3 → 2.4.0-alpha.4
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/index.cjs +1 -1
- package/dist/index.mjs +1 -0
- package/dist/namespace.d.ts +3563 -3563
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -223,7 +223,7 @@ ${r}
|
|
|
223
223
|
${o}
|
|
224
224
|
</Users>`:""}
|
|
225
225
|
</Extensions>
|
|
226
|
-
`}processMarkupComment(t){const{Guid:e,Date:s,Author:n,Comment:r,Viewpoint:o}=t;if(!(e&&s&&n&&(Cs||o)))return null;const a=this.components.get(Zt),l=new Cs(this.components,r??"");return l.guid=e,l.date=new Date(s),l.author=n,l.viewpoint=o!=null&&o.Guid?a.list.get(o.Guid):void 0,l.modifiedAuthor=t.ModifiedAuthor,l.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,l}getMarkupComments(t,e){var o;let s;if(e==="2.1"&&(s=t.Comment),e==="3"&&(s=(o=t.Topic.Comments)==null?void 0:o.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(t,e){var r;let s;return e==="2.1"&&(s=t.Topic.Labels),e==="3"&&(s=(r=t.Topic.Labels)==null?void 0:r.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(t,e){var n;let s;return e==="2.1"&&(s=t.Viewpoints),e==="3"&&(s=(n=t.Topic.Viewpoints)==null?void 0:n.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,e){var r;let s;return e==="2.1"&&(s=t.Topic.RelatedTopic),e==="3"&&(s=(r=t.Topic.RelatedTopics)==null?void 0:r.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(o=>o.Guid):[]}async load(t,e){var m;const{fallbackVersionOnImport:s,ignoreIncompleteTopicsOnImport:n,updateExtensionsOnImport:r}=this.config,o=new Lr;await o.loadAsync(t);const a=Object.values(o.files);let l=s;const h=a.find(F=>F.name.endsWith(".version"));if(h){const F=await h.async("string"),R=Fe.xmlParser.parse(F).Version.VersionId;l=String(R)}if(!(l&&(l==="2.1"||l==="3")))throw new Error(`BCFTopics: ${l} is not supported.`);const f=a.find(F=>F.name.endsWith(".extensions"));if(r&&f){const F=await f.async("string");Fo(this,F)}const I=[],u=this.components.get(Zt),d=a.filter(F=>F.name.endsWith(".bcfv"));for(const F of d){const R=await F.async("string"),S=Fe.xmlParser.parse(R).VisualizationInfo;if(!S){console.warn("Missing VisualizationInfo in Viewpoint");continue}const N={},{Guid:L,ClippingPlanes:D,Components:P,OrthogonalCamera:v,PerspectiveCamera:G}=S;if(L&&(N.guid=L),P){const{Selection:w,Visibility:g}=P;if(w&&w.Component){const Q=Array.isArray(w.Component)?w.Component:[w.Component];N.selectionComponents=Q.map(z=>z.IfcGuid).filter(z=>z)}if(g&&"DefaultVisibility"in g&&(N.defaultVisibility=g.DefaultVisibility),g&&g.Exceptions&&"Component"in g.Exceptions){const{Component:Q}=g.Exceptions,z=Array.isArray(Q)?Q:[Q];N.exceptionComponents=z.map(et=>et.IfcGuid).filter(et=>et)}let U;l==="2.1"&&(U=P.ViewSetupHints),l==="3"&&(U=(m=P.Visibility)==null?void 0:m.ViewSetupHints),U&&("OpeningsVisible"in U&&(N.openingsVisible=U.OpeningsVisible),"SpacesVisible"in U&&(N.spacesVisible=U.SpacesVisible),"SpaceBoundariesVisible"in U&&(N.spaceBoundariesVisible=U.SpaceBoundariesVisible))}if(v||G){const w=S.PerspectiveCamera??S.OrthogonalCamera,{CameraViewPoint:g,CameraDirection:U}=w,Q=new b.Vector3(Number(g.X),Number(g.Z),Number(-g.Y)),z=new b.Vector3(Number(U.X),Number(U.Z),Number(-U.Y)),et={position:{x:Q.x,y:Q.y,z:Q.z},direction:{x:z.x,y:z.y,z:z.z},aspectRatio:"AspectRatio"in w?w.AspectRatio:1};"ViewToWorldScale"in w&&(N.camera={...et,viewToWorldScale:w.ViewToWorldScale}),"FieldOfView"in w&&(N.camera={...et,fov:w.FieldOfView})}const O=new kn(this.components,e,{data:N,setCamera:!1});if(P){const{Coloring:w}=P;if(w&&w.Color){const g=Array.isArray(w.Color)?w.Color:[w.Color];for(const U of g){const{Color:Q,Component:z}=U,X=(Array.isArray(z)?z:[z]).map(nt=>nt.IfcGuid);O.componentColors.set(Q,X)}}}if(I.push(O),D){const w=this.components.get(Is),g=Array.isArray(D.ClippingPlane)?D.ClippingPlane:[D.ClippingPlane];for(const U of g){const{Location:Q,Direction:z}=U;if(!(Q&&z))continue;const et=new b.Vector3(Q.X,Q.Z,-Q.Y),X=new b.Vector3(z.X,-z.Z,z.Y),nt=w.createFromNormalAndCoplanarPoint(e,X,et);nt.visible=!1,nt.enabled=!1,O.clippingPlanes.add(nt)}}}const E={},T=[],p=a.filter(F=>F.name.endsWith(".bcf"));for(const F of p){const R=await F.async("string"),S=Fe.xmlParser.parse(R).Markup,N=S.Topic,{Guid:L,TopicType:D,TopicStatus:P,Title:v,CreationDate:G,CreationAuthor:O}=N;if(n&&!(L&&D&&P&&v&&G&&O))continue;const w=new Mi(this.components);w.guid=L??w.guid;const g=this.getMarkupRelatedTopics(S,l);E[w.guid]=new Set(g),w.type=D??w.type,w.status=P??w.status,w.title=v??w.title,w.creationDate=G?new Date(G):w.creationDate,w.creationAuthor=O??w.creationAuthor,w.serverAssignedId=N.ServerAssignedId,w.priority=N.Priority,w.index=N.Index,w.modifiedDate=N.ModifiedDate?new Date(N.ModifiedDate):void 0,w.modifiedAuthor=N.ModifiedAuthor,w.dueDate=N.DueDate?new Date(N.DueDate):void 0,w.assignedTo=N.AssignedTo,w.description=N.Description,w.stage=N.Stage;const U=this.getMarkupLabels(S,l);for(const et of U)w.labels.add(et);const Q=this.getMarkupComments(S,l);for(const et of Q)w.comments.set(et.guid,et);const z=this.getMarkupViewpoints(S,l);for(const et of z){if(!(et&&et.Guid))continue;const X=u.list.get(et.Guid);X&&w.viewpoints.add(X.guid)}this.list.set(w.guid,w),T.push(w)}for(const F in E){const R=this.list.get(F);if(!R)continue;const S=E[F];for(const N of S)R.relatedTopics.add(N)}return this.onBCFImported.trigger(T),{viewpoints:I,topics:T}}};C(Fe,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),C(Fe,"xmlParser",new Ao.XMLParser({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let Mt=Fe;const ie=class ie extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"onDisposed",new q);C(this,"_absoluteMin");C(this,"_absoluteMax");C(this,"_meshes",[]);this.components.add(ie.uuid,this),this._absoluteMin=ie.newBound(!0),this._absoluteMax=ie.newBound(!1)}static getDimensions(t){const{min:e,max:s}=t,n=Math.abs(s.x-e.x),r=Math.abs(s.y-e.y),o=Math.abs(s.z-e.z),a=new b.Vector3;return a.subVectors(s,e).divideScalar(2).add(e),{width:n,height:r,depth:o,center:a}}static newBound(t){const e=t?1:-1;return new b.Vector3(e*Number.MAX_VALUE,e*Number.MAX_VALUE,e*Number.MAX_VALUE)}static getBounds(t,e,s){const n=s||this.newBound(!1),r=e||this.newBound(!0);for(const o of t)o.x<r.x&&(r.x=o.x),o.y<r.y&&(r.y=o.y),o.z<r.z&&(r.z=o.z),o.x>n.x&&(n.x=o.x),o.y>n.y&&(n.y=o.y),o.z>n.z&&(n.z=o.z);return new b.Box3(e,s)}dispose(){const t=this.components.get(Ce);for(const e of this._meshes)t.destroy(e);this._meshes=[],this.onDisposed.trigger(ie.uuid),this.onDisposed.reset()}get(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone();return new b.Box3(t,e)}getSphere(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone(),s=Math.abs((e.x-t.x)/2),n=Math.abs((e.y-t.y)/2),r=Math.abs((e.z-t.z)/2),o=new b.Vector3(t.x+s,t.y+n,t.z+r),a=o.distanceTo(t);return new b.Sphere(o,a)}getMesh(){const t=new b.Box3(this._absoluteMin,this._absoluteMax),e=ie.getDimensions(t),{width:s,height:n,depth:r,center:o}=e,a=new b.BoxGeometry(s,n,r),l=new b.Mesh(a);return this._meshes.push(l),l.position.copy(o),l}reset(){this._absoluteMin=ie.newBound(!0),this._absoluteMax=ie.newBound(!1)}add(t){for(const e of t.items)this.addMesh(e.mesh)}addMesh(t,e){if(!t.geometry.index)return;const s=ie.getFragmentBounds(t);t.updateMatrixWorld();const n=t.matrixWorld,r=new b.Matrix4,o=t instanceof b.InstancedMesh,a=new Set;if(t instanceof jt.FragmentMesh){e||(e=t.fragment.ids);for(const l of e){const h=t.fragment.getInstancesIDs(l);if(h)for(const f of h)a.add(f)}}else a.add(0);for(const l of a){const h=s.min.clone(),f=s.max.clone();o&&(t.getMatrixAt(l,r),h.applyMatrix4(r),f.applyMatrix4(r)),h.applyMatrix4(n),f.applyMatrix4(n),h.x<this._absoluteMin.x&&(this._absoluteMin.x=h.x),h.y<this._absoluteMin.y&&(this._absoluteMin.y=h.y),h.z<this._absoluteMin.z&&(this._absoluteMin.z=h.z),h.x>this._absoluteMax.x&&(this._absoluteMax.x=h.x),h.y>this._absoluteMax.y&&(this._absoluteMax.y=h.y),h.z>this._absoluteMax.z&&(this._absoluteMax.z=h.z),f.x>this._absoluteMax.x&&(this._absoluteMax.x=f.x),f.y>this._absoluteMax.y&&(this._absoluteMax.y=f.y),f.z>this._absoluteMax.z&&(this._absoluteMax.z=f.z),f.x<this._absoluteMin.x&&(this._absoluteMin.x=f.x),f.y<this._absoluteMin.y&&(this._absoluteMin.y=f.y),f.z<this._absoluteMin.z&&(this._absoluteMin.z=f.z)}}addFragmentIdMap(t){const e=this.components.get(pt);for(const s in t){const n=e.list.get(s);if(!n)continue;const r=t[s];this.addMesh(n.mesh,r)}}static getFragmentBounds(t){const e=t.geometry.attributes.position,s=Number.MAX_VALUE,n=-s,r=new b.Vector3(s,s,s),o=new b.Vector3(n,n,n);if(!t.geometry.index)throw new Error("Geometry must be indexed!");const a=Array.from(t.geometry.index.array);for(let l=0;l<a.length;l++){if(l%3===0&&a[l]===0&&a[l+1]===0&&a[l+2]===0){l+=2;continue}const h=a[l],f=e.getX(h),I=e.getY(h),u=e.getZ(h);f<r.x&&(r.x=f),I<r.y&&(r.y=I),u<r.z&&(r.z=u),f>o.x&&(o.x=f),I>o.y&&(o.y=I),u>o.z&&(o.z=u)}return new b.Box3(r,o)}};C(ie,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Ts=ie;const ys=class ys{constructor(i){C(this,"onProgress",new q);C(this,"inclusive",!1);C(this,"rules",[]);C(this,"ids",{});C(this,"needsUpdate",new Map);C(this,"components");this.components=i}static import(i,t){const e=ys.importers.get(t.type);return e?e(i,t):(console.warn("Invalid query data:.",t),null)}static importRules(i){const t=[];for(const e of i){const s={};for(const n in e){const r=e[n];r.regexp?s[n]=new RegExp(r.value):s[n]=r}t.push(s)}return t}static importIds(i){const t={};for(const e in i.ids)t[e]=new Set(i.ids[e]);return t}clear(i){if(i===void 0){this.ids={},this.needsUpdate.clear();return}delete this.ids[i],this.needsUpdate.delete(i)}addID(i,t){this.ids[i]||(this.ids[i]=new Set),this.ids[i].add(t)}getData(){const i={};for(const e in this.ids)i[e]=Array.from(this.ids[e]);const t=this.exportRules();return{name:this.name,inclusive:this.inclusive,type:"IfcFinderQuery",ids:i,rules:t}}exportRules(){const i=[];for(const t of this.rules){const e={};for(const s in t){const n=t[s];n instanceof RegExp?e[s]={regexp:!0,value:n.source}:e[s]=n}i.push(e)}return i}findInFile(i,t){return new Promise(e=>{const s=new FileReader,n=new TextDecoder("utf-8"),r=1e4*1024,o=1e3;let a=0;const l=/;/,h=()=>{if(a>=t.size){e();return}const f=Math.min(a+r+o,t.size),I=t.slice(a,f);s.readAsArrayBuffer(I)};s.onload=()=>{if(!(s.result instanceof ArrayBuffer))return;const f=new Uint8Array(s.result),u=n.decode(f).split(l);u.shift(),this.findInLines(i,u),this.onProgress.trigger(a/t.size),a+=r,h()},h()})}getIdFromLine(i){const t=i.slice(i.indexOf("#")+1,i.indexOf("="));return parseInt(t,10)}testRules(i){let t=null,e=null,s=null,n=!1;for(const r of this.rules){if(r.type==="category"){if(t===null&&(t=this.getCategoryFromLine(i),t===null)){if(this.inclusive)continue;break}if(!r.value.test(t)){if(this.inclusive)continue;n=!1;break}n=!0;continue}if(e===null&&(e=this.getAttributesFromLine(i),e===null)){if(this.inclusive)continue;n=!1;break}if(t===null&&(t=this.getCategoryFromLine(i),t===null)){if(this.inclusive)continue;n=!1;break}if(s===null&&(s=Object.keys(new k.IFC4[t]),s=s.slice(2),s===null)){if(this.inclusive)continue;n=!1;break}if(r.type==="property"){const{name:o,value:a}=r;if(!a.test(i)){if(this.inclusive)continue;n=!1;break}let l=!1;for(let h=0;h<e.length;h++){const f=e[h],I=s[h];if(a.test(f)&&o.test(I)){l=!0;break}}if(l)n=!0;else if(!this.inclusive){n=!1;break}}if(r.type==="operator"){const{name:o,value:a,operator:l}=r;let h=!1;for(let f=0;f<e.length;f++){const I=s[f],u=e[f].replace(/IFCLENGTHMEASURE\(|IFCVOLUMEMEASURE\(|\)/g,"");if(o.test(I)){if(l==="="&&parseFloat(u)===a){h=!0;break}else if(l==="<"&&parseFloat(u)<a){h=!0;break}else if(l===">"&&parseFloat(u)>a){h=!0;break}else if(l===">="&&parseFloat(u)>=a){h=!0;break}else if(l==="<="&&parseFloat(u)<=a){h=!0;break}}}if(h)n=!0;else if(!this.inclusive){n=!1;break}}}return n}getCategoryFromLine(i){const t=i.indexOf("=")+1,e=i.indexOf("("),s=i.slice(t,e).trim(),n=ao[s];return n||null}getAttributesFromLine(i){const t=/\((.*)\)/,e=i.match(t);if(!(e&&e[1]))return null;const s=/,(?![^()]*\))/g;return e[1].split(s).map(r=>r.trim())}};C(ys,"importers",new Map);let qt=ys;class br{constructor(i){C(this,"list",new Map);C(this,"id",b.MathUtils.generateUUID());C(this,"mode","intersect");C(this,"_components");this._components=i}get queries(){return new Set(this.list.values())}get items(){const i=[];for(const t of this.queries)i.push(t.items);return this.mode==="combine"?jt.FragmentUtils.combine(i):jt.FragmentUtils.intersect(i)}add(i){if(this.list.has(i.name))throw new Error(`This group already has a query with the name ${i.name}.`);this.list.set(i.name,i)}clear(i){for(const t of this.queries)t.clear(i)}import(i){this.mode=i.mode,this.id=i.id;for(const t in i.queries){const e=qt.import(this._components,i.queries[t]);e&&this.list.set(t,e)}}export(){const i={};for(const[t,e]of this.list)i[t]=e.export();return{mode:this.mode,id:this.id,queries:i}}async update(i,t){for(const e of this.queries){const s=e.needsUpdate.get(i);(s===void 0||s)&&await e.update(i,t)}}}const Ls=class Ls extends qt{constructor(t,e){super(t);C(this,"name");this.name=e.name,this.rules=e.rules,this.inclusive=e.inclusive}get items(){const t=this.components.get(pt),e=[];for(const s in this.ids){const n=this.ids[s],r=t.groups.get(s);if(!r){console.warn(`Model ${s} not found!`);continue}const o=r.getFragmentMap(n);e.push(o)}return jt.FragmentUtils.combine(e)}export(){const t=this.getData();return t.type=Ls.type,t}async update(t,e){this.ids[t]=new Set,await this.findInFile(t,e),this.needsUpdate.set(t,!1)}findInLines(t,e){for(const s of e)if(this.testRules(s)){const r=this.getIdFromLine(s);this.addID(t,r)}}};C(Ls,"type","IfcBasicQuery");let wi=Ls;qt.importers.set(wi.type,(c,i)=>{const t=new wi(c,{name:i.name,rules:qt.importRules(i.rules),inclusive:i.inclusive});return t.ids=qt.importIds(i),t});const Ps=class Ps extends qt{constructor(t,e){super(t);C(this,"name");C(this,"psets",[]);this.name=e.name,this.rules=e.rules,this.inclusive=e.inclusive}get items(){const t=this.components.get(Bt),e=this.components.get(pt),s=[];for(const n in this.ids){const r=e.groups.get(n);if(!r){console.log(`Model not found: ${n}.`);continue}const o=this.ids[n];for(const a of o){const l=t.getEntityRelations(n,a,"DefinesOcurrence");if(l){const h=r.getFragmentMap(l);s.push(h)}}}return jt.FragmentUtils.combine(s)}export(){const t=this.getData();return t.type=Ps.type,t}async update(t,e){await this.findInFile(t,e);const s=new Set;for(const n of this.psets){const r=this.getAttributesFromLine(n);if(r===null)continue;const o=r[4].replace("(","[").replace(")","]").replace(/#/g,""),a=JSON.parse(o);for(const l of a){const h=this.ids[t];if(h&&h.has(l)){const f=this.getIdFromLine(n);s.add(f);break}}}this.ids[t]=s,this.psets=[],this.needsUpdate.set(t,!1)}findInLines(t,e){for(const s of e){const n=this.getCategoryFromLine(s);if(n==="IfcPropertySet"){this.psets.push(s);continue}if(n!=="IfcPropertySingleValue")continue;if(this.testRules(s)){const o=this.getIdFromLine(s);this.addID(t,o)}}}};C(Ps,"type","IfcPropertyQuery");let Di=Ps;qt.importers.set(Di.type,(c,i)=>{const t=new Di(c,{name:i.name,inclusive:i.inclusive,rules:qt.importRules(i.rules)});return t.ids=qt.importIds(i),t});const _s=class _s extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",new Map);t.add(_s.uuid,this)}get queries(){const t=new Set;for(const[,e]of this.list)for(const s of e.queries)t.add(s);return t}import(t){for(const e in t){const s=new br(this.components);s.import(t[e]),this.list.set(e,s)}}export(){const t={};for(const[e,s]of this.list)t[e]=s.export();return t}create(){const t=new br(this.components);return this.list.set(t.id,t),t}delete(t){this.list.delete(t)}clear(){this.list.clear()}};C(_s,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let yn=_s;const Ms=class Ms extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",{});C(this,"onDisposed",new q);C(this,"onFragmentsDisposed",t=>{const{groupID:e,fragmentIDs:s}=t;for(const n in this.list){const r=this.list[n],o=Object.keys(r);if(o.includes(e))delete r[e],Object.values(r).length===0&&delete this.list[n];else for(const a of o){const l=r[a];for(const h of s)delete l.map[h];Object.values(l).length===0&&delete r[a]}}});t.add(Ms.uuid,this),t.get(pt).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.list={},this.components.get(pt).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(t){for(const e in this.list){const s=this.list[e];for(const n in s){const r=s[n];delete r.map[t]}}}find(t){const e=this.components.get(pt);if(!t){const o={};for(const[a,l]of e.list)o[a]=new Set(l.ids);return o}const s=Object.keys(t).length,n={};for(const o in t){const a=t[o];if(!this.list[o]){console.warn(`Classification ${o} does not exist.`);continue}for(const l of a){const h=this.list[o][l];if(h)for(const f in h.map){n[f]||(n[f]=new Map);for(const I of h.map[f]){const u=n[f].get(I);u===void 0?n[f].set(I,1):n[f].set(I,u+1)}}}}const r={};for(const o in n){const a=n[o];for(const[l,h]of a){if(h===void 0)throw new Error("Malformed fragments map!");h===s&&(r[o]||(r[o]=new Set),r[o].add(l))}}return r}byModel(t,e){this.list.models||(this.list.models={});const s=this.list.models;s[t]||(s[t]={map:{},id:null,name:t});const n=s[t];for(const[r,o]of e.data){const a=o[0];for(const l of a){const h=e.keyFragments.get(l);h&&(n.map[h]||(n.map[h]=new Set),n.map[h].add(r))}}}async byPredefinedType(t){var n;this.list.predefinedTypes||(this.list.predefinedTypes={});const e=this.list.predefinedTypes,s=t.getAllPropertiesIDs();for(const r of s){const o=await t.getProperties(r);if(!o)continue;const a=String((n=o.PredefinedType)==null?void 0:n.value).toUpperCase();e[a]||(e[a]={map:{},id:null,name:a});const l=e[a];for(const[h,f]of t.data){const I=f[0];for(const u of I){const d=t.keyFragments.get(u);if(!d)throw new Error("Fragment ID not found!");l.map[d]||(l.map[d]=new Set),l.map[d].add(o.expressID)}}}}byEntity(t){this.list.entities||(this.list.entities={});for(const[e,s]of t.data){const r=s[1][1],o=_i[r];this.saveItem(t,"entities",o,e)}}async byIfcRel(t,e,s){be.isRel(e)&&await be.getRelationMap(t,e,async(n,r)=>{const{name:o}=await be.getEntityName(t,n);for(const a of r)this.saveItem(t,s,o??"NO REL NAME",a)})}async bySpatialStructure(t,e={}){var l,h;const s=this.components.get(Bt),n=s.relationMaps[t.uuid];if(!n)throw new Error(`Classifier: model relations of ${t.name||t.uuid} have to exists to group by spatial structure.`);const r="spatialStructures",a=e.useProperties===void 0||e.useProperties;for(const[f]of n){if(e.isolate){const E=t.data.get(f);if(!E)continue;const T=E[1][1];if(T===void 0||!e.isolate.has(T))continue}const I=s.getEntityRelations(t,f,"Decomposes");if(I)for(const E of I){let T=E.toString();if(a){const p=await t.getProperties(E);if(!p)continue;T=(l=p.Name)==null?void 0:l.value}this.saveItem(t,r,T,f,E)}const u=s.getEntityRelations(t,f,"ContainsElements");if(!u)continue;let d=f.toString();if(a){const E=await t.getProperties(f);if(!E)continue;d=(h=E.Name)==null?void 0:h.value}for(const E of u){this.saveItem(t,r,d,E,f);const T=s.getEntityRelations(t,Number(E),"IsDecomposedBy");if(T)for(const p of T)this.saveItem(t,r,d,p,f)}}}setColor(t,e,s=!1){const n=this.components.get(pt);for(const r in t){const o=n.list.get(r);if(!o)continue;const a=t[r];o.setColor(e,a,s)}}resetColor(t){const e=this.components.get(pt);for(const s in t){const n=e.list.get(s);if(!n)continue;const r=t[s];n.resetColor(r)}}saveItem(t,e,s,n,r=null){this.list[e]||(this.list[e]={});const o=t.data.get(n);if(o)for(const a of o[0]){const l=t.keyFragments.get(a);if(l){const h=this.list[e];h[s]||(h[s]={map:{},id:r,name:s}),h[s].map[l]||(h[s].map[l]=new Set),h[s].map[l].add(n)}}}};C(Ms,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let ti=Ms;const ws=class ws extends mt{constructor(t){super(t);C(this,"onDisposed",new q);C(this,"enabled",!0);C(this,"height",10);C(this,"groupName","spatialStructures");C(this,"list",new Set);t.add(ws.uuid,this)}dispose(){this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}set(t){if(!this.enabled)return;const e=this.components.get(ti),s=this.components.get(pt),n=t?1:-1;let r=0;const o=e.list[this.groupName],a=new b.Matrix4;for(const l in o){a.elements[13]=r*n*this.height;for(const h in o[l].map){const f=s.list.get(h),I=l+h,u=this.list.has(I);if(!f||t&&u||!t&&!u)continue;t?this.list.add(I):this.list.delete(I);const d=o[l].map[h];f.applyTransform(d,a),f.mesh.computeBoundingSphere(),f.mesh.computeBoundingBox()}r++}}};C(ws,"uuid","d260618b-ce88-4c7d-826c-6debb91de3e2");let Ln=ws;const Ds=class Ds extends mt{constructor(t){super(t);C(this,"enabled",!0);this.components.add(Ds.uuid,this)}set(t,e){const s=this.components.get(pt);if(!e){for(const[n,r]of s.list)r&&(r.setVisibility(t),this.updateCulledVisibility(r));return}for(const n in e){const r=e[n],o=s.list.get(n);o&&(o.setVisibility(t,r),this.updateCulledVisibility(o))}}isolate(t){this.set(!1),this.set(!0,t)}updateCulledVisibility(t){const e=this.components.get(fs);for(const[s,n]of e.list){const r=n.colorMeshes.get(t.id);r&&(r.count=t.mesh.count)}}};C(Ds,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let ms=Ds;class Oo extends zs{constructor(){super(...arguments);C(this,"minGeometrySize",10);C(this,"minAssetsSize",1e3);C(this,"maxTriangles",null)}}const bs=class bs extends mt{constructor(t){super(t);C(this,"onGeometryStreamed",new fe);C(this,"onAssetStreamed",new fe);C(this,"onProgress",new fe);C(this,"onIfcLoaded",new fe);C(this,"onDisposed",new q);C(this,"settings",new Oo);C(this,"enabled",!0);C(this,"webIfc",new k.IfcAPI);C(this,"_nextAvailableID",0);C(this,"_splittedGeometries",new Map);C(this,"_spatialTree",new co);C(this,"_metaData",new ho);C(this,"_visitedGeometries",new Map);C(this,"_streamSerializer",new jt.StreamSerializer);C(this,"_geometries",new Map);C(this,"_geometryCount",0);C(this,"_civil",new lo);C(this,"_groupSerializer",new jt.Serializer);C(this,"_assets",[]);C(this,"_meshesWithHoles",new Set);this.components.add(bs.uuid,this),this.settings.excludedCategories.add(k.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModel(t,this.settings.webIfc),this._nextAvailableID=this.webIfc.GetMaxExpressID(0)}async streamIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllGeometries(){const{minGeometrySize:t,minAssetsSize:e}=this.settings;this._spatialTree.setUp(this.webIfc);const s=this.webIfc.GetIfcEntityList(0),n=[[]],r=new jt.FragmentsGroup;r.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let o=0,a=0;for(const E of s){if(!this.webIfc.IsIfcElement(E)&&E!==k.IFCSPACE||this.settings.excludedCategories.has(E))continue;const T=this.webIfc.GetLineIDsWithType(0,E),p=T.size();for(let m=0;m<p;m++){o>t&&(o=0,a++,n.push([]));const F=T.get(m);n[a].push(F);const R=this.webIfc.GetLine(0,F);if(R.GlobalId){const N=(R==null?void 0:R.GlobalId.value)||(R==null?void 0:R.GlobalId);r.globalToExpressIDs.set(N,F)}const S=this._spatialTree.itemsByFloor[F]||0;r.data.set(F,[[],[S,E]]),o++}}this._spatialTree.cleanUp();let l=.01,h=0;for(const E of n){h++,this.webIfc.StreamMeshes(0,E,p=>{this.getMesh(this.webIfc,p,r)}),this._geometryCount>this.settings.minGeometrySize&&await this.streamGeometries(),this._assets.length>e&&await this.streamAssets();const T=h/n.length;T>l&&(l+=.01,l=Math.max(l,T),await this.onProgress.trigger(Math.round(l*100)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:f,transparent:I}=r.geometryIDs;for(const[E,{index:T,uuid:p}]of this._visitedGeometries)r.keyFragments.set(T,p),(E>1?f:I).set(E,T);uo.get(r,this.webIfc);const u=this.webIfc.GetCoordinationMatrix(0);r.coordinationMatrix.fromArray(u),r.civilData=this._civil.read(this.webIfc);const d=this._groupSerializer.export(r);await this.onIfcLoaded.trigger(d),r.dispose(!0)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new k.IfcAPI,this._visitedGeometries.clear(),this._geometries.clear(),this._assets=[],this._meshesWithHoles.clear()}getMesh(t,e,s){const n=e.geometries.size(),r=e.expressID,o={id:r,geometries:[]};for(let a=0;a<n;a++){const l=e.geometries.get(a),h=l.geometryExpressID,I=l.color.w===1?1:-1,u=h*I;this._visitedGeometries.has(u)||this.getGeometry(t,h,u),this.registerGeometryData(s,r,l,o,h,u);const d=this._splittedGeometries.get(h);if(d)for(const E of d)this.registerGeometryData(s,r,l,o,E,E)}this._assets.push(o)}getGeometry(t,e,s){const n=t.GetGeometry(0,e),r=t.GetIndexArray(n.GetIndexData(),n.GetIndexDataSize()),o=t.GetVertexArray(n.GetVertexData(),n.GetVertexDataSize()),a=new Float32Array(o.length/2),l=new Float32Array(o.length/2);for(let u=0;u<o.length;u+=6)a[u/2]=o[u],a[u/2+1]=o[u+1],a[u/2+2]=o[u+2],l[u/2]=o[u+3],l[u/2+1]=o[u+4],l[u/2+2]=o[u+5];if(r.length===0){const u=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]);this._geometries.set(e,{position:a,normal:l,index:r,boundingBox:u,hasHoles:!1});const d=this._visitedGeometries.size,E=b.MathUtils.generateUUID();this._visitedGeometries.set(s,{uuid:E,index:d}),this._geometryCount++,n.delete();return}const f=(this.settings.maxTriangles||r.length/3)*3;let I=!0;for(let u=0;u<r.length;u+=f){const d=r.length-u,E=Math.min(d,f),T=u+E,p=[],m=[],F=[];let R=0;for(let g=u;g<T;g++){p.push(R++);const U=r[g];m.push(a[U*3]),m.push(a[U*3+1]),m.push(a[U*3+2]),F.push(l[U*3]),F.push(l[U*3+1]),F.push(l[U*3+2])}const S=new Uint32Array(p),N=new Float32Array(m),L=new Float32Array(F),D=kr(N),P=new Float32Array(D.transformation.elements),v=!1,G=I?e:this._nextAvailableID++;this._geometries.set(G,{position:N,normal:L,index:S,boundingBox:P,hasHoles:v}),I||(this._splittedGeometries.has(e)||this._splittedGeometries.set(e,new Set),this._splittedGeometries.get(e).add(G));const O=this._visitedGeometries.size,w=b.MathUtils.generateUUID();this._visitedGeometries.set(s,{uuid:w,index:O}),this._geometryCount++,I=!1}n.delete()}async streamAssets(){await this.onAssetStreamed.trigger(this._assets),this._assets=null,this._assets=[]}async streamGeometries(){let t=this._streamSerializer.export(this._geometries),e={};for(const[s,{boundingBox:n,hasHoles:r}]of this._geometries)e[s]={boundingBox:n,hasHoles:r};await this.onGeometryStreamed.trigger({data:e,buffer:t}),e=null,t=null,this._geometries.clear(),this._geometryCount=0}registerGeometryData(t,e,s,n,r,o){const a=this._visitedGeometries.get(o);if(a===void 0)throw new Error("Error getting geometry data for streaming!");const l=t.data.get(e);if(!l)throw new Error("Data not found!");l[0].push(a.index);const{x:h,y:f,z:I,w:u}=s.color,d=[h,f,I,u],E=s.flatTransformation;n.geometries.push({color:d,geometryID:r,transformation:E})}};C(bs,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let Pn=bs;class No extends zs{constructor(){super(...arguments);C(this,"propertiesSize",100)}}class yo extends mt{constructor(){super(...arguments);C(this,"onPropertiesStreamed",new fe);C(this,"onProgress",new fe);C(this,"onIndicesStreamed",new fe);C(this,"onDisposed",new q);C(this,"enabled",!0);C(this,"settings",new No);C(this,"webIfc",new k.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllProperties(){const{propertiesSize:t}=this.settings,e=new Set(this.webIfc.GetIfcEntityList(0)),s=new Set([k.IFCPROJECT,k.IFCSITE,k.IFCBUILDING,k.IFCBUILDINGSTOREY,k.IFCSPACE]);for(const l of s)e.add(l);let n=.01,r=0;for(const l of e){if(r++,Vn.has(l))continue;const h=s.has(l),f=this.webIfc.GetLineIDsWithType(0,l),I=f.size();let u=0;for(let E=0;E<I-t;E+=t){const T={};for(let p=0;p<t;p++){u++;const m=f.get(E+p);try{const F=this.webIfc.GetLine(0,m,h);T[F.expressID]=F}catch{console.log(`Could not get property: ${m}`)}}await this.onPropertiesStreamed.trigger({type:l,data:T})}if(u!==I){const E={};for(let T=u;T<I;T++){const p=f.get(T);try{const m=this.webIfc.GetLine(0,p,h);E[m.expressID]=m}catch{console.log(`Could not get property: ${p}`)}}await this.onPropertiesStreamed.trigger({type:l,data:E})}r/e.size>n&&(n=Math.round(n*100)/100,await this.onProgress.trigger(n),n+=.01)}await this.onProgress.trigger(1);const a=await this.components.get(Bt).processFromWebIfc(this.webIfc,0);await this.onIndicesStreamed.trigger(a)}cleanUp(){this.webIfc.Dispose(),this.webIfc=null,this.webIfc=new k.IfcAPI}}C(yo,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");class kn{constructor(i,t,e){C(this,"title");C(this,"guid",Kt.create());C(this,"clippingPlanes",new Ie);C(this,"camera",{aspectRatio:0,fov:0,direction:{x:0,y:0,z:80},position:{x:0,y:0,z:0}});C(this,"exceptionComponents",new Ie);C(this,"selectionComponents",new Ie);C(this,"componentColors",new Qt);C(this,"spacesVisible",!1);C(this,"spaceBoundariesVisible",!1);C(this,"openingsVisible",!1);C(this,"defaultVisibility",!0);C(this,"_components");C(this,"world");const s={setCamera:!0,...e},{data:n,setCamera:r}=s;this._components=i,this.world=t,n&&(this.guid=n.guid??this.guid,this.set(n)),r&&this.updateCamera()}get _selectionModelIdMap(){const i=this._components.get(pt),t={};for(const[e,s]of i.groups){e in t||(t[e]=new Set);for(const n of this.selectionComponents){const r=s.globalToExpressIDs.get(n);r&&t[e].add(r)}}return t}get _exceptionModelIdMap(){const i=this._components.get(pt),t={};for(const[e,s]of i.groups){e in t||(t[e]=new Set);for(const n of this.exceptionComponents){const r=s.globalToExpressIDs.get(n);r&&t[e].add(r)}}return t}get selection(){return this._components.get(pt).modelIdToFragmentIdMap(this._selectionModelIdMap)}get exception(){return this._components.get(pt).modelIdToFragmentIdMap(this._exceptionModelIdMap)}get projection(){return"fov"in this.camera?"Perspective":"Orthographic"}get position(){const i=this._components.get(pt),{position:t}=this.camera,{x:e,y:s,z:n}=t,r=new b.Vector3(e,s,n);return i.applyBaseCoordinateSystem(r,new b.Matrix4),r}get direction(){const{direction:i}=this.camera,{x:t,y:e,z:s}=i;return new b.Vector3(t,e,s)}get _managerVersion(){return this._components.get(Mt).config.version}get topics(){return[...this._components.get(Mt).list.values()].filter(s=>s.viewpoints.has(this.guid))}addComponentsFromMap(i){const e=this._components.get(pt).fragmentIdMapToGuids(i);this.selectionComponents.add(...e),this._components.get(Zt).list.set(this.guid,this)}set(i){const t=i,e=this;for(const n in i){if(n==="guid")continue;const r=t[n];if(n==="selectionComponents"){this.selectionComponents.clear(),this.selectionComponents.add(...r);continue}if(n==="exceptionComponents"){this.exceptionComponents.clear(),this.exceptionComponents.add(...r);continue}n in this&&(e[n]=r)}return this._components.get(Zt).list.set(this.guid,this),this}async go(i=!0){const{camera:t}=this.world;if(!t.hasCameraControls())throw new Error("Viewpoint: the world's camera need controls to set the viewpoint.");t instanceof ro&&t.projection.set(this.projection);const e=this.position,s=this.direction;let n={x:e.x+s.x*80,y:e.y+s.y*80,z:e.z+s.z*80};const r=this.selection;if(Object.keys(r).length===0){const h=this._components.get(ve).get(this.world).castRayFromVector(e,this.direction);h&&(n=h.point)}else{const a=this._components.get(Ts);a.reset(),a.addFragmentIdMap(r),n=a.getSphere().center,a.reset()}const o=this._components.get(ms);o.set(this.defaultVisibility),o.set(!this.defaultVisibility,this.exception),o.set(!0,r),await t.controls.setLookAt(e.x,e.y,e.z,n.x,n.y,n.z,i)}updateCamera(){const{camera:i,renderer:t}=this.world;if(!t)throw new Error("Viewpoint: the world needs to have a renderer!");if(!i.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const e=new b.Vector3;i.controls.getPosition(e);const s=i.three,n=new b.Vector3(0,0,-1).applyEuler(s.rotation),{width:r,height:o}=t.getSize();let a=r/o;Number.isNaN(a)&&(a=1);const l=this._components.get(pt);e.applyMatrix4(l.baseCoordinationMatrix.clone().invert());const h={aspectRatio:a,position:{x:e.x,y:e.y,z:e.z},direction:{x:n.x,y:n.y,z:n.z}};s instanceof b.PerspectiveCamera?this.camera={...h,fov:s.fov}:s instanceof b.OrthographicCamera&&(this.camera={...h,viewToWorldScale:s.top-s.bottom}),this._components.get(Zt).list.set(this.guid,this)}colorize(){const i=this._components.get(Zt),t=this._components.get(pt),e=this._components.get(ti);for(const[s,n]of this.componentColors){const r=t.guidToFragmentIdMap(n),o=new b.Color(`#${s}`);e.setColor(r,o,i.config.overwriteColors)}}resetColors(){const i=this._components.get(pt),t=this._components.get(ti);for(const[e,s]of this.componentColors){const n=i.guidToFragmentIdMap(s);t.resetColor(n)}}async createComponentTags(i){var n,r;const t=this._components.get(pt),e=this._components.get(Mt);let s="";if(e.config.includeSelectionTag){const o=i==="selection"?this._selectionModelIdMap:this._exceptionModelIdMap;for(const a in o){const l=t.groups.get(a);if(!l)continue;const h=o[a];for(const f of h){const I=await l.getProperties(f);if(!I)continue;const u=(n=I.GlobalId)==null?void 0:n.value;if(!u)continue;const d=(r=I.Tag)==null?void 0:r.value;let E=null;d&&(E=`AuthoringToolId="${d}"`),s+=`
|
|
226
|
+
`}processMarkupComment(t){const{Guid:e,Date:s,Author:n,Comment:r,Viewpoint:o}=t;if(!(e&&s&&n&&(Cs||o)))return null;const a=this.components.get(Zt),l=new Cs(this.components,r??"");return l.guid=e,l.date=new Date(s),l.author=n,l.viewpoint=o!=null&&o.Guid?a.list.get(o.Guid):void 0,l.modifiedAuthor=t.ModifiedAuthor,l.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,l}getMarkupComments(t,e){var o;let s;if(e==="2.1"&&(s=t.Comment),e==="3"&&(s=(o=t.Topic.Comments)==null?void 0:o.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(t,e){var r;let s;return e==="2.1"&&(s=t.Topic.Labels),e==="3"&&(s=(r=t.Topic.Labels)==null?void 0:r.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(t,e){var n;let s;return e==="2.1"&&(s=t.Viewpoints),e==="3"&&(s=(n=t.Topic.Viewpoints)==null?void 0:n.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,e){var r;let s;return e==="2.1"&&(s=t.Topic.RelatedTopic),e==="3"&&(s=(r=t.Topic.RelatedTopics)==null?void 0:r.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(o=>o.Guid):[]}async load(t,e){var m;const{fallbackVersionOnImport:s,ignoreIncompleteTopicsOnImport:n,updateExtensionsOnImport:r}=this.config,o=new Lr;await o.loadAsync(t);const a=Object.values(o.files);let l=s;const h=a.find(F=>F.name.endsWith(".version"));if(h){const F=await h.async("string"),R=Fe.xmlParser.parse(F).Version.VersionId;l=String(R)}if(!(l&&(l==="2.1"||l==="3")))throw new Error(`BCFTopics: ${l} is not supported.`);const f=a.find(F=>F.name.endsWith(".extensions"));if(r&&f){const F=await f.async("string");Fo(this,F)}const I=[],u=this.components.get(Zt),d=a.filter(F=>F.name.endsWith(".bcfv"));for(const F of d){const R=await F.async("string"),S=Fe.xmlParser.parse(R).VisualizationInfo;if(!S){console.warn("Missing VisualizationInfo in Viewpoint");continue}const N={},{Guid:L,ClippingPlanes:D,Components:P,OrthogonalCamera:v,PerspectiveCamera:G}=S;if(L&&(N.guid=L),P){const{Selection:w,Visibility:g}=P;if(w&&w.Component){const Q=Array.isArray(w.Component)?w.Component:[w.Component];N.selectionComponents=Q.map(z=>z.IfcGuid).filter(z=>z)}if(g&&"DefaultVisibility"in g&&(N.defaultVisibility=g.DefaultVisibility),g&&g.Exceptions&&"Component"in g.Exceptions){const{Component:Q}=g.Exceptions,z=Array.isArray(Q)?Q:[Q];N.exceptionComponents=z.map(et=>et.IfcGuid).filter(et=>et)}let U;l==="2.1"&&(U=P.ViewSetupHints),l==="3"&&(U=(m=P.Visibility)==null?void 0:m.ViewSetupHints),U&&("OpeningsVisible"in U&&(N.openingsVisible=U.OpeningsVisible),"SpacesVisible"in U&&(N.spacesVisible=U.SpacesVisible),"SpaceBoundariesVisible"in U&&(N.spaceBoundariesVisible=U.SpaceBoundariesVisible))}if(v||G){const w=S.PerspectiveCamera??S.OrthogonalCamera,{CameraViewPoint:g,CameraDirection:U}=w,Q=new b.Vector3(Number(g.X),Number(g.Z),Number(-g.Y)),z=new b.Vector3(Number(U.X),Number(U.Z),Number(-U.Y)),et={position:{x:Q.x,y:Q.y,z:Q.z},direction:{x:z.x,y:z.y,z:z.z},aspectRatio:"AspectRatio"in w?w.AspectRatio:1};"ViewToWorldScale"in w&&(N.camera={...et,viewToWorldScale:w.ViewToWorldScale}),"FieldOfView"in w&&(N.camera={...et,fov:w.FieldOfView})}const O=new kn(this.components,e,{data:N,setCamera:!1});if(P){const{Coloring:w}=P;if(w&&w.Color){const g=Array.isArray(w.Color)?w.Color:[w.Color];for(const U of g){const{Color:Q,Component:z}=U,X=(Array.isArray(z)?z:[z]).map(nt=>nt.IfcGuid);O.componentColors.set(Q,X)}}}if(I.push(O),D){const w=this.components.get(Is),g=Array.isArray(D.ClippingPlane)?D.ClippingPlane:[D.ClippingPlane];for(const U of g){const{Location:Q,Direction:z}=U;if(!(Q&&z))continue;const et=new b.Vector3(Q.X,Q.Z,-Q.Y),X=new b.Vector3(z.X,-z.Z,z.Y),nt=w.createFromNormalAndCoplanarPoint(e,X,et);nt.visible=!1,nt.enabled=!1,O.clippingPlanes.add(nt)}}}const E={},T=[],p=a.filter(F=>F.name.endsWith(".bcf"));for(const F of p){const R=await F.async("string"),S=Fe.xmlParser.parse(R).Markup,N=S.Topic,{Guid:L,TopicType:D,TopicStatus:P,Title:v,CreationDate:G,CreationAuthor:O}=N;if(n&&!(L&&D&&P&&v&&G&&O))continue;const w=new Mi(this.components);w.guid=L??w.guid;const g=this.getMarkupRelatedTopics(S,l);E[w.guid]=new Set(g),w.type=D??w.type,w.status=P??w.status,w.title=v??w.title,w.creationDate=G?new Date(G):w.creationDate,w.creationAuthor=O??w.creationAuthor,w.serverAssignedId=N.ServerAssignedId,w.priority=N.Priority,w.index=N.Index,w.modifiedDate=N.ModifiedDate?new Date(N.ModifiedDate):void 0,w.modifiedAuthor=N.ModifiedAuthor,w.dueDate=N.DueDate?new Date(N.DueDate):void 0,w.assignedTo=N.AssignedTo,w.description=N.Description,w.stage=N.Stage;const U=this.getMarkupLabels(S,l);for(const et of U)w.labels.add(et);const Q=this.getMarkupComments(S,l);for(const et of Q)w.comments.set(et.guid,et);const z=this.getMarkupViewpoints(S,l);for(const et of z){if(!(et&&et.Guid))continue;const X=u.list.get(et.Guid);X&&w.viewpoints.add(X.guid)}this.list.set(w.guid,w),T.push(w)}for(const F in E){const R=this.list.get(F);if(!R)continue;const S=E[F];for(const N of S)R.relatedTopics.add(N)}return this.onBCFImported.trigger(T),{viewpoints:I,topics:T}}};C(Fe,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),C(Fe,"xmlParser",new Ao.XMLParser({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let Mt=Fe;const ie=class ie extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"onDisposed",new q);C(this,"_absoluteMin");C(this,"_absoluteMax");C(this,"_meshes",[]);this.components.add(ie.uuid,this),this._absoluteMin=ie.newBound(!0),this._absoluteMax=ie.newBound(!1)}static getDimensions(t){const{min:e,max:s}=t,n=Math.abs(s.x-e.x),r=Math.abs(s.y-e.y),o=Math.abs(s.z-e.z),a=new b.Vector3;return a.subVectors(s,e).divideScalar(2).add(e),{width:n,height:r,depth:o,center:a}}static newBound(t){const e=t?1:-1;return new b.Vector3(e*Number.MAX_VALUE,e*Number.MAX_VALUE,e*Number.MAX_VALUE)}static getBounds(t,e,s){const n=s||this.newBound(!1),r=e||this.newBound(!0);for(const o of t)o.x<r.x&&(r.x=o.x),o.y<r.y&&(r.y=o.y),o.z<r.z&&(r.z=o.z),o.x>n.x&&(n.x=o.x),o.y>n.y&&(n.y=o.y),o.z>n.z&&(n.z=o.z);return new b.Box3(e,s)}dispose(){const t=this.components.get(Ce);for(const e of this._meshes)t.destroy(e);this._meshes=[],this.onDisposed.trigger(ie.uuid),this.onDisposed.reset()}get(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone();return new b.Box3(t,e)}getSphere(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone(),s=Math.abs((e.x-t.x)/2),n=Math.abs((e.y-t.y)/2),r=Math.abs((e.z-t.z)/2),o=new b.Vector3(t.x+s,t.y+n,t.z+r),a=o.distanceTo(t);return new b.Sphere(o,a)}getMesh(){const t=new b.Box3(this._absoluteMin,this._absoluteMax),e=ie.getDimensions(t),{width:s,height:n,depth:r,center:o}=e,a=new b.BoxGeometry(s,n,r),l=new b.Mesh(a);return this._meshes.push(l),l.position.copy(o),l}reset(){this._absoluteMin=ie.newBound(!0),this._absoluteMax=ie.newBound(!1)}add(t){for(const e of t.items)this.addMesh(e.mesh)}addMesh(t,e){if(!t.geometry.index)return;const s=ie.getFragmentBounds(t);t.updateMatrixWorld();const n=t.matrixWorld,r=new b.Matrix4,o=t instanceof b.InstancedMesh,a=new Set;if(t instanceof jt.FragmentMesh){e||(e=t.fragment.ids);for(const l of e){const h=t.fragment.getInstancesIDs(l);if(h)for(const f of h)a.add(f)}}else a.add(0);for(const l of a){const h=s.min.clone(),f=s.max.clone();o&&(t.getMatrixAt(l,r),h.applyMatrix4(r),f.applyMatrix4(r)),h.applyMatrix4(n),f.applyMatrix4(n),h.x<this._absoluteMin.x&&(this._absoluteMin.x=h.x),h.y<this._absoluteMin.y&&(this._absoluteMin.y=h.y),h.z<this._absoluteMin.z&&(this._absoluteMin.z=h.z),h.x>this._absoluteMax.x&&(this._absoluteMax.x=h.x),h.y>this._absoluteMax.y&&(this._absoluteMax.y=h.y),h.z>this._absoluteMax.z&&(this._absoluteMax.z=h.z),f.x>this._absoluteMax.x&&(this._absoluteMax.x=f.x),f.y>this._absoluteMax.y&&(this._absoluteMax.y=f.y),f.z>this._absoluteMax.z&&(this._absoluteMax.z=f.z),f.x<this._absoluteMin.x&&(this._absoluteMin.x=f.x),f.y<this._absoluteMin.y&&(this._absoluteMin.y=f.y),f.z<this._absoluteMin.z&&(this._absoluteMin.z=f.z)}}addFragmentIdMap(t){const e=this.components.get(pt);for(const s in t){const n=e.list.get(s);if(!n)continue;const r=t[s];this.addMesh(n.mesh,r)}}static getFragmentBounds(t){const e=t.geometry.attributes.position,s=Number.MAX_VALUE,n=-s,r=new b.Vector3(s,s,s),o=new b.Vector3(n,n,n);if(!t.geometry.index)throw new Error("Geometry must be indexed!");const a=Array.from(t.geometry.index.array);for(let l=0;l<a.length;l++){if(l%3===0&&a[l]===0&&a[l+1]===0&&a[l+2]===0){l+=2;continue}const h=a[l],f=e.getX(h),I=e.getY(h),u=e.getZ(h);f<r.x&&(r.x=f),I<r.y&&(r.y=I),u<r.z&&(r.z=u),f>o.x&&(o.x=f),I>o.y&&(o.y=I),u>o.z&&(o.z=u)}return new b.Box3(r,o)}};C(ie,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Ts=ie;const ys=class ys{constructor(i){C(this,"onProgress",new q);C(this,"inclusive",!1);C(this,"rules",[]);C(this,"ids",{});C(this,"needsUpdate",new Map);C(this,"components");this.components=i}static import(i,t){const e=ys.importers.get(t.type);return e?e(i,t):(console.warn("Invalid query data:.",t),null)}static importRules(i){const t=[];for(const e of i){const s={};for(const n in e){const r=e[n];r.regexp?s[n]=new RegExp(r.value):s[n]=r}t.push(s)}return t}static importIds(i){const t={};for(const e in i.ids)t[e]=new Set(i.ids[e]);return t}clear(i){if(i===void 0){this.ids={},this.needsUpdate.clear();return}delete this.ids[i],this.needsUpdate.delete(i)}addID(i,t){this.ids[i]||(this.ids[i]=new Set),this.ids[i].add(t)}getData(){const i={};for(const e in this.ids)i[e]=Array.from(this.ids[e]);const t=this.exportRules();return{name:this.name,inclusive:this.inclusive,type:"IfcFinderQuery",ids:i,rules:t}}exportRules(){const i=[];for(const t of this.rules){const e={};for(const s in t){const n=t[s];n instanceof RegExp?e[s]={regexp:!0,value:n.source}:e[s]=n}i.push(e)}return i}findInFile(i,t){return new Promise(e=>{const s=new FileReader,n=new TextDecoder("utf-8"),r=1e4*1024,o=1e3;let a=0;const l=/;/,h=()=>{if(a>=t.size){e();return}const f=Math.min(a+r+o,t.size),I=t.slice(a,f);s.readAsArrayBuffer(I)};s.onload=()=>{if(!(s.result instanceof ArrayBuffer))return;const f=new Uint8Array(s.result),u=n.decode(f).split(l);u.shift(),this.findInLines(i,u),this.onProgress.trigger(a/t.size),a+=r,h()},h()})}getIdFromLine(i){const t=i.slice(i.indexOf("#")+1,i.indexOf("="));return parseInt(t,10)}testRules(i){let t=null,e=null,s=null,n=!1;for(const r of this.rules){if(r.type==="category"){if(t===null&&(t=this.getCategoryFromLine(i),t===null)){if(this.inclusive)continue;break}if(!r.value.test(t)){if(this.inclusive)continue;n=!1;break}n=!0;continue}if(e===null&&(e=this.getAttributesFromLine(i),e===null)){if(this.inclusive)continue;n=!1;break}if(t===null&&(t=this.getCategoryFromLine(i),t===null)){if(this.inclusive)continue;n=!1;break}if(s===null&&(s=Object.keys(new k.IFC4[t]),s=s.slice(2),s===null)){if(this.inclusive)continue;n=!1;break}if(r.type==="property"){const{name:o,value:a}=r;if(!a.test(i)){if(this.inclusive)continue;n=!1;break}let l=!1;for(let h=0;h<e.length;h++){const f=e[h],I=s[h];if(a.test(f)&&o.test(I)){l=!0;break}}if(l)n=!0;else if(!this.inclusive){n=!1;break}}if(r.type==="operator"){const{name:o,value:a,operator:l}=r;let h=!1;for(let f=0;f<e.length;f++){const I=s[f],u=e[f].replace(/IFCLENGTHMEASURE\(|IFCVOLUMEMEASURE\(|\)/g,"");if(o.test(I)){if(l==="="&&parseFloat(u)===a){h=!0;break}else if(l==="<"&&parseFloat(u)<a){h=!0;break}else if(l===">"&&parseFloat(u)>a){h=!0;break}else if(l===">="&&parseFloat(u)>=a){h=!0;break}else if(l==="<="&&parseFloat(u)<=a){h=!0;break}}}if(h)n=!0;else if(!this.inclusive){n=!1;break}}}return n}getCategoryFromLine(i){const t=i.indexOf("=")+1,e=i.indexOf("("),s=i.slice(t,e).trim(),n=ao[s];return n||null}getAttributesFromLine(i){const t=/\((.*)\)/,e=i.match(t);if(!(e&&e[1]))return null;const s=/,(?![^()]*\))/g;return e[1].split(s).map(r=>r.trim())}};C(ys,"importers",new Map);let qt=ys;class br{constructor(i){C(this,"list",new Map);C(this,"id",b.MathUtils.generateUUID());C(this,"mode","intersect");C(this,"_components");this._components=i}get queries(){return new Set(this.list.values())}get items(){const i=[];for(const t of this.queries)i.push(t.items);return this.mode==="combine"?jt.FragmentUtils.combine(i):jt.FragmentUtils.intersect(i)}add(i){if(this.list.has(i.name))throw new Error(`This group already has a query with the name ${i.name}.`);this.list.set(i.name,i)}clear(i){for(const t of this.queries)t.clear(i)}import(i){this.mode=i.mode,this.id=i.id;for(const t in i.queries){const e=qt.import(this._components,i.queries[t]);e&&this.list.set(t,e)}}export(){const i={};for(const[t,e]of this.list)i[t]=e.export();return{mode:this.mode,id:this.id,queries:i}}async update(i,t){for(const e of this.queries){const s=e.needsUpdate.get(i);(s===void 0||s)&&await e.update(i,t)}}}const Ls=class Ls extends qt{constructor(t,e){super(t);C(this,"name");this.name=e.name,this.rules=e.rules,this.inclusive=e.inclusive}get items(){const t=this.components.get(pt),e=[];for(const s in this.ids){const n=this.ids[s],r=t.groups.get(s);if(!r){console.warn(`Model ${s} not found!`);continue}const o=r.getFragmentMap(n);e.push(o)}return jt.FragmentUtils.combine(e)}export(){const t=this.getData();return t.type=Ls.type,t}async update(t,e){this.ids[t]=new Set,await this.findInFile(t,e),this.needsUpdate.set(t,!1)}findInLines(t,e){for(const s of e)if(this.testRules(s)){const r=this.getIdFromLine(s);this.addID(t,r)}}};C(Ls,"type","IfcBasicQuery");let wi=Ls;qt.importers.set(wi.type,(c,i)=>{const t=new wi(c,{name:i.name,rules:qt.importRules(i.rules),inclusive:i.inclusive});return t.ids=qt.importIds(i),t});const Ps=class Ps extends qt{constructor(t,e){super(t);C(this,"name");C(this,"psets",[]);this.name=e.name,this.rules=e.rules,this.inclusive=e.inclusive}get items(){const t=this.components.get(Bt),e=this.components.get(pt),s=[];for(const n in this.ids){const r=e.groups.get(n);if(!r){console.log(`Model not found: ${n}.`);continue}const o=this.ids[n];for(const a of o){const l=t.getEntityRelations(n,a,"DefinesOcurrence");if(l){const h=r.getFragmentMap(l);s.push(h)}}}return jt.FragmentUtils.combine(s)}export(){const t=this.getData();return t.type=Ps.type,t}async update(t,e){await this.findInFile(t,e);const s=new Set;for(const n of this.psets){const r=this.getAttributesFromLine(n);if(r===null)continue;const o=r[4].replace("(","[").replace(")","]").replace(/#/g,""),a=JSON.parse(o);for(const l of a){const h=this.ids[t];if(h&&h.has(l)){const f=this.getIdFromLine(n);s.add(f);break}}}this.ids[t]=s,this.psets=[],this.needsUpdate.set(t,!1)}findInLines(t,e){for(const s of e){const n=this.getCategoryFromLine(s);if(n==="IfcPropertySet"){this.psets.push(s);continue}if(n!=="IfcPropertySingleValue")continue;if(this.testRules(s)){const o=this.getIdFromLine(s);this.addID(t,o)}}}};C(Ps,"type","IfcPropertyQuery");let Di=Ps;qt.importers.set(Di.type,(c,i)=>{const t=new Di(c,{name:i.name,inclusive:i.inclusive,rules:qt.importRules(i.rules)});return t.ids=qt.importIds(i),t});const _s=class _s extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",new Map);t.add(_s.uuid,this)}get queries(){const t=new Set;for(const[,e]of this.list)for(const s of e.queries)t.add(s);return t}import(t){for(const e in t){const s=new br(this.components);s.import(t[e]),this.list.set(e,s)}}export(){const t={};for(const[e,s]of this.list)t[e]=s.export();return t}create(){const t=new br(this.components);return this.list.set(t.id,t),t}delete(t){this.list.delete(t)}clear(){this.list.clear()}};C(_s,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let yn=_s;const Ms=class Ms extends mt{constructor(t){super(t);C(this,"enabled",!0);C(this,"list",{});C(this,"onDisposed",new q);C(this,"onFragmentsDisposed",t=>{const{groupID:e,fragmentIDs:s}=t;for(const n in this.list){const r=this.list[n],o=Object.keys(r);if(o.includes(e))delete r[e],Object.values(r).length===0&&delete this.list[n];else for(const a of o){const l=r[a];for(const h of s)delete l.map[h];Object.values(l).length===0&&delete r[a]}}});t.add(Ms.uuid,this),t.get(pt).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.list={},this.components.get(pt).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(t){for(const e in this.list){const s=this.list[e];for(const n in s){const r=s[n];delete r.map[t]}}}find(t){const e=this.components.get(pt);if(!t){const o={};for(const[a,l]of e.list)o[a]=new Set(l.ids);return o}const s=Object.keys(t).length,n={};for(const o in t){const a=t[o];if(!this.list[o]){console.warn(`Classification ${o} does not exist.`);continue}for(const l of a){const h=this.list[o][l];if(h)for(const f in h.map){n[f]||(n[f]=new Map);for(const I of h.map[f]){const u=n[f].get(I);u===void 0?n[f].set(I,1):n[f].set(I,u+1)}}}}const r={};for(const o in n){const a=n[o];for(const[l,h]of a){if(h===void 0)throw new Error("Malformed fragments map!");h===s&&(r[o]||(r[o]=new Set),r[o].add(l))}}return r}byModel(t,e){this.list.models||(this.list.models={});const s=this.list.models;s[t]||(s[t]={map:{},id:null,name:t});const n=s[t];for(const[r,o]of e.data){const a=o[0];for(const l of a){const h=e.keyFragments.get(l);h&&(n.map[h]||(n.map[h]=new Set),n.map[h].add(r))}}}async byPredefinedType(t){var n;this.list.predefinedTypes||(this.list.predefinedTypes={});const e=this.list.predefinedTypes,s=t.getAllPropertiesIDs();for(const r of s){const o=await t.getProperties(r);if(!o)continue;const a=String((n=o.PredefinedType)==null?void 0:n.value).toUpperCase();e[a]||(e[a]={map:{},id:null,name:a});const l=e[a];for(const[h,f]of t.data){const I=f[0];for(const u of I){const d=t.keyFragments.get(u);if(!d)throw new Error("Fragment ID not found!");l.map[d]||(l.map[d]=new Set),l.map[d].add(o.expressID)}}}}byEntity(t){this.list.entities||(this.list.entities={});for(const[e,s]of t.data){const r=s[1][1],o=_i[r];this.saveItem(t,"entities",o,e)}}async byIfcRel(t,e,s){be.isRel(e)&&await be.getRelationMap(t,e,async(n,r)=>{const{name:o}=await be.getEntityName(t,n);for(const a of r)this.saveItem(t,s,o??"NO REL NAME",a)})}async bySpatialStructure(t,e={}){var l,h;const s=this.components.get(Bt),n=s.relationMaps[t.uuid];if(!n)throw new Error(`Classifier: model relations of ${t.name||t.uuid} have to exists to group by spatial structure.`);const r="spatialStructures",a=e.useProperties===void 0||e.useProperties;for(const[f]of n){if(e.isolate){const E=t.data.get(f);if(!E)continue;const T=E[1][1];if(T===void 0||!e.isolate.has(T))continue}const I=s.getEntityRelations(t,f,"Decomposes");if(I)for(const E of I){let T=E.toString();if(a){const p=await t.getProperties(E);if(!p)continue;T=(l=p.Name)==null?void 0:l.value}this.saveItem(t,r,T,f,E)}const u=s.getEntityRelations(t,f,"ContainsElements");if(!u)continue;let d=f.toString();if(a){const E=await t.getProperties(f);if(!E)continue;d=(h=E.Name)==null?void 0:h.value}for(const E of u){this.saveItem(t,r,d,E,f);const T=s.getEntityRelations(t,Number(E),"IsDecomposedBy");if(T)for(const p of T)this.saveItem(t,r,d,p,f)}}}setColor(t,e,s=!1){const n=this.components.get(pt);for(const r in t){const o=n.list.get(r);if(!o)continue;const a=t[r];o.setColor(e,a,s)}}resetColor(t){const e=this.components.get(pt);for(const s in t){const n=e.list.get(s);if(!n)continue;const r=t[s];n.resetColor(r)}}saveItem(t,e,s,n,r=null){this.list[e]||(this.list[e]={});const o=t.data.get(n);if(o)for(const a of o[0]){const l=t.keyFragments.get(a);if(l){const h=this.list[e];h[s]||(h[s]={map:{},id:r,name:s}),h[s].map[l]||(h[s].map[l]=new Set),h[s].map[l].add(n)}}}};C(Ms,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let ti=Ms;const ws=class ws extends mt{constructor(t){super(t);C(this,"onDisposed",new q);C(this,"enabled",!0);C(this,"height",10);C(this,"groupName","spatialStructures");C(this,"list",new Set);t.add(ws.uuid,this)}dispose(){this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}set(t){if(!this.enabled)return;const e=this.components.get(ti),s=this.components.get(pt),n=t?1:-1;let r=0;const o=e.list[this.groupName],a=new b.Matrix4;for(const l in o){a.elements[13]=r*n*this.height;for(const h in o[l].map){const f=s.list.get(h),I=l+h,u=this.list.has(I);if(!f||t&&u||!t&&!u)continue;t?this.list.add(I):this.list.delete(I);const d=o[l].map[h];f.applyTransform(d,a),f.mesh.computeBoundingSphere(),f.mesh.computeBoundingBox()}r++}}};C(ws,"uuid","d260618b-ce88-4c7d-826c-6debb91de3e2");let Ln=ws;const Ds=class Ds extends mt{constructor(t){super(t);C(this,"enabled",!0);this.components.add(Ds.uuid,this)}set(t,e){const s=this.components.get(pt);if(!e){for(const[n,r]of s.list)r&&(r.setVisibility(t),this.updateCulledVisibility(r));return}for(const n in e){const r=e[n],o=s.list.get(n);o&&(o.setVisibility(t,r),this.updateCulledVisibility(o))}}isolate(t){this.set(!1),this.set(!0,t)}updateCulledVisibility(t){const e=this.components.get(fs);for(const[s,n]of e.list){const r=n.colorMeshes.get(t.id);r&&(r.count=t.mesh.count)}}};C(Ds,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let ms=Ds;class Oo extends zs{constructor(){super(...arguments);C(this,"minGeometrySize",10);C(this,"minAssetsSize",1e3);C(this,"maxTriangles",null)}}const bs=class bs extends mt{constructor(t){super(t);C(this,"onGeometryStreamed",new fe);C(this,"onAssetStreamed",new fe);C(this,"onProgress",new fe);C(this,"onIfcLoaded",new fe);C(this,"onDisposed",new q);C(this,"settings",new Oo);C(this,"enabled",!0);C(this,"webIfc",new k.IfcAPI);C(this,"_nextAvailableID",0);C(this,"_splittedGeometries",new Map);C(this,"_spatialTree",new co);C(this,"_metaData",new ho);C(this,"_visitedGeometries",new Map);C(this,"_streamSerializer",new jt.StreamSerializer);C(this,"_geometries",new Map);C(this,"_geometryCount",0);C(this,"_civil",new lo);C(this,"_groupSerializer",new jt.Serializer);C(this,"_assets",[]);C(this,"_meshesWithHoles",new Set);this.components.add(bs.uuid,this),this.settings.excludedCategories.add(k.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModel(t,this.settings.webIfc),this._nextAvailableID=this.webIfc.GetMaxExpressID(0)}async streamIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllGeometries(){console.log("Converting geometries to tiles...");const{minGeometrySize:t,minAssetsSize:e}=this.settings;this._spatialTree.setUp(this.webIfc);const s=this.webIfc.GetIfcEntityList(0),n=[[]],r=new jt.FragmentsGroup;r.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let o=0,a=0;for(const E of s){if(!this.webIfc.IsIfcElement(E)&&E!==k.IFCSPACE||this.settings.excludedCategories.has(E))continue;const T=this.webIfc.GetLineIDsWithType(0,E),p=T.size();for(let m=0;m<p;m++){o>t&&(o=0,a++,n.push([]));const F=T.get(m);n[a].push(F);const R=this.webIfc.GetLine(0,F);if(R.GlobalId){const N=(R==null?void 0:R.GlobalId.value)||(R==null?void 0:R.GlobalId);r.globalToExpressIDs.set(N,F)}const S=this._spatialTree.itemsByFloor[F]||0;r.data.set(F,[[],[S,E]]),o++}}this._spatialTree.cleanUp();let l=.01,h=0;for(const E of n){h++,this.webIfc.StreamMeshes(0,E,p=>{this.getMesh(this.webIfc,p,r)}),this._geometryCount>this.settings.minGeometrySize&&await this.streamGeometries(),this._assets.length>e&&await this.streamAssets();const T=h/n.length;T>l&&(l+=.01,l=Math.max(l,T),await this.onProgress.trigger(Math.round(l*100)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:f,transparent:I}=r.geometryIDs;for(const[E,{index:T,uuid:p}]of this._visitedGeometries)r.keyFragments.set(T,p),(E>1?f:I).set(E,T);uo.get(r,this.webIfc);const u=this.webIfc.GetCoordinationMatrix(0);r.coordinationMatrix.fromArray(u),r.civilData=this._civil.read(this.webIfc);const d=this._groupSerializer.export(r);await this.onIfcLoaded.trigger(d),r.dispose(!0)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new k.IfcAPI,this._visitedGeometries.clear(),this._geometries.clear(),this._assets=[],this._meshesWithHoles.clear()}getMesh(t,e,s){const n=e.geometries.size(),r=e.expressID,o={id:r,geometries:[]};for(let a=0;a<n;a++){const l=e.geometries.get(a),h=l.geometryExpressID,I=l.color.w===1?1:-1,u=h*I;this._visitedGeometries.has(u)||this.getGeometry(t,h,u),this.registerGeometryData(s,r,l,o,h,u);const d=this._splittedGeometries.get(h);if(d)for(const E of d)this.registerGeometryData(s,r,l,o,E,E)}this._assets.push(o)}getGeometry(t,e,s){const n=t.GetGeometry(0,e),r=t.GetIndexArray(n.GetIndexData(),n.GetIndexDataSize()),o=t.GetVertexArray(n.GetVertexData(),n.GetVertexDataSize()),a=new Float32Array(o.length/2),l=new Float32Array(o.length/2);for(let u=0;u<o.length;u+=6)a[u/2]=o[u],a[u/2+1]=o[u+1],a[u/2+2]=o[u+2],l[u/2]=o[u+3],l[u/2+1]=o[u+4],l[u/2+2]=o[u+5];if(r.length===0){const u=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]);this._geometries.set(e,{position:a,normal:l,index:r,boundingBox:u,hasHoles:!1});const d=this._visitedGeometries.size,E=b.MathUtils.generateUUID();this._visitedGeometries.set(s,{uuid:E,index:d}),this._geometryCount++,n.delete();return}const f=(this.settings.maxTriangles||r.length/3)*3;let I=!0;for(let u=0;u<r.length;u+=f){const d=r.length-u,E=Math.min(d,f),T=u+E,p=[],m=[],F=[];let R=0;for(let g=u;g<T;g++){p.push(R++);const U=r[g];m.push(a[U*3]),m.push(a[U*3+1]),m.push(a[U*3+2]),F.push(l[U*3]),F.push(l[U*3+1]),F.push(l[U*3+2])}const S=new Uint32Array(p),N=new Float32Array(m),L=new Float32Array(F),D=kr(N),P=new Float32Array(D.transformation.elements),v=!1,G=I?e:this._nextAvailableID++;this._geometries.set(G,{position:N,normal:L,index:S,boundingBox:P,hasHoles:v}),I||(this._splittedGeometries.has(e)||this._splittedGeometries.set(e,new Set),this._splittedGeometries.get(e).add(G));const O=this._visitedGeometries.size,w=b.MathUtils.generateUUID();this._visitedGeometries.set(s,{uuid:w,index:O}),this._geometryCount++,I=!1}n.delete()}async streamAssets(){await this.onAssetStreamed.trigger(this._assets),this._assets=null,this._assets=[]}async streamGeometries(){let t=this._streamSerializer.export(this._geometries),e={};for(const[s,{boundingBox:n,hasHoles:r}]of this._geometries)e[s]={boundingBox:n,hasHoles:r};await this.onGeometryStreamed.trigger({data:e,buffer:t}),e=null,t=null,this._geometries.clear(),this._geometryCount=0}registerGeometryData(t,e,s,n,r,o){const a=this._visitedGeometries.get(o);if(a===void 0)throw new Error("Error getting geometry data for streaming!");const l=t.data.get(e);if(!l)throw new Error("Data not found!");l[0].push(a.index);const{x:h,y:f,z:I,w:u}=s.color,d=[h,f,I,u],E=s.flatTransformation;n.geometries.push({color:d,geometryID:r,transformation:E})}};C(bs,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let Pn=bs;class No extends zs{constructor(){super(...arguments);C(this,"propertiesSize",100)}}class yo extends mt{constructor(){super(...arguments);C(this,"onPropertiesStreamed",new fe);C(this,"onProgress",new fe);C(this,"onIndicesStreamed",new fe);C(this,"onDisposed",new q);C(this,"enabled",!0);C(this,"settings",new No);C(this,"webIfc",new k.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:s,logLevel:n}=this.settings.wasm;this.webIfc.SetWasmPath(e,s),await this.webIfc.Init(),n&&this.webIfc.SetLogLevel(n),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllProperties(){const{propertiesSize:t}=this.settings,e=new Set(this.webIfc.GetIfcEntityList(0)),s=new Set([k.IFCPROJECT,k.IFCSITE,k.IFCBUILDING,k.IFCBUILDINGSTOREY,k.IFCSPACE]);for(const l of s)e.add(l);let n=.01,r=0;for(const l of e){if(r++,Vn.has(l))continue;const h=s.has(l),f=this.webIfc.GetLineIDsWithType(0,l),I=f.size();let u=0;for(let E=0;E<I-t;E+=t){const T={};for(let p=0;p<t;p++){u++;const m=f.get(E+p);try{const F=this.webIfc.GetLine(0,m,h);T[F.expressID]=F}catch{console.log(`Could not get property: ${m}`)}}await this.onPropertiesStreamed.trigger({type:l,data:T})}if(u!==I){const E={};for(let T=u;T<I;T++){const p=f.get(T);try{const m=this.webIfc.GetLine(0,p,h);E[m.expressID]=m}catch{console.log(`Could not get property: ${p}`)}}await this.onPropertiesStreamed.trigger({type:l,data:E})}r/e.size>n&&(n=Math.round(n*100)/100,await this.onProgress.trigger(n),n+=.01)}await this.onProgress.trigger(1);const a=await this.components.get(Bt).processFromWebIfc(this.webIfc,0);await this.onIndicesStreamed.trigger(a)}cleanUp(){this.webIfc.Dispose(),this.webIfc=null,this.webIfc=new k.IfcAPI}}C(yo,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");class kn{constructor(i,t,e){C(this,"title");C(this,"guid",Kt.create());C(this,"clippingPlanes",new Ie);C(this,"camera",{aspectRatio:0,fov:0,direction:{x:0,y:0,z:80},position:{x:0,y:0,z:0}});C(this,"exceptionComponents",new Ie);C(this,"selectionComponents",new Ie);C(this,"componentColors",new Qt);C(this,"spacesVisible",!1);C(this,"spaceBoundariesVisible",!1);C(this,"openingsVisible",!1);C(this,"defaultVisibility",!0);C(this,"_components");C(this,"world");const s={setCamera:!0,...e},{data:n,setCamera:r}=s;this._components=i,this.world=t,n&&(this.guid=n.guid??this.guid,this.set(n)),r&&this.updateCamera()}get _selectionModelIdMap(){const i=this._components.get(pt),t={};for(const[e,s]of i.groups){e in t||(t[e]=new Set);for(const n of this.selectionComponents){const r=s.globalToExpressIDs.get(n);r&&t[e].add(r)}}return t}get _exceptionModelIdMap(){const i=this._components.get(pt),t={};for(const[e,s]of i.groups){e in t||(t[e]=new Set);for(const n of this.exceptionComponents){const r=s.globalToExpressIDs.get(n);r&&t[e].add(r)}}return t}get selection(){return this._components.get(pt).modelIdToFragmentIdMap(this._selectionModelIdMap)}get exception(){return this._components.get(pt).modelIdToFragmentIdMap(this._exceptionModelIdMap)}get projection(){return"fov"in this.camera?"Perspective":"Orthographic"}get position(){const i=this._components.get(pt),{position:t}=this.camera,{x:e,y:s,z:n}=t,r=new b.Vector3(e,s,n);return i.applyBaseCoordinateSystem(r,new b.Matrix4),r}get direction(){const{direction:i}=this.camera,{x:t,y:e,z:s}=i;return new b.Vector3(t,e,s)}get _managerVersion(){return this._components.get(Mt).config.version}get topics(){return[...this._components.get(Mt).list.values()].filter(s=>s.viewpoints.has(this.guid))}addComponentsFromMap(i){const e=this._components.get(pt).fragmentIdMapToGuids(i);this.selectionComponents.add(...e),this._components.get(Zt).list.set(this.guid,this)}set(i){const t=i,e=this;for(const n in i){if(n==="guid")continue;const r=t[n];if(n==="selectionComponents"){this.selectionComponents.clear(),this.selectionComponents.add(...r);continue}if(n==="exceptionComponents"){this.exceptionComponents.clear(),this.exceptionComponents.add(...r);continue}n in this&&(e[n]=r)}return this._components.get(Zt).list.set(this.guid,this),this}async go(i=!0){const{camera:t}=this.world;if(!t.hasCameraControls())throw new Error("Viewpoint: the world's camera need controls to set the viewpoint.");t instanceof ro&&t.projection.set(this.projection);const e=this.position,s=this.direction;let n={x:e.x+s.x*80,y:e.y+s.y*80,z:e.z+s.z*80};const r=this.selection;if(Object.keys(r).length===0){const h=this._components.get(ve).get(this.world).castRayFromVector(e,this.direction);h&&(n=h.point)}else{const a=this._components.get(Ts);a.reset(),a.addFragmentIdMap(r),n=a.getSphere().center,a.reset()}const o=this._components.get(ms);o.set(this.defaultVisibility),o.set(!this.defaultVisibility,this.exception),o.set(!0,r),await t.controls.setLookAt(e.x,e.y,e.z,n.x,n.y,n.z,i)}updateCamera(){const{camera:i,renderer:t}=this.world;if(!t)throw new Error("Viewpoint: the world needs to have a renderer!");if(!i.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const e=new b.Vector3;i.controls.getPosition(e);const s=i.three,n=new b.Vector3(0,0,-1).applyEuler(s.rotation),{width:r,height:o}=t.getSize();let a=r/o;Number.isNaN(a)&&(a=1);const l=this._components.get(pt);e.applyMatrix4(l.baseCoordinationMatrix.clone().invert());const h={aspectRatio:a,position:{x:e.x,y:e.y,z:e.z},direction:{x:n.x,y:n.y,z:n.z}};s instanceof b.PerspectiveCamera?this.camera={...h,fov:s.fov}:s instanceof b.OrthographicCamera&&(this.camera={...h,viewToWorldScale:s.top-s.bottom}),this._components.get(Zt).list.set(this.guid,this)}colorize(){const i=this._components.get(Zt),t=this._components.get(pt),e=this._components.get(ti);for(const[s,n]of this.componentColors){const r=t.guidToFragmentIdMap(n),o=new b.Color(`#${s}`);e.setColor(r,o,i.config.overwriteColors)}}resetColors(){const i=this._components.get(pt),t=this._components.get(ti);for(const[e,s]of this.componentColors){const n=i.guidToFragmentIdMap(s);t.resetColor(n)}}async createComponentTags(i){var n,r;const t=this._components.get(pt),e=this._components.get(Mt);let s="";if(e.config.includeSelectionTag){const o=i==="selection"?this._selectionModelIdMap:this._exceptionModelIdMap;for(const a in o){const l=t.groups.get(a);if(!l)continue;const h=o[a];for(const f of h){const I=await l.getProperties(f);if(!I)continue;const u=(n=I.GlobalId)==null?void 0:n.value;if(!u)continue;const d=(r=I.Tag)==null?void 0:r.value;let E=null;d&&(E=`AuthoringToolId="${d}"`),s+=`
|
|
227
227
|
<Component IfcGuid="${u}" ${E??""} />`}}}else s=[...this.selectionComponents].map(o=>`<Component IfcGuid="${o}" />`).join(`
|
|
228
228
|
`);return s}async serialize(i=this._managerVersion){const t=this._components.get(pt),e=this.position;e.applyMatrix4(t.baseCoordinationMatrix.clone().invert());const s=this.direction;s.normalize();const n=new b.Matrix4().makeRotationX(Math.PI/2),r=s.clone().applyMatrix4(n);r.normalize();const o=`<CameraViewPoint>
|
|
229
229
|
<X>${e.x}</X>
|
package/dist/index.mjs
CHANGED
|
@@ -18293,6 +18293,7 @@ const xs = class xs extends At {
|
|
|
18293
18293
|
this.webIfc.SetWasmPath(e, s), await this.webIfc.Init(), n && this.webIfc.SetLogLevel(n), this.webIfc.OpenModelFromCallback(t, this.settings.webIfc);
|
|
18294
18294
|
}
|
|
18295
18295
|
async streamAllGeometries() {
|
|
18296
|
+
console.log("Converting geometries to tiles...");
|
|
18296
18297
|
const { minGeometrySize: t, minAssetsSize: e } = this.settings;
|
|
18297
18298
|
this._spatialTree.setUp(this.webIfc);
|
|
18298
18299
|
const s = this.webIfc.GetIfcEntityList(0), n = [[]], r = new Qt.FragmentsGroup();
|