在JavaScript中将Qubble模型转换为Techne模型

在JavaScript中将Qubble模型转换为Techne模型,javascript,json,minecraft,Javascript,Json,Minecraft,我需要打开这个JSON对象,一个由以下程序生成的模型: 以某种方式使用JavaScript转换为这种格式,以便我的模型查看器可以读取: { "Techne": { "Models": [{ "Model": { "@texture": "texture.png", "BaseClass": "ModelBase", "Geometry": {

我需要打开这个JSON对象,一个由以下程序生成的模型:

以某种方式使用JavaScript转换为这种格式,以便我的模型查看器可以读取:

{
    "Techne": {
        "Models": [{
            "Model": {
                "@texture": "texture.png",
                "BaseClass": "ModelBase",
                "Geometry": {
                    "Shape": [{
                        "@name": "Shape1",
                        "Offset": "0,0,0",
                        "Position": "-1,15,7",
                        "Rotation": "-6,0,0",
                        "Size": "2,9,1",
                        "TextureOffset": "0,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1,14,7",
                        "Rotation": "-6,18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "7,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.2,14,6.3",
                        "Rotation": "-6,36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "14,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,16,-1",
                        "Rotation": "0,0,6",
                        "Size": "1,8,2",
                        "TextureOffset": "21,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6.3,16,3.1",
                        "Rotation": "-6,72,0",
                        "Size": "2,8,1",
                        "TextureOffset": "28,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "5,15,4.9",
                        "Rotation": "-6,54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "35,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-1,14,-8",
                        "Rotation": "6,0,0",
                        "Size": "2,10,1",
                        "TextureOffset": "42,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1",
                        "Rotation": "0,0,-6",
                        "Size": "1,10,2",
                        "TextureOffset": "49,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.4,15,-7.3",
                        "Rotation": "6,18,0",
                        "Size": "2,9,1",
                        "TextureOffset": "56,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-5.5,15,-5.9",
                        "Rotation": "6,36,0",
                        "Size": "2,9,1",
                        "TextureOffset": "63,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7.1,14,-3.8",
                        "Rotation": "6,58,0",
                        "Size": "2,10,1",
                        "TextureOffset": "70,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1.5",
                        "Rotation": "6,72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "77,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1.5,14,-7.9",
                        "Rotation": "6,-18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "84,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.9,14,-7",
                        "Rotation": "6,-36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "91,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6,14,-5.4",
                        "Rotation": "6,-54,0",
                        "Size": "2,10,1",
                        "TextureOffset": "98,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7.4,14,-3.4",
                        "Rotation": "6,-72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "105,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6.9,15,1.2",
                        "Rotation": "-6,-72,0",
                        "Size": "2,9,1",
                        "TextureOffset": "112,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6,15,3.3",
                        "Rotation": "-6,-54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "119,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-4.7,16,5.1",
                        "Rotation": "-6,-36,0",
                        "Size": "2,8,1",
                        "TextureOffset": "0,20"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.1,16,6.2",
                        "Rotation": "-6,-18,0",
                        "Size": "2,8,1",
                        "TextureOffset": "7,20"
                    }, {
                        "@name": "Shape5",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,19,0",
                        "Rotation": "0,0,0",
                        "Size": "1,1,1",
                        "TextureOffset": "0,12"
                    }, {
                        "@name": "Shape6",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7,23,-7",
                        "Rotation": "0,0,0",
                        "Size": "14,1,14",
                        "TextureOffset": "14,13"
                    }]
                },
                "GlScale": "1,1,1",
                "Name": "Barrel",
                "TextureSize": "128,32"
            }
        }],
        "Name": "Barrel",
        "PreviewImage": "",
        "ProjectName": "Barrel",
        "ProjectType": "Minecraft"
    }
}

有没有办法用JavaScript将Qubble模型转换成Techne模型?

你有一个字符串,你想要回一个字符串?只是格式不同?这里肯定没有足够的信息来回答这个问题。这不是简单的通用JSON转换,而是两种特定复杂格式之间的转换。我不确定第一个对象是否包含所有必要的信息。如果您想获得这方面的帮助,您至少需要为这两种格式提供文档(或至少提供一个名称)。如前所述,这是不可回答的。您可以尝试在第一个JSON结构上使用
JSON.parse()
,假设它是一个字符串。如果是这样,那么它将把它转换成一个JavaScript对象。然后可以使用JavaScript修改它。您还可以使用
delete
关键字从JSON对象中删除项。还可以根据需要移动属性。使用
JSON.stringify()
将JSON对象转换为字符串,假设您希望它再次成为字符串。我建议您使用jsfiddle,这样我们就可以看到您已经尝试过做的事情&您在哪里遇到了困难。第一种格式是qbble,第二种格式是Techne@Qbotindustries,谢谢。看起来这两种格式都不是正式的文档格式,所以如果没有特别有用的东西存在,我不会感到惊讶,但是考虑到Minecraft社区的多产性,如果有什么东西存在,我也不会感到惊讶。
{
    "Techne": {
        "Models": [{
            "Model": {
                "@texture": "texture.png",
                "BaseClass": "ModelBase",
                "Geometry": {
                    "Shape": [{
                        "@name": "Shape1",
                        "Offset": "0,0,0",
                        "Position": "-1,15,7",
                        "Rotation": "-6,0,0",
                        "Size": "2,9,1",
                        "TextureOffset": "0,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1,14,7",
                        "Rotation": "-6,18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "7,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.2,14,6.3",
                        "Rotation": "-6,36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "14,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,16,-1",
                        "Rotation": "0,0,6",
                        "Size": "1,8,2",
                        "TextureOffset": "21,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6.3,16,3.1",
                        "Rotation": "-6,72,0",
                        "Size": "2,8,1",
                        "TextureOffset": "28,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "5,15,4.9",
                        "Rotation": "-6,54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "35,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-1,14,-8",
                        "Rotation": "6,0,0",
                        "Size": "2,10,1",
                        "TextureOffset": "42,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1",
                        "Rotation": "0,0,-6",
                        "Size": "1,10,2",
                        "TextureOffset": "49,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.4,15,-7.3",
                        "Rotation": "6,18,0",
                        "Size": "2,9,1",
                        "TextureOffset": "56,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-5.5,15,-5.9",
                        "Rotation": "6,36,0",
                        "Size": "2,9,1",
                        "TextureOffset": "63,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7.1,14,-3.8",
                        "Rotation": "6,58,0",
                        "Size": "2,10,1",
                        "TextureOffset": "70,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1.5",
                        "Rotation": "6,72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "77,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1.5,14,-7.9",
                        "Rotation": "6,-18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "84,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.9,14,-7",
                        "Rotation": "6,-36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "91,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6,14,-5.4",
                        "Rotation": "6,-54,0",
                        "Size": "2,10,1",
                        "TextureOffset": "98,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7.4,14,-3.4",
                        "Rotation": "6,-72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "105,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6.9,15,1.2",
                        "Rotation": "-6,-72,0",
                        "Size": "2,9,1",
                        "TextureOffset": "112,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6,15,3.3",
                        "Rotation": "-6,-54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "119,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-4.7,16,5.1",
                        "Rotation": "-6,-36,0",
                        "Size": "2,8,1",
                        "TextureOffset": "0,20"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.1,16,6.2",
                        "Rotation": "-6,-18,0",
                        "Size": "2,8,1",
                        "TextureOffset": "7,20"
                    }, {
                        "@name": "Shape5",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,19,0",
                        "Rotation": "0,0,0",
                        "Size": "1,1,1",
                        "TextureOffset": "0,12"
                    }, {
                        "@name": "Shape6",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7,23,-7",
                        "Rotation": "0,0,0",
                        "Size": "14,1,14",
                        "TextureOffset": "14,13"
                    }]
                },
                "GlScale": "1,1,1",
                "Name": "Barrel",
                "TextureSize": "128,32"
            }
        }],
        "Name": "Barrel",
        "PreviewImage": "",
        "ProjectName": "Barrel",
        "ProjectType": "Minecraft"
    }
}