1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-26 00:54:06 +02:00
This commit is contained in:
syuilo
2026-02-13 14:10:02 +09:00
parent efd101d0a0
commit 8665923337
2 changed files with 13 additions and 2 deletions

View File

@@ -25,6 +25,10 @@ const canvas = useTemplateRef('canvas');
let engine: RoomEngine; let engine: RoomEngine;
function resize() {
if (engine != null) engine.resize();
}
onMounted(() => { onMounted(() => {
engine = new RoomEngine({ engine = new RoomEngine({
roomType: 'default', roomType: 'default',
@@ -184,10 +188,14 @@ onMounted(() => {
engine.init(); engine.init();
canvas.value!.focus(); canvas.value!.focus();
window.addEventListener('resize', resize);
}); });
onUnmounted(() => { onUnmounted(() => {
engine.destroy(); engine.destroy();
window.removeEventListener('resize', resize);
}); });
function onKeydown(ev: KeyboardEvent) { function onKeydown(ev: KeyboardEvent) {

View File

@@ -286,8 +286,7 @@ const OBJECTS = {
castShadows: false, castShadows: false,
onInit: (room, o, obj) => { onInit: (room, o, obj) => {
const rotor = obj.meshes[0].getChildMeshes().find(m => m.name === 'Rotor') as BABYLON.Mesh; const rotor = obj.meshes[0].getChildMeshes().find(m => m.name === 'Rotor') as BABYLON.Mesh;
rotor.rotationQuaternion = null; rotor.rotation = rotor.rotationQuaternion != null ? rotor.rotationQuaternion.toEulerAngles() : rotor.rotation;
console.log(obj.meshes, obj.meshes[0].getChildMeshes().map(x => x.name), rotor, rotor.getChildMeshes());
const anim = new BABYLON.Animation('', 'rotation.y', 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); const anim = new BABYLON.Animation('', 'rotation.y', 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
anim.setKeys([ anim.setKeys([
{ frame: 0, value: 0 }, { frame: 0, value: 0 },
@@ -1049,6 +1048,10 @@ export class RoomEngine {
} }
} }
public resize() {
this.engine.resize();
}
public destroy() { public destroy() {
for (const id of this.intervalIds) { for (const id of this.intervalIds) {
window.clearInterval(id); window.clearInterval(id);