我用以下代码创建了上传文本文件:
var koloader = new THREE.FileLoader();
koloader.load('Koordinate.txt',
function ( data ) {
const kord = data.split('\n').map(line =>line.trim()).map(line => line
.split(' ') // split by ' '
.map(parseFloat),line => line
.split(' ') // split by ' '
.map(parseFloat)) // and parse the parts to numbers
.map(([ x, y, z, w]) => ({ x, y, z, w }));
var dolzina = kord.length;
dolzList = dolzina;
//var pointList = [];
for( let i = 0; i < dolzina; i++){
var temp = new THREE.Vector3(kord[i].x,kord[i].y,kord[i].z);
pot[i] = new THREE.Vector3(temp.x,temp.y,temp.z);
casi[i] = kord[i].w;
droneFlightLine.vertices.push(new THREE.Vector3(kord[i].x,kord[i].y,kord[i].z));
}
flighLine = new THREE.Line( droneFlightLine, materialG );
},
此代码获取x,y,z和我保存在Koordinate.txt文件中的时间坐标。 我现在想创建一个文件对话框(也许是输入标签)并通过此对话框加载文件。示例:我单击按钮,选择此txt文件,然后像下面的代码一样向我加载该文件。