Skip to content

Commit b7c9099

Browse files
committed
Editor: Scale PointLightHelper based on camera distance.
1 parent 47df54e commit b7c9099

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

editor/js/Editor.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,32 @@ Editor.prototype = {
396396

397397
helper = new THREE.PointLightHelper( object, 1 );
398398

399+
helper.matrix = new THREE.Matrix4();
400+
helper.matrixAutoUpdate = true;
401+
402+
const light = object;
403+
const editor = this;
404+
405+
helper.updateMatrixWorld = function () {
406+
407+
light.getWorldPosition( this.position );
408+
409+
const distance = editor.viewportCamera.position.distanceTo( this.position );
410+
this.scale.setScalar( distance / 30 );
411+
412+
this.updateMatrix();
413+
this.matrixWorld.copy( this.matrix );
414+
415+
const children = this.children;
416+
417+
for ( let i = 0, l = children.length; i < l; i ++ ) {
418+
419+
children[ i ].updateMatrixWorld();
420+
421+
}
422+
423+
};
424+
399425
} else if ( object.isDirectionalLight ) {
400426

401427
helper = new THREE.DirectionalLightHelper( object, 1 );

0 commit comments

Comments
 (0)