1import{__decorate as t}from"../node_modules/tslib/tslib.es6.js";import{css as e,LitElement as o,html as i}from"https://cdn.jsdelivr.net/gh/lit/dist@2/core/lit-core.min.js";import{property as r,customElement as s}from"https://cdn.skypack.dev/pin/lit@v2.5.0-jYRq0AKQogjUdUh7SCAE/mode=imports/optimized/lit/decorators.js";import{simulationState as d}from"./device-observer.js";let a=class extends o{constructor(){super(...arguments),this.yaw=-15,this.pitch=-15,this.roll=0,this.posZ=0,this.color=e`red`,this.size=e`30px`,this.controls=!1,this.highlighted=!1,this.handleOrientationEvent=t=>{const{detail:e}=t;e.name===this.id&&this.controls&&("yaw"===e.type?this.yaw=e.value:"pitch"===e.type?this.pitch=e.value:this.roll=e.value)}}connectedCallback(){super.connectedCallback(),d.registerObserver(this),window.addEventListener("orientationEvent",this.handleOrientationEvent)}disconnectedCallback(){window.removeEventListener("orientationEvent",this.handleOrientationEvent),d.removeObserver(this),super.disconnectedCallback()}onNotify(t){this.highlighted=t.selectedId===this.id;for(const e of t.devices)if(e.name===this.id)return void(this.posZ=100*e.position.z)}render(){return i`
2      <style>
3        :host {
4          font-size: ${this.size};
5          --color: ${this.color};
6          --yaw: ${this.yaw};
7          --pitch: ${this.pitch};
8          --roll: ${this.roll};
9          --posZ: ${this.controls?this.posZ:0};
10        }
11        .cube > div {
12          outline: ${this.highlighted&&this.controls?e`dashed`:e``};
13        }
14      </style>
15      <div class="cube">
16        <div></div>
17        <div></div>
18        <div></div>
19        <div></div>
20        <div></div>
21        <div></div>
22      </div>
23      ${this.controls?i`
24            <div class="line"></div>
25            <div class="base"></div>
26          `:i``}
27    `}};a.styles=e`
28    :host {
29      /** all sizes are relative to font-size **/
30      display: block;
31      min-height: 1.5em;
32      min-width: 1.5em;
33      width: 1em;
34      /*  overflow: hidden; */
35      transform-origin: center;
36      transform-style: preserve-3d;
37      transform: translateZ(calc(var(--posZ) * 1px));
38      cursor: move;
39    }
40
41    .cube {
42      transform-style: preserve-3d;
43      transform: rotateX(calc(var(--yaw) * 1deg))
44        rotateY(calc(var(--pitch) * 1deg)) rotateZ(calc(var(--roll) * 1deg));
45      position: absolute;
46      left: 0.25em;
47      bottom: 0.25em;
48      width: 1em;
49      height: 1em;
50    }
51    .cube > div {
52      position: absolute;
53      background-color: var(--color);
54      width: 100%;
55      height: 100%;
56      box-shadow: 0 0 0.25em #000 inset;
57    }
58    .cube > div:nth-child(1) {
59      transform: translateZ(0.5em);
60    }
61    .cube > div:nth-child(2) {
62      transform: rotateY(180deg) translateZ(0.5em);
63    }
64    .cube > div:nth-child(3) {
65      right: 0;
66      width: 1em;
67      transform: rotateY(90deg) translateZ(0.5em);
68    }
69    .cube > div:nth-child(4) {
70      width: 1em;
71      transform: rotateY(270deg) translateZ(0.5em);
72    }
73    .cube > div:nth-child(5) {
74      bottom: -0.5em;
75      height: 1em;
76      transform: rotateX(90deg);
77      box-shadow: 0 0 0.25em #000 inset, 0 0 0.25em #000;
78    }
79    .cube div:nth-child(6) {
80      height: 1em;
81      transform: translateY(-0.5em) rotateX(90deg);
82      overflow: hidden;
83    }
84
85    .line {
86      position: absolute;
87      border-bottom: 5px dashed;
88      width: calc(var(--posZ) * 1px);
89      top: 50%;
90      left: 50%;
91      transform: rotateY(90deg) rotateX(90deg);
92      transform-origin: left;
93    }
94
95    .base {
96      position: absolute;
97      border: 5px solid;
98      border-radius: 50%;
99      background-color: black;
100      height: 5px;
101      width: 5px;
102      top: 50%;
103      left: 50%;
104      transform: translate3d(-50%, -50%, calc(var(--posZ) * -1px));
105    }
106  `,t([r({type:Number})],a.prototype,"yaw",void 0),t([r({type:Number})],a.prototype,"pitch",void 0),t([r({type:Number})],a.prototype,"roll",void 0),t([r({type:Number})],a.prototype,"posZ",void 0),t([r({type:e,attribute:"color"})],a.prototype,"color",void 0),t([r({type:e,attribute:"size"})],a.prototype,"size",void 0),t([r({type:Boolean})],a.prototype,"controls",void 0),t([r({type:Boolean})],a.prototype,"highlighted",void 0),a=t([s("ns-cube-sprite")],a);export{a as CubeSprite};
107