UNPKG

mylingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

35 lines 1.35 kB
import CharacterCamera from "../core/CharacterCamera"; import { Reactive } from "@lincode/reactivity"; import getWorldPosition from "../utils/getWorldPosition"; import getWorldQuaternion from "../utils/getWorldQuaternion"; import { onBeforeRender } from "../../events/onBeforeRender"; export default class FirstPersonCamera extends CharacterCamera { static componentName = "firstPersonCamera"; constructor() { super(); const cam = this.camera; this.watch(onBeforeRender(() => { cam.position.copy(getWorldPosition(this.object3d)); cam.quaternion.copy(getWorldQuaternion(this.object3d)); })); this.createEffect(() => { const target = this.targetState.get(); const innerYSet = this.innerYSetState.get(); if (!target || !("height" in target) || innerYSet) return; super.innerY = target.height * 0.4; return () => { super.innerY = 0; }; }, [this.targetState.get, this.innerYSetState.get]); } innerYSetState = new Reactive(false); get innerY() { return super.innerY; } set innerY(val) { super.innerY = val; this.innerYSetState.set(true); } } //# sourceMappingURL=FirstPersonCamera.js.map