% rebase('base.tpl')

<script src="/static/jquery-3.6.0.min.js"></script>

<style>
model-viewer {
  width: 500px;
  height: 500px;
  outline: none;
  background-color: transparent;
}
</style>

%if 'preloader' in object:
<style>
  #lazy-load-poster {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-image: url("{{ object['preloader'] }}");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }
  #button-load {
    background-image: url("/static/assets/ic_get_app_white_24dp.svg");
    background-repeat: no-repeat;
    background-size: 24px 24px;
    background-position: 6% 50%;
    background-color: #000;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    display: inline-block;
    padding: 10px 18px 9px 40px;
    font-weight: 500;
    box-shadow: 0 0 8px rgba(0,0,0,.2), 0 0 4px rgba(0,0,0,.25);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    z-index: 100;
  }
</style>
%end

<h3>
  <i class="fa fa-folder-o" aria-hidden="true"></i>
  <a href="/list/{{ current_dir.rstrip('/') }}">objects/{{current_dir}}</a>
</h3>
<h4>
  <span style="text-transform: uppercase">
    {{ object['type'] }}:
  </span>
  {{name}}
</h4>

<div class="model-wrap" style="display:none">
  <div id="model" style="display:absolute">
    <model-viewer id="3d-model"
                  reveal="interaction"
                  src="{{ object['urls'][0] }}"
                  alt="A 3D model of a robot"
                  auto-rotate=""
                  camera-controls=""
                  background-color="#455A64"
                  %if 'skybox' in object:
                  skybox-image="{{ object['skybox'] }}"
                  %end
    >
    %if 'preloader' in object:
    <div id="lazy-load-poster" slot="poster"></div>
    <div id="button-load" slot="poster">Load 3D Model</div>
    %end
    </model-viewer>
  </div>
</div>

<script type="module" src="/static/vendor/google/model-viewer.js"></script>

<script>
jQuery(function($) {
  $(".model-wrap").show();
});
</script>
