I have the frequency, time and amplitude array values which have been loading using the rest api and i need to create the 3d surface plot using that data values using planeGeometry How can i do it so.
import * as THREE from '../modules/three.module.js'
import { OrbitControls } from "../modules/OrbitControls.js";
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
var renderer = new THREE.WebGLRenderer({ antialias: true, resolution: window.devicePixelRatio, alpha: true });
renderer.setPixelRatio(window.devicePixelRatio)
renderer.setClearColor(0x000)
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
camera.position.z = 25;
const url = "http://localhost:3000/getdata"
const body = {
"assetEcn": "H2BPA27",
"firstRequest": true,
"dateRange": {
"fromDate": 1680287400000,
"toDate": 1682879400000
},
"type": 4265,
"sensors": [],
"directions": [
"x"
]
}
$.ajax({
async:true,
url: url,
method: 'POST',
contentType: "application/json",
headers:{
"Authorization": 'Basic Y2x5bm46SHlkZVZpbCM3MQ==',
},
data: JSON.stringify(body),
dataType: 'json',
success: function (data) {
segregateData(data)
},
error: function (XHR, textStatus, errorThrown) {
console.log('File load failed!');
console.log(errorThrown);
}
});
})
function segregateData(data){
var orgData= data.VibConditionData.harmonics;
// var orgData = data.harmonics;
var time = [];
var amp = [];
var freq = [];
for(let i = 0;i<orgData.length;i++){
time.push(orgData[i].time)
amp.push(orgData[i].amplitude)
freq.push(orgData[i].frequency)
}
const planeGeometry = new THREE.PlaneGeometry(1,10,19,19);
console.log(planeGeometry);
const planeMaterial = new THREE.MeshBasicMaterial({color:"white",wireframe:true});
const planeMesh = new THREE.Mesh(planeGeometry,planeMaterial)
scene.add(planeMesh)
}
var controls = new OrbitControls(camera,renderer.domElement)
function animate(){
requestAnimationFrame(animate)
renderer.render(scene,camera)
}
animate()