src/util/loader_ex.js
function createComponent(loader, obj) {
    const entitySet = loader.entitySet;

    // determine whether any attributes are refering to marked pois
    obj = resolveMarkReferences(loader, obj);

    // the alternative form is to use @uri
    if (obj[CMD_COMPONENT_URI]) {
        obj[CMD_COMPONENT] = obj[CMD_COMPONENT_URI];
        delete obj[CMD_COMPONENT_URI];
    }

    if( obj[CMD_COMPONENT] === undefined ){
        throw new Error('invalid create component command');
    }

    const component = loader.registry.createComponent(obj);

    return Promise.resolve(component)
        .then(component => {
            if (!loader.entity) {
                return _createEntity(loader, null, { shadow: true });
            }
            // Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id);
            return component;
        })
        .then(() => loader.entity.addComponent(component))
        .then(() => component);

    // loader.entity.addComponent( component );

    // return Promise.resolve(component);
}
function createComponent(loader, obj) {
    const entitySet = loader.entitySet;

    // determine whether any attributes are refering to marked pois
    obj = resolveMarkReferences(loader, obj);

    // the alternative form is to use @uri
    if (obj[CMD_COMPONENT_URI]) {
        obj[CMD_COMPONENT] = obj[CMD_COMPONENT_URI];
        delete obj[CMD_COMPONENT_URI];
    }

    if( obj[CMD_COMPONENT] === undefined ){
        throw new Error('invalid create component command');
    }

    const component = loader.registry.createComponent(obj);

    return Promise.resolve(component)
        .then(component => {
            if (!loader.entity) {
                return _createEntity(loader, null, { shadow: true });
            }
            // Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id);
            return component;
        })
        .then(() => loader.entity.addComponent(component))
        .then(() => component);

    // loader.entity.addComponent( component );

    // return Promise.resolve(component);
}
function createComponent ( loader , obj ) { const entitySet = loader . entitySet ; // determine whether any attributes are refering to marked pois obj = resolveMarkReferences ( loader , obj ) ; // the alternative form is to use @uri if ( obj [ CMD_COMPONENT_URI ] ) { obj [ CMD_COMPONENT ] = obj [ CMD_COMPONENT_URI ] ; delete obj [ CMD_COMPONENT_URI ] ; } if ( obj [ CMD_COMPONENT ] === undefined ) { throw new Error ( 'invalid create component command' ) ; } const component = loader . registry . createComponent ( obj ) ; return Promise . resolve ( component ) . then ( component => { if ( ! loader . entity ) { return _createEntity ( loader , null , { shadow : true } ) ; } // Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id); return component ; } ) . then ( ( ) => loader . entity . addComponent ( component ) ) . then ( ( ) => component ) ; // loader.entity.addComponent( component ); // return Promise.resolve(component); }
return value; }
return value ; }