forked from aframevr/aframe-inspector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.js
More file actions
38 lines (34 loc) · 1.12 KB
/
Copy pathhistory.js
File metadata and controls
38 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Events from './Events';
export const updates = {};
/**
* Store change to export.
*
* payload: entity, component, property, value.
*/
Events.on('entityupdate', (payload) => {
let value = payload.value;
const entity = payload.entity;
updates[entity.id] = updates[entity.id] || {};
const component = AFRAME.components[payload.component];
if (component) {
if (payload.property) {
updates[entity.id][payload.component] =
updates[entity.id][payload.component] || {};
if (value === null) {
delete updates[entity.id][payload.component][payload.property];
} else if (component.schema[payload.property]) {
value = component.schema[payload.property].stringify(payload.value);
updates[entity.id][payload.component][payload.property] = value;
} else {
updates[entity.id][payload.component][payload.property] = value;
}
} else {
if (value === null) {
delete updates[entity.id][payload.component];
} else {
value = component.schema.stringify(payload.value);
updates[entity.id][payload.component] = value;
}
}
}
});