Skip to content

辅助器

addAxesHelper

添加坐标轴辅助器

样例:

定义:

ts
interface AxesHelperOptions extends BaseHelperOptions {
  axesLength?: number;
}

function addAxesHelper(options: AxesHelperOptions): AxesHelper;

用法:

js
ssp.addAxesHelper({
  id: 'test_axesHelper',
  axesLength: 1000,
});

参数:

options

  • 描述: 可配置项
  • 必填:
  • 类型: AxesHelperOptions
AxesHelperOptions
属性描述类型必填默认值
id唯一 IDstring
axesLength轴线长度number1000

addGridHelper

添加网格辅助器

定义:

ts
interface GridHelperOptions extends BaseHelperOptions {
  size?: number;
  divisions?: number;
  color?: IColor;
  position?: Position;
  rotation?: Rotation;
  scale?: Scale;
}

function addGridHelper(options: GridHelperOptions): GridHelper;

用法:

js
ssp.addGridHelper({
  id: 'test_gridHelper',
  size: 1000,
  divisions: 20,
  color: '#fff',
});

options

  • 描述: 可配置项
  • 必填:
  • 类型: GridHelperOptions
GridHelperOptions
属性描述类型必填默认值
id唯一 IDstring
size网格尺寸number1000
divisions网格横纵向分割格数number20
color网格颜色IColor#ffffff
position空间位置Position{ x: 0, y: 0, z: 0 }
rotation空间旋转弧度Rotation{ x: 0, y: 0, z: 0 }
scale缩放比Scale{ x: 1, y: 1, z: 1 }

addPlaneHelper

添加面辅助器

定义:

ts
interface PlaneHelperOptions extends BaseHelperOptions {
  width?: number;
  height?: number;
  color?: IColor;
  opacity?: number;
  position?: Position;
  rotation?: Rotation;
  scale?: Scale;
}

function addPlaneHelper(options: PlaneHelperOptions): BaseMesh;

用法:

js
ssp.addPlaneHelper({
  id: 'test_planeHelper',
  width: 500,
  height: 500,
  color: '#00ff00',
  opacity: 0.2,
  position: { x: 0, y: 0, z: 0 },
  rotation: { x: 0, y: 0, z: 0 },
});

参数:

options

  • 描述: 可配置项
  • 必填:
  • 类型: PlaneHelperOptions
PlaneHelperOptions
属性描述类型必填默认值
id唯一 IDstring
width宽度number500
height高度number500
color颜色IColor#00ff00
opacity不透明度number0.2
position空间位置Position{ x: 0, y: 0, z: 0 }
rotation空间旋转弧度Rotation{ x: 0, y: 0, z: 0 }
scale缩放比Scale{ x: 1, y: 1, z: 1 }

addBoxHelper

添加包围盒辅助器

定义:

ts
interface BoxHelperOptions extends BaseHelperOptions {
  box: Box3;
  color?: IColor;
}

function addBoxHelper(options: BoxHelperOptions): Box3Helper;

用法:

js
ssp.addBoxHelper({
  id: 'test_boxHelper',
  box: ssp.getObjectById('xxx_model').getBoundingBox(),
  color: '#00ff00',
});

参数:

options

  • 描述: 可配置项
  • 必填:
  • 类型: BoxHelperOptions
BoxHelperOptions
属性描述类型必填默认值
id唯一 IDstring
box包围盒string
color辅助线条颜色IColor#00ff00

addGroundHelper

添加地面辅助器

样例:

定义:

ts
interface GroundHelperOptions extends BaseHelperOptions {
  imgUrl: string;
  width?: number;
  height?: number;
  opacity?: number;
  position?: Position;
  rotation?: Position;
  scale?: Scale;
  repeat?: IVector2;
}

function addGroundHelper(options: GroundHelperOptions): Promise<Ground>;

用法:

js
await ssp.addGroundHelper({
  id: 'test_ground'
  imgUrl: 'http://xxx.com/xx.png',
  width: 500,
  height: 500,
  // ...
})

参数:

options

  • 描述: 可配置项
  • 必填:
  • 类型: GroundHelperOptions
GroundHelperOptions
属性描述类型必填默认值
imgUrl生成地面的图片资源路径string
id地面唯一 IDstring
width地面长(平面的宽)number500
height地面宽(平面的高)number500
opacity地面不透明度number1
position地面中心点坐标Position{ x: 0, y: 0, z: 0 }
rotation地面旋转弧度Rotation{ x: 0, y: 0, z: 0 }
scale地面缩放比Scale{ x: 1, y: 1, z: 1 }
repeat地面在平面内的平铺数IVector2{ x: 10, y: 10 }

addDirectionalLightHelper

添加平行光辅助器

定义:

ts
interface DirectionalLightHelperOptions extends BaseHelperOptions {
  light: DirectionalLight;
  color?: IColor;
  size?: number;
}

function addDirectionalLightHelper(
  options: DirectionalLightHelperOptions
): THREE.DirectionalLightHelper;

用法:

js
const light = ssp.createDirectionalLight({
  id: 'directional_light',
});

ssp.addDirectionalLightHelper({
  id: 'directional_light_helper',
  light,
  color: 'yellow',
});

参数:

options

  • 描述: 配置项
  • 必填:
  • 类型: DirectionalLightHelperOptions
DirectionalLightHelperOptions
属性描述类型必填默认值
id唯一 IDstring
light平行光对象DirectionalLight
color颜色IColor平行光的颜色
size大小number50

addHemisphereLightHelper

添加半球光辅助器

定义:

ts
interface HemisphereLightHelperOptions extends BaseHelperOptions {
  light: HemisphereLight;
  color?: IColor;
  size?: number;
}

function addHemisphereLightHelper(
  options: HemisphereLightHelperOptions
): THREE.HemisphereLightHelper;

用法:

js
const light = ssp.createHemisphereLight({
  id: 'hemisphere_light',
});

ssp.addHemisphereLightHelper({
  id: 'hemisphere_light_helper',
  light,
  color: 'yellow',
});

参数:

options

  • 描述: 配置项
  • 必填:
  • 类型: HemisphereLightHelperOptions
HemisphereLightHelperOptions
属性描述类型必填默认值
id唯一 IDstring
light半球光对象HemisphereLight
color颜色IColor半球光的颜色
size大小number20

addSpotLightHelper

添加聚光灯辅助器

定义:

ts
interface SpotLightHelperOptions extends BaseHelperOptions {
  light: SpotLight;
  color?: IColor;
}

function addSpotLightHelper(
  options: SpotLightHelperOptions
): THREE.SpotLightHelper;

用法:

js
const light = ssp.createSpotLight({
  id: 'spot_light',
});

ssp.addSpotLightHelper({
  id: 'spot_light_helper',
  light,
  color: 'yellow',
});

参数:

options

  • 描述: 配置项
  • 必填:
  • 类型: SpotLightHelperOptions
属性描述类型必填默认值
id唯一 IDstring
light聚光灯对象SpotLight
color颜色IColor聚光灯的颜色

addPointLightHelper

添加点光辅助器

定义:

ts
interface PointLightHelperOptions extends BaseHelperOptions {
  light: PointLight;
  color?: IColor;
  size?: number;
}

function addPointLightHelper(
  options: PointLightHelperOptions
): THREE.PointLightHelper;

用法:

js
const light = ssp.createPointLight({
  id: 'point_light',
});

ssp.addPointLightHelper({
  id: 'point_light_helper',
  light,
  color: 'yellow',
});

参数:

options

  • 描述: 配置项
  • 必填:
  • 类型: PointLightHelperOptions
PointLightHelperOptions
属性描述类型必填默认值
id唯一 IDstring
light点光对象PointLight
color颜色IColor点光的颜色
size大小number20

addRectAreaLightHelper

添加矩形区域光辅助器

定义:

ts
interface RectAreaLightHelperOptions extends BaseHelperOptions {
  light: RectAreaLight;
  color?: IColor;
}

function addRectAreaLightHelper(
  options: RectAreaLightHelperOptions
): RectAreaLightHelper;

用法:

js
const light = ssp.createRectAreaLight({
  id: 'rect_area_light',
});

ssp.addRectAreaLightHelper({
  id: 'rect_area_light_helper',
  light,
  color: 'yellow',
});

参数:

options

  • 描述: 配置项
  • 必填:
  • 类型: RectAreaLightHelperOptions
RectAreaLightHelperOptions
属性描述类型必填默认值
id唯一 IDstring
light矩形区域光对象RectAreaLight
color颜色IColor矩形区域光的颜色

clearHelper

清空辅助器

定义:

ts
function clearHelper(): void;

用法:

js
ssp.clearHelper();

showAllHelper

显示所有辅助器

定义:

ts
function showAllHelper(): void;

用法:

js
ssp.showAllHelper();

hideAllHelper

隐藏所有辅助器

定义:

ts
function hideAllHelper(): void;

用法:

js
ssp.hideAllHelper();

浙ICP备16043491号