forked from decentraland/sdk6-adaption-layer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add global events, pointer events and nft shape (decentraland#2)
* feat: add global events, pointer events and nft shape * fix * move system to a global one * fix * better test * apply @lean feedback * feat: add animation component fix: fix gltf visible collision layer
- Loading branch information
Showing
22 changed files
with
347 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { sdk7EnsureEntity } from '../ecs7/ECS7' | ||
import { ECS6State } from '../types' | ||
|
||
import { Animator, PBAnimationState } from '@dcl/sdk/ecs' | ||
|
||
function convertAnimationState(states: any): PBAnimationState[] { | ||
const animationStates: PBAnimationState[] = [] | ||
|
||
for (const state of states) { | ||
animationStates.push({ | ||
name: state.clip, // TODO: Review if this is right | ||
clip: state.clip, | ||
loop: state.looping, | ||
weight: state.weight, | ||
playing: state.playing, | ||
shouldReset: state.shouldReset, | ||
speed: state.speed, | ||
}) | ||
} | ||
|
||
return animationStates | ||
} | ||
|
||
export function update(state: ECS6State, ecs6EntityId: EntityID, payload: any) { | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
|
||
Animator.createOrReplace(ecs7Entity, { | ||
states: convertAnimationState(payload.states) | ||
}) | ||
} | ||
|
||
export function remove(state: ECS6State, ecs6EntityId: EntityID) { | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
Animator.deleteFrom(ecs7Entity) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import { ecs7EnsureEntity } from '../ecs7/ECS7' | ||
import { sdk7EnsureEntity } from '../ecs7/ECS7' | ||
import { ECS6State } from '../types' | ||
|
||
import { GltfContainer } from '@dcl/ecs' | ||
import { getColliderLayer } from './commons/utils' | ||
|
||
export function update(state: ECS6State, ecs6EntityId: EntityID, payload: any) { | ||
const ecs7Entity = ecs7EnsureEntity(state, ecs6EntityId) | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
|
||
GltfContainer.createOrReplace(ecs7Entity, { | ||
src: payload.src, | ||
invisibleMeshesCollisionMask: getColliderLayer(payload) | ||
}) | ||
if (payload.visible) { | ||
GltfContainer.createOrReplace(ecs7Entity, { | ||
src: payload.src, | ||
invisibleMeshesCollisionMask: getColliderLayer(payload), | ||
visibleMeshesCollisionMask: getColliderLayer(payload) | ||
}) | ||
} else { | ||
GltfContainer.deleteFrom(ecs7Entity) | ||
} | ||
} | ||
|
||
export function remove(state: ECS6State, ecs6EntityId: EntityID) { | ||
const ecs7Entity = ecs7EnsureEntity(state, ecs6EntityId) | ||
if (GltfContainer.getOrNull(ecs7Entity)) { | ||
GltfContainer.deleteFrom(ecs7Entity) | ||
} | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
GltfContainer.deleteFrom(ecs7Entity) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { sdk7EnsureEntity } from '../ecs7/ECS7' | ||
import { ECS6State } from '../types' | ||
|
||
import { NftShape, MeshCollider } from '@dcl/ecs' | ||
import { getColliderLayer } from './commons/utils' | ||
|
||
function convertNftSrcToUrn(src: string): string { | ||
src = src.substring('ethereum://'.length) | ||
src = src.replace('/', ':') | ||
return `urn:decentraland:ethereum:erc721:${src}` | ||
} | ||
|
||
export function update(state: ECS6State, ecs6EntityId: EntityID, payload: any) { | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
|
||
if (payload.visible) { | ||
NftShape.createOrReplace(ecs7Entity, { | ||
urn: convertNftSrcToUrn(payload.src), | ||
color: payload.color, | ||
style: payload.style | ||
}) | ||
} else { | ||
NftShape.deleteFrom(ecs7Entity) | ||
} | ||
|
||
const colliderLayer = getColliderLayer(payload) | ||
if (colliderLayer) { | ||
MeshCollider.setPlane(ecs7Entity, colliderLayer) | ||
} else { | ||
MeshCollider.deleteFrom(ecs7Entity) | ||
} | ||
} | ||
|
||
export function remove(state: ECS6State, ecs6EntityId: EntityID) { | ||
const ecs7Entity = sdk7EnsureEntity(state, ecs6EntityId) | ||
NftShape.deleteFrom(ecs7Entity) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.