import { Laya } from "Laya" ; import { BaseCamera } from "laya/d3/core/BaseCamera" ; import { Camera , CameraClearFlags } from "laya/d3/core/Camera" ; import { DirectionLight } from "laya/d3/core/light/DirectionLight" ; import { BaseMaterial } from "laya/d3/core/material/BaseMaterial" ; import { Material } from "laya/d3/core/material/Material" ; import { SkyBoxMaterial } from "laya/d3/core/material/SkyBoxMaterial" ; import { Scene3D } from "laya/d3/core/scene/Scene3D" ; import { Sprite3D } from "laya/d3/core/Sprite3D" ; import { Vector3 } from "laya/d3/math/Vector3" ; import { Vector4 } from "laya/d3/math/Vector4" ; import { Viewport } from "laya/d3/math/Viewport" ; 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" ; author ...
  export class MultiCamera { private _translate : Vector3 = new Vector3 ( 0 , 0 , 1.5 ) ; constructor ( ) { Laya3D . init ( 0 , 0 ) ; Laya . stage . scaleMode = Stage . SCALE_FULL ; Laya . stage . screenMode = Stage . SCREEN_NONE ; Stat . show ( ) ; var scene = ( < Scene3D > Laya . stage . addChild ( new Scene3D ( ) ) ) ; var camera1 = ( < Camera > scene . addChild ( new Camera ( 0 , 0.1 , 100 ) ) ) ; camera1 . clearColor = new Vector4 ( 0.3 , 0.3 , 0.3 , 1.0 ) ; camera1 . transform . translate ( this . _translate ) ; camera1 . normalizedViewport = new Viewport ( 0 , 0 , 0.5 , 1.0 ) ; var camera2 = ( < Camera > scene . addChild ( new Camera ( 0 , 0.1 , 100 ) ) ) ; camera2 . clearColor = new Vector4 ( 0.0 , 0.0 , 1.0 , 1.0 ) ; this . _translate . setValue ( 0 , 0 , 1.5 ) ; camera2 . transform . translate ( this . _translate ) ; camera2 . normalizedViewport = new Viewport ( 0.5 , 0.0 , 0.5 , 0.5 ) ; camera2 . addComponent ( CameraMoveScript ) ; camera2 . clearFlag = CameraClearFlags . Sky ; Material . load ( "res/threeDimen/skyBox/skyBox2/skyBox2.lmat" , Handler . create ( this , function ( mat ) : void { var skyRenderer = camera2 . skyRenderer ; skyRenderer . mesh = SkyBox . instance ; skyRenderer . material = mat ; } ) ) ; var directionLight = ( < DirectionLight > scene . addChild ( new DirectionLight ( ) ) ) ; Sprite3D . load ( "res/threeDimen/skinModel/LayaMonkey/LayaMonkey.lh" , Handler . create ( this , function ( sp ) : void { var layaMonkey = ( < Sprite3D > scene . addChild ( sp ) ) ; } ) ) ; } }