Skip to content

Commit

Permalink
ix: Add Visibility component and stop manifest from ending prematuraly (
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia authored May 9, 2024
1 parent 46f0fa9 commit b89b33b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
case RenderableEntityConstants.MeshRenderer:
componentData = new MeshRendererData();
break;
case RenderableEntityConstants.Visibility:
componentData = new VisibilityData();
break;
}

if (componentData != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class RenderableEntityConstants
public const string Material = "core::Material";
public const string GLTFContainer = "core::GltfContainer";
public const string MeshRenderer = "core::MeshRenderer";
public const string Visibility = "core::VisibilityComponent";
}

public class MeshConstants
Expand Down
11 changes: 11 additions & 0 deletions DCL_PiXYZ/SceneRepositioner/JsonParsing/VisibilityData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace DCL_PiXYZ.SceneRepositioner.JsonParsing
{
[Serializable]
public class VisibilityData : ComponentData
{
public bool visible;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class DCLRendereableEntity

private int entityID;
private TransformData transform = new TransformData();
private VisibilityData visibilityData;
private DCLMesh rendereableMesh;
public DCLMaterial dclMaterial = new EmptyMaterial();
private PiXYZAPI pxz;
Expand All @@ -40,6 +41,9 @@ public void SetComponentData(RenderableEntity renderableEntity)
case RenderableEntityConstants.Material:
dclMaterial = ((MaterialData)renderableEntity.data).material;
break;
case RenderableEntityConstants.Visibility:
visibilityData = ((VisibilityData)renderableEntity.data);
break;
}
}

Expand All @@ -55,8 +59,9 @@ public PXZModel PositionAndInstantiteMesh(Dictionary<string, string> contentTabl

bool hasZeroScale = HasZeroScaleApplied(renderableEntities);
bool isFullyTransparent = dclMaterial.IsFullyTransparent();
bool isHidden = visibilityData is { visible: false };

if (rendereableMesh != null && !hasZeroScale && !isFullyTransparent)
if (rendereableMesh != null && !hasZeroScale && !isFullyTransparent && !isHidden)
{
//TODO (Juani): Clean up the amterial logic. If its a GLTFMesh, we dont have a material. This can get confusing for debugging
uint material = dclMaterial.GetMaterial(pxz, entityID.ToString(), contentTable);
Expand Down
2 changes: 1 addition & 1 deletion scene-lod-entities-manifest-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"build": "tsc -p tsconfig.json",
"watch": "tsc -p tsconfig.json --watch",
"start": "node --trace-warnings --abort-on-uncaught-exception --unhandled-rejections=strict dist/index.js",
"start": "node --trace-warnings dist/index.js",
"test": "jest --forceExit --detectOpenHandles --coverage --verbose --passWithNoTests",
"lint:check": "npx eslint . --ext .ts",
"lint:fix": "npx eslint . --ext .ts --fix"
Expand Down
7 changes: 7 additions & 0 deletions scene-lod-entities-manifest-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ import { main } from './service'

// This file is the program entry point, it only calls the Lifecycle function
Lifecycle.run({ main, initComponents })

process.on('uncaughtException', (err, origin) => {
console.log("Uncaught Exception", err)
});
process.on('unhandledRejection', (err, origin) => {
console.log("Uncaught Rejection", err)
});
40 changes: 30 additions & 10 deletions scene-lod-entities-manifest-builder/src/logic/scene-runtime/apis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { serializeCrdtMessages } from './logger'
import { contentFetchBaseUrl, mainCrdt, sceneId, sdk6FetchComponent, sdk6SceneContent } from "../sceneFetcher";
import { writeFile, mkdir } from 'fs'
import { engine, Entity, PutComponentOperation, Transform } from '@dcl/ecs/dist-cjs'
import {engine, Entity, PutComponentOperation, Transform, UiCanvasInformation} from '@dcl/ecs/dist-cjs'
import { ReadWriteByteBuffer } from '@dcl/ecs/dist-cjs/serialization/ByteBuffer'
import {FRAMES_TO_RUN, framesCount} from "../../adapters/scene";

Expand All @@ -18,7 +18,18 @@ function addPlayerEntityTransform() {
const transformData = buffer.toCopiedBinary()
buffer.resetBuffer()
PutComponentOperation.write(1 as Entity, 1, Transform.componentId, transformData, buffer)


return buffer.toBinary()
}

function addUICanvasOnRootEntity() {
const buffer = new ReadWriteByteBuffer()
const uiCanvasInformation = UiCanvasInformation.create(engine.RootEntity)
UiCanvasInformation.schema.serialize(uiCanvasInformation, buffer)
const uiCanvasComponentData = buffer.toCopiedBinary()
buffer.resetBuffer()
PutComponentOperation.write(0 as Entity, 1, UiCanvasInformation.componentId, uiCanvasComponentData, buffer)

return buffer.toBinary()
}

Expand All @@ -28,16 +39,17 @@ export const LoadableApis = {
// to avoid compilation errors on very old sdk6 scenes when running their eval to generate the manifest.
EnvironmentApi: {
isPreviewMode: async () => ({ isPreview: false }),

getBootstrapData: async () => ({ }),

getPlatform: async () => ({ }),

areUnsafeRequestAllowed: async () => ({ }),

getCurrentRealm: async () => ({ }),

getExplorerConfiguration: async () => ({ }),
getExplorerConfiguration: async () => ({
clientUri: "",
configurations: {
questsServerUrl : "https://quests-api.decentraland.org"
},
}),

getDecentralandTime: async () => ({ })
},
Expand All @@ -49,9 +61,9 @@ export const LoadableApis = {
},
EngineApi: {
sendBatch: async () => ({ events: [] }),

crdtGetState: async () => ({ hasEntities: mainCrdt !== undefined, data: [addPlayerEntityTransform(), mainCrdt] }),

subscribe : async () => ({ events: [] }),
unsubscribe : async () => ({ events: [] }),
crdtGetState: async () => ({ hasEntities: mainCrdt !== undefined, data: [addPlayerEntityTransform(), addUICanvasOnRootEntity(), mainCrdt] }),
crdtSendToRenderer: async ({ data }: { data: Uint8Array }) => {
async function ensureDirectoryExists(directory: string): Promise<void> {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -215,6 +227,14 @@ export const LoadableApis = {
contents: []
}
}
},
SocialController:{
registerSocialControllerServiceServerImplementation(port:any) {
return{
async() {}
}
},

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function createSceneFetcherComponent({ config, fetch }: Pick<BaseCo
sdk6SceneContent = sceneData.content
sdk6FetchComponent = fetch

let fetchResponse = await fetch.fetch(`https://renderer-artifacts.decentraland.org/sdk7-adaption-layer/main/index.js`)
let fetchResponse = await fetch.fetch(`https://renderer-artifacts.decentraland.org/sdk6-adaption-layer/main/index.js`)
return await fetchResponse.text()
}

Expand Down

0 comments on commit b89b33b

Please sign in to comment.