Giter VIP home page Giter VIP logo

layabox / layaair1.0 Goto Github PK

View Code? Open in Web Editor NEW
1.8K 160.0 427.0 647.13 MB

This is old LayaAir veriosn writetten by ActionScript 3.0 ,now LayaAir is using TypeScript as the Engine Script,Please use https://github.com/layabox/LayaAir instead.

Home Page: http://www.layabox.com/

License: Other

JavaScript 98.95% PostScript 0.60% GLSL 0.35% Batchfile 0.01% Perl 0.01% HTML 0.08% Makefile 0.01% CSS 0.01%
webgl html5-engine canvas typescript javascript-programming-language particles flash 3d 3d-engine html5

layaair1.0's People

Contributors

a7359475 avatar akimgacem avatar cntanglijun avatar dashaomai avatar guolei1990 avatar hyzmm avatar i2t3oz6q avatar luckyyang avatar mornui avatar sonic3d avatar vancopper avatar winggao avatar xiaosong888 avatar ydcoming avatar yungzhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

layaair1.0's Issues

TiledMap is not a constructor

TiledMap_AnimationTile.js直接使用把这个文件拷贝这js报错:
Uncaught TypeError: TiledMap is not a constructor
at createMap (TiledMap.js:25)
at TiledMap.js:20
at TiledMap.js:10
at Object.3 (TiledMap.js:1)
at o (_prelude.js:11)
at _prelude.js:11
at Object.2../GameConfig (Main.js:3)
at o (_prelude.js:11)
at r (_prelude.js:11)
at _prelude.js:11
createMap @ TiledMap.js:25
(anonymous) @ TiledMap.js:20
(anonymous) @ TiledMap.js:10
3 @ TiledMap.js:1
o @ _prelude.js:11
(anonymous) @ _prelude.js:11
2../GameConfig @ Main.js:3
o @ _prelude.js:11
r @ _prelude.js:11
(anonymous) @ _prelude.js:11

  createMap @ TiledMap_AnimationTile.js:25
  (anonymous) @ TiledMap_AnimationTile.js:20
  (anonymous) @ TiledMap_AnimationTile.js:10
  3 @ TiledMap_AnimationTile.js:1
  o @ _prelude.js:11
  (anonymous) @ _prelude.js:11
  2../GameConfig @ Main.js:3
  o @ _prelude.js:11
  r @ _prelude.js:11
  (anonymous) @ _prelude.js:11

Building WebGL libraries that work with each other in the same webgl context.

Description of the problem

It's difficult and complex these days to mix WebGL libraries together, to draw things using different libraries in the same webgl context. (examples of difficulties: mrdoob/three.js#8147, pixijs/pixijs#3230, pixijs/pixijs#3345, pixijs/pixijs#1366, pixijs/pixijs#298, jonobr1/two.js#233)

For example, suppose we would like to render Three, Babylon, and Pixi objects into the same WebGL context, in the same 3D space.

It is currently very difficult to do this because each WebGL library manages state of the context in their own ways, and these private internals often change and break solutions that people come up with because there's no standard way to do it.

Pixi.js v4 goes through efforts to make Pixi compatible with Three.js, so that it can render in a Three scene, but this is obviously fragile.

Solution

Enter Regl to the party.

Maybe if the foundations for each library (Three, Babylon, Pixi, Two, etc) were built on Regl, we'd have a common way of rendering to a single context.

Regl makes an abstraction just on top of raw WebGL for managing WebGL state. It doesn't render for you all the things that Three.js can, it only provides the minimal foundation for working with raw WebGL in a stateful way that is easy to manage.

It seems that libraries like Three, Babylon, PlayCanvas, Pixi, Two, etc, could benefit from using a standardized way for managing WebGL state, which would make it easy to combine renderings from any of these libraries into the same WebGL context.


What are your thoughts on refactoring the foundation of Laya to use Regl for managing WebGL state? Does Regl offer enough flexibility for Laya to do what it needs to do on top of Regl?

problems on play [laya.ui.Clip]

  1. [onDisplay()] does not remember [toIndex]
    replace play() with playFromCurr(),
    playFromCurr() does not modify toIndex
    https://github.com/layabox/layaair/blob/d1811049e17fc73915ae014f7e25dfbd7ae889cb/bin/as/libs/src/laya/ui/Clip.as#L182-L190

2.[play()] does not remember [fromIndex]
add this.fromIndex = from, set index = fromIndex when index > toIndex;
https://github.com/layabox/layaair/blob/d1811049e17fc73915ae014f7e25dfbd7ae889cb/bin/as/libs/src/laya/ui/Clip.as#L429-L443

  1. [ play(from, to, autoLoop), make autoLoop is optional ]
    play() is auto loop, but play(from, to) not.
    sometimes we need an autoLoop play(from, to)
    https://github.com/layabox/layaair/blob/d1811049e17fc73915ae014f7e25dfbd7ae889cb/bin/as/libs/src/laya/ui/Clip.as#L445-L455

Laya.stage.bgColor背景透明源码报错

问题:设置Laya.stage.bgColor = null后控制台报错;
版本:LayaAir 1.7.18;
代码如下图:
image
表现如下图:
image
经过调试发现源码报错位置如下图:
image
总结:
虽然源码中判断isNaN(color) 则return,但是控制台我发现isNaN(null)其实是false;

【Chrome下九宫格缝隙问题】

Chrome的userAgent里是包含Safari字符串的,所以在Browser模块里关于是否为Safari浏览器的判断是错误的。
Browser.onSafar=Browser.u.indexOf("Safari")>-1应修改为:Browser.onSafar=Browser.u.index("Chrome")===-1 && Browser.u.indexOf("Safari")>-1
这样的话在Graphics模块中var offset=(!Render.isWebGL && (Browser.onFirefox || Browser.onEdge || Browser.onIE || Browser.onSafari)) ? 0.5 : 0 offset的值就是正确的,在Chrome下就不会有九宫格缝隙问题了。

2.0.0beta4 Uncaught Can not find class laya.effect.GlowFilterSetter undefined

编辑器为label添加 GlowFilter组件,
编辑器效果正常
运行时报错
Uncaught Can not find class laya.effect.GlowFilterSetter
undefined

已经引入"laya.filter.js"

自己用代码new laya.GlowFilter能正常使用
,,应该是编辑器使用的类没有发布到bin
其它两个filter未测试

websocket 握手请求中可否支持自定义 header ?

如题,自定义 header 主要是同步一些需要在握手时检查的状态,包括且不限于 session 。
目前的 api ,看起来似乎能用 url + querystring

ws = new Laya.Socket();
ws.connectByUrl(url);

未来的版本可否考虑加个 headers 参数?

headers = {
    "foo": "bar"
}
ws = new Laya.Socket();
ws.connectByUrl(url, headers);

IDE不支持webgl,调用canvas.getContext("webgl")返回空

Issue Type: Bug

安装最新的2.0IDE打开编辑模式报错

VS Code version: LayaAirIDE2.0 1.21.1 (79b44aa704ce542d8ca4a3cc44cfca566e7720f1, 2018-03-14T14:47:13.351Z)
OS version: Windows_NT ia32 10.0.15063

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz (4 x 2400)
Memory (System) 3.89GB (0.69GB free)
Process Argv D:\layaide\LayaAirIDE_beta\LayaAir.exe
Screen Reader no
VM 0%
Extensions: none Reproduces without extensions

微信小游戏中音频预载有问题

播放时无限warn:
Resources already exist,is repeated loading: res/snd/pop.mp3
不管你有没预载这个音频,只要多次调用playMusic就会报这个警告。
看了core源码。发现
if (!Browser.onMiniGame) 并没有和下面的Loader.cacheRes(url,tSound);配合
导致无限警告。
还有另一个warn:
laya.core.js:7725 [error] Undefined class: b
也有很多,不清楚是怎么出来的。Undefined class : b

event

stage以外的事件还能监听吗?点击都没有反应??

Questions about Sprite.loadImage

		public function loadImage(url:String, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, complete:Handler = null):Sprite {
			function loaded(tex:Texture):void {
				if (!destroyed) {
					size(x + (width || tex.width), y + (height || tex.height));
					//if (_width == 0 && _height == 0) setBounds(getSelfBounds());
					repaint();
					complete && complete.runWith(tex);
				}
			}
			graphics.loadImage(url, x, y, width, height, loaded);
			return this;
		}

code
Why width hight need to add x y???

Layabox UI In English

Hi!

i m instructed in your great product but
i m NOT Chines , and could not found IDE in English.

then i try to ask question on your forum ,
"How to convert IDE to English "
but first, i have to register and , i could not sign Up there because they were asking Phone number , as i mentioned i m not chines ,
so i could not registered.

plz help me to sort out.

MeshTexture.addData实现有bug

在vertN > 0这个分支,sz这个局部变量被复用了,变成了索引个数,导致最下面更新vertNum的时候数量是不对的。

同时设置MiniAdpter.nativefiles和URL.basePath后,formatURL的问题

MiniAdpter.nativefiles.push('comp/bg.jpg');  //设置微信小游戏的【本地文件】列表

URL.basePath = "http://www.example.com/";  //设置资源下载的【根路径】

这时formatURL返回的是
http://www.example.com/comp/bg.jpg

但我们希望的是:comp/bg.jpg

所以需要在formatURL中,加入判断:

if(MiniAdpter.nativefiles.indexOf(url)!=-1)
{
	return url;
}

https://github.com/layabox/layaair/blob/76ba77242e775ecf8c3fe03d241578dc86598d54/bin/as/libs/src/laya/net/URL.as#L42-L67

关于 2D Demo Sprite_DisplayImage.js 中 Laya.loader.load 的疑问

https://github.com/layabox/layaair/blob/master/samples/js/2d/samples/Sprite_DisplayImage.js

function showApe()
	{
		// 方法1:使用loadImage
		var ape = new Sprite();
		Laya.stage.addChild(ape);
		ape.loadImage("../../res/apes/monkey3.png");

		// 方法2:使用drawTexture
		Laya.loader.load("../../res/apes/monkey2.png", Handler.create(this, function()
		{
			var t = Laya.loader.getRes("../../res/apes/monkey2.png");
			var ape = new Sprite();
			ape.graphics.drawTexture(t, 0, 0);
			Laya.stage.addChild(ape);
			ape.pos(200, 0);
		}));
	}

测试时发现去掉 Laya.loader.load

var t = Laya.loader.getRes("../../res/apes/monkey2.png");
var ape = new Sprite();
ape.graphics.drawTexture(t, 0, 0);
Laya.stage.addChild(ape);
ape.pos(200, 0);

程序也可以正常执行。我的问题是:在外层加上 Laya.loader.load 的目的和意义什么。如果有必要加上 Laya.loader.load,是否可以把 monkey2 提取出来 😋

var monkey2 = '../../res/apes/monkey2.png'

Laya.loader.load(monkey2, Handler.create(this, function() {
    var t = Laya.loader.getRes(monkey2);
    var ape = new Sprite();
    ape.graphics.drawTexture(t, 0, 0);
    Laya.stage.addChild(ape);
    ape.pos(200, 0);
}));

Laya.stage.bgColor = null没有背景透明,是黑色

问题:设置Laya.stage.bgColor = null,背景并没有透明,背后使用html标签已经写了一个背景,但是因为没有透明所以被挡住了;
引擎版本:LayaAir 1.7.19.1 beta(以前的版本也存在此问题);
文档描述如下:
image
我的代码如下:
image
所得表现结果如下:
image

一加手机自带浏览器播放声音卡死

1.7.18版本
laya.core.js 4921行
WebAudioSound.ctx.resume();

resume方法不存在出错,请解决 :)

ua信息
Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A3010 Build/NMF26F) AppleWebKit/537.36(KHTML, like Gecko) Chrome/37.0.0.0 Mobile Safari/537.36

一些小问题

1.使用Label组件时 使用了 centerX 与 centerY 会导致 pandding A,B,C,D 中的 A,B 效果不准确。
2.使用Label并使用图形字体时 设置 align为 center使文字显示在中间。再添加 underline 与 underlinecolor 会发现下划线依旧左边没有跟随文字显示在中间
预览

使用 MatterJS 后无法自动横屏

Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;

Laya.stage.scaleMode = "showall";
Laya.stage.screenMode = Stage.SCREEN_HORIZONTAL;

无法横屏,如何解决?谢谢

2.0版本加载报错

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0

LayaIDE English

Hello I wanted to use Laya but I can't change it to english, is it still possible to change it to english?

I followed the steps here
layabox/LayaAir#19

But it doesn't change the other menus to english.
Is it not on full english?
Thank you

No IDE found how to setup the project ?

Are you guys still working on this engine and IDE ? i found the old version of the IDE and it is written in Japanese or Chinese but not in English, and if you go to tutorials section it is using IDE to make project structure and yet in the master branch you can't even find the IDE executable also the IDE link on the main site is downloading source code of an android app i don't know what is going on with this engine i liked it because of Flash AS3 it seems that it is not for global developers.

Laya.Stage.SCALE_SHOWALL模式下Ray射线不正确

在使用Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;模式下的时候,通过Camera构造Ray的结果不正确。测试代码如下:

`
import Camera = Laya.Camera;
import PhasorSpriter3D = Laya.PhasorSpriter3D;
import Ray = Laya.Ray;
import RenderState = Laya.RenderState;
import Script = Laya.Script;
import Vector2 = Laya.Vector2;
import Vector3 = Laya.Vector3;
import Vector4 = Laya.Vector4;
import WebGLContext = Laya.WebGLContext;

class SceneScript extends Script {
private _originPosition: Vector3 = new Vector3(0, 0, 0);
private _phasorSpriter3D: PhasorSpriter3D;
private _color: Vector4 = new Vector4(1, 0, 0, 1);
private _point: Vector2 = new Vector2();
private _camera: Camera;
private _ray: Ray = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));

public _start(state: RenderState): void {
    super._start(state);

    this._phasorSpriter3D = new PhasorSpriter3D();
    this._camera = this._owner.getChildByName("Camera") as Camera;
}

public _postRenderUpdate(state: RenderState): void {
    super._update(state);

    this._point.elements[0] = Laya.stage.mouseX;
    this._point.elements[1] = Laya.stage.mouseY;
    this._camera.viewportPointToRay(this._point, this._ray);

    this._phasorSpriter3D.begin(WebGLContext.LINES, this._camera);

    // 绘出射线
    this._phasorSpriter3D.line(
        this._ray.origin,
        this._color,
        this._originPosition,
        this._color);

    this._phasorSpriter3D.end();
}

}

// 程序入口
class GameMain {
constructor() {
Laya3D.init(1334, 768, true, true);

    Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
    Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;

    Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
    Laya.stage.bgColor = "#232628";

    Laya.Stat.show();

    let camera: Laya.Camera = new Laya.Camera();
    camera.name = "Camera";
    camera.transform.position = new Laya.Vector3(
        -6.87492561340332, 3.95000958442688, 1.06434166431427);
    camera.transform.rotation = new Laya.Quaternion(
        -0.19387270510196686,
        -0.6291995048522949,
        -0.16616787016391754,
        0.7341046333312988);
    let scene: Laya.Scene = new Laya.Scene();
    scene.addChild(camera);
    scene.addScript(SceneScript);
    Laya.stage.addChild(scene);
}

}

new GameMain();
`

在微信小游戏中无法加载场景文件

提示出错信息
Scene: the .lh file root type must be Scene,please use other function to load this file.

稍微跟了一下:
首先ls文件的类型是"SPRITE3DHIERARCHY",没有作为json文件读入。
然后因为MiniLoader.load的实现没有支持customParser,所以不会递归去加载材质、MESH等资源。
求解决。

laya.webgl.js Transform 异常

相关的代码片段缺少 tx 和 ty 值,导致 Transform Matrix 异常。

x = this._curMat.a * _x1 + this._curMat.c * _y1 + this._curMat.tx;
y = this._curMat.b * _x1 + this._curMat.d * _y1 + this._curMat.ty;

使用Sprite的drawToCanvas 参数带有小数点会导致错误

报错信息如下,没有小数点就不会报错

Uncaught RangeError: Source is too large
at Uint8ClampedArray.set ()
at Function.RunDriver.drawToCanvas (bundle.js:24135)
at SButton.__proto.drawToCanvas (bundle.js:15002)
at Guide. (Guide.ts:26)
at TimerHandler.__proto.run (bundle.js:9492)
at Timer.__proto._update (bundle.js:9236)
at Stage.__proto.render (bundle.js:17820)
at Stage.__proto._loop (bundle.js:17778)
at loop (bundle.js:5219)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.