@albi_scando/as-design-system-threejs-lib 1.1.9 → 1.1.10

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.
@@ -30387,13 +30387,10 @@ class _A extends HTMLElement {
30387
30387
  */
30388
30388
  resizeHandler = () => {
30389
30389
  const t = () => {
30390
- const e = this._canvas.parentElement;
30391
- if (e === null)
30392
- return;
30393
- const i = e.clientWidth, n = e.clientHeight;
30394
- i === 0 || n === 0 || (this._camera.aspect = i / n, this._camera.updateProjectionMatrix(), this._renderer.setSize(i, n, !1));
30390
+ const e = this._root.clientWidth, i = this._root.clientHeight;
30391
+ e === 0 || i === 0 || (this._camera.aspect = e / i, this._camera.updateProjectionMatrix(), this._renderer.setSize(e, i, !1));
30395
30392
  };
30396
- this._resizeObserver = new ResizeObserver(t), this._resizeObserver.observe(this._canvas.parentElement), t();
30393
+ this._resizeObserver = new ResizeObserver(t), this._resizeObserver.observe(this._root), t();
30397
30394
  };
30398
30395
  // ─────────────────────────────────────────────────────────────────────────
30399
30396
  // BarMenu navigation listener — replaces per-frame DOM polling
@@ -3962,7 +3962,7 @@ void main() {
3962
3962
  headline="Switch language?"
3963
3963
  ></confirmation-dialog>
3964
3964
  </section>
3965
- `,YI="*{box-sizing:border-box}:host{display:block;width:100%;height:100%}.root{position:relative;width:100%;height:100%;overflow:hidden}canvas{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none}.menu-container{position:absolute;bottom:clamp(1rem,12vh,25%);left:50%}@media(max-width:768px){.menu-container{bottom:max(1rem,env(safe-area-inset-bottom) + 1rem)}}",uc=new CSSStyleSheet;uc.replaceSync(YI);class _A extends HTMLElement{static textureLoader=new bh;shadowRoot;static get observedAttributes(){return Object.values(fa)}options=RA.options;flags=[];selected=RA.selected;selectedTmp=RA.selected;_renderer;_scene;_camera;_root;_canvas;_resizeObserver;_clock=new Lh;_lastTime=0;_spotlight;_flagsGroup;_wind=null;_circleRadius=5;_cameraLookAtY=2;_targetGroupRotation=0;_currentGroupRotation=0;_unwrappedGroupRotation=0;_animationFrameId=0;_introCameraStartPosition=new F(0,5,10);_introCameraEndPosition=new F(0,5,10);_introCameraElapsed=0;_introCameraMoveDuration=2.2;_introCameraHoldDuration=.4;_isIntroCameraAnimating=!1;_isIntroCameraHolding=!1;_menuContainer;_menuIntroStartScale=.72;_barMenu;_confirmationDialog;_isInitialized=!1;_isInitializing=!1;_barMenuVisibleIndex=-1;_floorGeometry;_floorMaterial;_programmaticScrollTimer=null;constructor(){super(),this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(uc)}attributeChangedCallback(t,e,i){if(!(e===i||i==null))switch(t){case fa.OPTIONS:{const n=JSON.parse(i);this.init(new Set(n))}break;case fa.SELECTED:{const n=i;this.select(n)}break}}connectedCallback(){this._isInitialized&&this._animationFrameId===0&&(this._animationFrameId=requestAnimationFrame(this._animate))}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0,this._programmaticScrollTimer!==null&&(clearTimeout(this._programmaticScrollTimer),this._programmaticScrollTimer=null),this.flags.forEach(t=>{t.flagGroup?.destroy()}),this.flags=[],this._floorGeometry.dispose(),this._floorMaterial.dispose(),this._scene.clear(),this._renderer.dispose(),this._resizeObserver.disconnect(),this._confirmationDialog?.removeEventListener(Yi.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation)}init(t){if(!(this._isInitialized||this._isInitializing)){if(this.options=t,this.options.size===0){console.warn(`${this.constructor.name}: No languages provided`);return}this._isInitializing=!0,this.setupHtmlElements(),this.setupScene(),this.setupUI(),this.setupFlags(),this.setupConfirmationDialog(),this._isInitialized=!0,this._isInitializing=!1,this.isConnected&&this._animationFrameId===0&&(this._animationFrameId=requestAnimationFrame(this._animate))}}setupHtmlElements(){this.shadowRoot.innerHTML=WI,this._root=this.shadowRoot.querySelector(".root")??(()=>{throw new Error(`${this.constructor.name}: root element not found`)})(),this._canvas=this.shadowRoot.querySelector(NA.CANVAS)??(()=>{throw new Error(`${this.constructor.name}: canvas element not found`)})(),this._confirmationDialog=this.shadowRoot.querySelector(Yi.selector)??(()=>{throw new Error(`${this.constructor.name}: confirmation-dialog element not found`)})()}setupScene(){this._scene=new Sh,this._scene.background=new Vt(1710618),this._scene.fog=new fA(1710618,8,50),this._camera=new ze(45,1,.1,100),this._camera.position.set(0,5,10),this._camera.lookAt(0,2,0),this._scene.add(this._camera),this._renderer=new hc({antialias:!0,canvas:this._canvas,alpha:!0}),this._renderer.debug.checkShaderErrors=!0,this._renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this._renderer.shadowMap.enabled=!1;const t=new zf(16777215,.3);this._scene.add(t);const e=new Ph(14674943,3);e.position.set(10,20,10),this._scene.add(e);const i=new Ph(11329439,.15);i.position.set(0,-1,0),this._scene.add(i),this._spotlight=new Of(16777215,150),this._spotlight.angle=Math.PI/6,this._spotlight.penumbra=.3,this._spotlight.decay=2,this._spotlight.distance=30,this._scene.add(this._spotlight),this._scene.add(this._spotlight.target);const n=100;this._floorGeometry=new cr(n,n),this._floorMaterial=new _f({color:1710618,roughness:.8,metalness:.2});const s=new mi(this._floorGeometry,this._floorMaterial);s.rotation.x=-Math.PI/2,s.receiveShadow=!0,this._scene.add(s),this.resizeHandler(),this.shadowRoot.appendChild(this._root)}setupUI(){this._menuContainer=this.shadowRoot.querySelector(".menu-container")??(()=>{throw new Error(`${this.constructor.name}: menu-container not found`)})(),this._barMenu=this.shadowRoot.querySelector(tu.selector)??(()=>{throw new Error(`${this.constructor.name}: bar menu element not found`)})()}setupFlags(){this._flagsGroup=new hr,this._scene.add(this._flagsGroup),this._wind=new Li.Wind({speed:8,direction:new F(1,0,0)});const t=this.options.size;this._circleRadius=Math.max(5,3+t*.5),this._cameraLookAtY=this._circleRadius*.4,[...this.options].forEach((n,s)=>{const a=-(s/t*Math.PI*2),o=-Math.sin(a)*this._circleRadius,l=Math.cos(a)*this._circleRadius,A=Li.buildFlag(),h=Li.buildFlagpole({flagpoleType:Li.FLAG_POLE_TYPE.VERTICAL},A),c=new Li.FlagGroup({flagpole:h,flag:A});c.object.position.set(o,0,l);const u=va.get(n)?.isoCode,d=u!=null?zn[u]:void 0;d!=null&&_A.textureLoader.load(d,p=>{c.setTexture(p)},void 0,()=>{console.warn(`LanguagePickerComponent: Failed to load texture for ${n}`)}),this._flagsGroup.add(c.object),this.flags.push({id:n,flagGroup:c,angle:a,windPhase:Math.random()*Math.PI*2,randomSeed:Math.random()})});const e=this.flags.find(n=>n.id===this.selected)??this.flags[0];if(e===void 0)return;this.selected=e.id,this.selectedTmp=this.selected,this._targetGroupRotation=e.angle,this._currentGroupRotation=e.angle,this._unwrappedGroupRotation=e.angle,this._flagsGroup.rotation.y=e.angle;const i=this._computeIntroCameraEndPosition();this._introCameraEndPosition.copy(i),this._introCameraStartPosition.set(0,i.y+this._circleRadius*3.1,i.z+this._circleRadius*4.6),this._camera.position.copy(this._introCameraStartPosition),this._camera.lookAt(0,this._cameraLookAtY,0),this._introCameraElapsed=0,this._isIntroCameraHolding=!0,this._isIntroCameraAnimating=!0,this._setMenuIntroScale(0),this._spotlight.position.set(0,8,this._circleRadius),this._spotlight.target.position.set(0,0,this._circleRadius),this._spotlight.target.updateMatrixWorld()}resizeHandler=()=>{const t=()=>{const e=this._canvas.parentElement;if(e===null)return;const i=e.clientWidth,n=e.clientHeight;i===0||n===0||(this._camera.aspect=i/n,this._camera.updateProjectionMatrix(),this._renderer.setSize(i,n,!1))};this._resizeObserver=new ResizeObserver(t),this._resizeObserver.observe(this._canvas.parentElement),t()};listenToBarMenuNavigation(){new MutationObserver(()=>{if(this._programmaticScrollTimer!==null)return;const e=this._barMenu.querySelectorAll(zA.selector);for(let i=0;i<e.length;i++){const n=window.getComputedStyle(e[i]);if(n.display!=="none"&&n.visibility!=="hidden"&&parseFloat(n.opacity)>0){if(i===this._barMenuVisibleIndex)return;this._barMenuVisibleIndex=i;const a=[...this.options][i];if(a==null)return;this.selectedTmp=a,this._rotateToId(a);break}}}).observe(this._barMenu,{attributes:!0,subtree:!0,attributeFilter:["style","class"]})}_computeIntroCameraEndPosition(){const t=new hs().setFromObject(this._flagsGroup),e=new F,i=new F;t.getSize(e),t.getCenter(i);const n=t.min.y,s=Math.max(e.x,e.y,e.z)*.5,a=this._camera.fov*Math.PI/180,o=this._camera.aspect>0?this._camera.aspect:1,l=2*Math.atan(Math.tan(a*.5)*o),A=Math.max(s/Math.tan(a*.5),s/Math.tan(l*.5))*1.05,h=n+e.y*.25;this._cameraLookAtY=h+e.y*.06;const c=h+Math.max(e.y*.8,this._circleRadius*.28),u=i.z+A+this._circleRadius*.01;return new F(0,c,u)}select(t){if(this._isInitialized===!1){this.selected=t,this.selectedTmp=t;return}if(this.options.has(t)===!1){console.warn(`${this.constructor.name}: Language '${t}' not found`);return}t!==this.selected&&(this.selected=t,this.selectedTmp=t,this._rotateToId(this.selected),this._syncBarMenuToId(this.selected))}_rotateToId(t){const e=this.flags.find(s=>s.id===t);if(e===void 0)return;const i=2*Math.PI;let n=e.angle;for(;Math.abs(n-this._unwrappedGroupRotation)>Math.PI;)n+=n<this._unwrappedGroupRotation?i:-i;this._targetGroupRotation=n,this._unwrappedGroupRotation=n}_syncBarMenuToId(t){const e=[...this.options].indexOf(t);e!==-1&&(this._barMenuVisibleIndex=e,this._programmaticScrollTimer!==null&&clearTimeout(this._programmaticScrollTimer),this._programmaticScrollTimer=setTimeout(()=>{this._programmaticScrollTimer=null},500),this._barMenu.scrollToButton(e))}setupConfirmationDialog(){this._confirmationDialog.addEventListener(Yi.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this.options.forEach(t=>{const e=document.createElement(zA.selector);e.textContent=va.get(t)?.autonyms??t,e.addEventListener(fr.CLICK,()=>{this.barMenuButtonClickHandler()}),this._barMenu.appendChild(e)}),this._barMenu.visibleButtons=1,this._barMenu.cyclicalNavigation=!0,requestAnimationFrame(()=>{this._syncBarMenuToId(this.selected),this.listenToBarMenuNavigation()})}barMenuButtonClickHandler=()=>{const t=va.get(this.selectedTmp);t!==void 0&&(this._confirmationDialog.text=`Switch to ${t.language.toLowerCase()}?`,this._confirmationDialog.showModal())};_handleConfirmation=()=>{this.selectedTmp!==this.selected&&this.dispatchEvent(new CustomEvent(cc.LANGUAGE_CHANGE_CONFIRMED,{detail:{value:this.selectedTmp},bubbles:!0,composed:!0}))};_animate=()=>{this._animationFrameId=requestAnimationFrame(this._animate);try{if(!this._isInitialized||this._camera==null||this._renderer==null)return;const t=this._clock.getElapsedTime(),e=t-this._lastTime;this._lastTime=t,this._wind!=null&&this._wind.update(),this.flags.forEach((i,n)=>{if(i.flagGroup==null)return;i.windPhase+=e*(.5+i.randomSeed*1.5),Li.applyGravityToCloth(i.flagGroup.flag.cloth,i.flagGroup.flag.object),this._wind!=null&&Li.applyWindForceToCloth(i.flagGroup.flag.cloth,this._wind,i.flagGroup.flag.object,{randomizeAmount:.6,randomSeed:i.randomSeed});const s=new Li.Wind({speed:.3+Math.sin(i.windPhase)*.2,direction:new F(Math.sin(i.windPhase+n)*.5,Math.cos(i.windPhase*.7),Math.sin(i.windPhase*.5+n)).normalize()});Li.applyWindForceToCloth(i.flagGroup.flag.cloth,s,i.flagGroup.flag.object,{randomizeAmount:.5,randomSeed:i.randomSeed*2}),i.flagGroup.simulate(e),i.flagGroup.render()}),this._updateGroupRotation(),this._updateIntroCamera(e),this._camera.lookAt(0,this._cameraLookAtY,0),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId)}};_updateGroupRotation(){if(this._flagsGroup==null)return;const t=this._targetGroupRotation-this._currentGroupRotation;this._currentGroupRotation+=t*.1,this._flagsGroup.rotation.y=this._currentGroupRotation}_updateIntroCamera(t){if(!this._isIntroCameraAnimating)return;if(this._isIntroCameraHolding){this._introCameraElapsed+=t,this._camera.position.copy(this._introCameraStartPosition),this._setMenuIntroScale(0),this._introCameraElapsed>=this._introCameraHoldDuration&&(this._isIntroCameraHolding=!1,this._introCameraElapsed=0);return}this._introCameraElapsed+=t;const e=Math.min(1,this._introCameraElapsed/this._introCameraMoveDuration),i=e*e*(3-2*e),n=1-Math.pow(1-e,4);this._camera.position.set(0,this._introCameraStartPosition.y+(this._introCameraEndPosition.y-this._introCameraStartPosition.y)*n,this._introCameraStartPosition.z+(this._introCameraEndPosition.z-this._introCameraStartPosition.z)*i),this._setMenuIntroScale(i),e>=1&&(this._isIntroCameraAnimating=!1,this._camera.position.copy(this._introCameraEndPosition),this._setMenuIntroScale(1))}_setMenuIntroScale(t){if(this._menuContainer==null)return;const e=Math.min(1,Math.max(0,t)),i=this._menuIntroStartScale+(1-this._menuIntroStartScale)*e;this._menuContainer.style.transform=`translateX(-50%) scale(${i})`}addLanguage(t){}addLocales(t){}removeLanguage(t){}removeLocales(t){}}const XI=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:cc,LanguagePickerComponent:_A,OBSERVED_ATTRIBUTES:fa,selector:"as-language-picker"},Symbol.toStringTag,{value:"Module"})),dc={THEME_CHANGE_CONFIRMED:Ca.THEME_CHANGE_CONFIRMED},ga={RIGHT:new F(1,0,0),LEFT:new F(-1,0,0),TOP:new F(0,1,0),BOTTOM:new F(0,-1,0),FRONT:new F(0,0,1),BACK:new F(0,0,-1)},ZI=new Set([me.DARK_PURPLE]),PA={selected:me.DARK_PURPLE,options:ZI},pa={OPTIONS:"themes",SELECTED:"selected"},JI=`<section class="root">
3965
+ `,YI="*{box-sizing:border-box}:host{display:block;width:100%;height:100%}.root{position:relative;width:100%;height:100%;overflow:hidden}canvas{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none}.menu-container{position:absolute;bottom:clamp(1rem,12vh,25%);left:50%}@media(max-width:768px){.menu-container{bottom:max(1rem,env(safe-area-inset-bottom) + 1rem)}}",uc=new CSSStyleSheet;uc.replaceSync(YI);class _A extends HTMLElement{static textureLoader=new bh;shadowRoot;static get observedAttributes(){return Object.values(fa)}options=RA.options;flags=[];selected=RA.selected;selectedTmp=RA.selected;_renderer;_scene;_camera;_root;_canvas;_resizeObserver;_clock=new Lh;_lastTime=0;_spotlight;_flagsGroup;_wind=null;_circleRadius=5;_cameraLookAtY=2;_targetGroupRotation=0;_currentGroupRotation=0;_unwrappedGroupRotation=0;_animationFrameId=0;_introCameraStartPosition=new F(0,5,10);_introCameraEndPosition=new F(0,5,10);_introCameraElapsed=0;_introCameraMoveDuration=2.2;_introCameraHoldDuration=.4;_isIntroCameraAnimating=!1;_isIntroCameraHolding=!1;_menuContainer;_menuIntroStartScale=.72;_barMenu;_confirmationDialog;_isInitialized=!1;_isInitializing=!1;_barMenuVisibleIndex=-1;_floorGeometry;_floorMaterial;_programmaticScrollTimer=null;constructor(){super(),this.shadowRoot=this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(uc)}attributeChangedCallback(t,e,i){if(!(e===i||i==null))switch(t){case fa.OPTIONS:{const n=JSON.parse(i);this.init(new Set(n))}break;case fa.SELECTED:{const n=i;this.select(n)}break}}connectedCallback(){this._isInitialized&&this._animationFrameId===0&&(this._animationFrameId=requestAnimationFrame(this._animate))}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._animationFrameId=0,this._programmaticScrollTimer!==null&&(clearTimeout(this._programmaticScrollTimer),this._programmaticScrollTimer=null),this.flags.forEach(t=>{t.flagGroup?.destroy()}),this.flags=[],this._floorGeometry.dispose(),this._floorMaterial.dispose(),this._scene.clear(),this._renderer.dispose(),this._resizeObserver.disconnect(),this._confirmationDialog?.removeEventListener(Yi.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation)}init(t){if(!(this._isInitialized||this._isInitializing)){if(this.options=t,this.options.size===0){console.warn(`${this.constructor.name}: No languages provided`);return}this._isInitializing=!0,this.setupHtmlElements(),this.setupScene(),this.setupUI(),this.setupFlags(),this.setupConfirmationDialog(),this._isInitialized=!0,this._isInitializing=!1,this.isConnected&&this._animationFrameId===0&&(this._animationFrameId=requestAnimationFrame(this._animate))}}setupHtmlElements(){this.shadowRoot.innerHTML=WI,this._root=this.shadowRoot.querySelector(".root")??(()=>{throw new Error(`${this.constructor.name}: root element not found`)})(),this._canvas=this.shadowRoot.querySelector(NA.CANVAS)??(()=>{throw new Error(`${this.constructor.name}: canvas element not found`)})(),this._confirmationDialog=this.shadowRoot.querySelector(Yi.selector)??(()=>{throw new Error(`${this.constructor.name}: confirmation-dialog element not found`)})()}setupScene(){this._scene=new Sh,this._scene.background=new Vt(1710618),this._scene.fog=new fA(1710618,8,50),this._camera=new ze(45,1,.1,100),this._camera.position.set(0,5,10),this._camera.lookAt(0,2,0),this._scene.add(this._camera),this._renderer=new hc({antialias:!0,canvas:this._canvas,alpha:!0}),this._renderer.debug.checkShaderErrors=!0,this._renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this._renderer.shadowMap.enabled=!1;const t=new zf(16777215,.3);this._scene.add(t);const e=new Ph(14674943,3);e.position.set(10,20,10),this._scene.add(e);const i=new Ph(11329439,.15);i.position.set(0,-1,0),this._scene.add(i),this._spotlight=new Of(16777215,150),this._spotlight.angle=Math.PI/6,this._spotlight.penumbra=.3,this._spotlight.decay=2,this._spotlight.distance=30,this._scene.add(this._spotlight),this._scene.add(this._spotlight.target);const n=100;this._floorGeometry=new cr(n,n),this._floorMaterial=new _f({color:1710618,roughness:.8,metalness:.2});const s=new mi(this._floorGeometry,this._floorMaterial);s.rotation.x=-Math.PI/2,s.receiveShadow=!0,this._scene.add(s),this.resizeHandler(),this.shadowRoot.appendChild(this._root)}setupUI(){this._menuContainer=this.shadowRoot.querySelector(".menu-container")??(()=>{throw new Error(`${this.constructor.name}: menu-container not found`)})(),this._barMenu=this.shadowRoot.querySelector(tu.selector)??(()=>{throw new Error(`${this.constructor.name}: bar menu element not found`)})()}setupFlags(){this._flagsGroup=new hr,this._scene.add(this._flagsGroup),this._wind=new Li.Wind({speed:8,direction:new F(1,0,0)});const t=this.options.size;this._circleRadius=Math.max(5,3+t*.5),this._cameraLookAtY=this._circleRadius*.4,[...this.options].forEach((n,s)=>{const a=-(s/t*Math.PI*2),o=-Math.sin(a)*this._circleRadius,l=Math.cos(a)*this._circleRadius,A=Li.buildFlag(),h=Li.buildFlagpole({flagpoleType:Li.FLAG_POLE_TYPE.VERTICAL},A),c=new Li.FlagGroup({flagpole:h,flag:A});c.object.position.set(o,0,l);const u=va.get(n)?.isoCode,d=u!=null?zn[u]:void 0;d!=null&&_A.textureLoader.load(d,p=>{c.setTexture(p)},void 0,()=>{console.warn(`LanguagePickerComponent: Failed to load texture for ${n}`)}),this._flagsGroup.add(c.object),this.flags.push({id:n,flagGroup:c,angle:a,windPhase:Math.random()*Math.PI*2,randomSeed:Math.random()})});const e=this.flags.find(n=>n.id===this.selected)??this.flags[0];if(e===void 0)return;this.selected=e.id,this.selectedTmp=this.selected,this._targetGroupRotation=e.angle,this._currentGroupRotation=e.angle,this._unwrappedGroupRotation=e.angle,this._flagsGroup.rotation.y=e.angle;const i=this._computeIntroCameraEndPosition();this._introCameraEndPosition.copy(i),this._introCameraStartPosition.set(0,i.y+this._circleRadius*3.1,i.z+this._circleRadius*4.6),this._camera.position.copy(this._introCameraStartPosition),this._camera.lookAt(0,this._cameraLookAtY,0),this._introCameraElapsed=0,this._isIntroCameraHolding=!0,this._isIntroCameraAnimating=!0,this._setMenuIntroScale(0),this._spotlight.position.set(0,8,this._circleRadius),this._spotlight.target.position.set(0,0,this._circleRadius),this._spotlight.target.updateMatrixWorld()}resizeHandler=()=>{const t=()=>{const e=this._root.clientWidth,i=this._root.clientHeight;e===0||i===0||(this._camera.aspect=e/i,this._camera.updateProjectionMatrix(),this._renderer.setSize(e,i,!1))};this._resizeObserver=new ResizeObserver(t),this._resizeObserver.observe(this._root),t()};listenToBarMenuNavigation(){new MutationObserver(()=>{if(this._programmaticScrollTimer!==null)return;const e=this._barMenu.querySelectorAll(zA.selector);for(let i=0;i<e.length;i++){const n=window.getComputedStyle(e[i]);if(n.display!=="none"&&n.visibility!=="hidden"&&parseFloat(n.opacity)>0){if(i===this._barMenuVisibleIndex)return;this._barMenuVisibleIndex=i;const a=[...this.options][i];if(a==null)return;this.selectedTmp=a,this._rotateToId(a);break}}}).observe(this._barMenu,{attributes:!0,subtree:!0,attributeFilter:["style","class"]})}_computeIntroCameraEndPosition(){const t=new hs().setFromObject(this._flagsGroup),e=new F,i=new F;t.getSize(e),t.getCenter(i);const n=t.min.y,s=Math.max(e.x,e.y,e.z)*.5,a=this._camera.fov*Math.PI/180,o=this._camera.aspect>0?this._camera.aspect:1,l=2*Math.atan(Math.tan(a*.5)*o),A=Math.max(s/Math.tan(a*.5),s/Math.tan(l*.5))*1.05,h=n+e.y*.25;this._cameraLookAtY=h+e.y*.06;const c=h+Math.max(e.y*.8,this._circleRadius*.28),u=i.z+A+this._circleRadius*.01;return new F(0,c,u)}select(t){if(this._isInitialized===!1){this.selected=t,this.selectedTmp=t;return}if(this.options.has(t)===!1){console.warn(`${this.constructor.name}: Language '${t}' not found`);return}t!==this.selected&&(this.selected=t,this.selectedTmp=t,this._rotateToId(this.selected),this._syncBarMenuToId(this.selected))}_rotateToId(t){const e=this.flags.find(s=>s.id===t);if(e===void 0)return;const i=2*Math.PI;let n=e.angle;for(;Math.abs(n-this._unwrappedGroupRotation)>Math.PI;)n+=n<this._unwrappedGroupRotation?i:-i;this._targetGroupRotation=n,this._unwrappedGroupRotation=n}_syncBarMenuToId(t){const e=[...this.options].indexOf(t);e!==-1&&(this._barMenuVisibleIndex=e,this._programmaticScrollTimer!==null&&clearTimeout(this._programmaticScrollTimer),this._programmaticScrollTimer=setTimeout(()=>{this._programmaticScrollTimer=null},500),this._barMenu.scrollToButton(e))}setupConfirmationDialog(){this._confirmationDialog.addEventListener(Yi.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation),this.options.forEach(t=>{const e=document.createElement(zA.selector);e.textContent=va.get(t)?.autonyms??t,e.addEventListener(fr.CLICK,()=>{this.barMenuButtonClickHandler()}),this._barMenu.appendChild(e)}),this._barMenu.visibleButtons=1,this._barMenu.cyclicalNavigation=!0,requestAnimationFrame(()=>{this._syncBarMenuToId(this.selected),this.listenToBarMenuNavigation()})}barMenuButtonClickHandler=()=>{const t=va.get(this.selectedTmp);t!==void 0&&(this._confirmationDialog.text=`Switch to ${t.language.toLowerCase()}?`,this._confirmationDialog.showModal())};_handleConfirmation=()=>{this.selectedTmp!==this.selected&&this.dispatchEvent(new CustomEvent(cc.LANGUAGE_CHANGE_CONFIRMED,{detail:{value:this.selectedTmp},bubbles:!0,composed:!0}))};_animate=()=>{this._animationFrameId=requestAnimationFrame(this._animate);try{if(!this._isInitialized||this._camera==null||this._renderer==null)return;const t=this._clock.getElapsedTime(),e=t-this._lastTime;this._lastTime=t,this._wind!=null&&this._wind.update(),this.flags.forEach((i,n)=>{if(i.flagGroup==null)return;i.windPhase+=e*(.5+i.randomSeed*1.5),Li.applyGravityToCloth(i.flagGroup.flag.cloth,i.flagGroup.flag.object),this._wind!=null&&Li.applyWindForceToCloth(i.flagGroup.flag.cloth,this._wind,i.flagGroup.flag.object,{randomizeAmount:.6,randomSeed:i.randomSeed});const s=new Li.Wind({speed:.3+Math.sin(i.windPhase)*.2,direction:new F(Math.sin(i.windPhase+n)*.5,Math.cos(i.windPhase*.7),Math.sin(i.windPhase*.5+n)).normalize()});Li.applyWindForceToCloth(i.flagGroup.flag.cloth,s,i.flagGroup.flag.object,{randomizeAmount:.5,randomSeed:i.randomSeed*2}),i.flagGroup.simulate(e),i.flagGroup.render()}),this._updateGroupRotation(),this._updateIntroCamera(e),this._camera.lookAt(0,this._cameraLookAtY,0),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId)}};_updateGroupRotation(){if(this._flagsGroup==null)return;const t=this._targetGroupRotation-this._currentGroupRotation;this._currentGroupRotation+=t*.1,this._flagsGroup.rotation.y=this._currentGroupRotation}_updateIntroCamera(t){if(!this._isIntroCameraAnimating)return;if(this._isIntroCameraHolding){this._introCameraElapsed+=t,this._camera.position.copy(this._introCameraStartPosition),this._setMenuIntroScale(0),this._introCameraElapsed>=this._introCameraHoldDuration&&(this._isIntroCameraHolding=!1,this._introCameraElapsed=0);return}this._introCameraElapsed+=t;const e=Math.min(1,this._introCameraElapsed/this._introCameraMoveDuration),i=e*e*(3-2*e),n=1-Math.pow(1-e,4);this._camera.position.set(0,this._introCameraStartPosition.y+(this._introCameraEndPosition.y-this._introCameraStartPosition.y)*n,this._introCameraStartPosition.z+(this._introCameraEndPosition.z-this._introCameraStartPosition.z)*i),this._setMenuIntroScale(i),e>=1&&(this._isIntroCameraAnimating=!1,this._camera.position.copy(this._introCameraEndPosition),this._setMenuIntroScale(1))}_setMenuIntroScale(t){if(this._menuContainer==null)return;const e=Math.min(1,Math.max(0,t)),i=this._menuIntroStartScale+(1-this._menuIntroStartScale)*e;this._menuContainer.style.transform=`translateX(-50%) scale(${i})`}addLanguage(t){}addLocales(t){}removeLanguage(t){}removeLocales(t){}}const XI=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:cc,LanguagePickerComponent:_A,OBSERVED_ATTRIBUTES:fa,selector:"as-language-picker"},Symbol.toStringTag,{value:"Module"})),dc={THEME_CHANGE_CONFIRMED:Ca.THEME_CHANGE_CONFIRMED},ga={RIGHT:new F(1,0,0),LEFT:new F(-1,0,0),TOP:new F(0,1,0),BOTTOM:new F(0,-1,0),FRONT:new F(0,0,1),BACK:new F(0,0,-1)},ZI=new Set([me.DARK_PURPLE]),PA={selected:me.DARK_PURPLE,options:ZI},pa={OPTIONS:"themes",SELECTED:"selected"},JI=`<section class="root">
3966
3966
  <canvas></canvas>
3967
3967
  <section class="preview-dialog-container">
3968
3968
  <header-body-footer-dialog class="preview-dialog">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@albi_scando/as-design-system-threejs-lib",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "A library of reusable, strongly typed threejs Web Components built with TypeScript, designed for creating consistent and maintainable user interfaces.",
5
5
  "type": "module",
6
6
  "files": [