mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-12 03:34:12 +02:00
wip
This commit is contained in:
@@ -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