[LayaAirIDE 2.0]加载.lh文件 运行后黑屏 无法显示

下面代码为所用代码 按理说text文本应该会有啊 直接黑屏  实在不知道是什么问题了  下面的触屏代码为官方案例示例代码  Copy过来的  希望各位给看一下 
图片为运行的结果
import GameConfig from "./GameConfig"; 
class Main {
    //private scene:Laya.Scene3D;
    private text:Laya.Text;
    private _upVector3:Laya.Vector3 = new Laya.Vector3(0, 1, 0);
    constructor() {
        this._upVector3 = new Laya.Vector3(0, 1, 0);
        Laya3D.init(0, 0);
Laya.stage.scaleMode = Laya.Stage.SCALE_FULL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
        Laya.Stat.show();
    //var resource = [{url: "res/threeDimen/skinModel/LayaMonkey/LayaMonkey.lh", type: Laya3D.HIERARCHY, priority: 1}];
    //Laya.loader.create(resource, Laya.Handler.create(this, this.onComplete));
        Laya.loader.create("Export/LayaScene_JJF/Conventional/JJF.lh", Laya.Handler.create(this, this.onComplete));
    }
    public onComplete():void {
    //创建场景
    var scene = Laya.stage.addChild(new Laya.Scene3D());
    //创建相机
    var camera = new Laya.Camera(0, 0.1, 100);
    scene.addChild(camera);
    camera.name = "camera";
        //this.scene = Laya.stage.addChild(new Laya.Scene3D()) as Laya.Scene3D;
        //this.scene.ambientColor = new Laya.Vector3(1, 1, 1);
        camera.transform.translate(new Laya.Vector3(0,0.8,1.5));
        camera.transform.rotate(new Laya.Vector3( -15, 0, 0), true, false);
    //  var camera:Laya.Camera = this.scene.addChild(new Laya.Camera(0, 0.1, 100)) as Laya.Camera;
// camera.transform.translate(new Laya.Vector3(0, 0.5, 1));
    //  camera.transform.rotate(new Laya.Vector3( -15, 0, 0), true, false);
    var directionLight = new Laya.DirectionLight();
    scene.addChild(directionLight);
    //设置平行光颜色
    directionLight.color = new Laya.Vector3(0.6, 0.6, 0.6);
        var layaMonkey:Laya.Sprite3D = scene.addChild(Laya.Loader.getRes("Export/LayaScene_JJF/Conventional/JJF.lh")) as Laya.Sprite3D;
        //var layaMonkey = Laya.Loader.getRes("Export/LayaScene_JJF/Conventional/JJF.lh");
        layaMonkey.addComponent(MonkeyScript);
        camera.transform.lookAt(layaMonkey.transform.position, new Laya.Vector3(0, 1, 0));
                //设置文本显示框位置
                this.text.x = Laya.stage.width / 2 -50 ;
                this.text.text = "触控点归零";
                //显示文本显示框
                this.text = new Laya.Text();
                this.text.name = "ceshi";
                this.text.overflow = Laya.Text.HIDDEN;
                this.text.color = "#FFFFFF";
                this.text.font = "Impact";
                this.text.fontSize = 20;
                this.text.borderColor = "#FFFF00";
                this.text.x = Laya.stage.width / 2;
                Laya.stage.addChild(this.text);
}
}
//激活启动类
new Main();
class MonkeyScript extends Laya.Script3D{
    private _scene:Laya.Scene3D;
    private _text:Laya.Text;
    private _camera:Laya.Camera;
    private rotation:Laya.Vector3;
    private lastPosition:Laya.Vector2;
    private distance:number = 0.0;
    private disVector1:Laya.Vector2;
    private disVector2:Laya.Vector2;
    private isTwoTouch:boolean;
    private first:boolean;
    private twoFirst:boolean;
constructor(){
        super();
this._scene = null;
     this._text = null;
        this._camera = null;
        this.rotation = new Laya.Vector3(0, 0.01, 0);
     this.lastPosition = new Laya.Vector2(0, 0);
     this.distance = 0.0;
     this.disVector1 = new Laya.Vector2(0, 0);
     this.disVector2 = new Laya.Vector2(0, 0);
     this.isTwoTouch = false;
        this.first = true;
        this.twoFirst = true;
}
onStart(){
this._scene = this.owner.parent as Laya.Scene3D;
        this._text = this._scene.parent.getChildByName("ceshi") as Laya.Text;
        this._camera = this._scene.getChildByName("camera") as Laya.Camera;
}
onUpdate(){
var touchCount = this._scene.input.touchCount();
        if (1 === touchCount){
            //判断是否为两指触控,撤去一根手指后引发的touchCount===1
            if(this.isTwoTouch){
                return;
            }
            this._text.text = "触控点为1";
            //获取当前的触控点,数量为1
            var touch = this._scene.input.getTouch(0);
            //是否为新一次触碰,并未发生移动
            if (this.first){
                //获取触碰点的位置
                this.lastPosition.x = touch._position.x;
                this.lastPosition.y = touch._position.y;
                this.first = false;
            }
            else{
                //移动触碰点
                var deltaY = touch._position.y - this.lastPosition.y;
                var deltaX = touch._position.x - this.lastPosition.x;
                this.lastPosition.x = touch._position.x;
                this.lastPosition.y = touch._position.y;
                //根据移动的距离进行旋转
                (this.owner as Laya.Sprite3D).transform.rotate(new Laya.Vector3(1 * deltaY /2, 1 * deltaX / 2, 0), true, false);
            }
        }
        else if (2 === touchCount){
            this._text.text = "触控点为2";
            this.isTwoTouch = true;
            //获取两个触碰点
            var touch = this._scene.input.getTouch(0);
            var touch2 = this._scene.input.getTouch(1);
            //是否为新一次触碰,并未发生移动
            if (this.twoFirst){
                //获取触碰点的位置
                this.disVector1.x = touch.position.x - touch2.position.x;
                this.disVector1.y = touch.position.y - touch2.position.y;
                this.distance = Laya.Vector2.scalarLength(this.disVector1);
                this.twoFirst = false;
            }
            else{
                this.disVector2.x = touch.position.x - touch2.position.x;
                this.disVector2.y = touch.position.y - touch2.position.y;
                var distance2 = Laya.Vector2.scalarLength(this.disVector2);
                //根据移动的距离进行缩放
                this._camera.transform.translate(new Laya.Vector3(0, 0, -0.01 * (distance2 - this.distance)));
                this.distance = distance2;
            }   
        }
        else if (0 === touchCount){
            this._text.text = "触控点归零";
            this.first = true;
            this.twoFirst = true;
            this.lastPosition.x = 0;
            this.lastPosition.y = 0;
            this.isTwoTouch = false;
        }
}
onLateUpdate() {
    }
}
new Main();
TIM图片20190531160751.png

要回复问题请先

商务合作
商务合作