Skip to content

Commit

Permalink
Revert "add environment node support"
Browse files Browse the repository at this point in the history
  • Loading branch information
Algorush committed Jul 6, 2023
1 parent a5f9854 commit 99976f8
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions src/json-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ and returns a Javascript object
*/
function convertDOMElToObject (entity) {
const data = [];
const environmentElement = document.querySelector('#environment');
const sceneEntities = [entity, environmentElement];

for (const entry of sceneEntities) {
const entityData = getElementData(entry);
if (entityData) {
data.push(entityData);
if (entity.length) {
for (const entry of entity) {
data.push(getElementData(entry));
}
} else {
data.push(getElementData(entity));
}
return {
title: 'scene',
Expand All @@ -23,9 +21,6 @@ function convertDOMElToObject (entity) {
}

function getElementData (entity) {
if (!entity.isEntity) {
return;
}
const elementTree = getAttributes(entity);
const children = entity.childNodes;
if (children.length) {
Expand All @@ -41,8 +36,7 @@ function getElementData (entity) {

function getAttributes (entity) {
const elemObj = {};

elemObj['element'] = entity.tagName.toLowerCase();
elemObj['element'] = entity.tagName.toLowerCase();

if (entity.id) {
elemObj['id'] = entity.id;
Expand Down Expand Up @@ -118,8 +112,7 @@ const removeProps = {
normalMap: {},
'set-loader-from-hash': '*',
'create-from-json': '*',
street: { JSON: '*' },
'street-environment': '*'
street: { JSON: '*' }
};
// a list of component_name:new_component_name pairs to rename in JSON string
const renameProps = {
Expand All @@ -129,6 +122,7 @@ const renameProps = {

function filterJSONstreet (removeProps, renameProps, streetJSON) {
function removeValueCheck (removeVal, value) {
// console.error(removeVal, value, AFRAME.utils.deepEqual(removeVal, value))
if (AFRAME.utils.deepEqual(removeVal, value) || removeVal === '*') {
return true;
}
Expand Down Expand Up @@ -262,6 +256,7 @@ function getModifiedProperty (entity, componentName) {
return data;
}
}

const diff = {};
for (const key in data) {
const defaultValue = defaultData[key].default;
Expand All @@ -275,19 +270,19 @@ function getModifiedProperty (entity, componentName) {
diff[key] = data[key];
}
}

return diff;
}

function createEntities (entitiesData, parentEl) {
const sceneElement = document.querySelector('a-scene');
function createEntities (entitiesData, parentEl) {
for (const entityData of entitiesData) {
if (entityData.id === 'street-container' &&
entityData.children &&
entityData.children[0].id === 'default-street' &&
entityData.children[0].components.hasOwnProperty('set-loader-from-hash')) {
delete entityData.children[0].components['set-loader-from-hash'];
}
createEntityFromObj(entityData, sceneElement);
createEntityFromObj(entityData, parentEl);
}
}

Expand Down Expand Up @@ -335,14 +330,12 @@ function createEntityFromObj (entityData, parentEl) {
entity.setAttribute('mixin', entityData.mixin);
}
// Ensure the components are loaded before update the UI

entity.emit('entitycreated', {}, false);
});

if (entityData.children) {
for (const childEntityData of entityData.children) {
createEntityFromObj(childEntityData, entity);
}
}
});
if (entityData.children) {
for (const childEntityData of entityData.children) {
createEntityFromObj(childEntityData, entity);
}
}
}

0 comments on commit 99976f8

Please sign in to comment.