3D-tester/views/vue-3d.tpl

113 lines
2.4 KiB
Smarty
Raw Normal View History

2021-06-08 14:19:24 +02:00
% rebase('base.tpl')
<script src="/static/vendor/vue/vue.js"></script>
<script src="/static/vendor/vue-3d-model/vue-3d-model.umd.js"></script>
<h3>
<i class="fa fa-folder-o" aria-hidden="true"></i>
2021-06-18 20:48:16 +02:00
<a href="/list/{{ current_dir.rstrip('/') }}">objects/{{current_dir}}</a>
2021-06-08 14:19:24 +02:00
</h3>
<h4>
<span style="text-transform: uppercase">
{{ object['type'] }}:
</span>
{{name}}
</h4>
<div class="model-wrap">
<div id="object">
%if object['type'] == "gltf":
<model-gltf
src="{{ object['urls'][0] }}"
@on-mousemove="onMouseMove"
>
</model-gltf>
%end
%if object['type'] == "obj":
<model-obj
src="{{ object['urls'][0] }}"
>
</model-obj>
%end
%if object['type'] == "fbx":
<model-fbx
src="{{ object['urls'][0] }}"
>
</model-fbx>
%end
%if object['type'] == "stl":
<model-stl
src="{{ object['urls'][0] }}"
>
</model-stl>
%end
2021-06-13 14:28:28 +02:00
%if object['type'] == "json":
<model-three
:backgroundAlpha="0"
@on-load="onLoad"
:rotation="rotation"
src="{{ object['urls'][0] }}"
>
</model-three>
%end
2021-06-13 14:34:58 +02:00
%if object['type'] == "ply":
<model-ply
2021-06-13 15:34:16 +02:00
src="{{ object['urls'][0] }}"
2021-06-13 14:34:58 +02:00
:backgroundAlpha="0"
@on-load="onLoad"
:rotation="rotation"
2021-06-13 15:34:16 +02:00
2021-06-13 14:34:58 +02:00
>
</model-ply>
%end
2021-06-13 15:34:16 +02:00
%if object['type'] == "dae":
<model-collada
src="{{ object['urls'][0] }}"
:rotation="rotation"
@on-load="onLoad"
>
</model-collada>
%end
%if object['type'] == "obj-mtl":
<model-obj
src="{{ object['urls'][0] }}"
mtl="{{ object['urls'][1] }}"
:backgroundAlpha="0"
@on-load="onLoad"
:height="height"
2021-06-18 20:27:33 +02:00
background-color="green"
2021-06-13 15:34:16 +02:00
>
</model-obj>
%end
2021-06-08 14:19:24 +02:00
</div>
</div>
<script>
2021-06-13 15:34:16 +02:00
new Vue({
el: "#object",
data: {
height: 500,
loading: true,
rotation: {
x: -Math.PI / 2,
y: 0,
z: 0,
},
2021-06-18 20:27:33 +02:00
cameraRotation: { x: 3, y: 2, z: -1 },
2021-06-13 15:34:16 +02:00
},
methods: {
onLoad () {
this.loading = true;
//this.rotate();
},
rotate () {
this.rotation.z += 0.01;
requestAnimationFrame( this.rotate );
}
},
})
2021-06-08 14:19:24 +02:00
</script>