markuno_lib 1.2.33 → 1.2.34
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/bin/markcad.js +10 -10
- package/package.json +1 -1
- package/types/markcad.d.ts +9 -12
package/bin/markcad.js
CHANGED
|
@@ -270,7 +270,7 @@ function tovec(){return pt.flatMap((p=>[p.x,p.y]))}function move(x=0,y=0){"objec
|
|
|
270
270
|
* Aggiunge punti da array di coordinate
|
|
271
271
|
* @param {Array<number>} aa - Array [x1,y1,x2,y2,...]
|
|
272
272
|
*/
|
|
273
|
-
function _addvec(aa){for(let i=0;i<aa.length;i+=2)pt.push({x:aa[i],y:aa[i+1]})}function fromstr(str){return pt=removeduplicate(function processTokens(tokens){const points=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("point"===token.type)points.push(token.point);else if("command"===token.type)switch(token.cmd){case"x":{const p1=points[points.length-1],p2="point"===tokens[i+1]?.type?tokens[i+1].point:points[0],bulge=parseFloat(token.params[0])||5;{const STEP=1;let dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>1&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-STEP)/(STEP+2))+1))}break}case"b":{if(points.length<2)continue;const npt=parseInt(token.params[0])||5,p1=points[points.length-2],p2=points[points.length-1];let p3="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p4="point"===tokens[i+2]?.type?tokens[i+2].point:void 0;p3?p4||(p4=points[0]):(p3=points[0],p4=points[1]);const raccordo=raccordabezier(p1,p2,p3,p4,npt);points.push(...raccordo),i+=1;break}case"r":{if(points.length<1)continue;const dist=parseFloat(token.params[0])||
|
|
273
|
+
function _addvec(aa){for(let i=0;i<aa.length;i+=2)pt.push({x:aa[i],y:aa[i+1]})}function fromstr(str){return pt=removeduplicate(function processTokens(tokens){const points=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("point"===token.type)points.push(token.point);else if("command"===token.type)switch(token.cmd){case"x":{const p1=points[points.length-1],p2="point"===tokens[i+1]?.type?tokens[i+1].point:points[0],bulge=parseFloat(token.params[0])||5;{const STEP=1;let dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>1&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-STEP)/(STEP+2))+1))}break}case"b":{if(points.length<2)continue;const npt=parseInt(token.params[0])||5,p1=points[points.length-2],p2=points[points.length-1];let p3="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p4="point"===tokens[i+2]?.type?tokens[i+2].point:void 0;p3?p4||(p4=points[0]):(p3=points[0],p4=points[1]);const raccordo=raccordabezier(p1,p2,p3,p4,npt);points.push(...raccordo),i+=1;break}case"r":{if(points.length<1)continue;const dist=parseFloat(token.params[0])||0;if(dist>0){const npt=parseInt(token.params[1])||Math.min(dist,10),p1=points[points.length-1];let p2="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p3="point"===tokens[i+2]?.type?tokens[i+2].point:"point"===tokens[i+3]?.type?tokens[i+3].point:void 0;p2?p3||(p3=points[0]):(p2=points[0],p3=points[1],points.splice(0,1));const raccordo=raccordabezier3(p1,p2,p3,dist,npt);points.push(...raccordo),i+=1}break}case"c":{const radius=parseFloat(token.params[0])||50,segments=parseInt(token.params[1])||12,center="point"===tokens[i+1]?.type?tokens[i+1].point:new Punto2(0,0);for(let j=0;j<segments;j++)points.push(new Punto2(center.x+radius*Math.cos(j/segments*Math.PI*2),center.y+radius*Math.sin(j/segments*Math.PI*2)));i+=1;break}case"a":{let npt,p1="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p2="point"===tokens[i+2]?.type?tokens[i+2].point:void 0,p3="point"===tokens[i+3]?.type?tokens[i+3].point:void 0;if(!p1||!p3)continue;if(p2)if(token.params[0])npt=clamp(parseInt(token.params[0]),1,24);else{const chord=Math.hypot(p3.x-p1.x,p3.y-p1.y),sagitta=Math.abs((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))/(2*chord);npt=Math.round(chord*Math.sqrt(sagitta/(chord+.1))*10),npt=clamp(npt,1,24),npt=1}else p2=p3,npt=0;const arcoPoints=arcfrom3point(npt,p1,p2,p3);points.push(...arcoPoints),i+=3;break}}}return points}(function tokenize(str){const tokens=[],values=str.replace(/[\n\r,;]/g," ").replace(/\s+/g," ").toLowerCase().trim().split(" ").filter((s=>s.length>0));let i=0;for(;i<values.length;){const val=values[i];/^[brcax]/.test(val)?(tokens.push({type:"command",cmd:val[0],params:val.slice(1).split(":")}),i++):i<values.length-1&&/^-?\d+(\.\d+)?$/.test(values[i])&&/^-?\d+(\.\d+)?$/.test(values[i+1])?(tokens.push({type:"point",point:new Punto2(parseFloat(values[i]),parseFloat(values[i+1]))}),i+=2):i++}return tokens}(str))),this}function dims(pts){let{p1:p1,p2:p2}=pts.reduce(((m,p)=>(m.p1.x=Math.min(m.p1.x,p.x),m.p2.x=Math.max(m.p2.x,p.x),m.p1.y=Math.min(m.p1.y,p.y),m.p2.y=Math.max(m.p2.y,p.y),m)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}),isrect=!1;if(4==pts.length){const TOLL=.001;function findpunto(x,y){let f=pts.find((p=>Math.abs(p.x-x)<TOLL&&Math.abs(p.y-y)<TOLL));return!!f}findpunto(p1.x,p1.y)&&findpunto(p1.x,p2.y)&&findpunto(p2.x,p1.y)&&findpunto(p2.x,p2.y)&&(isrect=!0)}return{p1:p1,p2:p2,isrect:isrect,width:p2.x-p1.x,height:p2.y-p1.y}}return{get key(){return hash(tovec().join("\t"))},orienta:function orienta(p0,p1){if(!p0||!p1)return null;const dx=p1.x-p0.x,dy=p1.y-p0.y,angolo=180*Math.atan2(dy,dx)/Math.PI,matrix=new Matrix3D;matrix.rotateZ(-angolo),matrix.translate(-p0.x,-p0.y,0);const ptTrasformati=pt.map((p=>matrix.transform(p.x,p.y)));let mm=ptTrasformati.reduce(((m,p)=>(m.p1.x=Math.min(m.p1.x,p.x),m.p2.x=Math.max(m.p2.x,p.x),m.p1.y=Math.min(m.p1.y,p.y),m.p2.y=Math.max(m.p2.y,p.y),m)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)});return{shape:getshape().frompt(ptTrasformati),origine:new Punto2(p0.x,p0.y),angolo:angolo,mm:mm,width:mm.p2.x-mm.p1.x,height:mm.p2.y-mm.p1.y}},rebase:function rebase(angolo,forceorigin=!1,ox=0,oy=0){const matrix=new Matrix3D;matrix.rotateZ(-angolo);let ptTrasformati=pt.map((p=>matrix.transform(p.x,p.y))),{p1:p1,p2:p2,width:width,height:height}=dims(ptTrasformati);return forceorigin||(ox=p1.x,oy=p1.y),ptTrasformati=ptTrasformati.map((p=>new Punto2(p.x-ox,p.y-oy))),{shape:getshape().frompt(ptTrasformati),origine:new Punto2(ox,oy),angolo:angolo,width:width,height:height}},fromstr:fromstr,move:move,get pt(){return pt},set pt(val){Array.isArray(val)&&(pt=val)},get npt(){return pt?.length||0},get vec(){return tovec()},toJSON:()=>({vec:tovec(),orient:orientation()}),get orient(){return orientation()},corners:(angolo=45)=>
|
|
274
274
|
/**
|
|
275
275
|
* Trova i punti in cui l’angolo interno è maggiore di `thresholdDeg`.
|
|
276
276
|
*
|
|
@@ -523,7 +523,7 @@ function alignByMinDist(sag1,sag2,isopen){const n1=sag1.length,n2=sag2.length;if
|
|
|
523
523
|
* - dati: Array di oggetti con le posizioni elaborate dei tagli
|
|
524
524
|
* - punti: Array di oggetti {a,b} che definiscono inizio e fine di ogni segmento
|
|
525
525
|
*/
|
|
526
|
-
function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:tipoalign,tipocut:tipocut});function fondilinee(linee){const out=linee.slice();out.forEach((e=>e.valid=!0));for(let i=0;i<out.length;i++)if(!1!==out[i].valid)if(out[i].len<.1)out[i].valid=!1;else for(let j=i+1;j<out.length;j++){if(!1===out[j].valid)continue;const a=out[i],b=out[j];if(!a||!b)continue;if(!a.isparallela(b))continue;const a1_su_b=b.onsegment(a.p1,.1),a2_su_b=b.onsegment(a.p2,.1),b1_su_a=a.onsegment(b.p1,.1),b2_su_a=a.onsegment(b.p2,.1);if(!(a1_su_b||a2_su_b||b1_su_a||b2_su_a))continue;const dot=a.dx*b.dx+a.dy*b.dy,pa1=0,pa2=1,rb1=a.proiezionet(b.p1),rb2=a.proiezionet(b.p2);if(!rb1||!rb2)continue;const pb1=rb1.t,pb2=rb2.t;if(dot>0){const tmin=Math.min(pa1,pa2,pb1,pb2),tmax=Math.max(pa1,pa2,pb1,pb2),pmin=a.puntot(tmin),pmax=a.puntot(tmax),fus=new Linea2(pmin,pmax);out[i].valid=!1,out[j].valid=!1,fus.len>=.1&&(fus.valid=!0,out.push(fus))}else if(dot<0){const a_min=Math.min(pa1,pa2),a_max=Math.max(pa1,pa2),b_min=Math.min(pb1,pb2),b_max=Math.max(pb1,pb2),ov_min=Math.max(a_min,b_min),ov_max=Math.min(a_max,b_max);if(ov_min>ov_max+.1)continue;const gmin=Math.min(a_min,b_min),gmax=Math.max(a_max,b_max);if(gmin<ov_min-.1){const s1=new Linea2(a.puntot(gmin),a.puntot(ov_min));s1.len>=.1&&(s1.valid=!0,out.push(s1))}if(ov_max<gmax-.1){const s2=new Linea2(a.puntot(ov_max),a.puntot(gmax));s2.len>=.1&&(s2.valid=!0,out.push(s2))}out[i].valid=!1,out[j].valid=!1}}const res=out.filter((s=>s.valid)),tt=[];function samepoint(p1,p2){return Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y)<.1}for(let r of res){let fi=-1,fe=-1;for(let i=0;i<tt.length;i++){let t=tt[i];if(fi<0&&samepoint(t[0],r.p2)&&(tt[i]=[r.p1,...t],fi=i),fe<0&&samepoint(t[t.length-1],r.p1)&&(tt[i]=[...t,r.p2],fe=i),fi>=0&&fe>=0)break}fi<0&&fe<0?tt.push([r.p1,r.p2]):fi>=0&&fe>=0&&fi!=fe&&(tt[fi]=[...tt[fi],...tt[fe]],tt.splice(fe,1))}return tt}async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&¯o.head&¯o.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(console.log(tipifree),pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&¶metri.length)for(const param of parametri)await _parsepars(param);if(macro&¯o.head&¯o.head.length){let tm=macro.head.filter((e=>!["g","p"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){let rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname,order:order}=pos;if("number"==typeof order&&g2.traverse((child=>{child.isMesh&&(child.renderOrder=order)})),tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
|
|
526
|
+
function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:tipoalign,tipocut:tipocut});function fondilinee(linee){const out=linee.slice();out.forEach((e=>e.valid=!0));for(let i=0;i<out.length;i++)if(!1!==out[i].valid)if(out[i].len<.1)out[i].valid=!1;else for(let j=i+1;j<out.length;j++){if(!1===out[j].valid)continue;const a=out[i],b=out[j];if(!a||!b)continue;if(!a.isparallela(b))continue;const a1_su_b=b.onsegment(a.p1,.1),a2_su_b=b.onsegment(a.p2,.1),b1_su_a=a.onsegment(b.p1,.1),b2_su_a=a.onsegment(b.p2,.1);if(!(a1_su_b||a2_su_b||b1_su_a||b2_su_a))continue;const dot=a.dx*b.dx+a.dy*b.dy,pa1=0,pa2=1,rb1=a.proiezionet(b.p1),rb2=a.proiezionet(b.p2);if(!rb1||!rb2)continue;const pb1=rb1.t,pb2=rb2.t;if(dot>0){const tmin=Math.min(pa1,pa2,pb1,pb2),tmax=Math.max(pa1,pa2,pb1,pb2),pmin=a.puntot(tmin),pmax=a.puntot(tmax),fus=new Linea2(pmin,pmax);out[i].valid=!1,out[j].valid=!1,fus.len>=.1&&(fus.valid=!0,out.push(fus))}else if(dot<0){const a_min=Math.min(pa1,pa2),a_max=Math.max(pa1,pa2),b_min=Math.min(pb1,pb2),b_max=Math.max(pb1,pb2),ov_min=Math.max(a_min,b_min),ov_max=Math.min(a_max,b_max);if(ov_min>ov_max+.1)continue;const gmin=Math.min(a_min,b_min),gmax=Math.max(a_max,b_max);if(gmin<ov_min-.1){const s1=new Linea2(a.puntot(gmin),a.puntot(ov_min));s1.len>=.1&&(s1.valid=!0,out.push(s1))}if(ov_max<gmax-.1){const s2=new Linea2(a.puntot(ov_max),a.puntot(gmax));s2.len>=.1&&(s2.valid=!0,out.push(s2))}out[i].valid=!1,out[j].valid=!1}}const res=out.filter((s=>s.valid)),tt=[];function samepoint(p1,p2){return Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y)<.1}for(let r of res){let fi=-1,fe=-1;for(let i=0;i<tt.length;i++){let t=tt[i];if(fi<0&&samepoint(t[0],r.p2)&&(tt[i]=[r.p1,...t],fi=i),fe<0&&samepoint(t[t.length-1],r.p1)&&(tt[i]=[...t,r.p2],fe=i),fi>=0&&fe>=0)break}fi<0&&fe<0?tt.push([r.p1,r.p2]):fi>=0&&fe>=0&&fi!=fe&&(tt[fi]=[...tt[fi],...tt[fe]],tt.splice(fe,1))}return tt}async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&¯o.head&¯o.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(console.log(tipifree),pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&¶metri.length)for(const param of parametri)await _parsepars(param);if(macro&¯o.head&¯o.head.length){let tm=macro.head.filter((e=>!["g","p"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){let rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter$1(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}function getbb(obj,force=!1){if(!force&&obj.userData.bb)return obj.userData._boundingbox;const box=(new THREE.Box3).setFromObject(obj);return obj.userData._boundingbox=box,box}function setorigine(obj,x=0,y=0,z=0){const min=getbb(obj).min,wrapper=new THREE.Group;return wrapper.add(obj),obj.position.sub(new THREE.Vector3(min.x+x,min.y+y,min.z+z)),wrapper}function scalaoggetto(gcad,originale,scale={}){const box=getbb(originale),size=new THREE.Vector3;box.getSize(size);const min=box.min,axes=["x","y","z","u","v"],norm={};for(let ax of axes){let sc=scale[ax];if(void 0===sc)norm[ax]={s:1};else if("number"==typeof sc)norm[ax]={s:sc};else if("object"==typeof sc){let s=sc.s??1,dim="x"===ax?size.x:"y"===ax?size.y:size.z,minv="x"===ax?min.x:"y"===ax?min.y:min.z;void 0!==sc.distperc&&(sc.dist=dim*sc.distperc),void 0!==sc.dist&&(s=(dim+sc.dist)/dim);let p1=sc.p1?sc.p1+minv:void 0,p2=sc.p2?sc.p2+minv:void 0;void 0!==sc.p1perc&&(p1=minv+dim*sc.p1perc),void 0!==sc.p2perc&&(p2=minv+dim*sc.p2perc),norm[ax]={s:s,p1:p1,p2:p2}}}if(axes.every((ax=>void 0===norm[ax].p1||void 0===norm[ax].p2))){if(1===norm.x.s&&1===norm.y.s&&1===norm.z.s)return originale;const wrapper=new THREE.Group;return wrapper.scale.set(norm.x.s,norm.y.s,norm.z.s),wrapper.add(originale),wrapper}const key=hash(`${originale.uuid}|${JSON.stringify(norm)}`);if(gcad.meshes[key])return gcad.meshes[key];const needAxis={};axes.forEach((ax=>{const{s:s,p1:p1,p2:p2}=norm[ax];needAxis[ax]=!(1===s&&void 0===p1&&void 0===p2)}));const clone=originale.clone(!0);return delete clone?.userData._boundingbox,clone.traverse((n=>{if(n.isMesh){const sOld=n.scale.clone();n.geometry=n.geometry.clone();const posAttr=n.geometry.attributes.position,uvAttr=n.geometry.attributes.uv,trasf=(val,ax)=>{if(!needAxis[ax])return val;const{s:s,p1:p1,p2:p2}=norm[ax];if(void 0===p1||void 0===p2)return val*s;const delta=p2*s-p2;if(val<p1)return val;if(val>=p2)return val+delta;return p1+(val-p1)*((p2-p1+delta)/(p2-p1))};if(posAttr&&(needAxis.x||needAxis.y||needAxis.z)){const arr=posAttr.array;for(let i=0;i<arr.length;i+=3)needAxis.x&&(arr[i]=trasf(arr[i],"x")),needAxis.y&&(arr[i+1]=trasf(arr[i+1],"y")),needAxis.z&&(arr[i+2]=trasf(arr[i+2],"z"));posAttr.needsUpdate=!0,n.geometry.computeVertexNormals()}if(uvAttr&&(needAxis.u||needAxis.v)){const arr=uvAttr.array;for(let i=0;i<arr.length;i+=2)needAxis.u&&(arr[i]=trasf(arr[i],"u")),needAxis.v&&(arr[i+1]=trasf(arr[i+1],"v"));uvAttr.needsUpdate=!0}n.scale.set(sOld.x*norm.x.s,sOld.y*norm.y.s,sOld.z*norm.z.s)}})),gcad.meshes[key]=clone,clone}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname,order:order}=pos;if("number"==typeof order&&g2.traverse((child=>{child.isMesh&&(child.renderOrder=order)})),tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
|
|
527
527
|
/**
|
|
528
528
|
* Crea una linea 3D
|
|
529
529
|
* @param {Object} l - Oggetto contenente punti p1 e p2
|
|
@@ -538,7 +538,7 @@ function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,sha
|
|
|
538
538
|
* @param {THREE.Material} [mat=null] - Materiale da applicare
|
|
539
539
|
* @param {number} [size=5] - Dimensione della sfera
|
|
540
540
|
* @returns {THREE.Mesh} Punto 3D
|
|
541
|
-
*/function getpoint(p,id,mat=null,size=5){const pointgeom=new THREE.SphereGeometry(size,8,8);let tm=new THREE.Mesh(pointgeom,mat||randombasemat());return tm.position.set(p.x,0,p.y),tm}async function smat(gcad,file,op={}){op||(op={});let ky=hash(file+JSON.stringify(op));return gcad.smats[ky]||(gcad.smats[ky]=await async function smat0(gcad,file,op={}){let fileini=file,paramstr="",isColore=!1;file.startsWith("#")&&(isColore=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(file)||(file=file.slice(1)));let basefile=file;const paramMatch=file.match(/^(.*)\[([^\]]+)\]$/);paramMatch&&(basefile=paramMatch[1],paramstr=paramMatch[2]);const p={};paramstr&¶mstr.split(/[,;]/).forEach((kv=>{let[k,v]=kv.split("=").map((x=>x.trim()));void 0!==v&&(["e"].includes(k)?p[k]=v.startsWith("0x")?parseInt(v):parseFloat(v):isNaN(parseFloat(v))?p[k]=v:p[k]=parseFloat(v))}));const mappaParam={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let optot={...op};for(let k in p)if(mappaParam[k])for(let t of mappaParam[k])optot[t]=p[k];let transparent=!!optot?.transparent,sx=optot.sx??optot.s??p.sx??p.s??1,sy=optot.sy??optot.s??p.sy??p.s??1,rot=Number(optot.rot??0)*PIF;try{let tm={roughness:optot.roughness??.5,metalness:optot.metalness??0,side:THREE.DoubleSide,envMapIntensity:optot.env??1};if(void 0!==optot.normalScale){let ns=Number(optot.normalScale);isNaN(ns)||0===ns||(tm.normalScale=new THREE.Vector2(ns,ns))}let hasNormal=!1,hasBump=!1;if(file.includes("(")||isColore){let{base:base,files:files,transparent:t2}=function getFilesToLoad(isColore,basefile){let files=[],m=basefile.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!m)return{base:basefile,files:files};let base=m[1],transparent=!1,mapalias=m[3]||base,suffstr=m[4]||m[5]||"";isColore||files.push({suff:"",file:`${base}.webp`});for(let s of suffstr)"t"==s?(transparent=!0,m[3]&&suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`})):suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`});return{base:base,files:files,transparent:transparent}}(isColore,basefile);if(transparent=t2,files.some((f=>"n"===f.suff))&&(files=files.filter((f=>"h"!==f.suff))),0===optot.roughness&&(files=files.filter((f=>"r"!==f.suff))),0===optot.metalness&&(files=files.filter((f=>"m"!==f.suff))),0===optot.emissiveIntensity&&(files=files.filter((f=>"e"!==f.suff))),files&&files.length){let textures=await Promise.all(files.map((f=>gcad.tex(f.file,sx,sy,rot).catch((()=>null)))));for(let i=0;i<files.length;i++){let t=textures[i];if(!t)continue;let suff=files[i].suff,{prop:prop,extra:extra}=suffissoMap[suff];tm[prop]=t,"normalMap"===extra?(hasNormal=!0,tm.normalMap=t,tm.normalScale=tm.normalScale??new THREE.Vector2(1,1)):"bumpScale"===extra?(hasBump=!0,tm.bumpMap=t):Array.isArray(extra)&&extra.includes("emissive")&&void 0!==optot.emissiveIntensity&&0!==optot.emissiveIntensity&&(tm.emissive=optot.emissive||16777215,tm.emissiveIntensity=optot.emissiveIntensity??1)}}isColore&&(tm.color=new THREE.Color(base))}else if(basefile.includes(".")){let tx=await gcad.tex(basefile,sx,sy,rot);if(!tx)return mwhite;tm.map=tx}if(hasNormal&&hasBump?delete tm.bumpMap:hasBump&&(tm.bumpScale=optot.bumpScale??.03),tm.transparent=!!transparent,tm.transparent&&(tm.depthWrite=!1,tm.opacity=optot?.opacity??1),void 0!==optot.brightness){let bf=Number(optot.brightness);!isNaN(bf)&&bf>0&&1!==bf&&(tm.color||(tm.color=new THREE.Color(1,1,1)),tm.color.multiplyScalar(bf))}return new THREE.MeshStandardMaterial(tm)}catch(error){return console.log("errore mat:",error.message,fileini),mwhite}}
|
|
541
|
+
*/function getpoint(p,id,mat=null,size=5){const pointgeom=new THREE.SphereGeometry(size,8,8);let tm=new THREE.Mesh(pointgeom,mat||randombasemat());return tm.position.set(p.x,0,p.y),tm}async function smat(gcad,file,op={}){op||(op={});let ky=hash(file+JSON.stringify(op));return gcad.smats[ky]||(gcad.smats[ky]=await async function smat0(gcad,file,op={}){let fileini=file,paramstr="",isColore=!1;file.startsWith("#")&&(isColore=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(file)||(file=file.slice(1)));let basefile=file;const paramMatch=file.match(/^(.*)\[([^\]]+)\]$/);paramMatch&&(basefile=paramMatch[1],paramstr=paramMatch[2]);const p={};paramstr&¶mstr.split(/[,;]/).forEach((kv=>{let[k,v]=kv.split("=").map((x=>x.trim()));void 0!==v&&(["e"].includes(k)?p[k]=v.startsWith("0x")?parseInt(v):parseFloat(v):isNaN(parseFloat(v))?p[k]=v:p[k]=parseFloat(v))}));const mappaParam={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let rot0=op.rot,optot={...op};for(let k in p)if(mappaParam[k])for(let t of mappaParam[k])optot[t]=p[k];let transparent=!!optot?.transparent,sx=optot.sx??optot.s??p.sx??p.s??1,sy=optot.sy??optot.s??p.sy??p.s??1,rot=Number((optot.rot??0)+(rot0??0))*PIF;try{let tm={roughness:optot.roughness??.5,metalness:optot.metalness??0,side:THREE.DoubleSide,envMapIntensity:optot.env??1};if(void 0!==optot.normalScale){let ns=Number(optot.normalScale);isNaN(ns)||0===ns||(tm.normalScale=new THREE.Vector2(ns,ns))}let hasNormal=!1,hasBump=!1;if(file.includes("(")||isColore){let{base:base,files:files,transparent:t2}=function getFilesToLoad(isColore,basefile){let files=[],m=basefile.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!m)return{base:basefile,files:files};let base=m[1],transparent=!1,mapalias=m[3]||base,suffstr=m[4]||m[5]||"";isColore||files.push({suff:"",file:`${base}.webp`});for(let s of suffstr)"t"==s?(transparent=!0,m[3]&&suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`})):suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`});return{base:base,files:files,transparent:transparent}}(isColore,basefile);if(transparent=t2,files.some((f=>"n"===f.suff))&&(files=files.filter((f=>"h"!==f.suff))),0===optot.roughness&&(files=files.filter((f=>"r"!==f.suff))),0===optot.metalness&&(files=files.filter((f=>"m"!==f.suff))),0===optot.emissiveIntensity&&(files=files.filter((f=>"e"!==f.suff))),files&&files.length){let textures=await Promise.all(files.map((f=>gcad.tex(f.file,sx,sy,rot).catch((()=>null)))));for(let i=0;i<files.length;i++){let t=textures[i];if(!t)continue;let suff=files[i].suff,{prop:prop,extra:extra}=suffissoMap[suff];tm[prop]=t,"normalMap"===extra?(hasNormal=!0,tm.normalMap=t,tm.normalScale=tm.normalScale??new THREE.Vector2(1,1)):"bumpScale"===extra?(hasBump=!0,tm.bumpMap=t):Array.isArray(extra)&&extra.includes("emissive")&&void 0!==optot.emissiveIntensity&&0!==optot.emissiveIntensity&&(tm.emissive=optot.emissive||16777215,tm.emissiveIntensity=optot.emissiveIntensity??1)}}isColore&&(tm.color=new THREE.Color(base))}else if(basefile.includes(".")){let tx=await gcad.tex(basefile,sx,sy,rot);if(!tx)return mwhite;tm.map=tx}if(hasNormal&&hasBump?delete tm.bumpMap:hasBump&&(tm.bumpScale=optot.bumpScale??.03),tm.transparent=!!transparent,tm.transparent&&(tm.depthWrite=!1,tm.opacity=optot?.opacity??1),void 0!==optot.brightness){let bf=Number(optot.brightness);!isNaN(bf)&&bf>0&&1!==bf&&(tm.color||(tm.color=new THREE.Color(1,1,1)),tm.color.multiplyScalar(bf))}return new THREE.MeshStandardMaterial(tm)}catch(error){return console.log("errore mat:",error.message,fileini),mwhite}}
|
|
542
542
|
/**
|
|
543
543
|
* Estrae tutte le texture usate nella scena glb e le converte in file WEBP.
|
|
544
544
|
* @param {THREE.Object3D} root - nodo root (es: gltf.scene)
|
|
@@ -591,7 +591,7 @@ function getriferimento(dati,x=0,y=0,z=0,id="rif"){"string"==typeof dati&&(dati=
|
|
|
591
591
|
* @param {number} dim - Larghezza/altezza della targhetta
|
|
592
592
|
* @param {Object} options - Opzioni aggiuntive
|
|
593
593
|
* @returns {THREE.Mesh} Mesh con la targhetta
|
|
594
|
-
*/function gettarghetta(gcad,testo,dim=100,options={}){const{noSfondo:noSfondo=!1,forcey:forcey=!1,coloreSfondo:coloreSfondo="white",coloreBordo:coloreBordo="
|
|
594
|
+
*/function gettarghetta(gcad,testo,dim=100,options={}){const{noSfondo:noSfondo=!1,forcey:forcey=!1,coloreSfondo:coloreSfondo="white",coloreBordo:coloreBordo="gray",spessoreBordo:spessoreBordo=2,padding:padding=8,layer:layer=21,size:size=24,fontFamily:fontFamily="Arial",raggioAngoli:raggioAngoli=10,order:order=0}=options;let tt=hash(`T:${coloreSfondo}|${coloreBordo}|${fontFamily}|${padding}|${spessoreBordo}|${raggioAngoli}|${noSfondo}|${testo}`);const sizebase=size??24;testo=testo.split("\n").map((e=>{let size=sizebase,bold=!1,italic=!1,color="black";e=e.trim();let rr=/^\s*#(\w)([bi]?)([\d.]*),(.*)$/.exec(e);if(rr)switch(size=parseFloat(rr[3]||1)*sizebase,"b"===rr[2]&&(bold=!0),"i"===rr[2]&&(italic=!0),e=rr[4],rr[1].toLowerCase()){case"r":color="red";break;case"g":color="green";break;case"b":color="blue";break;case"c":color="cyan"}return{testo:e,size:size,color:color,bold:bold,italic:italic}})).filter((e=>e.testo)),console.log(testo);const{canvas:canvas,context:context}=function getGlobalCanvas(){return globalLabelCanvas||(globalLabelCanvas=document.createElement("canvas"),globalLabelContext=globalLabelCanvas.getContext("2d",{willReadFrequently:!0})),{canvas:globalLabelCanvas,context:globalLabelContext}}();let maxWidth=0,totalHeight=2*padding;testo.forEach(((riga,i)=>{const{testo:testoRiga,size:size=12}=riga,fontSize=2*size;context.font=`${fontSize}px ${fontFamily}`;const textWidth=context.measureText(testoRiga).width,textHeight=fontSize*(i==testo.length-1?1:1.2);maxWidth=Math.max(maxWidth,textWidth),totalHeight+=textHeight})),maxWidth+=2*padding;const aspectRatio=totalHeight/maxWidth||1;let dimx,dimy;if(forcey?(dimy=dim,dimx=Math.ceil(dimy/aspectRatio)):(dimx=dim,dimy=Math.ceil(dimx*aspectRatio)),!gcad.textures[tt]){const canvasWidth=Math.floor(maxWidth+2*spessoreBordo),canvasHeight=Math.floor(totalHeight+2*spessoreBordo);(canvas.width<canvasWidth||canvas.height<canvasHeight)&&(canvas.width=Math.max(canvas.width,canvasWidth),canvas.height=Math.max(canvas.height,canvasHeight)),context.clearRect(0,0,canvasWidth,canvasHeight);const bgColor=new THREE.Color(coloreSfondo),bgColorStyle=`rgb(${Math.floor(255*bgColor.r)}, ${Math.floor(255*bgColor.g)}, ${Math.floor(255*bgColor.b)})`,borderColor=new THREE.Color(coloreBordo),borderColorStyle=`rgb(${Math.floor(255*borderColor.r)}, ${Math.floor(255*borderColor.g)}, ${Math.floor(255*borderColor.b)})`,radius=raggioAngoli;context.beginPath(),noSfondo||(drawRoundedRect(context,0,0,canvasWidth,canvasHeight,radius+spessoreBordo/2),context.fillStyle=borderColorStyle,context.fill(),context.beginPath(),drawRoundedRect(context,spessoreBordo,spessoreBordo,canvasWidth-2*spessoreBordo,canvasHeight-2*spessoreBordo,radius-spessoreBordo/2),context.fillStyle=bgColorStyle,context.fill());let yPosition=padding+spessoreBordo;testo.forEach((riga=>{const{testo:testoRiga,size:size=12,color:color="black",bold:bold,italic:italic}=riga,fontSize=2*size;context.font=`${bold?"bold ":italic?"italic ":""}${fontSize}px ${fontFamily}`,context.fillStyle=color,context.textAlign="center",context.textBaseline="top",context.fillText(testoRiga,canvasWidth/2,yPosition),yPosition+=1.2*fontSize}));const imageData=context.getImageData(0,0,canvasWidth,canvasHeight),texture=new THREE.DataTexture(imageData.data,imageData.width,imageData.height,THREE.RGBAFormat);texture.needsUpdate=!0,texture.flipY=!0,texture.minFilter=THREE.LinearFilter,texture.magFilter=THREE.LinearFilter,gcad.textures[tt]=texture}const materialeTesto=new THREE.MeshBasicMaterial({map:gcad.textures[tt],transparent:!0,alphaTest:.5,side:SIDE}),geometriaTesto=new THREE.PlaneGeometry(dimx,dimy),meshTesto=new THREE.Mesh(geometriaTesto,materialeTesto);return meshTesto.layers.set(layer),meshTesto.renderOrder=order,meshTesto.userData={dimx:dimx,dimy:dimy},meshTesto}function drawRoundedRect(ctx,x,y,width,height,radius){radius=Math.min(radius,Math.min(width/2,height/2)),ctx.moveTo(x+radius,y),ctx.lineTo(x+width-radius,y),ctx.quadraticCurveTo(x+width,y,x+width,y+radius),ctx.lineTo(x+width,y+height-radius),ctx.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),ctx.lineTo(x+radius,y+height),ctx.quadraticCurveTo(x,y+height,x,y+height-radius),ctx.lineTo(x,y+radius),ctx.quadraticCurveTo(x,y,x+radius,y),ctx.closePath()}
|
|
595
595
|
/**
|
|
596
596
|
* Crea una quota tra due punti in 3D sul piano XY
|
|
597
597
|
* @param {string} testo - Testo da visualizzare nella quota
|
|
@@ -602,7 +602,7 @@ function getriferimento(dati,x=0,y=0,z=0,id="rif"){"string"==typeof dati&&(dati=
|
|
|
602
602
|
* @param {number} sizetesto - Dimensione del testo
|
|
603
603
|
* @param {Object} options - Opzioni aggiuntive
|
|
604
604
|
* @returns {THREE.Group} Gruppo contenente la quota
|
|
605
|
-
*/function getquota(gcad,testo,x1,y1,x2,y2,altezza=30,offset=0,
|
|
605
|
+
*/function getquota(gcad,testo,x1,y1,x2,y2,options={}){const{altezza:altezza=30,offset:offset=0,piano:piano="xy",layer:layer=22,delta:delta=5,spessoreLinea:spessoreLinea=3}=options,pp=(x,y)=>"xz"===piano?[x,0,y]:"yz"===piano?[0,x,y]:[x,y,0],quotaGroup=new THREE.Group;quotaGroup.name="quota";const dx=x2-x1,dy=y2-y1,distanza=Math.sqrt(dx*dx+dy*dy),angolo=Math.atan2(dy,dx);testo||(testo="$$"),testo.includes("$$")&&(testo=testo.replace("$$",`${distanza.toFixed(1)}`));let linee=testo.split("\n").length;const offsetX=-Math.sin(angolo)*offset,offsetY=Math.cos(angolo)*offset,targhetta=gettarghetta(gcad,testo,2*altezza*linee,{noSfondo:!0,layer:layer,forcey:!0}),{dimx:dimx,dimy:dimy}=targhetta.userData;function getCilindro(puntoInizio,puntoFine,spessore){const direzione=(new THREE.Vector3).subVectors(puntoFine,puntoInizio),lunghezza=direzione.length();let geometria,ky=hash(`c:${spessore}|${lunghezza}`);gcad.geo[ky]?geometria=gcad.geo[ky]:(geometria=new THREE.CylinderGeometry(spessore/2,spessore/2,lunghezza,3,1,!0),gcad.geo[ky]=geometria);const cilindro=new THREE.Mesh(geometria,mblack);cilindro.position.copy(puntoInizio).add(direzione.multiplyScalar(.5));const punto=(new THREE.Vector3).copy(puntoFine);return cilindro.lookAt(punto),cilindro.rotateX(Math.PI/2),cilindro}if(dimx>distanza-delta){targhetta.position.set(distanza/2,altezza,0);const lineaOrizzontale=getCilindro(new THREE.Vector3(...pp(0,0)),new THREE.Vector3(...pp(distanza,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale)}else{const spazioTarghetta=dimx+delta,inizioTarghetta=(distanza-spazioTarghetta)/2,fineTarghetta=inizioTarghetta+spazioTarghetta,lineaOrizzontale1=getCilindro(new THREE.Vector3(...pp(0,0)),new THREE.Vector3(...pp(inizioTarghetta,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale1);const lineaOrizzontale2=getCilindro(new THREE.Vector3(...pp(fineTarghetta,0)),new THREE.Vector3(...pp(distanza,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale2),targhetta.position.set(...pp(distanza/2,0))}const h1=offset>altezza/2?-offset:-altezza/2,h2=-offset>altezza/2?-offset:altezza/2,puntoInizioV1=new THREE.Vector3(...pp(0,h1)),puntoFineV1=new THREE.Vector3(...pp(0,h2)),puntoInizioV2=new THREE.Vector3(...pp(distanza,h1)),puntoFineV2=new THREE.Vector3(...pp(distanza,h2)),lineaVerticale1=getCilindro(puntoInizioV1,puntoFineV1,spessoreLinea);quotaGroup.add(lineaVerticale1);const lineaVerticale2=getCilindro(puntoInizioV2,puntoFineV2,spessoreLinea);return quotaGroup.add(lineaVerticale2),targhetta.userData.updateOrientation=function(camera){camera&&this.quaternion.copy(camera.quaternion)},quotaGroup.add(targhetta),"xy"===piano?(quotaGroup.position.set(x1+offsetX,y1+offsetY,0),quotaGroup.rotation.z=angolo):"xz"===piano?(quotaGroup.position.set(x1+offsetX,0,y1+offsetY),quotaGroup.rotation.y=-angolo):"yz"===piano&&(quotaGroup.position.set(0,x1+offsetX,y1+offsetY),quotaGroup.rotation.x=angolo),quotaGroup.traverse((function(object){object.layers.set(layer)})),quotaGroup}
|
|
606
606
|
/**
|
|
607
607
|
* Crea un cilindro 3D con orientamento personalizzabile
|
|
608
608
|
* @param {string} ori - Orientamento (X/L, Y/A, Z/P)
|
|
@@ -622,7 +622,7 @@ function getcilindro(gcad,ori,h,r1,r2,mats=mwhite,options){options||(options={})
|
|
|
622
622
|
* @param {THREE.Material} mat - Materiale da applicare
|
|
623
623
|
* @param {Object} options - Opzioni di configurazione
|
|
624
624
|
* @returns {Promise<THREE.Group>} Gruppo contenente il box
|
|
625
|
-
*/function getface(gcad,x,y,mat,op={}){let{repeat:repeat,order:order}=op;const key=hash(`f:${x}|${y}|${repeat?1:0}`);if(!gcad.geo[key]){const geometry=new THREE.PlaneGeometry(x,y),uvs=geometry.attributes.uv;if(repeat)for(let i=0;i<uvs.count;i++)uvs.setXY(i,uvs.getX(i)*x,uvs.getY(i)*y);else{const tm=[[0,1e3],[1e3,1e3],[0,0],[1e3,0]];for(let i=0;i<uvs.count;i++){const t=tm[i];uvs.setXY(i,t[0],t[1])}}uvs.needsUpdate=!0,gcad.geo[key]=geometry}const plane=new THREE.Mesh(gcad.geo[key],mat);return"number"==typeof order&&(plane.renderOrder=order),plane.position.set(x/2,y/2,0),mat?.transparent&&plane.layers.set(2),plane}function
|
|
625
|
+
*/function scalauv(box){const uvAttr=box.attributes.uv;if(uvAttr){const arr=uvAttr.array;for(let i=0;i<arr.length;i++)arr[i]*=1e3;uvAttr.needsUpdate=!0}}function getface(gcad,x,y,mat,op={}){let{repeat:repeat,order:order}=op;const key=hash(`f:${x}|${y}|${repeat?1:0}`);if(!gcad.geo[key]){const geometry=new THREE.PlaneGeometry(x,y),uvs=geometry.attributes.uv;if(repeat)for(let i=0;i<uvs.count;i++)uvs.setXY(i,uvs.getX(i)*x,uvs.getY(i)*y);else{const tm=[[0,1e3],[1e3,1e3],[0,0],[1e3,0]];for(let i=0;i<uvs.count;i++){const t=tm[i];uvs.setXY(i,t[0],t[1])}}uvs.needsUpdate=!0,gcad.geo[key]=geometry}const plane=new THREE.Mesh(gcad.geo[key],mat);return"number"==typeof order&&(plane.renderOrder=order),plane.position.set(x/2,y/2,0),mat?.transparent&&plane.layers.set(2),plane}function getbox(gcad,x,y,z,mat,options){mat&&mat.isMaterial||(options=mat,mat=void 0),options||(options={});let{center:center=!1,nolines:nolines,centerbase:centerbase=!1,px:px=0,py:py=0,pz:pz=0}=options;const box=new THREE.BoxGeometry(x,y,z);scalauv(box);const grp=new THREE.Group;if(centerbase?grp.position.set(0,y/2,0):px||py||pz?grp.position.set(px||0,py||0,pz||0):center||grp.position.set(x/2,y/2,z/2),!nolines||!mat){let segments=edgesfromgeometry(box);grp.add(segments)}return mat&&grp.add(getmesh(box,mat)),grp}function getcyl(gcad,height,radius,mat,options){options||(options={});let{center:center=!1,nolines:nolines=!1,segments:segments=16,top:top=-1,bottom:bottom=-1,heightSegments:heightSegments=1,openEnded:openEnded=!1,thetaStart:thetaStart=0,thetaLength:thetaLength=2*Math.PI}=options;top<0&&(top=radius),bottom<0&&(bottom=radius);const cylinder=new THREE.CylinderGeometry(top,bottom,height,segments,heightSegments,openEnded,thetaStart,thetaLength);scalauv(cylinder);const mesh=getmesh(cylinder,mat||mwhite),grp=new THREE.Group;if(grp.add(mesh),grp.position.set(0,center?0:height/2,0),!nolines){let segs=edgesfromgeometry(cylinder);grp.add(segs)}return grp}
|
|
626
626
|
/**
|
|
627
627
|
* Crea una sfera 3D come gruppo (mesh + edges opzionali).
|
|
628
628
|
* @param {object} gcad - riferimento (non usato ma coerente con getbox)
|
|
@@ -630,7 +630,7 @@ function getcilindro(gcad,ori,h,r1,r2,mats=mwhite,options){options||(options={})
|
|
|
630
630
|
* @param {THREE.Material} mat - materiale della mesh
|
|
631
631
|
* @param {object} [options] - opzioni: {center: boolean, nolines: boolean}
|
|
632
632
|
* @returns {THREE.Group}
|
|
633
|
-
*/function getsphere(gcad,r,mat,options){options||(options={});let{center:center,nolines:nolines,segmenti:segmenti=16}=options,grp=new THREE.Group;const sphere=new THREE.SphereGeometry(r,2*segmenti,segmenti);if(grp.position.set(0,center?0:r,0),!nolines){let segments=edgesfromgeometry(sphere);grp.add(segments)}return grp.add(getmesh(sphere,mat||mwhite)),grp}
|
|
633
|
+
*/function getsphere(gcad,r,mat,options){options||(options={});let{center:center,nolines:nolines,segmenti:segmenti=16}=options,grp=new THREE.Group;const sphere=new THREE.SphereGeometry(r,2*segmenti,segmenti);if(scalauv(sphere),grp.position.set(0,center?0:r,0),!nolines){let segments=edgesfromgeometry(sphere);grp.add(segments)}return grp.add(getmesh(sphere,mat||mwhite)),grp}function getextrude(gcad,pts,h=10,holes=[],mat=void 0,op={}){mat&&mat.isMaterial||(op=mat,mat=void 0),op=op??{};let{stonda:stonda,sx:sx,sy:sy,round:round}=op,ky=hash(`${JSON.stringify(pts)}|${h}|${JSON.stringify(op)}`);sx=sx??stonda??0,sy=sy??stonda??0;let geom=gcad.geo[ky];if(!geom){const sh=function makeShape(points){const shape=new THREE.Shape;shape.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)shape.lineTo(points[i].x,points[i].y);return shape.closePath(),shape}(pts);holes.forEach((hh=>sh.holes.push(function makePath(points){const path=new THREE.Path;path.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)path.lineTo(points[i].x,points[i].y);return path.closePath(),path}(hh)))),geom=new THREE.ExtrudeGeometry(sh,{depth:h,bevelEnabled:sx>0&&sy>0,bevelSize:sx,bevelThickness:sy,bevelSegments:round?3:1,curveSegments:10}),gcad.geo[ky]=geom}return new THREE.Mesh(geom,mat||mwhite)}
|
|
634
634
|
/**
|
|
635
635
|
* @param {BufferGeometry} geometry
|
|
636
636
|
* @param {number} tolerance
|
|
@@ -651,7 +651,7 @@ function toTrianglesDrawMode(geometry,drawMode){if(drawMode===TrianglesDrawMode)
|
|
|
651
651
|
* @param {Array} mats - Array di materiali
|
|
652
652
|
* @param {Object} options - Opzioni di configurazione
|
|
653
653
|
* @returns {THREE.Group} Gruppo contenente la geometria estrusa
|
|
654
|
-
*/function estruso(gcad,orient,hshape,shape,holes,mats,options){options||(options={}),mats||(mats=[]),Array.isArray(mats)||(mats=[mats,mats,mats]);let p0=options.p0||0,coeffbase1=Math.tan(options.coeffbase1*PIF||0),coeffbase2=Math.tan(options.coeffbase2*PIF||0),p1=hshape||options.p1||20,coefftop1=Math.tan(options.coefftop1*PIF||0),coefftop2=Math.tan(options.coefftop2*PIF||0),shapetop=options.shapetop,shapebase=options.shapebase||options.shapebottom;shapetop&&(coefftop2=0),shapebase&&(coefftop2=0);let shb=shapebase?shapebase.key:"",sht=shapetop?shapetop.key:"",notopholes=options.notopholes||!1,nobottomholes=options.nobottomholes||options.nobaseholes||!1,opinvert=options.invert||!1,open=options.open||!1,grp=new THREE.Group;if(shape){if(!options.nobase){let h1=holes;nobottomholes&&(h1=Array.isArray(nobottomholes)?h1.filter(((_,i)=>!nobottomholes[i])):[]);let g1=bottomgeomfromshape(gcad,!1,shape,open?[]:h1,p0,coeffbase1,coeffbase2,shapebase);options.nolines||grp.add(edgesfromgeometry(g1)),grp.add(getmesh(g1,mats[0]||mwhite))}if(!options.notop){let h1=holes;notopholes&&(h1=Array.isArray(notopholes)?h1.filter(((_,i)=>!notopholes[i])):[]);let g3=bottomgeomfromshape(gcad,!0,shape,open?[]:h1,p1,coefftop1,coefftop2,shapetop);grp.add(getmesh(g3,mats[1]||mats[0]||mwhite)),options.nolines||grp.add(edgesfromgeometry(g3))}if(!options.nosides){let pat1=shape.to3d(0,p0,coeffbase1,-coeffbase2,open,shapebase,!opinvert),pat2=shape.to3d(1,p1,coefftop1,-coefftop2,open,shapetop,opinvert),ky=`${shape.key}${opinvert?1:0}|${p0}|${p1}|${coeffbase1}|${coeffbase2||shb}|${coefftop1}|${coefftop2||sht}|${open}`,geo1=sidegeomfromshapes(gcad,ky,pat1,pat2,!1);if(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite)),holes&&!open&&!nobottomholes&&!notopholes)for(let h of holes){pat1=h.to3d(0,p0,coeffbase1,coeffbase2),pat2=h.to3d(0,p1,coefftop1,coefftop2),ky=`${h.key}|${p0}|${p1}|${coeffbase1}|${coeffbase2}|${coefftop1}|${coefftop2}`;let geo2=sidegeomfromshapes(gcad,ky,pat1,pat2,!0);options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo2)),grp.add(getmesh(geo2,mats[3]||mats[0]||mwhite))}}return estrusorotate(orient,grp,hshape)}return grp}function revolve(gcad,shape,orient,mat,options){options||(options={});let segmenti=options.segmenti??12,ky=hash(`rev|${shape.key}|${orient}|${segmenti}`),geometria=gcad.geo[ky],grp=new THREE.Group;if(!geometria){const punti3D=shape.pt.map((p=>new THREE.Vector3(p.x,p.y,0)));geometria=new THREE.LatheGeometry(punti3D,segmenti,0,2*Math.PI),gcad.geo[ky]=geometria}const mesh=new THREE.Mesh(geometria,mat);return grp.add(mesh),options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geometria)),grp}function estrusopat(gcad,orient,pat,plink,shape,mats,options){options||(options={});let invert=options.invert;mats||(mats=[]);let open=options.open,closepat=options.closepat;if(!pat.pt?.length)return;let pbase=shape.to3d(0,0,0,0,open),grp=new THREE.Group;if(!options.nobase&&!options.open&&!closepat){let gb=new THREE.Group,angolo=angle3point(plink[0],pat.pt[0],pat.pt[1])+Math.PI/2,g1=bottomgeomfromshape(gcad,!1,shape,[],0,-Math.tan(angolo));gb.add(getmesh(g1,mats[0]||mwhite)),gb.add(edgesfromgeometry(g1));let seg1=pat.infosegmento(0,!0);grp.add(posiziona(gb,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}if(!options.notop&&!options.open&&!closepat){let gt=new THREE.Group,angolo=-(angle3point(pat.pt[pat.npt-2],pat.pt[pat.npt-1],plink[pat.npt-1])+Math.PI/2),g2=bottomgeomfromshape(gcad,!0,shape,[],0,-Math.tan(angolo),0);gt.add(getmesh(g2,mats[1]||mats[0]||mwhite)),gt.add(edgesfromgeometry(g2));let seg1=pat.infosegmento(pat.pt.length-1,!0);grp.add(posiziona(gt,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}const geo1=function sidegeomfrompat(gcad,pbase,pat,plink,closepat,invert){let ky=`bsg:${pbase.key}|${pat.key}|${closepat}|${invert}`;if(pat.npt==plink.length){if(ky=hash(ky),!gcad.geo[ky]){const vertices=[],uvs=[],indices=[],np=pbase.length,equalpos=(p1,p2)=>p1.x===p2.x&&p1.y===p2.y&&p1.z===p2.z;let l0=0,pt=pat.pt,ptl=pat.npt;const addpts=(ss,mat,deltav,coeffz)=>{for(const s of ss){let p=new THREE.Vector3(s.x,s.y,s.x*coeffz);p.applyMatrix4(mat),vertices.push(p.x,p.y,p.z),uvs.push(s.u,s.v+deltav)}};let lp=ptl;for(let ii=0;ii<ptl;ii++){let angolo;angolo=ii<ptl-1?angle3point(plink[ii],pt[ii],pt[ii+1])+Math.PI/2:-(angle3point(pt[ii-1],pt[ii],plink[ii])+Math.PI/2);let coefficente=-Math.tan(angolo),seg1=pat.infosegmento(ii,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0),obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l}if(closepat){let seg1=pat.infosegmento(0,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0);let angolo=angle3point(pt[ptl-1],pt[0],plink[0])+Math.PI/2,coefficente=-Math.tan(angolo);obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l,lp++}for(let li=0;li<lp-1;li++)for(let i=0;i<np-1;i++){const addindexquad=(i1,i2,i3,i4)=>{invert?indices.push(i1,i3,i2,i3,i4,i2):indices.push(i1,i2,i3,i3,i2,i4)},j=i+1;equalpos(pbase[i],pbase[j])||addindexquad(i+li*np,j+li*np,i+(li+1)*np,j+(li+1)*np)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uvs,2)),geometry.setIndex(indices),geometry.computeVertexNormals(),gcad[ky]=geometry}return gcad[ky]}}(gcad,pbase,pat,plink,closepat?1:0,invert?1:0);return geo1&&(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite))),estrusorotate(orient,grp,0)}async function spritemat(gcad,file){try{let tm={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(file.startsWith("#"))tm.color=file;else{let tx=await gcad.tex(file,1e3,1e3);tx?tm.map=tx:tm.color="black"}return new THREE.SpriteMaterial(tm)}catch(error){return mwhite}}function getsprite0(ispunto,x,y,z,mat,options={}){options||(options={});let{size:size=50,pick:pick=!1,screen:screen=!1,sizex:sizex,sizey:sizey}=options;const sprite=new THREE.Sprite(mat);sprite.position.set(0,0,0),sprite.userData.issprite=!0,sprite.userData.ispunto=ispunto,sprite.userData.ispick=pick,sprite.userData.isScreen=screen,sprite.renderOrder=999,sprite.layers.set(29),sprite.name=ispunto?"_punto":"_sprite";let gr=new THREE.Group;return gr.position.set(x,y,z),gr.scale.set(sizex||size,sizey||sizex||size,1),gr.add(sprite),gr.traverse((obj=>{obj.material&&(obj.material.depthTest=!1,obj.material.depthWrite=!1)})),gr.renderOrder=999,gr}async function getpunto(gcad,x,y,z,color="yellow",options){options||(options={size:20}),options.screen=!0;const texture=await function createCircleTexture(gcad,size=64,color="rgba(255,0,0,1)"){const ky=`ct|${size}|${color}`;if(!gcad.textures[ky]){const canvas=document.createElement("canvas");canvas.width=canvas.height=size;const ctx=canvas.getContext("2d"),radius=size/2;ctx.clearRect(0,0,size,size),ctx.fillStyle=color,ctx.beginPath(),ctx.arc(radius,radius,radius,0,2*Math.PI),ctx.fill();const texture=new THREE.CanvasTexture(canvas);texture.needsUpdate=!0,gcad.textures[ky]=texture}return gcad.textures[ky]}(gcad,64,color);return getsprite0(!0,x,y,z,new THREE.SpriteMaterial({map:texture,transparent:!0,fog:!1,toneMapped:!1}),options)}function getsprite(gcad,x,y,z,mat,options={}){return getsprite0(!1,x,y,z,mat,options)}class GLTFLoader extends Loader{constructor(manager){super(manager),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(parser){return new GLTFMaterialsClearcoatExtension(parser)})),this.register((function(parser){return new GLTFMaterialsDispersionExtension(parser)})),this.register((function(parser){return new GLTFTextureBasisUExtension(parser)})),this.register((function(parser){return new GLTFTextureWebPExtension(parser)})),this.register((function(parser){return new GLTFTextureAVIFExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSheenExtension(parser)})),this.register((function(parser){return new GLTFMaterialsTransmissionExtension(parser)})),this.register((function(parser){return new GLTFMaterialsVolumeExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIorExtension(parser)})),this.register((function(parser){return new GLTFMaterialsEmissiveStrengthExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSpecularExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIridescenceExtension(parser)})),this.register((function(parser){return new GLTFMaterialsAnisotropyExtension(parser)})),this.register((function(parser){return new GLTFMaterialsBumpExtension(parser)})),this.register((function(parser){return new GLTFLightsExtension(parser)})),this.register((function(parser){return new GLTFMeshoptCompression(parser)})),this.register((function(parser){return new GLTFMeshGpuInstancing(parser)}))}load(url,onLoad,onProgress,onError){const scope=this;let resourcePath;if(""!==this.resourcePath)resourcePath=this.resourcePath;else if(""!==this.path){const relativeUrl=LoaderUtils.extractUrlBase(url);resourcePath=LoaderUtils.resolveURL(relativeUrl,this.path)}else resourcePath=LoaderUtils.extractUrlBase(url);this.manager.itemStart(url);const _onError=function(e){onError?onError(e):console.error(e),scope.manager.itemError(url),scope.manager.itemEnd(url)},loader=new FileLoader(this.manager);loader.setPath(this.path),loader.setResponseType("arraybuffer"),loader.setRequestHeader(this.requestHeader),loader.setWithCredentials(this.withCredentials),loader.load(url,(function(data){try{scope.parse(data,resourcePath,(function(gltf){onLoad(gltf),scope.manager.itemEnd(url)}),_onError)}catch(e){_onError(e)}}),onProgress,_onError)}setDRACOLoader(dracoLoader){return this.dracoLoader=dracoLoader,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(ktx2Loader){return this.ktx2Loader=ktx2Loader,this}setMeshoptDecoder(meshoptDecoder){return this.meshoptDecoder=meshoptDecoder,this}register(callback){return-1===this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.push(callback),this}unregister(callback){return-1!==this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback),1),this}parse(data,path,onLoad,onError){let json;const extensions={},plugins={},textDecoder=new TextDecoder;if("string"==typeof data)json=JSON.parse(data);else if(data instanceof ArrayBuffer){if(textDecoder.decode(new Uint8Array(data,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{extensions[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(data)}catch(error){return void(onError&&onError(error))}json=JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content)}else json=JSON.parse(textDecoder.decode(data))}else json=data;if(void 0===json.asset||json.asset.version[0]<2)return void(onError&&onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const parser=new GLTFParser(json,{path:path||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});parser.fileLoader.setRequestHeader(this.requestHeader);for(let i=0;i<this.pluginCallbacks.length;i++){const plugin=this.pluginCallbacks[i](parser);plugin.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),plugins[plugin.name]=plugin,extensions[plugin.name]=!0}if(json.extensionsUsed)for(let i=0;i<json.extensionsUsed.length;++i){const extensionName=json.extensionsUsed[i],extensionsRequired=json.extensionsRequired||[];switch(extensionName){case EXTENSIONS.KHR_MATERIALS_UNLIT:extensions[extensionName]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:extensions[extensionName]=new GLTFDracoMeshCompressionExtension(json,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:extensions[extensionName]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:extensions[extensionName]=new GLTFMeshQuantizationExtension;break;default:extensionsRequired.indexOf(extensionName)>=0&&void 0===plugins[extensionName]&&console.warn('THREE.GLTFLoader: Unknown extension "'+extensionName+'".')}}parser.setExtensions(extensions),parser.setPlugins(plugins),parser.parse(onLoad,onError)}parseAsync(data,path){const scope=this;return new Promise((function(resolve,reject){scope.parse(data,path,resolve,reject)}))}}function GLTFRegistry(){let objects={};return{get:function(key){return objects[key]},add:function(key,object){objects[key]=object},remove:function(key){delete objects[key]},removeAll:function(){objects={}}}}
|
|
654
|
+
*/function estruso(gcad,orient,hshape,shape,holes,mats,options){options||(options={}),mats||(mats=[]),Array.isArray(mats)||(mats=[mats,mats,mats]);let p0=options.p0||0,coeffbase1=Math.tan(options.coeffbase1*PIF||0),coeffbase2=Math.tan(options.coeffbase2*PIF||0),p1=hshape||options.p1||20,coefftop1=Math.tan(options.coefftop1*PIF||0),coefftop2=Math.tan(options.coefftop2*PIF||0),shapetop=options.shapetop,shapebase=options.shapebase||options.shapebottom;shapetop&&(coefftop2=0),shapebase&&(coefftop2=0);let shb=shapebase?shapebase.key:"",sht=shapetop?shapetop.key:"",notopholes=options.notopholes||!1,nobottomholes=options.nobottomholes||options.nobaseholes||!1,opinvert=options.invert||!1,open=options.open||!1,grp=new THREE.Group;if(shape){if(!options.nobase){let h1=holes;nobottomholes&&(h1=Array.isArray(nobottomholes)?h1.filter(((_,i)=>!nobottomholes[i])):[]);let g1=bottomgeomfromshape(gcad,!1,shape,open?[]:h1,p0,coeffbase1,coeffbase2,shapebase);options.nolines||grp.add(edgesfromgeometry(g1)),grp.add(getmesh(g1,mats[0]||mwhite))}if(!options.notop){let h1=holes;notopholes&&(h1=Array.isArray(notopholes)?h1.filter(((_,i)=>!notopholes[i])):[]);let g3=bottomgeomfromshape(gcad,!0,shape,open?[]:h1,p1,coefftop1,coefftop2,shapetop);grp.add(getmesh(g3,mats[1]||mats[0]||mwhite)),options.nolines||grp.add(edgesfromgeometry(g3))}if(!options.nosides){let pat1=shape.to3d(0,p0,coeffbase1,-coeffbase2,open,shapebase,!opinvert),pat2=shape.to3d(1,p1,coefftop1,-coefftop2,open,shapetop,opinvert),ky=`${shape.key}${opinvert?1:0}|${p0}|${p1}|${coeffbase1}|${coeffbase2||shb}|${coefftop1}|${coefftop2||sht}|${open}`,geo1=sidegeomfromshapes(gcad,ky,pat1,pat2,!1);if(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite)),holes&&!open)for(let i=0;i<holes.length;i++){let h=holes[i];if(Array.isArray(notopholes)){if(notopholes[i])continue}else if(notopholes)continue;if(Array.isArray(nobottomholes)){if(nobottomholes[i])continue}else if(nobottomholes)continue;pat1=h.to3d(0,p0,coeffbase1,coeffbase2),pat2=h.to3d(0,p1,coefftop1,coefftop2),ky=`${h.key}|${p0}|${p1}|${coeffbase1}|${coeffbase2}|${coefftop1}|${coefftop2}`;let geo2=sidegeomfromshapes(gcad,ky,pat1,pat2,!0);options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo2)),grp.add(getmesh(geo2,mats[3]||mats[0]||mwhite))}}return estrusorotate(orient,grp,hshape)}return grp}function revolve(gcad,shape,orient,mat,options){options||(options={});let segmenti=options.segmenti??12,ky=hash(`rev|${shape.key}|${orient}|${segmenti}`),geometria=gcad.geo[ky],grp=new THREE.Group;if(!geometria){const punti3D=shape.pt.map((p=>new THREE.Vector3(p.x,p.y,0)));geometria=new THREE.LatheGeometry(punti3D,segmenti,0,2*Math.PI),gcad.geo[ky]=geometria}const mesh=new THREE.Mesh(geometria,mat);return grp.add(mesh),options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geometria)),grp}function estrusopat(gcad,orient,pat,plink,shape,mats,options){options||(options={});let invert=options.invert;mats||(mats=[]);let open=options.open,closepat=options.closepat;if(!pat.pt?.length)return;let pbase=shape.to3d(0,0,0,0,open),grp=new THREE.Group;if(!options.nobase&&!options.open&&!closepat){let gb=new THREE.Group,angolo=angle3point(plink[0],pat.pt[0],pat.pt[1])+Math.PI/2,g1=bottomgeomfromshape(gcad,!1,shape,[],0,-Math.tan(angolo));gb.add(getmesh(g1,mats[0]||mwhite)),gb.add(edgesfromgeometry(g1));let seg1=pat.infosegmento(0,!0);grp.add(posiziona(gb,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}if(!options.notop&&!options.open&&!closepat){let gt=new THREE.Group,angolo=-(angle3point(pat.pt[pat.npt-2],pat.pt[pat.npt-1],plink[pat.npt-1])+Math.PI/2),g2=bottomgeomfromshape(gcad,!0,shape,[],0,-Math.tan(angolo),0);gt.add(getmesh(g2,mats[1]||mats[0]||mwhite)),gt.add(edgesfromgeometry(g2));let seg1=pat.infosegmento(pat.pt.length-1,!0);grp.add(posiziona(gt,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}const geo1=function sidegeomfrompat(gcad,pbase,pat,plink,closepat,invert){let ky=`bsg:${pbase.key}|${pat.key}|${closepat}|${invert}`;if(pat.npt==plink.length){if(ky=hash(ky),!gcad.geo[ky]){const vertices=[],uvs=[],indices=[],np=pbase.length,equalpos=(p1,p2)=>p1.x===p2.x&&p1.y===p2.y&&p1.z===p2.z;let l0=0,pt=pat.pt,ptl=pat.npt;const addpts=(ss,mat,deltav,coeffz)=>{for(const s of ss){let p=new THREE.Vector3(s.x,s.y,s.x*coeffz);p.applyMatrix4(mat),vertices.push(p.x,p.y,p.z),uvs.push(s.u,s.v+deltav)}};let lp=ptl;for(let ii=0;ii<ptl;ii++){let angolo;angolo=ii<ptl-1?angle3point(plink[ii],pt[ii],pt[ii+1])+Math.PI/2:-(angle3point(pt[ii-1],pt[ii],plink[ii])+Math.PI/2);let coefficente=-Math.tan(angolo),seg1=pat.infosegmento(ii,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0),obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l}if(closepat){let seg1=pat.infosegmento(0,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0);let angolo=angle3point(pt[ptl-1],pt[0],plink[0])+Math.PI/2,coefficente=-Math.tan(angolo);obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l,lp++}for(let li=0;li<lp-1;li++)for(let i=0;i<np-1;i++){const addindexquad=(i1,i2,i3,i4)=>{invert?indices.push(i1,i3,i2,i3,i4,i2):indices.push(i1,i2,i3,i3,i2,i4)},j=i+1;equalpos(pbase[i],pbase[j])||addindexquad(i+li*np,j+li*np,i+(li+1)*np,j+(li+1)*np)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uvs,2)),geometry.setIndex(indices),geometry.computeVertexNormals(),gcad[ky]=geometry}return gcad[ky]}}(gcad,pbase,pat,plink,closepat?1:0,invert?1:0);return geo1&&(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite))),estrusorotate(orient,grp,0)}async function spritemat(gcad,file){try{let tm={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(file.startsWith("#"))tm.color=file;else{let tx=await gcad.tex(file,1e3,1e3);tx?tm.map=tx:tm.color="black"}return new THREE.SpriteMaterial(tm)}catch(error){return mwhite}}function getsprite0(ispunto,x,y,z,mat,options={}){options||(options={});let{size:size=50,pick:pick=!1,screen:screen=!1,sizex:sizex,sizey:sizey}=options;const sprite=new THREE.Sprite(mat);sprite.position.set(0,0,0),sprite.userData.issprite=!0,sprite.userData.ispunto=ispunto,sprite.userData.ispick=pick,sprite.userData.isScreen=screen,sprite.renderOrder=999,sprite.layers.set(29),sprite.name=ispunto?"_punto":"_sprite";let gr=new THREE.Group;return gr.position.set(x,y,z),gr.scale.set(sizex||size,sizey||sizex||size,1),gr.add(sprite),gr.traverse((obj=>{obj.material&&(obj.material.depthTest=!1,obj.material.depthWrite=!1)})),gr.renderOrder=999,gr}async function getpunto(gcad,x,y,z,color="yellow",options){options||(options={size:20}),options.screen=!0;const texture=await function createCircleTexture(gcad,size=64,color="rgba(255,0,0,1)"){const ky=`ct|${size}|${color}`;if(!gcad.textures[ky]){const canvas=document.createElement("canvas");canvas.width=canvas.height=size;const ctx=canvas.getContext("2d"),radius=size/2;ctx.clearRect(0,0,size,size),ctx.fillStyle=color,ctx.beginPath(),ctx.arc(radius,radius,radius,0,2*Math.PI),ctx.fill();const texture=new THREE.CanvasTexture(canvas);texture.needsUpdate=!0,gcad.textures[ky]=texture}return gcad.textures[ky]}(gcad,64,color);return getsprite0(!0,x,y,z,new THREE.SpriteMaterial({map:texture,transparent:!0,fog:!1,toneMapped:!1}),options)}function getsprite(gcad,x,y,z,mat,options={}){return getsprite0(!1,x,y,z,mat,options)}class GLTFLoader extends Loader{constructor(manager){super(manager),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(parser){return new GLTFMaterialsClearcoatExtension(parser)})),this.register((function(parser){return new GLTFMaterialsDispersionExtension(parser)})),this.register((function(parser){return new GLTFTextureBasisUExtension(parser)})),this.register((function(parser){return new GLTFTextureWebPExtension(parser)})),this.register((function(parser){return new GLTFTextureAVIFExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSheenExtension(parser)})),this.register((function(parser){return new GLTFMaterialsTransmissionExtension(parser)})),this.register((function(parser){return new GLTFMaterialsVolumeExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIorExtension(parser)})),this.register((function(parser){return new GLTFMaterialsEmissiveStrengthExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSpecularExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIridescenceExtension(parser)})),this.register((function(parser){return new GLTFMaterialsAnisotropyExtension(parser)})),this.register((function(parser){return new GLTFMaterialsBumpExtension(parser)})),this.register((function(parser){return new GLTFLightsExtension(parser)})),this.register((function(parser){return new GLTFMeshoptCompression(parser)})),this.register((function(parser){return new GLTFMeshGpuInstancing(parser)}))}load(url,onLoad,onProgress,onError){const scope=this;let resourcePath;if(""!==this.resourcePath)resourcePath=this.resourcePath;else if(""!==this.path){const relativeUrl=LoaderUtils.extractUrlBase(url);resourcePath=LoaderUtils.resolveURL(relativeUrl,this.path)}else resourcePath=LoaderUtils.extractUrlBase(url);this.manager.itemStart(url);const _onError=function(e){onError?onError(e):console.error(e),scope.manager.itemError(url),scope.manager.itemEnd(url)},loader=new FileLoader(this.manager);loader.setPath(this.path),loader.setResponseType("arraybuffer"),loader.setRequestHeader(this.requestHeader),loader.setWithCredentials(this.withCredentials),loader.load(url,(function(data){try{scope.parse(data,resourcePath,(function(gltf){onLoad(gltf),scope.manager.itemEnd(url)}),_onError)}catch(e){_onError(e)}}),onProgress,_onError)}setDRACOLoader(dracoLoader){return this.dracoLoader=dracoLoader,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(ktx2Loader){return this.ktx2Loader=ktx2Loader,this}setMeshoptDecoder(meshoptDecoder){return this.meshoptDecoder=meshoptDecoder,this}register(callback){return-1===this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.push(callback),this}unregister(callback){return-1!==this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback),1),this}parse(data,path,onLoad,onError){let json;const extensions={},plugins={},textDecoder=new TextDecoder;if("string"==typeof data)json=JSON.parse(data);else if(data instanceof ArrayBuffer){if(textDecoder.decode(new Uint8Array(data,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{extensions[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(data)}catch(error){return void(onError&&onError(error))}json=JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content)}else json=JSON.parse(textDecoder.decode(data))}else json=data;if(void 0===json.asset||json.asset.version[0]<2)return void(onError&&onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const parser=new GLTFParser(json,{path:path||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});parser.fileLoader.setRequestHeader(this.requestHeader);for(let i=0;i<this.pluginCallbacks.length;i++){const plugin=this.pluginCallbacks[i](parser);plugin.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),plugins[plugin.name]=plugin,extensions[plugin.name]=!0}if(json.extensionsUsed)for(let i=0;i<json.extensionsUsed.length;++i){const extensionName=json.extensionsUsed[i],extensionsRequired=json.extensionsRequired||[];switch(extensionName){case EXTENSIONS.KHR_MATERIALS_UNLIT:extensions[extensionName]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:extensions[extensionName]=new GLTFDracoMeshCompressionExtension(json,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:extensions[extensionName]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:extensions[extensionName]=new GLTFMeshQuantizationExtension;break;default:extensionsRequired.indexOf(extensionName)>=0&&void 0===plugins[extensionName]&&console.warn('THREE.GLTFLoader: Unknown extension "'+extensionName+'".')}}parser.setExtensions(extensions),parser.setPlugins(plugins),parser.parse(onLoad,onError)}parseAsync(data,path){const scope=this;return new Promise((function(resolve,reject){scope.parse(data,path,resolve,reject)}))}}function GLTFRegistry(){let objects={};return{get:function(key){return objects[key]},add:function(key,object){objects[key]=object},remove:function(key){delete objects[key]},removeAll:function(){objects={}}}}
|
|
655
655
|
/*********************************/
|
|
656
656
|
/********** EXTENSIONS ***********/
|
|
657
657
|
/*********************************/const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};
|
|
@@ -1095,7 +1095,7 @@ constructor(data,position,debugMessage){this.data=data,this.offset=position,this
|
|
|
1095
1095
|
/**
|
|
1096
1096
|
* Libera tutte le risorse caricate
|
|
1097
1097
|
*/
|
|
1098
|
-
async function clearmat(){for(const key in _textures)if(_textures[key]){const texture=await _textures[key];texture?.dispose()}for(const key in _smats)_smats[key]&&_smats[key]?.dispose();for(const[key,texOrPromise]of textureCache.entries()){const texture=texOrPromise instanceof Promise?await texOrPromise:texOrPromise;texture?.dispose&&texture.dispose()}textureCache.clear(),_textures={},_smats={}}return{clearmatricole:()=>{_gmatricole={}},islog:islog,clear:async function clear(){function destroymesh(mesh){function disposeMaterial(material){material.map&&material.map.dispose(),material.lightMap&&material.lightMap.dispose(),material.bumpMap&&material.bumpMap.dispose(),material.normalMap&&material.normalMap.dispose(),material.specularMap&&material.specularMap.dispose(),material.dispose()}mesh&&mesh.traverse((child=>{child.isMesh&&(child.geometry.dispose(),child.material&&(Array.isArray(child.material)?child.material.forEach(disposeMaterial):disposeMaterial(child.material)))}))}_gmatricole={},THREE.Cache.clear();for(const c in _geometries)_geometries[c]?.dispose();for(const key in _meshes)if(_meshes[key]){destroymesh(await _meshes[key])}await clearmat(),_movs={},_textures={},_meshes={},_geometries={},_smats={},_scripts={}},clearmat:clearmat,getScript:async function getScript(file){file.endsWith(".custom")?file=file.slice(-7):file.endsWith(".js")&&(file=file.slice(-3));let key=hash(`${getcat()}|${file}`);if(!_scripts[key]){let script;try{script=await P.fetch("mufiles/customfn",{id:getcat(),name:file,ispar:1})}catch(error){script=`log('undefined ${getcat()}/${file}: ${error.message}');`}_scripts[key]=script}return _scripts[key]},checkScripts:async function checkScripts(files){let cl=[];if(!files||!Array.isArray(files))return;let ct=getcat();for(let f of files){let key=hash(`${ct}|${f}`);_scripts[key]||cl.push(f)}if(cl?.length){let scripts=await P.fetch("mufiles/customfn",{id:ct,name:cl,ispar:1});if(scripts)for(let s of scripts){let key=hash(`${ct}|${s.n}`);_scripts[key]=s.v}}},get loaderGLTF(){return _loaderGLTF},get gmats(){return _gmatricole},scripts:()=>Object.keys(_scripts),get geo(){return _geometries},get movs(){return _movs},get textures(){return _textures},get smats(){return _smats},dump(){console.log(`SMATS:\n${Object.keys(_smats).join(" - ")};\nGEOMS:\n${Object.keys(_geometries).join(" - ")};\nTEX:\n${Object.keys(_textures).join(" - ")};\nMESH:\n${Object.keys(_meshes).join(" - ")};\n`)},get cat(){return getcat()},pushcat(cat){cats.push(cat)},popcat:()=>(cats.length>1&&cats.length--,getcat()),async tex(file,sx=1,sy,rot){sy||(sy=sx),rot||(rot=0);const key=hash(`${getcat()}|${file}|${sx}|${sy}|${rot}`);return _textures[key]||(_textures[key]=new Promise(((resolve,reject)=>{let url;if(file.startsWith("https://"))url=file;else if(P._cdn)if(file.includes("/")){let v=file.split("/");url=`${P._cdn}${v[0]}/textures/${v[1]}`}else url=`${P._cdn}${getcat()}/textures/${file}`;else url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:file,force:1});if(textureCache.has(url)){const tex=textureCache.get(url).clone();return tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,void resolve(tex)}_loadertex.load(url,(tex=>{textureCache.set(url,tex),tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,resolve(tex)}),void 0,(error=>{console.log(`Manca Texture ${file}!. questo rallenta molto il processo`),delete _textures[key],resolve(void 0)}))}))),_textures[key]},async get3ds(file,callback,ky=""){file.endsWith(".3ds")&&(file=file.slice(0,-4));const modifierKey=callback?hash(callback.toString()):"nomod",key=hash(`${getcat()}|${file}.3ds|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url,urlt="";file.startsWith("https://")?(url=`${file}.3ds`,urlt=url):P._cdn?(url=`${P._cdn}${getcat()}/3d/${file}.3ds`,urlt=`${P._cdn}${getcat()}/3d/${file}/`):(url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:".3ds"}),urlt=url+"&tex="),_loader3DS.setResourcePath(urlt),_loader3DS.load(url,(object=>{callback&&object.traverse((child=>{child.isMesh&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))})),resolve(object)}),void 0,(error=>{delete _meshes[key],resolve(void 0)}))}))),_meshes[key]},async getglb(file,textures,callback=null,ky=""){const ext=".glb";file.endsWith(ext)&&(file=file.slice(0,-4)),file.startsWith("https://")||(file=file.replace(/\//g,"+"));let elemento=(file=file.split("+"))[1];file=file[0],Array.isArray(textures)||(textures=[]);const modifierKey=callback?hash(callback.toString()):"nomod",texturesKey=textures.map((tex=>tex?.uuid||"null")).join("|"),key=hash(`${getcat()}|${file}${ext}|${texturesKey}|${modifierKey}|${ky}`);_meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url;url=file.startsWith("https://")?`${file}.glb`:P._cdn?`${P._cdn}${getcat()}/3d/${file}.glb`:P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:ext}),_loaderGLTF.setPath(""),_loaderGLTF.setResourcePath((resource=>(console.log("risorsa",resource),`${url}&tex=${resource}`))),_loaderGLTF.load(url,(async gltf=>{gltf.scene.traverse((child=>{if(child.isMesh){child.frustumCulled=!0;(Array.isArray(child.material)?child.material:[child.material]).forEach((material=>{if(!material||!material.map)return;const originalTexName=material.map.source?.data?.src;if(!originalTexName)return;const match=originalTexName.match(/(\d{2})\.jpg$/);if(!match)return;const textureIndex=parseInt(match[1]);textures[textureIndex]&&(material.map=textures[textureIndex],material.needsUpdate=!0)})),callback&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))}})),resolve(gltf.scene)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))})));let tm=_meshes[key];if(elemento){let n=tm?.getObjectByName(elemento);n&&(tm=n)}return tm}}}const originalMaterials=new Map;
|
|
1098
|
+
async function clearmat(){for(const key in _textures)if(_textures[key]){const texture=await _textures[key];texture?.dispose()}for(const key in _smats)_smats[key]&&_smats[key]?.dispose();for(const[key,texOrPromise]of textureCache.entries()){const texture=texOrPromise instanceof Promise?await texOrPromise:texOrPromise;texture?.dispose&&texture.dispose()}textureCache.clear(),_textures={},_smats={}}return{clearmatricole:()=>{_gmatricole={}},islog:islog,clear:async function clear(){function destroymesh(mesh){function disposeMaterial(material){material.map&&material.map.dispose(),material.lightMap&&material.lightMap.dispose(),material.bumpMap&&material.bumpMap.dispose(),material.normalMap&&material.normalMap.dispose(),material.specularMap&&material.specularMap.dispose(),material.dispose()}mesh&&mesh.traverse((child=>{child.isMesh&&(child.geometry.dispose(),child.material&&(Array.isArray(child.material)?child.material.forEach(disposeMaterial):disposeMaterial(child.material)))}))}_gmatricole={},THREE.Cache.clear();for(const c in _geometries)_geometries[c]?.dispose();for(const key in _meshes)if(_meshes[key]){destroymesh(await _meshes[key])}await clearmat(),_movs={},_textures={},_meshes={},_geometries={},_smats={},_scripts={}},clearmat:clearmat,getScript:async function getScript(file){file.endsWith(".custom")?file=file.slice(-7):file.endsWith(".js")&&(file=file.slice(-3));let key=hash(`${getcat()}|${file}`);if(!_scripts[key]){let script;try{script=await P.fetch("mufiles/customfn",{id:getcat(),name:file,ispar:1})}catch(error){script=`log('undefined ${getcat()}/${file}: ${error.message}');`}_scripts[key]=script}return _scripts[key]},checkScripts:async function checkScripts(files){let cl=[];if(!files||!Array.isArray(files))return;let ct=getcat();for(let f of files){let key=hash(`${ct}|${f}`);_scripts[key]||cl.push(f)}if(cl?.length){let scripts=await P.fetch("mufiles/customfn",{id:ct,name:cl,ispar:1});if(scripts)for(let s of scripts){let key=hash(`${ct}|${s.n}`);_scripts[key]=s.v}}},get loaderGLTF(){return _loaderGLTF},get gmats(){return _gmatricole},scripts:()=>Object.keys(_scripts),get geo(){return _geometries},get movs(){return _movs},get textures(){return _textures},get smats(){return _smats},get meshes(){return _meshes},dump(){console.log(`SMATS:\n${Object.keys(_smats).join(" - ")};\nGEOMS:\n${Object.keys(_geometries).join(" - ")};\nTEX:\n${Object.keys(_textures).join(" - ")};\nMESH:\n${Object.keys(_meshes).join(" - ")};\n`)},get cat(){return getcat()},pushcat(cat){cats.push(cat)},popcat:()=>(cats.length>1&&cats.length--,getcat()),async tex(file,sx=1,sy,rot){sy||(sy=sx),rot||(rot=0);const key=hash(`${getcat()}|${file}|${sx}|${sy}|${rot}`);return _textures[key]||(_textures[key]=new Promise(((resolve,reject)=>{let url;if(file.startsWith("https://"))url=file;else if(P._cdn)if(file.includes("/")){let v=file.split("/");url=`${P._cdn}${v[0]}/textures/${v[1]}`}else url=`${P._cdn}${getcat()}/textures/${file}`;else url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:file,force:1});if(textureCache.has(url)){const tex=textureCache.get(url).clone();return tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,void resolve(tex)}_loadertex.load(url,(tex=>{textureCache.set(url,tex),tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,resolve(tex)}),void 0,(error=>{console.log(`Manca Texture ${file}!. questo rallenta molto il processo`),delete _textures[key],resolve(void 0)}))}))),_textures[key]},async get3ds(file,callback,ky=""){file.endsWith(".3ds")&&(file=file.slice(0,-4));const modifierKey=callback?hash(callback.toString()):"nomod",key=hash(`${getcat()}|${file}.3ds|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url,urlt="";file.startsWith("https://")?(url=`${file}.3ds`,urlt=url):P._cdn?(url=`${P._cdn}${getcat()}/3d/${file}.3ds`,urlt=`${P._cdn}${getcat()}/3d/${file}/`):(url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:".3ds"}),urlt=url+"&tex="),_loader3DS.setResourcePath(urlt),_loader3DS.load(url,(object=>{callback&&object.traverse((child=>{child.isMesh&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))})),resolve(object)}),void 0,(error=>{delete _meshes[key],resolve(void 0)}))}))),_meshes[key]},async getglb(file,textures,callback=null,ky=""){const ext=".glb";file.endsWith(ext)&&(file=file.slice(0,-4)),file.startsWith("https://")||(file=file.replace(/\//g,"+"));let elemento=(file=file.split("+"))[1];file=file[0],Array.isArray(textures)||(textures=[]);const modifierKey=callback?hash(callback.toString()):"nomod",texturesKey=textures.map((tex=>tex?.uuid||"null")).join("|"),key=hash(`${getcat()}|${file}${ext}|${texturesKey}|${modifierKey}|${ky}`);_meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url;url=file.startsWith("https://")?`${file}.glb`:P._cdn?`${P._cdn}${getcat()}/3d/${file}.glb`:P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:ext}),_loaderGLTF.setPath(""),_loaderGLTF.setResourcePath((resource=>(console.log("risorsa",resource),`${url}&tex=${resource}`))),_loaderGLTF.load(url,(async gltf=>{gltf.scene.traverse((child=>{if(child.isMesh){child.frustumCulled=!0;(Array.isArray(child.material)?child.material:[child.material]).forEach((material=>{if(!material||!material.map)return;const originalTexName=material.map.source?.data?.src;if(!originalTexName)return;const match=originalTexName.match(/(\d{2})\.jpg$/);if(!match)return;const textureIndex=parseInt(match[1]);textures[textureIndex]&&(material.map=textures[textureIndex],material.needsUpdate=!0)})),callback&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))}})),resolve(gltf.scene)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))})));let tm=_meshes[key];if(elemento){let n=tm?.getObjectByName(elemento);n&&(tm=n)}return tm}}}const originalMaterials=new Map;
|
|
1099
1099
|
/**
|
|
1100
1100
|
* Salva i materiali originali di tutti i mesh nel gruppo (solo layer <= 20)
|
|
1101
1101
|
* @param {THREE.Object3D} gruppo
|
|
@@ -1115,4 +1115,4 @@ async function clearmat(){for(const key in _textures)if(_textures[key]){const te
|
|
|
1115
1115
|
* @param {THREE.Object3D} gruppo - oggetto root
|
|
1116
1116
|
* @param {Array<{ mats: string[], name?: string }>} matricole - elenco da evidenziare
|
|
1117
1117
|
* @returns {Promise<File[]>}
|
|
1118
|
-
*/async function evidenziaColli(gruppo,matricole,callback){salvaMaterialiOriginali(gruppo);const SIDE=THREE.DoubleSide,mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE});let ii=0;try{for(let mts of matricole)ii++,mts.name||(mts.name=`collo_${ii}`),applicaEvidenziazione(gruppo,mts.mats,mwhite,mgreen),await callback(mts)}catch(err){console.error("Errore durante evidenzia:",err)}finally{ripristinaMaterialiOriginali()}}function TODEG(a,dec=1){let C=10**dec;return Math.round(180*a*C/Math.PI)/C}function TORAD(a,dec=3){let C=10**dec;return Math.round(a*PIF*C)/C}const blocked={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(obj,exclude=[]){if(Array.isArray(obj))return obj.map((item=>getOggetto(item,exclude)));if(obj&&"object"==typeof obj){const result={};for(const[key,value]of Object.entries(obj))"function"==typeof value||exclude&&exclude.includes(key)||(result[key]=getOggetto(value,exclude));return result}return obj}async function evalcustomfunction(amb,code,values,objects){try{values||(values={}),objects||(objects={});const params={GCAD:!1,...values,A:amb,V:amb.vari,amb:amb,log:function addlog(...pars){const sanitized=pars.map((p=>getOggetto(p)));console.log(...sanitized)},Math:Math,clean:clean,SP:SP,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:PIF,getshape:getshape,shapeclip:shapeclip,...objects},paramNames=[...Object.keys(params),...Object.keys(blocked)],paramValues=[...Object.values(params),...Object.values(blocked)],fn=new Function(...paramNames,`\n try {\n return (async () => {\n ${code}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await fn(...paramValues)}catch(error){throw console.error("Errore durante l'esecuzione:",error),error}}function setLineColorMode(white){white?(materialline1.color.set(16777215),materialline2.color.set(16777215)):(materialline1.color.set(3158064),materialline2.color.set(5263440)),materialline1.needsUpdate=!0,materialline2.needsUpdate=!0}export{Linea2,Matrix3D,PIF,Punto2,SIDE,SP,TODEG,TORAD,Vis2d,addmovpivot,angle2vec,angle3point,blocked,calcolatasks,clamp,clean,creategroup,deletegroup,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,extractTextures,fondilinee,get3dshape,getOggetto,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter,getface,getfakeshadow,getfakeshadow2,getline,getlinesgeom,getmesh,getmovimento,getnodebyid,getpannello,getpoint,getprojectkeys,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,groupfromgeometry,hash,infoestrudi,isfn,ismacro,mapvertices,materialline1,materialline2,mblack,mblue,mgray1,mgray2,mgreen,mred,mwhite,newgcad,normal2,posiziona,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,salvaMaterialiOriginali,scaleunit,setLineColorMode,shapeclip,smat,spritemat,svuotanodo,valutagrafica};
|
|
1118
|
+
*/async function evidenziaColli(gruppo,matricole,callback){salvaMaterialiOriginali(gruppo);const SIDE=THREE.DoubleSide,mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE});let ii=0;try{for(let mts of matricole)ii++,mts.name||(mts.name=`collo_${ii}`),applicaEvidenziazione(gruppo,mts.mats,mwhite,mgreen),await callback(mts)}catch(err){console.error("Errore durante evidenzia:",err)}finally{ripristinaMaterialiOriginali()}}function TODEG(a,dec=1){let C=10**dec;return Math.round(180*a*C/Math.PI)/C}function TORAD(a,dec=3){let C=10**dec;return Math.round(a*PIF*C)/C}const blocked={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(obj,exclude=[]){if(Array.isArray(obj))return obj.map((item=>getOggetto(item,exclude)));if(obj&&"object"==typeof obj){const result={};for(const[key,value]of Object.entries(obj))"function"==typeof value||exclude&&exclude.includes(key)||(result[key]=getOggetto(value,exclude));return result}return obj}async function evalcustomfunction(amb,code,values,objects){try{values||(values={}),objects||(objects={});const params={GCAD:!1,...values,A:amb,V:amb.vari,amb:amb,log:function addlog(...pars){const sanitized=pars.map((p=>getOggetto(p)));console.log(...sanitized)},Math:Math,clean:clean,SP:SP,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:PIF,getshape:getshape,shapeclip:shapeclip,...objects},paramNames=[...Object.keys(params),...Object.keys(blocked)],paramValues=[...Object.values(params),...Object.values(blocked)],fn=new Function(...paramNames,`\n try {\n return (async () => {\n ${code}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await fn(...paramValues)}catch(error){throw console.error("Errore durante l'esecuzione:",error),error}}function setLineColorMode(white){white?(materialline1.color.set(16777215),materialline2.color.set(16777215)):(materialline1.color.set(3158064),materialline2.color.set(5263440)),materialline1.needsUpdate=!0,materialline2.needsUpdate=!0}export{Linea2,Matrix3D,PIF,Punto2,SIDE,SP,TODEG,TORAD,Vis2d,addmovpivot,angle2vec,angle3point,blocked,calcolatasks,clamp,clean,creategroup,deletegroup,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,extractTextures,fondilinee,get3dshape,getOggetto,getbb,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter$1 as getemitter,getextrude,getface,getfakeshadow,getfakeshadow2,getline,getlinesgeom,getmesh,getmovimento,getnodebyid,getpannello,getpoint,getprojectkeys,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,groupfromgeometry,hash,infoestrudi,isfn,ismacro,mapvertices,materialline1,materialline2,mblack,mblue,mgray1,mgray2,mgreen,mred,mwhite,newgcad,normal2,posiziona,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,salvaMaterialiOriginali,scalaoggetto,scaleunit,setLineColorMode,setorigine,shapeclip,smat,spritemat,svuotanodo,valutagrafica};
|
package/package.json
CHANGED
package/types/markcad.d.ts
CHANGED
|
@@ -364,6 +364,7 @@ export function extractTextures(root: any, baseName: any): Promise<any[]>;
|
|
|
364
364
|
export function fondilinee(linee: any): any[][];
|
|
365
365
|
export function get3dshape(punti: any, material: any, layer: any): any;
|
|
366
366
|
export function getOggetto(obj: any, exclude?: any[]): any;
|
|
367
|
+
export function getbb(obj: any, force?: boolean): any;
|
|
367
368
|
export function getbordi(oggetti: any, bordo: any): {
|
|
368
369
|
bordi: any[];
|
|
369
370
|
uguali: boolean;
|
|
@@ -387,16 +388,9 @@ export function getbox(gcad: any, x: any, y: any, z: any, mat: any, options: any
|
|
|
387
388
|
export function getcilindro(gcad: any, ori: string, h: number, r1: number, r2: number, mats: THREE.Material | any[], options: any): Promise<THREE.Group>;
|
|
388
389
|
export function getcyl(gcad: any, height: any, radius: any, mat: any, options: any): any;
|
|
389
390
|
export function getdumpmacro(nodo: any): string;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
* @param {number} x - Larghezza
|
|
394
|
-
* @param {number} y - Altezza
|
|
395
|
-
* @param {number} z - Profondità
|
|
396
|
-
* @param {THREE.Material} mat - Materiale da applicare
|
|
397
|
-
* @param {Object} options - Opzioni di configurazione
|
|
398
|
-
* @returns {Promise<THREE.Group>} Gruppo contenente il box
|
|
399
|
-
*/ export function getface(gcad: any, x: number, y: number, mat: THREE.Material, op?: {}): Promise<THREE.Group>;
|
|
391
|
+
declare function getemitter$1(data: any): any;
|
|
392
|
+
export function getextrude(gcad: any, pts: any, h?: number, holes?: any[], mat?: any, op?: {}): any;
|
|
393
|
+
export function getface(gcad: any, x: any, y: any, mat: any, op?: {}): any;
|
|
400
394
|
export function getfakeshadow(gcad: any, shape: any, alfa: any): any;
|
|
401
395
|
export function getfakeshadow2(w: any, h: any, map: any): any;
|
|
402
396
|
/**
|
|
@@ -471,7 +465,7 @@ export function getpunto(gcad: any, x: any, y: any, z: any, color: string, optio
|
|
|
471
465
|
* @param {number} sizetesto - Dimensione del testo
|
|
472
466
|
* @param {Object} options - Opzioni aggiuntive
|
|
473
467
|
* @returns {THREE.Group} Gruppo contenente la quota
|
|
474
|
-
*/ export function getquota(gcad: any, testo: string, x1: number, y1: number, x2: number, y2: number,
|
|
468
|
+
*/ export function getquota(gcad: any, testo: string, x1: number, y1: number, x2: number, y2: number, options?: any): THREE.Group;
|
|
475
469
|
export function getreceiver(gcad: any, data: any): any;
|
|
476
470
|
/**
|
|
477
471
|
* Crea un punto di riferimento invisibile nell'albero 3D
|
|
@@ -572,6 +566,7 @@ export function newgcad(P: any, _cat: any, islog?: boolean): {
|
|
|
572
566
|
readonly movs: {};
|
|
573
567
|
readonly textures: {};
|
|
574
568
|
readonly smats: {};
|
|
569
|
+
readonly meshes: {};
|
|
575
570
|
dump(): void;
|
|
576
571
|
readonly cat: any;
|
|
577
572
|
pushcat(cat: any): void;
|
|
@@ -606,8 +601,10 @@ export function revolve(gcad: any, shape: any, orient: any, mat: any, options: a
|
|
|
606
601
|
* Salva i materiali originali di tutti i mesh nel gruppo (solo layer <= 20)
|
|
607
602
|
* @param {THREE.Object3D} gruppo
|
|
608
603
|
*/ export function salvaMaterialiOriginali(gruppo: THREE.Object3D): void;
|
|
604
|
+
export function scalaoggetto(gcad: any, originale: any, scale?: {}): any;
|
|
609
605
|
export const scaleunit: 0.001;
|
|
610
606
|
export function setLineColorMode(white: any): void;
|
|
607
|
+
export function setorigine(obj: any, x?: number, y?: number, z?: number): any;
|
|
611
608
|
export function shapeclip(): {
|
|
612
609
|
offset(shape: any, delta: any, full?: boolean): any;
|
|
613
610
|
inflate: (shape: any, delta?: number, mantainorder?: boolean, isopen?: number) => any;
|
|
@@ -730,4 +727,4 @@ declare class GLTFLoader {
|
|
|
730
727
|
parse(data: any, path: any, onLoad: any, onError: any): any;
|
|
731
728
|
parseAsync(data: any, path: any): Promise<any>;
|
|
732
729
|
}
|
|
733
|
-
export {};
|
|
730
|
+
export { getemitter$1 as getemitter };
|