This commit is contained in:
syuilo
2026-02-22 13:25:23 +09:00
parent c5eaf0f7af
commit 0729e209c5
15 changed files with 115 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

View File

@@ -6,6 +6,7 @@
import { a4Case } from './objects/a4Case.js';
import { aircon } from './objects/aircon.js';
import { aquarium } from './objects/aquarium.js';
import { aromaReadDiffuser } from './objects/aromaReadDiffuser.js';
import { banknote } from './objects/banknote.js';
import { bed } from './objects/bed.js';
import { blind } from './objects/blind.js';
@@ -30,6 +31,7 @@ import { monstera } from './objects/monstera.js';
import { mug } from './objects/mug.js';
import { openedCardboardBox } from './objects/openedCardboardBox.js';
import { pachira } from './objects/pachira.js';
import { pc } from './objects/pc.js';
import { petBottle } from './objects/petBottle.js';
import { plant } from './objects/plant.js';
import { plant2 } from './objects/plant2.js';
@@ -51,6 +53,7 @@ export const OBJECT_DEFS = [
a4Case,
aircon,
aquarium,
aromaReadDiffuser,
banknote,
bed,
blind,
@@ -75,6 +78,7 @@ export const OBJECT_DEFS = [
mug,
openedCardboardBox,
pachira,
pc,
petBottle,
plant,
plant2,

View File

@@ -0,0 +1,57 @@
/*
* 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 aromaReadDiffuser = defineObject({
id: 'aromaReadDiffuser',
name: 'Aroma Read Diffuser',
options: {
schema: {
bottleColor: {
type: 'color',
label: 'Bottle Color',
},
oilColor: {
type: 'color',
label: 'Oil Color',
},
},
default: {
bottleColor: [1, 0.83, 0.48],
oilColor: [1, 0.4, 0],
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const bottleMesh = root.getChildMeshes().find(m => m.name.includes('__X_BOTTLE__')) as BABYLON.Mesh;
const bottleMaterial = bottleMesh.material as BABYLON.PBRMaterial;
const oilMesh = root.getChildMeshes().find(m => m.name.includes('__X_OIL__')) as BABYLON.Mesh;
const oilMaterial = oilMesh.material as BABYLON.PBRMaterial;
const applyBottleColor = () => {
const [r, g, b] = options.bottleColor;
bottleMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
const applyOilColor = () => {
const [r, g, b] = options.oilColor;
oilMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyBottleColor();
applyOilColor();
return {
onOptionsUpdated: ([k, v]) => {
applyBottleColor();
applyOilColor();
},
interactions: {},
};
},
});

View File

@@ -0,0 +1,42 @@
/*
* 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 pc = defineObject({
id: 'pc',
name: 'PC',
options: {
schema: {
color: {
type: 'color',
label: 'Color',
},
},
default: {
color: [0, 0, 0],
},
},
placement: 'top',
createInstance: ({ options, root }) => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyColor = () => {
const [r, g, b] = options.color;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyColor();
return {
onOptionsUpdated: ([k, v]) => {
applyColor();
},
interactions: {},
};
},
});

View File

@@ -15,24 +15,36 @@ export const petBottle = defineObject({
type: 'boolean',
label: 'With Cap',
},
empty: {
type: 'boolean',
label: 'Empty',
},
},
default: {
withCap: true,
empty: false,
},
},
placement: 'top',
createInstance: ({ root, options }) => {
const capMesh = root.getChildMeshes().find(m => m.name.includes('__X_CAP__')) as BABYLON.Mesh;
const liquidMesh = root.getChildMeshes().find(m => m.name.includes('__X_LIQUID__')) as BABYLON.Mesh;
const applyWithCap = () => {
capMesh.setEnabled(options.withCap);
};
const applyEmpty = () => {
liquidMesh.setEnabled(!options.empty);
};
applyWithCap();
applyEmpty();
return {
onOptionsUpdated: ([k, v]) => {
applyWithCap();
applyEmpty();
},
interactions: {},
};