Hello,
i am loading .stl file directly ,it work fine.
but i want load that stl file on button click event ,i wrote code but it give error on console given below
And my code is :
var button = document.getElementById("btn_img");
button.addEventListener('click',function (){
decorative_frame();
});
var loader = new THREE.STLLoader();
function decorative_frame(){
loader.load( "deco_frame.stl",function(geometry1) {
geometry = new THREE.Geometry().fromBufferGeometry( geometry1 );
var mesh1 = new THREE.Mesh(geometry);
mesh1.name = 'deco_frame';
var boundingBox = new THREE.Box3().setFromObject(mesh1);
var distance = boundingBox.min.distanceTo(boundingBox.max);
var center = boundingBox.getCenter();
camera.position.x = 0;
camera.position.y = 0;
camera.position.z = center.z + distance/0.8;
camera.lookAt(center);
cameraTarget = center;
mesh1.position.set(-10, -10, 0);
scene.add(mesh1);
});
}
How do I solve it?