Three JS Keep Label Size On Zoom

前端 未结 4 532
臣服心动
臣服心动 2020-12-05 16:08

I\'m working on a solar system in three.js and am curious if there is an easy way to make the labels for the planets I have below all show up the same size regardless of how

4条回答
  •  独厮守ぢ
    2020-12-05 16:23

    For the benefit of future visitors, the transform controls example does exactly this:

    https://threejs.org/examples/misc_controls_transform.html

    Here's how its done in the example code:

    var factor;
    if ( this.camera.isOrthographicCamera ) {
    	factor = ( this.camera.top - this.camera.bottom ) / this.camera.zoom;
    } else {
    	factor = this.worldPosition.distanceTo( this.cameraPosition ) * Math.min( 1.9 * Math.tan( Math.PI * this.camera.fov / 360 ) / this.camera.zoom, 7 );
    }
    handle.scale.set( 1, 1, 1 ).multiplyScalar( factor * this.size / 7 );

提交回复
热议问题