FlyControlComponent()

new FlyControlComponent()

第一人称/第三人称飞行控制器组件,为场景中的角色对象提供 W/A/S/D/Q/E/R/T 键+鼠标的完整控制能力。支持第一人称和第三人称视角切换,包含行走、奔跑、跳跃、飞行四种运动模式,通过 Pointer Lock API 实现鼠标视角控制,支持碰撞检测、重力模拟和自定义热键映射。还提供打击点检测(focusUI)、动画状态自动切换和地板碰撞检测功能。适用于游戏角色控制、虚拟漫游、建筑内部浏览等场景。

Example
// 为玩家角色添加飞行控制器
 	let component = new THING.FlyControlComponent();
	person.addComponent(component, 'objControl');
	person.objControl.setFloorObject(floorObj); //floorObj是一个Object3D,第一人称行走的平面
	person.objControl.setEyeHeight(1.8);
	person.objControl.setAttachCamera(app.camera);
	person.objControl.setFirstPersonView(true);
	person.objControl.setPlayerTurning(0);
	person.objControl.setMouseOppositeMode(true);
	person.objControl.setPointerLockEnable(false);
	person.objControl.enableChangeDirecetionByMouseMove(false);
  
	// 切换到第三人称
	person.objControl.setFirstPersonView(false);
	person.objControl.setThirdPersonCameraDis(3.0);

Extends

Members

active :boolean

激活或停用组件。
Inherited From:

app :THING.App

获取应用程序。
Inherited From:

object :THING.BaseObject

获取对象。
Inherited From:

onActiveChange :OnActiveChangeComponentCallback

活动状态改变时的回调函数。
Inherited From:

onAfterAdd :OnAfterAddComponentCallback

添加之后。
Inherited From:

onAfterAddChild :OnAddChildComponentCallback

添加子对象之后的回调函数。
Inherited From:

onAfterRemove :OnAfterRemoveComponentCallback

移除之后。
Inherited From:

onAfterRemoveChild :OnRemoveChildComponentCallback

移除子对象之后的回调函数。
Inherited From:

onBeforeAdd :OnBeforeAddComponentCallback

添加之前。
Inherited From:

onBeforeAddChild :OnAddChildComponentCallback

添加子对象之前的回调函数。
Inherited From:

onBeforeRemove :OnBeforeRemoveComponentCallback

移除之前。
Inherited From:

onBeforeRemoveChild :OnRemoveChildComponentCallback

移除子对象之前的回调函数。
Inherited From:

onCopy :OnCopyComponentCallback

复制时的回调函数。
Inherited From:

onExport :OnExportComponentCallback

导出数据时。
Inherited From:

onImport :OnImportComponentCallback

导入数据时。
Inherited From:

onInit :OnInitComponentCallback

初始化时的回调函数。
Inherited From:

onLoadResource :OnLoadResourceComponentCallback

加载资源时的回调函数。
Inherited From:

onParentChange :OnParentChangeComponentCallback

改变父对象时的回调函数。
Inherited From:

onRefresh :OnRefreshComponentCallback

刷新时的回调函数。
Inherited From:

onResize :OnResizeComponentCallback

调整大小时的回调函数。
Inherited From:

onUnloadResource :OnUnloadResourceComponentCallback

卸载资源时的回调函数。
Inherited From:

onUpdate :OnUpdateComponentCallback

更新时的回调函数。
Inherited From:

onVisibleChange :OnVisibleChangeComponentCallback

可见性改变时的回调函数。
Inherited From:

Methods

onAdd(object)

当添加组件时。
Parameters:
Name Type Description
object THING.BaseObject 对象。
Inherited From:

onRemove()

当移除组件时。
Inherited From: