Skip to content
15 changes: 7 additions & 8 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
"dependencies": {
"@actions/core": "^1.10.0",
"@dcl/protocol": "1.0.0-16571544774.commit-3f0ec22",
"@dcl/protocol": "1.0.0-16800835851.commit-2ec49fe",
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
"@dcl/ts-proto": "1.153.0",
"@types/fs-extra": "^9.0.12",
Expand Down
55 changes: 55 additions & 0 deletions packages/@dcl/ecs/src/components/extended/LightSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine'
import { LightSource, PBLightSource_Point, PBLightSource_Spot, PBLightSource } from '../generated/index.gen'
import {} from '../generated/LightSource.gen'

/**
* @public
*/
export interface LightSourceHelper {
/**
* @returns a Light Source type
*/
Point: (point: PBLightSource_Point) => PBLightSource['type']

/**
* @returns a Light Source type
*/
Spot: (spot: PBLightSource_Spot) => PBLightSource['type']
}

/**
* @public
*/
export interface LightSourceComponentDefinitionExtended
extends LastWriteWinElementSetComponentDefinition<PBLightSource> {
/**
* LightSource helper with constructor
*/
Type: LightSourceHelper
}

const LightSourceHelper: LightSourceHelper = {
Point(point) {
return {
$case: 'point',
point
}
},
Spot(spot) {
return {
$case: 'spot',
spot
}
}
}

export function defineLightSourceComponent(
engine: Pick<IEngine, 'defineComponentFromSchema'>
): LightSourceComponentDefinitionExtended {
const theComponent = LightSource(engine)

return {
...theComponent,
Type: LightSourceHelper
}
}
5 changes: 5 additions & 0 deletions packages/@dcl/ecs/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AudioStreamComponentDefinitionExtended, defineAudioStreamComponent } fr
import { MediaState } from './generated/pb/decentraland/sdk/components/common/media_state.gen'
import { defineVirtualCameraComponent, VirtualCameraComponentDefinitionExtended } from './extended/VirtualCamera'
import { defineInputModifierComponent, InputModifierComponentDefinitionExtended } from './extended/InputModifier'
import { defineLightSourceComponent, LightSourceComponentDefinitionExtended } from './extended/LightSource'

export * from './generated/index.gen'

Expand Down Expand Up @@ -65,6 +66,10 @@ export const VirtualCamera: LwwComponentGetter<VirtualCameraComponentDefinitionE
export const InputModifier: LwwComponentGetter<InputModifierComponentDefinitionExtended> = (engine) =>
defineInputModifierComponent(engine)

/* @__PURE__ */
export const LightSource: LwwComponentGetter<LightSourceComponentDefinitionExtended> = (engine) =>
defineLightSourceComponent(engine)

/**
* @alpha
*/
Expand Down
56 changes: 56 additions & 0 deletions packages/@dcl/playground-assets/etc/playground-assets.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ export const componentDefinitionByName: {
"core::GltfContainerLoadingState": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>>;
"core::GltfNodeModifiers": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfNodeModifiers>>;
"core::InputModifier": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBInputModifier>>;
"core::LightSource": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBLightSource>>;
"core::MainCamera": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMainCamera>>;
"core::Material": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMaterial>>;
"core::MeshCollider": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshCollider>>;
Expand Down Expand Up @@ -1578,6 +1579,9 @@ export interface LastWriteWinElementSetComponentDefinition<T> extends BaseCompon
getOrNull(entity: Entity): DeepReadonly<T> | null;
}

// @public (undocumented)
export const LightSource: LastWriteWinElementSetComponentDefinition<PBLightSource>;

// @public
export type Listeners = {
onMouseDown?: Callback;
Expand Down Expand Up @@ -2456,6 +2460,58 @@ export namespace PBInputModifier_StandardInput {
export function encode(message: PBInputModifier_StandardInput, writer?: _m0.Writer): _m0.Writer;
}

// @public (undocumented)
export interface PBLightSource {
active?: boolean | undefined;
color?: PBColor3 | undefined;
intensity?: number | undefined;
range?: number | undefined;
shadow?: boolean | undefined;
shadowMaskTexture?: TextureUnion | undefined;
// (undocumented)
type?: {
$case: "point";
point: PBLightSource_Point;
} | {
$case: "spot";
spot: PBLightSource_Spot;
} | undefined;
}

// @public (undocumented)
export namespace PBLightSource {
// (undocumented)
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBLightSource;
// (undocumented)
export function encode(message: PBLightSource, writer?: _m0.Writer): _m0.Writer;
}

// @public (undocumented)
export interface PBLightSource_Point {
}

// @public (undocumented)
export namespace PBLightSource_Point {
// (undocumented)
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBLightSource_Point;
// (undocumented)
export function encode(_: PBLightSource_Point, writer?: _m0.Writer): _m0.Writer;
}

// @public (undocumented)
export interface PBLightSource_Spot {
innerAngle?: number | undefined;
outerAngle?: number | undefined;
}

// @public (undocumented)
export namespace PBLightSource_Spot {
// (undocumented)
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBLightSource_Spot;
// (undocumented)
export function encode(message: PBLightSource_Spot, writer?: _m0.Writer): _m0.Writer;
}

// @public (undocumented)
export interface PBMainCamera {
virtualCameraEntity?: number | undefined;
Expand Down
15 changes: 7 additions & 8 deletions packages/@dcl/sdk-commands/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/@dcl/sdk-commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@dcl/inspector": "file:../inspector",
"@dcl/linker-dapp": "^0.14.2",
"@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
"@dcl/protocol": "1.0.0-16571544774.commit-3f0ec22",
"@dcl/protocol": "1.0.0-16800835851.commit-2ec49fe",
"@dcl/quests-client": "^1.0.3",
"@dcl/quests-manager": "^0.1.4",
"@dcl/rpc": "^1.1.1",
Expand Down
106 changes: 106 additions & 0 deletions test/ecs/components/LightSource.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { Engine, components } from '../../../packages/@dcl/ecs/src'
import { testComponentSerialization } from './assertion'
import { PBLightSource, PBLightSource_Point, LightSource } from '../../../packages/@dcl/ecs'

Check warning on line 3 in test/ecs/components/LightSource.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'LightSource' is defined but never used. Allowed unused vars must match /^_|ReactEcs/u

Check warning on line 3 in test/ecs/components/LightSource.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'PBLightSource_Point' is defined but never used. Allowed unused vars must match /^_|ReactEcs/u

describe('Generated LightSource ProtoBuf', () => {
it('should serialize/deserialize Point LightSource', () => {
const newEngine = Engine()
const LightSource = components.LightSource(newEngine)

testComponentSerialization(LightSource, {
active: true,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: { $case: 'point', point: {} }
})
})

it('should serialize/deserialize Spot LightSource', () => {
const newEngine = Engine()
const LightSource = components.LightSource(newEngine)

testComponentSerialization(LightSource, {
active: false,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: {
$case: 'spot',
spot: {
innerAngle: 21.8,
outerAngle: 30
}
}
})
})

it('should test point light helper', () => {
const newEngine = Engine()
const LightSource = components.LightSource(newEngine)
const entity = newEngine.addEntity()

expect(LightSource.getOrNull(entity)).toBeNull()

LightSource.create(entity, {
active: true,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: LightSource.Type.Point({})
})

expect(LightSource.get(entity)).toStrictEqual<PBLightSource>({
active: true,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: { $case: 'point', point: {} }
})
})

it('should test spot light helper', () => {
const newEngine = Engine()
const LightSource = components.LightSource(newEngine)
const entity = newEngine.addEntity()

expect(LightSource.getOrNull(entity)).toBeNull()

LightSource.create(entity, {
active: false,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: LightSource.Type.Spot({
innerAngle: 21.8,
outerAngle: 30
})
})

expect(LightSource.get(entity)).toStrictEqual<PBLightSource>({
active: false,
color: { r: 1, g: 1, b: 1 },
intensity: 1,
range: 10,
shadowMaskTexture: undefined,
shadow: true,
type: {
$case: 'spot',
spot: {
innerAngle: 21.8,
outerAngle: 30
}
}
})
})
})
10 changes: 5 additions & 5 deletions test/snapshots/development-bundles/static-scene.test.ts.crdt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SCENE_COMPILED_JS_SIZE_PROD=474.2k bytes
SCENE_COMPILED_JS_SIZE_PROD=480.6k bytes
THE BUNDLE HAS SOURCEMAPS
(start empty vm 0.21.0-3680274614.commit-1808aa1)
OPCODES ~= 0k
Expand All @@ -10,9 +10,9 @@ EVAL test/snapshots/development-bundles/static-scene.test.js
REQUIRE: ~system/Testing
REQUIRE: ~system/EngineApi
REQUIRE: ~system/EngineApi
OPCODES ~= 55k
MALLOC_COUNT = 14039
ALIVE_OBJS_DELTA ~= 2.77k
OPCODES ~= 56k
MALLOC_COUNT = 14173
ALIVE_OBJS_DELTA ~= 2.80k
CALL onStart()
main.crdt: PUT_COMPONENT e=0x200 c=1 t=0 data={"position":{"x":5.880000114440918,"y":2.7916901111602783,"z":7.380000114440918},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
main.crdt: PUT_COMPONENT e=0x202 c=1 t=0 data={"position":{"x":4,"y":0.800000011920929,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
Expand Down Expand Up @@ -56,4 +56,4 @@ CALL onUpdate(0.1)
OPCODES ~= 3k
MALLOC_COUNT = -5
ALIVE_OBJS_DELTA ~= 0.00k
MEMORY_USAGE_COUNT ~= 1230.72k bytes
MEMORY_USAGE_COUNT ~= 1242.30k bytes
Loading
Loading