lunchboxjs 2.2.0 → 2.2.2
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/lunchboxjs.cjs +11 -11
- package/dist/lunchboxjs.js +7 -0
- package/dist/lunchboxjs.umd.cjs +11 -11
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/three-base.ts +2 -2
package/dist/lunchboxjs.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("three");function Ie(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const p=Ie(ke),X=["WebGLRenderer","Scene","Group","Object3D","Mesh","Sprite","BoxGeometry","BufferGeometry","CircleGeometry","ConeGeometry","CylinderGeometry","DodecahedronGeometry","ExtrudeGeometry","IcosahedronGeometry","InstancedBufferGeometry","LatheGeometry","OctahedronGeometry","PlaneGeometry","PolyhedronGeometry","RingGeometry","ShapeGeometry","SphereGeometry","TetrahedronGeometry","TorusGeometry","TorusKnotGeometry","TubeGeometry","WireframeGeometry","PointsMaterial","ShaderMaterial","ShadowMaterial","SpriteMaterial","MeshToonMaterial","MeshBasicMaterial","MeshDepthMaterial","MeshPhongMaterial","LineBasicMaterial","RawShaderMaterial","MeshMatcapMaterial","MeshNormalMaterial","LineDashedMaterial","MeshLambertMaterial","MeshStandardMaterial","MeshDistanceMaterial","MeshPhysicalMaterial","Light","SpotLight","SpotLightHelper","PointLight","PointLightHelper","AmbientLight","RectAreaLight","HemisphereLight","HemisphereLightHelper","DirectionalLight","DirectionalLightHelper","CubeCamera","ArrayCamera","StereoCamera","PerspectiveCamera","OrthographicCamera","Texture","CubeTexture","DataTexture","DepthTexture","VideoTexture","CanvasTexture","CompressedTexture","CatmullRomCurve3","Points","Raycaster","CameraHelper","Color","TextureLoader"];/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/const k=globalThis,Q=k.ShadowRoot&&(k.ShadyCSS===void 0||k.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ee=Symbol(),oe=new WeakMap;let _e=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==ee)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Q&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=oe.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&oe.set(t,e))}return e}toString(){return this.cssText}};const Be=i=>new _e(typeof i=="string"?i:i+"",void 0,ee),Ge=(i,...e)=>{const t=i.length===1?i[0]:e.reduce((s,r,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+i[n+1],i[0]);return new _e(t,i,ee)},ze=(i,e)=>{if(Q)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const s=document.createElement("style"),r=k.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=t.cssText,i.appendChild(s)}},ae=Q?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return Be(t)})(i):i;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:
|
|
9
|
+
*/const{is:qe,defineProperty:Ve,getOwnPropertyDescriptor:We,getOwnPropertyNames:Fe,getOwnPropertySymbols:Je,getPrototypeOf:Ke}=Object,g=globalThis,he=g.trustedTypes,Ze=he?he.emptyScript:"",q=g.reactiveElementPolyfillSupport,O=(i,e)=>i,I={toAttribute(i,e){switch(e){case Boolean:i=i?Ze:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},te=(i,e)=>!qe(i,e),ce={attribute:!0,type:String,converter:I,reflect:!1,useDefault:!1,hasChanged:te};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),g.litPropertyMetadata??(g.litPropertyMetadata=new WeakMap);let S=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ce){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(e,s,t);r!==void 0&&Ve(this.prototype,e,r)}}static getPropertyDescriptor(e,t,s){const{get:r,set:n}=We(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){const a=r==null?void 0:r.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ce}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const e=Ke(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const t=this.properties,s=[...Fe(t),...Je(t)];for(const r of s)this.createProperty(r,t[r])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[s,r]of t)this.elementProperties.set(s,r)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const r=this._$Eu(t,s);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const r of s)t.unshift(ae(r))}else e!==void 0&&t.push(ae(e));return t}static _$Eu(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ze(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostConnected)==null?void 0:s.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostDisconnected)==null?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){var n;const s=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,s);if(r!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:I).toAttribute(t,s.type);this._$Em=e,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(e,t){var n,o;const s=this.constructor,r=s._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const a=s.getPropertyOptions(r),h=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:I;this._$Em=r;const c=h.fromAttribute(t,a.type);this[r]=c??((o=this._$Ej)==null?void 0:o.get(r))??c,this._$Em=null}}requestUpdate(e,t,s,r=!1,n){var o;if(e!==void 0){const a=this.constructor;if(r===!1&&(n=this[e]),s??(s=a.getPropertyOptions(e)),!((s.hasChanged??te)(n,t)||s.useDefault&&s.reflect&&n===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(a._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:r,wrapped:n},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[n,o]of r){const{wrapped:a}=o,h=this[n];a!==!0||this._$AL.has(n)||h===void 0||this.C(n,void 0,o,h)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(s=this._$EO)==null||s.forEach(r=>{var n;return(n=r.hostUpdate)==null?void 0:n.call(r)}),this.update(t)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(s=>{var r;return(r=s.hostUpdated)==null?void 0:r.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[O("elementProperties")]=new Map,S[O("finalized")]=new Map,q==null||q({ReactiveElement:S}),(g.reactiveElementVersions??(g.reactiveElementVersions=[])).push("2.1.2");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const x=globalThis,
|
|
14
|
-
\f\r]`,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
13
|
+
*/const x=globalThis,le=i=>i,B=x.trustedTypes,de=B?B.createPolicy("lit-html",{createHTML:i=>i}):void 0,be="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,ve="?"+$,Ye=`<${ve}>`,w=document,N=()=>w.createComment(""),L=i=>i===null||typeof i!="object"&&typeof i!="function",se=Array.isArray,Xe=i=>se(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",V=`[
|
|
14
|
+
\f\r]`,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ue=/-->/g,pe=/>/g,_=RegExp(`>|${V}(?:([^\\s"'>=/]+)(${V}*=${V}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),me=/'/g,fe=/"/g,Ce=/^(?:script|style|textarea|title)$/i,Qe=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),re=Qe(1),T=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),ye=new WeakMap,b=w.createTreeWalker(w,129);function we(i,e){if(!se(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return de!==void 0?de.createHTML(e):e}const et=(i,e)=>{const t=i.length-1,s=[];let r,n=e===2?"<svg>":e===3?"<math>":"",o=M;for(let a=0;a<t;a++){const h=i[a];let c,d,l=-1,m=0;for(;m<h.length&&(o.lastIndex=m,d=o.exec(h),d!==null);)m=o.lastIndex,o===M?d[1]==="!--"?o=ue:d[1]!==void 0?o=pe:d[2]!==void 0?(Ce.test(d[2])&&(r=RegExp("</"+d[2],"g")),o=_):d[3]!==void 0&&(o=_):o===_?d[0]===">"?(o=r??M,l=-1):d[1]===void 0?l=-2:(l=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?_:d[3]==='"'?fe:me):o===fe||o===me?o=_:o===ue||o===pe?o=M:(o=_,r=void 0);const E=o===_&&i[a+1].startsWith("/>")?" ":"";n+=o===M?h+Ye:l>=0?(s.push(c),h.slice(0,l)+be+h.slice(l)+$+E):h+$+(l===-2?a:E)}return[we(i,n+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};class U{constructor({strings:e,_$litType$:t},s){let r;this.parts=[];let n=0,o=0;const a=e.length-1,h=this.parts,[c,d]=et(e,t);if(this.el=U.createElement(c,s),b.currentNode=this.el.content,t===2||t===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(r=b.nextNode())!==null&&h.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const l of r.getAttributeNames())if(l.endsWith(be)){const m=d[o++],E=r.getAttribute(l).split($),D=/([.?@])?(.*)/.exec(m);h.push({type:1,index:n,name:D[2],strings:E,ctor:D[1]==="."?st:D[1]==="?"?rt:D[1]==="@"?it:z}),r.removeAttribute(l)}else l.startsWith($)&&(h.push({type:6,index:n}),r.removeAttribute(l));if(Ce.test(r.tagName)){const l=r.textContent.split($),m=l.length-1;if(m>0){r.textContent=B?B.emptyScript:"";for(let E=0;E<m;E++)r.append(l[E],N()),b.nextNode(),h.push({type:2,index:++n});r.append(l[m],N())}}}else if(r.nodeType===8)if(r.data===ve)h.push({type:2,index:n});else{let l=-1;for(;(l=r.data.indexOf($,l+1))!==-1;)h.push({type:7,index:n}),l+=$.length-1}n++}}static createElement(e,t){const s=w.createElement("template");return s.innerHTML=e,s}}function P(i,e,t=i,s){var o,a;if(e===T)return e;let r=s!==void 0?(o=t._$Co)==null?void 0:o[s]:t._$Cl;const n=L(e)?void 0:e._$litDirective$;return(r==null?void 0:r.constructor)!==n&&((a=r==null?void 0:r._$AO)==null||a.call(r,!1),n===void 0?r=void 0:(r=new n(i),r._$AT(i,t,s)),s!==void 0?(t._$Co??(t._$Co=[]))[s]=r:t._$Cl=r),r!==void 0&&(e=P(i,r._$AS(i,e.values),r,s)),e}class tt{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:s}=this._$AD,r=((e==null?void 0:e.creationScope)??w).importNode(t,!0);b.currentNode=r;let n=b.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new j(n,n.nextSibling,this,e):h.type===1?c=new h.ctor(n,h.name,h.strings,this,e):h.type===6&&(c=new nt(n,this,e)),this._$AV.push(c),h=s[++a]}o!==(h==null?void 0:h.index)&&(n=b.nextNode(),o++)}return b.currentNode=w,r}p(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class j{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,s,r){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=r,this._$Cv=(r==null?void 0:r.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=P(this,e,t),L(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==T&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Xe(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==u&&L(this._$AH)?this._$AA.nextSibling.data=e:this.T(w.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:s}=e,r=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=U.createElement(we(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===r)this._$AH.p(t);else{const o=new tt(r,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=ye.get(e.strings);return t===void 0&&ye.set(e.strings,t=new U(e)),t}k(e){se(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,r=0;for(const n of e)r===t.length?t.push(s=new j(this.O(N()),this.O(N()),this,this.options)):s=t[r],s._$AI(n),r++;r<t.length&&(this._$AR(s&&s._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,t);e!==this._$AB;){const r=le(e).nextSibling;le(e).remove(),e=r}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class z{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,r,n){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=u}_$AI(e,t=this,s,r){const n=this.strings;let o=!1;if(n===void 0)e=P(this,e,t,0),o=!L(e)||e!==this._$AH&&e!==T,o&&(this._$AH=e);else{const a=e;let h,c;for(e=n[0],h=0;h<n.length-1;h++)c=P(this,a[s+h],t,h),c===T&&(c=this._$AH[h]),o||(o=!L(c)||c!==this._$AH[h]),c===u?e=u:e!==u&&(e+=(c??"")+n[h+1]),this._$AH[h]=c}o&&!r&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class st extends z{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}}class rt extends z{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}}class it extends z{constructor(e,t,s,r,n){super(e,t,s,r,n),this.type=5}_$AI(e,t=this){if((e=P(this,e,t,0)??u)===T)return;const s=this._$AH,r=e===u&&s!==u||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,n=e!==u&&(s===u||r);r&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class nt{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){P(this,e)}}const W=x.litHtmlPolyfillSupport;W==null||W(U,j),(x.litHtmlVersions??(x.litHtmlVersions=[])).push("3.3.2");const ot=(i,e,t)=>{const s=(t==null?void 0:t.renderBefore)??e;let r=s._$litPart$;if(r===void 0){const n=(t==null?void 0:t.renderBefore)??null;s._$litPart$=r=new j(e.insertBefore(N(),n),n,void 0,t??{})}return r._$AI(i),r};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/const v=globalThis;class C extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=
|
|
19
|
+
*/const v=globalThis;class C extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ot(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return T}}var Ae;C._$litElement$=!0,C.finalized=!0,(Ae=v.litElementHydrateSupport)==null||Ae.call(v,{LitElement:C});const F=v.litElementPolyfillSupport;F==null||F({LitElement:C});(v.litElementVersions??(v.litElementVersions=[])).push("4.2.2");const Se=(i,e,t)=>{if(!e)return;const s=Array.isArray(e)?e:e.match(/([^[.\]])+/g),r=s==null?void 0:s.reduce((n,o)=>n&&n[o],i);return r===void 0?t:r};function Te(i){if(!i)return!1;const e=i.constructor&&i.constructor.toString().substring(0,5)==="class";if(i.prototype===void 0)return e;const t=i.prototype.constructor&&i.prototype.constructor.toString&&i.prototype.constructor.toString().substring(0,5)==="class";return e||t}const at=()=>{const i="[object Number]",t=Object.prototype.toString;function s(n){return!!n&&typeof n=="object"}return function(o){return typeof o=="number"||s(o)&&t.call(o)==i}},Pe=at(),Me=(i,e,t)=>{const s=Array.isArray(e)?e:e.match(/([^[.\]])+/g);s==null||s.reduce((r,n,o)=>(r[n]===void 0&&(r[n]={}),o===s.length-1&&(r[n]=t),r[n]),i)},ie="data-three-uuid",K=i=>{var t,s,r;let e=i.parentNode;for(;e&&!(e!=null&&e.instance)&&!((t=e==null?void 0:e.three)!=null&&t.scene);)e=(e==null?void 0:e.parentNode)||(e==null?void 0:e.host)||((r=(s=e.getRootNode)==null?void 0:s.call(e))==null?void 0:r.host);return e};function R(i,e){return i?i instanceof ShadowRoot?R(i.host,e):i instanceof HTMLElement&&(typeof e=="string"&&i.matches(e)||typeof e=="function"&&e(i))?i:R(i.parentNode,e):null}const Z=(i,e,t)=>{var n,o;const s=Se(i,e);if(Pe(t)&&(s!=null&&s.setScalar))s.setScalar(+t);else if(s!=null&&s.set)if(typeof t=="string"){const a=t.split(","),h=a.every(c=>!c.match(/^[^\d,]+$/));if((n=t.toLowerCase().trim().match(/^#[\dabcdef]{3,6}$/))!=null&&n.length)if(t.length===4){const c=[t[1],t[1],t[2],t[2],t[3],t[3]].join("");s.set(+`0x${c}`)}else s.set(+`0x${t.slice(1)}`);else a!=null&&a.length&&h?s.set(...a.map(c=>+c)):s.set(t)}else{const a=Array.isArray(t)?t:[t];s.set(...a)}else Me(i,e,t);const r=i;typeof r.type=="string"&&((o=r.type)!=null&&o.toLowerCase().endsWith("material"))&&(r.needsUpdate=!0)},J={$scene:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.scene},$camera:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.camera},$renderer:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.renderer},$domElement:i=>{var t;const e=i.closest("three-lunchbox");return(t=e==null?void 0:e.three.renderer)==null?void 0:t.domElement}},G=(i,e)=>{var s;if(typeof i!="string")return i;if(i==="")return!0;const t=(s=J[i])==null?void 0:s.call(J,e);return CSS.supports("color",i)?new p.Color(i):t??i};/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const ht={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:
|
|
23
|
+
*/const ht={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:te},ct=(i=ht,e,t)=>{const{kind:s,metadata:r}=t;let n=globalThis.litPropertyMetadata.get(r);if(n===void 0&&globalThis.litPropertyMetadata.set(r,n=new Map),s==="setter"&&((i=Object.create(i)).wrapped=!0),n.set(t.name,i),s==="accessor"){const{name:o}=t;return{set(a){const h=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,h,i,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,i,a),a}}}if(s==="setter"){const{name:o}=t;return function(a){const h=this[o];e.call(this,a),this.requestUpdate(o,h,i,!0,a)}}throw Error("Unsupported decorator location: "+s)};function y(i){return(e,t)=>typeof t=="object"?ct(i,e,t):((s,r,n)=>{const o=r.hasOwnProperty(n);return r.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(r,n):void 0})(i,e,t)}/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/function lt(i){return y({...i,state:!0,attribute:!1})}var dt=Object.defineProperty,
|
|
27
|
+
*/function lt(i){return y({...i,state:!0,attribute:!1})}var dt=Object.defineProperty,Oe=(i,e,t,s)=>{for(var r=void 0,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(e,t,r)||r);return r&&dt(e,t,r),r};const Y="raycast",Ee=[Y,"args","data"],$e=i=>i.split("-");class H extends C{constructor(e){super(),this.classSource=e,this.instance=null,this.dispose=[],this.mutationObserver=null,this.tryAddOnce=!1,this.connected=!1}observeAttributes(){this.mutationObserver=new MutationObserver(e=>{e.forEach(t=>{var r;if(!t.attributeName||(r=Object.getPrototypeOf(this).constructor.observedAttributes)!=null&&r.includes(t.attributeName))return;const s=this.attributes.getNamedItem(t.attributeName);s&&this.updateProperty(s)})}),this.mutationObserver.observe(this,{attributes:!0})}parsedArgs(){const e=this.args??this.getAttribute("args")??[];return typeof e=="string"?JSON.parse(e):e}createUnderlyingThreeObject(){this.instance=new this.classSource(...this.parsedArgs().map(e=>G(e,this)))}refreshAttributes(){this.getAttributeNames().forEach(e=>{const t=this.attributes.getNamedItem(e);t&&this.updateProperty(t)}),Array.from(this.attributes).forEach(this.updateProperty.bind(this))}async onUnderlyingThreeObjectReady(){var s,r,n,o;const e=this.instance;e.uuid&&this.setAttribute(ie,e.uuid);let t=K(this);for(;this!=null&&this.connected&&!this.tryAddOnce&&!t;)await new Promise(requestAnimationFrame),t=K(this);if(t&&t.instance||(s=t==null?void 0:t.three)!=null&&s.scene){const a=this.instance,h=this.instance,c=t.instance,d=t.instance??((r=t.three)==null?void 0:r.scene),l=this.instance;if((n=a.type)!=null&&n.toLowerCase().includes("geometry")&&c.geometry)c.geometry=a;else if((o=h.type)!=null&&o.toLowerCase().includes("material")&&c.material)c.material=h;else if(d.add)try{d.add(l),this.dispatchEvent(new CustomEvent("instanceadded",{detail:{instance:this.instance,parent:d}}))}catch{throw new Error(`Error adding ${this.tagName} to ${d}`)}const m=this.getAttribute("attach");m&&this.executeAttach(m,this.instance)}}connectedCallback(){super.connectedCallback(),this.observeAttributes.call(this),this.createUnderlyingThreeObject.call(this),this.refreshAttributes.call(this),this.dispatchEvent(new CustomEvent("instancecreated",{detail:{instance:this.instance}})),this.connected=!0,this.onUnderlyingThreeObjectReady.call(this)}updateProperty(e){const{name:t,value:s}=e;let r=t;Object.keys(this.instance??{}).forEach(a=>{a.toLowerCase()===r&&(r=a)});const n=$e(r);if(Ee.includes(r)||Ee.includes(n[0]))return;let o=G(s,this);try{o=JSON.parse(s===""?"true":s)}catch{}this.instance&&Z(this.instance,n,o)}executeAttach(e,t){const s=this.parentElement;s.instance&&Z(s.instance,$e(e),t)}disconnectedCallback(){super.disconnectedCallback();const e=[this.instance];this.disposeThreeObjects.call(this,e),this.connected=!1}disposeThreeObjects(e){e.forEach(t=>{var n,o;if(!t)return;const s=t,r=t;(n=s.dispose)==null||n.call(s),(o=r.removeFromParent)==null||o.call(r)})}render(){return re`<slot></slot>`}createRenderRoot(){return this}}Oe([y({type:Boolean,attribute:"try-add-once"})],H.prototype,"tryAddOnce");Oe([lt()],H.prototype,"connected");const xe=i=>{const e=typeof i=="string"?p[i]:i;if(!Te(e))return null;const t=i.toString().toLowerCase().endsWith("loader");class s extends H{constructor(){super(e)}}class r extends H{constructor(){super(...arguments),this.loader=null}createUnderlyingThreeObject(){this.loader=new e(...this.parsedArgs().map(o=>G(o,this)))}async onUnderlyingThreeObjectReady(){const o=this.getAttribute("src");if(!o)throw new Error("Loader requires a source.");if(!this.loader)throw new Error(`Missing loader ${this.tagName}`);this.loader.load(o,a=>{this.instance=a;const h=this.getAttribute("attach");h&&this.executeAttach(h,a),this.refreshAttributes.call(this),this.dispatchEvent(new CustomEvent("loaded",{detail:{instance:a}}))},void 0,a=>{throw new Error(`error loading: ${o}`+a)})}disconnectedCallback(){super.disconnectedCallback(),this.disposeThreeObjects.call(this,[this.loader])}}return t?r:s};var ut=Object.defineProperty,A=(i,e,t,s)=>{for(var r=void 0,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(e,t,r)||r);return r&&ut(e,t,r),r};const pt="orthographic",ge=1/0,ne=class ne extends C{constructor(){super(),this.scratchV2=new p.Vector2,this.background=null,this.dpr=ge,this.headless=!1,this.manualRender=!1,this.dispatchBeforeRender=!1,this.dispatchAfterRender=!1,this.rendererArgs=[],this.cameraArgs=[],this.raycaster=new p.Raycaster,this.raycastPool=[],this.frame=1/0,this.three=this.createThree(),this.resizeObserver=new ResizeObserver(e=>{e.forEach(({target:t,contentRect:s})=>{var r;if(t===this&&((r=this.three.renderer)==null||r.setSize(s.width*this.dpr,s.height*this.dpr),this.three.camera)){const n=s.width/s.height;if(this.three.camera.type.toLowerCase()==="perspectivecamera")this.three.camera.aspect=n,this.three.camera.updateProjectionMatrix();else if(this.three.camera.type.toLowerCase()==="orthographiccamera"){const o=s.height/s.width,a=10;this.three.camera.top=o*a,this.three.camera.bottom=-o*a,this.three.camera.right=a,this.three.camera.left=-a,this.three.camera.updateProjectionMatrix()}this.manualRender||this.renderThree()}})})}createDefaultScene(){return new p.Scene}createThree(){return{scene:this.createDefaultScene(),camera:null,renderer:null}}connectedCallback(){if(super.connectedCallback(),this.dpr===ge&&(this.dpr=window.devicePixelRatio),this.getAttribute(pt)!==null?this.three.camera=new p.OrthographicCamera(...this.cameraArgs):this.three.camera=new p.PerspectiveCamera(...this.cameraArgs.length?this.cameraArgs:[75]),["scene","camera","renderer"].forEach(e=>{const t=this[e]??this.getAttribute(e)??{},s=typeof t=="string"?JSON.parse(t):t;Object.entries(s).forEach(([r,n])=>{this.three[e]&&Z(this.three[e],r.split("-"),G(n,this))})}),this.resizeObserver.observe(this),this.background!==null&&(this.three.scene.background=new p.Color(this.background)),!this.headless){const e=new p.WebGLRenderer(...this.rendererArgs);e.domElement.addEventListener("pointermove",this.onPointerMove.bind(this)),e.domElement.addEventListener("mousemove",this.onPointerMove.bind(this)),e.domElement.addEventListener("click",this.onClick.bind(this)),this.three.renderer=e}this.manualRender||this.updateLoop()}disconnectedCallback(){var e,t,s,r;(e=this.three.renderer)==null||e.domElement.removeEventListener("pointermove",this.onPointerMove.bind(this)),(t=this.three.renderer)==null||t.domElement.removeEventListener("mousemove",this.onPointerMove.bind(this)),(s=this.three.renderer)==null||s.domElement.removeEventListener("click",this.onClick.bind(this)),(r=this.three.renderer)==null||r.dispose(),this.resizeObserver.unobserve(this),cancelAnimationFrame(this.frame)}handleDefaultSlotChange(e){e.target.assignedElements().forEach(t=>{const s=t;s.instance instanceof p.Object3D&&t.getAttributeNames().includes(Y)&&t.getAttributeNames().includes(Y)&&this.raycastPool.push(s.instance)}),this.renderThree()}runRaycast(e){var a,h;if(!this.raycastPool.length||!this.three.camera)return[];const t=((a=this.three.renderer)==null?void 0:a.domElement.width)??0,s=((h=this.three.renderer)==null?void 0:h.domElement.height)??0,r=this.scratchV2.clone().set(e.clientX/(t/this.dpr)*2-1,-(e.clientY/(s/this.dpr))*2+1);return this.raycaster.setFromCamera(r,this.three.camera),this.raycaster.intersectObjects(this.raycastPool).map(c=>({intersect:c,element:this.querySelector(`[${ie}="${c.object.uuid}"]`)}))}onPointerMove(e){this.runRaycast.bind(this)(e).forEach(s=>{var r,n,o,a;e.type==="pointermove"?((r=s.element)==null||r.dispatchEvent(new PointerEvent("pointermove")),(n=s.element)==null||n.dispatchEvent(new CustomEvent(Ne,{detail:s}))):e.type==="mousemove"&&((o=s.element)==null||o.dispatchEvent(new MouseEvent("mousemove")),(a=s.element)==null||a.dispatchEvent(new CustomEvent(Le,{detail:s})))})}onClick(e){let t=[];if(e instanceof TouchEvent){const s=e.touches[0];t=this.runRaycast.bind(this)(s),t.forEach(r=>{var n;(n=r.element)==null||n.dispatchEvent(new TouchEvent("touchstart"))})}else t=this.runRaycast.bind(this)(e),t.forEach(s=>{var r;(r=s.element)==null||r.dispatchEvent(new MouseEvent("click"))});t.forEach(s=>{var r;(r=s.element)==null||r.dispatchEvent(new CustomEvent(Ue,{detail:s}))})}updateLoop(){this.renderThree(),this.manualRender||(this.frame=requestAnimationFrame(this.updateLoop.bind(this)))}renderThree(e,t){var s;this.dispatchBeforeRender&&this.dispatchEvent(new CustomEvent(He,{})),this.three.camera&&((s=this.three.renderer)==null||s.render(e??this.three.scene,t??this.three.camera),this.dispatchAfterRender&&this.dispatchEvent(new CustomEvent(je,{})))}render(){var e;return re`
|
|
28
28
|
<slot @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
29
29
|
${(e=this.three.renderer)==null?void 0:e.domElement}
|
|
30
|
-
`}};
|
|
30
|
+
`}};ne.styles=Ge`
|
|
31
31
|
:host {
|
|
32
32
|
width: 100%;
|
|
33
33
|
height: 100%;
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
max-width: 100%;
|
|
41
41
|
max-height: 100%;
|
|
42
42
|
}
|
|
43
|
-
`;let f=
|
|
43
|
+
`;let f=ne;A([y()],f.prototype,"background");A([y()],f.prototype,"dpr");A([y()],f.prototype,"headless");A([y({attribute:"manual-render",type:Boolean})],f.prototype,"manualRender");A([y({attribute:"dispatch-before-render",type:Boolean})],f.prototype,"dispatchBeforeRender");A([y({attribute:"dispatch-after-render",type:Boolean})],f.prototype,"dispatchAfterRender");A([y({attribute:"renderer-args",type:Object})],f.prototype,"rendererArgs");A([y({attribute:"camera-args",type:Object})],f.prototype,"cameraArgs");class Re extends C{constructor(){super(...arguments),this.parentLunchbox=null,this.frame=-1,this.scratchV3=new p.Vector3,this.scratchFrustum=new p.Frustum,this.scratchMatrix4=new p.Matrix4}tryAttachUpdate(){var o;const e=(o=this.parentLunchbox)==null?void 0:o.instance;if(!e)return!1;if(!e.isObject3D)throw new Error("html-anchor must be the child of an Object3D");const t=R(this,a=>{var h;return!!((h=a==null?void 0:a.three)!=null&&h.renderer)});if(!t)return console.error("three-lunchbox parent required for html-anchor"),!1;const s=t.three.camera;if(!s)return console.error("camera required for html-anchor"),!1;const r=t.three.renderer;if(!(r!=null&&r.domElement))return console.error("renderer and DOM element required for html-anchor"),!1;const n=()=>{this.frame=requestAnimationFrame(n),s.updateMatrix(),s.updateMatrixWorld(),e.getWorldPosition(this.scratchV3);const a=this.scratchV3.clone();this.scratchV3.project(s),this.scratchV3.multiplyScalar(.5).addScalar(.5),this.scratchV3.y=1-this.scratchV3.y;const h=this.scratchV3.clone().set(r.domElement.width,r.domElement.height,1);h.divideScalar(devicePixelRatio),this.scratchV3.multiply(h);const c=e.position.clone().distanceTo(s.getWorldPosition(this.scratchV3.clone()));this.scratchFrustum.setFromProjectionMatrix(this.scratchMatrix4.clone().multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse));const d=this.scratchFrustum.containsPoint(a);this.style.setProperty("--left",`${this.scratchV3.x}px`),this.style.setProperty("--top",`${this.scratchV3.y}px`),this.style.setProperty("--distance-from-camera",`${c}`),this.style.setProperty("--in-frustum",`${d?1:0}`),d?this.classList.add("in-frustum"):this.classList.remove("in-frustum")};return n(),!0}connectedCallback(){super.connectedCallback();const e=this.parentNode;if(!e)throw new Error("html-anchor requires a 3D parent");this.parentLunchbox=e,this.tryAttachUpdate()||this.parentLunchbox.addEventListener("instanceadded",()=>{if(!this.tryAttachUpdate())throw new Error("error attaching html-anchor to Object3D")},{once:!0})}disconnectedCallback(){this.frame!==-1&&cancelAnimationFrame(this.frame)}render(){return re`<slot></slot>`}createRenderRoot(){return this}}const mt=({prependList:i=[]}={})=>{Object.entries({"three-lunchbox":f,"html-anchor":Re}).forEach(([t,s])=>{customElements.get(t)||customElements.define(t,s)}),[...i,...X].forEach(t=>{const s=De(t);if(customElements.get(s))return;const r=xe(t);r&&customElements.define(s,r)})},ft=(i,e,t=window)=>{if(t.customElements.get(i)){console.log(`${i} already registered as a custom element. Try a different name if registering is still required.`);return}const s=xe(e);if(s)t.customElements.define(i,s);else throw new Error(`Could not extend ${i}. The second paramater must be a class.`)},Ne="threepointermove",Le="threemousemove",Ue="threeclick",He="beforerender",je="afterrender",De=i=>{let e=i.split(/\.?(?=[A-Z])/).join("-").toLowerCase().replace(/-g-l-/,"-gl-");return e.includes("-")||(e=`three-${e}`),e},yt=X.map(De);exports.AFTER_RENDER_EVENT_NAME=je;exports.BEFORE_RENDER_EVENT_NAME=He;exports.HtmlAnchor=Re;exports.THREE_CLICK_EVENT_NAME=Ue;exports.THREE_MOUSE_MOVE_EVENT_NAME=Le;exports.THREE_POINTER_MOVE_EVENT_NAME=Ne;exports.THREE_UUID_ATTRIBUTE_NAME=ie;exports.ThreeBase=H;exports.ThreeLunchbox=f;exports.autoComponents=X;exports.closestPassShadow=R;exports.extend=ft;exports.get=Se;exports.getCandidateParent=K;exports.initLunchbox=mt;exports.isClass=Te;exports.isNumber=Pe;exports.set=Me;exports.webComponentNames=yt;
|
package/dist/lunchboxjs.js
CHANGED
|
@@ -1235,10 +1235,17 @@ export {
|
|
|
1235
1235
|
ct as THREE_CLICK_EVENT_NAME,
|
|
1236
1236
|
ht as THREE_MOUSE_MOVE_EVENT_NAME,
|
|
1237
1237
|
at as THREE_POINTER_MOVE_EVENT_NAME,
|
|
1238
|
+
Ce as THREE_UUID_ATTRIBUTE_NAME,
|
|
1238
1239
|
G as ThreeBase,
|
|
1239
1240
|
f as ThreeLunchbox,
|
|
1240
1241
|
Ae as autoComponents,
|
|
1242
|
+
D as closestPassShadow,
|
|
1241
1243
|
ft as extend,
|
|
1244
|
+
Ze as get,
|
|
1245
|
+
me as getCandidateParent,
|
|
1242
1246
|
mt as initLunchbox,
|
|
1247
|
+
Ke as isClass,
|
|
1248
|
+
Xe as isNumber,
|
|
1249
|
+
Qe as set,
|
|
1243
1250
|
yt as webComponentNames
|
|
1244
1251
|
};
|
package/dist/lunchboxjs.umd.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],O):(d=typeof globalThis<"u"?globalThis:d||self,O(d.LunchboxJS={},d.three))})(this,function(d,O){"use strict";var Ie;function Be(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const m=Be(O),W=["WebGLRenderer","Scene","Group","Object3D","Mesh","Sprite","BoxGeometry","BufferGeometry","CircleGeometry","ConeGeometry","CylinderGeometry","DodecahedronGeometry","ExtrudeGeometry","IcosahedronGeometry","InstancedBufferGeometry","LatheGeometry","OctahedronGeometry","PlaneGeometry","PolyhedronGeometry","RingGeometry","ShapeGeometry","SphereGeometry","TetrahedronGeometry","TorusGeometry","TorusKnotGeometry","TubeGeometry","WireframeGeometry","PointsMaterial","ShaderMaterial","ShadowMaterial","SpriteMaterial","MeshToonMaterial","MeshBasicMaterial","MeshDepthMaterial","MeshPhongMaterial","LineBasicMaterial","RawShaderMaterial","MeshMatcapMaterial","MeshNormalMaterial","LineDashedMaterial","MeshLambertMaterial","MeshStandardMaterial","MeshDistanceMaterial","MeshPhysicalMaterial","Light","SpotLight","SpotLightHelper","PointLight","PointLightHelper","AmbientLight","RectAreaLight","HemisphereLight","HemisphereLightHelper","DirectionalLight","DirectionalLightHelper","CubeCamera","ArrayCamera","StereoCamera","PerspectiveCamera","OrthographicCamera","Texture","CubeTexture","DataTexture","DepthTexture","VideoTexture","CanvasTexture","CompressedTexture","CatmullRomCurve3","Points","Raycaster","CameraHelper","Color","TextureLoader"];/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/const I=globalThis,F=I.ShadowRoot&&(I.ShadyCSS===void 0||I.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,J=Symbol(),he=new WeakMap;let ce=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==J)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(F&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=he.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&he.set(t,e))}return e}toString(){return this.cssText}};const Ge=i=>new ce(typeof i=="string"?i:i+"",void 0,J),ze=(i,...e)=>{const t=i.length===1?i[0]:e.reduce((s,r,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+i[n+1],i[0]);return new ce(t,i,J)},qe=(i,e)=>{if(F)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const s=document.createElement("style"),r=I.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=t.cssText,i.appendChild(s)}},le=F?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return Ge(t)})(i):i;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:
|
|
9
|
+
*/const{is:Ve,defineProperty:We,getOwnPropertyDescriptor:Fe,getOwnPropertyNames:Je,getOwnPropertySymbols:Ke,getPrototypeOf:Ze}=Object,g=globalThis,de=g.trustedTypes,Ye=de?de.emptyScript:"",K=g.reactiveElementPolyfillSupport,R=(i,e)=>i,B={toAttribute(i,e){switch(e){case Boolean:i=i?Ye:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},Z=(i,e)=>!Ve(i,e),ue={attribute:!0,type:String,converter:B,reflect:!1,useDefault:!1,hasChanged:Z};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),g.litPropertyMetadata??(g.litPropertyMetadata=new WeakMap);let T=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ue){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(e,s,t);r!==void 0&&We(this.prototype,e,r)}}static getPropertyDescriptor(e,t,s){const{get:r,set:n}=Fe(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:r,set(o){const a=r==null?void 0:r.call(this);n==null||n.call(this,o),this.requestUpdate(e,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ue}static _$Ei(){if(this.hasOwnProperty(R("elementProperties")))return;const e=Ze(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(R("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(R("properties"))){const t=this.properties,s=[...Je(t),...Ke(t)];for(const r of s)this.createProperty(r,t[r])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[s,r]of t)this.elementProperties.set(s,r)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const r=this._$Eu(t,s);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const r of s)t.unshift(le(r))}else e!==void 0&&t.push(le(e));return t}static _$Eu(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return qe(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostConnected)==null?void 0:s.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostDisconnected)==null?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){var n;const s=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,s);if(r!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:B).toAttribute(t,s.type);this._$Em=e,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(e,t){var n,o;const s=this.constructor,r=s._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const a=s.getPropertyOptions(r),h=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:B;this._$Em=r;const c=h.fromAttribute(t,a.type);this[r]=c??((o=this._$Ej)==null?void 0:o.get(r))??c,this._$Em=null}}requestUpdate(e,t,s,r=!1,n){var o;if(e!==void 0){const a=this.constructor;if(r===!1&&(n=this[e]),s??(s=a.getPropertyOptions(e)),!((s.hasChanged??Z)(n,t)||s.useDefault&&s.reflect&&n===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(a._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:r,wrapped:n},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),r===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[n,o]of r){const{wrapped:a}=o,h=this[n];a!==!0||this._$AL.has(n)||h===void 0||this.C(n,void 0,o,h)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(s=this._$EO)==null||s.forEach(r=>{var n;return(n=r.hostUpdate)==null?void 0:n.call(r)}),this.update(t)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(s=>{var r;return(r=s.hostUpdated)==null?void 0:r.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};T.elementStyles=[],T.shadowRootOptions={mode:"open"},T[R("elementProperties")]=new Map,T[R("finalized")]=new Map,K==null||K({ReactiveElement:T}),(g.reactiveElementVersions??(g.reactiveElementVersions=[])).push("2.1.2");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const N=globalThis,
|
|
14
|
-
\f\r]`,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),
|
|
13
|
+
*/const N=globalThis,pe=i=>i,G=N.trustedTypes,me=G?G.createPolicy("lit-html",{createHTML:i=>i}):void 0,fe="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,ye="?"+A,Xe=`<${ye}>`,b=document,x=()=>b.createComment(""),L=i=>i===null||typeof i!="object"&&typeof i!="function",Y=Array.isArray,Qe=i=>Y(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",X=`[
|
|
14
|
+
\f\r]`,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ee=/-->/g,$e=/>/g,v=RegExp(`>|${X}(?:([^\\s"'>=/]+)(${X}*=${X}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ge=/'/g,Ae=/"/g,_e=/^(?:script|style|textarea|title)$/i,et=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),Q=et(1),P=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),be=new WeakMap,C=b.createTreeWalker(b,129);function ve(i,e){if(!Y(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return me!==void 0?me.createHTML(e):e}const tt=(i,e)=>{const t=i.length-1,s=[];let r,n=e===2?"<svg>":e===3?"<math>":"",o=U;for(let a=0;a<t;a++){const h=i[a];let c,u,l=-1,y=0;for(;y<h.length&&(o.lastIndex=y,u=o.exec(h),u!==null);)y=o.lastIndex,o===U?u[1]==="!--"?o=Ee:u[1]!==void 0?o=$e:u[2]!==void 0?(_e.test(u[2])&&(r=RegExp("</"+u[2],"g")),o=v):u[3]!==void 0&&(o=v):o===v?u[0]===">"?(o=r??U,l=-1):u[1]===void 0?l=-2:(l=o.lastIndex-u[2].length,c=u[1],o=u[3]===void 0?v:u[3]==='"'?Ae:ge):o===Ae||o===ge?o=v:o===Ee||o===$e?o=U:(o=v,r=void 0);const $=o===v&&i[a+1].startsWith("/>")?" ":"";n+=o===U?h+Xe:l>=0?(s.push(c),h.slice(0,l)+fe+h.slice(l)+A+$):h+A+(l===-2?a:$)}return[ve(i,n+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};class H{constructor({strings:e,_$litType$:t},s){let r;this.parts=[];let n=0,o=0;const a=e.length-1,h=this.parts,[c,u]=tt(e,t);if(this.el=H.createElement(c,s),C.currentNode=this.el.content,t===2||t===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(r=C.nextNode())!==null&&h.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const l of r.getAttributeNames())if(l.endsWith(fe)){const y=u[o++],$=r.getAttribute(l).split(A),V=/([.?@])?(.*)/.exec(y);h.push({type:1,index:n,name:V[2],strings:$,ctor:V[1]==="."?rt:V[1]==="?"?it:V[1]==="@"?nt:z}),r.removeAttribute(l)}else l.startsWith(A)&&(h.push({type:6,index:n}),r.removeAttribute(l));if(_e.test(r.tagName)){const l=r.textContent.split(A),y=l.length-1;if(y>0){r.textContent=G?G.emptyScript:"";for(let $=0;$<y;$++)r.append(l[$],x()),C.nextNode(),h.push({type:2,index:++n});r.append(l[y],x())}}}else if(r.nodeType===8)if(r.data===ye)h.push({type:2,index:n});else{let l=-1;for(;(l=r.data.indexOf(A,l+1))!==-1;)h.push({type:7,index:n}),l+=A.length-1}n++}}static createElement(e,t){const s=b.createElement("template");return s.innerHTML=e,s}}function M(i,e,t=i,s){var o,a;if(e===P)return e;let r=s!==void 0?(o=t._$Co)==null?void 0:o[s]:t._$Cl;const n=L(e)?void 0:e._$litDirective$;return(r==null?void 0:r.constructor)!==n&&((a=r==null?void 0:r._$AO)==null||a.call(r,!1),n===void 0?r=void 0:(r=new n(i),r._$AT(i,t,s)),s!==void 0?(t._$Co??(t._$Co=[]))[s]=r:t._$Cl=r),r!==void 0&&(e=M(i,r._$AS(i,e.values),r,s)),e}class st{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:s}=this._$AD,r=((e==null?void 0:e.creationScope)??b).importNode(t,!0);C.currentNode=r;let n=C.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let c;h.type===2?c=new j(n,n.nextSibling,this,e):h.type===1?c=new h.ctor(n,h.name,h.strings,this,e):h.type===6&&(c=new ot(n,this,e)),this._$AV.push(c),h=s[++a]}o!==(h==null?void 0:h.index)&&(n=C.nextNode(),o++)}return C.currentNode=b,r}p(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class j{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,s,r){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=r,this._$Cv=(r==null?void 0:r.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=M(this,e,t),L(e)?e===p||e==null||e===""?(this._$AH!==p&&this._$AR(),this._$AH=p):e!==this._$AH&&e!==P&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Qe(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==p&&L(this._$AH)?this._$AA.nextSibling.data=e:this.T(b.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:s}=e,r=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=H.createElement(ve(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===r)this._$AH.p(t);else{const o=new st(r,this),a=o.u(this.options);o.p(t),this.T(a),this._$AH=o}}_$AC(e){let t=be.get(e.strings);return t===void 0&&be.set(e.strings,t=new H(e)),t}k(e){Y(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,r=0;for(const n of e)r===t.length?t.push(s=new j(this.O(x()),this.O(x()),this,this.options)):s=t[r],s._$AI(n),r++;r<t.length&&(this._$AR(s&&s._$AB.nextSibling,r),t.length=r)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,t);e!==this._$AB;){const r=pe(e).nextSibling;pe(e).remove(),e=r}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class z{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,r,n){this.type=1,this._$AH=p,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(e,t=this,s,r){const n=this.strings;let o=!1;if(n===void 0)e=M(this,e,t,0),o=!L(e)||e!==this._$AH&&e!==P,o&&(this._$AH=e);else{const a=e;let h,c;for(e=n[0],h=0;h<n.length-1;h++)c=M(this,a[s+h],t,h),c===P&&(c=this._$AH[h]),o||(o=!L(c)||c!==this._$AH[h]),c===p?e=p:e!==p&&(e+=(c??"")+n[h+1]),this._$AH[h]=c}o&&!r&&this.j(e)}j(e){e===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class rt extends z{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===p?void 0:e}}class it extends z{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==p)}}class nt extends z{constructor(e,t,s,r,n){super(e,t,s,r,n),this.type=5}_$AI(e,t=this){if((e=M(this,e,t,0)??p)===P)return;const s=this._$AH,r=e===p&&s!==p||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,n=e!==p&&(s===p||r);r&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class ot{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){M(this,e)}}const ee=N.litHtmlPolyfillSupport;ee==null||ee(H,j),(N.litHtmlVersions??(N.litHtmlVersions=[])).push("3.3.2");const at=(i,e,t)=>{const s=(t==null?void 0:t.renderBefore)??e;let r=s._$litPart$;if(r===void 0){const n=(t==null?void 0:t.renderBefore)??null;s._$litPart$=r=new j(e.insertBefore(x(),n),n,void 0,t??{})}return r._$AI(i),r};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/const w=globalThis;class S extends T{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=
|
|
19
|
+
*/const w=globalThis;class S extends T{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=at(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return P}}S._$litElement$=!0,S.finalized=!0,(Ie=w.litElementHydrateSupport)==null||Ie.call(w,{LitElement:S});const te=w.litElementPolyfillSupport;te==null||te({LitElement:S}),(w.litElementVersions??(w.litElementVersions=[])).push("4.2.2");const Ce=(i,e,t)=>{if(!e)return;const s=Array.isArray(e)?e:e.match(/([^[.\]])+/g),r=s==null?void 0:s.reduce((n,o)=>n&&n[o],i);return r===void 0?t:r};function we(i){if(!i)return!1;const e=i.constructor&&i.constructor.toString().substring(0,5)==="class";if(i.prototype===void 0)return e;const t=i.prototype.constructor&&i.prototype.constructor.toString&&i.prototype.constructor.toString().substring(0,5)==="class";return e||t}const Se=(()=>{const i="[object Number]",t=Object.prototype.toString;function s(n){return!!n&&typeof n=="object"}return function(o){return typeof o=="number"||s(o)&&t.call(o)==i}})(),Te=(i,e,t)=>{const s=Array.isArray(e)?e:e.match(/([^[.\]])+/g);s==null||s.reduce((r,n,o)=>(r[n]===void 0&&(r[n]={}),o===s.length-1&&(r[n]=t),r[n]),i)},se="data-three-uuid",re=i=>{var t,s,r;let e=i.parentNode;for(;e&&!(e!=null&&e.instance)&&!((t=e==null?void 0:e.three)!=null&&t.scene);)e=(e==null?void 0:e.parentNode)||(e==null?void 0:e.host)||((r=(s=e.getRootNode)==null?void 0:s.call(e))==null?void 0:r.host);return e};function D(i,e){return i?i instanceof ShadowRoot?D(i.host,e):i instanceof HTMLElement&&(typeof e=="string"&&i.matches(e)||typeof e=="function"&&e(i))?i:D(i.parentNode,e):null}const ie=(i,e,t)=>{var n,o;const s=Ce(i,e);if(Se(t)&&(s!=null&&s.setScalar))s.setScalar(+t);else if(s!=null&&s.set)if(typeof t=="string"){const a=t.split(","),h=a.every(c=>!c.match(/^[^\d,]+$/));if((n=t.toLowerCase().trim().match(/^#[\dabcdef]{3,6}$/))!=null&&n.length)if(t.length===4){const c=[t[1],t[1],t[2],t[2],t[3],t[3]].join("");s.set(+`0x${c}`)}else s.set(+`0x${t.slice(1)}`);else a!=null&&a.length&&h?s.set(...a.map(c=>+c)):s.set(t)}else{const a=Array.isArray(t)?t:[t];s.set(...a)}else Te(i,e,t);const r=i;typeof r.type=="string"&&((o=r.type)!=null&&o.toLowerCase().endsWith("material"))&&(r.needsUpdate=!0)},ne={$scene:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.scene},$camera:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.camera},$renderer:i=>{const e=i.closest("three-lunchbox");return e==null?void 0:e.three.renderer},$domElement:i=>{var t;const e=i.closest("three-lunchbox");return(t=e==null?void 0:e.three.renderer)==null?void 0:t.domElement}},q=(i,e)=>{var s;if(typeof i!="string")return i;if(i==="")return!0;const t=(s=ne[i])==null?void 0:s.call(ne,e);return CSS.supports("color",i)?new m.Color(i):t??i};/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const ht={attribute:!0,type:String,converter:
|
|
23
|
+
*/const ht={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:Z},ct=(i=ht,e,t)=>{const{kind:s,metadata:r}=t;let n=globalThis.litPropertyMetadata.get(r);if(n===void 0&&globalThis.litPropertyMetadata.set(r,n=new Map),s==="setter"&&((i=Object.create(i)).wrapped=!0),n.set(t.name,i),s==="accessor"){const{name:o}=t;return{set(a){const h=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,h,i,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,i,a),a}}}if(s==="setter"){const{name:o}=t;return function(a){const h=this[o];e.call(this,a),this.requestUpdate(o,h,i,!0,a)}}throw Error("Unsupported decorator location: "+s)};function E(i){return(e,t)=>typeof t=="object"?ct(i,e,t):((s,r,n)=>{const o=r.hasOwnProperty(n);return r.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(r,n):void 0})(i,e,t)}/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/function lt(i){return E({...i,state:!0,attribute:!1})}var dt=Object.defineProperty,
|
|
27
|
+
*/function lt(i){return E({...i,state:!0,attribute:!1})}var dt=Object.defineProperty,Pe=(i,e,t,s)=>{for(var r=void 0,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(e,t,r)||r);return r&&dt(e,t,r),r};const oe="raycast",Me=[oe,"args","data"],Oe=i=>i.split("-");class k extends S{constructor(e){super(),this.classSource=e,this.instance=null,this.dispose=[],this.mutationObserver=null,this.tryAddOnce=!1,this.connected=!1}observeAttributes(){this.mutationObserver=new MutationObserver(e=>{e.forEach(t=>{var r;if(!t.attributeName||(r=Object.getPrototypeOf(this).constructor.observedAttributes)!=null&&r.includes(t.attributeName))return;const s=this.attributes.getNamedItem(t.attributeName);s&&this.updateProperty(s)})}),this.mutationObserver.observe(this,{attributes:!0})}parsedArgs(){const e=this.args??this.getAttribute("args")??[];return typeof e=="string"?JSON.parse(e):e}createUnderlyingThreeObject(){this.instance=new this.classSource(...this.parsedArgs().map(e=>q(e,this)))}refreshAttributes(){this.getAttributeNames().forEach(e=>{const t=this.attributes.getNamedItem(e);t&&this.updateProperty(t)}),Array.from(this.attributes).forEach(this.updateProperty.bind(this))}async onUnderlyingThreeObjectReady(){var s,r,n,o;const e=this.instance;e.uuid&&this.setAttribute(se,e.uuid);let t=re(this);for(;this!=null&&this.connected&&!this.tryAddOnce&&!t;)await new Promise(requestAnimationFrame),t=re(this);if(t&&t.instance||(s=t==null?void 0:t.three)!=null&&s.scene){const a=this.instance,h=this.instance,c=t.instance,u=t.instance??((r=t.three)==null?void 0:r.scene),l=this.instance;if((n=a.type)!=null&&n.toLowerCase().includes("geometry")&&c.geometry)c.geometry=a;else if((o=h.type)!=null&&o.toLowerCase().includes("material")&&c.material)c.material=h;else if(u.add)try{u.add(l),this.dispatchEvent(new CustomEvent("instanceadded",{detail:{instance:this.instance,parent:u}}))}catch{throw new Error(`Error adding ${this.tagName} to ${u}`)}const y=this.getAttribute("attach");y&&this.executeAttach(y,this.instance)}}connectedCallback(){super.connectedCallback(),this.observeAttributes.call(this),this.createUnderlyingThreeObject.call(this),this.refreshAttributes.call(this),this.dispatchEvent(new CustomEvent("instancecreated",{detail:{instance:this.instance}})),this.connected=!0,this.onUnderlyingThreeObjectReady.call(this)}updateProperty(e){const{name:t,value:s}=e;let r=t;Object.keys(this.instance??{}).forEach(a=>{a.toLowerCase()===r&&(r=a)});const n=Oe(r);if(Me.includes(r)||Me.includes(n[0]))return;let o=q(s,this);try{o=JSON.parse(s===""?"true":s)}catch{}this.instance&&ie(this.instance,n,o)}executeAttach(e,t){const s=this.parentElement;s.instance&&ie(s.instance,Oe(e),t)}disconnectedCallback(){super.disconnectedCallback();const e=[this.instance];this.disposeThreeObjects.call(this,e),this.connected=!1}disposeThreeObjects(e){e.forEach(t=>{var n,o;if(!t)return;const s=t,r=t;(n=s.dispose)==null||n.call(s),(o=r.removeFromParent)==null||o.call(r)})}render(){return Q`<slot></slot>`}createRenderRoot(){return this}}Pe([E({type:Boolean,attribute:"try-add-once"})],k.prototype,"tryAddOnce"),Pe([lt()],k.prototype,"connected");const Re=i=>{const e=typeof i=="string"?m[i]:i;if(!we(e))return null;const t=i.toString().toLowerCase().endsWith("loader");class s extends k{constructor(){super(e)}}class r extends k{constructor(){super(...arguments),this.loader=null}createUnderlyingThreeObject(){this.loader=new e(...this.parsedArgs().map(o=>q(o,this)))}async onUnderlyingThreeObjectReady(){const o=this.getAttribute("src");if(!o)throw new Error("Loader requires a source.");if(!this.loader)throw new Error(`Missing loader ${this.tagName}`);this.loader.load(o,a=>{this.instance=a;const h=this.getAttribute("attach");h&&this.executeAttach(h,a),this.refreshAttributes.call(this),this.dispatchEvent(new CustomEvent("loaded",{detail:{instance:a}}))},void 0,a=>{throw new Error(`error loading: ${o}`+a)})}disconnectedCallback(){super.disconnectedCallback(),this.disposeThreeObjects.call(this,[this.loader])}}return t?r:s};var ut=Object.defineProperty,_=(i,e,t,s)=>{for(var r=void 0,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(e,t,r)||r);return r&&ut(e,t,r),r};const pt="orthographic",Ne=1/0,ae=class ae extends S{constructor(){super(),this.scratchV2=new m.Vector2,this.background=null,this.dpr=Ne,this.headless=!1,this.manualRender=!1,this.dispatchBeforeRender=!1,this.dispatchAfterRender=!1,this.rendererArgs=[],this.cameraArgs=[],this.raycaster=new m.Raycaster,this.raycastPool=[],this.frame=1/0,this.three=this.createThree(),this.resizeObserver=new ResizeObserver(e=>{e.forEach(({target:t,contentRect:s})=>{var r;if(t===this&&((r=this.three.renderer)==null||r.setSize(s.width*this.dpr,s.height*this.dpr),this.three.camera)){const n=s.width/s.height;if(this.three.camera.type.toLowerCase()==="perspectivecamera")this.three.camera.aspect=n,this.three.camera.updateProjectionMatrix();else if(this.three.camera.type.toLowerCase()==="orthographiccamera"){const o=s.height/s.width,a=10;this.three.camera.top=o*a,this.three.camera.bottom=-o*a,this.three.camera.right=a,this.three.camera.left=-a,this.three.camera.updateProjectionMatrix()}this.manualRender||this.renderThree()}})})}createDefaultScene(){return new m.Scene}createThree(){return{scene:this.createDefaultScene(),camera:null,renderer:null}}connectedCallback(){if(super.connectedCallback(),this.dpr===Ne&&(this.dpr=window.devicePixelRatio),this.getAttribute(pt)!==null?this.three.camera=new m.OrthographicCamera(...this.cameraArgs):this.three.camera=new m.PerspectiveCamera(...this.cameraArgs.length?this.cameraArgs:[75]),["scene","camera","renderer"].forEach(e=>{const t=this[e]??this.getAttribute(e)??{},s=typeof t=="string"?JSON.parse(t):t;Object.entries(s).forEach(([r,n])=>{this.three[e]&&ie(this.three[e],r.split("-"),q(n,this))})}),this.resizeObserver.observe(this),this.background!==null&&(this.three.scene.background=new m.Color(this.background)),!this.headless){const e=new m.WebGLRenderer(...this.rendererArgs);e.domElement.addEventListener("pointermove",this.onPointerMove.bind(this)),e.domElement.addEventListener("mousemove",this.onPointerMove.bind(this)),e.domElement.addEventListener("click",this.onClick.bind(this)),this.three.renderer=e}this.manualRender||this.updateLoop()}disconnectedCallback(){var e,t,s,r;(e=this.three.renderer)==null||e.domElement.removeEventListener("pointermove",this.onPointerMove.bind(this)),(t=this.three.renderer)==null||t.domElement.removeEventListener("mousemove",this.onPointerMove.bind(this)),(s=this.three.renderer)==null||s.domElement.removeEventListener("click",this.onClick.bind(this)),(r=this.three.renderer)==null||r.dispose(),this.resizeObserver.unobserve(this),cancelAnimationFrame(this.frame)}handleDefaultSlotChange(e){e.target.assignedElements().forEach(t=>{const s=t;s.instance instanceof m.Object3D&&t.getAttributeNames().includes(oe)&&t.getAttributeNames().includes(oe)&&this.raycastPool.push(s.instance)}),this.renderThree()}runRaycast(e){var a,h;if(!this.raycastPool.length||!this.three.camera)return[];const t=((a=this.three.renderer)==null?void 0:a.domElement.width)??0,s=((h=this.three.renderer)==null?void 0:h.domElement.height)??0,r=this.scratchV2.clone().set(e.clientX/(t/this.dpr)*2-1,-(e.clientY/(s/this.dpr))*2+1);return this.raycaster.setFromCamera(r,this.three.camera),this.raycaster.intersectObjects(this.raycastPool).map(c=>({intersect:c,element:this.querySelector(`[${se}="${c.object.uuid}"]`)}))}onPointerMove(e){this.runRaycast.bind(this)(e).forEach(s=>{var r,n,o,a;e.type==="pointermove"?((r=s.element)==null||r.dispatchEvent(new PointerEvent("pointermove")),(n=s.element)==null||n.dispatchEvent(new CustomEvent(Le,{detail:s}))):e.type==="mousemove"&&((o=s.element)==null||o.dispatchEvent(new MouseEvent("mousemove")),(a=s.element)==null||a.dispatchEvent(new CustomEvent(Ue,{detail:s})))})}onClick(e){let t=[];if(e instanceof TouchEvent){const s=e.touches[0];t=this.runRaycast.bind(this)(s),t.forEach(r=>{var n;(n=r.element)==null||n.dispatchEvent(new TouchEvent("touchstart"))})}else t=this.runRaycast.bind(this)(e),t.forEach(s=>{var r;(r=s.element)==null||r.dispatchEvent(new MouseEvent("click"))});t.forEach(s=>{var r;(r=s.element)==null||r.dispatchEvent(new CustomEvent(He,{detail:s}))})}updateLoop(){this.renderThree(),this.manualRender||(this.frame=requestAnimationFrame(this.updateLoop.bind(this)))}renderThree(e,t){var s;this.dispatchBeforeRender&&this.dispatchEvent(new CustomEvent(je,{})),this.three.camera&&((s=this.three.renderer)==null||s.render(e??this.three.scene,t??this.three.camera),this.dispatchAfterRender&&this.dispatchEvent(new CustomEvent(De,{})))}render(){var e;return Q`
|
|
28
28
|
<slot @slotchange=${this.handleDefaultSlotChange}></slot>
|
|
29
29
|
${(e=this.three.renderer)==null?void 0:e.domElement}
|
|
30
|
-
`}};
|
|
30
|
+
`}};ae.styles=ze`
|
|
31
31
|
:host {
|
|
32
32
|
width: 100%;
|
|
33
33
|
height: 100%;
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
max-width: 100%;
|
|
41
41
|
max-height: 100%;
|
|
42
42
|
}
|
|
43
|
-
`;let f=
|
|
43
|
+
`;let f=ae;_([E()],f.prototype,"background"),_([E()],f.prototype,"dpr"),_([E()],f.prototype,"headless"),_([E({attribute:"manual-render",type:Boolean})],f.prototype,"manualRender"),_([E({attribute:"dispatch-before-render",type:Boolean})],f.prototype,"dispatchBeforeRender"),_([E({attribute:"dispatch-after-render",type:Boolean})],f.prototype,"dispatchAfterRender"),_([E({attribute:"renderer-args",type:Object})],f.prototype,"rendererArgs"),_([E({attribute:"camera-args",type:Object})],f.prototype,"cameraArgs");class xe extends S{constructor(){super(...arguments),this.parentLunchbox=null,this.frame=-1,this.scratchV3=new m.Vector3,this.scratchFrustum=new m.Frustum,this.scratchMatrix4=new m.Matrix4}tryAttachUpdate(){var o;const e=(o=this.parentLunchbox)==null?void 0:o.instance;if(!e)return!1;if(!e.isObject3D)throw new Error("html-anchor must be the child of an Object3D");const t=D(this,a=>{var h;return!!((h=a==null?void 0:a.three)!=null&&h.renderer)});if(!t)return console.error("three-lunchbox parent required for html-anchor"),!1;const s=t.three.camera;if(!s)return console.error("camera required for html-anchor"),!1;const r=t.three.renderer;if(!(r!=null&&r.domElement))return console.error("renderer and DOM element required for html-anchor"),!1;const n=()=>{this.frame=requestAnimationFrame(n),s.updateMatrix(),s.updateMatrixWorld(),e.getWorldPosition(this.scratchV3);const a=this.scratchV3.clone();this.scratchV3.project(s),this.scratchV3.multiplyScalar(.5).addScalar(.5),this.scratchV3.y=1-this.scratchV3.y;const h=this.scratchV3.clone().set(r.domElement.width,r.domElement.height,1);h.divideScalar(devicePixelRatio),this.scratchV3.multiply(h);const c=e.position.clone().distanceTo(s.getWorldPosition(this.scratchV3.clone()));this.scratchFrustum.setFromProjectionMatrix(this.scratchMatrix4.clone().multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse));const u=this.scratchFrustum.containsPoint(a);this.style.setProperty("--left",`${this.scratchV3.x}px`),this.style.setProperty("--top",`${this.scratchV3.y}px`),this.style.setProperty("--distance-from-camera",`${c}`),this.style.setProperty("--in-frustum",`${u?1:0}`),u?this.classList.add("in-frustum"):this.classList.remove("in-frustum")};return n(),!0}connectedCallback(){super.connectedCallback();const e=this.parentNode;if(!e)throw new Error("html-anchor requires a 3D parent");this.parentLunchbox=e,this.tryAttachUpdate()||this.parentLunchbox.addEventListener("instanceadded",()=>{if(!this.tryAttachUpdate())throw new Error("error attaching html-anchor to Object3D")},{once:!0})}disconnectedCallback(){this.frame!==-1&&cancelAnimationFrame(this.frame)}render(){return Q`<slot></slot>`}createRenderRoot(){return this}}const mt=({prependList:i=[]}={})=>{Object.entries({"three-lunchbox":f,"html-anchor":xe}).forEach(([t,s])=>{customElements.get(t)||customElements.define(t,s)}),[...i,...W].forEach(t=>{const s=ke(t);if(customElements.get(s))return;const r=Re(t);r&&customElements.define(s,r)})},ft=(i,e,t=window)=>{if(t.customElements.get(i)){console.log(`${i} already registered as a custom element. Try a different name if registering is still required.`);return}const s=Re(e);if(s)t.customElements.define(i,s);else throw new Error(`Could not extend ${i}. The second paramater must be a class.`)},Le="threepointermove",Ue="threemousemove",He="threeclick",je="beforerender",De="afterrender",ke=i=>{let e=i.split(/\.?(?=[A-Z])/).join("-").toLowerCase().replace(/-g-l-/,"-gl-");return e.includes("-")||(e=`three-${e}`),e},yt=W.map(ke);d.AFTER_RENDER_EVENT_NAME=De,d.BEFORE_RENDER_EVENT_NAME=je,d.HtmlAnchor=xe,d.THREE_CLICK_EVENT_NAME=He,d.THREE_MOUSE_MOVE_EVENT_NAME=Ue,d.THREE_POINTER_MOVE_EVENT_NAME=Le,d.THREE_UUID_ATTRIBUTE_NAME=se,d.ThreeBase=k,d.ThreeLunchbox=f,d.autoComponents=W,d.closestPassShadow=D,d.extend=ft,d.get=Ce,d.getCandidateParent=re,d.initLunchbox=mt,d.isClass=we,d.isNumber=Se,d.set=Te,d.webComponentNames=yt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"types": "./src/types.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"version": "2.2.
|
|
16
|
+
"version": "2.2.2",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"types": "./src/types.d.ts",
|
|
19
19
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"cypress": "^13.9.0",
|
|
36
36
|
"happy-dom": "^16.8.1",
|
|
37
37
|
"three": "^0.164.1",
|
|
38
|
-
"typescript": "^5.
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
39
|
"vite": "^5.2.0",
|
|
40
40
|
"vitest": "^3.0.5"
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { Intersection, Object3DEventMap, Scene, Object3D } from 'three';
|
|
|
8
8
|
export * from './three-lunchbox';
|
|
9
9
|
export * from './html-anchor';
|
|
10
10
|
export { ThreeBase } from './three-base';
|
|
11
|
+
export * from './utils';
|
|
11
12
|
|
|
12
13
|
/** Every component in a Lunchbox scene is of the Lunchbox type - it contains its ThreeJS instance
|
|
13
14
|
* as a property called `instance`.
|
package/src/three-base.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const IGNORED_ATTRIBUTES = [
|
|
|
17
17
|
const buildNestedPropertyArray = (input: string) => input.split('-');
|
|
18
18
|
|
|
19
19
|
/** Standard ThreeJS class */
|
|
20
|
-
export abstract class ThreeBase<U extends
|
|
20
|
+
export abstract class ThreeBase<U extends IsClass> extends LitElement {
|
|
21
21
|
instance: U | null = null;
|
|
22
22
|
|
|
23
23
|
dispose: (() => void)[] = [];
|
|
@@ -63,7 +63,7 @@ export abstract class ThreeBase<U extends new (...args: any) => any> extends Lit
|
|
|
63
63
|
createUnderlyingThreeObject() {
|
|
64
64
|
// Instance creation
|
|
65
65
|
// ==================
|
|
66
|
-
this.instance = new (this.classSource)(...this.parsedArgs().map(arg => parseAttributeOrPropertyValue(arg, this)));
|
|
66
|
+
this.instance = new (this.classSource)(...this.parsedArgs().map(arg => parseAttributeOrPropertyValue(arg, this))) as U;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
refreshAttributes() {
|