mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-25 09:44:11 +02:00
wip
This commit is contained in:
@@ -854,7 +854,7 @@ export class RoomEngine {
|
||||
const objectInstance = def.createInstance({
|
||||
room: this,
|
||||
root,
|
||||
options: args.options,
|
||||
options: args.options, // todo: merge with default options
|
||||
loaderResult: loaderResult,
|
||||
meshUpdated: () => {
|
||||
meshUpdated(this.objectMeshs.get(args.id)!.getChildMeshes() as BABYLON.Mesh[]);
|
||||
@@ -998,7 +998,7 @@ export class RoomEngine {
|
||||
this.zGridPreviewPlane.isVisible = false;
|
||||
}
|
||||
|
||||
private interact(oid: string) {
|
||||
public interact(oid: string) {
|
||||
const o = this.roomState.installedObjects.find(o => o.id === oid)!;
|
||||
const mesh = this.objectMeshs.get(o.id)!;
|
||||
const objDef = getObjectDef(o.type);
|
||||
@@ -1150,6 +1150,11 @@ export class RoomEngine {
|
||||
if (this.grabbingCtx.distance < 5/*cm*/) this.grabbingCtx.distance = 5/*cm*/;
|
||||
}
|
||||
|
||||
public changeGrabbingRotationY(delta: number) {
|
||||
if (this.grabbingCtx == null) return;
|
||||
this.grabbingCtx.rotation += delta;
|
||||
}
|
||||
|
||||
public resize() {
|
||||
this.engine.resize();
|
||||
}
|
||||
|
||||
@@ -5,16 +5,30 @@
|
||||
|
||||
import * as BABYLON from '@babylonjs/core';
|
||||
import { defineObject } from '../engine.js';
|
||||
import { get7segMeshesOfCurrentTime, yuge } from '../utility.js';
|
||||
import { get7segMeshesOfCurrentTime } from '../utility.js';
|
||||
|
||||
export const tabletopDigitalClock = defineObject({
|
||||
id: 'tabletopDigitalClock',
|
||||
defaultOptions: {},
|
||||
defaultOptions: {
|
||||
bodyStyle: {
|
||||
type: 'color',
|
||||
value: [0.45, 0.8, 0],
|
||||
} as { type: 'color'; value: [number, number, number] } | { type: 'wood'; } | null,
|
||||
},
|
||||
placement: 'top',
|
||||
createInstance: ({ room, root }) => {
|
||||
createInstance: ({ room, options, root }) => {
|
||||
return {
|
||||
onInited: () => {
|
||||
const meshes = {
|
||||
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
|
||||
|
||||
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
|
||||
|
||||
if (options.bodyStyle?.type === 'color') {
|
||||
const [r, g, b] = options.bodyStyle.value;
|
||||
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
|
||||
}
|
||||
|
||||
const segmentMeshes = {
|
||||
'1a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1A__')),
|
||||
'1b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1B__')),
|
||||
'1c': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1C__')),
|
||||
@@ -48,9 +62,9 @@ export const tabletopDigitalClock = defineObject({
|
||||
const colonMeshes = root.getChildMeshes().filter(m => m.name.includes('__TIME_7SEG_COLON__'));
|
||||
|
||||
room.intervalIds.push(window.setInterval(() => {
|
||||
const onMeshes = get7segMeshesOfCurrentTime(meshes);
|
||||
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
|
||||
|
||||
for (const mesh of Object.values(meshes)) {
|
||||
for (const mesh of Object.values(segmentMeshes)) {
|
||||
mesh.isVisible = onMeshes.includes(mesh);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user