MCPcopy Create free account
hub / github.com/NikLever/ThreeJS-PathEditor / getCameraOffset

Method getCameraOffset

preview.js:78–97  ·  view source on GitHub ↗
(mesh)

Source from the content-addressed store, hash-verified

76 }
77
78 getCameraOffset(mesh) {
79 const geometry = mesh.geometry;
80
81 geometry.computeBoundingBox();
82
83 const theta = 20 * (Math.PI/180.0);
84 const halfwidth = (geometry.boundingBox.max.x - geometry.boundingBox.min.x)/2;
85 //y = sin(t) * sc => sc = y/sin(t)
86 let scale = halfwidth / Math.sin( theta );
87 //x = cos(t) * sc =>
88 let posZ = (Math.cos( theta ) * scale) * 1.5;
89
90 const halfheight = (geometry.boundingBox.max.y - geometry.boundingBox.min.y)/2;
91 //y = sin(t) * sc => sc = y/sin(t)
92 scale = halfheight / Math.sin( theta );
93 //x = cos(t) * sc =>
94 posZ = Math.max( posZ, (Math.cos( theta ) * scale) * 1.5 );
95
96 return posZ;
97 }
98
99 getCenterPoint(mesh) {
100 const middle = new Vector3();

Callers 1

showMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected