shx-3d-render

main
Jan Umbach 2024-06-13 21:37:51 +02:00
parent 9df4a83e40
commit a5aace40d0
1 changed files with 11 additions and 11 deletions

View File

@ -110,6 +110,7 @@
let tJS_renderer = null;
this.tJS = {
script: threeJS,
scene: tJS_scene,
camera: tJS_camera,
renderer: tJS_renderer
@ -168,6 +169,7 @@
renderView() {
// request data from server
let tJS = this.tJS;
fetch('https://render.shinnex.de/render/' + this.currentVariant, { method: 'POST', body: JSON.stringify(globalInputFormsObjValues[this.currentVariant]) })
.then((response) => {
@ -177,25 +179,23 @@
// log size in kB
console.log(blob.size / 1024 + 'kB');
const material = new threeJS.MeshBasicMaterial({ color: 0x00ff00 });
const material = new tJS.script.MeshBasicMaterial({ color: 0x00ff00 });
const stl_cube = new threeJS.STLLoader();
const stl_cube = new tJS.script.STLLoader();
stl_cube.load(blob, function (geometry) {
stl_cube = new threeJS.Mesh(geometry, material);
stl_cube = new tJS.script.Mesh(geometry, material);
tJS.scene.add(stl_cube);
tJS.camera.position.z = 5;
tJS_scene.add(stl_cube);
tJS_camera.position.z = 5;
tJS_renderer.setAnimationLoop(animate);
tJS.renderer.setAnimationLoop(animate);
function animate() {
stl_cube.rotation.x += 0.01;
stl_cube.rotation.y += 0.01;
tJS_renderer.render(tJS_scene, tJS_camera);
tJS.renderer.render(tJS.scene, tJS.camera);
}
});
});