读取Txt文件并在three.js中填写Vector3

时间:2019-01-06 14:16:32

标签: three.js

我有一个.txt文件,其中包含无人机飞行的x,y,z坐标 示例:

121.12 98.12 1.02

122.98 98.88 3.05

第一列是x,第二列是y,第三列是z。

我尝试使用文件加载器并将数据输出到控制台,但是现在我不知道如何将x,y,z保存到Vector3

    var loader = new THREE.FileLoader();

//load a text file and output the result to the console
loader.load(
    // resource URL
    'example.txt',

    // onLoad callback
    function ( data ) {
        // output the text to the console
        console.log( data )
    }

1 个答案:

答案 0 :(得分:0)

尝试train_data = np.array(np.arange(1, 100, 0.5)) test_data = np.array(np.arange(100, 120, 0.5)) train_labels = np.array(list(map(lambda x : math.cos(x), np.arange(1, 100, 0.5)))) model = CatBoostRegressor(iterations=100, learning_rate=0.01, depth=12, verbose=False) model.fit(train_data, train_labels) preds = model.predict(test_data) plt.plot(preds) plt.show() 以便将您的字符串拆分为子字符串数组。接下来,您遍历数组并像data.split( '\n' )那样分割每一行。然后,您可以将结果值解析为浮点数,并将其分配给line.split(" ")的新实例。