1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 20:32:02 +08:00
trois/src/core/PerspectiveCamera.js

36 lines
690 B
JavaScript
Raw Normal View History

2020-09-18 22:28:17 +08:00
import { PerspectiveCamera, Vector3 } from 'three';
2020-09-14 22:57:11 +08:00
import { setFromProp } from '../tools.js';
export default {
inject: ['three'],
props: {
fov: {
type: Number,
default: 50,
},
2020-09-18 22:28:17 +08:00
position: {
type: [Object, Vector3],
default: { x: 0, y: 0, z: 0 },
},
},
watch: {
fov() {
this.camera.fov = this.fov;
},
position: {
deep: true,
handler() {
setFromProp(this.camera.position, this.position);
},
},
2020-09-14 22:57:11 +08:00
},
created() {
2020-09-18 22:28:17 +08:00
this.camera = new PerspectiveCamera(this.fov);
setFromProp(this.camera.position, this.position);
this.three.camera = this.camera;
2020-09-14 22:57:11 +08:00
},
render() {
return [];
},
};