mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
wip
This commit is contained in:
parent
f8a981a1fc
commit
c343ccbdff
4 changed files with 35 additions and 30 deletions
|
|
@ -49,7 +49,7 @@ const DEFAULT_FACE_PARTS_MOUTH = {
|
|||
export class PlayerContainer {
|
||||
public id: string;
|
||||
private profile: PlayerProfile;
|
||||
private root: BABYLON.TransformNode;
|
||||
public root: BABYLON.TransformNode;
|
||||
private subRootContainerForAnim: BABYLON.TransformNode;
|
||||
private subRoot: BABYLON.TransformNode;
|
||||
private modelRoot: BABYLON.TransformNode | null = null;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ export class ObjectContainer {
|
|||
private options: ConvertedOptions;
|
||||
public root: BABYLON.TransformNode;
|
||||
private subRoot: BABYLON.TransformNode | null = null;
|
||||
private metadata: any;
|
||||
public instance: RoomObjectInstance | null = null;
|
||||
public model: ModelManager | null = null;
|
||||
private scene: BABYLON.Scene;
|
||||
|
|
@ -79,7 +78,6 @@ export class ObjectContainer {
|
|||
roomAttachments: RoomAttachments;
|
||||
position: BABYLON.Vector3;
|
||||
rotation: BABYLON.Vector3;
|
||||
metadata: any;
|
||||
sr: BABYLON.SnapshotRenderingHelper;
|
||||
getIsSrReady: () => boolean;
|
||||
lightContainer: BABYLON.ClusteredLightContainer;
|
||||
|
|
@ -95,12 +93,10 @@ export class ObjectContainer {
|
|||
this.getIsSrReady = args.getIsSrReady;
|
||||
this.lightContainer = args.lightContainer;
|
||||
this.scene = args.scene;
|
||||
this.metadata = args.metadata;
|
||||
this.graphicsQuality = args.graphicsQuality;
|
||||
this.root = new BABYLON.TransformNode(`object_${args.id}_${args.type}`, this.scene);
|
||||
this.root.position = args.position;
|
||||
this.root.rotation = args.rotation;
|
||||
this.root.metadata = this.metadata;
|
||||
if (args.sitChair != null) this.sitChair = args.sitChair;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -465,30 +465,15 @@ export class RoomEngine extends EngineBase<{
|
|||
const o = this.objectContainers.get(oid)!;
|
||||
const boundingInfo = getMeshesBoundingBox(o.root.getChildMeshes().filter(m => m.isEnabled() && m.isVisible && !m.isDisposed()), true);
|
||||
this.selectObject(oid);
|
||||
this.look(boundingInfo.center);
|
||||
return;
|
||||
}
|
||||
|
||||
{ // camera animation
|
||||
const animTarget = new BABYLON.Animation(
|
||||
'',
|
||||
'target',
|
||||
60,
|
||||
BABYLON.Animation.ANIMATIONTYPE_VECTOR3,
|
||||
BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT,
|
||||
);
|
||||
const keys = [
|
||||
{ frame: 0, value: this.camera.target.clone() },
|
||||
{ frame: 30, value: boundingInfo.center.clone() },
|
||||
];
|
||||
animTarget.setKeys(keys);
|
||||
const easing = new BABYLON.CubicEase();
|
||||
easing.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT);
|
||||
animTarget.setEasingFunction(easing);
|
||||
this.camera.animations.push(animTarget);
|
||||
this.scene.beginAnimation(this.camera, 0, 30, false, undefined, () => {
|
||||
// 視点が動くとアウトラインが薄くなるのでリセット (babylonのバグ?)
|
||||
this.sr.disableSnapshotRendering();
|
||||
this.sr.enableSnapshotRendering();
|
||||
});
|
||||
}
|
||||
const playerId = pickingInfo.pickedMesh.metadata.playerId;
|
||||
if (playerId != null && this.playerContainers.some(c => c.id === playerId)) {
|
||||
const c = this.playerContainers.find(c => c.id === playerId)!;
|
||||
this.look(c.root.position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -514,6 +499,30 @@ export class RoomEngine extends EngineBase<{
|
|||
this.inited = true;
|
||||
}
|
||||
|
||||
private look(pos: BABYLON.Vector3) {
|
||||
const animTarget = new BABYLON.Animation(
|
||||
'',
|
||||
'target',
|
||||
60,
|
||||
BABYLON.Animation.ANIMATIONTYPE_VECTOR3,
|
||||
BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT,
|
||||
);
|
||||
const keys = [
|
||||
{ frame: 0, value: this.camera.target.clone() },
|
||||
{ frame: 30, value: pos.clone() },
|
||||
];
|
||||
animTarget.setKeys(keys);
|
||||
const easing = new BABYLON.CubicEase();
|
||||
easing.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEOUT);
|
||||
animTarget.setEasingFunction(easing);
|
||||
this.camera.animations.push(animTarget);
|
||||
this.scene.beginAnimation(this.camera, 0, 30, false, undefined, () => {
|
||||
// 視点が動くとアウトラインが薄くなるのでリセット (babylonのバグ?)
|
||||
this.sr.disableSnapshotRendering();
|
||||
this.sr.enableSnapshotRendering();
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 初回以外で呼び出すとエンジンがクラッシュするのを修正
|
||||
public async changeEnvType(type: RoomState['env']['type'], forInit = false) {
|
||||
this.roomState.env.type = type;
|
||||
|
|
@ -613,7 +622,6 @@ export class RoomEngine extends EngineBase<{
|
|||
rotation: args.rotation.clone(),
|
||||
options: args.options,
|
||||
roomAttachments: this.roomAttachments,
|
||||
metadata,
|
||||
sr: this.sr,
|
||||
getIsSrReady: () => this.inited,
|
||||
lightContainer: this.lightContainer,
|
||||
|
|
@ -623,6 +631,7 @@ export class RoomEngine extends EngineBase<{
|
|||
this.sitChair(args.id);
|
||||
},
|
||||
});
|
||||
container.root.metadata = metadata;
|
||||
container.registerMeshes = (meshes) => {
|
||||
if (this.selected?.objectId === args.id) {
|
||||
this.highlightMeshes(meshes);
|
||||
|
|
@ -1484,6 +1493,7 @@ export class RoomEngine extends EngineBase<{
|
|||
mesh.receiveShadows = false;
|
||||
mesh.isVisible = false;
|
||||
} else {
|
||||
mesh.metadata = { isPlayer: true, playerId: k };
|
||||
mesh.receiveShadows = true;
|
||||
// TODO: メモリリークしそうだからいい感じにする
|
||||
this.envManager.addShadowCaster(mesh);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ export class RoomObjectPreviewEngine extends EngineBase<{
|
|||
rotation: new BABYLON.Vector3(0, 0, 0),
|
||||
options: this.objectOptions,
|
||||
roomAttachments: { files: [] },
|
||||
metadata: {},
|
||||
sr: this.sr,
|
||||
getIsSrReady: () => true,
|
||||
lightContainer: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue