mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 14:05:35 +02:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,8 @@ import { laptopPc } from './objects/laptopPc.js';
|
||||
import { lavaLamp } from './objects/lavaLamp.js';
|
||||
import { letterCase } from './objects/letterCase.js';
|
||||
import { milk } from './objects/milk.js';
|
||||
import { miPlate } from './objects/miPlate.js';
|
||||
import { miPlateDisplayed } from './objects/miPlateDisplayed.js';
|
||||
import { mixer } from './objects/mixer.js';
|
||||
import { monitor } from './objects/monitor.js';
|
||||
import { monitorSpeaker } from './objects/monitorSpeaker.js';
|
||||
@@ -58,6 +60,7 @@ import { speaker } from './objects/speaker.js';
|
||||
import { steelRack } from './objects/steelRack.js';
|
||||
import { tabletopCalendar } from './objects/tabletopCalendar.js';
|
||||
import { tabletopDigitalClock } from './objects/tabletopDigitalClock.js';
|
||||
import { tabletopFlag } from './objects/tabletopFlag.js';
|
||||
import { tabletopPictureFrame } from './objects/tabletopPictureFrame.js';
|
||||
import { tapestry } from './objects/tapestry.js';
|
||||
import { tetrapod } from './objects/tetrapod.js';
|
||||
@@ -99,6 +102,8 @@ export const OBJECT_DEFS = [
|
||||
lavaLamp,
|
||||
letterCase,
|
||||
milk,
|
||||
miPlate,
|
||||
miPlateDisplayed,
|
||||
mixer,
|
||||
monitor,
|
||||
monitorSpeaker,
|
||||
@@ -122,6 +127,7 @@ export const OBJECT_DEFS = [
|
||||
steelRack,
|
||||
tabletopCalendar,
|
||||
tabletopDigitalClock,
|
||||
tabletopFlag,
|
||||
tabletopPictureFrame,
|
||||
tapestry,
|
||||
tetrapod,
|
||||
|
||||
@@ -89,6 +89,7 @@ export const allInOnePc = defineObject({
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.level = 0.5;
|
||||
|
||||
screenMaterial.unfreeze();
|
||||
screenMaterial.emissiveTexture = tex;
|
||||
|
||||
tex.onLoadObservable.addOnce(() => {
|
||||
|
||||
@@ -98,6 +98,7 @@ export const laptopPc = defineObject({
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.level = 0.5;
|
||||
|
||||
screenMaterial.unfreeze();
|
||||
screenMaterial.emissiveTexture = tex;
|
||||
|
||||
tex.onLoadObservable.addOnce(() => {
|
||||
|
||||
@@ -164,6 +164,7 @@ export const pictureFrame = defineObject({
|
||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
|
||||
pictureMaterial.unfreeze();
|
||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||
pictureMaterial.albedoTexture = tex;
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ export const poster = defineObject({
|
||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
|
||||
pictureMaterial.unfreeze();
|
||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||
pictureMaterial.albedoTexture = tex;
|
||||
|
||||
|
||||
85
packages/frontend/src/utility/room/objects/tabletopFlag.ts
Normal file
85
packages/frontend/src/utility/room/objects/tabletopFlag.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as BABYLON from '@babylonjs/core';
|
||||
import { defineObject } from '../engine.js';
|
||||
import { createPlaneUvMapper } from '../utility.js';
|
||||
|
||||
export const tabletopFlag = defineObject({
|
||||
id: 'tabletopFlag',
|
||||
name: 'Tabletop flag',
|
||||
options: {
|
||||
schema: {
|
||||
customPicture: {
|
||||
type: 'image',
|
||||
label: 'Custom picture',
|
||||
},
|
||||
fit: {
|
||||
type: 'enum',
|
||||
label: 'Custom picture fit',
|
||||
enum: ['cover', 'contain', 'stretch'],
|
||||
},
|
||||
},
|
||||
default: {
|
||||
customPicture: null,
|
||||
fit: 'cover',
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: async ({ model, options, scene }) => {
|
||||
const flagMesh = model.findMesh('__X_FLAG__');
|
||||
const flagMaterial = model.findMaterial('__X_FLAG__');
|
||||
|
||||
const updateUv = createPlaneUvMapper(flagMesh);
|
||||
|
||||
const applyFit = () => {
|
||||
const tex = flagMaterial.albedoTexture;
|
||||
if (tex == null) return;
|
||||
|
||||
const srcWidth = tex.getSize().width;
|
||||
const srcHeight = tex.getSize().height;
|
||||
const srcAspect = srcWidth / srcHeight;
|
||||
|
||||
updateUv(srcAspect, 24 / 16, options.fit);
|
||||
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyFit();
|
||||
|
||||
const applyCustomPicture = () => new Promise<void>((resolve) => {
|
||||
if (options.customPicture != null) {
|
||||
const tex = new BABYLON.Texture(options.customPicture, scene, false, false);
|
||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
|
||||
flagMaterial.unfreeze();
|
||||
flagMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||
flagMaterial.albedoTexture = tex;
|
||||
|
||||
tex.onLoadObservable.addOnce(() => {
|
||||
applyFit();
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
flagMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5);
|
||||
flagMaterial.albedoTexture = null;
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
await applyCustomPicture();
|
||||
|
||||
return {
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
switch (k) {
|
||||
case 'customPicture': applyCustomPicture(); break;
|
||||
case 'fit': applyFit(); break;
|
||||
}
|
||||
},
|
||||
interactions: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -169,6 +169,7 @@ export const tabletopPictureFrame = defineObject({
|
||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
|
||||
pictureMaterial.unfreeze();
|
||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||
pictureMaterial.albedoTexture = tex;
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ export const tapestry = defineObject({
|
||||
tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
tex.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
|
||||
|
||||
pictureMaterial.unfreeze();
|
||||
pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1);
|
||||
pictureMaterial.albedoTexture = tex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user