shx-3d-render

main
Jan Umbach 2024-06-13 21:30:27 +02:00
parent 350899b1d1
commit 0da55ff310
1 changed files with 23 additions and 13 deletions

View File

@ -145,21 +145,9 @@
tJS_renderer.domElement.style.height = height + 'px';
tJS_renderer.domElement.classList.add('shx-threejs-renderer');
tJS_renderer.setAnimationLoop(animate);
container.appendChild(tJS_renderer.domElement);
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
tJS_scene.add(cube);
tJS_camera.position.z = 5;
function animate() {
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
tJS_renderer.render(tJS_scene, tJS_camera);
}
});
@ -188,6 +176,28 @@
}).then((blob) => {
// log size in kB
console.log(blob.size / 1024 + 'kB');
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const stl_cube = new THREE.STLLoader();
stl_cube.load(blob, function (geometry) {
stl_cube = new THREE.Mesh(geometry, material);
tJS_scene.add(stl_cube);
tJS_camera.position.z = 5;
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);
}
});
});
}