x.y不是构造函数

时间:2018-01-23 13:09:28

标签: javascript constructor blueprint

我正在尝试将ts文件函数用于js文件。首先,我试图将ts文件转换为js文件

转换后的文件如下

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 = {}));

现在我正在尝试使用给定代码访问构造函数

$(document).ready(function() {

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

但错误来了

BP3D.Blueprint3d不是构造函数

转换后的js文件包含内部构造函数,我无法访问..如何修改constrcutor变量,至少可以访问?

需要一些建议

0 个答案:

没有答案