[]StaticModel_MeshSample例子运行不起来
class StaticModel_MeshSample {
constructor() {
Laya3D.init(0, 0,true);
Laya.stage.scaleMode = Laya.Stage.SCALE_FULL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
Laya.Stat.show();
var scene = Laya.stage.addChild(new Laya.Scene()) as Laya.Scene;
var camera = scene.addChild(new Laya.Camera(0, 0.1, 100)) as Laya.Camera;
camera.transform.translate(new Laya.Vector3(0, 0.8, 1.5));
camera.transform.rotate(new Laya.Vector3(-30, 0, 0), true, false);
var mesh = scene.addChild(new Laya.MeshSprite3D(Laya.Mesh.load("../../res/threeDimen/staticModel/sphere/sphere-Sphere001.lm"))) as Laya.MeshSprite3D;
mesh.transform.localPosition = new Laya.Vector3(-0.3, 0.0, 0.0);
mesh.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
}
}
new StaticModel_MeshSample();报错如下:
TypeError: Cannot read property 'AnimationPlayer' of undefined
TypeError: Cannot read property 'component' of undefined
ReferenceError: Laya3D is not defined
个人环境:
layaAIR 1.5.4beta
nodejs v7.2.0
tsc version 2.0.10
采用TS开发,index.html配置如下
求解
constructor() {
Laya3D.init(0, 0,true);
Laya.stage.scaleMode = Laya.Stage.SCALE_FULL;
Laya.stage.screenMode = Laya.Stage.SCREEN_NONE;
Laya.Stat.show();
var scene = Laya.stage.addChild(new Laya.Scene()) as Laya.Scene;
var camera = scene.addChild(new Laya.Camera(0, 0.1, 100)) as Laya.Camera;
camera.transform.translate(new Laya.Vector3(0, 0.8, 1.5));
camera.transform.rotate(new Laya.Vector3(-30, 0, 0), true, false);
var mesh = scene.addChild(new Laya.MeshSprite3D(Laya.Mesh.load("../../res/threeDimen/staticModel/sphere/sphere-Sphere001.lm"))) as Laya.MeshSprite3D;
mesh.transform.localPosition = new Laya.Vector3(-0.3, 0.0, 0.0);
mesh.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
}
}
new StaticModel_MeshSample();报错如下:
TypeError: Cannot read property 'AnimationPlayer' of undefined
TypeError: Cannot read property 'component' of undefined
ReferenceError: Laya3D is not defined
个人环境:
layaAIR 1.5.4beta
nodejs v7.2.0
tsc version 2.0.10
采用TS开发,index.html配置如下
<body>
<!-- Protobuf -->
<!--<script type="text/javascript" src="libs/bytebuffer.js"></script>
<script type="text/javascript" src="libs/protobuf.js"></script>-->
<!--核心包,封装了显示对象渲染,事件,时间管理,时间轴动画,缓动,消息交互,socket,本地存储,鼠标触摸,声音,加载,颜色滤镜,位图字体等-->
<script type="text/javascript" src="libs/laya.core.js"></script>
<script type="text/javascript" src="libs/laya.d3.js"></script>
<script type="text/javascript" src="libs/laya.d3Plugin.js"></script>
<!--封装了webgl渲染管线,如果使用webgl渲染,可以在初始化时调用Laya.init(1000,800,laya.webgl.WebGL);-->
<script type="text/javascript" src="libs/laya.webgl.js"></script>
<!--是动画模块,包含了swf动画,骨骼动画等-->
<script type="text/javascript" src="libs/laya.ani.js"></script>
<!--包含更多webgl滤镜,比如外发光,阴影,模糊以及更多-->
<script type="text/javascript" src="libs/laya.filter.js"></script>
<!--封装了html动态排版功能-->
<script type="text/javascript" src="libs/laya.html.js"></script>
<!--粒子类库-->
<script type="text/javascript" src="libs/laya.particle.js"></script>
<!--提供tileMap解析支持-->
<script type="text/javascript" src="libs/laya.tiledmap.js"></script>
<!--提供了制作UI的各种组件实现-->
<script type="text/javascript" src="libs/laya.ui.js"></script>
<!-- 物理引擎matter.js -->
<script type="text/javascript" src="libs/matter.js"></script>
<script type="text/javascript" src="libs/matter-RenderLaya.js"></script>
<!--用户自定义顺序文件添加到这里-->
<!--jsfile--Custom-->
<!--jsfile--Custom-->
<!--自定义的js(src文件夹下)文件自动添加到下面jsfile模块标签里面里-->
<!--删除标签,ide不会自动添加js文件,请谨慎操作-->
<!--jsfile--startTag-->
<!--jsfile--endTag-->
<!--启动类添加到这里-->
<!--jsfile--Main-->
<script src="js/LayaSample.js"></script>
<!--jsfile--Main-->
</body>
求解
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
cuixueying
赞同来自:
请参考官方类库的引用顺序进行类库引用的排序
yanyu0506
赞同来自: