This commit is contained in:
syuilo
2026-03-04 18:01:00 +09:00
parent f311105b54
commit 354504b534
2 changed files with 282 additions and 274 deletions

View File

@@ -60,6 +60,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkButton @click="toggleLight">Toggle Light</MkButton>
<MkButton :primary="engine.isEditMode.value" @click="toggleEditMode">Edit mode: {{ engine.isEditMode.value ? 'on' : 'off' }}</MkButton>
<MkButton @click="addObject">addObject</MkButton>
<MkButton primary @click="save">save</MkButton>
</div>
</template>
</div>
@@ -202,8 +203,7 @@ function onWheel(ev: WheelEvent) {
}
}
onMounted(() => {
engine.value = new RoomEngine({
const data = localStorage.getItem('roomData') != null ? JSON.parse(localStorage.getItem('roomData')!) : {
roomType: 'default',
installedObjects: [{
id: 'a',
@@ -475,7 +475,10 @@ onMounted(() => {
open: 0.5,
},
}],
}, {
};
onMounted(() => {
engine.value = new RoomEngine(data, {
canvas: canvas.value!,
});
@@ -593,6 +596,11 @@ function getRgb(hex: string | number): [number, number, number] | null {
return m.map(x => parseInt(x, 16) / 255) as [number, number, number];
}
function save() {
if (engine.value == null) return;
localStorage.setItem('roomData', JSON.stringify(engine.value.roomState));
}
definePage(() => ({
title: 'Room',
icon: 'ti ti-door',

View File

@@ -521,7 +521,7 @@ export class RoomEngine {
id: o.id,
type: o.type,
position: new BABYLON.Vector3(...o.position),
rotation: new BABYLON.Vector3(o.rotation[0], -o.rotation[1], o.rotation[2]),
rotation: new BABYLON.Vector3(o.rotation[0], o.rotation[1], o.rotation[2]),
options: o.options,
isMainLight: o.isMainLight,
})));