1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 00:35:52 +02:00
This commit is contained in:
syuilo
2026-04-13 10:12:24 +09:00
parent 8f133d3fed
commit e989c4b1a5
4 changed files with 89 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import { ceilingFanLight } from './objects/ceilingFanLight.js';
import { chair } from './objects/chair.js';
import { coffeeCup } from './objects/coffeeCup.js';
import { colorBox } from './objects/colorBox.js';
import { cuboid } from './objects/cuboid.js';
import { cupNoodle } from './objects/cupNoodle.js';
import { custardPudding } from './objects/custardPudding.js';
import { debugHipoly } from './objects/debugHipoly.js';
@@ -102,6 +103,7 @@ export const OBJECT_DEFS = [
chair,
coffeeCup,
colorBox,
cuboid,
cupNoodle,
custardPudding,
desk,

View File

@@ -0,0 +1,87 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js';
export const cuboid = defineObject({
id: 'cuboid',
name: 'cuboid',
options: {
schema: {
x: {
type: 'range',
label: 'X',
min: 0,
max: 1,
step: 0.01,
},
y: {
type: 'range',
label: 'Y',
min: 0,
max: 1,
step: 0.01,
},
z: {
type: 'range',
label: 'Z',
min: 0,
max: 1,
step: 0.01,
},
color: {
type: 'color',
label: 'Color',
},
},
default: {
x: 0.01,
y: 0.01,
z: 0.01,
color: [1, 1, 1],
},
},
placement: 'top',
createInstance: async ({ scene, options, model }) => {
const mesh = model.findMesh('__X_BODY__');
const mat = model.findMaterial('__X_BODY__');
const applySize = () => {
mesh.morphTargetManager!.getTargetByName('X')!.influence = options.x;
mesh.morphTargetManager!.getTargetByName('Y')!.influence = options.y;
mesh.morphTargetManager!.getTargetByName('Z')!.influence = options.z;
model.updated();
};
applySize();
const applyColor = () => {
const [r, g, b] = options.color;
mat.albedoColor = new BABYLON.Color3(r, g, b);
};
applyColor();
return {
onInited: () => {
},
onOptionsUpdated: ([k, v]) => {
switch (k) {
case 'color':
applyColor();
break;
case 'x':
case 'y':
case 'z':
applySize();
break;
}
},
interactions: {},
};
},
});