import { Laya3D } from "Laya3D" ; import { Laya } from "Laya" ; import { BaseCamera } from "laya/d3/core/BaseCamera" ; import { Camera } from "laya/d3/core/Camera" ; import { MeshSprite3D } from "laya/d3/core/MeshSprite3D" ; import { Sprite3D } from "laya/d3/core/Sprite3D" ; import { DirectionLight } from "laya/d3/core/light/DirectionLight" ; import { BaseMaterial } from "laya/d3/core/material/BaseMaterial" ; import { BlinnPhongMaterial } from "laya/d3/core/material/BlinnPhongMaterial" ; import { Scene3D } from "laya/d3/core/scene/Scene3D" ; import { TrailSprite3D } from "laya/d3/core/trail/TrailSprite3D" ; import { Vector3 } from "laya/d3/math/Vector3" ; import { Vector4 } from "laya/d3/math/Vector4" ; import { PrimitiveMesh } from "laya/d3/resource/models/PrimitiveMesh" ; import { Stage } from "laya/display/Stage" ; import { Event } from "laya/events/Event" ; import { Loader } from "laya/net/Loader" ; import { Resource } from "laya/resource/Resource" ; import { Button } from "laya/ui/Button" ; import { Browser } from "laya/utils/Browser" ; import { Handler } from "laya/utils/Handler" ; import { Stat } from "laya/utils/Stat" ; import { Texture2D } from "laya/resource/Texture2D" ; author ...
  export class TrailBugTest { private scene : Scene3D ; private sprite : Sprite3D ; private camera : Camera ; private index : number = 0 ; constructor ( ) { Laya3D . init ( 1000 , 500 ) ; Laya . stage . scaleMode = Stage . SCALE_FULL ; Laya . stage . screenMode = Stage . SCREEN_NONE ; Stat . show ( ) ; this . onPreLoadFinish ( ) ; } private onPreLoadFinish ( ) { this . scene = new Scene3D ( ) ; Laya . stage . addChild ( this . scene ) ; this . camera = new Camera ( 0 , 0.1 , 100 ) ; this . camera . clearFlag = BaseCamera . CLEARFLAG_SOLIDCOLOR ; this . camera . fieldOfView = 60 ; this . scene . addChild ( this . camera ) ; var directionLight = ( < DirectionLight > this . scene . addChild ( new DirectionLight ( ) ) ) ; directionLight . color . setValue ( 1 , 1 , 1 ) ; this . sprite = new Sprite3D ; this . scene . addChild ( this . sprite ) ; this . loadUI ( ) ; } private loadUI ( ) { Laya . loader . load ( [ "../../../../res/threeDimen/ui/button.png" ] , Handler . create ( null , function ( ) : void { var changeActionButton = ( < Button > Laya . stage . addChild ( new Button ( "../../../../res/threeDimen/ui/button.png" , "正透切换" ) ) ) ; changeActionButton . size ( 160 , 40 ) ; changeActionButton . labelBold = true ; changeActionButton . labelSize = 30 ; changeActionButton . sizeGrid = "4,4,4,4" ; changeActionButton . scale ( Browser . pixelRatio , Browser . pixelRatio ) ; changeActionButton . pos ( Laya . stage . width / 2 - changeActionButton . width * Browser . pixelRatio / 2 - 100 , Laya . stage . height - 100 * Browser . pixelRatio ) ; changeActionButton . on ( Event . CLICK , this , function ( ) : void { this . index ++ ; if ( this . index % 2 === 1 ) { var trail = new TrailSprite3D ( ) ; this . sprite . addChild ( trail ) ; } else { this . sprite . destroy ( true ) ; Resource . destroyUnusedResources ( ) ; } } ) ; } ) ) ; } }