mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-24 23:14:06 +02:00
wip
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="$style.root">
|
||||||
|
<div class="_gaps">
|
||||||
|
<MkFolder>
|
||||||
|
<template #label>Wall N</template>
|
||||||
|
<XWallOption :options="options.walls.n" @update="v => { emit('update', { ...options, walls: { ...options.walls, n: v } }); }"></XWallOption>
|
||||||
|
</MkFolder>
|
||||||
|
<MkFolder>
|
||||||
|
<template #label>Wall S</template>
|
||||||
|
<XWallOption :options="options.walls.s" @update="v => { emit('update', { ...options, walls: { ...options.walls, s: v } }); }"></XWallOption>
|
||||||
|
</MkFolder>
|
||||||
|
<MkFolder>
|
||||||
|
<template #label>Wall W</template>
|
||||||
|
<XWallOption :options="options.walls.w" @update="v => { emit('update', { ...options, walls: { ...options.walls, w: v } }); }"></XWallOption>
|
||||||
|
</MkFolder>
|
||||||
|
<MkFolder>
|
||||||
|
<template #label>Wall E</template>
|
||||||
|
<XWallOption :options="options.walls.e" @update="v => { emit('update', { ...options, walls: { ...options.walls, e: v } }); }"></XWallOption>
|
||||||
|
</MkFolder>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
||||||
|
import XWallOption from './room.default-heya-wall-options.vue';
|
||||||
|
import type { ObjectDef } from '@/world/room/object.js';
|
||||||
|
import type { SimpleHeyaOptions } from '@/world/room/heya.js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkSelect from '@/components/MkSelect.vue';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
import MkInput from '@/components/MkInput.vue';
|
||||||
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
import MkRange from '@/components/MkRange.vue';
|
||||||
|
import { getHex, getRgb } from '@/world/utility.js';
|
||||||
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
options: SimpleHeyaOptions;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'update', v: SimpleHeyaOptions): void;
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="$style.root">
|
||||||
|
<div class="_gaps">
|
||||||
|
<MkSelect
|
||||||
|
:items="[
|
||||||
|
{ label: 'None', value: null },
|
||||||
|
{ label: 'Wood', value: 'wood' },
|
||||||
|
{ label: 'Concrete', value: 'concrete' },
|
||||||
|
]" :modelValue="options.material" @update:modelValue="v => { update({ material: v }); }"
|
||||||
|
>
|
||||||
|
<template #label>wallpaper</template>
|
||||||
|
</MkSelect>
|
||||||
|
<MkInput :modelValue="getHex(options.color)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) update({ color: c }); }">
|
||||||
|
<template #label>color</template>
|
||||||
|
</MkInput>
|
||||||
|
<hr>
|
||||||
|
<MkSwitch :modelValue="options.withHari" @update:modelValue="v => { update({ withHari: v }); }">
|
||||||
|
<template #label>with Hari</template>
|
||||||
|
</MkSwitch>
|
||||||
|
<MkSelect
|
||||||
|
:items="[
|
||||||
|
{ label: 'None', value: null },
|
||||||
|
{ label: 'Wood', value: 'wood' },
|
||||||
|
{ label: 'Concrete', value: 'concrete' },
|
||||||
|
]" :modelValue="options.hariMaterial" @update:modelValue="v => { update({ hariMaterial: v }); }"
|
||||||
|
>
|
||||||
|
<template #label>hari material</template>
|
||||||
|
</MkSelect>
|
||||||
|
<MkInput :modelValue="getHex(options.hariColor)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) update({ hariColor: c }); }">
|
||||||
|
<template #label>hari color</template>
|
||||||
|
</MkInput>
|
||||||
|
<hr>
|
||||||
|
<MkSwitch :modelValue="options.withHabaki" @update:modelValue="v => { update({ withHabaki: v }); }">
|
||||||
|
<template #label>with Habaki</template>
|
||||||
|
</MkSwitch>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
||||||
|
import type { ObjectDef } from '@/world/room/object.js';
|
||||||
|
import type { SimpleHeyaOptions } from '@/world/room/heya.js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkSelect from '@/components/MkSelect.vue';
|
||||||
|
import * as os from '@/os.js';
|
||||||
|
import MkInput from '@/components/MkInput.vue';
|
||||||
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
import MkRange from '@/components/MkRange.vue';
|
||||||
|
import { getHex, getRgb } from '@/world/utility.js';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
options: SimpleHeyaOptions['walls']['n' | 's' | 'w' | 'e'];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'update', v: SimpleHeyaOptions['walls']['n' | 's' | 'w' | 'e']): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
function update(v: Partial<SimpleHeyaOptions['walls']['n' | 's' | 'w' | 'e']>) {
|
||||||
|
emit('update', { ...props.options, ...v });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -84,146 +84,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</MkSelect>
|
</MkSelect>
|
||||||
|
|
||||||
<template v-if="controller.roomState.value.heya.type === 'simple'">
|
<template v-if="controller.roomState.value.heya.type === 'simple'">
|
||||||
<div>
|
<XDefaultHeyaOptions :options="controller.roomState.value.heya.options" @update="v => controller.updateHeyaOptions(v)"></XDefaultHeyaOptions>
|
||||||
<div>Wall N</div>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallN.material" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, material: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>wallpaper</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallN.color)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, color: c } }); }">
|
|
||||||
<template #label>color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallN.withHari" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, withHari: v } }); }">
|
|
||||||
<template #label>with Hari</template>
|
|
||||||
</MkSwitch>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallN.hariMaterial" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, hariMaterial: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>hari material</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallN.hariColor)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, hariColor: c } }); }">
|
|
||||||
<template #label>hari color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallN.withHabaki" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallN: { ...controller.roomState.value.heya.options.wallN, withHabaki: v } }); }">
|
|
||||||
<template #label>with Habaki</template>
|
|
||||||
</MkSwitch>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Wall E</div>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallE.material" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, material: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>wallpaper</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallE.color)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, color: c } }); }">
|
|
||||||
<template #label>color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallE.withHari" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, withHari: v } }); }">
|
|
||||||
<template #label>with Hari</template>
|
|
||||||
</MkSwitch>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallE.hariMaterial" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, hariMaterial: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>hari material</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallE.hariColor)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, hariColor: c } }); }">
|
|
||||||
<template #label>hari color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallE.withHabaki" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallE: { ...controller.roomState.value.heya.options.wallE, withHabaki: v } }); }">
|
|
||||||
<template #label>with Habaki</template>
|
|
||||||
</MkSwitch>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Wall S</div>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallS.material" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, material: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>wallpaper</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallS.color)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, color: c } }); }">
|
|
||||||
<template #label>color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallS.withHari" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, withHari: v } }); }">
|
|
||||||
<template #label>with Hari</template>
|
|
||||||
</MkSwitch>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallS.hariMaterial" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, hariMaterial: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>hari material</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallS.hariColor)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, hariColor: c } }); }">
|
|
||||||
<template #label>hari color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallS.withHabaki" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallS: { ...controller.roomState.value.heya.options.wallS, withHabaki: v } }); }">
|
|
||||||
<template #label>with Habaki</template>
|
|
||||||
</MkSwitch>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div>Wall W</div>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallW.material" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, material: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>wallpaper</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallW.color)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, color: c } }); }">
|
|
||||||
<template #label>color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallW.withHari" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, withHari: v } }); }">
|
|
||||||
<template #label>with Hari</template>
|
|
||||||
</MkSwitch>
|
|
||||||
<MkSelect
|
|
||||||
:items="[
|
|
||||||
{ label: 'None', value: null },
|
|
||||||
{ label: 'Wood', value: 'wood' },
|
|
||||||
{ label: 'Concrete', value: 'concrete' },
|
|
||||||
]" :modelValue="controller.roomState.value.heya.options.wallW.hariMaterial" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, hariMaterial: v } }); }"
|
|
||||||
>
|
|
||||||
<template #label>hari material</template>
|
|
||||||
</MkSelect>
|
|
||||||
<MkInput :modelValue="getHex(controller.roomState.value.heya.options.wallW.hariColor)" type="color" @update:modelValue="v => { const c = getRgb(v); if (c != null) controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, hariColor: c } }); }">
|
|
||||||
<template #label>hari color</template>
|
|
||||||
</MkInput>
|
|
||||||
<hr>
|
|
||||||
<MkSwitch :modelValue="controller.roomState.value.heya.options.wallW.withHabaki" @update:modelValue="v => { controller.updateHeyaOptions({ ...controller.roomState.value.heya.options, wallW: { ...controller.roomState.value.heya.options.wallW, withHabaki: v } }); }">
|
|
||||||
<template #label>with Habaki</template>
|
|
||||||
</MkSwitch>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -239,6 +100,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
||||||
import * as BABYLON from '@babylonjs/core';
|
import * as BABYLON from '@babylonjs/core';
|
||||||
import XObjectCustomizeForm from './room.object-customize-form.vue';
|
import XObjectCustomizeForm from './room.object-customize-form.vue';
|
||||||
|
import XDefaultHeyaOptions from './room.default-heya-options.vue';
|
||||||
import type { RoomControllerOptions } from '@/world/room/controller.js';
|
import type { RoomControllerOptions } from '@/world/room/controller.js';
|
||||||
import { definePage } from '@/page.js';
|
import { definePage } from '@/page.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
@@ -311,21 +173,39 @@ const data = localStorage.getItem('roomData') != null ? JSON.parse(localStorage.
|
|||||||
options: {
|
options: {
|
||||||
dimension: [300, 300],
|
dimension: [300, 300],
|
||||||
window: 'demado',
|
window: 'demado',
|
||||||
wallN: {
|
walls: {
|
||||||
material: null,
|
n: {
|
||||||
color: [0.9, 0.9, 0.9],
|
material: null,
|
||||||
},
|
color: [0.9, 0.9, 0.9],
|
||||||
wallE: {
|
withHari: false,
|
||||||
material: null,
|
hariMaterial: null,
|
||||||
color: [0.9, 0.9, 0.9],
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
},
|
withHabaki: false,
|
||||||
wallS: {
|
},
|
||||||
material: null,
|
e: {
|
||||||
color: [0.9, 0.9, 0.9],
|
material: null,
|
||||||
},
|
color: [0.9, 0.9, 0.9],
|
||||||
wallW: {
|
withHari: false,
|
||||||
material: null,
|
hariMaterial: null,
|
||||||
color: [0.9, 0.9, 0.9],
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
s: {
|
||||||
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
w: {
|
||||||
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
flooring: {
|
flooring: {
|
||||||
material: 'wood',
|
material: 'wood',
|
||||||
@@ -341,10 +221,42 @@ const data = localStorage.getItem('roomData') != null ? JSON.parse(localStorage.
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 後方互換性のため
|
// 後方互換性のため
|
||||||
if (data.heya.options.wallE.hariColor == null) data.heya.options.wallE.hariColor = [0.8, 0.8, 0.8];
|
if (data.heya.options.walls == null) {
|
||||||
if (data.heya.options.wallN.hariColor == null) data.heya.options.wallN.hariColor = [0.8, 0.8, 0.8];
|
data.heya.options.walls = {
|
||||||
if (data.heya.options.wallS.hariColor == null) data.heya.options.wallS.hariColor = [0.8, 0.8, 0.8];
|
n: {
|
||||||
if (data.heya.options.wallW.hariColor == null) data.heya.options.wallW.hariColor = [0.8, 0.8, 0.8];
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
e: {
|
||||||
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
s: {
|
||||||
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
w: {
|
||||||
|
material: null,
|
||||||
|
color: [0.9, 0.9, 0.9],
|
||||||
|
withHari: false,
|
||||||
|
hariMaterial: null,
|
||||||
|
hariColor: [0.8, 0.8, 0.8],
|
||||||
|
withHabaki: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let latestData = deepClone(data);
|
let latestData = deepClone(data);
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,12 @@ type SimpleHeyaWallBase = {
|
|||||||
export type SimpleHeyaOptions = {
|
export type SimpleHeyaOptions = {
|
||||||
dimension: [number, number];
|
dimension: [number, number];
|
||||||
window: 'none' | 'kosidakamado' | 'demado' | 'hakidasimado';
|
window: 'none' | 'kosidakamado' | 'demado' | 'hakidasimado';
|
||||||
wallN: SimpleHeyaWallBase;
|
walls: {
|
||||||
wallE: SimpleHeyaWallBase;
|
n: SimpleHeyaWallBase;
|
||||||
wallS: SimpleHeyaWallBase;
|
s: SimpleHeyaWallBase;
|
||||||
wallW: SimpleHeyaWallBase;
|
w: SimpleHeyaWallBase;
|
||||||
|
e: SimpleHeyaWallBase;
|
||||||
|
};
|
||||||
flooring: {
|
flooring: {
|
||||||
material: null | 'wood' | 'concrete';
|
material: null | 'wood' | 'concrete';
|
||||||
color: [number, number, number];
|
color: [number, number, number];
|
||||||
@@ -59,18 +61,24 @@ export type JapaneseHeyaOptions = {
|
|||||||
export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
||||||
private loaderResult: BABYLON.ISceneLoaderAsyncResult | null = null;
|
private loaderResult: BABYLON.ISceneLoaderAsyncResult | null = null;
|
||||||
private meshes: BABYLON.Mesh[] = [];
|
private meshes: BABYLON.Mesh[] = [];
|
||||||
private wallNRoot: BABYLON.TransformNode | null = null;
|
private wallRoots: {
|
||||||
private wallSRoot: BABYLON.TransformNode | null = null;
|
n: BABYLON.TransformNode;
|
||||||
private wallWRoot: BABYLON.TransformNode | null = null;
|
s: BABYLON.TransformNode;
|
||||||
private wallERoot: BABYLON.TransformNode | null = null;
|
w: BABYLON.TransformNode;
|
||||||
private wallNMaterial: BABYLON.PBRMaterial | null = null;
|
e: BABYLON.TransformNode;
|
||||||
private wallSMaterial: BABYLON.PBRMaterial | null = null;
|
} | null = null;
|
||||||
private wallWMaterial: BABYLON.PBRMaterial | null = null;
|
private wallMaterials: {
|
||||||
private wallEMaterial: BABYLON.PBRMaterial | null = null;
|
n: BABYLON.PBRMaterial;
|
||||||
private wallNHariMaterial: BABYLON.PBRMaterial | null = null;
|
s: BABYLON.PBRMaterial;
|
||||||
private wallSHariMaterial: BABYLON.PBRMaterial | null = null;
|
w: BABYLON.PBRMaterial;
|
||||||
private wallWHariMaterial: BABYLON.PBRMaterial | null = null;
|
e: BABYLON.PBRMaterial;
|
||||||
private wallEHariMaterial: BABYLON.PBRMaterial | null = null;
|
} | null = null;
|
||||||
|
private wallHariMaterials: {
|
||||||
|
n: BABYLON.PBRMaterial;
|
||||||
|
s: BABYLON.PBRMaterial;
|
||||||
|
w: BABYLON.PBRMaterial;
|
||||||
|
e: BABYLON.PBRMaterial;
|
||||||
|
} | null = null;
|
||||||
|
|
||||||
constructor(onMeshUpdatedCallback?: ((meshes: BABYLON.AbstractMesh[]) => void) | null) {
|
constructor(onMeshUpdatedCallback?: ((meshes: BABYLON.AbstractMesh[]) => void) | null) {
|
||||||
super(onMeshUpdatedCallback);
|
super(onMeshUpdatedCallback);
|
||||||
@@ -104,47 +112,36 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wallNRoot = this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_N__'))!;
|
this.wallRoots = {
|
||||||
this.wallSRoot = this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_S__'))!;
|
n: this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_N__'))!,
|
||||||
this.wallWRoot = this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_W__'))!;
|
s: this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_S__'))!,
|
||||||
this.wallERoot = this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_E__'))!;
|
w: this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_W__'))!,
|
||||||
|
e: this.loaderResult.transformNodes.find(t => t.name.includes('__WALL_E__'))!,
|
||||||
|
};
|
||||||
|
|
||||||
const wallMaterial = findMaterial(this.meshes[0], '__X_WALL__');
|
const wallMaterial = findMaterial(this.meshes[0], '__X_WALL__');
|
||||||
this.wallNMaterial = wallMaterial.clone('wallNMaterial');
|
this.wallMaterials = {
|
||||||
this.wallSMaterial = wallMaterial.clone('wallSMaterial');
|
n: wallMaterial.clone('wallNMaterial'),
|
||||||
this.wallWMaterial = wallMaterial.clone('wallWMaterial');
|
s: wallMaterial.clone('wallSMaterial'),
|
||||||
this.wallEMaterial = wallMaterial.clone('wallEMaterial');
|
w: wallMaterial.clone('wallWMaterial'),
|
||||||
|
e: wallMaterial.clone('wallEMaterial'),
|
||||||
for (const m of this.wallNRoot.getChildMeshes().filter(m => m.material === wallMaterial)) {
|
};
|
||||||
m.material = this.wallNMaterial;
|
|
||||||
}
|
|
||||||
for (const m of this.wallSRoot.getChildMeshes().filter(m => m.material === wallMaterial)) {
|
|
||||||
m.material = this.wallSMaterial;
|
|
||||||
}
|
|
||||||
for (const m of this.wallWRoot.getChildMeshes().filter(m => m.material === wallMaterial)) {
|
|
||||||
m.material = this.wallWMaterial;
|
|
||||||
}
|
|
||||||
for (const m of this.wallERoot.getChildMeshes().filter(m => m.material === wallMaterial)) {
|
|
||||||
m.material = this.wallEMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hariMaterial = findMaterial(this.meshes[0], '__X_HARI__');
|
const hariMaterial = findMaterial(this.meshes[0], '__X_HARI__');
|
||||||
this.wallNHariMaterial = hariMaterial.clone('wallNHariMaterial');
|
this.wallHariMaterials = {
|
||||||
this.wallSHariMaterial = hariMaterial.clone('wallSHariMaterial');
|
n: hariMaterial.clone('wallNHariMaterial'),
|
||||||
this.wallWHariMaterial = hariMaterial.clone('wallWHariMaterial');
|
s: hariMaterial.clone('wallSHariMaterial'),
|
||||||
this.wallEHariMaterial = hariMaterial.clone('wallEHariMaterial');
|
w: hariMaterial.clone('wallWHariMaterial'),
|
||||||
|
e: hariMaterial.clone('wallEHariMaterial'),
|
||||||
|
};
|
||||||
|
|
||||||
for (const m of this.wallNRoot.getChildMeshes().filter(m => m.material === hariMaterial)) {
|
for (const [k, v] of Object.entries(this.wallRoots)) {
|
||||||
m.material = this.wallNHariMaterial;
|
for (const m of v.getChildMeshes().filter(m => m.material === wallMaterial)) {
|
||||||
}
|
m.material = this.wallMaterials[k];
|
||||||
for (const m of this.wallSRoot.getChildMeshes().filter(m => m.material === hariMaterial)) {
|
}
|
||||||
m.material = this.wallSHariMaterial;
|
for (const m of v.getChildMeshes().filter(m => m.material === hariMaterial)) {
|
||||||
}
|
m.material = this.wallHariMaterials[k];
|
||||||
for (const m of this.wallWRoot.getChildMeshes().filter(m => m.material === hariMaterial)) {
|
}
|
||||||
m.material = this.wallWHariMaterial;
|
|
||||||
}
|
|
||||||
for (const m of this.wallERoot.getChildMeshes().filter(m => m.material === hariMaterial)) {
|
|
||||||
m.material = this.wallEHariMaterial;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.applyOptions(options);
|
await this.applyOptions(options);
|
||||||
@@ -153,18 +150,9 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
public applyOptions(options: SimpleHeyaOptions) {
|
public applyOptions(options: SimpleHeyaOptions) {
|
||||||
// TODO: 返り値をpromiseにしてちゃんとテクスチャが読み終わってからresolveする
|
// TODO: 返り値をpromiseにしてちゃんとテクスチャが読み終わってからresolveする
|
||||||
|
|
||||||
const applyWall = (wall: 'N' | 'S' | 'W' | 'E') => {
|
for (const type of ['n', 's', 'w', 'e'] as const) {
|
||||||
const wallRoot =
|
const wallRoot = this.wallRoots[type];
|
||||||
wall === 'N' ? this.wallNRoot :
|
const wallOptions = options.walls[type];
|
||||||
wall === 'S' ? this.wallSRoot :
|
|
||||||
wall === 'W' ? this.wallWRoot :
|
|
||||||
this.wallERoot;
|
|
||||||
|
|
||||||
const wallOptions =
|
|
||||||
wall === 'N' ? options.wallN :
|
|
||||||
wall === 'S' ? options.wallS :
|
|
||||||
wall === 'W' ? options.wallW :
|
|
||||||
options.wallE;
|
|
||||||
|
|
||||||
for (const mesh of wallRoot.getChildMeshes()) {
|
for (const mesh of wallRoot.getChildMeshes()) {
|
||||||
if (mesh.name.includes('__X_HARI__')) {
|
if (mesh.name.includes('__X_HARI__')) {
|
||||||
@@ -175,11 +163,7 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const targetMaterial =
|
const targetMaterial = this.wallMaterials[type];
|
||||||
wall === 'N' ? this.wallNMaterial :
|
|
||||||
wall === 'S' ? this.wallSMaterial :
|
|
||||||
wall === 'W' ? this.wallWMaterial :
|
|
||||||
this.wallEMaterial;
|
|
||||||
|
|
||||||
targetMaterial.unfreeze();
|
targetMaterial.unfreeze();
|
||||||
targetMaterial.albedoColor = new BABYLON.Color3(...wallOptions.color);
|
targetMaterial.albedoColor = new BABYLON.Color3(...wallOptions.color);
|
||||||
@@ -199,11 +183,7 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const targetMaterial =
|
const targetMaterial = this.wallHariMaterials[type];
|
||||||
wall === 'N' ? this.wallNHariMaterial :
|
|
||||||
wall === 'S' ? this.wallSHariMaterial :
|
|
||||||
wall === 'W' ? this.wallWHariMaterial :
|
|
||||||
this.wallEHariMaterial;
|
|
||||||
|
|
||||||
targetMaterial.unfreeze();
|
targetMaterial.unfreeze();
|
||||||
targetMaterial.albedoColor = new BABYLON.Color3(...wallOptions.hariColor);
|
targetMaterial.albedoColor = new BABYLON.Color3(...wallOptions.hariColor);
|
||||||
@@ -221,12 +201,7 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
|
|
||||||
targetMaterial.freeze();
|
targetMaterial.freeze();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
applyWall('N');
|
|
||||||
applyWall('S');
|
|
||||||
applyWall('W');
|
|
||||||
applyWall('E');
|
|
||||||
|
|
||||||
this.onMeshUpdatedCallback?.(this.meshes);
|
this.onMeshUpdatedCallback?.(this.meshes);
|
||||||
}
|
}
|
||||||
@@ -243,9 +218,11 @@ export class SimpleHeyaManager extends HeyaManager<SimpleHeyaOptions> {
|
|||||||
for (const m of this.meshes) {
|
for (const m of this.meshes) {
|
||||||
m.dispose();
|
m.dispose();
|
||||||
}
|
}
|
||||||
this.wallNMaterial?.dispose();
|
for (const m of Object.values(this.wallMaterials ?? {})) {
|
||||||
this.wallSMaterial?.dispose();
|
m.dispose();
|
||||||
this.wallWMaterial?.dispose();
|
}
|
||||||
this.wallEMaterial?.dispose();
|
for (const m of Object.values(this.wallHariMaterials ?? {})) {
|
||||||
|
m.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user