1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-06-04 13:34:10 +02:00

Update engine.ts

This commit is contained in:
syuilo
2026-04-26 10:05:00 +09:00
parent 1cd6d01fdd
commit 7e41d17c6a

View File

@@ -125,7 +125,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
private canvas: HTMLCanvasElement; private canvas: HTMLCanvasElement;
private engine: BABYLON.WebGPUEngine; private engine: BABYLON.WebGPUEngine;
public scene: BABYLON.Scene; public scene: BABYLON.Scene;
private shadowGeneratorForRoomLight: BABYLON.ShadowGenerator; private shadowGeneratorForRoomLight: BABYLON.ShadowGenerator | null = null;
private shadowGeneratorForSunLight: BABYLON.ShadowGenerator | null = null; private shadowGeneratorForSunLight: BABYLON.ShadowGenerator | null = null;
public camera: BABYLON.UniversalCamera; public camera: BABYLON.UniversalCamera;
public objectEntities: Map<string, { public objectEntities: Map<string, {
@@ -325,18 +325,18 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
this.roomLight.shadowMaxZ = cm(300); this.roomLight.shadowMaxZ = cm(300);
this.roomLight.radius = cm(30); this.roomLight.radius = cm(30);
this.shadowGeneratorForRoomLight = new BABYLON.ShadowGenerator(options.graphicsQuality <= GRAPHICS_QUALITY_LOW ? 1024 : 2048, this.roomLight); if (options.graphicsQuality >= GRAPHICS_QUALITY_MEDIUM) {
this.shadowGeneratorForRoomLight = new BABYLON.ShadowGenerator(options.graphicsQuality <= GRAPHICS_QUALITY_MEDIUM ? 1024 : 2048, this.roomLight);
this.shadowGeneratorForRoomLight.forceBackFacesOnly = true; this.shadowGeneratorForRoomLight.forceBackFacesOnly = true;
this.shadowGeneratorForRoomLight.bias = 0.00001; this.shadowGeneratorForRoomLight.bias = 0.00001;
this.shadowGeneratorForRoomLight.normalBias = 0.005; this.shadowGeneratorForRoomLight.normalBias = 0.005;
this.shadowGeneratorForRoomLight.usePercentageCloserFiltering = true; this.shadowGeneratorForRoomLight.usePercentageCloserFiltering = true;
this.shadowGeneratorForRoomLight.filteringQuality = BABYLON.ShadowGenerator.QUALITY_HIGH; this.shadowGeneratorForRoomLight.filteringQuality = BABYLON.ShadowGenerator.QUALITY_HIGH;
if (options.graphicsQuality <= GRAPHICS_QUALITY_LOW) { if (options.graphicsQuality <= GRAPHICS_QUALITY_MEDIUM) {
this.shadowGeneratorForRoomLight.getShadowMap().refreshRate = 120;
} else if (options.graphicsQuality <= GRAPHICS_QUALITY_MEDIUM) {
this.shadowGeneratorForRoomLight.getShadowMap().refreshRate = 60; this.shadowGeneratorForRoomLight.getShadowMap().refreshRate = 60;
} }
//this.shadowGenerator1.useContactHardeningShadow = true; //this.shadowGeneratorForRoomLight.useContactHardeningShadow = true;
}
if (options.graphicsQuality >= GRAPHICS_QUALITY_MEDIUM) { if (options.graphicsQuality >= GRAPHICS_QUALITY_MEDIUM) {
const sunLight = new BABYLON.DirectionalLight('sunLight', new BABYLON.Vector3(0.2, -1, -1), this.scene); const sunLight = new BABYLON.DirectionalLight('sunLight', new BABYLON.Vector3(0.2, -1, -1), this.scene);
@@ -346,7 +346,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
sunLight.shadowMinZ = cm(1000); sunLight.shadowMinZ = cm(1000);
sunLight.shadowMaxZ = cm(2000); sunLight.shadowMaxZ = cm(2000);
this.shadowGeneratorForSunLight = new BABYLON.ShadowGenerator(2048, sunLight); this.shadowGeneratorForSunLight = new BABYLON.ShadowGenerator(options.graphicsQuality <= GRAPHICS_QUALITY_MEDIUM ? 1024 : 2048, sunLight);
this.shadowGeneratorForSunLight.forceBackFacesOnly = true; this.shadowGeneratorForSunLight.forceBackFacesOnly = true;
this.shadowGeneratorForSunLight.bias = 0.00001; this.shadowGeneratorForSunLight.bias = 0.00001;
this.shadowGeneratorForSunLight.usePercentageCloserFiltering = true; this.shadowGeneratorForSunLight.usePercentageCloserFiltering = true;
@@ -842,7 +842,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
m.isPickable = false; m.isPickable = false;
m.checkCollisions = false; m.checkCollisions = false;
m.receiveShadows = true; m.receiveShadows = true;
this.shadowGeneratorForRoomLight.addShadowCaster(m); this.shadowGeneratorForRoomLight?.addShadowCaster(m);
this.shadowGeneratorForSunLight?.addShadowCaster(m); this.shadowGeneratorForSunLight?.addShadowCaster(m);
//if (m.material) (m.material as BABYLON.PBRMaterial).ambientColor = new BABYLON.Color3(1, 1, 1); //if (m.material) (m.material as BABYLON.PBRMaterial).ambientColor = new BABYLON.Color3(1, 1, 1);
if (m.material) { if (m.material) {
@@ -1094,7 +1094,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
} else { } else {
if (def.receiveShadows !== false) mesh.receiveShadows = true; if (def.receiveShadows !== false) mesh.receiveShadows = true;
if (def.castShadows !== false) { if (def.castShadows !== false) {
this.shadowGeneratorForRoomLight.addShadowCaster(mesh); this.shadowGeneratorForRoomLight?.addShadowCaster(mesh);
this.shadowGeneratorForSunLight?.addShadowCaster(mesh); this.shadowGeneratorForSunLight?.addShadowCaster(mesh);
} }