• Hi,
    we have a lot of models and we using SOLIDWORKS XR to make .glb files for the 3D viewer. And the models are displayed in your 3D Viewer. But we always have the problem, that the model is to big or to near.

    Is there a way, that your viewer can use the camara that is included in the glb file? Or any other way, that we just can upload the glb without editing the view / camara / scale of the model.

    I mean even the 3D viewer in Windows 10 always show the model in the right angle / view.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter exogenia

    (@exogenia)

    So i looked into your code and found this part. Is this the auto scale view?


    function woo3dvFitCameraToObject( camera, object, offset, controls ) {	if (woo3dv.object.type!='Scene') {		var mesh_width = woo3dv.boundingBox.max.x - woo3dv.boundingBox.min.x;		var mesh_length = woo3dv.boundingBox.max.y - woo3dv.boundingBox.min.y;		var mesh_height = woo3dv.boundingBox.max.z - woo3dv.boundingBox.min.z;		var max_side = Math.max(mesh_width, mesh_length, mesh_height)	    	const plane_width = max_side * 100;		var aspect = Math.max(mesh_width, mesh_length)/mesh_height;		woo3dv.camera.position.set(max_side*woo3dv.resize_scale, max_side*woo3dv.resize_scale, max_side*woo3dv.resize_scale);/*		if (aspect>1) {			woo3dv.controls.target = new THREEW.Vector3(0, 0, 0);		}		else {			woo3dv.controls.target = new THREEW.Vector3(0, mesh_height/2, 0);		}*/		woo3dv.controls.target = new THREEW.Vector3(0, 0, 0);		woo3dv.camera.far=plane_width*5;		woo3dv.camera.updateProjectionMatrix();		return;	}	offset =  offset || 1.35;	const boundingBox = new THREEW.Box3().setFromObject(object);	const center = boundingBox.getCenter(new THREEW.Vector3());	const size = boundingBox.getSize(new THREEW.Vector3());	const maxDim = Math.max( size.x, size.y, size.z );	const fov = camera.fov * ( Math.PI / 180 );    	const plane_width = maxDim * 100;	cameraZ = Math.abs( maxDim / 2 * Math.tan( fov * 2 ) ); 	r=camera.position.z*offset;	cameraZ *= offset; 	woo3dv.scene.updateMatrixWorld();         var objectWorldPosition = new THREEW.Vector3();         objectWorldPosition.setFromMatrixPosition( object.matrixWorld );	const directionVector = camera.position.sub(objectWorldPosition);           const unitDirectionVector = directionVector.normalize();         camera.position = unitDirectionVector.multiplyScalar(cameraZ);         camera.lookAt(objectWorldPosition);         const minZ = boundingBox.min.z;        const cameraToFarEdge = ( minZ < 0 ) ? -minZ + cameraZ : cameraZ - minZ;            camera.far = plane_width * 5;        camera.updateProjectionMatrix();            if ( controls ) {                controls.target = center;            if (woo3dv.zoom_distance_max!='0') {            	controls.maxDistance = cameraToFarEdge * 2;            }	    if (typeof(controls.saveState)!='undefined')	            controls.saveState();            } else {            camera.lookAt( center )        }    }
    Thread Starter exogenia

    (@exogenia)

    Hi. so maybe the glb files can help to find the problem with auto scaling and position

    Here is the link to the glb file:
    https://newaricon2022.aricon.de/wp-content/uploads/2023/06/fd-e_300.glb

    Plugin Author fuzzoid

    (@fuzzoid)

    Hi,

    Try using the “remember camera position” in the shortcode builder

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘SOLIDWORKS XR and Camara/Scale’ is closed to new replies.