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 [];
|
|
|
|
},
|
2020-09-19 22:40:58 +08:00
|
|
|
__hmrId: 'PerspectiveCamera',
|
2020-09-14 22:57:11 +08:00
|
|
|
};
|