|
@@ -11,407 +11,514 @@ const castRayOffsetY = .01;
|
|
const castRayTeleportationOffset = 10;
|
|
const castRayTeleportationOffset = 10;
|
|
|
|
|
|
export default class XAvatar {
|
|
export default class XAvatar {
|
|
- constructor({id: e, avatarType: t, priority: r, avatarManager: n, assets: o, status: a}) {
|
|
|
|
- E(this, "id", "-1");
|
|
|
|
- E(this, "priority", 0);
|
|
|
|
- E(this, "isRender", !1);
|
|
|
|
- E(this, "distLevel", 0);
|
|
|
|
- E(this, "isInLoadingList", !1);
|
|
|
|
- E(this, "isHide", !1);
|
|
|
|
- E(this, "component");
|
|
|
|
- E(this, "controller");
|
|
|
|
- E(this, "stateMachine");
|
|
|
|
- E(this, "bbComponent");
|
|
|
|
- E(this, "_avatarType");
|
|
|
|
- E(this, "clothesList", []);
|
|
|
|
- E(this, "isSelected", !1);
|
|
|
|
- E(this, "pendingLod", !1);
|
|
|
|
- E(this, "_previousReceivedPosition", new BABYLON.Vector3(0,1e4,0));
|
|
|
|
- E(this, "_avatarPosition");
|
|
|
|
- E(this, "_avatarRotation");
|
|
|
|
- E(this, "_avatarScale");
|
|
|
|
- E(this, "rootNode");
|
|
|
|
- E(this, "distToCam", 1e11);
|
|
|
|
- E(this, "enableNickname", !0);
|
|
|
|
- E(this, "distance", 1e11);
|
|
|
|
- E(this, "isCulling", !1);
|
|
|
|
- E(this, "reslevel", 0);
|
|
|
|
- E(this, "isInLoadingQueue", !1);
|
|
|
|
- E(this, "_isRayCastEnable");
|
|
|
|
- E(this, "_scene");
|
|
|
|
- E(this, "_avatarManager");
|
|
|
|
- E(this, "_transparent", 0);
|
|
|
|
- E(this, "hide", ()=>(this.isHide = !0,
|
|
|
|
- this._hide(),
|
|
|
|
- !this.isRender));
|
|
|
|
- E(this, "_show", ()=>{
|
|
|
|
- var e;
|
|
|
|
- this.isHide || (this.setIsPickable(!0),
|
|
|
|
- this.priority == 0 && (this.rootNode.setEnabled(!0),
|
|
|
|
- this.isRender = !0,
|
|
|
|
- this.avatarManager._updateBillboardStatus(this, BillboardStatus.SHOW),
|
|
|
|
- (e = this.controller) == null || e.playAnimation(this.controller.onPlay, this.controller.loop)))
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- E(this, "show", ()=>(this.isHide = !1,
|
|
|
|
- this._show(),
|
|
|
|
- !!this.isRender));
|
|
|
|
- E(this, "setAnimations", e=>{
|
|
|
|
- this.controller.animations = e
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- E(this, "attachToAvatar", (e,t=!1,r={
|
|
|
|
- x: 0,
|
|
|
|
- y: 0,
|
|
|
|
- z: 0
|
|
|
|
- },n=!1,o,a)=>this.bbComponent.attachToAvatar(this, e, t, r, n, o, a));
|
|
|
|
- E(this, "detachFromAvatar", (e,t=!1)=>this.bbComponent.detachFromAvatar(this, e, t));
|
|
|
|
- E(this, "getBbox", (e={})=>this.bbComponent.getBbox(this, e));
|
|
|
|
- this.id = e,
|
|
|
|
- this._avatarManager = n,
|
|
|
|
|
|
+ constructor({id, avatarType, priority, avatarManager, assets, status}) {
|
|
|
|
+ this.id = "-1",
|
|
|
|
+ this.priority = 0,
|
|
|
|
+ this.isRender = !1,
|
|
|
|
+ this.distLevel = 0,
|
|
|
|
+ this.isInLoadingList = !1,
|
|
|
|
+ this.isHide = !1,
|
|
|
|
+ this.clothesList = [],
|
|
|
|
+ this.isSelected = !1,
|
|
|
|
+ this.pendingLod = !1,
|
|
|
|
+ this._previousReceivedPosition = new BABYLON.Vector3(0,1e4,0),
|
|
|
|
+ this.rootNode = void 0,
|
|
|
|
+ this.distToCam = 1e11,
|
|
|
|
+ this.enableNickname = !0,
|
|
|
|
+ this.distance = 1e11,
|
|
|
|
+ this.isCulling = !1,
|
|
|
|
+ this.reslevel = 0,
|
|
|
|
+ this.isInLoadingQueue = !1,
|
|
|
|
+ this._scene = void 0,
|
|
|
|
+ this._transparent = 0,
|
|
|
|
+
|
|
|
|
+ this.hide = ()=>{
|
|
|
|
+ this.isHide = !0
|
|
|
|
+ this._hide()
|
|
|
|
+ return !this.isRender
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this._show = ()=>{
|
|
|
|
+ this.isHide || (
|
|
|
|
+ this.setIsPickable(!0),
|
|
|
|
+ this.bbComponent._attachmentObservers.forEach((b,k)=>{
|
|
|
|
+ k.setEnabled(!0)
|
|
|
|
+ }),
|
|
|
|
+ this.priority == 0 && (
|
|
|
|
+ this.rootNode.setEnabled(!0),
|
|
|
|
+ this.isRender = !0,
|
|
|
|
+ this.avatarManager._updateBillboardStatus(this, BillboardStatus.SHOW),
|
|
|
|
+ this.component.accessories.forEach(b=>{
|
|
|
|
+ b.rootComponent.setEnabled(!0)
|
|
|
|
+ }),
|
|
|
|
+ this.controller == null || this.controller.playAnimation(this.controller.onPlay, this.controller.loop)
|
|
|
|
+ ),
|
|
|
|
+ this.component.accessories.forEach(b=>{
|
|
|
|
+ b.rootComponent.setEnabled(!0)
|
|
|
|
+ })
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this.show = ()=>{
|
|
|
|
+ this.isHide = !1
|
|
|
|
+ this._show()
|
|
|
|
+ return !!this.isRender
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this.setAnimations = _=>{
|
|
|
|
+ this.controller.animations = _
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this.attachToAvatar = ( _, b=!1, k={x:0,y:0,z:0}, j=!1, $, _e ) => {
|
|
|
|
+ this.bbComponent.attachToAvatar(this, _, b, k, j, _e)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this.detachFromAvatar = ( _, b=!1 )=>{
|
|
|
|
+ this.bbComponent.detachFromAvatar(this, _, b)
|
|
|
|
+ },
|
|
|
|
+ this.getBbox = (_={})=>{
|
|
|
|
+ this.bbComponent.getBbox(this, _)
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ this.id = id,
|
|
|
|
+ this._avatarManager = avatarManager,
|
|
this._scene = this.avatarManager.scene,
|
|
this._scene = this.avatarManager.scene,
|
|
- this.clothesList = o,
|
|
|
|
- this._avatarType = t,
|
|
|
|
- this.priority = r || 0,
|
|
|
|
|
|
+ this.clothesList = assets,
|
|
|
|
+ this._avatarType = avatarType,
|
|
|
|
+ this.priority = priority || 0,
|
|
|
|
+
|
|
this.controller = new XAnimationController(this),
|
|
this.controller = new XAnimationController(this),
|
|
this.component = new XAvatarComopnent,
|
|
this.component = new XAvatarComopnent,
|
|
this.stateMachine = new XStateMachine(this._scene),
|
|
this.stateMachine = new XStateMachine(this._scene),
|
|
this.bbComponent = new XAvatarBillboardComponent(this._scene),
|
|
this.bbComponent = new XAvatarBillboardComponent(this._scene),
|
|
- this.rootNode = new BABYLON.TransformNode(e,this._avatarManager.scene),
|
|
|
|
- this._avatarScale = a.avatarScale == null ? 1 : a.avatarScale,
|
|
|
|
- this._avatarRotation = a.avatarRotation == null ? {
|
|
|
|
- pitch: 0,
|
|
|
|
- yaw: 0,
|
|
|
|
- roll: 0
|
|
|
|
- } : a.avatarRotation,
|
|
|
|
- this._avatarPosition = a.avatarPosition == null ? {
|
|
|
|
- x: 0,
|
|
|
|
- y: 0,
|
|
|
|
- z: 0
|
|
|
|
- } : a.avatarPosition,
|
|
|
|
- this.setPosition(this._avatarPosition),
|
|
|
|
|
|
+ this.rootNode = new BABYLON.TransformNode(id, this._avatarManager.scene),
|
|
|
|
+
|
|
|
|
+ this._avatarScale = status.avatarScale == null ? 1 : status.avatarScale,
|
|
|
|
+ this._avatarRotation = status.avatarRotation == null ? { pitch: 0, yaw: 0, roll: 0 } : status.avatarRotation,
|
|
|
|
+ this._avatarPosition = status.avatarPosition == null ? { x: 0, y: 0, z: 0 } : status.avatarPosition,
|
|
|
|
+ this._isRayCastEnable = avatarSetting.isRayCastEnable,
|
|
|
|
+
|
|
|
|
+ this.setPosition(this._avatarPosition, !0),
|
|
this.setRotation(this._avatarRotation),
|
|
this.setRotation(this._avatarRotation),
|
|
this.setScale(this.scale),
|
|
this.setScale(this.scale),
|
|
this._isRayCastEnable = avatarSetting.isRayCastEnable,
|
|
this._isRayCastEnable = avatarSetting.isRayCastEnable,
|
|
|
|
+
|
|
this._scene.registerBeforeRender(()=>{
|
|
this._scene.registerBeforeRender(()=>{
|
|
this.tick()
|
|
this.tick()
|
|
- }
|
|
|
|
- )
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
+
|
|
tick() {
|
|
tick() {
|
|
this.cullingTick()
|
|
this.cullingTick()
|
|
}
|
|
}
|
|
|
|
+
|
|
cullingTick() {
|
|
cullingTick() {
|
|
- var e;
|
|
|
|
- this.isCulling && ((e = this.rootNode) == null || e.getChildMeshes().forEach(t=>{
|
|
|
|
- this.distToCam < 50 ? t.visibility = 0 : t.visibility = this._transparent
|
|
|
|
- }
|
|
|
|
- ))
|
|
|
|
|
|
+ this.isCulling && (this.rootNode == null || this.rootNode.getChildMeshes().forEach(i=>{
|
|
|
|
+ this.distToCam < 50 ? i.visibility = 0 : i.visibility = this._transparent
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
|
|
+
|
|
setTransParentThresh(e) {
|
|
setTransParentThresh(e) {
|
|
this._transparent = e
|
|
this._transparent = e
|
|
}
|
|
}
|
|
|
|
+
|
|
get isNameVisible() {
|
|
get isNameVisible() {
|
|
return this.bbComponent.isNameVisible
|
|
return this.bbComponent.isNameVisible
|
|
}
|
|
}
|
|
|
|
+
|
|
get isBubbleVisible() {
|
|
get isBubbleVisible() {
|
|
return this.bbComponent.isBubbleVisible
|
|
return this.bbComponent.isBubbleVisible
|
|
}
|
|
}
|
|
|
|
+
|
|
get isGiftButtonsVisible() {
|
|
get isGiftButtonsVisible() {
|
|
return this.bbComponent.isGiftButtonsVisible
|
|
return this.bbComponent.isGiftButtonsVisible
|
|
}
|
|
}
|
|
|
|
+
|
|
get words() {
|
|
get words() {
|
|
return this.bbComponent.words
|
|
return this.bbComponent.words
|
|
}
|
|
}
|
|
|
|
+
|
|
get nickName() {
|
|
get nickName() {
|
|
return this.bbComponent.nickName
|
|
return this.bbComponent.nickName
|
|
}
|
|
}
|
|
|
|
+
|
|
get giftButtons() {
|
|
get giftButtons() {
|
|
return this.bbComponent.giftButtons
|
|
return this.bbComponent.giftButtons
|
|
}
|
|
}
|
|
|
|
+
|
|
get bubble() {
|
|
get bubble() {
|
|
return this.bbComponent.bubble
|
|
return this.bbComponent.bubble
|
|
}
|
|
}
|
|
|
|
+
|
|
get nameBoard() {
|
|
get nameBoard() {
|
|
return this.bbComponent.nameBoard
|
|
return this.bbComponent.nameBoard
|
|
}
|
|
}
|
|
|
|
+
|
|
get avatarManager() {
|
|
get avatarManager() {
|
|
return this._avatarManager
|
|
return this._avatarManager
|
|
}
|
|
}
|
|
|
|
+
|
|
set withinVisibleRange(e) {
|
|
set withinVisibleRange(e) {
|
|
this.bbComponent.withinVisualRange = e
|
|
this.bbComponent.withinVisualRange = e
|
|
}
|
|
}
|
|
|
|
+
|
|
setNicknameStatus(e) {
|
|
setNicknameStatus(e) {
|
|
return this.bbComponent.setNicknameStatus(e)
|
|
return this.bbComponent.setNicknameStatus(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
setBubbleStatus(e) {
|
|
setBubbleStatus(e) {
|
|
return this.bbComponent.setBubbleStatus(e)
|
|
return this.bbComponent.setBubbleStatus(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
setButtonsStatus(e) {
|
|
setButtonsStatus(e) {
|
|
return this.bbComponent.setBubbleStatus(e)
|
|
return this.bbComponent.setBubbleStatus(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
setGiftButtonsVisible(e) {
|
|
setGiftButtonsVisible(e) {
|
|
return this.bbComponent.setGiftButtonsVisible(e)
|
|
return this.bbComponent.setGiftButtonsVisible(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
get avatarType() {
|
|
get avatarType() {
|
|
return this._avatarType
|
|
return this._avatarType
|
|
}
|
|
}
|
|
|
|
+
|
|
attachBody(e) {
|
|
attachBody(e) {
|
|
return this.component.addBodyComp(this, e)
|
|
return this.component.addBodyComp(this, e)
|
|
}
|
|
}
|
|
|
|
+
|
|
attachDecoration(e) {
|
|
attachDecoration(e) {
|
|
return this.component.addClothesComp(this, e)
|
|
return this.component.addClothesComp(this, e)
|
|
}
|
|
}
|
|
|
|
+
|
|
detachDecoration(e) {
|
|
detachDecoration(e) {
|
|
return this.component.clearClothesComp(e)
|
|
return this.component.clearClothesComp(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
detachDecorationAll() {
|
|
detachDecorationAll() {
|
|
return this.component.clearAllClothesComps()
|
|
return this.component.clearAllClothesComps()
|
|
}
|
|
}
|
|
|
|
+
|
|
get skeleton() {
|
|
get skeleton() {
|
|
return this.component.skeleton
|
|
return this.component.skeleton
|
|
}
|
|
}
|
|
|
|
+
|
|
get position() {
|
|
get position() {
|
|
return this._avatarPosition
|
|
return this._avatarPosition
|
|
}
|
|
}
|
|
|
|
+
|
|
get rotation() {
|
|
get rotation() {
|
|
return this._avatarRotation
|
|
return this._avatarRotation
|
|
}
|
|
}
|
|
|
|
+
|
|
get scale() {
|
|
get scale() {
|
|
return this._avatarScale
|
|
return this._avatarScale
|
|
}
|
|
}
|
|
|
|
+
|
|
_hide_culling() {
|
|
_hide_culling() {
|
|
this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
|
|
this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
|
|
this.isCulling = !0
|
|
this.isCulling = !0
|
|
}
|
|
}
|
|
|
|
+
|
|
_show_culling() {
|
|
_show_culling() {
|
|
this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(e=>{
|
|
this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(e=>{
|
|
e.visibility = 1
|
|
e.visibility = 1
|
|
- }
|
|
|
|
- ),
|
|
|
|
|
|
+ }),
|
|
this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW),
|
|
this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW),
|
|
this.isCulling = !1)
|
|
this.isCulling = !1)
|
|
}
|
|
}
|
|
|
|
+
|
|
_hide() {
|
|
_hide() {
|
|
!this.isHide || (this.setIsPickable(!1),
|
|
!this.isHide || (this.setIsPickable(!1),
|
|
|
|
+ this.bbComponent._attachmentObservers.forEach((e,i)=>{
|
|
|
|
+ i.setEnabled(!1)
|
|
|
|
+ }
|
|
|
|
+ ),
|
|
this.priority == 0 ? (this.rootNode.setEnabled(!1),
|
|
this.priority == 0 ? (this.rootNode.setEnabled(!1),
|
|
this.isRender = !1,
|
|
this.isRender = !1,
|
|
- this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE)) : this.isRender && (this.avatarManager.currentLODUsers[this.distLevel]--,
|
|
|
|
- this.removeAvatarFromScene()))
|
|
|
|
|
|
+ this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
|
|
|
|
+ this.component.accessories.forEach(e=>{
|
|
|
|
+ e.rootComponent.setEnabled(!1)
|
|
|
|
+ }
|
|
|
|
+ )) : this.isRender && (this.avatarManager.currentLODUsers[this.distLevel]--,
|
|
|
|
+ this.removeAvatarFromScene()),
|
|
|
|
+ this.component.accessories.forEach(e=>{
|
|
|
|
+ e.rootComponent.setEnabled(!1)
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
- rotate(e, t, r) {
|
|
|
|
- return this.stateMachine.roll(this, e, t, r)
|
|
|
|
|
|
+
|
|
|
|
+ rotate(e, i, o) {
|
|
|
|
+ return this.stateMachine.roll(this, e, i, o)
|
|
}
|
|
}
|
|
|
|
+
|
|
set isRayCastEnable(e) {
|
|
set isRayCastEnable(e) {
|
|
this._isRayCastEnable = e
|
|
this._isRayCastEnable = e
|
|
}
|
|
}
|
|
|
|
+
|
|
get isRayCastEnable() {
|
|
get isRayCastEnable() {
|
|
return this._isRayCastEnable
|
|
return this._isRayCastEnable
|
|
}
|
|
}
|
|
|
|
+
|
|
getAvatarId() {
|
|
getAvatarId() {
|
|
return this.id
|
|
return this.id
|
|
}
|
|
}
|
|
|
|
+
|
|
getAvaliableAnimations() {
|
|
getAvaliableAnimations() {
|
|
const e = avatarLoader.avaliableAnimation.get(this.avatarType);
|
|
const e = avatarLoader.avaliableAnimation.get(this.avatarType);
|
|
return e || []
|
|
return e || []
|
|
}
|
|
}
|
|
- setPosition(e, t=!1) {
|
|
|
|
- if (this._avatarPosition = e,
|
|
|
|
- this.rootNode) {
|
|
|
|
- const r = ue4Position2Xverse(this._avatarPosition);
|
|
|
|
- let n = !1;
|
|
|
|
- this.avatarManager.getMainAvatar() && (this.id != this.avatarManager.getMainAvatar().id || (Math.abs(r.y - this._previousReceivedPosition.y) > castRayOffsetY && (n = !0),
|
|
|
|
- r.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (n = !0))),
|
|
|
|
- this._isRayCastEnable ? n || t ? this._castRay(e).then(o=>{
|
|
|
|
- this.rootNode.position = r,
|
|
|
|
- this.rootNode.position.y -= o
|
|
|
|
- }
|
|
|
|
- ).catch(o=>{
|
|
|
|
- Promise.reject(o)
|
|
|
|
|
|
+
|
|
|
|
+ // todo i用于控制是否接触地面。目前设默认为true,实时检测模型地面高度
|
|
|
|
+ setPosition(e, i=!0) {
|
|
|
|
+ this._avatarPosition = e;
|
|
|
|
+ if (this.rootNode) {
|
|
|
|
+ const o = ue4Position2Xverse(this._avatarPosition);
|
|
|
|
+ let s = !1;
|
|
|
|
+ if(this.avatarManager.getMainAvatar() ){
|
|
|
|
+ if(this.id == this.avatarManager.getMainAvatar().id){
|
|
|
|
+ Math.abs(o.y - this._previousReceivedPosition.y) > castRayOffsetY && (s = !0);
|
|
|
|
+ o.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (s = !0)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- ) : (this.rootNode.position.x = r.x,
|
|
|
|
- this.rootNode.position.z = r.z) : this.rootNode.position = r,
|
|
|
|
- this._previousReceivedPosition = r.clone()
|
|
|
|
|
|
+ if(this._isRayCastEnable)
|
|
|
|
+ if(s || i) {
|
|
|
|
+ // 检测模型地面高度
|
|
|
|
+ this._castRay(e).then(c=>{
|
|
|
|
+ this.rootNode.position = o;
|
|
|
|
+ this.rootNode.position.y -= c;
|
|
|
|
+ }
|
|
|
|
+ ).catch(c=>{
|
|
|
|
+ Promise.reject(c)
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // 保持人物高度不变
|
|
|
|
+ this.rootNode.position.x = o.x
|
|
|
|
+ this.rootNode.position.z = o.z
|
|
|
|
+ }
|
|
|
|
+ else this.rootNode.position = o
|
|
|
|
+ this._previousReceivedPosition = o.clone()
|
|
}
|
|
}
|
|
return Promise.resolve(e)
|
|
return Promise.resolve(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
setRotation(e) {
|
|
setRotation(e) {
|
|
if (this._avatarRotation = e,
|
|
if (this._avatarRotation = e,
|
|
this.rootNode) {
|
|
this.rootNode) {
|
|
- const t = {
|
|
|
|
|
|
+ const i = {
|
|
pitch: e.pitch,
|
|
pitch: e.pitch,
|
|
yaw: e.yaw + 180,
|
|
yaw: e.yaw + 180,
|
|
roll: e.roll
|
|
roll: e.roll
|
|
}
|
|
}
|
|
- , r = ue4Rotation2Xverse(t);
|
|
|
|
- this.rootNode.rotation = r
|
|
|
|
|
|
+ , o = ue4Rotation2Xverse(i);
|
|
|
|
+ this.rootNode.rotation = o
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
setAvatarVisible(e) {
|
|
setAvatarVisible(e) {
|
|
this.rootNode && (this.rootNode.setEnabled(e),
|
|
this.rootNode && (this.rootNode.setEnabled(e),
|
|
- this.rootNode.getChildMeshes().forEach(t=>{
|
|
|
|
- t.setEnabled(e)
|
|
|
|
|
|
+ this.rootNode.getChildMeshes().forEach(i=>{
|
|
|
|
+ i.setEnabled(e)
|
|
}
|
|
}
|
|
))
|
|
))
|
|
}
|
|
}
|
|
|
|
+
|
|
setScale(e) {
|
|
setScale(e) {
|
|
this._avatarScale = e,
|
|
this._avatarScale = e,
|
|
this.rootNode && (this.rootNode.scaling = new BABYLON.Vector3(e,e,e)),
|
|
this.rootNode && (this.rootNode.scaling = new BABYLON.Vector3(e,e,e)),
|
|
this.bbComponent.bbox && this.getBbox()
|
|
this.bbComponent.bbox && this.getBbox()
|
|
}
|
|
}
|
|
|
|
+
|
|
_removeAvatarFromScene() {
|
|
_removeAvatarFromScene() {
|
|
- var e, t;
|
|
|
|
|
|
+ var e, i;
|
|
this.isRender = !1,
|
|
this.isRender = !1,
|
|
(e = this.controller) == null || e.detachAnimation(),
|
|
(e = this.controller) == null || e.detachAnimation(),
|
|
this.component.dispose(this),
|
|
this.component.dispose(this),
|
|
- (t = this.avatarManager.sceneManager) == null || t.lightComponent.removeShadow(this)
|
|
|
|
|
|
+ (i = this.avatarManager.sceneManager) == null || i.lightComponent.removeShadow(this),
|
|
|
|
+ this.component.accessories.forEach(o=>{
|
|
|
|
+ o.rootComponent.setEnabled(!1)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
+
|
|
removeAvatarFromScene() {
|
|
removeAvatarFromScene() {
|
|
this._removeAvatarFromScene(),
|
|
this._removeAvatarFromScene(),
|
|
this._disposeBillBoard()
|
|
this._disposeBillBoard()
|
|
}
|
|
}
|
|
|
|
+
|
|
_disposeBillBoard() {
|
|
_disposeBillBoard() {
|
|
this.bbComponent.disposeBillBoard(this)
|
|
this.bbComponent.disposeBillBoard(this)
|
|
}
|
|
}
|
|
- addComponent(e, t, r, n) {
|
|
|
|
- return this.component.changeClothesComp(this, e, t, r, n)
|
|
|
|
|
|
+
|
|
|
|
+ addComponent(e, i, o, s) {
|
|
|
|
+ return i === "pendant" ? this.component.attachPendant(this, e) : this.component.changeClothesComp(this, e, i, o, s)
|
|
}
|
|
}
|
|
- _castRay(e) {
|
|
|
|
- return new Promise((t,r)=>{
|
|
|
|
- var d;
|
|
|
|
- const n = ue4Position2Xverse(e)
|
|
|
|
- , o = new BABYLON.Vector3(0,-1,0)
|
|
|
|
- , a = 1.5 * this.scale
|
|
|
|
- , s = 100 * a
|
|
|
|
- , l = a
|
|
|
|
- , u = new BABYLON.Vector3(n.x,n.y + l,+n.z)
|
|
|
|
- , c = new BABYLON.Ray(u,o,s)
|
|
|
|
- , h = (d = this.avatarManager.sceneManager) == null ? void 0 : d.getGround(e);
|
|
|
|
- if (!h || h.length <= 0)
|
|
|
|
- return logger.warn(`\u89D2\u8272 id= ${this.id} \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6`),
|
|
|
|
- t(0);
|
|
|
|
- let f = c.intersectsMeshes(h);
|
|
|
|
- if (f.length > 0)
|
|
|
|
- return t(f[0].distance - l);
|
|
|
|
- if (o.y = 1,
|
|
|
|
- f = c.intersectsMeshes(h),
|
|
|
|
- f.length > 0)
|
|
|
|
- return t(-(f[0].distance - l))
|
|
|
|
|
|
+
|
|
|
|
+ removeComponent(e, i) {
|
|
|
|
+ if (e === "pendant")
|
|
|
|
+ i ? this.component.detachPendant(i) : this.component.accessories.forEach((o,s)=>{
|
|
|
|
+ this.component.detachPendant(s)
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ else {
|
|
|
|
+ const o = this.component.resourceIdList.find(s=>s.type == e);
|
|
|
|
+ o && (this.detachDecoration(o),
|
|
|
|
+ this.clothesList = this.clothesList.filter(s=>s.type != e))
|
|
}
|
|
}
|
|
- )
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ getComponentByType(e, i) {
|
|
|
|
+ if (e === "pendant")
|
|
|
|
+ if (i) {
|
|
|
|
+ const o = this.component.accessories.get(i);
|
|
|
|
+ return o || []
|
|
|
|
+ } else
|
|
|
|
+ return Array.from(this.component.accessories).map(o=>o[1]);
|
|
|
|
+ else
|
|
|
|
+ return this.component.resourceIdList.find(o=>o.type == e)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _castRay(e) {
|
|
|
|
+ return new Promise((i,o)=>{
|
|
|
|
+ var et;
|
|
|
|
+ const s = ue4Position2Xverse(e)
|
|
|
|
+ , c = new BABYLON.Vector3(0,-1,0)
|
|
|
|
+ , d = 1.5 * this.scale
|
|
|
|
+ , _ = 100 * d
|
|
|
|
+ , b = d
|
|
|
|
+ , k = new BABYLON.Vector3(s.x,s.y + b,+s.z)
|
|
|
|
+ , j = new BABYLON.Ray(k,c,_)
|
|
|
|
+ , $ = (et = this.avatarManager.sceneManager) == null ? void 0 : et.getGround(e);
|
|
|
|
+ if (!$ || $.length <= 0)
|
|
|
|
+ return log$F.warn(`\u89D2\u8272 id= ${this.id} \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6`),
|
|
|
|
+ i(0);
|
|
|
|
+ let _e = j.intersectsMeshes($);
|
|
|
|
+ if (_e.length > 0)
|
|
|
|
+ return i(_e[0].distance - b);
|
|
|
|
+ if (c.y = 1,
|
|
|
|
+ _e = j.intersectsMeshes($),
|
|
|
|
+ _e.length > 0)
|
|
|
|
+ return i(-(_e[0].distance - b))
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
setPickBoxScale(e) {
|
|
setPickBoxScale(e) {
|
|
return this.bbComponent.setPickBoxScale(e)
|
|
return this.bbComponent.setPickBoxScale(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
setIsPickable(e) {
|
|
setIsPickable(e) {
|
|
return this.bbComponent.setIsPickable(this, e)
|
|
return this.bbComponent.setIsPickable(this, e)
|
|
}
|
|
}
|
|
|
|
+
|
|
createPickBoundingbox(e) {
|
|
createPickBoundingbox(e) {
|
|
return this.bbComponent.createPickBoundingbox(this, e)
|
|
return this.bbComponent.createPickBoundingbox(this, e)
|
|
}
|
|
}
|
|
|
|
+
|
|
scaleBbox(e) {
|
|
scaleBbox(e) {
|
|
this.bbComponent.bbox && this.bbComponent.bbox.scale(e)
|
|
this.bbComponent.bbox && this.bbComponent.bbox.scale(e)
|
|
}
|
|
}
|
|
- rotateTo(e, t, r) {
|
|
|
|
- return this.stateMachine.rotateTo(this, e, t, r)
|
|
|
|
|
|
+
|
|
|
|
+ rotateTo(e, i, o) {
|
|
|
|
+ return this.stateMachine.rotateTo(this, e, i, o)
|
|
}
|
|
}
|
|
- faceTo(e, t) {
|
|
|
|
- return this.stateMachine.lookAt(this, e, t)
|
|
|
|
|
|
+
|
|
|
|
+ faceTo(e, i) {
|
|
|
|
+ return this.stateMachine.lookAt(this, e, i)
|
|
}
|
|
}
|
|
|
|
+
|
|
removeObserver() {
|
|
removeObserver() {
|
|
this.stateMachine.disposeObsever()
|
|
this.stateMachine.disposeObsever()
|
|
}
|
|
}
|
|
- move(e, t, r, n, o) {
|
|
|
|
- return this.stateMachine.moveTo(this, e, t, r, n, o)
|
|
|
|
|
|
+
|
|
|
|
+ moveHermite(e, i, o, s, c, d) {
|
|
|
|
+ return this.stateMachine.moveToHermite(this, e, i, o, s, c, d)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ moveCardinal(e, i, o, s, c, d, _=!1) {
|
|
|
|
+ return this.stateMachine.moveToCardinal(this, e, i, o, s, c, d, _)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ move(e, i, o, s, c, d=!1) {
|
|
|
|
+ return this.stateMachine.moveTo(this, e, i, o, s, c, d)
|
|
|
|
+ }
|
|
|
|
+
|
|
initNameboard(e=1) {
|
|
initNameboard(e=1) {
|
|
return this.bbComponent.initNameboard(this, e)
|
|
return this.bbComponent.initNameboard(this, e)
|
|
}
|
|
}
|
|
|
|
+
|
|
initBubble(e=1) {
|
|
initBubble(e=1) {
|
|
return this.bbComponent.initBubble(this, e)
|
|
return this.bbComponent.initBubble(this, e)
|
|
}
|
|
}
|
|
- say(e, {id: t, isUser: r, background: n, font: o="Arial", fontsize: a=38, fontcolor: s="#ffffff", fontstyle: l="bold", linesize: u=22, linelimit: c, offsets: h={
|
|
|
|
- x: 0,
|
|
|
|
- y: 0,
|
|
|
|
- z: 40
|
|
|
|
- }, scale: f=this._avatarScale, compensationZ: d=11.2, reregistAnyway: _=!0}) {
|
|
|
|
|
|
+
|
|
|
|
+ say(e, {
|
|
|
|
+ id, isUser, background,
|
|
|
|
+ font="Arial", fontsize=38, fontcolor="#ffffff", fontstyle="bold", linesize=22, linelimit,
|
|
|
|
+ offsets={x: 0, y: 0, z: 40}, scale=this._avatarScale, compensationZ=11.2, reregistAnyway=!0
|
|
|
|
+ }) {
|
|
return this.bbComponent.say(this, e, {
|
|
return this.bbComponent.say(this, e, {
|
|
- id: t,
|
|
|
|
- isUser: r,
|
|
|
|
- background: n,
|
|
|
|
- font: o,
|
|
|
|
- fontsize: a,
|
|
|
|
- fontcolor: s,
|
|
|
|
- fontstyle: l,
|
|
|
|
- linesize: u,
|
|
|
|
- linelimit: c,
|
|
|
|
- offsets: h,
|
|
|
|
- scale: f,
|
|
|
|
- compensationZ: d,
|
|
|
|
- reregistAnyway: _
|
|
|
|
|
|
+ id, isUser, background,
|
|
|
|
+ font, fontsize, fontcolor, fontstyle, linesize, linelimit,
|
|
|
|
+ offsets, scale, compensationZ, reregistAnyway
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
silent() {
|
|
silent() {
|
|
return this.bbComponent.silent()
|
|
return this.bbComponent.silent()
|
|
}
|
|
}
|
|
- setNickName(e, {id: t, isUser: r, background: n, font: o="Arial", fontsize: a=40, fontcolor: s="#ffffff", fontstyle: l="bold", linesize: u=22, linelimit: c, offsets: h={
|
|
|
|
- x: 0,
|
|
|
|
- y: 0,
|
|
|
|
- z: 15
|
|
|
|
- }, scale: f=this._avatarScale, compensationZ: d=0, reregistAnyway: _=!1}) {
|
|
|
|
|
|
+
|
|
|
|
+ setNickName(e, {
|
|
|
|
+ id, isUser, background,
|
|
|
|
+ font="Arial", fontsize=40, fontcolor="#ffffff", fontstyle="bold", linesize=22, linelimit,
|
|
|
|
+ offsets={x: 0, y: 0, z: 15}, scale=this._avatarScale, compensationZ=0, reregistAnyway=!1
|
|
|
|
+ }) {
|
|
return this.bbComponent.setNickName(this, e, {
|
|
return this.bbComponent.setNickName(this, e, {
|
|
- id: t,
|
|
|
|
- isUser: r,
|
|
|
|
- background: n,
|
|
|
|
- font: o,
|
|
|
|
- fontsize: a,
|
|
|
|
- fontcolor: s,
|
|
|
|
- fontstyle: l,
|
|
|
|
- linesize: u,
|
|
|
|
- linelimit: c,
|
|
|
|
- offsets: h,
|
|
|
|
- scale: f,
|
|
|
|
- compensationZ: d,
|
|
|
|
- reregistAnyway: _
|
|
|
|
|
|
+ id, isUser, background,
|
|
|
|
+ font, fontsize, fontcolor, fontstyle, linesize, linelimit,
|
|
|
|
+ offsets, scale, compensationZ, reregistAnyway
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- generateButtons(e=null, t=this._avatarScale, r=85) {
|
|
|
|
- return this.bbComponent.generateButtons(this, e, t, r)
|
|
|
|
|
|
+
|
|
|
|
+ generateButtons(e=null, i=this._avatarScale, o=85) {
|
|
|
|
+ return this.bbComponent.generateButtons(this, e, i, o)
|
|
}
|
|
}
|
|
|
|
+
|
|
clearButtons() {
|
|
clearButtons() {
|
|
return this.bbComponent.clearButtons()
|
|
return this.bbComponent.clearButtons()
|
|
}
|
|
}
|
|
- attachExtraProp(e, t, r, n) {
|
|
|
|
- return this.component.addDecoComp(this, e, t, r, n)
|
|
|
|
|
|
+
|
|
|
|
+ attachExtraProp(e, i, o, s) {
|
|
|
|
+ return this.component.addDecoComp(this, e, i, o, s)
|
|
}
|
|
}
|
|
|
|
+
|
|
showExtra(e) {
|
|
showExtra(e) {
|
|
return this.component.showExtra(e)
|
|
return this.component.showExtra(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
hideExtra(e) {
|
|
hideExtra(e) {
|
|
return this.component.hideExtra(e)
|
|
return this.component.hideExtra(e)
|
|
}
|
|
}
|
|
|
|
+
|
|
disposeExtra() {
|
|
disposeExtra() {
|
|
return this.component.disposeExtra()
|
|
return this.component.disposeExtra()
|
|
}
|
|
}
|
|
|
|
+
|
|
getSkeletonPositionByName(e) {
|
|
getSkeletonPositionByName(e) {
|
|
- var t;
|
|
|
|
|
|
+ var i;
|
|
if (this.skeleton) {
|
|
if (this.skeleton) {
|
|
- const r = this.skeleton.bones.find(n=>n.name.replace("Clone of ", "") == e);
|
|
|
|
- if (r && r.getTransformNode() && ((t = r.getTransformNode()) == null ? void 0 : t.position)) {
|
|
|
|
- const n = r.getTransformNode().position;
|
|
|
|
|
|
+ const o = this.skeleton.bones.find(s=>s.name.replace("Clone of ", "") == e);
|
|
|
|
+ if (o && o.getTransformNode() && ((i = o.getTransformNode()) == null ? void 0 : i.position)) {
|
|
|
|
+ const s = o.getTransformNode().position;
|
|
return xversePosition2Ue4({
|
|
return xversePosition2Ue4({
|
|
- x: n.x,
|
|
|
|
- y: n.y,
|
|
|
|
- z: n.z
|
|
|
|
|
|
+ x: s.x,
|
|
|
|
+ y: s.y,
|
|
|
|
+ z: s.z
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- shootTo(e, t, r=2, n=10, o={
|
|
|
|
|
|
+
|
|
|
|
+ shootTo(e, i, o=2, s=10, c={
|
|
x: 0,
|
|
x: 0,
|
|
y: 0,
|
|
y: 0,
|
|
z: 150
|
|
z: 150
|
|
}) {
|
|
}) {
|
|
- return this.stateMachine.sendObjectTo(this, e, t, r, n, o)
|
|
|
|
|
|
+ return this.stateMachine.sendObjectTo(this, e, i, o, s, c)
|
|
}
|
|
}
|
|
}
|
|
}
|