1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 22:15:41 +02:00
This commit is contained in:
syuilo
2026-03-26 19:13:45 +09:00
parent 58ec8af8cd
commit 4965429069
5 changed files with 30 additions and 4 deletions

View File

@@ -164,6 +164,7 @@ type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
findMesh: (keyword: string) => BABYLON.Mesh;
findMeshes: (keyword: string) => BABYLON.Mesh[];
findMaterial: (keyword: string) => BABYLON.PBRMaterial;
findTransformNode: (keyword: string) => BABYLON.TransformNode;
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>>;
};
@@ -956,6 +957,13 @@ export class RoomEngine {
findMaterial: (keyword) => {
return findMaterial(root, keyword);
},
findTransformNode: (keyword) => {
const node = root.getChildTransformNodes().find(n => n.name.includes(keyword));
if (node == null) {
throw new Error(`TransformNode with keyword "${keyword}" not found for object ${args.type} (${args.id})`);
}
return node;
},
});
this.objectInstances.set(args.id, objectInstance);

View File

@@ -13,20 +13,20 @@ export const blind = defineObject({
options: {
schema: {
blades: {
type: 'number',
type: 'range',
label: 'Number of blades',
min: 1,
max: 100,
},
angle: {
type: 'number',
type: 'range',
label: 'Blade rotation angle (radian)',
min: -Math.PI / 2,
max: Math.PI / 2,
step: 0.01,
},
open: {
type: 'number',
type: 'range',
label: 'Opening state',
min: 0,
max: 1,

View File

@@ -36,6 +36,13 @@ export const laptopPc = defineObject({
label: 'Custom picture fit',
enum: ['cover', 'contain', 'stretch'],
},
openAngle: {
type: 'range',
label: 'Open',
min: -Math.PI / 2,
max: Math.PI / 2,
step: 0.01,
},
},
default: {
bodyColor: [1, 1, 1],
@@ -43,11 +50,13 @@ export const laptopPc = defineObject({
screenBrightness: 0.35,
customPicture: null,
fit: 'cover',
openAngle: 0,
},
},
placement: 'top',
createInstance: ({ room, options, findMesh, findMaterial }) => {
createInstance: ({ room, options, findMesh, findMaterial, findTransformNode }) => {
const screenMesh = findMesh('__X_SCREEN__');
const hutaNode = findTransformNode('__X_HUTA__');
const bodyMaterial = findMaterial('__X_BODY__');
const bezelMaterial = findMaterial('__X_BEZEL__');
@@ -111,6 +120,14 @@ export const laptopPc = defineObject({
applyBodyColor();
applyBezelColor();
const applyOpenAngle = () => {
const angle = options.openAngle;
hutaNode.rotationQuaternion = null;
hutaNode.rotation.x = -angle;
};
applyOpenAngle();
return {
onOptionsUpdated: ([k, v]) => {
switch (k) {
@@ -119,6 +136,7 @@ export const laptopPc = defineObject({
case 'screenBrightness': applyScreenBrightness(); break;
case 'customPicture': applyCustomPicture(); break;
case 'fit': applyFit(); break;
case 'openAngle': applyOpenAngle(); break;
}
},
interactions: {},