From e3198ee941c78e60cfa6429c054b81e2f5fc2be3 Mon Sep 17 00:00:00 2001 From: Agnieszka Besz Date: Thu, 22 Feb 2024 12:37:59 +0000 Subject: [PATCH 1/4] hotfix: support multiple scenes in world (#6099) * support multiple scenes in world * dont wait to attach transport to set the worker on the local storage # Conflicts: # browser-interface/packages/shared/world/SceneWorker.ts --- .../scene-loader/world-loader-impl/index.ts | 7 ++-- .../packages/shared/world/SceneWorker.ts | 37 ++++++++++++++++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/browser-interface/packages/shared/scene-loader/world-loader-impl/index.ts b/browser-interface/packages/shared/scene-loader/world-loader-impl/index.ts index de0487e132..a9f2b33419 100644 --- a/browser-interface/packages/shared/scene-loader/world-loader-impl/index.ts +++ b/browser-interface/packages/shared/scene-loader/world-loader-impl/index.ts @@ -22,9 +22,10 @@ function getParcels(position: Vector2, loadingRadius: number): string[] { export async function createWorldLoader(options: { urns: string[] }): Promise { const mappingScene = new Map() const scenes = await Promise.all(options.urns.map((urn) => getPortableExperienceFromUrn(urn))) - - for (const parcel of scenes[0].entity.metadata.scene.parcels) { - mappingScene.set(parcel, scenes[0]) + for (const scene of scenes) { + for (const parcel of scene.entity.metadata.scene.parcels) { + mappingScene.set(parcel, scene) + } } const emptyParcelController = new EmptyParcelController({ rootUrl: getResourcesURL('.') }) diff --git a/browser-interface/packages/shared/world/SceneWorker.ts b/browser-interface/packages/shared/world/SceneWorker.ts index 595060873d..e470d448a2 100644 --- a/browser-interface/packages/shared/world/SceneWorker.ts +++ b/browser-interface/packages/shared/world/SceneWorker.ts @@ -12,6 +12,7 @@ import { getAssetBundlesBaseUrl, PIPE_SCENE_CONSOLE, playerHeight, + PREVIEW, WSS_ENABLED } from 'config' import { gridToWorld } from 'lib/decentraland/parcels/gridToWorld' @@ -42,6 +43,8 @@ import { joinBuffers } from 'lib/javascript/uint8arrays' import { nativeMsgBridge } from 'unity-interface/nativeMessagesBridge' import { _INTERNAL_WEB_TRANSPORT_ALLOC_SIZE } from 'renderer-protocol/transports/webTransport' import { createInternalEngine } from './runtime-7/engine' +import { initSourcemap } from './runtime-7/sourcemap' +import { forceStopScene } from './parcelSceneManager' export enum SceneWorkerReadyState { LOADING = 1 << 0, @@ -114,7 +117,6 @@ export class SceneWorker { private rpcServer!: RpcServer private sceneStarted: boolean = false - private position: Vector3 = new Vector3() private readonly lastSentPosition = new Vector3(0, 0, 0) private readonly lastSentRotation = new Quaternion(0, 0, 0, 1) @@ -130,7 +132,7 @@ export class SceneWorker { const sceneNumber = globalSceneNumberCounter const scenePort = await rpcClient.createPort(`scene-${sceneNumber}`) const worker = new SceneWorker(loadableScene, sceneNumber, scenePort) - await worker.attachTransport() + worker.attachTransport().catch(() => forceStopScene(loadableScene.id)) return worker } @@ -194,7 +196,8 @@ export class SceneWorker { readFile: this.readFile.bind(this), initialEntitiesTick0: Uint8Array.of(), hasMainCrdt: false, - internalEngine: undefined + internalEngine: undefined, + sourcemap: undefined } // if the scene metadata has a base parcel, then we set it as the position @@ -230,7 +233,27 @@ export class SceneWorker { } } - async readFile(fileName: string) { + async loadSourcemap() { + try { + // Only sdk7 scenes + if (!this.rpcContext.sdk7) return + + // Only preview or production scenes with the DEBUG_MOD or DEBUG_SCENE_LOG param + if (!PREVIEW && !DEBUG_SCENE_LOG) return + + const mainFile = PREVIEW + ? this.loadableScene.entity.metadata.main + : `${this.loadableScene.entity.metadata.main}.map` + const file = await this.readFile(mainFile, 'text') + if (!file?.content) return + return (await initSourcemap(file.content, PREVIEW)) ?? undefined + } catch (_) {} + } + + async readFile( + fileName: string, + type?: T + ): Promise { // filenames are lower cased as per https://adr.decentraland.org/adr/ADR-80 const normalized = fileName.toLowerCase() @@ -245,8 +268,11 @@ export class SceneWorker { const response = await fetch(url) if (!response.ok) throw new Error(`Error fetching file ${file} from ${url}`) + if (!type || type === 'arraybuffer') { + return { hash, content: new Uint8Array(await response.arrayBuffer()) } as any + } - return { hash, content: new Uint8Array(await response.arrayBuffer()) } + return { hash, content: await response.text() } as any } } @@ -407,6 +433,7 @@ export class SceneWorker { this.metadata.scene.parcels, showAsPortableExperience ) + this.rpcContext.sourcemap = await this.loadSourcemap() } sceneEvents.emit(SCENE_LOAD, signalSceneLoad(this.loadableScene)) } From 1d426e42311d050dad30e149632115e3670c7149 Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Thu, 22 Feb 2024 11:50:45 -0300 Subject: [PATCH 2/4] remove sourcemap commit --- .../packages/shared/world/SceneWorker.ts | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/browser-interface/packages/shared/world/SceneWorker.ts b/browser-interface/packages/shared/world/SceneWorker.ts index e470d448a2..f47bbd82d1 100644 --- a/browser-interface/packages/shared/world/SceneWorker.ts +++ b/browser-interface/packages/shared/world/SceneWorker.ts @@ -12,7 +12,6 @@ import { getAssetBundlesBaseUrl, PIPE_SCENE_CONSOLE, playerHeight, - PREVIEW, WSS_ENABLED } from 'config' import { gridToWorld } from 'lib/decentraland/parcels/gridToWorld' @@ -43,7 +42,6 @@ import { joinBuffers } from 'lib/javascript/uint8arrays' import { nativeMsgBridge } from 'unity-interface/nativeMessagesBridge' import { _INTERNAL_WEB_TRANSPORT_ALLOC_SIZE } from 'renderer-protocol/transports/webTransport' import { createInternalEngine } from './runtime-7/engine' -import { initSourcemap } from './runtime-7/sourcemap' import { forceStopScene } from './parcelSceneManager' export enum SceneWorkerReadyState { @@ -196,8 +194,7 @@ export class SceneWorker { readFile: this.readFile.bind(this), initialEntitiesTick0: Uint8Array.of(), hasMainCrdt: false, - internalEngine: undefined, - sourcemap: undefined + internalEngine: undefined } // if the scene metadata has a base parcel, then we set it as the position @@ -233,27 +230,7 @@ export class SceneWorker { } } - async loadSourcemap() { - try { - // Only sdk7 scenes - if (!this.rpcContext.sdk7) return - - // Only preview or production scenes with the DEBUG_MOD or DEBUG_SCENE_LOG param - if (!PREVIEW && !DEBUG_SCENE_LOG) return - - const mainFile = PREVIEW - ? this.loadableScene.entity.metadata.main - : `${this.loadableScene.entity.metadata.main}.map` - const file = await this.readFile(mainFile, 'text') - if (!file?.content) return - return (await initSourcemap(file.content, PREVIEW)) ?? undefined - } catch (_) {} - } - - async readFile( - fileName: string, - type?: T - ): Promise { + async readFile(fileName: string) { // filenames are lower cased as per https://adr.decentraland.org/adr/ADR-80 const normalized = fileName.toLowerCase() @@ -268,11 +245,7 @@ export class SceneWorker { const response = await fetch(url) if (!response.ok) throw new Error(`Error fetching file ${file} from ${url}`) - if (!type || type === 'arraybuffer') { - return { hash, content: new Uint8Array(await response.arrayBuffer()) } as any - } - - return { hash, content: await response.text() } as any + return { hash, content: new Uint8Array(await response.arrayBuffer()) } } } @@ -433,7 +406,6 @@ export class SceneWorker { this.metadata.scene.parcels, showAsPortableExperience ) - this.rpcContext.sourcemap = await this.loadSourcemap() } sceneEvents.emit(SCENE_LOAD, signalSceneLoad(this.loadableScene)) } From d22010f7403b7c0f9b67a327eefa4a72cc134427 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Fri, 23 Feb 2024 20:12:11 -0300 Subject: [PATCH 3/4] fix: emote amount display --- .../BackpackEditorHUDV2/BackpackEmotesSectionController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEmotesSectionController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEmotesSectionController.cs index 79c90365bc..73fc47b47e 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEmotesSectionController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEmotesSectionController.cs @@ -112,10 +112,10 @@ async UniTaskVoid LoadEmotesAsync(CancellationToken ct = default) foreach (var emote in allEmotes) { if (consolidatedEmotes.TryGetValue(emote.id, out WearableItem consolidatedEmote)) - consolidatedEmote.amount += emote.amount + 1; + consolidatedEmote.amount += emote.amount; else { - emote.amount++; + emote.amount = 1; consolidatedEmotes[emote.id] = emote; } } From 73c9e032838f760ab71ad3ee987dd4c11b0a9862 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso <56365551+lorux0@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:06:56 -0300 Subject: [PATCH 4/4] fix: add extended urns for saving outfits (#6116) --- .../BackpackEditorHUDController.cs | 2 +- .../BackpackEditorHUDModel.cs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs index 95aeadf65c..bea458664d 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs @@ -817,7 +817,7 @@ private void SetAllColors(Color eyesColor, Color hairColor, Color bodyColor) private void UpdateAvatarModel(AvatarModel avatarModel) { view.UpdateAvatarPreview(avatarModel); - outfitsController.UpdateAvatarPreview(model.ToAvatarModel()); + outfitsController.UpdateAvatarPreview(model.ToAvatarModel(extendedWearableUrns)); } private void OnColorPickerToggled() => diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs index 216be669e5..476fb70a14 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDModel.cs @@ -13,12 +13,25 @@ public record BackpackEditorHUDModel public Color eyesColor; public HashSet forceRender = new (); - public AvatarModel ToAvatarModel() + public AvatarModel ToAvatarModel(Dictionary extendedWearableUrns = null) { + List wearables; + + if (extendedWearableUrns != null) + { + wearables = new List(); + + foreach (string w in this.wearables.Keys) + wearables.Add(extendedWearableUrns.TryGetValue(w, out string extendedUrn) + ? extendedUrn : w); + } + else + wearables = this.wearables.Keys.ToList(); + return new AvatarModel { bodyShape = bodyShape.id, - wearables = wearables.Keys.ToList(), + wearables = wearables, hairColor = hairColor, skinColor = skinColor, eyeColor = eyesColor,