pptx-vanilla-viewer 3.0.0 → 3.1.0
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/CHANGELOG.md +6 -0
- package/dist/{ai-panel-LZOXHVK4.js → ai-panel-TNS5GMNT.js} +1 -1
- package/dist/{ai-panel-REIQXI4X.cjs → ai-panel-UQU4RDXH.cjs} +1 -1
- package/dist/{chunk-RCLS4YA2.js → chunk-3JY5CPM5.js} +298 -294
- package/dist/{chunk-2OHFOCQA.js → chunk-3KAN5NGI.js} +24 -24
- package/dist/{chunk-JTYS5UQN.js → chunk-H3EVSCTR.js} +3 -3
- package/dist/{chunk-T4DCDAP3.cjs → chunk-HWJJ5QG2.cjs} +24 -24
- package/dist/{chunk-3JOXWH72.cjs → chunk-NVO6GK3B.cjs} +298 -294
- package/dist/{chunk-V5EVLAGC.cjs → chunk-O7JVE7YG.cjs} +3 -3
- package/dist/i18n/de.cjs +2 -0
- package/dist/i18n/de.mjs +2 -0
- package/dist/i18n/es.cjs +2 -0
- package/dist/i18n/es.mjs +2 -0
- package/dist/i18n/fr.cjs +2 -0
- package/dist/i18n/fr.mjs +2 -0
- package/dist/i18n/zh-CN.cjs +2 -0
- package/dist/i18n/zh-CN.mjs +2 -0
- package/dist/index.cjs +63 -63
- package/dist/index.d.ts +335 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -63
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +1 -1
- package/dist/smartart-3d-IBFV63QB.cjs +1 -0
- package/dist/smartart-3d-SLCPNIFS.js +1 -0
- package/dist/{transition-overlay-CcDuw_PK.d.ts → transition-overlay-DAd59XX1.d.ts} +562 -2
- package/dist/{transition-overlay-CcDuw_PK.d.ts.map → transition-overlay-DAd59XX1.d.ts.map} +1 -1
- package/package.json +2 -2
- package/dist/smartart-3d-4XR267AX.cjs +0 -1
- package/dist/smartart-3d-5ELDYNIY.js +0 -1
package/dist/internals.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkO7JVE7YG_cjs=require('./chunk-O7JVE7YG.cjs'),chunkNVO6GK3B_cjs=require('./chunk-NVO6GK3B.cjs');require('./chunk-B5PFHICE.cjs');Object.defineProperty(exports,"playTransitionOverlay",{enumerable:true,get:function(){return chunkO7JVE7YG_cjs.d}});Object.defineProperty(exports,"CINEMATIC_TRANSITION_KEYFRAMES",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Ph}});Object.defineProperty(exports,"DEFAULT_MORPH_DURATION_MS",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Gh}});Object.defineProperty(exports,"DEFAULT_TRANSITION_DURATION_MS",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Fh}});Object.defineProperty(exports,"EASE",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Ih}});Object.defineProperty(exports,"INSTANT",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Eh}});Object.defineProperty(exports,"P14_TRANSITION_KEYFRAMES",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Lh}});Object.defineProperty(exports,"P14_TRANSITION_KEYFRAMES_2",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Mh}});Object.defineProperty(exports,"P14_TRANSITION_KEYFRAMES_ALL",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Nh}});Object.defineProperty(exports,"RANDOM_ELIGIBLE_TYPES",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Dh}});Object.defineProperty(exports,"SLIDE_TRANSITION_KEYFRAMES",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Rh}});Object.defineProperty(exports,"SLIDE_TRANSITION_KEYFRAMES_CSS",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Sh}});Object.defineProperty(exports,"TRANSITION_SPEED_DURATION_MS",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Hh}});Object.defineProperty(exports,"WHEEL_SPOKE_COUNTS",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Jh}});Object.defineProperty(exports,"getCinematicTransitionAnimations",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Oh}});Object.defineProperty(exports,"getP14TransitionAnimations",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Th}});Object.defineProperty(exports,"getSlideTransitionAnimations",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Uh}});Object.defineProperty(exports,"resolveDirection",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Ah}});Object.defineProperty(exports,"resolveDirection8",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Bh}});Object.defineProperty(exports,"resolveOrientation",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Ch}});Object.defineProperty(exports,"resolveSlideTransition",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Vh}});Object.defineProperty(exports,"resolveTransitionDurationMs",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Wh}});Object.defineProperty(exports,"resolveWheelSpokeCount",{enumerable:true,get:function(){return chunkNVO6GK3B_cjs.Kh}});
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Et as WHEEL_SPOKE_COUNTS, Ft as getSlideTransitionAnimations, Gt as resolveDirection8, H as P14_TRANSITION_KEYFRAMES, Jt as resolveTransitionDurationMs, Kt as resolveOrientation, Mt as getCinematicTransitionAnimations, N as INSTANT, Nt as getP14TransitionAnimations, Q as RANDOM_ELIGIBLE_TYPES, S as EASE, U as P14_TRANSITION_KEYFRAMES_2, W as P14_TRANSITION_KEYFRAMES_ALL, Wt as resolveDirection, Yt as resolveWheelSpokeCount, b as DEFAULT_MORPH_DURATION_MS, gt as SlideTransitionAnimations, n as playTransitionOverlay, nt as ResolvedDirection8, ot as SLIDE_TRANSITION_KEYFRAMES, qt as resolveSlideTransition, s as CINEMATIC_TRANSITION_KEYFRAMES, st as SLIDE_TRANSITION_KEYFRAMES_CSS, t as TransitionOverlayParams, tt as ResolvedDirection, vt as TRANSITION_SPEED_DURATION_MS, x as DEFAULT_TRANSITION_DURATION_MS } from "./transition-overlay-DAd59XX1.js";
|
|
2
2
|
export { CINEMATIC_TRANSITION_KEYFRAMES, DEFAULT_MORPH_DURATION_MS, DEFAULT_TRANSITION_DURATION_MS, EASE, INSTANT, P14_TRANSITION_KEYFRAMES, P14_TRANSITION_KEYFRAMES_2, P14_TRANSITION_KEYFRAMES_ALL, RANDOM_ELIGIBLE_TYPES, type ResolvedDirection, type ResolvedDirection8, SLIDE_TRANSITION_KEYFRAMES, SLIDE_TRANSITION_KEYFRAMES_CSS, type SlideTransitionAnimations, TRANSITION_SPEED_DURATION_MS, type TransitionOverlayParams, WHEEL_SPOKE_COUNTS, getCinematicTransitionAnimations, getP14TransitionAnimations, getSlideTransitionAnimations, playTransitionOverlay, resolveDirection, resolveDirection8, resolveOrientation, resolveSlideTransition, resolveTransitionDurationMs, resolveWheelSpokeCount };
|
package/dist/internals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as playTransitionOverlay}from'./chunk-
|
|
1
|
+
export{d as playTransitionOverlay}from'./chunk-H3EVSCTR.js';export{Ph as CINEMATIC_TRANSITION_KEYFRAMES,Gh as DEFAULT_MORPH_DURATION_MS,Fh as DEFAULT_TRANSITION_DURATION_MS,Ih as EASE,Eh as INSTANT,Lh as P14_TRANSITION_KEYFRAMES,Mh as P14_TRANSITION_KEYFRAMES_2,Nh as P14_TRANSITION_KEYFRAMES_ALL,Dh as RANDOM_ELIGIBLE_TYPES,Rh as SLIDE_TRANSITION_KEYFRAMES,Sh as SLIDE_TRANSITION_KEYFRAMES_CSS,Hh as TRANSITION_SPEED_DURATION_MS,Jh as WHEEL_SPOKE_COUNTS,Oh as getCinematicTransitionAnimations,Th as getP14TransitionAnimations,Uh as getSlideTransitionAnimations,Ah as resolveDirection,Bh as resolveDirection8,Ch as resolveOrientation,Vh as resolveSlideTransition,Wh as resolveTransitionDurationMs,Kh as resolveWheelSpokeCount}from'./chunk-3JY5CPM5.js';import'./chunk-62D2TNHX.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('./chunk-B5PFHICE.cjs');var three=require('three'),OrbitControls_js=require('three/examples/jsm/controls/OrbitControls.js');var L=4,H=.86;function ft(e,t,n){let o=t.split(/\s+/u).filter(Boolean);if(o.length===0)return [];let i=[],a=o[0];for(let s=1;s<o.length;s++){let r=`${a} ${o[s]}`;e.measureText(r).width<=n?a=r:(i.push(a),a=o[s]);}return i.push(a),i}function dt(e,t){let n=t?.bold===void 0?"600":t.bold?"700":"400",o=t?.italic?"italic ":"",i=typeof t?.fontScale=="number"&&Number.isFinite(t.fontScale)&&t.fontScale>0?t.fontScale:1;return {weight:n,italic:o,color:t?.color??e,scale:i}}function ht(e,t,n,o,i,a){if(typeof document>"u"||!e.trim()||o<=0||i<=0)return null;let{weight:s,italic:r,color:c,scale:h}=dt(t,a),v=o*H,w=i*H,f=document.createElement("canvas");f.width=Math.max(8,Math.round(v*L)),f.height=Math.max(8,Math.round(w*L));let l=f.getContext("2d");if(!l)return null;let M="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",g=f.width*.94,m=y=>`${r}${s} ${y}px ${M}`,p=Math.max(6,n)*h*L,b=[];for(let y=0;y<12;y++){l.font=m(p),b=ft(l,e,g);let x=p*1.2;if(b.length*x<=f.height*.96||p<=6*L)break;p*=.88;}l.clearRect(0,0,f.width,f.height),l.fillStyle=c,l.textAlign="center",l.textBaseline="middle",l.font=m(p);let d=p*1.2,F=b.length*d,S=f.height/2-F/2+d/2;for(let y=0;y<b.length;y++){let x=S+y*d;if(l.fillText(b[y],f.width/2,x),a?.underline){let z=l.measureText(b[y]).width;l.strokeStyle=c,l.lineWidth=Math.max(1,p*.06),l.beginPath(),l.moveTo(f.width/2-z/2,x+p*.32),l.lineTo(f.width/2+z/2,x+p*.32),l.stroke();}}let u=new three.CanvasTexture(f);return u.colorSpace=three.SRGBColorSpace,u.minFilter=three.LinearFilter,u.magFilter=three.LinearFilter,u.flipY=false,u.premultiplyAlpha=false,u.wrapT=three.RepeatWrapping,u.repeat.set(1,-1),u.offset.set(0,1),u.needsUpdate=true,{texture:u,worldWidth:v,worldHeight:w}}function pt(e){let t=new three.Shape;e.outline.forEach((o,i)=>{i===0?t.moveTo(o.x,o.y):t.lineTo(o.x,o.y);}),t.closePath();let n=e.bevel>0;return new three.ExtrudeGeometry(t,{depth:e.depth,bevelEnabled:n,bevelThickness:e.bevel,bevelSize:e.bevel,bevelSegments:2,curveSegments:e.rounded?24:1,steps:1})}function ut(e,t,n){let o=pt(n),i=new three.MeshStandardMaterial({color:new three.Color(n.fill),metalness:.12,roughness:.52,transparent:n.opacity<1,opacity:n.opacity}),a=new three.Mesh(o,i);if(a.position.set(n.position.x,n.position.y,n.position.z),a.rotation.set(n.rotation.x,n.rotation.y,n.rotation.z),e.add(a),t.push(o,i),n.strokeWidth>0){let s=new three.EdgesGeometry(o,30),r=new three.LineBasicMaterial({color:new three.Color(n.stroke)}),c=new three.LineSegments(s,r);c.position.copy(a.position),c.rotation.copy(a.rotation),e.add(c),t.push(s,r);}return o}function W(e,t){if(!e.text)return null;let n=ht(e.text,e.textColor,e.fontSize,e.halfWidth*2,e.halfHeight*2,t);if(!n)return null;let o=new three.PlaneGeometry(n.worldWidth,n.worldHeight),i=new three.MeshBasicMaterial({map:n.texture,transparent:true,depthWrite:false,depthTest:false,side:three.DoubleSide}),a=new three.Mesh(o,i);a.renderOrder=1;let s=new three.Euler(e.rotation.x,e.rotation.y,e.rotation.z),r=new three.Vector3(0,0,e.depth+e.bevel+.4).applyEuler(s);return a.position.set(e.position.x+r.x,e.position.y+r.y,e.position.z+r.z),a.rotation.copy(s),{plane:a,disposables:[o,i,n.texture]}}function xt(e,t,n){for(let o of n.connectors){if(o.points.length<2)continue;let i=new three.BufferGeometry().setFromPoints(o.points.map(s=>new three.Vector3(s.x,s.y,s.z))),a=new three.LineBasicMaterial({color:new three.Color(o.color),transparent:true,opacity:.7});e.add(new three.Line(i,a)),t.push(i,a);}}function D(e,t){t.plane&&e.remove(t.plane);for(let n of t.disposables)n.dispose();t.plane=null,t.disposables=[];}function yt(e,t){let n=new three.Group,o=[],i=e.meshes.map(a=>{ut(n,o,a);let s=W(a,t);return s&&n.add(s.plane),{node:a,plane:s?.plane??null,disposables:s?.disposables??[]}});return xt(n,o,e),{group:n,setTextStyle(a){for(let s of i){D(n,s);let r=W(s.node,a);r&&(n.add(r.plane),s.plane=r.plane,s.disposables=r.disposables);}},forEachLabelPlane(a){for(let s of i)s.plane&&a(s.plane);},dispose(){for(let a of o)a.dispose();for(let a of i)D(n,a);}}}var I=42;function bt(e,t){let n=t.halfWidth+t.bevel,o=t.halfHeight+t.bevel,i=t.depth/2+t.bevel,a=t.position.z+t.depth/2,s=Math.cos(t.rotation.y),r=Math.sin(t.rotation.y),c=Math.abs(n*s)+Math.abs(i*r),h=Math.abs(n*r)+Math.abs(i*s);e(t.position.x,t.position.y,a,c,o,h);}function wt(e){let t=1/0,n=1/0,o=1/0,i=-1/0,a=-1/0,s=-1/0,r=(c,h,v,w,f,l)=>{t=Math.min(t,c-w),n=Math.min(n,h-f),o=Math.min(o,v-l),i=Math.max(i,c+w),a=Math.max(a,h+f),s=Math.max(s,v+l);};for(let c of e.meshes)bt(r,c);for(let c of e.connectors)for(let h of c.points)r(h.x,h.y,h.z,1,1,1);if(!Number.isFinite(t)){let c=e.bounds.width/2||1,h=e.bounds.height/2||1;return {cx:0,cy:0,cz:0,radius:Math.max(c,h),halfW:c,halfH:h,halfD:1}}return {cx:(t+i)/2,cy:(n+a)/2,cz:(o+s)/2,radius:.5*Math.hypot(i-t,a-n,s-o)||1,halfW:(i-t)/2,halfH:(a-n)/2,halfD:(s-o)/2}}function Mt(e,t){let n=I*Math.PI/180,o=2*Math.atan(Math.tan(n/2)*t),i=Math.min(n,o);return e/Math.sin(i/2)*1.1}var gt=.92;function G(e,t,n){let{cx:o,cy:i,cz:a,radius:s}=e,r=zt(t,s,n);return {position:[o+s*.25,i+r,a+n],target:[o,i,a],dist:n}}function vt(e,t,n){let o=I*Math.PI/180,i=Math.tan(o/2),a=i*n,[s,r,c]=t.position,[h,v,w]=t.target,f=h-s,l=v-r,M=w-c,g=Math.hypot(f,l,M)||1;f/=g,l/=g,M/=g;let m=-M,p=f,b=Math.hypot(m,p)||1;m/=b,p/=b;let d=-p*l,F=p*f-m*M,S=m*l,u=0;for(let y of [-1,1])for(let x of [-1,1])for(let z of [-1,1]){let E=e.cx+y*e.halfW-s,R=e.cy+x*e.halfH-r,P=e.cz+z*e.halfD-c,T=E*f+R*l+P*M;if(T<=1e-6)return 1/0;let O=Math.abs(E*m+P*p)/(T*a),N=Math.abs(E*d+R*F+P*S)/(T*i);u=Math.max(u,O,N);}return u}function mt(e,t,n){let o=Mt(e.radius,n),i=G(e,t,o);for(let a=0;a<8;a++){let s=vt(e,i,n);if(!Number.isFinite(s))o*=2;else {let r=s/gt;if(Math.abs(r-1)<.01)break;o*=r;}i=G(e,t,o);}return i}var St=34;function zt(e,t,n){return e==="cycle"||e==="radial"?n*Math.tan(St*Math.PI/180):t*.3}function Ft(e,t){e.forEachLabelPlane(n=>{let o=t.position.x-n.position.x,i=t.position.z-n.position.z;n.rotation.set(0,Math.atan2(o,i),0);});}function Et(e,t,n,o,i={}){let a=new three.WebGLRenderer({canvas:e,antialias:true,alpha:!i.background});a.setPixelRatio(Math.min(typeof window>"u"?1:window.devicePixelRatio||1,i.maxPixelRatio??2)),a.setSize(n,o,false);let s=new three.Scene;i.background&&(s.background=new three.Color(i.background));let r=wt(t),{cx:c,cy:h,cz:v,radius:w}=r,f=n/Math.max(1,o),l=mt(r,t.family,f),{dist:M}=l,g=new three.PerspectiveCamera(I,f,.1,M*8+w*4);g.position.set(...l.position),g.lookAt(...l.target),s.add(new three.AmbientLight(16777215,.62));let m=new three.DirectionalLight(16777215,.95);m.position.set(c+w,h+w*1.4,v+M),s.add(m);let p=new three.DirectionalLight(16777215,.3);p.position.set(c-w,h-w*.6,v+M*.6),s.add(p);let b=yt(t,i.textStyle);s.add(b.group);let d=null,F=x=>{x&&!d?(d=new OrbitControls_js.OrbitControls(g,e),d.enablePan=false,d.target.set(c,h,v),d.minDistance=M*.4,d.maxDistance=M*3,d.update()):!x&&d&&(d.dispose(),d=null),d&&(d.autoRotate=!!i.autoRotate,d.autoRotateSpeed=1.2);};F(!!i.interactive);let S=0,u=false,y=()=>{u||(S=requestAnimationFrame(y),Ft(b,g),d?.update(),a.render(s,g));};return S=requestAnimationFrame(y),{resize(x,z){g.aspect=x/Math.max(1,z),g.updateProjectionMatrix(),a.setSize(x,z,false);},setInteractive(x){F(x);},setTextStyle(x){b.setTextStyle(x);},dispose(){u=true,cancelAnimationFrame(S),d?.dispose(),b.dispose(),a.dispose();}}}exports.mountSmartArt3D=Et;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-62D2TNHX.js';import {WebGLRenderer,Scene,Color,PerspectiveCamera,AmbientLight,DirectionalLight,Group,MeshStandardMaterial,Mesh,EdgesGeometry,LineBasicMaterial,LineSegments,PlaneGeometry,MeshBasicMaterial,DoubleSide,Euler,Vector3,BufferGeometry,Line,Shape,ExtrudeGeometry,CanvasTexture,SRGBColorSpace,LinearFilter,RepeatWrapping}from'three';import {OrbitControls}from'three/examples/jsm/controls/OrbitControls.js';var L=4,H=.86;function ft(e,t,n){let o=t.split(/\s+/u).filter(Boolean);if(o.length===0)return [];let i=[],a=o[0];for(let s=1;s<o.length;s++){let r=`${a} ${o[s]}`;e.measureText(r).width<=n?a=r:(i.push(a),a=o[s]);}return i.push(a),i}function dt(e,t){let n=t?.bold===void 0?"600":t.bold?"700":"400",o=t?.italic?"italic ":"",i=typeof t?.fontScale=="number"&&Number.isFinite(t.fontScale)&&t.fontScale>0?t.fontScale:1;return {weight:n,italic:o,color:t?.color??e,scale:i}}function ht(e,t,n,o,i,a){if(typeof document>"u"||!e.trim()||o<=0||i<=0)return null;let{weight:s,italic:r,color:c,scale:h}=dt(t,a),v=o*H,w=i*H,f=document.createElement("canvas");f.width=Math.max(8,Math.round(v*L)),f.height=Math.max(8,Math.round(w*L));let l=f.getContext("2d");if(!l)return null;let M="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",g=f.width*.94,m=y=>`${r}${s} ${y}px ${M}`,p=Math.max(6,n)*h*L,b=[];for(let y=0;y<12;y++){l.font=m(p),b=ft(l,e,g);let x=p*1.2;if(b.length*x<=f.height*.96||p<=6*L)break;p*=.88;}l.clearRect(0,0,f.width,f.height),l.fillStyle=c,l.textAlign="center",l.textBaseline="middle",l.font=m(p);let d=p*1.2,F=b.length*d,S=f.height/2-F/2+d/2;for(let y=0;y<b.length;y++){let x=S+y*d;if(l.fillText(b[y],f.width/2,x),a?.underline){let z=l.measureText(b[y]).width;l.strokeStyle=c,l.lineWidth=Math.max(1,p*.06),l.beginPath(),l.moveTo(f.width/2-z/2,x+p*.32),l.lineTo(f.width/2+z/2,x+p*.32),l.stroke();}}let u=new CanvasTexture(f);return u.colorSpace=SRGBColorSpace,u.minFilter=LinearFilter,u.magFilter=LinearFilter,u.flipY=false,u.premultiplyAlpha=false,u.wrapT=RepeatWrapping,u.repeat.set(1,-1),u.offset.set(0,1),u.needsUpdate=true,{texture:u,worldWidth:v,worldHeight:w}}function pt(e){let t=new Shape;e.outline.forEach((o,i)=>{i===0?t.moveTo(o.x,o.y):t.lineTo(o.x,o.y);}),t.closePath();let n=e.bevel>0;return new ExtrudeGeometry(t,{depth:e.depth,bevelEnabled:n,bevelThickness:e.bevel,bevelSize:e.bevel,bevelSegments:2,curveSegments:e.rounded?24:1,steps:1})}function ut(e,t,n){let o=pt(n),i=new MeshStandardMaterial({color:new Color(n.fill),metalness:.12,roughness:.52,transparent:n.opacity<1,opacity:n.opacity}),a=new Mesh(o,i);if(a.position.set(n.position.x,n.position.y,n.position.z),a.rotation.set(n.rotation.x,n.rotation.y,n.rotation.z),e.add(a),t.push(o,i),n.strokeWidth>0){let s=new EdgesGeometry(o,30),r=new LineBasicMaterial({color:new Color(n.stroke)}),c=new LineSegments(s,r);c.position.copy(a.position),c.rotation.copy(a.rotation),e.add(c),t.push(s,r);}return o}function W(e,t){if(!e.text)return null;let n=ht(e.text,e.textColor,e.fontSize,e.halfWidth*2,e.halfHeight*2,t);if(!n)return null;let o=new PlaneGeometry(n.worldWidth,n.worldHeight),i=new MeshBasicMaterial({map:n.texture,transparent:true,depthWrite:false,depthTest:false,side:DoubleSide}),a=new Mesh(o,i);a.renderOrder=1;let s=new Euler(e.rotation.x,e.rotation.y,e.rotation.z),r=new Vector3(0,0,e.depth+e.bevel+.4).applyEuler(s);return a.position.set(e.position.x+r.x,e.position.y+r.y,e.position.z+r.z),a.rotation.copy(s),{plane:a,disposables:[o,i,n.texture]}}function xt(e,t,n){for(let o of n.connectors){if(o.points.length<2)continue;let i=new BufferGeometry().setFromPoints(o.points.map(s=>new Vector3(s.x,s.y,s.z))),a=new LineBasicMaterial({color:new Color(o.color),transparent:true,opacity:.7});e.add(new Line(i,a)),t.push(i,a);}}function D(e,t){t.plane&&e.remove(t.plane);for(let n of t.disposables)n.dispose();t.plane=null,t.disposables=[];}function yt(e,t){let n=new Group,o=[],i=e.meshes.map(a=>{ut(n,o,a);let s=W(a,t);return s&&n.add(s.plane),{node:a,plane:s?.plane??null,disposables:s?.disposables??[]}});return xt(n,o,e),{group:n,setTextStyle(a){for(let s of i){D(n,s);let r=W(s.node,a);r&&(n.add(r.plane),s.plane=r.plane,s.disposables=r.disposables);}},forEachLabelPlane(a){for(let s of i)s.plane&&a(s.plane);},dispose(){for(let a of o)a.dispose();for(let a of i)D(n,a);}}}var I=42;function bt(e,t){let n=t.halfWidth+t.bevel,o=t.halfHeight+t.bevel,i=t.depth/2+t.bevel,a=t.position.z+t.depth/2,s=Math.cos(t.rotation.y),r=Math.sin(t.rotation.y),c=Math.abs(n*s)+Math.abs(i*r),h=Math.abs(n*r)+Math.abs(i*s);e(t.position.x,t.position.y,a,c,o,h);}function wt(e){let t=1/0,n=1/0,o=1/0,i=-1/0,a=-1/0,s=-1/0,r=(c,h,v,w,f,l)=>{t=Math.min(t,c-w),n=Math.min(n,h-f),o=Math.min(o,v-l),i=Math.max(i,c+w),a=Math.max(a,h+f),s=Math.max(s,v+l);};for(let c of e.meshes)bt(r,c);for(let c of e.connectors)for(let h of c.points)r(h.x,h.y,h.z,1,1,1);if(!Number.isFinite(t)){let c=e.bounds.width/2||1,h=e.bounds.height/2||1;return {cx:0,cy:0,cz:0,radius:Math.max(c,h),halfW:c,halfH:h,halfD:1}}return {cx:(t+i)/2,cy:(n+a)/2,cz:(o+s)/2,radius:.5*Math.hypot(i-t,a-n,s-o)||1,halfW:(i-t)/2,halfH:(a-n)/2,halfD:(s-o)/2}}function Mt(e,t){let n=I*Math.PI/180,o=2*Math.atan(Math.tan(n/2)*t),i=Math.min(n,o);return e/Math.sin(i/2)*1.1}var gt=.92;function G(e,t,n){let{cx:o,cy:i,cz:a,radius:s}=e,r=zt(t,s,n);return {position:[o+s*.25,i+r,a+n],target:[o,i,a],dist:n}}function vt(e,t,n){let o=I*Math.PI/180,i=Math.tan(o/2),a=i*n,[s,r,c]=t.position,[h,v,w]=t.target,f=h-s,l=v-r,M=w-c,g=Math.hypot(f,l,M)||1;f/=g,l/=g,M/=g;let m=-M,p=f,b=Math.hypot(m,p)||1;m/=b,p/=b;let d=-p*l,F=p*f-m*M,S=m*l,u=0;for(let y of [-1,1])for(let x of [-1,1])for(let z of [-1,1]){let E=e.cx+y*e.halfW-s,R=e.cy+x*e.halfH-r,P=e.cz+z*e.halfD-c,T=E*f+R*l+P*M;if(T<=1e-6)return 1/0;let O=Math.abs(E*m+P*p)/(T*a),N=Math.abs(E*d+R*F+P*S)/(T*i);u=Math.max(u,O,N);}return u}function mt(e,t,n){let o=Mt(e.radius,n),i=G(e,t,o);for(let a=0;a<8;a++){let s=vt(e,i,n);if(!Number.isFinite(s))o*=2;else {let r=s/gt;if(Math.abs(r-1)<.01)break;o*=r;}i=G(e,t,o);}return i}var St=34;function zt(e,t,n){return e==="cycle"||e==="radial"?n*Math.tan(St*Math.PI/180):t*.3}function Ft(e,t){e.forEachLabelPlane(n=>{let o=t.position.x-n.position.x,i=t.position.z-n.position.z;n.rotation.set(0,Math.atan2(o,i),0);});}function Et(e,t,n,o,i={}){let a=new WebGLRenderer({canvas:e,antialias:true,alpha:!i.background});a.setPixelRatio(Math.min(typeof window>"u"?1:window.devicePixelRatio||1,i.maxPixelRatio??2)),a.setSize(n,o,false);let s=new Scene;i.background&&(s.background=new Color(i.background));let r=wt(t),{cx:c,cy:h,cz:v,radius:w}=r,f=n/Math.max(1,o),l=mt(r,t.family,f),{dist:M}=l,g=new PerspectiveCamera(I,f,.1,M*8+w*4);g.position.set(...l.position),g.lookAt(...l.target),s.add(new AmbientLight(16777215,.62));let m=new DirectionalLight(16777215,.95);m.position.set(c+w,h+w*1.4,v+M),s.add(m);let p=new DirectionalLight(16777215,.3);p.position.set(c-w,h-w*.6,v+M*.6),s.add(p);let b=yt(t,i.textStyle);s.add(b.group);let d=null,F=x=>{x&&!d?(d=new OrbitControls(g,e),d.enablePan=false,d.target.set(c,h,v),d.minDistance=M*.4,d.maxDistance=M*3,d.update()):!x&&d&&(d.dispose(),d=null),d&&(d.autoRotate=!!i.autoRotate,d.autoRotateSpeed=1.2);};F(!!i.interactive);let S=0,u=false,y=()=>{u||(S=requestAnimationFrame(y),Ft(b,g),d?.update(),a.render(s,g));};return S=requestAnimationFrame(y),{resize(x,z){g.aspect=x/Math.max(1,z),g.updateProjectionMatrix(),a.setSize(x,z,false);},setInteractive(x){F(x);},setTextStyle(x){b.setTextStyle(x);},dispose(){u=true,cancelAnimationFrame(S),d?.dispose(),b.dispose(),a.dispose();}}}export{Et as mountSmartArt3D};
|