mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 13:25:48 +02:00
speakerStand
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -70,6 +70,7 @@ import { router } from './objects/router.js';
|
||||
import { siphon } from './objects/siphon.js';
|
||||
import { snakeplant } from './objects/snakeplant.js';
|
||||
import { speaker } from './objects/speaker.js';
|
||||
import { speakerStand } from './objects/speakerStand.js';
|
||||
import { sprayer } from './objects/sprayer.js';
|
||||
import { steelRack } from './objects/steelRack.js';
|
||||
import { tabletopCalendar } from './objects/tabletopCalendar.js';
|
||||
@@ -161,6 +162,7 @@ export const OBJECT_DEFS = [
|
||||
siphon,
|
||||
snakeplant,
|
||||
speaker,
|
||||
speakerStand,
|
||||
sprayer,
|
||||
steelRack,
|
||||
tabletopCalendar,
|
||||
|
||||
65
packages/frontend/src/world/room/objects/speakerStand.ts
Normal file
65
packages/frontend/src/world/room/objects/speakerStand.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 speakerStand = defineObject({
|
||||
id: 'speakerStand',
|
||||
name: 'speakerStand',
|
||||
options: {
|
||||
schema: {
|
||||
bodyColor: {
|
||||
type: 'color',
|
||||
label: 'Body color',
|
||||
},
|
||||
height: {
|
||||
type: 'range',
|
||||
label: 'height',
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
},
|
||||
},
|
||||
default: {
|
||||
bodyColor: [0.2, 0.2, 0.2],
|
||||
height: 0.1,
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
hasCollisions: false,
|
||||
hasTexture: false,
|
||||
createInstance: ({ options, model }) => {
|
||||
const bodyMaterial = model.findMaterial('__X_BODY__');
|
||||
|
||||
const applyBodyColor = () => {
|
||||
const [r, g, b] = options.bodyColor;
|
||||
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
|
||||
};
|
||||
|
||||
applyBodyColor();
|
||||
|
||||
const applySize = () => {
|
||||
for (const mesh of model.root.getChildMeshes()) {
|
||||
if (mesh.morphTargetManager != null && mesh.morphTargetManager.getTargetByName('Height') != null) {
|
||||
mesh.morphTargetManager.getTargetByName('Height').influence = options.height;
|
||||
}
|
||||
}
|
||||
model.updated();
|
||||
};
|
||||
|
||||
applySize();
|
||||
|
||||
return {
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
switch (k) {
|
||||
case 'bodyColor': applyBodyColor(); break;
|
||||
case 'height': applySize(); break;
|
||||
}
|
||||
},
|
||||
interactions: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user