-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix flickering * feat: add the current project title to topbar (#73) * feat: local store projects (#75) * feat: local store projects * feat: empty projects notice * feat: translations * feat: add new assets to stored scene * feat: translation gizmo (#80) * feat: gizmo * fix flickering * chore: gizmo events * fix: position changes in ECS scene * chore: move gizmo dependency to decentraland-ecs * chore: small refactor * chore: small fixes * chore: update package.json * chore: remove startEditor action
- Loading branch information
1 parent
a8c09ad
commit 1c4f3fe
Showing
19 changed files
with
9,298 additions
and
6,729 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,6 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.vscode | ||
.vscode | ||
|
||
src/ecsScene/scene.js |
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,8 @@ | ||
[ | ||
{ | ||
"name": "Compile ecs scene", | ||
"kind": "Webpack", | ||
"file": "./src/ecsScene/scene.ts", | ||
"target": "web" | ||
} | ||
] |
Large diffs are not rendered by default.
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
Large diffs are not rendered by default.
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
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
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,98 @@ | ||
import { log, engine, GLTFShape, Transform, Entity, Gizmos, OnDragEnded } from 'decentraland-ecs' | ||
import { DecentralandInterface } from 'decentraland-ecs/dist/decentraland/Types' | ||
import { EntityDefinition, AnyComponent, ComponentData, ComponentType } from 'modules/scene/types' | ||
declare var dcl: DecentralandInterface | ||
|
||
const editorComponents: Record<string, any> = {} | ||
|
||
const gizmo = new Gizmos() | ||
gizmo.position = true | ||
gizmo.rotation = false | ||
gizmo.scale = false | ||
gizmo.updateEntity = false | ||
|
||
let gizmoEvent = new OnDragEnded((e: any) => log('drag ended received in ECS', e)) | ||
gizmoEvent.data.uuid = 'dragEndedEvent-editor' | ||
|
||
function getComponentById(id: string) { | ||
if (id in editorComponents) { | ||
return editorComponents[id] | ||
} | ||
return null | ||
} | ||
|
||
function handleExternalAction(message: { type: string; payload: Record<string, any> }) { | ||
switch (message.type) { | ||
case 'Update editor': | ||
const { | ||
scene: { components, entities } | ||
} = message.payload | ||
|
||
createComponents(components) | ||
createEntities(entities) | ||
// TODO: remove unused components | ||
// TODO: remove unused entities | ||
break | ||
} | ||
} | ||
|
||
function createComponents(components: AnyComponent[]) { | ||
for (let id in components) { | ||
const { type, data } = components[id] | ||
|
||
if (!getComponentById(id)) { | ||
switch (type) { | ||
case 'GLTFShape': | ||
editorComponents[id] = new GLTFShape((data as ComponentData[ComponentType.GLTFShape]).src) | ||
editorComponents[id].isPickable = true | ||
break | ||
case 'Transform': | ||
editorComponents[id] = new Transform() | ||
break | ||
} | ||
} | ||
|
||
const component = editorComponents[id] | ||
|
||
if (component) { | ||
if (type === 'Transform') { | ||
const transform = component as Transform | ||
const transformData = data as ComponentData[ComponentType.Transform] | ||
transformData.position && transform.position.copyFrom(transformData.position) | ||
} | ||
} | ||
} | ||
} | ||
|
||
function createEntities(entities: EntityDefinition[]) { | ||
for (let id in entities) { | ||
let entity: Entity = engine.entities[id] | ||
|
||
if (!entity) { | ||
entity = new Entity() | ||
;(entity as any).uuid = id | ||
entity.set(gizmoEvent) | ||
entity.set(gizmo) | ||
engine.addEntity(entity) | ||
} | ||
|
||
for (let componentId of entities[id].components) { | ||
const component = getComponentById(componentId) | ||
if (component) { | ||
entity.set(component) | ||
} | ||
} | ||
} | ||
} | ||
|
||
function subscribeToExternalActions() { | ||
dcl.subscribe('externalAction') | ||
|
||
dcl.onEvent(e => { | ||
if ((e.type as any) === 'externalAction') { | ||
handleExternalAction(e.data as any) | ||
} | ||
}) | ||
} | ||
|
||
subscribeToExternalActions() |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "../", | ||
"experimentalDecorators": true, | ||
"outDir": "." | ||
}, | ||
"includes": "*.ts", | ||
"exclude": [] | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.