Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix onChange for custom componetns #1043

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions packages/@dcl/ecs/src/systems/crdt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,14 @@ export function crdtSceneSystem(engine: PreEngine, onProcessEntityComponentChang
...message,
messageBuffer: buffer.buffer().subarray(offset, buffer.currentWriteOffset())
})
}
if (onProcessEntityComponentChange) {
const rawValue =
message.type === CrdtMessageType.PUT_COMPONENT || message.type === CrdtMessageType.APPEND_VALUE
? component.get(message.entityId)
: undefined

if (onProcessEntityComponentChange) {
const rawValue =
message.type === CrdtMessageType.PUT_COMPONENT || message.type === CrdtMessageType.APPEND_VALUE
? component.get(message.entityId)
: undefined

onProcessEntityComponentChange(message.entityId, message.type, component, rawValue)
}
onProcessEntityComponentChange(message.entityId, message.type, component, rawValue)
}
}
}
Expand Down
33 changes: 27 additions & 6 deletions packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Result } from 'arg'
import { args as startArgs } from '.'
import { CliComponents } from '../../components'

const isWindows = /^win/.test(process.platform)

export async function runExplorerAlpha(
components: CliComponents,
opts: { cwd: string; realm: string; baseCoords: { x: number; y: number }; isHub: boolean }
opts: {
cwd: string
realm: string
baseCoords: { x: number; y: number }
isHub: boolean
args: Result<typeof startArgs>
}
) {
const { cwd, realm, baseCoords, isHub } = opts

if (await runApp(components, { cwd, realm, baseCoords, isHub })) {
if (await runApp(components, { cwd, realm, baseCoords, isHub, args: opts.args })) {
return
}

Expand All @@ -19,14 +27,27 @@ async function runApp(
components: CliComponents,
{
cwd,
realm,
realm: realmValue,
baseCoords,
isHub
}: { cwd: string; realm: string; baseCoords: { x: number; y: number }; isHub: boolean }
isHub,
args
}: {
cwd: string
realm: string
baseCoords: { x: number; y: number }
isHub: boolean
args: Result<typeof startArgs>
}
) {
const cmd = isWindows ? 'start' : 'open'
const position = args['--position'] ?? `${baseCoords.x},${baseCoords.y}`
const realm = args['--realm'] ?? realmValue
const localScene = args['--local-scene'] ?? true
const debug = args['--debug'] ?? true
const dclenv = args['--dclenv'] ?? 'org'

try {
const params = `realm=${realm}&position=${baseCoords.x},${baseCoords.y}&local-scene=true&debug=true&hub=${isHub}`
const params = `realm=${realm}&position=${position}&local-scene=${localScene}&debug=${debug}&hub=${isHub}&dclenv=${dclenv}`
const app = `decentraland://"${params}"`
await components.spawner.exec(cwd, cmd, [app], { silent: true })
components.logger.info(`Desktop client: decentraland://${params}\n`)
Expand Down
17 changes: 14 additions & 3 deletions packages/@dcl/sdk-commands/src/commands/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ export const args = declareArgs({
'--desktop-client': Boolean,
'--data-layer': Boolean,
'--explorer-alpha': Boolean,
'--hub': Boolean
'--hub': Boolean,
// Params related to the explorer-alpha
'--debug': Boolean,
'--dclenv': String,
'--realm': String,
'--local-scene': String,
'--position': String
})

export async function help(options: Options) {
Expand All @@ -70,6 +76,12 @@ export async function help(options: Options) {
--web3 Connects preview to browser wallet to use the associated avatar and account
--skip-build Skip build and only serve the files in preview mode
--desktop-client Show URL to launch preview in the desktop client (BETA)
--debug Enables Debug panel mode inside DCL Explorer (default=true)
--dclenv Decentraland Environment. Which environment to use for the content. This determines the catalyst server used, asset-bundles, etc. Possible values: org, zone, today. (default=org)
--realm Realm used to serve the content. (default=Localhost)
--local-scene Enable local scene development.
--position Initial Position to start the explorer. (default=position defined at scene.json)


Examples:

Expand Down Expand Up @@ -97,7 +109,6 @@ export async function main(options: Options) {
const isHub = !!options.args['--hub']

let hasSmartWearable = false

const workspace = await getValidWorkspace(options.components, workingDirectory)

/* istanbul ignore if */
Expand Down Expand Up @@ -232,7 +243,7 @@ export async function main(options: Options) {

if (explorerAlpha) {
const realm = new URL(sortedURLs[0]).origin
await runExplorerAlpha(components, { cwd: workingDirectory, realm, baseCoords, isHub })
await runExplorerAlpha(components, { cwd: workingDirectory, realm, baseCoords, isHub, args: options.args })
}

// Open preferably localhost/127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ CALL onUpdate(0.1)
OPCODES ~= 3k
MALLOC_COUNT = -5
ALIVE_OBJS_DELTA ~= 0.00k
MEMORY_USAGE_COUNT ~= 1194.79k bytes
MEMORY_USAGE_COUNT ~= 1194.77k bytes
4 changes: 2 additions & 2 deletions test/snapshots/development-bundles/testing-fw.test.ts.crdt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SCENE_COMPILED_JS_SIZE_PROD=454k bytes
SCENE_COMPILED_JS_SIZE_PROD=453.9k bytes
THE BUNDLE HAS SOURCEMAPS
(start empty vm 0.21.0-3680274614.commit-1808aa1)
OPCODES ~= 0k
Expand Down Expand Up @@ -64,4 +64,4 @@ CALL onUpdate(0.1)
OPCODES ~= 5k
MALLOC_COUNT = -40
ALIVE_OBJS_DELTA ~= -0.01k
MEMORY_USAGE_COUNT ~= 1203.40k bytes
MEMORY_USAGE_COUNT ~= 1203.39k bytes
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ CALL onUpdate(0.1)
OPCODES ~= 5k
MALLOC_COUNT = -40
ALIVE_OBJS_DELTA ~= -0.01k
MEMORY_USAGE_COUNT ~= 1203.41k bytes
MEMORY_USAGE_COUNT ~= 1203.39k bytes
6 changes: 3 additions & 3 deletions test/snapshots/production-bundles/billboard.ts.crdt
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x201 c=1 t=2 data={"position":{"x":12,"y":3.0420734882354736,"z":1},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x204 c=1 t=2 data={"position":{"x":12,"y":3.0420734882354736,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x203 c=1 t=2 data={"position":{"x":8,"y":3.0420734882354736,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
OPCODES ~= 9k
OPCODES ~= 10k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x200 c=1 t=3 data={"position":{"x":8,"y":3.087538480758667,"z":1},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x201 c=1 t=3 data={"position":{"x":12,"y":3.087538480758667,"z":1},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x204 c=1 t=3 data={"position":{"x":12,"y":3.087538480758667,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x203 c=1 t=3 data={"position":{"x":8,"y":3.087538480758667,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
OPCODES ~= 9k
OPCODES ~= 10k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x200 c=1 t=4 data={"position":{"x":8,"y":3.0945944786071777,"z":1},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x201 c=1 t=4 data={"position":{"x":12,"y":3.0945944786071777,"z":1},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x204 c=1 t=4 data={"position":{"x":12,"y":3.0945944786071777,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
Scene: PUT_COMPONENT e=0x203 c=1 t=4 data={"position":{"x":8,"y":3.0945944786071777,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":2,"y":2,"z":2},"parent":0}
OPCODES ~= 9k
OPCODES ~= 10k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
MEMORY_USAGE_COUNT ~= 1042.09k bytes
8 changes: 4 additions & 4 deletions test/snapshots/production-bundles/cubes.ts.crdt
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ CALL onUpdate(0)
Scene: PUT_COMPONENT e=0x2b4 c=1018 t=1 data={"mesh":{"$case":"box","box":{"uvs":[]}}}
Scene: PUT_COMPONENT e=0x2b5 c=1018 t=1 data={"mesh":{"$case":"box","box":{"uvs":[]}}}
Scene: PUT_COMPONENT e=0x2b6 c=1018 t=1 data={"mesh":{"$case":"box","box":{"uvs":[]}}}
OPCODES ~= 998k
OPCODES ~= 1000k
MALLOC_COUNT = 1840
ALIVE_OBJS_DELTA ~= 0.74k
CALL onUpdate(0.1)
Expand Down Expand Up @@ -925,7 +925,7 @@ CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x2b4 c=1017 t=2 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b5 c=1017 t=2 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b6 c=1017 t=2 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
OPCODES ~= 691k
OPCODES ~= 692k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
CALL onUpdate(0.1)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x2b4 c=1017 t=3 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b5 c=1017 t=3 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b6 c=1017 t=3 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
OPCODES ~= 691k
OPCODES ~= 692k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
CALL onUpdate(0.1)
Expand Down Expand Up @@ -1649,7 +1649,7 @@ CALL onUpdate(0.1)
Scene: PUT_COMPONENT e=0x2b4 c=1017 t=4 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b5 c=1017 t=4 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
Scene: PUT_COMPONENT e=0x2b6 c=1017 t=4 data={"material":{"$case":"pbr","pbr":{"albedoColor":{"r":0,"g":0,"b":1,"a":1}}}}
OPCODES ~= 691k
OPCODES ~= 692k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
MEMORY_USAGE_COUNT ~= 1178.02k bytes
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ CALL onUpdate(0.1)
OPCODES ~= 1k
MALLOC_COUNT = 0
ALIVE_OBJS_DELTA ~= 0.00k
MEMORY_USAGE_COUNT ~= 854.79k bytes
MEMORY_USAGE_COUNT ~= 854.80k bytes
Loading