new CameraDynamicSkyComponent()
相机动态天空组件,用于管理相机的动态天空效果。
Example
// 创建一个基础的动态天空场景
const app = new THING.App();
// 创建一个基础的盒子和平面作为场景内容
const box = new THING.Box({
position: [0, 0.5, 0]
});
const plane = new THING.Plane(20, 20);
// 创建天空盒纹理
const nightSkyTexture = new THING.CubeTexture({
url: {
negx: './dynamicSkyData/night/negx.png', // 左
negy: './dynamicSkyData/night/negy.png', // 下
negz: './dynamicSkyData/night/negz.png', // 前
posx: './dynamicSkyData/night/posx.png', // 右
posy: './dynamicSkyData/night/posy.png', // 上
posz: './dynamicSkyData/night/posz.png' // 后
}
});
// 创建月亮纹理
const moonTexture = new THING.ImageTexture({
url: './dynamicSkyData/texture/Full_Moon_glow.jpg',
wrapTypeT: THING.ImageWrapType.ClampToEdge,
wrapTypeS: THING.ImageWrapType.ClampToEdge,
});
// 创建云层纹理
const cloudsTexture = new THING.ImageTexture('./dynamicSkyData/texture/Sample_Rectangular_2048.jpg');
// 创建星星数据
const starsData = './dynamicSkyData/data/StarsData.bytes';
// 启用动态天空并设置纹理
app.camera.dynamicSky.active = true;
app.camera.dynamicSky.timeline = 13;
app.camera.dynamicSky.nightSkyTexture = nightSkyTexture;
app.camera.dynamicSky.moonTexture = moonTexture;
app.camera.dynamicSky.starsData = starsData;
app.camera.dynamicSky.cloudsTexture = cloudsTexture;
// 调整天空参数
app.camera.dynamicSky.lightExposure = 1.0; // 设置光照曝光度
app.camera.dynamicSky.exposure = 0.8; // 设置天空曝光度
app.camera.dynamicSky.sunEquatorOffset = -40; // 设置太阳赤道偏移量
app.camera.dynamicSky.sunLightIntensity = 1.0; // 设置日光强度
app.camera.dynamicSky.moonLightIntensity = 0.2;// 设置月光强度
Extends
Members
-
active :boolean
-
激活或停用组件。
- Overrides:
-
activeSkyRender :boolean
-
设置是否渲染天空盒参数。
-
app :THING.App
-
获取应用程序。
- Overrides:
-
cloudsTexture :ImageTextureResource
-
设置天空的云层贴图。
-
enable :boolean
-
获取/设置天空的启用状态。
- Deprecated:
- Yes
-
envMap :CubeTextureResource
-
获取天空的贴图。
-
exposure :number
-
设置/获取天空的曝光度。
- Default Value:
- 0.8
-
groundColorGradient :object
-
设置渲染地面光颜色。
- Default Value:
- { 0: [63 / 255, 149 / 255, 255 / 255], 0.39: [180 / 255, 220 / 255, 255 / 255], 0.51: [180 / 255, 220 / 255, 255 / 255], 0.7: [180 / 255, 220 / 255, 255 / 255], 1: [63 / 255, 149 / 255, 255 / 255] }
-
hemisphereLight :HemisphereLight
-
获取半球光。
-
light :DirectionalLight
-
获取主光。
-
lightColorGradient :object
-
设置渲染光颜色。
- Default Value:
- { 0: [85 / 255, 99 / 255, 112 / 255], 0.49: [85 / 255, 99 / 255, 112 / 255], 0.51: [245 / 255, 173 / 255, 84 / 255], 0.57: [249 / 255, 208 / 255, 144 / 255], 1: [252 / 255, 222 / 255, 186 / 255] }
-
lightExposure :number
-
设置/获取天空的光照曝光度。
- Default Value:
- 1.0
-
moonLightIntensity :number
-
设置夜晚日光强度。
-
moonTexture :ImageTextureResource
-
设置天空的月亮贴图。
-
nightSkyTexture :CubeTextureResource
-
设置天空的夜晚贴图。
-
object :THING.BaseObject
-
获取对象。
- Overrides:
-
onActiveChange :OnActiveChangeComponentCallback
-
活动状态改变时的回调函数。
- Overrides:
-
onAfterAdd :OnAfterAddComponentCallback
-
添加之后。
- Overrides:
-
onAfterAddChild :OnAddChildComponentCallback
-
添加子对象之后的回调函数。
- Overrides:
-
onAfterRemove :OnAfterRemoveComponentCallback
-
移除之后。
- Overrides:
-
onAfterRemoveChild :OnRemoveChildComponentCallback
-
移除子对象之后的回调函数。
- Overrides:
-
onBeforeAdd :OnBeforeAddComponentCallback
-
添加之前。
- Overrides:
-
onBeforeAddChild :OnAddChildComponentCallback
-
添加子对象之前的回调函数。
- Overrides:
-
onBeforeRemove :OnBeforeRemoveComponentCallback
-
移除之前。
- Overrides:
-
onBeforeRemoveChild :OnRemoveChildComponentCallback
-
移除子对象之前的回调函数。
- Overrides:
-
onCopy :OnCopyComponentCallback
-
复制时的回调函数。
- Overrides:
-
onExport :OnExportComponentCallback
-
导出数据时。
- Overrides:
-
onImport :OnImportComponentCallback
-
导入数据时。
- Overrides:
-
onInit :OnInitComponentCallback
-
初始化时的回调函数。
- Overrides:
-
onLoadResource :OnLoadResourceComponentCallback
-
加载资源时的回调函数。
- Overrides:
-
onParentChange :OnParentChangeComponentCallback
-
改变父对象时的回调函数。
- Overrides:
-
onRefresh :OnRefreshComponentCallback
-
刷新时的回调函数。
- Overrides:
-
onResize :OnResizeComponentCallback
-
调整大小时的回调函数。
- Overrides:
-
onUnloadResource :OnUnloadResourceComponentCallback
-
卸载资源时的回调函数。
- Overrides:
-
onUpdate :OnUpdateComponentCallback
-
更新时的回调函数。
- Overrides:
-
onVisibleChange :OnVisibleChangeComponentCallback
-
可见性改变时的回调函数。
- Overrides:
-
skyColorGradient :object
-
设置渲染天光颜色。
- Default Value:
- { 0: [180 / 255, 220 / 255, 255 / 255], 0.39: [180 / 255, 220 / 255, 255 / 255], 0.51: [180 / 255, 220 / 255, 255 / 255], 0.7: [180 / 255, 220 / 255, 255 / 255], 1: [203 / 255, 146 / 255, 65 / 255] }
-
starsData :string|Float32Array
-
设置天空的星星数据。
-
sunEquatorOffset :number
-
设置/获取太阳赤道偏移量。
- Default Value:
- -40
-
sunLightIntensity :number
-
设置白天日光强度。
-
textureSize :Array.<number>
-
设置/获取纹理的尺寸。
- Default Value:
- - [1024,1024]
-
timeline :number
-
设置/获取时间线。
- Deprecated:
- Yes
- Default Value:
- 10
Methods
-
async init()
-
获取/设置天空的启用状态。
- Deprecated:
- Yes
-
onAdd(object)
-
当添加组件时。
Parameters:
Name Type Description objectTHING.BaseObject 对象。 - Overrides:
-
onRemove()
-
当移除组件时。
- Overrides: