mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 16:25:44 +02:00
boxWallShelf
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -14,6 +14,7 @@ import { bed } from './objects/bed.js';
|
||||
import { blind } from './objects/blind.js';
|
||||
import { book } from './objects/book.js';
|
||||
import { books } from './objects/books.js';
|
||||
import { boxWallShelf } from './objects/boxWallShelf.js';
|
||||
import { cactusS } from './objects/cactusS.js';
|
||||
import { cardboardBox } from './objects/cardboardBox.js';
|
||||
import { ceilingFanLight } from './objects/ceilingFanLight.js';
|
||||
@@ -105,6 +106,7 @@ export const OBJECT_DEFS = [
|
||||
blind,
|
||||
book,
|
||||
books,
|
||||
boxWallShelf,
|
||||
cactusS,
|
||||
cardboardBox,
|
||||
ceilingFanLight,
|
||||
|
||||
100
packages/frontend/src/world/room/objects/boxWallShelf.ts
Normal file
100
packages/frontend/src/world/room/objects/boxWallShelf.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as BABYLON from '@babylonjs/core';
|
||||
import { defineObject } from '../object.js';
|
||||
|
||||
export const boxWallShelf = defineObject({
|
||||
id: 'boxWallShelf',
|
||||
name: 'boxWallShelf',
|
||||
options: {
|
||||
schema: {
|
||||
width: {
|
||||
type: 'range',
|
||||
label: 'Width',
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
},
|
||||
height: {
|
||||
type: 'range',
|
||||
label: 'Height',
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
},
|
||||
bodyColor: {
|
||||
type: 'color',
|
||||
label: 'Body color',
|
||||
},
|
||||
withBack: {
|
||||
type: 'boolean',
|
||||
label: 'With back',
|
||||
},
|
||||
},
|
||||
default: {
|
||||
width: 0.1,
|
||||
height: 0.1,
|
||||
bodyColor: [0.6, 0.35, 0.15],
|
||||
withBack: true,
|
||||
},
|
||||
},
|
||||
placement: 'wall',
|
||||
hasCollisions: false,
|
||||
hasTexture: false,
|
||||
createInstance: async ({ scene, options, model }) => {
|
||||
const backMesh = model.findMesh('__X_BACK__');
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
|
||||
const applySize = () => {
|
||||
for (const mesh of model.root.getChildMeshes()) {
|
||||
if (mesh.morphTargetManager != null && mesh.morphTargetManager.getTargetByName('W') != null) {
|
||||
mesh.morphTargetManager.getTargetByName('W').influence = options.width;
|
||||
}
|
||||
if (mesh.morphTargetManager != null && mesh.morphTargetManager.getTargetByName('H') != null) {
|
||||
mesh.morphTargetManager.getTargetByName('H').influence = options.height;
|
||||
}
|
||||
}
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applySize();
|
||||
|
||||
const applyBodyColor = () => {
|
||||
const [r, g, b] = options.bodyColor;
|
||||
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
|
||||
};
|
||||
|
||||
applyBodyColor();
|
||||
|
||||
const applyWithBack = () => {
|
||||
backMesh.isVisible = options.withBack;
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applyWithBack();
|
||||
|
||||
return {
|
||||
onInited: () => {
|
||||
|
||||
},
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
switch (k) {
|
||||
case 'width':
|
||||
case 'height':
|
||||
applySize();
|
||||
break;
|
||||
case 'bodyColor':
|
||||
applyBodyColor();
|
||||
break;
|
||||
case 'withBack':
|
||||
applyWithBack();
|
||||
break;
|
||||
}
|
||||
},
|
||||
interactions: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user