|
@@ -6,10 +6,10 @@
|
|
|
|
|
|
import * as THREE from "../../../libs/three.js/build/three.module.js";
|
|
|
import Sprite from './Sprite.js'
|
|
|
-
|
|
|
+import Common from '../utils/Common.js';
|
|
|
|
|
|
//可能还是要用html写,因为要加按钮和图片
|
|
|
-
|
|
|
+
|
|
|
export class TextSprite extends THREE.Object3D{
|
|
|
//注:为了分两层控制scale,不直接extend Sprite
|
|
|
constructor( options={}){
|
|
@@ -33,10 +33,10 @@ export class TextSprite extends THREE.Object3D{
|
|
|
this.textBorderThick = options.textBorderThick || 0
|
|
|
this.fontface = 'Arial';
|
|
|
this.fontsize = options.fontsize || 16;
|
|
|
- this.textBorderColor = options.textBorderColor || { r: 0, g: 0, b: 0, a: 0.0 };
|
|
|
- this.backgroundColor = options.backgroundColor || { r: 255, g: 255, b: 255, a: 1.0 };
|
|
|
- this.textColor = options.textColor || {r: 0, g: 0, b: 0, a: 1.0};
|
|
|
- this.borderColor = options.borderColor || { r: 0, g: 0, b: 0, a: 0.0 };
|
|
|
+ this.textBorderColor = options.textBorderColor ? Common.CloneObject(options.textBorderColor):{ r: 0, g: 0, b: 0, a: 0.0 };
|
|
|
+ this.backgroundColor = options.backgroundColor ? Common.CloneObject(options.backgroundColor):{ r: 255, g: 255, b: 255, a: 1.0 };
|
|
|
+ this.textColor = options.textColor ? Common.CloneObject(options.textColor):{r: 0, g: 0, b: 0, a: 1.0};
|
|
|
+ this.borderColor = options.borderColor ? Common.CloneObject(options.borderColor):{ r: 0, g: 0, b: 0, a: 0.0 };
|
|
|
this.borderRadius = options.borderRadius || 6;
|
|
|
this.margin = options.margin
|
|
|
if(options.text != void 0)this.setText(options.text)
|
|
@@ -57,19 +57,19 @@ export class TextSprite extends THREE.Object3D{
|
|
|
}
|
|
|
|
|
|
setTextColor(color){
|
|
|
- this.textColor = color;
|
|
|
+ this.textColor = Common.CloneObject(color);
|
|
|
|
|
|
this.updateTexture();
|
|
|
}
|
|
|
|
|
|
setBorderColor(color){
|
|
|
- this.borderColor = color;
|
|
|
+ this.borderColor = Common.CloneObject(color);
|
|
|
|
|
|
this.updateTexture();
|
|
|
}
|
|
|
|
|
|
setBackgroundColor(color){
|
|
|
- this.backgroundColor = color;
|
|
|
+ this.backgroundColor = Common.CloneObject(color);
|
|
|
|
|
|
this.updateTexture();
|
|
|
}
|