mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-18 21:15:31 +02:00
65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
/*
|
|
* 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 lowPartitionBar = defineObject({
|
|
id: 'lowPartitionBar',
|
|
name: 'lowPartitionBar',
|
|
options: {
|
|
schema: {
|
|
bodyColor: {
|
|
type: 'color',
|
|
label: 'Body color',
|
|
},
|
|
width: {
|
|
type: 'range',
|
|
label: 'Width',
|
|
min: 0,
|
|
max: 1,
|
|
step: 0.01,
|
|
},
|
|
},
|
|
default: {
|
|
bodyColor: [0.8, 0.8, 0.8],
|
|
width: 0.5,
|
|
},
|
|
},
|
|
placement: 'top',
|
|
//hasCollisions: true,
|
|
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('W') != null) {
|
|
mesh.morphTargetManager.getTargetByName('W').influence = options.width;
|
|
}
|
|
}
|
|
model.updated();
|
|
};
|
|
|
|
applySize();
|
|
|
|
return {
|
|
onOptionsUpdated: ([k, v]) => {
|
|
switch (k) {
|
|
case 'bodyColor': applyBodyColor(); break;
|
|
case 'width': applySize(); break;
|
|
}
|
|
},
|
|
interactions: {},
|
|
};
|
|
},
|
|
});
|