mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-23 04:04:08 +02:00
cuboid
This commit is contained in:
BIN
packages/frontend/assets/room/objects/cuboid/cuboid.blend
Normal file
BIN
packages/frontend/assets/room/objects/cuboid/cuboid.blend
Normal file
Binary file not shown.
BIN
packages/frontend/assets/room/objects/cuboid/cuboid.glb
Normal file
BIN
packages/frontend/assets/room/objects/cuboid/cuboid.glb
Normal file
Binary file not shown.
@@ -20,6 +20,7 @@ import { ceilingFanLight } from './objects/ceilingFanLight.js';
|
|||||||
import { chair } from './objects/chair.js';
|
import { chair } from './objects/chair.js';
|
||||||
import { coffeeCup } from './objects/coffeeCup.js';
|
import { coffeeCup } from './objects/coffeeCup.js';
|
||||||
import { colorBox } from './objects/colorBox.js';
|
import { colorBox } from './objects/colorBox.js';
|
||||||
|
import { cuboid } from './objects/cuboid.js';
|
||||||
import { cupNoodle } from './objects/cupNoodle.js';
|
import { cupNoodle } from './objects/cupNoodle.js';
|
||||||
import { custardPudding } from './objects/custardPudding.js';
|
import { custardPudding } from './objects/custardPudding.js';
|
||||||
import { debugHipoly } from './objects/debugHipoly.js';
|
import { debugHipoly } from './objects/debugHipoly.js';
|
||||||
@@ -102,6 +103,7 @@ export const OBJECT_DEFS = [
|
|||||||
chair,
|
chair,
|
||||||
coffeeCup,
|
coffeeCup,
|
||||||
colorBox,
|
colorBox,
|
||||||
|
cuboid,
|
||||||
cupNoodle,
|
cupNoodle,
|
||||||
custardPudding,
|
custardPudding,
|
||||||
desk,
|
desk,
|
||||||
|
|||||||
87
packages/frontend/src/utility/room/objects/cuboid.ts
Normal file
87
packages/frontend/src/utility/room/objects/cuboid.ts
Normal 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: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user