@albi_scando/as-design-system-threejs-lib 1.0.4 → 1.0.5

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.
@@ -30569,7 +30569,7 @@ class ia extends HTMLElement {
30569
30569
  const n = document.createElement(
30570
30570
  fu.selector
30571
30571
  );
30572
- n.textContent = la.get(e.id)?.language ?? e.id, n.addEventListener(lu.CLICK, () => {
30572
+ n.textContent = la.get(e.id)?.autonyms ?? e.id, n.addEventListener(lu.CLICK, () => {
30573
30573
  t(i);
30574
30574
  }), this._languageButtons.push(n), this._barMenu.appendChild(n);
30575
30575
  });
@@ -3958,4 +3958,4 @@ void main() {
3958
3958
  width: 100%;
3959
3959
  height: 100%;
3960
3960
  }
3961
- `,this._shadowRoot.appendChild(t)}_setupFlags(t,e){const i=t.length;this._circleRadius=Math.max(5,3+i*.5),this._cameraLookAtY=this._circleRadius*.4,t.forEach((l,c)=>{const u=-(c/i*Math.PI*2),d=-Math.sin(u)*this._circleRadius,f=Math.cos(u)*this._circleRadius,g=Di.buildFlag(),_=Di.buildFlagpole({flagpoleType:Di.FLAG_POLE_TYPE.VERTICAL},g),m=new Di.FlagGroup({flagpole:_,flag:g});m.object.position.set(d,0,f);const p=new np,T=`/textures/flags/${la.get(l)?.isoCode}.png`;let b=!1;p.load(T,w=>{b||(m.setTexture(w),b=!0)},void 0,()=>{}),this._flagsGroup.add(m.object);const y=Math.random(),R={id:l,flagGroup:m,object:m.object,angle:u,wind:null,windPhase:Math.random()*Math.PI*2,randomSeed:y};this._languages.push(R)});const n=e!=null&&e.length>0?t.indexOf(e):-1,r=n>=0?n:0;if(r>=0&&r<this._languages.length){this._selectedLanguageIndex=r,this._currentVisibleButtonIndex=r;const l=this._languages[r].angle;this._targetGroupRotation=l,this._currentGroupRotation=l,this._unwrappedGroupRotation=l,this._flagsGroup.rotation.y=l}const a=this._computeIntroCameraEndPosition(),o=a.y,h=a.z;this._introCameraEndPosition.copy(a),this._introCameraStartPosition.set(0,o+this._circleRadius*3.1,h+this._circleRadius*4.6),this._camera.position.copy(this._introCameraStartPosition),this._controls.target.set(0,this._cameraLookAtY,0),this._controls.update(),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()}_computeIntroCameraEndPosition(){const t=new cs().setFromObject(this._flagsGroup),e=new N,i=new N;t.getSize(e),t.getCenter(i);const n=t.min.y,r=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,h=2*Math.atan(Math.tan(a*.5)*o),l=r/Math.tan(a*.5),c=r/Math.tan(h*.5),u=Math.max(l,c)*1.05,d=n+e.y*.25,f=d+Math.max(e.y*.8,this._circleRadius*.28);this._cameraLookAtY=d+e.y*.06;const g=i.z+u+this._circleRadius*.01;return new N(0,f,g)}_setupLanguageDialog(){this._confirmationDialog=document.createElement(Cl.selector),this._confirmationDialog.id="confirmation-dialog",this._shadowRoot.appendChild(this._confirmationDialog),this._confirmationDialog.addEventListener(Cl.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation);const t=e=>{const i=this._languages[e];if(i==null)return;this._updateGroupRotationToLanguage(e);const n=la.get(i.id);n!=null&&(this._confirmationDialog.value=n.id,this._confirmationDialog.headline="Switch language?",this._confirmationDialog.text=`Are you sure you want to switch the language to ${n.language.toLowerCase()}?`,this._confirmationDialog.showModal())};this._languages.forEach((e,i)=>{const n=document.createElement(lu.selector);n.textContent=la.get(e.id)?.language??e.id,n.addEventListener(su.CLICK,()=>{t(i)}),this._languageButtons.push(n),this._barMenu.appendChild(n)})}_handleConfirmation=()=>{const t=this._confirmationDialog.value,e=this._languages.findIndex(n=>n.id===t);if(e===-1||e===this._selectedLanguageIndex)return;const i=new CustomEvent(Kc.LANGUAGE_CHANGE_CONFIRMED,{detail:{value:t},bubbles:!0,composed:!0});this.dispatchEvent(i)};_setupEventListeners(){}_checkVisibleButtonChange(){const t=Array.from(this._barMenu.children);for(let e=0;e<t.length;e++){const i=t[e],n=window.getComputedStyle(i);if(n.display!=="none"&&n.visibility!=="hidden"&&n.opacity!=="0"){e!==this._currentVisibleButtonIndex&&(this._currentVisibleButtonIndex=e,this._updateGroupRotationToLanguage(e));break}}}_updateGroupRotationToLanguage(t){const e=this._languages[t].angle,i=2*Math.PI;let n=e;for(;Math.abs(n-this._unwrappedGroupRotation)>Math.PI;)n<this._unwrappedGroupRotation?n+=i:n-=i;this._targetGroupRotation=n,this._unwrappedGroupRotation=n,this._controls.enabled=!1}_updateGroupRotation(){if(this._flagsGroup==null)return;const t=this._targetGroupRotation-this._currentGroupRotation;this._currentGroupRotation+=t*.1,Math.abs(t)<.01&&(this._controls.enabled=!0),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._controls.target.set(0,this._cameraLookAtY,0),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),r=this._introCameraStartPosition.z+(this._introCameraEndPosition.z-this._introCameraStartPosition.z)*i,a=this._introCameraStartPosition.y+(this._introCameraEndPosition.y-this._introCameraStartPosition.y)*n;this._setMenuIntroScale(i),this._camera.position.set(0,a,r),this._controls.target.set(0,this._cameraLookAtY,0),e>=1&&(this._isIntroCameraAnimating=!1,this._camera.position.copy(this._introCameraEndPosition),this._controls.target.set(0,this._cameraLookAtY,0),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})`}_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._languages.forEach((i,n)=>{if(i.flagGroup!=null){i.windPhase+=e*(.5+i.randomSeed*1.5),Di.applyGravityToCloth(i.flagGroup.flag.cloth,i.flagGroup.flag.object),this._wind!=null&&Di.applyWindForceToCloth(i.flagGroup.flag.cloth,this._wind,i.flagGroup.flag.object,{randomizeAmount:.6,randomSeed:i.randomSeed});const r=.3+Math.sin(i.windPhase)*.2,a=new Di.Wind({speed:r,direction:new N(Math.sin(i.windPhase+n)*.5,Math.cos(i.windPhase*.7),Math.sin(i.windPhase*.5+n)).normalize()});Di.applyWindForceToCloth(i.flagGroup.flag.cloth,a,i.flagGroup.flag.object,{randomizeAmount:.5,randomSeed:i.randomSeed*2}),i.flagGroup.simulate(e),i.flagGroup.render()}}),this._updateGroupRotation(),this._updateIntroCamera(e),this._checkVisibleButtonChange(),this._controls.update(),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId)}};connectedCallback(){try{this._isInitialized&&(this._animationFrameId=requestAnimationFrame(this._animate))}catch(t){console.error("Failed to start animation:",t)}}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._languages.forEach(t=>{t.flagGroup!=null&&t.flagGroup.destroy(),this._scene.remove(t.object)}),this._lights.forEach(t=>{t.dispose()}),this._scene.clear(),this._renderer.dispose(),this._resizeObserver.disconnect()}addLanguage(t){}addLocales(t){}removeLanguage(t){}removeLocales(t){}selectLanguage(t){}}const C0=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:Kc,LanguagePickerComponent:ra,selector:"as-language-picker"},Symbol.toStringTag,{value:"Module"}));Ti.APPLICATION_NAME=Rs,Ti.CUSTOM_MESSAGES=vl,Ti.LanguagePicker=C0,Ti.WebComponentsRegistry=nu,Object.defineProperty(Ti,Symbol.toStringTag,{value:"Module"})}));
3961
+ `,this._shadowRoot.appendChild(t)}_setupFlags(t,e){const i=t.length;this._circleRadius=Math.max(5,3+i*.5),this._cameraLookAtY=this._circleRadius*.4,t.forEach((l,c)=>{const u=-(c/i*Math.PI*2),d=-Math.sin(u)*this._circleRadius,f=Math.cos(u)*this._circleRadius,g=Di.buildFlag(),_=Di.buildFlagpole({flagpoleType:Di.FLAG_POLE_TYPE.VERTICAL},g),m=new Di.FlagGroup({flagpole:_,flag:g});m.object.position.set(d,0,f);const p=new np,T=`/textures/flags/${la.get(l)?.isoCode}.png`;let b=!1;p.load(T,w=>{b||(m.setTexture(w),b=!0)},void 0,()=>{}),this._flagsGroup.add(m.object);const y=Math.random(),R={id:l,flagGroup:m,object:m.object,angle:u,wind:null,windPhase:Math.random()*Math.PI*2,randomSeed:y};this._languages.push(R)});const n=e!=null&&e.length>0?t.indexOf(e):-1,r=n>=0?n:0;if(r>=0&&r<this._languages.length){this._selectedLanguageIndex=r,this._currentVisibleButtonIndex=r;const l=this._languages[r].angle;this._targetGroupRotation=l,this._currentGroupRotation=l,this._unwrappedGroupRotation=l,this._flagsGroup.rotation.y=l}const a=this._computeIntroCameraEndPosition(),o=a.y,h=a.z;this._introCameraEndPosition.copy(a),this._introCameraStartPosition.set(0,o+this._circleRadius*3.1,h+this._circleRadius*4.6),this._camera.position.copy(this._introCameraStartPosition),this._controls.target.set(0,this._cameraLookAtY,0),this._controls.update(),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()}_computeIntroCameraEndPosition(){const t=new cs().setFromObject(this._flagsGroup),e=new N,i=new N;t.getSize(e),t.getCenter(i);const n=t.min.y,r=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,h=2*Math.atan(Math.tan(a*.5)*o),l=r/Math.tan(a*.5),c=r/Math.tan(h*.5),u=Math.max(l,c)*1.05,d=n+e.y*.25,f=d+Math.max(e.y*.8,this._circleRadius*.28);this._cameraLookAtY=d+e.y*.06;const g=i.z+u+this._circleRadius*.01;return new N(0,f,g)}_setupLanguageDialog(){this._confirmationDialog=document.createElement(Cl.selector),this._confirmationDialog.id="confirmation-dialog",this._shadowRoot.appendChild(this._confirmationDialog),this._confirmationDialog.addEventListener(Cl.COMPONENT_CUSTOM_MESSAGES.CONFIRMATION_DIALOG_CONFIRM,this._handleConfirmation);const t=e=>{const i=this._languages[e];if(i==null)return;this._updateGroupRotationToLanguage(e);const n=la.get(i.id);n!=null&&(this._confirmationDialog.value=n.id,this._confirmationDialog.headline="Switch language?",this._confirmationDialog.text=`Are you sure you want to switch the language to ${n.language.toLowerCase()}?`,this._confirmationDialog.showModal())};this._languages.forEach((e,i)=>{const n=document.createElement(lu.selector);n.textContent=la.get(e.id)?.autonyms??e.id,n.addEventListener(su.CLICK,()=>{t(i)}),this._languageButtons.push(n),this._barMenu.appendChild(n)})}_handleConfirmation=()=>{const t=this._confirmationDialog.value,e=this._languages.findIndex(n=>n.id===t);if(e===-1||e===this._selectedLanguageIndex)return;const i=new CustomEvent(Kc.LANGUAGE_CHANGE_CONFIRMED,{detail:{value:t},bubbles:!0,composed:!0});this.dispatchEvent(i)};_setupEventListeners(){}_checkVisibleButtonChange(){const t=Array.from(this._barMenu.children);for(let e=0;e<t.length;e++){const i=t[e],n=window.getComputedStyle(i);if(n.display!=="none"&&n.visibility!=="hidden"&&n.opacity!=="0"){e!==this._currentVisibleButtonIndex&&(this._currentVisibleButtonIndex=e,this._updateGroupRotationToLanguage(e));break}}}_updateGroupRotationToLanguage(t){const e=this._languages[t].angle,i=2*Math.PI;let n=e;for(;Math.abs(n-this._unwrappedGroupRotation)>Math.PI;)n<this._unwrappedGroupRotation?n+=i:n-=i;this._targetGroupRotation=n,this._unwrappedGroupRotation=n,this._controls.enabled=!1}_updateGroupRotation(){if(this._flagsGroup==null)return;const t=this._targetGroupRotation-this._currentGroupRotation;this._currentGroupRotation+=t*.1,Math.abs(t)<.01&&(this._controls.enabled=!0),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._controls.target.set(0,this._cameraLookAtY,0),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),r=this._introCameraStartPosition.z+(this._introCameraEndPosition.z-this._introCameraStartPosition.z)*i,a=this._introCameraStartPosition.y+(this._introCameraEndPosition.y-this._introCameraStartPosition.y)*n;this._setMenuIntroScale(i),this._camera.position.set(0,a,r),this._controls.target.set(0,this._cameraLookAtY,0),e>=1&&(this._isIntroCameraAnimating=!1,this._camera.position.copy(this._introCameraEndPosition),this._controls.target.set(0,this._cameraLookAtY,0),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})`}_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._languages.forEach((i,n)=>{if(i.flagGroup!=null){i.windPhase+=e*(.5+i.randomSeed*1.5),Di.applyGravityToCloth(i.flagGroup.flag.cloth,i.flagGroup.flag.object),this._wind!=null&&Di.applyWindForceToCloth(i.flagGroup.flag.cloth,this._wind,i.flagGroup.flag.object,{randomizeAmount:.6,randomSeed:i.randomSeed});const r=.3+Math.sin(i.windPhase)*.2,a=new Di.Wind({speed:r,direction:new N(Math.sin(i.windPhase+n)*.5,Math.cos(i.windPhase*.7),Math.sin(i.windPhase*.5+n)).normalize()});Di.applyWindForceToCloth(i.flagGroup.flag.cloth,a,i.flagGroup.flag.object,{randomizeAmount:.5,randomSeed:i.randomSeed*2}),i.flagGroup.simulate(e),i.flagGroup.render()}}),this._updateGroupRotation(),this._updateIntroCamera(e),this._checkVisibleButtonChange(),this._controls.update(),this._renderer.render(this._scene,this._camera)}catch(t){console.error("Animation loop error:",t),cancelAnimationFrame(this._animationFrameId)}};connectedCallback(){try{this._isInitialized&&(this._animationFrameId=requestAnimationFrame(this._animate))}catch(t){console.error("Failed to start animation:",t)}}disconnectedCallback(){cancelAnimationFrame(this._animationFrameId),this._languages.forEach(t=>{t.flagGroup!=null&&t.flagGroup.destroy(),this._scene.remove(t.object)}),this._lights.forEach(t=>{t.dispose()}),this._scene.clear(),this._renderer.dispose(),this._resizeObserver.disconnect()}addLanguage(t){}addLocales(t){}removeLanguage(t){}removeLocales(t){}selectLanguage(t){}}const C0=Object.freeze(Object.defineProperty({__proto__:null,COMPONENT_CUSTOM_MESSAGES:Kc,LanguagePickerComponent:ra,selector:"as-language-picker"},Symbol.toStringTag,{value:"Module"}));Ti.APPLICATION_NAME=Rs,Ti.CUSTOM_MESSAGES=vl,Ti.LanguagePicker=C0,Ti.WebComponentsRegistry=nu,Object.defineProperty(Ti,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@albi_scando/as-design-system-threejs-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
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": [