import { Laya } from "Laya" ; import { Camera , CameraClearFlags } from "laya/d3/core/Camera" ; import { DirectionLight } from "laya/d3/core/light/DirectionLight" ; import { Material } from "laya/d3/core/material/Material" ; import { PBRStandardMaterial } from "laya/d3/core/material/PBRStandardMaterial" ; import { SkyBoxMaterial } from "laya/d3/core/material/SkyBoxMaterial" ; import { MeshSprite3D } from "laya/d3/core/MeshSprite3D" ; import { Scene3D } from "laya/d3/core/scene/Scene3D" ; import { Sprite3D } from "laya/d3/core/Sprite3D" ; import { Vector3 } from "laya/d3/math/Vector3" ; import { Mesh } from "laya/d3/resource/models/Mesh" ; import { SkyBox } from "laya/d3/resource/models/SkyBox" ; import { SkyRenderer } from "laya/d3/resource/models/SkyRenderer" ; import { Stage } from "laya/display/Stage" ; import { Handler } from "laya/utils/Handler" ; import { Stat } from "laya/utils/Stat" ; import { Laya3D } from "Laya3D" ; import { CameraMoveScript } from "../common/CameraMoveScript" ; export class EnvironmentalReflection { private rotation : Vector3 = new Vector3 ( 0 , 0.01 , 0 ) ; private sprite3D : Sprite3D ; private scene : Scene3D = null ; private teapot : MeshSprite3D = null ; constructor ( ) { Laya3D . init ( 0 , 0 ) ; Laya . stage . scaleMode = Stage . SCALE_FULL ; Laya . stage . screenMode = Stage . SCREEN_NONE ; Stat . show ( ) ; var scene = new Scene3D ( ) ; Laya . stage . addChild ( scene ) ; scene . reflectionIntensity = 1.0 ; var camera = < Camera > scene . addChild ( new Camera ( 0 , 0.1 , 100 ) ) ; camera . transform . translate ( new Vector3 ( 0 , 2 , 3 ) ) ; camera . transform . rotate ( new Vector3 ( - 15 , 0 , 0 ) , true , false ) ; camera . addComponent ( CameraMoveScript ) ; camera . clearFlag = CameraClearFlags . Sky ; Material . load ( "res/threeDimen/skyBox/DawnDusk/SkyBox.lmat" , Handler . create ( this , function ( mat ) : void { var skyRenderer = camera . skyRenderer ; skyRenderer . mesh = SkyBox . instance ; skyRenderer . material = mat ; scene . reflection = mat . textureCube ; mat . exposure = 0.6 + 1 ; } ) ) ; var directionLight = < DirectionLight > scene . addChild ( new DirectionLight ( ) ) ; directionLight . color = new Vector3 ( 0.6 , 0.6 , 0.6 ) ; Mesh . load ( "res/threeDimen/staticModel/teapot/teapot-Teapot001.lm" , Handler . create ( this , function ( mesh ) : void { this . teapot = < MeshSprite3D > scene . addChild ( new MeshSprite3D ( mesh ) ) ; this . teapot . transform . position = new Vector3 ( 0 , 1.75 , 2 ) ; this . teapot . transform . rotate ( new Vector3 ( - 90 , 0 , 0 ) , false , false ) ; var pbrMat = new PBRStandardMaterial ( ) ; pbrMat . metallic = 1 ; this . teapot . meshRenderer . material = pbrMat ; } ) ) ; } }