mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 15:15:45 +02:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: {},
|
||||
|
||||
Reference in New Issue
Block a user