import { Laya } from "Laya" ; import { Animator } from "laya/d3/component/Animator" ; import { AnimatorState } from "laya/d3/component/AnimatorState" ; import { Camera } from "laya/d3/core/Camera" ; import { PointLight } from "laya/d3/core/light/PointLight" ; import { Scene3D } from "laya/d3/core/scene/Scene3D" ; import { Sprite3D } from "laya/d3/core/Sprite3D" ; import { Quaternion } from "laya/d3/math/Quaternion" ; import { Vector3 } from "laya/d3/math/Vector3" ; 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 PointLightDemo { private _temp_position : Vector3 = new Vector3 ( ) ; private _temp_quaternion : Quaternion = new Quaternion ( ) ; 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 ( ) ) ) ; scene . ambientColor = new Vector3 ( 0.1 , 0.1 , 0.1 ) ; var camera = ( < Camera > ( scene . addChild ( new Camera ( 0 , 0.1 , 1000 ) ) ) ) ; camera . transform . translate ( new Vector3 ( 0 , 0.7 , 1.3 ) ) ; camera . transform . rotate ( new Vector3 ( - 15 , 0 , 0 ) , true , false ) ; camera . addComponent ( CameraMoveScript ) ; var pointLight = ( < PointLight > scene . addChild ( new PointLight ( ) ) ) ; pointLight . color = new Vector3 ( 1.0 , 0.5 , 0.0 ) ; pointLight . transform . position = new Vector3 ( 0.4 , 0.4 , 0.0 ) ; pointLight . range = 3.0 ; Sprite3D . load ( "res/threeDimen/staticModel/grid/plane.lh" , Handler . create ( this , function ( sprite ) : void { var grid = ( < Sprite3D > scene . addChild ( sprite ) ) ; Sprite3D . load ( "res/threeDimen/skinModel/LayaMonkey/LayaMonkey.lh" , Handler . create ( this , function ( layaMonkey ) : void { scene . addChild ( layaMonkey ) ; var aniSprite3d = ( < Sprite3D > layaMonkey . getChildAt ( 0 ) ) ; var animator = ( < Animator > aniSprite3d . getComponent ( Animator ) ) ; var state = new AnimatorState ( ) ; state . name = "attack" ; state . clipStart = 75 / 150 ; state . clipEnd = 110 / 150 ; state . clip = animator . getDefaultState ( ) . clip ; animator . getControllerLayer ( 0 ) . addState ( state ) ; animator . play ( "attack" ) ; Laya . timer . frameLoop ( 1 , this , function ( ) : void { Quaternion . createFromYawPitchRoll ( 0.025 , 0 , 0 , this . _temp_quaternion ) ; Vector3 . transformQuat ( pointLight . transform . position , this . _temp_quaternion , this . _temp_position ) ; pointLight . transform . position = this . _temp_position ; } ) ; } ) ) ; } ) ) ; } }