1. 样条曲线类

继承自 MeshLine 位于:BOS3D.Geometry.SplineCurve

1.1. 实例化

名称 说明 类型 是否必须 示例
points 构成曲线的点,数量至少为 2 数组 Array [{ "x": 0,"y": 0,"z": 0},{"x": 0,"y": 4000,"z": 0},]
color 线条颜色,默认 #21a7e5 BOS3D.Color false new BOS3D.Color(1,0,0)
width 线条宽度 ,默认 1 数字 Number 1000
style 线条样式, 对象 Object 1000
type 曲线类型 字符串 String "spline"
let points = [
    {
        x: 0,
        y: 0,
        z: 0,
    },
    {
        x: 0,
        y: 4000,
        z: 0,
    },
];
let color = new BOS3D.Color(255, 52, 0, 1.0);
let width = 40;
let style = {
    lineType: "Continuous",
    lineStyle: null,
};
let splineCurve = new BOS3D.Geometry.SplineCurve(points, color, width, style);

1.2. 属性

1.3. 方法

1.3.1. setColor

设置曲线的颜色

名称 说明 类型 是否必须 示例
color 颜色值 颜色对象 BOS3D.Color new BOS3D.Color("#00ff00")
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置水面的颜色
 * @function setColor
 * @param {BOS3D.Color} color 曲线颜色
 * @return {void}
 */
splineCurve.setColor(new BOS3D.Color("#00ff00"));

1.3.2. getColor

获取曲线颜色

返回值说明 类型 示例
曲线颜色 颜色对象 BOS3D.Color {r:1,g:1,b:1,a:1}

调用方式:

/**
 * 获取曲线的颜色
 * @function  getColor
 * @return {Color} 曲线颜色
 */
splineCurve.getColor();

1.3.3. getWidth

获取曲线宽度

返回值说明 类型 示例
曲线宽度 数字 Number 123

调用方式:

/**
 * 获取曲线宽度
 * @function getWidth
 * @returns {Number} 曲线宽度
 */
splineCurve.getWidth();

1.3.4. setWidth

设置曲线宽度

名称 说明 类型 是否必须 示例
width 曲线宽度 数字 Number 1000
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置曲线宽度
 * @function setWidth
 * @param {Number} width 曲线宽度
 * @return {void}
 */
splineCurve.setWidth(1000);

1.3.5. getStyle

获取曲线样式

返回值说明 类型 示例
曲线样式 Object 对象 {"lineType": "Continuous","lineStyle": null}

调用方式:

/**
 * 获取曲线样式
 * @function getStyle
 * @returns {Object} 曲线样式
 */
splineCurve.getStyle();

1.3.6. setStyle

设置曲线样式

名称 说明 类型 是否必须 示例
style 曲线样式 对象 Object {"lineType": "Continuous","lineStyle": null}
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置曲线样式
 * @function setStyle
 * @param {Object} style 曲线样式(实线:{"lineType": "Continuous","lineStyle": null},虚线: {"lineType": "Dashed","lineStyle": {"dashLength": 100,"gapLength": 100}})
 * @return {void}
 */
splineCurve.setStyle({
    lineType: "Continuous",
    lineStyle: null,
});

1.3.7. getType

获取曲线类型

返回值说明 类型 示例
曲线类型 字符串 String “spline”或“polyline”

调用方式:

/**
 * 获取曲线类型
 * @function getType
 * @returns {String} 曲线类型 (样条线为"spline",折线为"polyline")
 */
splineCurve.getType();

1.3.8. setType

设置曲线类型

名称 说明 类型 是否必须 示例
type 曲线类型 字符串 String “spline”
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置曲线类型
 * @function setType
 * @param {String} type 曲线类型 (样条线为"spline",折线为"polyline")
 * @return {void}
 */
splineCurve.setType("trail");

1.3.9. setMap

设置贴图

名称 说明 类型 是否必须 示例
options 参数 对象 Object {}}
options.src 贴图路径 字符串 String "./123.jpg"
options.scale 缩放比例,默认为 1 数字 Number 1
options.offset 贴图偏移,默认为 0 数字 Number 0
options.enableColorOverride 是否允许颜色覆盖,默认为 false 布尔值 Boolean true
callback 贴图加载成功回调函数 函数 Function function(){}
onError 贴图加载失败的回调函数 函数 Function function(){}
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置贴图
 * @function setMap
 * @param {Object}  options 参数
 * @param {String}  options.src 贴图路径,必填
 * @param {Number}  options.scale 缩放比例,默认为1
 * @param {Number}  options.offset 贴图偏移,默认为0
 * @param {Boolean} options.enableColorOverride 是否允许颜色覆盖,默认为false
 * @param {Function} callback 贴图加载成功回调函数
 * @param {Function} onError 贴图加载失败的回调函数
 * @return {void}
 */
splineCurve.setMap({
    src: "./123.jpg",
    // 允许颜色覆盖
    enableColorOverride: false,
});

1.3.10. highlight

高亮曲线

名称 说明 类型 是否必须 示例
null null null null
返回值说明 类型 示例
null null

调用方式:

/**
 * 高亮曲线
 * @function highlight
 * @returns {void}
 */
splineCurve.highlight();

1.3.11. cancelHighlight

取消高亮

名称 说明 类型 是否必须 示例
null null null null
返回值说明 类型 示例
null null

调用方式:

/**
 * 取消高亮
 * @function cancelHighlight
 * @return {void}
 */
splineCurve.cancelHighlight();

1.3.12. getWidthType

获取宽度类型

返回值说明 类型 示例
宽度类型 字符串 String “DisplayWidth”或“ActualWidth”

调用方式:

/**
 * 获取宽度类型
 * @function getWidthType
 * @returns {String} type 宽度类型,"DisplayWidth"为显示宽度,单位为pixel,"ActualWidth"为实际宽度,单位跟随场景单位。
 */
splineCurve.getWidthType();

1.3.13. setWidthType

设置宽度类型

名称 说明 类型 是否必须 示例
type 宽度类型 字符串 String “ActualWidth”
返回值说明 类型 示例
null null

调用方式:

/**
 * 设置宽度类型
 * @function setWidthType
 * @returns {String} type 宽度类型,"DisplayWidth"为显示宽度,单位为pixel,"ActualWidth"为实际宽度,单位跟随场景单位。
 */
splineCurve.setWidthType("DisplayWidth");

1.3.14. show

显示

名称 说明 类型 是否必须 示例
null null null null
返回值说明 类型 示例
null null

调用方式:

/**
 * 显示
 * @function show
 * @return {void}
 */
splineCurve.show();

1.3.15. hide

隐藏

名称 说明 类型 是否必须 示例
null null null null
返回值说明 类型 示例
null null

调用方式:

/**
 * 隐藏
 * @function hide
 * @return {void}
 */
splineCurve.hide();

1.3.16. getPointByLength

获取曲线上某距离处的点坐标

名称 说明 类型 是否必须 示例
length 长度 数字 Number 100
返回值说明 类型 示例
点对象 对象 Object {x:1,y:1,z:1}}

调用方式:

/**
 * 获取曲线上某距离处的点坐标
 * @function getPointByLength
 * @param {Number} length 长度 (当length<0或length>curve.length时,返回为空)
 * @returns {Object} 点对象
 */
splineCurve.getPointByLength(100);

1.3.17. getPointByParameter

获取曲线上某比例处的点坐标

名称 说明 类型 是否必须 示例
parameter 曲线比例 数字 Number 0.5
返回值说明 类型 示例
点对象 对象 Object {x:1,y:1,z:1}}

调用方式:

/**
 * 获取曲线上某比例处的点坐标
 * @function getPointByParameter
 * @param {Number} parameter 曲线比例,取值范围[0,1] (当parameter<0或parameter>1时,返回为空)
 * @returns {Object} 点对象
 */
splineCurve.getPointByParameter(0.1);

1.3.18. getTangentByLength

获取曲线上某距离处的切向量

名称 说明 类型 是否必须 示例
length 长度 数字 Number 100
返回值说明 类型 示例
点对象 对象 Object {x:1,y:1,z:1}}

调用方式:

/**
 * 获取曲线上某距离处的切向量
 * @function getTangentByLength
 * @param {Number} length 长度 (当length<0或length>curve.length时,返回为空)
 * @returns {Object} 切向量
 */
splineCurve.getTangentByLength(100);

1.3.19. getTangentByParameter

获取曲线上某比例处的切向量

名称 说明 类型 是否必须 示例
parameter 曲线比例 数字 Number 0.5
返回值说明 类型 示例
点对象 对象 Object {x:1,y:1,z:1}}

调用方式:

/**
 * 获取曲线上某比例处的切向量
 * @function getTangentByParameter
 * @param {Number} parameter 曲线比例,取值范围[0,1] (当parameter<0或parameter>1时,返回为空)
 * @returns {Object} 切向量
 */
splineCurve.getTangentByParameter(0.5);

1.3.20. stretch

拉伸曲线

名称 说明 类型 是否必须 示例
intensity 向上拉伸强度,默认值为 0.5 数字 Number 0.5
parameter 两点之间线段的拉伸位置,默认值为 0.5,取值范围(0,1),越小越靠近起点 数字 Number 0.5
返回值说明 类型 示例
null null

调用方式:

/**
 * 拉伸曲线
 * @function stretch
 * @param {Number} intensity 向上拉伸强度,默认值为0.5
 * @param {Number} parameter 两点之间线段的拉伸位置,默认值为0.5,取值范围(0,1),越小越靠近起点
 * @return {void}
 */
splineCurve.stretch(0.5, 0.5);
版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-06-27 15:28:07

results matching ""

    No results matching ""