1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 15:15:45 +02:00

Update engine.ts

This commit is contained in:
syuilo
2026-04-12 19:58:40 +09:00
parent 21e6ac6678
commit 272c267ea0

View File

@@ -35,6 +35,8 @@
// TODO: 近くのオブジェクトの原点に軸を揃えるオプション
const BAKE_TRANSFORM = false; // 実験的
const SNAPSHOT_RENDERING = false; // 実験的
const SNAPSHOT_RENDERING_NON_SUPPORTED_OBJECTS = ['aromaReedDiffuser', 'tv', 'petBottle', 'aquarium', 'lavaLamp', 'beamLamp'];
import * as BABYLON from '@babylonjs/core';
import { AxesViewer } from '@babylonjs/core/Debug/axesViewer';
@@ -576,11 +578,13 @@ export class RoomEngine {
this.shadowGeneratorForSunLight.usePoissonSampling = true;
this.shadowGeneratorForSunLight.getShadowMap().refreshRate = 60;
this.lightContainer = new BABYLON.ClusteredLightContainer('clustered', [], this.scene);
if (!SNAPSHOT_RENDERING) { // Snapshot renderingでClustered Lightingが有効だとなんかエラーが出る
this.lightContainer = new BABYLON.ClusteredLightContainer('clustered', [], this.scene);
}
this.turnOnRoomLight();
if (USE_GLOW) {
if (USE_GLOW && !SNAPSHOT_RENDERING) {
const gl = new BABYLON.GlowLayer('glow', this.scene, {
//mainTextureFixedSize: 512,
blurKernelSize: 64,
@@ -749,7 +753,7 @@ export class RoomEngine {
public async init() {
await this.loadRoomModel();
await this.loadEnvModel();
await Promise.all(this.roomState.installedObjects.map(o => this.loadObject({
await Promise.all(this.roomState.installedObjects.filter(o => !SNAPSHOT_RENDERING || !SNAPSHOT_RENDERING_NON_SUPPORTED_OBJECTS.includes(o.type)).map(o => this.loadObject({
id: o.id,
type: o.type,
position: new BABYLON.Vector3(...o.position),
@@ -762,6 +766,13 @@ export class RoomEngine {
this.engine.runRenderLoop(() => {
this.scene.render();
});
if (SNAPSHOT_RENDERING) {
window.setTimeout(() => {
this.engine.snapshotRendering = true;
this.engine.snapshotRenderingMode = BABYLON.Constants.SNAPSHOTRENDERING_FAST;
}, 3000);
}
}
public selectObject(objectId: string | null) {
@@ -1218,6 +1229,10 @@ export class RoomEngine {
this.shadowGeneratorForSunLight.addShadowCaster(mesh);
}
if (SNAPSHOT_RENDERING) {
mesh.alwaysSelectAsActiveMesh = true;
}
//if (mesh.material) (mesh.material as BABYLON.PBRMaterial).ambientColor = new BABYLON.Color3(0.2, 0.2, 0.2);
if (mesh.material) {
if (mesh.material instanceof BABYLON.MultiMaterial) {