xzw il y a 5 mois
Parent
commit
1c2703f993
2 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 5 1
      src/custom/objects/TextSprite.js
  2. 1 0
      src/custom/objects/tool/Measure.js

+ 5 - 1
src/custom/objects/TextSprite.js

@@ -190,7 +190,7 @@ export class TextSprite extends THREE.Object3D{
             if (this.textBorderThick) {
             if (this.textBorderThick) {
                 context.strokeStyle = 'rgba(' + this.textBorderColor.r + ',' + this.textBorderColor.g + ',' + this.textBorderColor.b + ',' + this.textBorderColor.a + ')'
                 context.strokeStyle = 'rgba(' + this.textBorderColor.r + ',' + this.textBorderColor.g + ',' + this.textBorderColor.b + ',' + this.textBorderColor.a + ')'
                 context.lineWidth = this.textBorderThick * r
                 context.lineWidth = this.textBorderThick * r
-                context.strokeText(this.text[i], x, y)
+                context.strokeText(texts[i], x, y)
             }
             }
                
                
               
               
@@ -307,6 +307,10 @@ function breakLinesForCanvas(text, context, width, font) {
     return result;
     return result;
 } //'使用很寻常的二分查找,如果某一个位置之前的文字宽度小于等于设定的宽度,并且它之后一个字之前的文字宽度大于设定的宽度,那么这个位置就是文本的换行点。上面只是找到一个换行点,对于输入的一段文本,需要循环查找,直到不存在这样的换行点为止, 完整的代码如下',
 } //'使用很寻常的二分查找,如果某一个位置之前的文字宽度小于等于设定的宽度,并且它之后一个字之前的文字宽度大于设定的宽度,那么这个位置就是文本的换行点。上面只是找到一个换行点,对于输入的一段文本,需要循环查找,直到不存在这样的换行点为止, 完整的代码如下',
 
 
+
+
+//待改进:breakLinesForCanvas后的lineSpace稍小于预设的[]换行的lineSpace, 用于测量标签
+
 /* 
 /* 
 function wrapText(text, maxWidth) {  
 function wrapText(text, maxWidth) {  
   // 创建一个 canvas 元素来测量文本宽度  
   // 创建一个 canvas 元素来测量文本宽度  

+ 1 - 0
src/custom/objects/tool/Measure.js

@@ -60,6 +60,7 @@ const mainLabelProp = {
     maxOcclusionFactor:0.3,
     maxOcclusionFactor:0.3,
     maxClipFactor:0.8,
     maxClipFactor:0.8,
     maxLineWidth: 300,
     maxLineWidth: 300,
+    lineSpace:6
     
     
 }
 }
 const subLabelProp = { 
 const subLabelProp = {