Commit 1d455127 authored by wjf's avatar wjf

l

parent 4abf3278
File added
This diff is collapsed.
This diff is collapsed.
......@@ -273,7 +273,8 @@ export class Stage extends Container {
* @private
*/
onMouseEvent(e: any): void {
e.preventDefault();
//@ts-ignore
if (!my) e.preventDefault();
let s: Stage = this;
//检查mouse或touch事件是否有,如果有的话,就触发事件函数
if (EventDispatcher._totalMEC > 0) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -51,7 +51,15 @@ export class BaseMaterial extends HashObject {
/**
* 纹理贴图,默认白图
*/
map: Texture = Texture.WHITE;
private _map: Texture = Texture.WHITE;
get map() {
return this._map
}
set map(value: Texture) {
this._map = value || Texture.WHITE;
}
morphTargets: boolean = false;
morphNormals: boolean = false;
/**
* 是否用线框形式绘制
*/
......@@ -62,7 +70,7 @@ export class BaseMaterial extends HashObject {
* 是否光照影响
*/
_lightAffect: boolean = false;
constructor(parameters?) {
constructor(parameters?: BaseMaterialParamsInt) {
super();
this._instanceType = "BaseMaterial";
......
This diff is collapsed.
export * from "./BaseShader"
export * from "./LightShader"
// export * from "./BaseShader"
// export * from "./LightShader"
// export * from "./SkyboxShader"
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<!-- <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
<!-- 小程序分享得用这个 -->
<!-- <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> -->
<!-- 易盾js -->
<!-- <script type="text/javascript" src="//cstaticdun.126.net/load.min.js"></script> -->
<!-- <script src="libs/zepto.min.js"></script> -->
<!-- <script src="libs/p2.js"></script> -->
<script src="../build/fyge.min.js"></script>
<script src="./js/res.js"></script>
<script src="./js/egg_break.js"></script>
<script src="./js/egg_loop.js"></script>
<script src="./js/cloud_back.js"></script>
<script src="./js/cloud_front.js"></script>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: #eeeeee;
}
</style>
</head>
<body>
<div id="cusEngine" style="line-height:0;font-size:0">
<canvas id="canvas" style="width: 100%;height: 100%"></canvas>
</div>
<!-- 帧率检测 -->
<!-- <script src="js/stats.js"></script> -->
</body>
<script>
window.addEventListener("load", async function () {
//获取canvas
var canvas = document.getElementById("canvas");
canvas.width = document.body.clientWidth * (window.devicePixelRatio || 1)
canvas.height = document.body.clientHeight * (window.devicePixelRatio || 1)
var stage = new FYGE.Stage(
canvas,
750,//设计宽度,按设计搞给的就行
1624,//设计高度
document.body.clientWidth,
document.body.clientHeight,
FYGE.RENDERER_TYPE.WEBGL
);
//鼠标事件
var mouseEvent = stage.onMouseEvent.bind(stage);
canvas.addEventListener("touchstart", mouseEvent, false);
canvas.addEventListener('touchmove', mouseEvent, false);
canvas.addEventListener('touchend', mouseEvent, false);
//stage初始化
stage.addEventListener(FYGE.Event.INIT_STAGE, async () => {
//添加个背景
// var a = stage.addChild(new FYGE.Graphics())
// .beginFill(0x000000, 0.7)
// .drawRect(0, 0, 750, 1624)
// .endFill()
var textureSky = await new Promise((r) => {
FYGE.GlobalLoader.loadImage((s, image) => {
r(FYGE.Texture.fromImage(image))
}, "./res/asd.png")
})
//lottie的图片资源
await new Promise((r) => {
FYGE.GlobalLoader.loadImage((s, image) => {
//会进TextureCache,res在res.js里面,图集数据
FYGE.createTextureSheet(new FYGE.BaseTexture(image), res)
r()
}, "./res/res.png")
})
//几个2d动画
var a = stage.addChild(new FYGE.Lottie(cloud_back))
a.play();
//加个lottie
var b = stage.addChild(new FYGE.Lottie(egg_break))
b.play(1, () => {
var s = stage.addChild(new FYGE.Sprite(textureSky))
s.anchorTexture.set(0.5, 0.5)
s.position.set(375, 800)
s.scale.set(0.1,0.1)
FYGE.Tween.get(s)
.to({scaleX:5,scaleY:5},500)
.call(()=>{
stage.removeChild(s)
})
});
// var b = stage.addChild(new FYGE.Lottie(egg_loop))
// b.play();
//上层2d的动画
var b = stage.addChild(new FYGE.Lottie(cloud_front))
b.mouseEnable = false;
b.mouseChildren = false;
b.y = 200
b.play()
}, this);
//循环
loop();
function loop() {
if (!window.paused) {
stage.flush();
}
FYGE.Tween.flush()
FYGE.getRequestAnimationFrame()(loop);
}
})
</script>
</html>
\ No newline at end of file
......@@ -91,6 +91,8 @@
canvas.addEventListener('touchend', mouseEvent, false);
//stage初始化
stage.addEventListener(FYGE.Event.INIT_STAGE, async () => {
//添加个背景
// var a = stage.addChild(new FYGE.Graphics())
// .beginFill(0x000000, 0.7)
......@@ -108,6 +110,11 @@
r(FYGE.Texture.fromImage(image))
}, "./res/aa.jpg")
})
// var sss = stage.addChild(new FreeScroll(750, 1624, 2000, 3000))
// var content = sss.view.addChild(new FYGE.Sprite(textureSky))
// content.scaleY = 3
// sss.scrollTo(200, 200)
// return
//lottie的图片资源
await new Promise((r) => {
FYGE.GlobalLoader.loadImage((s, image) => {
......@@ -119,9 +126,11 @@
//几个2d动画
var a = stage.addChild(new FYGE.Lottie(cloud_back))
a.play();
a.mouseEnable = a.mouseChildren = false
//加个lottie
var b = stage.addChild(new FYGE.Lottie(egg_break))
b.play();
b.mouseEnable = a.mouseChildren = false
// var b = stage.addChild(new FYGE.Lottie(egg_loop))
// b.play();
......@@ -161,7 +170,7 @@
.to({ y: 450 }, 500000 * 3)
// m.visible = false;
m.position.y = 0
m.addEventListener(FYGE.MouseEvent.CLICK,()=>{console.log(123123)},this)
m.addEventListener(FYGE.MouseEvent.CLICK, () => { console.log(123123) }, this)
//不带光找的材质
var mat1 = new FYGE.BaseMaterial();
......@@ -210,7 +219,7 @@
mat2.side = 1//从里往外看,可见材质面取顺时针,
mat2.map = textureSky;
var m = scene.addChildAt(new FYGE.Mesh3D(geos, mat2), 0)
m.mouseEnable=false
m.mouseEnable = false
// m.position.set(0, 2, 0)
// m.scale.set(1, 1, 1)
......@@ -241,9 +250,9 @@
a.position.copy(l.position)
a.scale.set(0.1, 0.1, 0.1)
a.addEventListener(FYGE.MouseEvent.MOUSE_DOWN,()=>{
a.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, () => {
console.log(654564)
},this)
}, this)
}
}, this);
......@@ -258,6 +267,57 @@
FYGE.getRequestAnimationFrame()(loop);
}
})
class FreeScroll extends FYGE.Container {
constructor(viewWidth, viewHeight, maxWidth, maxHeight) {
super()
this.viewWidth = viewWidth
this.viewHeight = viewHeight
this.maxWidth = maxWidth
this.maxHeight = maxHeight
//鼠标事件捕捉用
this.bg = this.addChild(new FYGE.Graphics())
.beginFill(0x000000)
.drawRect(0, 0, viewWidth, viewHeight)
.endFill()
this.bg.alpha = 0;
//内容视图,滚动内容都加入这里
this.view = this.addChild(new FYGE.Container());
//x范围viewWidth-maxWidth到0,y范围viewHeight-maxHeight到0
this.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, (e) => {
let offset = [e.stageX - this.view.x, e.stageY - this.view.y];
//加移动事件
this.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this)
this.addEventListener(FYGE.MouseEvent.MOUSE_UP, up, this)
this.addEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this)
//移动
function move(me) {
//赋值
this.view.position.set(me.stageX - offset[0], me.stageY - offset[1])
//x有限制
if (this.view.x < this.viewWidth - this.maxWidth) this.view.x = this.viewWidth - this.maxWidth;
if (this.view.x > 0) this.view.x = 0;
//y限制
if (this.view.y < this.viewHeight - this.maxHeight) this.view.y = this.viewHeight - this.maxHeight;
if (this.view.y > 0) this.view.y = 0;
}
function up() {
this.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, move, this);
this.removeEventListener(FYGE.MouseEvent.MOUSE_UP, up, this);
this.removeEventListener(FYGE.MouseEvent.MOUSE_OUT, up, this);
}
}, this)
}
scrollTo(x, y) {
this.view.position.set(-x, -y);
if (this.view.x < this.viewWidth - this.maxWidth) this.view.x = this.viewWidth - this.maxWidth;
if (this.view.x > 0) this.view.x = 0;
//y限制
if (this.view.y < this.viewHeight - this.maxHeight) this.view.y = this.viewHeight - this.maxHeight;
if (this.view.y > 0) this.view.y = 0;
}
}
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment