mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 15:40:51 +01:00
Fixes
This commit is contained in:
parent
0df421e20c
commit
382cb665d8
11
src/App.tsx
11
src/App.tsx
@ -1,4 +1,4 @@
|
||||
import { GetAssetManager, GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTicker, HabboWebTools, LegacyExternalInterface, LoadGameUrlEvent, NitroLogger, NitroVersion, PrepareRenderer } from '@nitrots/nitro-renderer';
|
||||
import { GetAssetManager, GetAvatarRenderManager, GetCommunication, GetConfiguration, GetLocalizationManager, GetRoomCameraWidgetManager, GetRoomEngine, GetRoomSessionManager, GetSessionDataManager, GetSoundManager, GetStage, GetTexturePool, 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';
|
||||
@ -38,8 +38,6 @@ export const App: FC<{}> = props =>
|
||||
resolution: window.devicePixelRatio
|
||||
});
|
||||
|
||||
GetTicker().add(ticker => renderer.render(GetStage()));
|
||||
|
||||
await GetConfiguration().init();
|
||||
|
||||
GetTicker().maxFPS = GetConfiguration().getValue<number>('system.fps.max', 24);
|
||||
@ -58,7 +56,8 @@ export const App: FC<{}> = props =>
|
||||
GetAvatarRenderManager().init(),
|
||||
GetSoundManager().init(),
|
||||
GetSessionDataManager().init(),
|
||||
GetRoomSessionManager().init()
|
||||
GetRoomSessionManager().init(),
|
||||
GetRoomCameraWidgetManager().init()
|
||||
]
|
||||
);
|
||||
|
||||
@ -73,6 +72,10 @@ export const App: FC<{}> = props =>
|
||||
|
||||
setInterval(() => HabboWebTools.sendHeartBeat(), 10000);
|
||||
|
||||
GetTicker().add(ticker => GetRoomEngine().update(ticker));
|
||||
GetTicker().add(ticker => renderer.render(GetStage()));
|
||||
GetTicker().add(ticker => GetTexturePool().run());
|
||||
|
||||
setIsReady(true);
|
||||
|
||||
// handle socket close
|
||||
|
@ -47,7 +47,7 @@ export class BodyModel extends CategoryBaseModel
|
||||
const figureString = AvatarEditorUtilities.CURRENT_FIGURE.getFigureStringWithFace(part.id);
|
||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(figureString, AvatarScaleType.LARGE, null, { resetFigure, dispose: null, disposed: false });
|
||||
|
||||
const sprite = avatarImage.getImageAsSprite(AvatarSetType.HEAD);
|
||||
const sprite = avatarImage.processAsContainer(AvatarSetType.HEAD);
|
||||
|
||||
if(sprite)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ export class ChatBubbleUtilities
|
||||
|
||||
figure = avatarImage.getFigure().getFigureString();
|
||||
|
||||
const imageUrl = await avatarImage.getCroppedImageUrl(AvatarSetType.HEAD);
|
||||
const imageUrl = avatarImage.processAsImageUrl(AvatarSetType.HEAD);
|
||||
const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST);
|
||||
|
||||
if(isPlaceholder) this.placeHolderImageUrl = imageUrl;
|
||||
|
@ -2,6 +2,8 @@ import { AvatarScaleType, AvatarSetType, GetAvatarRenderManager } from '@nitrots
|
||||
import { CSSProperties, FC, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Base, BaseProps } from '../Base';
|
||||
|
||||
const AVATAR_IMAGE_CACHE: Map<string, string> = new Map();
|
||||
|
||||
export interface LayoutAvatarImageViewProps extends BaseProps<HTMLDivElement>
|
||||
{
|
||||
figure: string;
|
||||
@ -49,31 +51,40 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
||||
{
|
||||
if(!isReady) return;
|
||||
|
||||
const resetFigure = (_figure: string) =>
|
||||
const figureKey = [ figure, gender, direction, headOnly ].join('-');
|
||||
|
||||
if(AVATAR_IMAGE_CACHE.has(figureKey))
|
||||
{
|
||||
if(isDisposed.current) return;
|
||||
|
||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(_figure, AvatarScaleType.LARGE, gender, { resetFigure: (figure: string) => resetFigure(figure), dispose: null, disposed: false });
|
||||
|
||||
let setType = AvatarSetType.FULL;
|
||||
|
||||
if(headOnly) setType = AvatarSetType.HEAD;
|
||||
|
||||
avatarImage.setDirection(setType, direction);
|
||||
|
||||
const loadImage = async () =>
|
||||
setAvatarUrl(AVATAR_IMAGE_CACHE.get(figureKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
const resetFigure = (_figure: string) =>
|
||||
{
|
||||
const imageUrl = await avatarImage.getCroppedImageUrl(setType);
|
||||
if(isDisposed.current) return;
|
||||
|
||||
if(imageUrl && !isDisposed.current) setAvatarUrl(imageUrl);
|
||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(_figure, AvatarScaleType.LARGE, gender, { resetFigure: (figure: string) => resetFigure(figure), dispose: null, disposed: false });
|
||||
|
||||
avatarImage.dispose();
|
||||
let setType = AvatarSetType.FULL;
|
||||
|
||||
if(headOnly) setType = AvatarSetType.HEAD;
|
||||
|
||||
avatarImage.setDirection(setType, direction);
|
||||
|
||||
const imageUrl = avatarImage.processAsImageUrl(setType);
|
||||
|
||||
if(imageUrl && !isDisposed.current)
|
||||
{
|
||||
if(!avatarImage.isPlaceholder()) AVATAR_IMAGE_CACHE.set(figureKey, imageUrl);
|
||||
|
||||
setAvatarUrl(imageUrl);
|
||||
}
|
||||
|
||||
avatarImage.dispose(true);
|
||||
}
|
||||
|
||||
loadImage();
|
||||
resetFigure(figure);
|
||||
}
|
||||
|
||||
resetFigure(figure);
|
||||
}, [ figure, gender, direction, headOnly, isReady ]);
|
||||
|
||||
useEffect(() =>
|
||||
|
@ -256,14 +256,13 @@ const useRoomState = () =>
|
||||
const width = Math.floor(window.innerWidth);
|
||||
const height = Math.floor(window.innerHeight);
|
||||
|
||||
renderer.resolution = window.devicePixelRatio;
|
||||
renderer.resize(width, height);
|
||||
|
||||
background.width = width;
|
||||
background.height = height;
|
||||
|
||||
InitializeRoomInstanceRenderingCanvas(width, height, 1);
|
||||
|
||||
renderer.render(GetStage());
|
||||
}
|
||||
|
||||
window.addEventListener('resize', resize);
|
||||
|
Loading…
Reference in New Issue
Block a user