Source

infohub/ServiceRpc.js

//
// $Id$
//

import { Context } from '../infohub/Context.js';
import { RestServices, RestResponse } from '../tools/RestServices.js';

/**
  
  @category Infohub Hub and Routines
 
  @classdesc 
      
 */
export class ServiceRpc {
  
  #_ctx = null;

  /**
   *
   * @param {Context} ctx
   *
   */
  constructor(ctx) {
    this.#_ctx = ctx;
  }

  // IFC

  /**
   * 
   *  /{scope}/ifc/{node}/transform
   * 
   *  @param {*} node_sid 
   *  @param {*} transformMap =
   *  {
        "object_id1": {                       // object ID
          "move": [ 1.0, 1.0, 2.0 ],          // move [ dx , dy , dz ]
          "rotate": {
            "pivot": [ 11.3, 34.6, 34.0 ],    // rotate around that point in global coordinates before moving the object
            "alpha": 45.0
          }
        },
        "object_id2": {
          "move": [ 1.0, 1.0, 0.0 ],
          "rotate": {
            "pivot": [ 11.3, 34.6, 34.0 ],
            "alpha": 45.0
          }
        }
      }
   * 
   */
  async transformIfc(node_sid, request_data ) {
      
    let scope = this.#_ctx.getScope()    
    let path_endpoint = `${this.#_ctx.getServiceUrl(Context.SERVICE.RPC)}/${scope}/ifc/${node_sid}/transform`

    console.log(`### <transformIfc()> ENDPOINT : ${path_endpoint}`)

    let resp = await RestServices.makeApiCall(this.#_ctx.getToken(), RestServices.METHODS.POST, path_endpoint, request_data )

    // console.log( "RESPONSE:" )
    // console.log( JSON.stringify(resp.getData()) )

    return resp

  }

}