mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
downlight
This commit is contained in:
parent
ba66b5d609
commit
79541bcbe3
10 changed files with 130 additions and 0 deletions
|
|
@ -3908,6 +3908,10 @@ _miRoom:
|
|||
angleV: "縦方向の角度"
|
||||
bodyMat: "本体の素材"
|
||||
light: "照明"
|
||||
downlight: "ダウンライト"
|
||||
_downlight:
|
||||
bodyMat: "本体の素材"
|
||||
light: "照明"
|
||||
sprayer: "霧吹き"
|
||||
stanchionPole: "スタンションポール"
|
||||
_stanchionPole:
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ import { woodRingsPendantLight } from './furnitures/woodRingsPendantLight.js';
|
|||
import { woodSoundAbsorbingPanel } from './furnitures/woodSoundAbsorbingPanel.js';
|
||||
import { haniwa } from './furnitures/haniwa.js';
|
||||
import { ceilingFan } from './furnitures/ceilingFan.js';
|
||||
import { downlight } from './furnitures/downlight.js';
|
||||
import type { FurnitureDef } from './furniture.js';
|
||||
|
||||
export const FUNITURE_DEFS = [
|
||||
a4Case,
|
||||
|
|
@ -229,6 +231,7 @@ export const FUNITURE_DEFS = [
|
|||
clippedPicture,
|
||||
wireBasket,
|
||||
haniwa,
|
||||
downlight,
|
||||
] as FurnitureDef[];
|
||||
|
||||
export function getFurnitureDef(type: string): FurnitureDef {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as BABYLON from '@babylonjs/core/pure.js';
|
||||
import { cm, remap, WORLD_SCALE } from 'misskey-world/src/utility.js';
|
||||
import { downlight_schema } from 'misskey-world/src/room/furnitures/downlight.schema.js';
|
||||
import { defineFuniture } from '../furniture.js';
|
||||
import { getLightRangeFactorByGraphicsQuality } from '../utility.js';
|
||||
|
||||
export const downlight = defineFuniture(downlight_schema, {
|
||||
createInstance: ({ lc, scene, options, model, graphicsQuality }) => {
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
const lightMaterial = model.findMaterial('__X_LIGHT__');
|
||||
|
||||
const applyBodyMat = () => {
|
||||
bodyMaterial.albedoColor = new BABYLON.Color3(options.bodyMat.color[0], options.bodyMat.color[1], options.bodyMat.color[2]);
|
||||
bodyMaterial.roughness = options.bodyMat.roughness;
|
||||
bodyMaterial.metallic = options.bodyMat.metallic;
|
||||
};
|
||||
|
||||
applyBodyMat();
|
||||
|
||||
const body = model.findMesh('__X_BODY__');
|
||||
const light = new BABYLON.SpotLight('', new BABYLON.Vector3(cm(0), cm(0), 0), new BABYLON.Vector3(0, -1, 0), Math.PI / 1, 2, scene, lc != null);
|
||||
light.parent = body;
|
||||
light.radius = cm(8);
|
||||
if (lc != null) lc.addLight(light);
|
||||
|
||||
const applyLight = () => {
|
||||
const [r, g, b] = options.light.color;
|
||||
light.diffuse = new BABYLON.Color3(r, g, b);
|
||||
light.intensity = 5 * options.light.brightness * WORLD_SCALE * WORLD_SCALE;
|
||||
light.range = remap(options.light.brightness, 0, 1, cm(200), cm(400)) * getLightRangeFactorByGraphicsQuality(graphicsQuality);
|
||||
lightMaterial.emissiveColor = new BABYLON.Color3(r, g, b);
|
||||
lightMaterial.emissiveIntensity = options.light.brightness * 100;
|
||||
};
|
||||
|
||||
applyLight();
|
||||
|
||||
return {
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
switch (k) {
|
||||
case 'bodyMat': applyBodyMat(); break;
|
||||
case 'light': applyLight(); break;
|
||||
}
|
||||
},
|
||||
interactions: {},
|
||||
dispose: () => {
|
||||
light.dispose();
|
||||
if (lc != null) lc.removeLight(light);
|
||||
scene.removeLight(light); // lc使用時はsceneには追加してないはずだが、これがないとクラッシュする babylonのバグ?
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
BIN
packages/frontend/assets/world/objects/downlight/downlight.blend
Normal file
BIN
packages/frontend/assets/world/objects/downlight/downlight.blend
Normal file
Binary file not shown.
BIN
packages/frontend/assets/world/objects/downlight/downlight.glb
Normal file
BIN
packages/frontend/assets/world/objects/downlight/downlight.glb
Normal file
Binary file not shown.
|
|
@ -114,6 +114,7 @@ import { woodRingsPendantLight_ui } from './furnitures/woodRingsPendantLight.ui.
|
|||
import { woodSoundAbsorbingPanel_ui } from './furnitures/woodSoundAbsorbingPanel.ui.js';
|
||||
import { haniwa_ui } from './furnitures/haniwa.ui.js';
|
||||
import { ceilingFan_ui } from './furnitures/ceilingFan.ui.js';
|
||||
import { downlight_ui } from './furnitures/downlight.ui.js';
|
||||
import type { FurnitureUiDef } from './defineFurnitureUi.js';
|
||||
|
||||
export const FURNITURE_UI_DEFS = {
|
||||
|
|
@ -227,6 +228,7 @@ export const FURNITURE_UI_DEFS = {
|
|||
clippedPicture: clippedPicture_ui,
|
||||
wireBasket: wireBasket_ui,
|
||||
haniwa: haniwa_ui,
|
||||
downlight: downlight_ui,
|
||||
} as Record<string, FurnitureUiDef>;
|
||||
|
||||
export function getFurnitureUiDef(type: string): FurnitureUiDef {
|
||||
|
|
|
|||
20
packages/frontend/src/world/room/furnitures/downlight.ui.ts
Normal file
20
packages/frontend/src/world/room/furnitures/downlight.ui.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { defineFurnitureUi } from '../defineFurnitureUi.js';
|
||||
import type { downlight_schema } from 'misskey-world/src/room/furnitures/downlight.schema.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
export const downlight_ui = defineFurnitureUi<typeof downlight_schema>({
|
||||
name: i18n.ts._miRoom._furnitures.downlight,
|
||||
options: {
|
||||
bodyMat: {
|
||||
label: i18n.ts._miRoom._furnitures._downlight.bodyMat,
|
||||
},
|
||||
light: {
|
||||
label: i18n.ts._miRoom._furnitures._downlight.light,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -14543,6 +14543,20 @@ export interface Locale extends ILocale {
|
|||
*/
|
||||
"light": string;
|
||||
};
|
||||
/**
|
||||
* ダウンライト
|
||||
*/
|
||||
"downlight": string;
|
||||
"_downlight": {
|
||||
/**
|
||||
* 本体の素材
|
||||
*/
|
||||
"bodyMat": string;
|
||||
/**
|
||||
* 照明
|
||||
*/
|
||||
"light": string;
|
||||
};
|
||||
/**
|
||||
* 霧吹き
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ import { woodRingsPendantLight_schema } from './furnitures/woodRingsPendantLight
|
|||
import { woodSoundAbsorbingPanel_schema } from './furnitures/woodSoundAbsorbingPanel.schema.js';
|
||||
import { haniwa_schema } from './furnitures/haniwa.schema.js';
|
||||
import { ceilingFan_schema } from './furnitures/ceilingFan.schema.js';
|
||||
import { downlight_schema } from './furnitures/downlight.schema.js';
|
||||
import type { FurnitureSchemaDef } from './furniture.js';
|
||||
|
||||
export const FURNITURE_SCHEMA_DEFS = {
|
||||
|
|
@ -227,6 +228,7 @@ export const FURNITURE_SCHEMA_DEFS = {
|
|||
clippedPicture: clippedPicture_schema,
|
||||
wireBasket: wireBasket_schema,
|
||||
haniwa: haniwa_schema,
|
||||
downlight: downlight_schema,
|
||||
} as Record<string, FurnitureSchemaDef<any>>;
|
||||
|
||||
export function getFurnitureSchemaDef(type: string): FurnitureSchemaDef {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { defineFurnitureSchema } from '../furniture.js';
|
||||
export const downlight_schema = defineFurnitureSchema({
|
||||
id: 'downlight',
|
||||
options: {
|
||||
schema: {
|
||||
bodyMat: {
|
||||
type: 'material',
|
||||
},
|
||||
light: {
|
||||
type: 'light',
|
||||
},
|
||||
},
|
||||
default: {
|
||||
bodyMat: { color: [0.8, 0.8, 0.8], roughness: 0.3, metallic: 0 },
|
||||
light: {
|
||||
color: [1, 0.5, 0.2],
|
||||
brightness: 0.2,
|
||||
},
|
||||
},
|
||||
},
|
||||
placement: 'bottom',
|
||||
hasCollisions: false,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue