Преглед изворни кода

Editor: Scale PointLightHelper based on camera distance.

Mr.doob пре 2 месеци
родитељ
комит
b7c9099db9
1 измењених фајлова са 26 додато и 0 уклоњено
  1. 26 0
      editor/js/Editor.js

+ 26 - 0
editor/js/Editor.js

@@ -396,6 +396,32 @@ Editor.prototype = {
 
 
 					helper = new THREE.PointLightHelper( object, 1 );
 					helper = new THREE.PointLightHelper( object, 1 );
 
 
+					helper.matrix = new THREE.Matrix4();
+					helper.matrixAutoUpdate = true;
+
+					const light = object;
+					const editor = this;
+
+					helper.updateMatrixWorld = function () {
+
+						light.getWorldPosition( this.position );
+
+						const distance = editor.viewportCamera.position.distanceTo( this.position );
+						this.scale.setScalar( distance / 30 );
+
+						this.updateMatrix();
+						this.matrixWorld.copy( this.matrix );
+
+						const children = this.children;
+
+						for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+							children[ i ].updateMatrixWorld();
+
+						}
+
+					};
+
 				} else if ( object.isDirectionalLight ) {
 				} else if ( object.isDirectionalLight ) {
 
 
 					helper = new THREE.DirectionalLightHelper( object, 1 );
 					helper = new THREE.DirectionalLightHelper( object, 1 );

粤ICP备19079148号