1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-23 20:24:21 +02:00
Files
misskey/packages/frontend/src/world/room/objects/petBottle.ts
2026-04-20 21:39:23 +09:00

55 lines
1000 B
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 petBottle = defineObject({
id: 'petBottle',
name: 'PET Bottle',
options: {
schema: {
withCap: {
type: 'boolean',
label: 'With Cap',
},
empty: {
type: 'boolean',
label: 'Empty',
},
},
default: {
withCap: true,
empty: false,
},
},
placement: 'top',
hasCollisions: false,
hasTexture: true,
createInstance: ({ model, options }) => {
const capMesh = model.findMesh('__X_CAP__');
const liquidMesh = model.findMesh('__X_LIQUID__');
const applyWithCap = () => {
capMesh.isVisible = options.withCap;
};
const applyEmpty = () => {
liquidMesh.isVisible = !options.empty;
};
applyWithCap();
applyEmpty();
return {
onOptionsUpdated: ([k, v]) => {
applyWithCap();
applyEmpty();
},
interactions: {},
};
},
});