Renderer updates

This commit is contained in:
billsonnn 2024-03-23 20:58:34 -04:00
parent 75d8a4b385
commit cb80bf3a17
4 changed files with 19 additions and 19 deletions

View File

@ -1,4 +1,4 @@
import { GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetPixi, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion } from '@nitrots/nitro-renderer';
import { GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion, PrepareRenderer } from '@nitrots/nitro-renderer';
import { FC, useEffect, useState } from 'react';
import { GetUIVersion } from './api';
import { Base } from './common';
@ -23,15 +23,19 @@ export const App: FC<{}> = props =>
//@ts-ignore
if(!NitroConfig) throw new Error('NitroConfig is not defined!');
await GetPixi().init({
autoStart: false,
autoDensity: false,
const renderer = await PrepareRenderer({
width,
height,
sharedTicker: true,
backgroundAlpha: 0
autoDensity: true,
backgroundAlpha: 0,
//@ts-ignore
preference: 'webgl2'
});
const stage = GetStage();
GetTicker().add(ticker => renderer.render(stage));
await GetConfiguration().init();
GetTicker().maxFPS = GetConfiguration().getValue<number>('system.fps.max', 24);

View File

@ -1,4 +1,4 @@
import { GetPixi } from '@nitrots/nitro-renderer';
import { GetRenderer } from '@nitrots/nitro-renderer';
import { FC, useEffect, useRef } from 'react';
import { DispatchMouseEvent, DispatchTouchEvent } from '../../api';
import { Base } from '../../common';
@ -13,7 +13,7 @@ export const RoomView: FC<{}> = props =>
useEffect(() =>
{
const canvas = GetPixi().canvas;
const canvas = GetRenderer().canvas;
if(!canvas) return;

View File

@ -1,4 +1,4 @@
import { GetPixi, GetTicker, NitroRectangle, NitroTicker, RoomObjectType } from '@nitrots/nitro-renderer';
import { GetStage, GetTicker, NitroRectangle, NitroTicker, RoomObjectType } from '@nitrots/nitro-renderer';
import { CSSProperties, FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { FixedSizeStack, GetRoomObjectBounds, GetRoomObjectScreenLocation, GetRoomSession } from '../../../../api';
import { Base, BaseProps } from '../../../../common';
@ -80,8 +80,8 @@ export const ContextMenuView: FC<ContextMenuViewProps> = props =>
let x = ~~(location.x - (elementRef.current.offsetWidth / 2));
let y = ~~(deltaY + offset);
const maxLeft = ((GetPixi().stage.width - elementRef.current.offsetWidth) - SPACE_AROUND_EDGES);
const maxTop = ((GetPixi().stage.height - elementRef.current.offsetHeight) - SPACE_AROUND_EDGES);
const maxLeft = ((GetStage().width - elementRef.current.offsetWidth) - SPACE_AROUND_EDGES);
const maxTop = ((GetStage().height - elementRef.current.offsetHeight) - SPACE_AROUND_EDGES);
if(x < SPACE_AROUND_EDGES) x = SPACE_AROUND_EDGES;
else if(x > maxLeft) x = maxLeft;

View File

@ -1,4 +1,4 @@
import { ColorConverter, GetPixi, GetRoomEngine, IRoomSession, NitroAdjustmentFilter, NitroSprite, NitroTexture, RoomBackgroundColorEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomGeometry, RoomId, RoomObjectCategory, RoomObjectHSLColorEnabledEvent, RoomObjectOperationType, RoomSessionEvent, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer';
import { ColorConverter, GetRenderer, GetRoomEngine, GetStage, IRoomSession, NitroAdjustmentFilter, NitroSprite, NitroTexture, RoomBackgroundColorEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomGeometry, RoomId, RoomObjectCategory, RoomObjectHSLColorEnabledEvent, RoomObjectOperationType, RoomSessionEvent, RoomVariableEnum, Vector3d } from '@nitrots/nitro-renderer';
import { useEffect, useState } from 'react';
import { useBetween } from 'use-between';
import { CanManipulateFurniture, DispatchUiEvent, GetRoomSession, InitializeRoomInstanceRenderingCanvas, IsFurnitureSelectionDisabled, ProcessRoomObjectOperation, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomObjectEvent, SetActiveRoomId, StartRoomSession } from '../../api';
@ -202,7 +202,7 @@ const useRoomState = () =>
const canvasId = 1;
const width = Math.floor(window.innerWidth);
const height = Math.floor(window.innerHeight);
const renderer = GetPixi().renderer;
const renderer = GetRenderer();
if(renderer) renderer.resize(width, height);
@ -247,11 +247,7 @@ const useRoomState = () =>
geometry.location = new Vector3d(x, y, z);
}
const stage = GetPixi().stage;
if(!stage) return;
stage.addChild(displayObject);
GetStage().addChild(displayObject);
SetActiveRoomId(roomSession.roomId);
@ -267,7 +263,7 @@ const useRoomState = () =>
InitializeRoomInstanceRenderingCanvas(width, height, 1);
GetPixi().render();
renderer.render(GetStage());
}
window.addEventListener('resize', resize);