Skip to content

Commit

Permalink
Gltf Plugin Sakura Loader (#15)
Browse files Browse the repository at this point in the history
Gltf Plugin Sakura Loader
  • Loading branch information
alxart authored Nov 20, 2023
1 parent 3164bb0 commit de1e243
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
59 changes: 58 additions & 1 deletion src/gltf-plugin-sakura/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,74 @@
<style>
html,
body,
#container {
#container,
#curtain,
.wrap {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
}

#curtain {
display: none;
position: absolute;
top: 0;
left: 0;
backdrop-filter: blur(10px);
}

.wrap {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.wrap > p {
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
user-select: none;
}

.loader {
width: 16px;
height: 16px;
border-radius: 50%;
display: block;
margin: 15px auto;
position: relative;
background: #fff;
box-shadow: -24px 0 #fff, 24px 0 #fff;
box-sizing: border-box;
animation: shadowPulse 2s linear infinite;
}

@keyframes shadowPulse {
33% {
background: #fff;
box-shadow: -24px 0 #000, 24px 0 #fff;
}
66% {
background: #000;
box-shadow: -24px 0 #fff, 24px 0 #fff;
}
100% {
background: #fff;
box-shadow: -24px 0 #fff, 24px 0 #000;
}
}
</style>
</head>

<body>
<div id="container"></div>
<div id="curtain">
<div class="wrap">
<p>Models are loading. Please, wait...</p>
<span class="loader"></span>
</div>
</div>
<script src="https://mapgl.2gis.com/api/js/v1"></script>
<script src="https://unpkg.com/@2gis/mapgl-gltf@^1/dist/bundle.js"></script>
<script src="https://unpkg.com/mapgl-snow"></script>
Expand Down
10 changes: 8 additions & 2 deletions src/gltf-plugin-sakura/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const map = new mapgl.Map('container', {
maxZoom: 21,
});

const needPreload = new URL(location.href).searchParams.has('preload');
const curtain = document.getElementById('curtain');
curtain.style.display = 'block';

function sleep(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
Expand Down Expand Up @@ -100,7 +104,7 @@ async function runScenario(scenario) {
}

const plugin = new mapgl.GltfPlugin(map, {
modelsLoadStrategy: 'dontWaitAll',
modelsLoadStrategy: needPreload ? 'waitAll' : 'dontWaitAll',
ambientLight: { color: '#ffffff', intencity: 3 },
modelsBaseUrl: 'https://disk.2gis.com/digital-twin/models_s3/realty_ads/sakura/',
poiConfig: {
Expand Down Expand Up @@ -2679,7 +2683,9 @@ const realtyScene = [
},
];

plugin.addRealtyScene(realtyScene);
plugin.addRealtyScene(realtyScene).then(() => {
curtain.style.display = 'none';
});

const labelIds = [
'43556',
Expand Down

0 comments on commit de1e243

Please sign in to comment.