{% extends 'view_file_base.html' %}

{% block file_view %}
<div id="displaylink" class="alc"><a href="#" id="3d-view-link">Preview 3D-Model in browser</a></div>
<div id="viewer" style="margin:auto;width:96%;height:500px;"></div>
{% endblock %}

{% block extra_script %}{{ block.super }}
<script src="{{MEDIA_URL}}js/thingiview/Three.js"></script>
<script src="{{MEDIA_URL}}js/thingiview/plane.js"></script>
<script src="{{MEDIA_URL}}js/thingiview/thingiview.js"></script>
<script type="text/javascript">
$('#3d-view-link').on('click', function() {
	$('#displaylink').hide();
	thingiurlbase = "{{MEDIA_URL}}js/thingiview";
	thingiview = new Thingiview("viewer");
	thingiview.initScene();
	{% if fileext == "stl" %}
		thingiview.loadSTL("{{raw_path}}");
	{% else %}
		thingiview.loadOBJ("{{raw_path}}");
	{% endif %}

    return false;
});
</script>
{% endblock %}
