Appearance
配置项
实例初始时可配置选项。
js
const ssp = new SoonSpace({
el: '#view',
options: {
showStats: true,
showGrid: true,
showInfo: true,
showViewHelper: true,
background: {
color: 0x333300,
// alpha: false,
// img: null,
// skyBox: null
},
hoverEnabled: false,
fileCacheEnabled: true,
levelEnabled: false,
closeInfoLog: false,
closeWarnLog: false,
fog: null,
useIndexedDB: true,
},
events: {},
});showStats
是否在左上角显示场景渲染帧率
- 类型: boolean
- 默认值:
false
showGrid
是否显示场景网格。
- 类型: boolean | GridHelperOptions
- 默认值:
false
showInfo
是否显示左下角的加载数量信息。
- 类型: boolean
- 默认值:
false
showViewHelper
是否显示右下角的视图辅助器。
- 类型: boolean
- 默认值:
false
background
背景属性
- 类型: BackgroundOptions
BackgroundOptions
| 属性 | 描述 | 类型 | 必填 | 默认值 |
|---|---|---|---|---|
| color | 背景色,权重低于 img、skyBox | string | number | null | 0xaedbf4 | |
| alpha | 背景色是否透明 | boolean | false | |
| img | 背景图路径,权重低于 skyBox | string | undefined | |
| skyBox | 背景天空盒属性 | string | SkyBoxOptions | undefined |
SkyBoxOptions
| 属性 | 描述 | 类型 | 必填 | 默认值 |
|---|---|---|---|---|
| dirPath | 图片文件夹路径 | string | ||
| fileNames | 包围盒六张图片的名称集合 | string[] |
特殊使用
alpha 设置为 true,同时 color 设置为 null, 空间背景将完全透明。
fog
场景雾化效果。
- 类型: boolean | FogOptions
- 默认值:
false
controls(废弃)
控制器配置。
- 类型: ControlsOptions
- 默认值:
{ type: 'free' }
controls(新版)
控制器配置。
- 默认值:
{}
警告
不推荐传参设置,请直接设置 ssp.controls 属性
hoverEnabled
是否开启鼠标悬浮响应。
类型: boolean
默认值:
false
levelEnabled
是否开启 level 检测
- 类型: boolean
- 默认值:
false
scaleFixedEnabled
是否开启 scaleFixed 检测
- 类型: boolean
- 默认值:
false
fileCacheEnabled
是否将文件请求缓存至内存
类型: boolean
默认值:
true
closeInfoLog
是否关闭控制台信息
- 类型: boolean
- 默认值:
false
closeWarnLog
是否关闭控制台的警告日志(console.warn)。
- 类型: boolean
- 默认值:
false注意
在开发维护过程中发现大量来至
threejs层的警告日志占用浏览器内存所导致卡顿,但未找到其提供的关闭配置,所以soonspacejs添加该配置项来默认用一个空函数赋值到window.console.warn来解决该问题。
js
if (option.closeWarnLog) window.console.warn = function () {};useIndexedDB
是否使用 indexedDB 本地数据库来持久化存储模型文件数据。开启后重复的模型资源不会多次加载。
- 类型: boolean
- 默认值:
true
提示
清空 indexedDB 存储参考这里