1. 文字绘制

1.1. 初始化

初始化参数 说明 类型 是否必填
viewer viewer3D 实例 object Y

调用示例

const textLoader = new BOS3D.Plugins.TextLoader({
    viewer: viewer3D,
});

1.2. 方法

1.2.1. addText

增加文本

名称 说明 类型 是否必须 补充说明
opt 文本选项 object Y ---
opt.text 文字 string Y ---
opt.fontName 字体名称的拼音 string Y 仅支持楷体(kaiti),宋体(songti),黑体(heiti),隶书(lishu)
opt.fontSize 文字大小 number N 默认 100
opt.color 颜色 string N 默认#ff0000
opt.matrix 文字矩阵 typeof THREE.Matrix4 N 不要和其他改变位置和旋转的参数混用
opt.position 位置数组 number[] N ---
opt.rotation 旋转数组 number[] N ---
返回值说明 类型 补充说明
Promise 对象 Promise<{code: "success", id: string} or {code: "error", err: object}> 成功时会返回文字 id

示例

textLoader.addText({
    text: "盈嘉互联",
    fontName: "kaiti",
    fontSize: 10000,
    color: "#ff00ff",
});

demo 示例

示例名称 示例地址
添加文字标签 去体验

1.2.2. removeText

移除文本

名称 说明 类型 是否必须
id 文字 id string Y

示例

textLoader.removeText("I-am-text-id");

demo 示例

示例名称 示例地址
移除文字标签 去体验

1.2.3. setPosition

设置文字位置

名称 说明 类型 是否必须
id 文字 id string Y
pos 三维坐标点 number[] Y

示例

textLoader.setPosition("id", [1000, 2000, 3000]);

1.2.4. setMatrix

设置文字矩阵

名称 说明 类型 是否必须
id 文字 id string Y
mat 矩阵 typeof THREE.Matrix4 Y
textLoader.setMatrix("id", new THREE.Matrix4());

1.2.5. setRotation

设置旋转

名称 说明 类型 是否必须
id 文字 id string Y
rotate 旋转矩阵 number[] Y
textLoader.setRotation("id", [Math.PI, 0, 0]);

1.2.6. getTextIDs

获取文字 id

示例

textLoader.getTextIDs();

1.2.7. dragText

拖拽文字

名称 说明 类型 是否必须
id 文字 id string Y

示例

textLoader.dragText(id);

1.2.8. saveDragText

保存拖拽结果

示例

textLoader.saveDragText();
版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-06-27 15:28:07

results matching ""

    No results matching ""