Skip to content

Commit

Permalink
fix: Export Scenes (#3032)
Browse files Browse the repository at this point in the history
* fix: Import ECS library and thumbnail CORS error

* fix: Await async methods to generate the scene.json file

* feat: Update postinstall script to import the new built decentralad-ecs file

* fix: Await async methods to generate the scene.json file

* feat: Upgrade decentraland-ecs to the fixed version

* fix package version
  • Loading branch information
cyaiox authored Feb 5, 2024
1 parent acd4022 commit b547fb6
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 30 deletions.
66 changes: 46 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"decentraland-builder-scripts": "^0.24.0",
"decentraland-crypto-fetch": "^2.0.1",
"decentraland-dapps": "^18.1.0",
"decentraland-ecs": "6.6.1-20201020183014.commit-bdc29ef-hotfix",
"decentraland-ecs": "6.12.4-7784644013.commit-f770b3e",
"decentraland-experiments": "^1.0.2",
"decentraland-transactions": "^2.0.3",
"decentraland-ui": "^5.6.0",
Expand Down Expand Up @@ -154,7 +154,7 @@
},
"homepage": "",
"overrides": {
"decentraland-ecs": "6.6.1-20201020183014.commit-bdc29ef-hotfix",
"decentraland-ecs": "6.12.4-7784644013.commit-f770b3e",
"decentraland": "3.3.0"
}
}
2 changes: 1 addition & 1 deletion scripts/postinstall.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const prettier = require('prettier')
const editorPath = path.resolve(__dirname, process.argv[2] || require.resolve('decentraland-ecs/artifacts/editor'))
const targetEditorPath = path.resolve(__dirname, '../public/editor.js')

const ecsPath = path.resolve(__dirname, process.argv[3] || require.resolve('decentraland-ecs/dist/src/index.js'))
const ecsPath = path.resolve(__dirname, process.argv[3] || require.resolve('decentraland-ecs/dist/src/index.min.js'))
const targetEcsPath = path.resolve(__dirname, '../src/ecsScene/ecs.js.raw')

console.log(`> Copying file ${editorPath} into ${targetEditorPath}`)
Expand Down
5 changes: 1 addition & 4 deletions src/ecsScene/scene.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// This file is compiled using the decentraland-compiler, it's not using Vite as the compiler

import { EventEmitter } from 'events'
import { engine, GLTFShape, Transform, Entity, Component, NFTShape, IEntity } from 'decentraland-ecs'
import { engine, GLTFShape, Transform, Entity, Component, NFTShape, IEntity, Gizmos, SmartItem } from 'decentraland-ecs'
import * as ECS from 'decentraland-ecs'
import { createChannel } from 'decentraland-builder-scripts/channel'
import { createInventory } from 'decentraland-builder-scripts/inventory'
import { DecentralandInterface } from 'decentraland-ecs/dist/decentraland/Types'
import { EntityDefinition, AnyComponent, ComponentData, ComponentType, SceneSDK6 } from 'modules/scene/types'
import { AssetParameterValues } from 'modules/asset/types'

// @ts-ignore
const { Gizmos, SmartItem } = require('decentraland-ecs') as any
declare var dcl: DecentralandInterface

const inventory = createInventory(ECS.UICanvas, ECS.UIContainerStack, ECS.UIImage)
Expand Down
20 changes: 17 additions & 3 deletions src/modules/project/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,11 @@ export async function createDynamicFiles(args: {
null,
2
),
[EXPORT_PATH.SCENE_FILE]: JSON.stringify(getSceneDefinition(project, point, rotation, thumbnail, author, isEmpty, world), null, 2),
[EXPORT_PATH.SCENE_FILE]: JSON.stringify(
await getSceneDefinition(project, point, rotation, thumbnail, author, isEmpty, world),
null,
2
),
[EXPORT_PATH.TSCONFIG_FILE]: JSON.stringify(
{
...tsconfig,
Expand Down Expand Up @@ -571,7 +575,8 @@ export function buildAssetPath(namespace: string, path: string) {
// SDK7

export async function downloadSDK7File(key: string, url: string): Promise<{ path: string; file: Blob }> {
return fetch(url)
const headers = key === EXPORT_PATH.THUMBNAIL_FILE ? { headers: NO_CACHE_HEADERS } : {}
return fetch(url, headers)
.then(resp => resp.blob())
.then(blob => ({ path: key, file: blob }))
}
Expand Down Expand Up @@ -610,7 +615,16 @@ export async function createSDK7Files({ project, scene, builderAPI }: { project:
const sceneJson = new Blob([
new TextEncoder().encode(
JSON.stringify(
getSceneDefinition(project, { x: 0, y: 0 }, 'east', EXPORT_PATH.THUMBNAIL_FILE, project.ethAddress, undefined, undefined, true)
await getSceneDefinition(
project,
{ x: 0, y: 0 },
'east',
EXPORT_PATH.THUMBNAIL_FILE,
project.ethAddress,
undefined,
undefined,
true
)
)
)
])
Expand Down

0 comments on commit b547fb6

Please sign in to comment.