-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestar.html
More file actions
191 lines (153 loc) · 4.91 KB
/
Copy pathtestar.html
File metadata and controls
191 lines (153 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!-- Import the component -->
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
<model-viewer src="https://modelviewer.dev/assets/ShopifyModels/Chair.glb" poster="https://modelviewer.dev/assets/ShopifyModels/Chair.webp" tone-mapping="commerce" shadow-intensity="1" ar camera-controls touch-action="pan-y" alt="A 3D model carousel">
<button slot="ar-button" id="ar-button">
View in your space
</button>
<div id="ar-prompt">
<img src="https://modelviewer.dev/assets/hand.png">
</div>
<button id="ar-failure">
AR is not tracking!
</button>
<div class="slider">
<div class="slides">
<button class="slide selected" onclick="switchSrc(this, 'Chair')" style="background-image: url('https://modelviewer.dev/assets/ShopifyModels/Chair.webp');">
</button><button class="slide" onclick="switchSrc(this, 'Mixer')" style="background-image: url('https://modelviewer.dev/assets/ShopifyModels/Mixer.webp');">
</button><button class="slide" onclick="switchSrc(this, 'GeoPlanter')" style="background-image: url('https://modelviewer.dev/assets/ShopifyModels/GeoPlanter.webp');">
</button><button class="slide" onclick="switchSrc(this, 'ToyTrain')" style="background-image: url('https://modelviewer.dev/assets/ShopifyModels/ToyTrain.webp');">
</button><button class="slide" onclick="switchSrc(this, 'Canoe')" style="background-image: url('https://modelviewer.dev/assets/ShopifyModels/Canoe.webp');">
</button></div>
</div>
</model-viewer>
<script type="module">
const modelViewer = document.querySelector("model-viewer");
window.switchSrc = (element, name) => {
const base = "https://modelviewer.dev/assets/ShopifyModels/" + name;
modelViewer.src = base + '.glb';
modelViewer.poster = base + '.webp';
const slides = document.querySelectorAll(".slide");
slides.forEach((element) => {element.classList.remove("selected");});
element.classList.add("selected");
};
document.querySelector(".slider").addEventListener('beforexrselect', (ev) => {
// Keep slider interactions from affecting the XR scene.
ev.preventDefault();
});
</script>
<style>
/* This keeps child nodes hidden while the element loads */
:not(:defined) > * {
display: none;
}
/* This keeps child nodes hidden while the element loads */
:not(:defined) > * {
display: none;
}
#body {
background-color: #141414;
}
model-viewer {
background-color: #141414;
overflow-x: hidden;
width:100%;
height:100%;
}
#ar-button {
background-image: url(https://modelviewer.dev/assets/ic_view_in_ar_new_googblue_48dp.png);
background-repeat: no-repeat;
background-size: 20px 20px;
background-position: 12px 50%;
background-color: #4481f1;
position: absolute;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
bottom: 132px;
padding: 0px 16px 0px 40px;
font-family: Roboto Regular, Helvetica Neue, sans-serif;
font-size: 14px;
color:#ffffff;
height: 36px;
line-height: 36px;
border-radius: 18px;
border: 1px solid #DADCE0;
}
#ar-button:active {
background-color: #E8EAED;
}
#ar-button:focus {
outline: none;
}
#ar-button:focus-visible {
outline: 1px solid #4285f4;
}
@keyframes circle {
from { transform: translateX(-50%) rotate(0deg) translateX(50px) rotate(0deg); }
to { transform: translateX(-50%) rotate(360deg) translateX(50px) rotate(-360deg); }
}
@keyframes elongate {
from { transform: translateX(100px); }
to { transform: translateX(-100px); }
}
model-viewer > #ar-prompt {
position: absolute;
left: 50%;
bottom: 175px;
animation: elongate 2s infinite ease-in-out alternate;
display: none;
}
model-viewer[ar-status="session-started"] > #ar-prompt {
display: block;
}
model-viewer > #ar-prompt > img {
animation: circle 4s linear infinite;
}
model-viewer > #ar-failure {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 175px;
display: none;
}
model-viewer[ar-tracking="not-tracking"] > #ar-failure {
display: block;
}
.slider {
width: 100%;
text-align: center;
overflow: hidden;
position: absolute;
bottom: 16px;
}
.slides {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
}
.slide {
scroll-snap-align: start;
flex-shrink: 0;
width: 100px;
height: 100px;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
background-color: #141410;
margin-right: 10px;
border-radius: 30px;
border: none;
display: flex;
}
.slide.selected {
border: 2px solid #4285f4;
}
.slide:focus {
outline: none;
}
.slide:focus-visible {
outline: 1px solid #4285f4;
}
</style>