passes vue js data to component

This commit is contained in:
buttle 2021-06-13 15:34:16 +02:00
parent 081063647d
commit 16d8616f16
2 changed files with 49 additions and 21 deletions

View File

@ -4,3 +4,7 @@
padding: 1em;
background-color: lightgray;
}
#object {
height: 500px;
}

View File

@ -23,13 +23,6 @@
>
</model-gltf>
%end
%if object['type'] == "obj-mtl":
<model-obj
src="{{ object['urls'][0] }}"
mtl="{{ object['urls'][1] }}"
>
</model-obj>
%end
%if object['type'] == "obj":
<model-obj
src="{{ object['urls'][0] }}"
@ -48,15 +41,6 @@
>
</model-stl>
%end
%if object['type'] == "dae":
<model-collada
:backgroundAlpha="0"
@on-load="onLoad"
:rotation="rotation"
src="{{ object['urls'][0] }}"
>
</model-collada>
%end
%if object['type'] == "json":
<model-three
:backgroundAlpha="0"
@ -68,19 +52,59 @@
%end
%if object['type'] == "ply":
<model-ply
src="{{ object['urls'][0] }}"
:backgroundAlpha="0"
@on-load="onLoad"
:rotation="rotation"
src="{{ object['urls'][0] }}"
>
</model-ply>
%end
%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"
>
</model-obj>
%end
</div>
</div>
<script>
new Vue({
el: "#object"
el: "#object",
data: {
height: 500,
loading: true,
rotation: {
x: -Math.PI / 2,
y: 0,
z: 0,
},
},
methods: {
onLoad () {
this.loading = true;
//this.rotate();
},
rotate () {
this.rotation.z += 0.01;
requestAnimationFrame( this.rotate );
}
},
})
</script>