Coder Social home page Coder Social logo

layabox / layaair Goto Github PK

View Code? Open in Web Editor NEW
1.6K 1.6K 452.0 489.19 MB

LayaAir is a fully platform rendering engine with rich 2D/3D rendering capabilities and a mature integrated development platform

Home Page: https://www.layaair.com/

License: MIT License

JavaScript 54.58% HTML 0.02% TypeScript 43.54% GLSL 1.85% Shell 0.01% RenderScript 0.01% Batchfile 0.01%
2d-game-engine 3d-engine html html5 javascript minigames physics typescript webgl webgl2 webgpu

layaair's Introduction

LayaAir Engine

LayaAir engine, under the Layabox brand, is a 3D engine that supports full-platform publishing. It can be applied in various fields such as games, education, advertising, marketing, digital twins, metaverse, AR guides, VR scenes, architectural design, industrial design, etc.

中文

Screenshot of LayaAirIDE

LayaAir engine has adapted to many mainstream graphics APIs, such as WebGL/WebGPU/OpenGL/Vulkan, and supports programmable rendering pipelines, next-generation PBR rendering streams, ClusterLighting multi light technology, Forward+rendering pipelines, etc.

LayaAir engine can be released to multiple game platforms with one click. In addition to HTML5 WEB, it also supports the release of Native APP (Android、iOS、Mac、Windows、Linux), mini games (such as WeChat mini-games, ByteDance mini-games, Alipay mini-games, OPPO mini-games,vivo mini-games, and Xiaomi Quick Games).

LayaAir engine provides a powerful IDE, including a 3D scene editor, material editor, particle editor, blueprint editor, animation editor, physics editor, and UI editor. The IDE provides rich extension capabilities for developers to customize workflows, and developers can upload plugins to the resource store for sharing and sales.

LayaAir engine actively embraces AI and has built-in AIGC framework, providing AI creation generation, AI control IDE, AI customer service and other products.

Getting the engine

Binary downloads

Download LayaAir IDE directly from the official website of LayaAir, which includes the corresponding version of the engine.

LayaAir Engine Download.

Compiling from source

Install

Run the following command from the command line in the engine root directory, as shown below:

npm install

Run examples

Run the following command from the command line in the engine root directory, as shown below:

npm run start

Build

In the root directory of the engine, rrun the followingcommand from the command line. After that, a build folder will be generated in the root directory, where the compiled engine is located. As shown below:

npm run build

How to use compiled engine in LayaAirIDE

If you need to use your own compiled engine instead of the IDE's built-in engine, you can copy the JavaScript files from the "build/libs" folder of the engine to the "root directory of your IDE project/engine/libs". You don't need to copy all the JavaScript files, you can only copy the files you need to overwrite.

How to choose a branch

  • LayaAir_3.x: e.g. LayaAir_3.1. These are stable versions of the LayaAir3 engine, with each sub version number corresponding to a branch.

  • LayaAir_2.x: e.g. LayaAir_2.13.3. These are stable versions of the LayaAir2 engine, with each revision version number corresponding to a branch.

  • Master3.0: The active development version of LayaAir3, please do not use it for production environments.

How to contribute

Fork an official open source project from github to your own repository, clone it to your local computer, make changes to the code, and submit a PR to the official repository. We will respond as soon as possible and provide Approve and merge for you. Welcome everyone to join us in building together.

Related links

License

MIT

layaair's People

Contributors

anycode-dev avatar cceevv avatar cf-19 avatar dechunyu avatar eos3tion avatar geequlim avatar guolei1990 avatar guozhaokui avatar hhm-shy avatar hugao avatar ineedssd avatar jsjgameer avatar krapnikkk avatar kylinlove avatar layacharley avatar lirongf avatar liyan-debug avatar lurenyiabc avatar lvfulong avatar mapmapbear avatar photon0525 avatar qted avatar webreldesigner avatar wqsg avatar wywxhw2008 avatar xiaoguzhu avatar yarpee avatar zhengqixv avatar zringhost11 avatar zxj1997 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

layaair's Issues

新版物理库只有不到750KB了!请问怎么做到的?

请问只是编译参数的调整吗?还是说手动修改了BULLET的代码

另外就是编译出来的BULLET JS版,性能跟原生比,有多大的变化

能否提供一些概念分享,很好奇这一块
谢谢!我不是友商,我是引擎用户。

新版物理中:models/Mesh.ts中的类型是不是写错了

/** @internal */
	private static _nativeTempVector30: number;
	/** @internal */
	private static _nativeTempVector31: number;
	/** @internal */
	private static _nativeTempVector32: number;

	/**
 	* @internal
 	*/
	static __init__(): void {
		var physics3D: any = Physics3D._bullet;
		if (physics3D) {
			Mesh._nativeTempVector30 = physics3D.btVector3_create(0, 0, 0);
			Mesh._nativeTempVector31 = physics3D.btVector3_create(0, 0, 0);
			Mesh._nativeTempVector32 = physics3D.btVector3_create(0, 0, 0);
		}
	}

创建的不是vector吗,为啥从以前的any改成了number,不是vector

请问remapGLPositionZ的作用什么

是因为什么硬件不兼容吗?
能否说说加入这个函数的意义和为什么加入了这个函数的细节原因吗?

PS:用TS改写,然后用开源方式和引擎用户交互,谢谢你们的贡献!

功能建议:> layaair2-cmd 添加龙骨动画等 工具功能

功能建议:> layaair2-cmd 添加龙骨动画等 工具功能.
这样就可以将常用功能转换为node 脚本执行 不用打开编辑器...
(layaAir2.4把vs code功能剥离我觉得非常的正确 -- 专注ui编辑功能, 将这个功能做到最好)

laya.d3.js中createQuad的坐标是错误的,源码中是对的

laya.d3.js 29609行

	    static createQuad(long = 1, width = 1) {
	        var vertexDeclaration = VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
	        var vertexFloatStride = vertexDeclaration.vertexStride / 4;
	        var halfLong = long / 2;
	        var halfWidth = width / 2;
29609	var vertices = new Float32Array([halfLong, halfWidth, 0, 0, 0, 1, 0, 0, halfLong, halfWidth, 0, 0, 0, 1, 1, 0, -halfLong, -halfWidth, 0, 0, 0, 1, 0, 1, halfLong, -halfWidth, 0, 0, 0, 1, 1, 1]);
	        var indices = new Uint16Array([0, 1, 2, 3, 2, 1]);
	        return PrimitiveMesh._createMesh(vertexDeclaration, vertices, indices);
	    }

源码中的坐标是对的,js中halfLong前面少一个负号

29609	var vertices = new Float32Array([-halfLong, halfWidth, 0, ......

有沒可能使用cmd執行編譯

希望可以以打指令的方式觸發F8的編譯功能,
我有找到一個layacmd的程式庫,但是他的編譯不會打包成bundle.js像F8那樣,
不知是否有別的方法,謝謝。

net.HttpRequest 在收到 401 或 500 时可否正常返回个 http response? 以便于程序自行处理 statusCode 跟 body 部分.

目前的实现在收到非 200 状态码后就收到一个 string 对象,这个 string 给人看可以, 但给程序用就不够了.
https://github.com/layabox/LayaAir/blob/master/src/layaAir/laya/net/HttpRequest.ts#L125

用伪代码来描述我的需求.

resp = http.get(url, querystring)
switch resp.statusCode {
case 200:
    // 正常业务逻辑
case 401:
    // 需要重登录
case 500:
    // 错误记录
default:
    // blah blah
}

最新版本中WebGLRTMgr的优化调整造成mask泄漏问题

image
image

在2.1之后的版本优化造成了比较严重的问题
如果序列帧动画用了mask遮罩,会在RenderSprite的_mask中每帧都会调用WebGLRTMgr.getRT来new RenderTexture2D,不缓存会无限增长Resource,而且只调用了_disposeResource没有从Resource._urlResourcesMap中释放掉。

频繁释放资源ID变大后文本渲染有严重的无效遍历造成卡顿

 src/layaAir/laya/webgl/text/TextRender.ts | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/layaAir/laya/webgl/text/TextRender.ts b/src/layaAir/laya/webgl/text/TextRender.ts
index 579ca43b..84b15bdf 100644
--- a/src/layaAir/laya/webgl/text/TextRender.ts
+++ b/src/layaAir/laya/webgl/text/TextRender.ts
@@ -292,7 +292,7 @@ export class TextRender {
                         var add = sameTexData[ri.tex.id];
                         if (!add) {
                             var o1 = { texgen: ((<TextTexture>ri.tex)).genID, tex: ri.tex, words: [] }; // 根据genid来减少是否释放的判断量
-                            sameTexData[ri.tex.id] = o1;
+                            sameTexData[ri.tex.id] = o1; // TODO 数字key会造成一个不连续的数组 如果用length去遍历会有风险
                             add = o1.words;
                         } else {
                             add = add.words;
@@ -335,8 +335,10 @@ export class TextRender {
     protected _drawResortedWords(ctx: Context, startx: number, starty: number, samePagesData: any[]): void {
         var isLastRender = ctx._charSubmitCache?ctx._charSubmitCache._enable:false;
         var mat = ctx._curMat;
-        var slen = samePagesData.length;
-        for (var id = 0; id < slen; id++) {
+        var slen = samePagesData.length; 
+  
+        //for (var id = 0; id < slen; id++) {
+  for(var id in samePagesData) {// TODO samePagesData可能是个不连续的数组,比如只有一个samePagesData[29999] = dt;
             var dt = samePagesData[id];
             if (!dt) continue;
             var pri: any[] = dt.words;

Laya场景编辑器问题 及 引擎的一个小bug

一、1.0的版本还支持层级管理自定义位置,结果2.0就不支持了 用着太难受了 每次都得来回拖动 和 滚动鼠标滚轮 不知道你们引擎方有没有开发应用的 难道就没发现这个问题?想固定死也可以 最起码把层级和控件分到两列啊
二、提交一个引擎bug
laya.ui.js中的
set_scaleX(value) {
if (super.get_scaleX() == value)
return;
super.set_scaleX(value);
this.event(Laya.Event.RESIZE);
this._getWidget().resetLayoutX(); // 添加本行后 才正常
}
在Scene下的第一子节点 ScaleX变化时,如果没有最后那一行(即现在版本)left、right属性无效
(ScaleY同上)

使用publishTool.bat 打包的时候 缺少方法

这种类型没有准备对应的方法 GetAccessor
这种类型没有准备对应的方法 GetAccessor
这种类型没有准备对应的方法 GetAccessor
这种类型没有准备对应的方法 SetAccessor
这种类型没有准备对应的方法 FirstStatement
这种类型没有准备对应的方法 FirstStatement

ShurikenParticle 材质Unity无法导出

如题 导出时提示
LayaAir3D Warning : ShurikenParticle must config in CustomShaderConfig File.

CustomShaderConfig.json这个文件我找了在LayaTool文件夹里。
但这个该怎么让开发者填写呢。填写的格式是什么才能导出。

子类的 set get属性中直接调用父类的set get, 编译成es5报错

我将原来laya项目升级到最新的Laya 2.4.0beta, 自己编译laya的es6 ts源码, 发现一个错误 在es6没有问题转换成es5之后就会报错. 我发现错误出现在UIComponent这个类上, 比方说下面这个过程
ProgressBar.width(get) -> UIComponent.width(get);
所有经过这个调用之后原来的this对象都会丢失 变成莫名奇妙的东西;

我找了半天最后发现这和ts转义成es5的机制有关; ts 不支持在子类的 set get属性中直接调用父类的set get属性. 我很久以前也碰到这个问题, babel 可以支持这种转义.
ts官方讨论这个问题很久 microsoft/TypeScript#338, 但是没有改动.
我的理解是: 这个问题无法解决, 即使像babel那样转义, 可能也会导致些不可预知的问题;
我建议把代码改成在子类的set get 中直接调用父类的方法而不是 set get, 比方说
ProgressBar.width(get) -> UIComponent.get_width();

关联的网站 https://stackoverflow.com/questions/38717725/why-cant-get-superclasss-property-by-getter-typescript

layabox 能不能通过 npm 发布

通过npm发布版本,我们直接通过npm install @LayaAir/layaBox来安装;安装升级版本也很简单,就像react的npm包;
(也可以将laya-cmd放到@LayaAir/cli 中,这样看起来更先进, 更时髦)

TrailGeometry开八叉树时会报错

3ca748fconstructor时进行了修复,是否漏掉了
_updateVertexBufferUVhttps://github.com/layabox/LayaAir/blob/master/src/layaAir/laya/d3/core/trail/TrailGeometry.ts#L321-L328

当,_disappearBoundsMode时,应该要重置大小
但是遍历大小的代码https://github.com/layabox/LayaAir/blob/master/src/layaAir/laya/d3/core/trail/TrailGeometry.ts#L338
是从 _activeIndex开始,而_disappearBoundsMode设置为true的判断会导致_activeIndexvertexCount相等,导致遍历过程并不会执行

现在有两个解决方案
一个是将重新设置 min max的遍历代码,抽出来,从索引0开始遍历
要么L321-L328改成和constructor一致,改为:

		if (this._disappearBoundsMode) {//如果有顶点消失时候,需要重新计算包围盒
			bounds = this._owner._owner.trailRenderer.bounds;
			var sprite3dPosition: Vector3 = this._owner._owner.transform.position;
			bounds.setMin(sprite3dPosition);
			bounds.setMax(sprite3dPosition);
			min = bounds.getMin();
			max = bounds.getMax();
			Render.supportWebGLPlusCulling && this._calculateBoundingBoxForNative();//[NATIVE]
		}

我目前使用的是将,min,max初值改成和constructor的代码一致的方法

@ZhengQixv

很遗憾

“很遗憾,因您使用的当前设备或浏览器无法支持视频功能,本程序将无法继续,请您更换浏览器或其他设备来访问本程序,以获得最佳浏览体验。单击鼠标或点击屏幕即可退出。“” crome浏览器出现这个怎么解决

d.ts很多字段无法访问了

Vector3._ZERO
ColliderShape.SHAPEORIENTATION_UPY
AnimatorControllerLayer._currentPlayState

很多类似的字段无法访问了,总不能自己维护一个d.ts吧,希望能够向下兼容

建议让Camera.worldToViewportPoint能得到是在屏幕前,还是屏幕后

https://github.com/layabox/LayaAir/blob/master/src/layaAir/laya/d3/core/Camera.ts#L662-L667

目前Camera设计的接口,out.z 并无法得知,当前3d坐标,在屏幕上的映射,是在屏幕前面,还是屏幕后面,通常只有在屏幕前面的需要进行显示,而屏幕后的无法显示

https://github.com/layabox/LayaAir/blob/master/src/layaAir/laya/d3/math/Viewport.ts#L46-L62
中,project方法,计算的得到的a,并未返回,原本可以根据此数据的正负关系,得知是在屏幕前,还是屏幕后的

建议优化这两个接口可以将此数据返回,以便区分正负关系
我自己的处理是将Viewport.tsproject方法修改为:

project(source: Vector3, matrix: Matrix4x4, out: Vector3) {
		var sX: number = source.x;
		var sY: number = source.y;
		var sZ: number = source.z;
		Vector3.transformV3ToV3(source, matrix, out);
		var matE: Float32Array = matrix.elements;
		var a: number = (((sX * matE[3]) + (sY * matE[7])) + (sZ * matE[11])) + matE[15];
		if (a !== 1.0) {//待优化,经过计算得出的a可能会永远只近似于1,因为是Number类型
			out.x = out.x / a;
			out.y = out.y / a;
			out.z = out.z / a;
		}

		out.x = (((out.x + 1.0) * 0.5) * this.width) + this.x;
		out.y = (((-out.y + 1.0) * 0.5) * this.height) + this.y;
		out.z = (out.z * (this.maxDepth - this.minDepth)) + this.minDepth;
		return a;
	}

Camera.ts的worldToViewportPoint修改为

worldToViewportPoint(position: Vector3, out: Vector3): void {
		Matrix4x4.multiply(this._projectionMatrix, this._viewMatrix, this._projectionViewMatrix);
		let a = this.viewport.project(position, this._projectionViewMatrix, out);
		out.x = out.x / Laya.stage.clientScaleX;
		out.y = out.y / Laya.stage.clientScaleY;
		return a;
	}

小游戏中图片加载引擎可以支持区分下载方式吗

小游戏中使用图片加载的方式目前好像是先
downloadFile 之后 再 使用 image.src 加载。
引擎内部可以支持选择 image.src 直接加载网络图片的方式吗,不通过 downLoad file,
有些场景不想要增加小游戏的域名白名单

如何给BoxCollider 类增加rotation 属性 ?在编辑模式可以看到旋转效果

box2d的SetAsBox 是可以带 rotation 参数的,但laya封装的BoxCollider 没有rotation 属性
我直接修改 \bin\libs\laya.physics.js 下的 BoxCollider 代码,不能生效

自定义一个类继承ColliderBase,在其中增加rotation 属性,运行时可以生效,但在编辑模式看不到旋转的效果
export default class BoxCollider_rot extends Laya.ColliderBase {
/** @prop {name:rot, tips:"数字类型示例", type:Number, default:0}*/
this._rot = 0;
...
_setShape(re = true) {
var scaleX = (this.owner["scaleX"] || 1);
var scaleY = (this.owner["scaleY"] || 1);
this._shape.SetAsBox(this._width / 2 / Laya.Physics.PIXEL_RATIO * scaleX, this._height / 2 / Laya.Physics.PIXEL_RATIO * scaleY,
new window.box2d.b2Vec2((this._width / 2 + this._x) / Laya.Physics.PIXEL_RATIO * scaleX, (this._height / 2 + this._y) / Laya.Physics.PIXEL_RATIO * scaleY),
this._rot);
if (re)
this.refresh();
}
get rot() {
return this._rot;
}

set rot(value) {
    this._rot = value;
    if (this._shape) 
        this._setShape();
}

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.