This commit is contained in:
syuilo
2026-05-26 09:45:40 +09:00
parent 4f89010aca
commit cb605a3978
23 changed files with 54 additions and 54 deletions
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
import { cm, remap, WORLD_SCALE } from '@/world/utility.js';
import { cm, remap, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { ductRailSpotLights_schema } from 'misskey-world/src/room/objects/ductRailSpotLights.schema.js';
export const ductRailSpotLights = defineObject(ductRailSpotLights_schema, {
@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core';
import { createTextureManager, defineObject } from '../object.js';
import { remap } from '@/world/utility.js';
import { remap } from 'misskey-world/src/utility.js';
import { poster_schema } from 'misskey-world/src/room/objects/poster.schema.js';
export const poster = defineObject(poster_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import seedrandom from 'seedrandom';
import { defineObject } from '../object.js';
import { cm, remap, WORLD_SCALE } from '@/world/utility.js';
import { cm, remap, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { randomBooks_schema } from 'misskey-world/src/room/objects/randomBooks.schema.js';
export const randomBooks = defineObject(randomBooks_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
import { cm, remap, WORLD_SCALE } from '@/world/utility.js';
import { cm, remap, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { spotLight_schema } from 'misskey-world/src/room/objects/spotLight.schema.js';
export const spotLight = defineObject(spotLight_schema, {
@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { cm, get7segMeshesOfCurrentTime, WORLD_SCALE } from '@/world/utility.js';
import { cm, get7segMeshesOfCurrentTime, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { tabletopDigitalClock_schema } from 'misskey-world/src/room/objects/tabletopDigitalClock.schema.js';
export const tabletopDigitalClock = defineObject(tabletopDigitalClock_schema, {
@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core';
import { createTextureManager, defineObject } from '../object.js';
import { remap } from '@/world/utility.js';
import { remap } from 'misskey-world/src/utility.js';
import { tabletopGlassPictureFrame_schema } from 'misskey-world/src/room/objects/tabletopGlassPictureFrame.schema.js';
export const tabletopGlassPictureFrame = defineObject(tabletopGlassPictureFrame_schema, {
@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core';
import { createTextureManager, defineObject } from '../object.js';
import { remap } from '@/world/utility.js';
import { remap } from 'misskey-world/src/utility.js';
import { tapestry_schema } from 'misskey-world/src/room/objects/tapestry.schema.js';
export const tapestry = defineObject(tapestry_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality, initTv } from '../utility.js';
import { cm, WORLD_SCALE } from '@/world/utility.js';
import { cm, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { tv_schema } from 'misskey-world/src/room/objects/tv.schema.js';
export const tv = defineObject(tv_schema, {
@@ -5,7 +5,7 @@
import * as BABYLON from '@babylonjs/core';
import { createTextureManager, defineObject } from '../object.js';
import { remap } from '@/world/utility.js';
import { remap } from 'misskey-world/src/utility.js';
import { wallGlassPictureFrame_schema } from 'misskey-world/src/room/objects/wallGlassPictureFrame.schema.js';
export const wallGlassPictureFrame = defineObject(wallGlassPictureFrame_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
import { cm, WORLD_SCALE } from '@/world/utility.js';
import { cm, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { wallMountSpotLight_schema } from 'misskey-world/src/room/objects/wallMountSpotLight.schema.js';
export const wallMountSpotLight = defineObject(wallMountSpotLight_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
import { cm, WORLD_SCALE } from '@/world/utility.js';
import { cm, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { woodRingFloorLamp_schema } from 'misskey-world/src/room/objects/woodRingFloorLamp.schema.js';
export const woodRingFloorLamp = defineObject(woodRingFloorLamp_schema, {
@@ -6,7 +6,7 @@
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../object.js';
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
import { cm, remap, WORLD_SCALE } from '@/world/utility.js';
import { cm, remap, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { woodRingsPendantLight_schema } from 'misskey-world/src/room/objects/woodRingsPendantLight.schema.js';
export const woodRingsPendantLight = defineObject(woodRingsPendantLight_schema, {
@@ -254,14 +254,6 @@ export function applyMorphTargetsToMesh(mesh: BABYLON.Mesh) {
mesh.computeWorldMatrix(true);
}
// ex) hangingTShirt -> hanging-t-shirt
export const camelToKebab = (s: string) => {
return s
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
.toLowerCase();
};
// この実装方法だとマイナスの座標をうまく処理できず結果がおかしくなるので応急処置で全体を+10000cmオフセットしてから計算している
export function getMeshesBoundingBox(meshes: BABYLON.Mesh[], forceComputeWorldMatrix = false): BABYLON.BoundingBox {
let min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
@@ -548,7 +540,7 @@ export class RecyvlingTextGrid {
export function sleep(ms: number) {
// workerで実行される可能性がある
return new Promise(resolve => setTimeout(resolve, ms));
}
@@ -558,7 +550,7 @@ export class Timer {
public setTimeout(callback: () => void, ms: number) {
// workerで実行される可能性がある
const id = setTimeout(() => {
this.timeoutIds = this.timeoutIds.filter(i => i !== id);
callback();
@@ -569,7 +561,7 @@ export class Timer {
public setInterval(callback: () => void, ms: number, signal?: AbortSignal) {
// workerで実行される可能性がある
const id = setInterval(callback, ms);
this.intervalIds.push(id);
if (signal != null) {
@@ -582,14 +574,14 @@ export class Timer {
private clearTimeout(id: number) {
// workerで実行される可能性がある
clearTimeout(id);
this.timeoutIds = this.timeoutIds.filter(i => i !== id);
}
private clearInterval(id: number) {
// workerで実行される可能性がある
clearInterval(id);
this.intervalIds = this.intervalIds.filter(i => i !== id);
}
@@ -597,14 +589,14 @@ export class Timer {
public dispose() {
for (const id of this.timeoutIds) {
// workerで実行される可能性がある
clearTimeout(id);
}
this.timeoutIds = [];
for (const id of this.intervalIds) {
// workerで実行される可能性がある
clearInterval(id);
}
this.intervalIds = [];
@@ -624,24 +616,6 @@ export function getYRotationDirection(rotationY: number): '+x' | '+z' | '-x' | '
}
}
export function getHex(c: [number, number, number]) {
return `#${c.map(x => Math.round(x * 255).toString(16).padStart(2, '0')).join('')}`;
}
export function getRgb(hex: string | number): [number, number, number] | null {
if (
typeof hex === 'number' ||
typeof hex !== 'string' ||
!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex)
) {
return null;
}
const m = hex.slice(1).match(/[0-9a-fA-F]{2}/g);
if (m == null) return [0, 0, 0];
return m.map(x => parseInt(x, 16) / 255) as [number, number, number];
}
export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeCamera> {
public camera: BABYLON.FreeCamera;
private scene: BABYLON.Scene;
+1 -1
View File
@@ -21,7 +21,7 @@ import { ensureSignin } from '@/i';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/utility/misskey-api.js';
import { WORLD_SCALE } from '@/world/utility.js';
import { WORLD_SCALE } from 'misskey-world/src/utility.js';
import { useRouter } from '@/router.js';
const router = useRouter();
@@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script setup lang="ts">
import type { OBJECT_SCHEMA_DEFS } from '@/world/room/object-schema-defs.js';
import { OBJECT_UI_DEFS } from '@/world/room/object-ui-defs.js';
import { camelToKebab } from '@/world/utility.js';
import { camelToKebab } from 'misskey-world/src/utility.js';
const props = defineProps<{
def: typeof OBJECT_SCHEMA_DEFS[string];
@@ -75,7 +75,7 @@ import type { RoomAttachments } from '@/world/room/utility.js';
import { i18n } from '@/i18n.js';
import MkModalWindow from '@/components/MkModalWindow.vue';
import * as os from '@/os.js';
import { camelToKebab } from '@/world/utility.js';
import { camelToKebab } from 'misskey-world/src/utility.js';
import MkButton from '@/components/MkButton.vue';
import { prefer } from '@/preferences.js';
import { deepClone } from '@/utility/clone.js';
@@ -95,7 +95,7 @@ import { i18n } from '@/i18n.js';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { RoomController } from '@/world/room/controller.js';
import { cm, getHex, getRgb, WORLD_SCALE } from '@/world/utility.js';
import { cm, getHex, getRgb, WORLD_SCALE } from 'misskey-world/src/utility.js';
import { deepClone } from '@/utility/clone.js';
import { deviceKind } from '@/utility/device-kind.js';
import MkProgressBar from '@/components/MkProgressBar.vue';
@@ -44,7 +44,7 @@ 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 { getHex, getRgb } from 'misskey-world/src/utility.js';
import MkFolder from '@/components/MkFolder.vue';
const props = defineProps<{
@@ -83,7 +83,7 @@ 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 { getHex, getRgb } from 'misskey-world/src/utility.js';
import { chooseDriveFile } from '@/utility/drive.js';
import MkRadios from '@/components/MkRadios.vue';
import MkFolder from '@/components/MkFolder.vue';
@@ -108,7 +108,7 @@ 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 { getHex, getRgb } from 'misskey-world/src/utility.js';
import MkFolder from '@/components/MkFolder.vue';
const props = defineProps<{
@@ -37,7 +37,7 @@ 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 { getHex, getRgb } from 'misskey-world/src/utility.js';
const props = defineProps<{
options: SimpleEnvOptions['pillars']['nw' | 'ne' | 'sw' | 'se'];
@@ -55,7 +55,7 @@ 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 { getHex, getRgb } from 'misskey-world/src/utility.js';
const props = defineProps<{
options: SimpleEnvOptions['walls']['n' | 's' | 'w' | 'e'];
+26
View File
@@ -14,3 +14,29 @@ export const cm = (value: number) => value;
export function remap(value: number, inMin: number, inMax: number, outMin: number, outMax: number) {
return outMin + (outMax - outMin) * ((value - inMin) / (inMax - inMin));
}
// ex) hangingTShirt -> hanging-t-shirt
export const camelToKebab = (s: string) => {
return s
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
.toLowerCase();
};
export function getHex(c: [number, number, number]) {
return `#${c.map(x => Math.round(x * 255).toString(16).padStart(2, '0')).join('')}`;
}
export function getRgb(hex: string | number): [number, number, number] | null {
if (
typeof hex === 'number' ||
typeof hex !== 'string' ||
!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex)
) {
return null;
}
const m = hex.slice(1).match(/[0-9a-fA-F]{2}/g);
if (m == null) return [0, 0, 0];
return m.map(x => parseInt(x, 16) / 255) as [number, number, number];
}