0

i am trying to use a ts file function into js file . for that first i tried to convert ts file into js file

the converted file is as below

var BP3D;
(function (BP3D) {
    var Model;
    (function (Model_1) {

        var Model = /** @class */ (function () {

            function Model(textureDir) {
                /** */
            }
            Model.prototype.loadSerialized = function (json) {};
            Model.prototype.exportSerialized = function (json) {};
            Model.prototype.Blueprint3d= function (json) {};
                var items_arr = [];
                var objects = this.scene.getItems();
                for (var i = 0; i < objects.length; i++) {
                    var object = objects[i];
                    items_arr[i] = {
                        item_name: object.metadata.itemName,
                        item_type: object.metadata.itemType,
                        model_url: object.metadata.modelUrl,
                        xpos: object.position.x,
                        ypos: object.position.y,
                        zpos: object.position.z,
                        rotation: object.rotation.y,
                        scale_x: object.scale.x,
                        scale_y: object.scale.y,
                        scale_z: object.scale.z,
                        fixed: object.fixed
                    };
                }
                var room = {
                    floorplan: (this.floorplan.saveFloorplan()),
                    items: items_arr
                };
                return JSON.stringify(room);
            };
            Model.prototype.newRoom = function (floorplan, items) {};
                var _this = this;
                this.scene.clearItems();
                this.floorplan.loadFloorplan(floorplan);
                items.forEach(function (item) {
                    var position = new THREE.Vector3(item.xpos, item.ypos, item.zpos);
                    var metadata = {
                        itemName: item.item_name,
                        resizable: item.resizable,
                        itemType: item.item_type,
                        modelUrl: item.model_url
                    };
                    var scale = new THREE.Vector3(item.scale_x, item.scale_y, item.scale_z);
                    _this.scene.addItem(item.item_type, item.model_url, metadata, position, item.rotation, scale, item.fixed);
                });
            };

           return Model;
        }());
        Model_1.Model = Model;
    })(Model = BP3D.Model || (BP3D.Model = {}));
})(BP3D || (BP3D = {}));

now I am trying to access constructor with given code

$(document).ready(function() {

  var opts = {}
  var blueprint3d = new BP3D.Blueprint3d(opts);
});

but error comes

BP3D.Blueprint3d is not a constructor

the converted js file contain inner constructor , which i am getting unable to access .. How can i modify the constrcutor with variable to that at least it is getting accessible ?

Need some suggestion

Neeraj Verma
  • 2,174
  • 6
  • 30
  • 51
  • The `Blueprint3d` property doesn't seem to be defined anywhere. – VLAZ Jan 23 '18 at 13:10
  • updated the code – Neeraj Verma Jan 23 '18 at 13:13
  • You are terribly overengineering here. Your `BP3D` has a `Model` property that has `Model` function inside but since you set `Blueprint3D` in its prototype (rather than as a direct property) you have to first call `new` on it to have an instance that has `Blueprint3d` as a function to again call `new` on it. A working snippet here is `new (new BP3D.Model.Model()).Blueprint3d(opts)`. I am not sure you really want that. – Wiktor Zychla Jan 23 '18 at 14:15

0 Answers0