mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 19:15:32 +02:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
@@ -212,7 +212,13 @@ export class RoomEngine {
|
|||||||
constructor(roomState: RoomState, options: {
|
constructor(roomState: RoomState, options: {
|
||||||
canvas: HTMLCanvasElement;
|
canvas: HTMLCanvasElement;
|
||||||
}) {
|
}) {
|
||||||
this.roomState = roomState;
|
this.roomState = {
|
||||||
|
...roomState,
|
||||||
|
installedObjects: roomState.installedObjects.map(o => ({
|
||||||
|
...o,
|
||||||
|
options: { ...getObjectDef(o.type).options.default, ...o.options },
|
||||||
|
})),
|
||||||
|
};
|
||||||
this.canvas = options.canvas;
|
this.canvas = options.canvas;
|
||||||
|
|
||||||
registerBuiltInLoaders();
|
registerBuiltInLoaders();
|
||||||
@@ -904,7 +910,7 @@ export class RoomEngine {
|
|||||||
const objectInstance = def.createInstance({
|
const objectInstance = def.createInstance({
|
||||||
room: this,
|
room: this,
|
||||||
root,
|
root,
|
||||||
options: args.options, // todo: merge with default options
|
options: args.options,
|
||||||
loaderResult: loaderResult,
|
loaderResult: loaderResult,
|
||||||
meshUpdated: () => {
|
meshUpdated: () => {
|
||||||
meshUpdated(this.objectMeshs.get(args.id)!.getChildMeshes() as BABYLON.Mesh[]);
|
meshUpdated(this.objectMeshs.get(args.id)!.getChildMeshes() as BABYLON.Mesh[]);
|
||||||
|
|||||||
@@ -3,18 +3,39 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as BABYLON from '@babylonjs/core';
|
||||||
import { defineObject } from '../engine.js';
|
import { defineObject } from '../engine.js';
|
||||||
|
|
||||||
export const colorBox = defineObject({
|
export const colorBox = defineObject({
|
||||||
id: 'colorBox',
|
id: 'colorBox',
|
||||||
name: 'Color Box',
|
name: 'Color Box',
|
||||||
options: {
|
options: {
|
||||||
schema: {},
|
schema: {
|
||||||
default: {},
|
color: {
|
||||||
|
type: 'color',
|
||||||
|
label: 'Color',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
color: [1, 1, 1],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
placement: 'floor',
|
placement: 'floor',
|
||||||
createInstance: () => {
|
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 {
|
return {
|
||||||
|
onOptionsUpdated: ([k, v]) => {
|
||||||
|
applyColor();
|
||||||
|
},
|
||||||
interactions: {},
|
interactions: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user