@glyphcss/vue 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{CAMERA_BACKFACE_CULL_EPS as Ns,VOXEL_CAMERA_CULL_AXIS_EPS as zs,VOXEL_CAMERA_CULL_NORMAL_LIMIT as Ks,normalizePolygons as Xs,mergePolygons as Ys,coverPlanarPolygons as _s,optimizeMeshPolygons as Ds,cullInteriorPolygons as Is,cameraCullNormalGroups as Us,cameraCullNormalGroupsFromPolygons as qs,cameraCullNormalKey as $s,cameraCullVisibleSignature as Js,cameraFacingDepth as Ws,isAxisAlignedSurfaceNormal as Qs,isVoxelCameraCullableNormalGroups as Zs,normalFacesCamera as eo,polygonCssSurfaceNormal as to,polygonFacesCamera as so,parseObj as oo,parseMtl as no,parseGltf as ro,bakeSolidTextureSamples as lo,bakeSolidTextureSampledPolygons as ao,loadMesh as co,createIsometricCamera as io,parseVox as po,polygonFaces as uo,computeShapeLighting as mo,parseColor as yo,parsePureColor as ho,parseHexColor as fo,parseRgbColor as Go,formatColor as Co,clampChannel as go,shadeColor as vo,rotateVec3 as bo,inverseRotateVec3 as xo,axesHelperPolygons as Po,arrowPolygons as Ao,ringPolygons as So,octahedronPolygons as wo,buildSceneContext as Ro,computeSceneBbox as Oo,BASE_TILE as Mo,DEFAULT_CAMERA_STATE as Lo,DEFAULT_PROJECTION as To,normalizeInvertMultiplier as Ho,createGlyphcssAnimationMixer as Vo,LoopOnce as ko,LoopRepeat as jo,LoopPingPong as Bo}from"@glyphcss/core";import{defineComponent as X,h as Y,provide as _,shallowRef as k,onMounted as D,onBeforeUnmount as I,watch as U}from"vue";import{createGlyphcssScene as q,injectGlyphcssBaseStyles as $}from"glyphcss";var i=Symbol("glyphcss-scene");var x=X({name:"GlyphcssScene",inheritAttrs:!1,props:{mode:{type:String,default:void 0},glyphPalette:{type:String,default:void 0},useColors:{type:Boolean,default:void 0},cols:{type:Number,default:void 0},rows:{type:Number,default:void 0},cellAspect:{type:Number,default:void 0},directionalLight:{type:Object,default:void 0},ambientLight:{type:Object,default:void 0},class:{type:String,default:void 0}},setup(e,{slots:a,attrs:c}){let n=k(null),s=k(null);return _(i,{sceneRef:s}),D(()=>{let o=n.value;if(!o)return;$(o.ownerDocument??void 0);let t={};e.mode!==void 0&&(t.mode=e.mode),e.glyphPalette!==void 0&&(t.glyphPalette=e.glyphPalette),e.useColors!==void 0&&(t.useColors=e.useColors),e.cols!==void 0&&(t.cols=e.cols),e.rows!==void 0&&(t.rows=e.rows),e.cellAspect!==void 0&&(t.cellAspect=e.cellAspect),e.directionalLight!==void 0&&(t.directionalLight=e.directionalLight),e.ambientLight!==void 0&&(t.ambientLight=e.ambientLight),s.value=q(o,t)}),I(()=>{s.value?.destroy(),s.value=null}),U(()=>({mode:e.mode,glyphPalette:e.glyphPalette,useColors:e.useColors,cols:e.cols,rows:e.rows,cellAspect:e.cellAspect,directionalLight:e.directionalLight,ambientLight:e.ambientLight}),o=>{let t=s.value;if(!t)return;let r={};o.mode!==void 0&&(r.mode=o.mode),o.glyphPalette!==void 0&&(r.glyphPalette=o.glyphPalette),o.useColors!==void 0&&(r.useColors=o.useColors),o.cols!==void 0&&(r.cols=o.cols),o.rows!==void 0&&(r.rows=o.rows),o.cellAspect!==void 0&&(r.cellAspect=o.cellAspect),o.directionalLight!==void 0&&(r.directionalLight=o.directionalLight),o.ambientLight!==void 0&&(r.ambientLight=o.ambientLight),Object.keys(r).length>0&&t.setOptions(r)},{deep:!1}),()=>{let o=`glyphcss-host${e.class?` ${e.class}`:""}`;return Y("div",{ref:n,class:o,...Object.fromEntries(Object.entries(c).filter(([t])=>t!=="class"))},a.default?.())}}});import{defineComponent as J,h as W,inject as Q,onMounted as Z,onBeforeUnmount as ee,watch as j,shallowRef as te}from"vue";var P=J({name:"GlyphcssMesh",props:{id:{type:String,default:void 0},triangles:{type:Array,default:()=>[]},position:{type:Array,default:void 0},scale:{type:[Number,Array],default:void 0},rotation:{type:Array,default:void 0},class:{type:String,default:void 0}},setup(e,{slots:a}){let c=Q(i);if(!c)throw new Error("glyphcss: GlyphcssMesh must be used inside a GlyphcssScene.");let{sceneRef:n}=c,s=te(null);function o(){let l={};return e.position&&(l.position=e.position),e.scale!==void 0&&(l.scale=e.scale),e.rotation&&(l.rotation=e.rotation),l}function t(){let l=n.value;if(!l)return;let m=l.add(e.triangles??[],o());s.value=m}function r(){s.value?.dispose(),s.value=null}return Z(t),ee(r),j(()=>e.triangles,()=>{r(),t()}),j(()=>({position:e.position,scale:e.scale,rotation:e.rotation}),()=>{let l=s.value;l&&(l.setTransform(o()),n.value?.rerender())},{deep:!1}),()=>{let l=`glyphcss-mesh${e.class?` ${e.class}`:""}`;return W("div",{"data-glyphcss-mesh-id":e.id,class:l},a.default?.())}}});import{defineComponent as se,inject as oe,onMounted as ne,onBeforeUnmount as re,watch as le,shallowRef as ae}from"vue";var A=se({name:"GlyphcssHotspot",props:{id:{type:String,required:!0},at:{type:Array,required:!0},size:{type:Array,default:void 0}},emits:["click"],setup(e,{emit:a}){let c=oe(i);if(!c)throw new Error("glyphcss: GlyphcssHotspot must be used inside a GlyphcssScene.");let{sceneRef:n}=c,s=ae(null);function o(){let r=n.value;if(!r)return;let l=r.addHotspot({id:e.id,at:e.at,size:e.size},()=>a("click"));s.value=l}function t(){s.value?.remove(),s.value=null}return ne(o),re(t),le(()=>({id:e.id,at:e.at,size:e.size}),()=>{t(),o()},{deep:!1}),()=>null}});import{inject as ce}from"vue";function S(){let e=ce(i);if(!e)throw new Error("glyphcss: must be used inside a GlyphcssScene.");return e}import{defineComponent as ie,inject as pe,provide as ue,shallowRef as me,watch as ye,onMounted as he}from"vue";import{createGlyphcssPerspectiveCamera as fe}from"glyphcss";var f=Symbol("glyphcss-camera");var G=ie({name:"GlyphcssPerspectiveCamera",props:{rotX:{type:Number,default:void 0},rotY:{type:Number,default:void 0},distance:{type:Number,default:void 0},scale:{type:Number,default:void 0},stretch:{type:Number,default:void 0},center:{type:Array,default:void 0}},setup(e,{slots:a}){let c=pe(i);if(!c)throw new Error("glyphcss: GlyphcssPerspectiveCamera must be used inside a GlyphcssScene.");let{sceneRef:n}=c,s=me(null);function o(){n.value?.rerender()}return ue(f,{cameraRef:s,rerender:o}),he(()=>{let t={};e.rotX!==void 0&&(t.rotX=e.rotX),e.rotY!==void 0&&(t.rotY=e.rotY),e.distance!==void 0&&(t.distance=e.distance),e.scale!==void 0&&(t.scale=e.scale),e.stretch!==void 0&&(t.stretch=e.stretch),e.center!==void 0&&(t.center=e.center);let r=fe(t);s.value=r;let l=n.value;l&&(l.setOptions({camera:r}),l.rerender())}),ye(()=>({rotX:e.rotX,rotY:e.rotY,distance:e.distance,scale:e.scale,stretch:e.stretch}),t=>{let r=s.value;if(!r)return;let l=!1;t.rotX!==void 0&&r.rotX!==t.rotX&&(r.rotX=t.rotX,l=!0),t.rotY!==void 0&&r.rotY!==t.rotY&&(r.rotY=t.rotY,l=!0),t.distance!==void 0&&r.distance!==t.distance&&(r.distance=t.distance,l=!0),t.scale!==void 0&&r.scale!==t.scale&&(r.scale=t.scale,l=!0),t.stretch!==void 0&&r.stretch!==t.stretch&&(r.stretch=t.stretch,l=!0),l&&n.value?.rerender()}),()=>a.default?.()??null}});import{defineComponent as de,inject as Ge,provide as Ce,shallowRef as ge,watch as ve,onMounted as be}from"vue";import{createGlyphcssOrthographicCamera as xe}from"glyphcss";var w=de({name:"GlyphcssOrthographicCamera",props:{rotX:{type:Number,default:void 0},rotY:{type:Number,default:void 0},zoom:{type:Number,default:void 0},center:{type:Array,default:void 0}},setup(e,{slots:a}){let c=Ge(i);if(!c)throw new Error("glyphcss: GlyphcssOrthographicCamera must be used inside a GlyphcssScene.");let{sceneRef:n}=c,s=ge(null);function o(){n.value?.rerender()}return Ce(f,{cameraRef:s,rerender:o}),be(()=>{let t={};e.rotX!==void 0&&(t.rotX=e.rotX),e.rotY!==void 0&&(t.rotY=e.rotY),e.zoom!==void 0&&(t.zoom=e.zoom),e.center!==void 0&&(t.center=e.center);let r=xe(t);s.value=r;let l=n.value;l&&(l.setOptions({camera:r}),l.rerender())}),ve(()=>({rotX:e.rotX,rotY:e.rotY,zoom:e.zoom}),t=>{let r=s.value;if(!r)return;let l=!1;t.rotX!==void 0&&r.rotX!==t.rotX&&(r.rotX=t.rotX,l=!0),t.rotY!==void 0&&r.rotY!==t.rotY&&(r.rotY=t.rotY,l=!0),t.zoom!==void 0&&r.scale!==t.zoom&&(r.scale=t.zoom,l=!0),l&&n.value?.rerender()}),()=>a.default?.()??null}});import{inject as Pe}from"vue";function R(){let e=Pe(f);if(!e)throw new Error("glyphcss: useGlyphcssCamera must be used inside a GlyphcssCamera component.");return e}import{defineComponent as Ae,inject as Se,onMounted as we,onBeforeUnmount as Re,watch as Oe,shallowRef as Me}from"vue";import{createGlyphcssOrbitControls as Le}from"glyphcss";var O=Ae({name:"GlyphcssOrbitControls",props:{drag:{type:Boolean,default:!0},wheel:{type:Boolean,default:!0},invert:{type:[Boolean,Number],default:!1},animate:{type:[Boolean,Object],default:!1}},setup(e){let a=Se(i);if(!a)throw new Error("glyphcss: GlyphcssOrbitControls must be used inside a GlyphcssScene.");let{sceneRef:c}=a,n=Me(null);return we(()=>{let s=c.value;if(!s)return;let o={drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate===!1?!1:e.animate};n.value=Le(s,o)}),Re(()=>{n.value?.destroy(),n.value=null}),Oe(()=>({drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate}),s=>{n.value?.update({drag:s.drag,wheel:s.wheel,invert:s.invert,animate:s.animate===!1?!1:s.animate})}),()=>null}});import{defineComponent as Te,inject as He,onMounted as Ve,onBeforeUnmount as ke,watch as je,shallowRef as Be}from"vue";import{createGlyphcssMapControls as Ee}from"glyphcss";var M=Te({name:"GlyphcssMapControls",props:{drag:{type:Boolean,default:!0},wheel:{type:Boolean,default:!0},invert:{type:[Boolean,Number],default:!1},animate:{type:[Boolean,Object],default:!1}},setup(e){let a=He(i);if(!a)throw new Error("glyphcss: GlyphcssMapControls must be used inside a GlyphcssScene.");let{sceneRef:c}=a,n=Be(null);return Ve(()=>{let s=c.value;if(!s)return;let o={drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate===!1?!1:e.animate};n.value=Ee(s,o)}),ke(()=>{n.value?.destroy(),n.value=null}),je(()=>({drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate}),s=>{n.value?.update({drag:s.drag,wheel:s.wheel,invert:s.invert,animate:s.animate===!1?!1:s.animate})}),()=>null}});import{defineComponent as Fe,inject as Ne,onMounted as ze,onBeforeUnmount as Ke,watch as Xe,shallowRef as Ye}from"vue";import{createGlyphcssFirstPersonControls as _e}from"glyphcss";var L=Fe({name:"GlyphcssFirstPersonControls",props:{drag:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},moveSpeed:{type:Number,default:.05},lookSpeed:{type:Number,default:.004},invert:{type:[Boolean,Number],default:!1}},setup(e){let a=Ne(i);if(!a)throw new Error("glyphcss: GlyphcssFirstPersonControls must be used inside a GlyphcssScene.");let{sceneRef:c}=a,n=Ye(null);return ze(()=>{let s=c.value;if(!s)return;let o={drag:e.drag,keyboard:e.keyboard,moveSpeed:e.moveSpeed,lookSpeed:e.lookSpeed,invert:e.invert};n.value=_e(s,o)}),Ke(()=>{n.value?.destroy(),n.value=null}),Xe(()=>({drag:e.drag,keyboard:e.keyboard,moveSpeed:e.moveSpeed,lookSpeed:e.lookSpeed,invert:e.invert}),s=>{n.value?.update(s)}),()=>null}});import{defineComponent as De,inject as Ie,onMounted as Ue,onBeforeUnmount as qe,watch as $e,computed as Je,shallowRef as We}from"vue";function Qe(e){let a=e,c=a*.05,n=[];function s(o,t,r){let l=[o[0]-c,o[1]-c,o[2]],m=[t[0]-c,t[1]-c,t[2]],y=[t[0]+c,t[1]+c,t[2]],d=[o[0]+c,o[1]+c,o[2]];n.push({vertices:[l,m,y],color:r}),n.push({vertices:[l,y,d],color:r})}return s([0,0,0],[a,0,0],"#ff0000"),s([0,0,0],[0,a,0],"#00ff00"),s([0,0,0],[0,0,a],"#0000ff"),n}var T=De({name:"GlyphcssAxesHelper",props:{size:{type:Number,default:1}},setup(e){let a=Ie(i);if(!a)throw new Error("glyphcss: GlyphcssAxesHelper must be used inside a GlyphcssScene.");let{sceneRef:c}=a,n=We(null),s=Je(()=>Qe(e.size??1));function o(){let t=c.value;t&&(n.value=t.add(s.value))}return Ue(o),qe(()=>{n.value?.dispose(),n.value=null}),$e(s,()=>{n.value?.dispose(),n.value=null,o()}),()=>null}});import{defineComponent as Ze,inject as et,onMounted as tt,onBeforeUnmount as st,watch as ot,computed as nt,shallowRef as rt}from"vue";function lt(e,a,c){let[n,s,o]=e,t=c,r=[n,s,o+t],l=[n,s,o-t],m=[n+t,s,o],y=[n-t,s,o],d=[n,s+t,o],g=[n,s-t,o];return[{vertices:[r,m,d],color:a},{vertices:[r,d,y],color:a},{vertices:[r,y,g],color:a},{vertices:[r,g,m],color:a},{vertices:[l,d,m],color:a},{vertices:[l,y,d],color:a},{vertices:[l,g,y],color:a},{vertices:[l,m,g],color:a}]}var H=Ze({name:"GlyphcssDirectionalLightHelper",props:{position:{type:Array,default:()=>[1,1,1]},color:{type:String,default:"#ffff00"},size:{type:Number,default:.1}},setup(e){let a=et(i);if(!a)throw new Error("glyphcss: GlyphcssDirectionalLightHelper must be used inside a GlyphcssScene.");let{sceneRef:c}=a,n=rt(null),s=nt(()=>lt(e.position??[1,1,1],e.color??"#ffff00",e.size??.1));function o(){let t=c.value;t&&(n.value=t.add(s.value))}return tt(o),st(()=>{n.value?.dispose(),n.value=null}),ot(s,()=>{n.value?.dispose(),n.value=null,o()}),()=>null}});import{injectGlyphcssBaseStyles as B}from"glyphcss";import{ref as E,watch as at,onUnmounted as ct,computed as v}from"vue";import{createGlyphcssAnimationMixer as it}from"@glyphcss/core";function C(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function V(e,a,c){let n=E(null),s=null,o=null,t=null,r=E(0);function l(){return c==null?n.value:C(c)??n.value}function m(){o!==null&&(cancelAnimationFrame(o),o=null),t=null}function y(){m(),s&&(s.stopAllAction(),s.uncacheRoot(),s=null,r.value++)}function d(){if(o!==null)return;function p(u){if(t===null){t=u,o=requestAnimationFrame(p);return}let h=(u-t)/1e3;t=u,s?.update(h),o=requestAnimationFrame(p)}o=requestAnimationFrame(p)}function g(){y();let p=C(e),u=C(a);if(!p||p.length===0||!u)return;let h=l();h&&(s=it(h,u),r.value++,d())}let F=at(()=>{let p=C(e),u=C(a),h=c!=null?C(c):n.value;return{c:p,ctrl:u,r:h}},()=>g(),{immediate:!0,deep:!1});ct(()=>{F(),y()});let b=v(()=>C(e)??[]),N=v(()=>b.value.map(p=>p.name)),z=v(()=>(r.value,s)),K=v(()=>{r.value;let p=b.value,u={};for(let h of p)Object.defineProperty(u,h.name,{enumerable:!0,get(){if(!s)return null;try{return s.clipAction(h.name)}catch{return null}}});return u});return{ref:n,mixer:z,clips:b,names:N,actions:K}}export{Mo as BASE_TILE,Ns as CAMERA_BACKFACE_CULL_EPS,Lo as DEFAULT_CAMERA_STATE,To as DEFAULT_PROJECTION,T as GlyphcssAxesHelper,G as GlyphcssCamera,f as GlyphcssCameraContextKey,H as GlyphcssDirectionalLightHelper,L as GlyphcssFirstPersonControls,A as GlyphcssHotspot,M as GlyphcssMapControls,P as GlyphcssMesh,O as GlyphcssOrbitControls,w as GlyphcssOrthographicCamera,G as GlyphcssPerspectiveCamera,x as GlyphcssScene,i as GlyphcssSceneContextKey,ko as LoopOnce,Bo as LoopPingPong,jo as LoopRepeat,zs as VOXEL_CAMERA_CULL_AXIS_EPS,Ks as VOXEL_CAMERA_CULL_NORMAL_LIMIT,Ao as arrowPolygons,Po as axesHelperPolygons,ao as bakeSolidTextureSampledPolygons,lo as bakeSolidTextureSamples,Ro as buildSceneContext,Us as cameraCullNormalGroups,qs as cameraCullNormalGroupsFromPolygons,$s as cameraCullNormalKey,Js as cameraCullVisibleSignature,Ws as cameraFacingDepth,go as clampChannel,Oo as computeSceneBbox,mo as computeShapeLighting,_s as coverPlanarPolygons,Vo as createGlyphcssAnimationMixer,io as createIsometricCamera,Is as cullInteriorPolygons,Co as formatColor,B as injectGlyphcssBaseStyles,xo as inverseRotateVec3,Qs as isAxisAlignedSurfaceNormal,Zs as isVoxelCameraCullableNormalGroups,co as loadMesh,Ys as mergePolygons,eo as normalFacesCamera,Ho as normalizeInvertMultiplier,Xs as normalizePolygons,wo as octahedronPolygons,Ds as optimizeMeshPolygons,yo as parseColor,ro as parseGltf,fo as parseHexColor,no as parseMtl,oo as parseObj,ho as parsePureColor,Go as parseRgbColor,po as parseVox,to as polygonCssSurfaceNormal,uo as polygonFaces,so as polygonFacesCamera,So as ringPolygons,bo as rotateVec3,vo as shadeColor,V as useGlyphcssAnimation,R as useGlyphcssCamera,S as useGlyphcssSceneContext};
1
+ import{CAMERA_BACKFACE_CULL_EPS as an,VOXEL_CAMERA_CULL_AXIS_EPS as sn,VOXEL_CAMERA_CULL_NORMAL_LIMIT as pn,normalizePolygons as un,mergePolygons as yn,coverPlanarPolygons as cn,optimizeMeshPolygons as hn,cullInteriorPolygons as mn,cameraCullNormalGroups as dn,cameraCullNormalGroupsFromPolygons as fn,cameraCullNormalKey as Gn,cameraCullVisibleSignature as gn,cameraFacingDepth as Cn,isAxisAlignedSurfaceNormal as Pn,isVoxelCameraCullableNormalGroups as vn,normalFacesCamera as bn,polygonCssSurfaceNormal as xn,polygonFacesCamera as Sn,parseObj as An,parseMtl as wn,parseGltf as Rn,bakeSolidTextureSamples as Mn,bakeSolidTextureSampledPolygons as On,loadMesh as Tn,createIsometricCamera as Hn,parseVox as Vn,polygonFaces as Ln,computeShapeLighting as zn,parseColor as En,parsePureColor as kn,parseHexColor as Fn,parseRgbColor as Nn,formatColor as jn,clampChannel as Bn,shadeColor as Dn,rotateVec3 as In,inverseRotateVec3 as Xn,resolveGeometry as Kn,tetrahedronPolygons as Un,cubePolygons as Yn,octahedronPolygons as _n,dodecahedronPolygons as Wn,icosahedronPolygons as qn,smallStellatedDodecahedronPolygons as $n,greatDodecahedronPolygons as Jn,greatStellatedDodecahedronPolygons as Qn,greatIcosahedronPolygons as Zn,cuboctahedronPolygons as er,icosidodecahedronPolygons as or,truncatedTetrahedronPolygons as tr,truncatedCubePolygons as nr,truncatedOctahedronPolygons as rr,truncatedDodecahedronPolygons as lr,truncatedIcosahedronPolygons as ar,truncatedCuboctahedronPolygons as ir,truncatedIcosidodecahedronPolygons as sr,rhombicuboctahedronPolygons as pr,rhombicosidodecahedronPolygons as ur,snubCubePolygons as yr,snubDodecahedronPolygons as cr,rhombicDodecahedronPolygons as hr,rhombicTriacontahedronPolygons as mr,triakisTetrahedronPolygons as dr,triakisOctahedronPolygons as fr,triakisIcosahedronPolygons as Gr,tetrakisHexahedronPolygons as gr,pentakisDodecahedronPolygons as Cr,disdyakisDodecahedronPolygons as Pr,disdyakisTriacontahedronPolygons as vr,deltoidalIcositetrahedronPolygons as br,deltoidalHexecontahedronPolygons as xr,pentagonalIcositetrahedronPolygons as Sr,pentagonalHexecontahedronPolygons as Ar,prismPolygons as wr,antiprismPolygons as Rr,bipyramidPolygons as Mr,trapezohedronPolygons as Or,spherePolygons as Tr,cylinderPolygons as Hr,conePolygons as Vr,torusPolygons as Lr,pyramidPolygons as zr,planePolygons as Er,ringPolygons as kr,ringQuadPolygons as Fr,arrowPolygons as Nr,axesHelperPolygons as jr,buildSceneContext as Br,computeSceneBbox as Dr,BASE_TILE as Ir,DEFAULT_CAMERA_STATE as Xr,DEFAULT_PROJECTION as Kr,normalizeInvertMultiplier as Ur,createGlyphAnimationMixer as Yr,LoopOnce as _r,LoopRepeat as Wr,LoopPingPong as qr}from"@glyphcss/core";import{defineComponent as J,h as Q,provide as Z,shallowRef as k,onMounted as ee,onBeforeUnmount as oe,watch as te}from"vue";import{createGlyphScene as ne,injectGlyphBaseStyles as re}from"glyphcss";import{inject as $}from"vue";var d=Symbol("glyph-camera");function v(){let e=$(d);if(!e)throw new Error("glyphcss: GlyphScene must be placed inside a GlyphPerspectiveCamera or GlyphOrthographicCamera.");return e}var y=Symbol("glyph-scene");var S=J({name:"GlyphScene",inheritAttrs:!1,props:{mode:{type:String,default:void 0},glyphPalette:{type:String,default:void 0},useColors:{type:Boolean,default:void 0},cols:{type:Number,default:void 0},rows:{type:Number,default:void 0},cellAspect:{type:Number,default:void 0},directionalLight:{type:Object,default:void 0},ambientLight:{type:Object,default:void 0},autoSize:{type:Boolean,default:void 0},class:{type:String,default:void 0}},setup(e,{slots:s,attrs:a}){let{cameraRef:r,sceneRerenderRef:l}=v(),t=k(null),o=k(null);return Z(y,{sceneRef:o}),ee(()=>{let n=t.value;if(!n)return;re(n.ownerDocument??void 0);let i={};e.mode!==void 0&&(i.mode=e.mode),e.glyphPalette!==void 0&&(i.glyphPalette=e.glyphPalette),e.useColors!==void 0&&(i.useColors=e.useColors),e.cols!==void 0&&(i.cols=e.cols),e.rows!==void 0&&(i.rows=e.rows),e.cellAspect!==void 0&&(i.cellAspect=e.cellAspect),e.directionalLight!==void 0&&(i.directionalLight=e.directionalLight),e.ambientLight!==void 0&&(i.ambientLight=e.ambientLight),e.autoSize!==void 0&&(i.autoSize=e.autoSize),r.value!==null&&(i.camera=r.value),o.value=ne(n,i),l.value=()=>o.value?.rerender()}),oe(()=>{o.value?.destroy(),o.value=null,l.value=null}),te(()=>({mode:e.mode,glyphPalette:e.glyphPalette,useColors:e.useColors,cols:e.cols,rows:e.rows,cellAspect:e.cellAspect,directionalLight:e.directionalLight,ambientLight:e.ambientLight,autoSize:e.autoSize}),n=>{let i=o.value;if(!i)return;let u={};n.mode!==void 0&&(u.mode=n.mode),n.glyphPalette!==void 0&&(u.glyphPalette=n.glyphPalette),n.useColors!==void 0&&(u.useColors=n.useColors),n.cols!==void 0&&(u.cols=n.cols),n.rows!==void 0&&(u.rows=n.rows),n.cellAspect!==void 0&&(u.cellAspect=n.cellAspect),n.directionalLight!==void 0&&(u.directionalLight=n.directionalLight),n.ambientLight!==void 0&&(u.ambientLight=n.ambientLight),n.autoSize!==void 0&&(u.autoSize=n.autoSize),Object.keys(u).length>0&&i.setOptions(u)},{deep:!1}),()=>{let n=`glyph-host${e.class?` ${e.class}`:""}`;return Q("div",{ref:t,class:n,...Object.fromEntries(Object.entries(a).filter(([i])=>i!=="class"))},s.default?.())}}});import{defineComponent as le,h as ae,inject as ie,onBeforeUnmount as se,watch as F,shallowRef as pe,computed as ue,watchEffect as ye}from"vue";import{resolveGeometry as ce}from"@glyphcss/core";var P=le({name:"GlyphMesh",props:{id:{type:String,default:void 0},polygons:{type:Array,default:void 0},geometry:{type:String,default:void 0},size:{type:Number,default:1},color:{type:String,default:void 0},position:{type:Array,default:void 0},scale:{type:[Number,Array],default:void 0},rotation:{type:Array,default:void 0},class:{type:String,default:void 0},onPointerDown:{type:Function,default:void 0},onPointerUp:{type:Function,default:void 0},onPointerMove:{type:Function,default:void 0},onPointerEnter:{type:Function,default:void 0},onPointerLeave:{type:Function,default:void 0},onClick:{type:Function,default:void 0},onWheel:{type:Function,default:void 0}},setup(e,{slots:s}){let a=ie(y);if(!a)throw new Error("glyphcss: GlyphMesh must be used inside a GlyphScene.");let{sceneRef:r}=a,l=pe(null),t=ue(()=>e.polygons!==void 0?e.polygons:e.geometry!==void 0?ce(e.geometry,{size:e.size,color:e.color}):[]);function o(){let p={};return e.id&&(p.id=e.id),e.position&&(p.position=e.position),e.scale!==void 0&&(p.scale=e.scale),e.rotation&&(p.rotation=e.rotation),p}function n(){let p=r.value;if(!p)return;let c=p.add(t.value,o());l.value=c}function i(){l.value?.dispose(),l.value=null}let u=ye(()=>{!r.value||l.value||n()});return se(()=>{u(),i()}),F(t,()=>{i(),n()}),F(()=>({id:e.id,position:e.position,scale:e.scale,rotation:e.rotation}),()=>{let p=l.value;p&&(p.setTransform(o()),r.value?.rerender())},{deep:!1}),()=>{let p=`glyph-mesh${e.class?` ${e.class}`:""}`;return ae("div",{"data-glyph-mesh-id":e.id,class:p},s.default?.())}}});import{defineComponent as he,h as me,computed as de}from"vue";import{planePolygons as fe}from"@glyphcss/core";var A=he({name:"GlyphGround",props:{size:{type:Number,default:5},color:{type:String,default:"#444444"},position:{type:Array,default:()=>[0,-.5,0]},rotation:{type:Array,default:void 0},id:{type:String,default:void 0},class:{type:String,default:void 0}},setup(e,{slots:s}){let a=de(()=>fe({axis:1,size:e.size,offset:0,color:e.color}));return()=>me(P,{id:e.id,polygons:a.value,position:e.position,rotation:e.rotation??void 0,class:e.class},s)}});import{defineComponent as Ge,inject as ge,onBeforeUnmount as Ce,watch as Pe,shallowRef as N,watchEffect as ve,h as be,Teleport as xe}from"vue";var w=Ge({name:"GlyphHotspot",props:{id:{type:String,required:!0},at:{type:Array,required:!0},size:{type:Array,default:void 0}},emits:["click"],setup(e,{emit:s,slots:a}){let r=ge(y);if(!r)throw new Error("glyphcss: GlyphHotspot must be used inside a GlyphScene.");let{sceneRef:l}=r,t=N(null),o=N(null);function n(){let p=l.value;if(!p)return;let c=p.addHotspot({id:e.id,at:e.at,size:e.size},()=>s("click"));t.value=c,o.value=c.el}function i(){t.value?.remove(),t.value=null,o.value=null}let u=ve(()=>{!l.value||t.value||n()});return Ce(()=>{u(),i()}),Pe(()=>({id:e.id,at:e.at,size:e.size}),()=>{i(),n()},{deep:!1}),()=>{let p=o.value,c=a.default?.();return p&&c?be(xe,{to:p},c):null}}});import{inject as Se}from"vue";function R(){let e=Se(y);if(!e)throw new Error("glyphcss: must be used inside a GlyphScene.");return e}import{findGlyphMeshHandle as j,pointInMeshElement as B,findMeshUnderPoint as D}from"glyphcss";import{defineComponent as Ae,h as we,provide as Re,shallowRef as I,watch as Me}from"vue";import{createGlyphOrthographicCamera as Oe}from"glyphcss";var G=Ae({name:"GlyphOrthographicCamera",props:{rotX:{type:Number,default:void 0},rotY:{type:Number,default:void 0},zoom:{type:Number,default:void 0},center:{type:Array,default:void 0},class:{type:String,default:void 0},style:{type:[Object,String],default:void 0}},setup(e,{slots:s}){let a={};e.rotX!==void 0&&(a.rotX=e.rotX),e.rotY!==void 0&&(a.rotY=e.rotY),e.zoom!==void 0&&(a.zoom=e.zoom),e.center!==void 0&&(a.center=e.center);let r=I(Oe(a)),l=I(null);function t(){l.value?.()}return Re(d,{cameraRef:r,rerender:t,sceneRerenderRef:l}),Me(()=>({rotX:e.rotX,rotY:e.rotY,zoom:e.zoom}),o=>{let n=r.value;if(!n)return;let i=!1;o.rotX!==void 0&&n.rotX!==o.rotX&&(n.rotX=o.rotX,i=!0),o.rotY!==void 0&&n.rotY!==o.rotY&&(n.rotY=o.rotY,i=!0),o.zoom!==void 0&&n.zoom!==o.zoom&&(n.zoom=o.zoom,i=!0),i&&l.value?.()}),()=>we("div",{class:e.class,style:e.style},s.default?.()??[])}});import{defineComponent as Te,h as He,provide as Ve,shallowRef as X,watch as Le}from"vue";import{createGlyphPerspectiveCamera as ze}from"glyphcss";var M=Te({name:"GlyphPerspectiveCamera",props:{rotX:{type:Number,default:void 0},rotY:{type:Number,default:void 0},distance:{type:Number,default:void 0},zoom:{type:Number,default:void 0},stretch:{type:Number,default:void 0},center:{type:Array,default:void 0},class:{type:String,default:void 0},style:{type:[Object,String],default:void 0}},setup(e,{slots:s}){let a={};e.rotX!==void 0&&(a.rotX=e.rotX),e.rotY!==void 0&&(a.rotY=e.rotY),e.distance!==void 0&&(a.distance=e.distance),e.zoom!==void 0&&(a.zoom=e.zoom),e.stretch!==void 0&&(a.stretch=e.stretch),e.center!==void 0&&(a.center=e.center);let r=X(ze(a)),l=X(null);function t(){l.value?.()}return Ve(d,{cameraRef:r,rerender:t,sceneRerenderRef:l}),Le(()=>({rotX:e.rotX,rotY:e.rotY,distance:e.distance,zoom:e.zoom,stretch:e.stretch}),o=>{let n=r.value;if(!n)return;let i=!1;o.rotX!==void 0&&n.rotX!==o.rotX&&(n.rotX=o.rotX,i=!0),o.rotY!==void 0&&n.rotY!==o.rotY&&(n.rotY=o.rotY,i=!0),o.distance!==void 0&&n.distance!==o.distance&&(n.distance=o.distance,i=!0),o.zoom!==void 0&&n.zoom!==o.zoom&&(n.zoom=o.zoom,i=!0),o.stretch!==void 0&&n.stretch!==o.stretch&&(n.stretch=o.stretch,i=!0),i&&l.value?.()}),()=>He("div",{class:e.class,style:e.style},s.default?.()??[])}});import{inject as Ee}from"vue";function O(){let e=Ee(d);if(!e)throw new Error("glyphcss: useGlyphCamera must be used inside a GlyphCamera component.");return e}import{defineComponent as ke,inject as Fe,onBeforeUnmount as Ne,watch as je,shallowRef as Be,watchEffect as De}from"vue";import{createGlyphOrbitControls as Ie}from"glyphcss";var T=ke({name:"GlyphOrbitControls",props:{drag:{type:Boolean,default:!0},wheel:{type:Boolean,default:!0},invert:{type:[Boolean,Number],default:!1},animate:{type:[Boolean,Object],default:!1}},setup(e){let s=Fe(y);if(!s)throw new Error("glyphcss: GlyphOrbitControls must be used inside a GlyphScene.");let{sceneRef:a}=s,r=Be(null),l=De(()=>{let t=a.value;if(!t||r.value)return;let o={drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate===!1?!1:e.animate};r.value=Ie(t,o)});return Ne(()=>{l(),r.value?.destroy(),r.value=null}),je(()=>({drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate}),t=>{r.value?.update({drag:t.drag,wheel:t.wheel,invert:t.invert,animate:t.animate===!1?!1:t.animate})}),()=>null}});import{defineComponent as Xe,inject as Ke,onBeforeUnmount as Ue,watch as Ye,shallowRef as _e,watchEffect as We}from"vue";import{createGlyphMapControls as qe}from"glyphcss";var H=Xe({name:"GlyphMapControls",props:{drag:{type:Boolean,default:!0},wheel:{type:Boolean,default:!0},invert:{type:[Boolean,Number],default:!1},animate:{type:[Boolean,Object],default:!1}},setup(e){let s=Ke(y);if(!s)throw new Error("glyphcss: GlyphMapControls must be used inside a GlyphScene.");let{sceneRef:a}=s,r=_e(null),l=We(()=>{let t=a.value;if(!t||r.value)return;let o={drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate===!1?!1:e.animate};r.value=qe(t,o)});return Ue(()=>{l(),r.value?.destroy(),r.value=null}),Ye(()=>({drag:e.drag,wheel:e.wheel,invert:e.invert,animate:e.animate}),t=>{r.value?.update({drag:t.drag,wheel:t.wheel,invert:t.invert,animate:t.animate===!1?!1:t.animate})}),()=>null}});import{defineComponent as $e,inject as Je,onBeforeUnmount as Qe,watch as Ze,shallowRef as eo,watchEffect as oo}from"vue";import{createGlyphFirstPersonControls as to}from"glyphcss";var V=$e({name:"GlyphFirstPersonControls",props:{drag:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},moveSpeed:{type:Number,default:.05},lookSpeed:{type:Number,default:.004},invert:{type:[Boolean,Number],default:!1}},setup(e){let s=Je(y);if(!s)throw new Error("glyphcss: GlyphFirstPersonControls must be used inside a GlyphScene.");let{sceneRef:a}=s,r=eo(null),l=oo(()=>{let t=a.value;if(!t||r.value)return;let o={drag:e.drag,keyboard:e.keyboard,moveSpeed:e.moveSpeed,lookSpeed:e.lookSpeed,invert:e.invert};r.value=to(t,o)});return Qe(()=>{l(),r.value?.destroy(),r.value=null}),Ze(()=>({drag:e.drag,keyboard:e.keyboard,moveSpeed:e.moveSpeed,lookSpeed:e.lookSpeed,invert:e.invert}),t=>{r.value?.update(t)}),()=>null}});import{defineComponent as no,inject as ro,onMounted as lo,onBeforeUnmount as ao,watch as io,computed as so,shallowRef as po}from"vue";function uo(e){let s=e,a=s*.05,r=[];function l(t,o,n){let i=[t[0]-a,t[1]-a,t[2]],u=[o[0]-a,o[1]-a,o[2]],p=[o[0]+a,o[1]+a,o[2]],c=[t[0]+a,t[1]+a,t[2]];r.push({vertices:[i,u,p],color:n}),r.push({vertices:[i,p,c],color:n})}return l([0,0,0],[s,0,0],"#ff0000"),l([0,0,0],[0,s,0],"#00ff00"),l([0,0,0],[0,0,s],"#0000ff"),r}var L=no({name:"GlyphAxesHelper",props:{size:{type:Number,default:1}},setup(e){let s=ro(y);if(!s)throw new Error("glyphcss: GlyphAxesHelper must be used inside a GlyphScene.");let{sceneRef:a}=s,r=po(null),l=so(()=>uo(e.size??1));function t(){let o=a.value;o&&(r.value=o.add(l.value))}return lo(t),ao(()=>{r.value?.dispose(),r.value=null}),io(l,()=>{r.value?.dispose(),r.value=null,t()}),()=>null}});import{defineComponent as yo,inject as co,onMounted as ho,onBeforeUnmount as mo,watch as fo,computed as Go,shallowRef as go}from"vue";function Co(e,s,a){let[r,l,t]=e,o=a,n=[r,l,t+o],i=[r,l,t-o],u=[r+o,l,t],p=[r-o,l,t],c=[r,l+o,t],C=[r,l-o,t];return[{vertices:[n,u,c],color:s},{vertices:[n,c,p],color:s},{vertices:[n,p,C],color:s},{vertices:[n,C,u],color:s},{vertices:[i,c,u],color:s},{vertices:[i,p,c],color:s},{vertices:[i,C,p],color:s},{vertices:[i,u,C],color:s}]}var z=yo({name:"GlyphDirectionalLightHelper",props:{position:{type:Array,default:()=>[1,1,1]},color:{type:String,default:"#ffff00"},size:{type:Number,default:.1}},setup(e){let s=co(y);if(!s)throw new Error("glyphcss: GlyphDirectionalLightHelper must be used inside a GlyphScene.");let{sceneRef:a}=s,r=go(null),l=Go(()=>Co(e.position??[1,1,1],e.color??"#ffff00",e.size??.1));function t(){let o=a.value;o&&(r.value=o.add(l.value))}return ho(t),mo(()=>{r.value?.dispose(),r.value=null}),fo(l,()=>{r.value?.dispose(),r.value=null,t()}),()=>null}});import{injectGlyphBaseStyles as K}from"glyphcss";import{ref as U,watch as Po,onUnmounted as vo,computed as b}from"vue";import{createGlyphAnimationMixer as bo}from"@glyphcss/core";function g(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function E(e,s,a){let r=U(null),l=null,t=null,o=null,n=U(0);function i(){return a==null?r.value:g(a)??r.value}function u(){t!==null&&(cancelAnimationFrame(t),t=null),o=null}function p(){u(),l&&(l.stopAllAction(),l.uncacheRoot(),l=null,n.value++)}function c(){if(t!==null)return;function h(m){if(o===null){o=m,t=requestAnimationFrame(h);return}let f=(m-o)/1e3;o=m,l?.update(f),t=requestAnimationFrame(h)}t=requestAnimationFrame(h)}function C(){p();let h=g(e),m=g(s);if(!h||h.length===0||!m)return;let f=i();f&&(l=bo(f,m),n.value++,c())}let Y=Po(()=>{let h=g(e),m=g(s),f=a!=null?g(a):r.value;return{c:h,ctrl:m,r:f}},()=>C(),{immediate:!0,deep:!1});vo(()=>{Y(),p()});let x=b(()=>g(e)??[]),_=b(()=>x.value.map(h=>h.name)),W=b(()=>(n.value,l)),q=b(()=>{n.value;let h=x.value,m={};for(let f of h)Object.defineProperty(m,f.name,{enumerable:!0,get(){if(!l)return null;try{return l.clipAction(f.name)}catch{return null}}});return m});return{ref:r,mixer:W,clips:x,names:_,actions:q}}export{Ir as BASE_TILE,an as CAMERA_BACKFACE_CULL_EPS,Xr as DEFAULT_CAMERA_STATE,Kr as DEFAULT_PROJECTION,L as GlyphAxesHelper,G as GlyphCamera,d as GlyphCameraContextKey,z as GlyphDirectionalLightHelper,V as GlyphFirstPersonControls,A as GlyphGround,w as GlyphHotspot,H as GlyphMapControls,P as GlyphMesh,T as GlyphOrbitControls,G as GlyphOrthographicCamera,M as GlyphPerspectiveCamera,S as GlyphScene,y as GlyphSceneContextKey,_r as LoopOnce,qr as LoopPingPong,Wr as LoopRepeat,sn as VOXEL_CAMERA_CULL_AXIS_EPS,pn as VOXEL_CAMERA_CULL_NORMAL_LIMIT,Rr as antiprismPolygons,Nr as arrowPolygons,jr as axesHelperPolygons,On as bakeSolidTextureSampledPolygons,Mn as bakeSolidTextureSamples,Mr as bipyramidPolygons,Br as buildSceneContext,dn as cameraCullNormalGroups,fn as cameraCullNormalGroupsFromPolygons,Gn as cameraCullNormalKey,gn as cameraCullVisibleSignature,Cn as cameraFacingDepth,Bn as clampChannel,Dr as computeSceneBbox,zn as computeShapeLighting,Vr as conePolygons,cn as coverPlanarPolygons,Yr as createGlyphAnimationMixer,Hn as createIsometricCamera,Yn as cubePolygons,er as cuboctahedronPolygons,mn as cullInteriorPolygons,Hr as cylinderPolygons,xr as deltoidalHexecontahedronPolygons,br as deltoidalIcositetrahedronPolygons,Pr as disdyakisDodecahedronPolygons,vr as disdyakisTriacontahedronPolygons,Wn as dodecahedronPolygons,j as findGlyphMeshHandle,D as findMeshUnderPoint,jn as formatColor,Jn as greatDodecahedronPolygons,Zn as greatIcosahedronPolygons,Qn as greatStellatedDodecahedronPolygons,qn as icosahedronPolygons,or as icosidodecahedronPolygons,K as injectGlyphBaseStyles,Xn as inverseRotateVec3,Pn as isAxisAlignedSurfaceNormal,vn as isVoxelCameraCullableNormalGroups,Tn as loadMesh,yn as mergePolygons,bn as normalFacesCamera,Ur as normalizeInvertMultiplier,un as normalizePolygons,_n as octahedronPolygons,hn as optimizeMeshPolygons,En as parseColor,Rn as parseGltf,Fn as parseHexColor,wn as parseMtl,An as parseObj,kn as parsePureColor,Nn as parseRgbColor,Vn as parseVox,Ar as pentagonalHexecontahedronPolygons,Sr as pentagonalIcositetrahedronPolygons,Cr as pentakisDodecahedronPolygons,Er as planePolygons,B as pointInMeshElement,xn as polygonCssSurfaceNormal,Ln as polygonFaces,Sn as polygonFacesCamera,wr as prismPolygons,zr as pyramidPolygons,Kn as resolveGeometry,hr as rhombicDodecahedronPolygons,mr as rhombicTriacontahedronPolygons,ur as rhombicosidodecahedronPolygons,pr as rhombicuboctahedronPolygons,kr as ringPolygons,Fr as ringQuadPolygons,In as rotateVec3,Dn as shadeColor,$n as smallStellatedDodecahedronPolygons,yr as snubCubePolygons,cr as snubDodecahedronPolygons,Tr as spherePolygons,Un as tetrahedronPolygons,gr as tetrakisHexahedronPolygons,Lr as torusPolygons,Or as trapezohedronPolygons,Gr as triakisIcosahedronPolygons,fr as triakisOctahedronPolygons,dr as triakisTetrahedronPolygons,nr as truncatedCubePolygons,ir as truncatedCuboctahedronPolygons,lr as truncatedDodecahedronPolygons,ar as truncatedIcosahedronPolygons,sr as truncatedIcosidodecahedronPolygons,rr as truncatedOctahedronPolygons,tr as truncatedTetrahedronPolygons,E as useGlyphAnimation,O as useGlyphCamera,R as useGlyphSceneContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glyphcss/vue",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Native Vue 3 components for the glyphcss ASCII polygon mesh rendering engine.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -41,8 +41,8 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@glyphcss/core": "^0.0.1",
45
- "glyphcss": "^0.0.1"
44
+ "glyphcss": "^0.0.3",
45
+ "@glyphcss/core": "^0.0.3"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "vue": "^3.0.0"