-
Notifications
You must be signed in to change notification settings - Fork 0
/
a1.html
200 lines (167 loc) · 7.51 KB
/
a1.html
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
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="en" class="fullscreen-100">
<head>
<meta charset="utf-8">
<title>Teste</title>
<link rel="stylesheet" href="css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="white" />
<meta name="description" content="">
<script src="https://unpkg.com/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="https://unpkg.com/fullscreen-polyfill/dist/fullscreen.polyfill.js"></script>
<script src="https://unpkg.com/focus-visible/dist/focus-visible.js" defer></script>
<script src="https://unpkg.com/event-target@latest/min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ResizeObserver.global.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
<style>
body {
font-family: 'Roboto', sans-serif;
}
.hotspot-text {
margin-left: 8px;
margin-top: -4px;
max-width: 300px;
font-size: larger;
text-shadow:
-1px -1px 0 #000,
1px -1px 0 #000,
-1px 1px 0 #000,
1px 1px 0 #000;
}
.hotspot-bar {
width: 0;
background-color: #6ca0cf;
}
.no-ar-button {
--ar-button-display: none;
}
.text-white {
color: #f7f7f7;
font-family: 'Roboto', sans-serif;
}
.color-button {
width: 30px;
height: 30px;
margin-top: 5px;
background-color: rgba(255, 255, 255, 0);
border-radius: 50%;
}
.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
}
.color-button.selected {
border: 2px solid #717171;
}
</style>
</head>
<body class="fullscreen-100">
<model-viewer class='model-viewer' id="astronaut" camera-controls interaction-prompt="none" src="models/a.glb"
ios-src="models/a.usdz" ar alt="A 3D model of an astronaut" noloop
quick-look-browsers="safari chrome">
<div class="unselectable" id="hotspot-Fittings" slot="hotspot-Fittings" data-position="0.00 0.04 -0.01"
data-normal="0.00 1.00 0.00">
<div class="unselectable" style="display: flex;transform: translateX(50%)">
<div class="hotspot-bar"></div>
<div class="unselectable hotspot-text text-white">100% Leak-proof by high efficiency compression system
</div>
</div>
</div>
<div class="unselectable" id="hotspot-Couplings" slot="hotspot-Couplings" data-position="0.06 0.21 -0.17"
data-normal="0.00 1.00 0.00">
<div class="unselectable" style="display: flex;transform: translateX(50%)">
<div class="hotspot-bar"></div>
<div class="unselectable hotspot-text text-white">High performance, quick system couplings coated with
soft rubber</div>
</div>
</div>
<div class="unselectable" id="hotspot-Gun" slot="hotspot-Gun" data-position="-0.12 0.09 -0.12"
data-normal="0.00 1.00 0.00">
<div class="unselectable" style="display: flex;transform: translateX(50%)">
<div class="hotspot-bar"></div>
<div class="unselectable hotspot-text text-white">Premium soft touch material - Multi-Spray Nozzle</div>
</div>
</div>
<div id="viewer-bottom" class="viewer-bottom">
<div id="color1" class="clickable color-button selected" data-color="0.7,0.2,0.2,1" data-index=0
style="background-color: rgb(0, 151, 215);"></div>
<div id="color2" class="clickable color-button" data-color="0.44,0.03,0.03,1" data-index=1
style="background-color: rgb(149, 193, 31);"></div>
<div id="color3" class="clickable color-button" data-color="0.2,0.2,0.7,1" data-index=2
style="background-color: rgb(20, 20, 20);"></div>
<div id="move_camera" onclick="rotateCamera()" class="clickable"
style="background-color: rgba(20, 20, 20, 0); background-image: url(img/Move.png);"></div>
<div id="animate" onclick="modelAnimate()" class="clickable"
style="background-color: rgba(20, 20, 20, 0); background-image: url(img/Animate.png);"></div>
</div>
</model-viewer>
<script>
const modelViewer = document.querySelector("model-viewer");
const colorButtons = document.getElementsByClassName("color-button");
modelViewer.addEventListener('finished-animation', () => {
modelViewer.pause();
});
function clearSelected() {
for (let button of colorButtons) {
button.classList.remove("selected")
}
}
document.querySelector('#viewer-bottom').addEventListener('click', (event) => {
const colorString = event.target.dataset.color;
const index = event.target.dataset.index;
if (!colorString) {
return;
}
clearSelected();
console.log(event.target.dataset);
colorButtons[index].classList.add("selected");
const color = colorString.split(',')
.map(numberString => parseFloat(numberString));
matName = 'FITT_Force_colorable';
console.log('Changing color to: ', color);
console.log(modelViewer);
for (let mat of modelViewer.model.materials) {
console.log(mat.name);
if (mat.name === matName)
material = mat;
//materials.push(model.materials.find(mat=> mat.name===matName));
}
//const [material] = modelViewer.model.materials.find(mat=> mat.name===matName);
console.log(material.pbrMetallicRoughness);
material.pbrMetallicRoughness.setBaseColorFactor(color);
//console.log(mat.pbrMetallicRoughness.getMetallic());
});
</script>
<script>
const materialArray = [['FITT_Force_colorable',]];
//Questi valori sono tunati a mano per risolvere bug del viewer che li fa diversi
let colors = ['rgb(15, 45, 84)', 'rgb(73, 117, 11)', 'rgb(20, 20, 20)']
let bumps = [1, 1, 1]
const positions = [
"60deg 55deg 60%",
"-30deg 55deg 60%",
"180deg 60deg 70%",
"20deg 50deg 60%",
];
const getAnnotations = function () {
return [
document.getElementById('hotspot-Fittings'), document.getElementById('hotspot-Couplings'), document.getElementById('hotspot-Gun')
].filter((elem) => elem);
}
const positionToAnnotation = {
0: [], 1: ['hotspot-Fittings'], 2: ['hotspot-Couplings'], 3: ['hotspot-Gun']
};
const hasAnimations = true
if (!hasAnimations)
animate.style.display = "none"
</script>
<script src="js/TubiCustomizer.js"></script>
<script type="module" src="js/model-viewer/dist/new-model-viewer.js"></script>
<!-- <script nomodule src="https://unpkg.com/@google/model-viewer/dist/model-viewer-legacy.js"></script> -->
</body>
</html>