layaair-example

This commit is contained in:
King Wang
2021-07-21 23:11:13 +08:00
parent c3aa1f918e
commit 4bfe797a89
203 changed files with 257823 additions and 0 deletions
@@ -0,0 +1 @@
{"res/atlas/comp.atlas":["comp/",["btn_close.png","button.png","check_circle.png","checkbox.png","clip_num.png","clip_tree_arrow.png","clip_tree_folder.png","colorPicker.png","combobox.png","fontClip.png","fontClip_num.png","hscroll$bar.png","hscroll$down.png","hscroll$up.png","hscroll.png","hslider$bar.png","hslider.png","html.png","image.png","img_bg.png","img_bg2.png","img_bg3.png","img_bg4.png","img_bg5.png","img_blank.png","label.png","progress$bar.png","progress.png","radio.png","radiogroup.png","tab.png","textarea.png","textinput.png","vscroll$bar.png","vscroll$down.png","vscroll$up.png","vscroll.png","vslider$bar.png","vslider.png"]],"res/atlas/test.atlas":["test/",["b1.png","b2.png","block.png","c1.png","c2.png","p1.png","t1.png","tra.png"]]}
+32
View File
@@ -0,0 +1,32 @@
<html>
<head>
<title>www.layabox.com</title>
<meta charset='utf-8' />
<meta name='renderer' content='webkit' />
<meta name='viewport' content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no'
/>
<meta name='apple-mobile-web-app-capable' content='yes' />
<meta name='full-screen' content='true' />
<meta name='x5-fullscreen' content='true' />
<meta name='360-fullscreen' content='true' />
<meta name='laya' screenorientation='landscape' />
<meta http-equiv='expires' content='0' />
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
<meta http-equiv='expires' content='0' />
<meta http-equiv='Cache-Control' content='no-siteapp' />
</head>
<body>
<script type="text/javascript">
function loadLib(url) {
var script = document.createElement("script");
script.async = false;
script.src = url;
document.body.appendChild(script);
}
</script>
<script type="text/javascript" src="index.js"></script>
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
/**
* 设置LayaNative屏幕方向,可设置以下值
* landscape 横屏
* portrait 竖屏
* sensor_landscape 横屏(双方向)
* sensor_portrait 竖屏(双方向)
*/
window.screenOrientation = "sensor_landscape";
//-----libs-begin-----
loadLib("libs/laya.core.js")
loadLib("libs/laya.ui.js")
loadLib("libs/laya.physics.js")
//-----libs-end-------
loadLib("js/bundle.js");
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,678 @@
(function (exports, Laya) {
'use strict';
class AccelerationInfo {
constructor() {
}
}
class RotationInfo {
constructor() {
}
}
class Accelerator extends Laya.EventDispatcher {
constructor(singleton) {
super();
this.onDeviceOrientationChange = this.onDeviceOrientationChange.bind(this);
}
static get instance() {
Accelerator._instance = Accelerator._instance || new Accelerator(0);
return Accelerator._instance;
}
on(type, caller, listener, args = null) {
super.on(type, caller, listener, args);
Laya.ILaya.Browser.window.addEventListener('devicemotion', this.onDeviceOrientationChange);
return this;
}
off(type, caller, listener, onceOnly = false) {
if (!this.hasListener(type))
Laya.ILaya.Browser.window.removeEventListener('devicemotion', this.onDeviceOrientationChange);
return super.off(type, caller, listener, onceOnly);
}
onDeviceOrientationChange(e) {
var interval = e.interval;
Accelerator.acceleration.x = e.acceleration.x;
Accelerator.acceleration.y = e.acceleration.y;
Accelerator.acceleration.z = e.acceleration.z;
Accelerator.accelerationIncludingGravity.x = e.accelerationIncludingGravity.x;
Accelerator.accelerationIncludingGravity.y = e.accelerationIncludingGravity.y;
Accelerator.accelerationIncludingGravity.z = e.accelerationIncludingGravity.z;
Accelerator.rotationRate.alpha = e.rotationRate.gamma * -1;
Accelerator.rotationRate.beta = e.rotationRate.alpha * -1;
Accelerator.rotationRate.gamma = e.rotationRate.beta;
if (Laya.ILaya.Browser.onAndroid) {
if (Laya.ILaya.Browser.userAgent.indexOf("Chrome") > -1) {
Accelerator.rotationRate.alpha *= 180 / Math.PI;
Accelerator.rotationRate.beta *= 180 / Math.PI;
Accelerator.rotationRate.gamma *= 180 / Math.PI;
}
Accelerator.acceleration.x *= -1;
Accelerator.accelerationIncludingGravity.x *= -1;
}
else if (Laya.ILaya.Browser.onIOS) {
Accelerator.acceleration.y *= -1;
Accelerator.acceleration.z *= -1;
Accelerator.accelerationIncludingGravity.y *= -1;
Accelerator.accelerationIncludingGravity.z *= -1;
interval *= 1000;
}
this.event(Laya.Event.CHANGE, [Accelerator.acceleration, Accelerator.accelerationIncludingGravity, Accelerator.rotationRate, interval]);
}
static getTransformedAcceleration(acceleration) {
Accelerator.transformedAcceleration = Accelerator.transformedAcceleration || new AccelerationInfo();
Accelerator.transformedAcceleration.z = acceleration.z;
if (Laya.ILaya.Browser.window.orientation == 90) {
Accelerator.transformedAcceleration.x = acceleration.y;
Accelerator.transformedAcceleration.y = -acceleration.x;
}
else if (Laya.ILaya.Browser.window.orientation == -90) {
Accelerator.transformedAcceleration.x = -acceleration.y;
Accelerator.transformedAcceleration.y = acceleration.x;
}
else if (!Laya.ILaya.Browser.window.orientation) {
Accelerator.transformedAcceleration.x = acceleration.x;
Accelerator.transformedAcceleration.y = acceleration.y;
}
else if (Laya.ILaya.Browser.window.orientation == 180) {
Accelerator.transformedAcceleration.x = -acceleration.x;
Accelerator.transformedAcceleration.y = -acceleration.y;
}
var tx;
if (Laya.ILaya.stage.canvasDegree == -90) {
tx = Accelerator.transformedAcceleration.x;
Accelerator.transformedAcceleration.x = -Accelerator.transformedAcceleration.y;
Accelerator.transformedAcceleration.y = tx;
}
else if (Laya.ILaya.stage.canvasDegree == 90) {
tx = Accelerator.transformedAcceleration.x;
Accelerator.transformedAcceleration.x = Accelerator.transformedAcceleration.y;
Accelerator.transformedAcceleration.y = -tx;
}
return Accelerator.transformedAcceleration;
}
}
Accelerator.acceleration = new AccelerationInfo();
Accelerator.accelerationIncludingGravity = new AccelerationInfo();
Accelerator.rotationRate = new RotationInfo();
class Shake extends Laya.EventDispatcher {
constructor() {
super();
}
static get instance() {
Shake._instance = Shake._instance || new Shake();
return Shake._instance;
}
start(throushold, interval) {
this.throushold = throushold;
this.shakeInterval = interval;
this.lastX = this.lastY = this.lastZ = NaN;
Accelerator.instance.on(Laya.Event.CHANGE, this, this.onShake);
}
stop() {
Accelerator.instance.off(Laya.Event.CHANGE, this, this.onShake);
}
onShake(acceleration, accelerationIncludingGravity, rotationRate, interval) {
if (isNaN(this.lastX)) {
this.lastX = accelerationIncludingGravity.x;
this.lastY = accelerationIncludingGravity.y;
this.lastZ = accelerationIncludingGravity.z;
this.lastMillSecond = Laya.ILaya.Browser.now();
return;
}
var deltaX = Math.abs(this.lastX - accelerationIncludingGravity.x);
var deltaY = Math.abs(this.lastY - accelerationIncludingGravity.y);
var deltaZ = Math.abs(this.lastZ - accelerationIncludingGravity.z);
if (this.isShaked(deltaX, deltaY, deltaZ)) {
var deltaMillSecond = Laya.ILaya.Browser.now() - this.lastMillSecond;
if (deltaMillSecond > this.shakeInterval) {
this.event(Laya.Event.CHANGE);
this.lastMillSecond = Laya.ILaya.Browser.now();
}
}
this.lastX = accelerationIncludingGravity.x;
this.lastY = accelerationIncludingGravity.y;
this.lastZ = accelerationIncludingGravity.z;
}
isShaked(deltaX, deltaY, deltaZ) {
return (deltaX > this.throushold && deltaY > this.throushold) ||
(deltaX > this.throushold && deltaZ > this.throushold) ||
(deltaY > this.throushold && deltaZ > this.throushold);
}
}
class GeolocationInfo {
setPosition(pos) {
this.pos = pos;
this.coords = pos.coords;
}
get latitude() {
return this.coords.latitude;
}
get longitude() {
return this.coords.longitude;
}
get altitude() {
return this.coords.altitude;
}
get accuracy() {
return this.coords.accuracy;
}
get altitudeAccuracy() {
return this.coords.altitudeAccuracy;
}
get heading() {
return this.coords.heading;
}
get speed() {
return this.coords.speed;
}
get timestamp() {
return this.pos.timestamp;
}
}
class Geolocation {
constructor() {
}
static getCurrentPosition(onSuccess, onError = null) {
Geolocation.navigator.geolocation.getCurrentPosition(function (pos) {
Geolocation.position.setPosition(pos);
onSuccess.runWith(Geolocation.position);
}, function (error) {
onError.runWith(error);
}, {
enableHighAccuracy: Geolocation.enableHighAccuracy,
timeout: Geolocation.timeout,
maximumAge: Geolocation.maximumAge
});
}
static watchPosition(onSuccess, onError) {
return Geolocation.navigator.geolocation.watchPosition(function (pos) {
Geolocation.position.setPosition(pos);
onSuccess.runWith(Geolocation.position);
}, function (error) {
onError.runWith(error);
}, {
enableHighAccuracy: Geolocation.enableHighAccuracy,
timeout: Geolocation.timeout,
maximumAge: Geolocation.maximumAge
});
}
static clearWatch(id) {
Geolocation.navigator.geolocation.clearWatch(id);
}
}
Geolocation.navigator = navigator;
Geolocation.position = new GeolocationInfo();
Geolocation.PERMISSION_DENIED = 1;
Geolocation.POSITION_UNAVAILABLE = 2;
Geolocation.TIMEOUT = 3;
Geolocation.supported = !!Geolocation.navigator.geolocation;
Geolocation.enableHighAccuracy = false;
Geolocation.timeout = 1E10;
Geolocation.maximumAge = 0;
class HtmlVideo extends Laya.Bitmap {
constructor() {
super();
this._w = 0;
this._h = 0;
this._width = 1;
this._height = 1;
this.createDomElement();
}
createDomElement() {
this._source = this.video = Laya.ILaya.Browser.createElement("video");
var style = this.video.style;
style.position = 'absolute';
style.top = '0px';
style.left = '0px';
this.video.addEventListener("loadedmetadata", () => {
this._w = this.video.videoWidth;
this._h = this.video.videoHeight;
});
}
setSource(url, extension) {
while (this.video.childElementCount)
this.video.firstChild.remove();
if (extension & 1)
this.appendSource(url, "video/mp4");
if (extension & 2)
this.appendSource(url + ".ogg", "video/ogg");
}
appendSource(source, type) {
var sourceElement = Laya.ILaya.Browser.createElement("source");
sourceElement.src = source;
sourceElement.type = type;
this.video.appendChild(sourceElement);
}
getVideo() {
return this.video;
}
_getSource() {
return this._source;
}
destroy() {
super.destroy();
var isConchApp = Laya.ILaya.Render.isConchApp;
if (isConchApp) {
this.video._destroy();
}
}
}
HtmlVideo.create = function () {
return new HtmlVideo();
};
class Media {
constructor() {
}
static supported() {
return !!Laya.ILaya.Browser.window.navigator.getUserMedia;
}
static getMedia(options, onSuccess, onError) {
if (Laya.ILaya.Browser.window.navigator.getUserMedia) {
Laya.ILaya.Browser.window.navigator.getUserMedia(options, function (stream) {
onSuccess.runWith(Laya.ILaya.Browser.window.URL.createObjectURL(stream));
}, function (err) {
onError.runWith(err);
});
}
}
}
class WebGLVideo extends HtmlVideo {
constructor() {
super();
var gl = Laya.LayaGL.instance;
this.gl = Laya.ILaya.Render.isConchApp ? window.LayaGLContext.instance : Laya.WebGLContext.mainContext;
this._source = this.gl.createTexture();
Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, this._source);
this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, null);
}
updateTexture() {
var gl = Laya.LayaGL.instance;
Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, this._source);
this.gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
this.gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.video);
this.gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
WebGLVideo.curBindSource = this._source;
}
get _glTexture() {
return this._source;
}
destroy() {
if (this._source) {
this.gl = Laya.ILaya.Render.isConchApp ? window.LayaGLContext.instance : Laya.WebGLContext.mainContext;
if (this.gl) {
if (WebGLVideo.curBindSource == this._source) {
Laya.WebGLContext.bindTexture(this.gl, this.gl.TEXTURE_2D, null);
WebGLVideo.curBindSource = null;
}
this.gl.deleteTexture(this._source);
}
}
super.destroy();
}
}
class Video extends Laya.Sprite {
constructor(width = 320, height = 240) {
super();
this.htmlVideo = new WebGLVideo();
this.videoElement = this.htmlVideo.getVideo();
this.videoElement.layaTarget = this;
this.internalTexture = new Laya.Texture(this.htmlVideo);
this.videoElement.addEventListener("abort", Video.onAbort);
this.videoElement.addEventListener("canplay", Video.onCanplay);
this.videoElement.addEventListener("canplaythrough", Video.onCanplaythrough);
this.videoElement.addEventListener("durationchange", Video.onDurationchange);
this.videoElement.addEventListener("emptied", Video.onEmptied);
this.videoElement.addEventListener("error", Video.onError);
this.videoElement.addEventListener("loadeddata", Video.onLoadeddata);
this.videoElement.addEventListener("loadedmetadata", Video.onLoadedmetadata);
this.videoElement.addEventListener("loadstart", Video.onLoadstart);
this.videoElement.addEventListener("pause", Video.onPause);
this.videoElement.addEventListener("play", Video.onPlay);
this.videoElement.addEventListener("playing", Video.onPlaying);
this.videoElement.addEventListener("progress", Video.onProgress);
this.videoElement.addEventListener("ratechange", Video.onRatechange);
this.videoElement.addEventListener("seeked", Video.onSeeked);
this.videoElement.addEventListener("seeking", Video.onSeeking);
this.videoElement.addEventListener("stalled", Video.onStalled);
this.videoElement.addEventListener("suspend", Video.onSuspend);
this.videoElement.addEventListener("timeupdate", Video.onTimeupdate);
this.videoElement.addEventListener("volumechange", Video.onVolumechange);
this.videoElement.addEventListener("waiting", Video.onWaiting);
this.videoElement.addEventListener("ended", this.onPlayComplete['bind'](this));
this.size(width, height);
if (Laya.ILaya.Browser.onMobile) {
this.videoElement["x5-playsInline"] = true;
this.videoElement["x5-playsinline"] = true;
this.videoElement.x5PlaysInline = true;
this.videoElement.playsInline = true;
this.videoElement["webkit-playsInline"] = true;
this.videoElement["webkit-playsinline"] = true;
this.videoElement.webkitPlaysInline = true;
this.videoElement.playsinline = true;
this.videoElement.style.playsInline = true;
this.videoElement.crossOrigin = "anonymous";
this.videoElement.setAttribute('crossorigin', "anonymous");
this.videoElement.setAttribute('playsinline', 'true');
this.videoElement.setAttribute('x5-playsinline', 'true');
this.videoElement.setAttribute('webkit-playsinline', 'true');
this.videoElement.autoplay = true;
this._clickhandle = this.onDocumentClick.bind(this);
Laya.ILaya.Browser.document.addEventListener("touchend", this._clickhandle);
}
}
static onAbort(e) { e.target.layaTarget.event("abort"); }
static onCanplay(e) { e.target.layaTarget.event("canplay"); }
static onCanplaythrough(e) { e.target.layaTarget.event("canplaythrough"); }
static onDurationchange(e) { e.target.layaTarget.event("durationchange"); }
static onEmptied(e) { e.target.layaTarget.event("emptied"); }
static onError(e) { e.target.layaTarget.event("error"); }
static onLoadeddata(e) { e.target.layaTarget.event("loadeddata"); }
static onLoadedmetadata(e) { e.target.layaTarget.event("loadedmetadata"); }
static onLoadstart(e) { e.target.layaTarget.event("loadstart"); }
static onPause(e) { e.target.layaTarget.event("pause"); }
static onPlay(e) { e.target.layaTarget.event("play"); }
static onPlaying(e) { e.target.layaTarget.event("playing"); }
static onProgress(e) { e.target.layaTarget.event("progress"); }
static onRatechange(e) { e.target.layaTarget.event("ratechange"); }
static onSeeked(e) { e.target.layaTarget.event("seeked"); }
static onSeeking(e) { e.target.layaTarget.event("seeking"); }
static onStalled(e) { e.target.layaTarget.event("stalled"); }
static onSuspend(e) { e.target.layaTarget.event("suspend"); }
static onTimeupdate(e) { e.target.layaTarget.event("timeupdate"); }
static onVolumechange(e) { e.target.layaTarget.event("volumechange"); }
static onWaiting(e) { e.target.layaTarget.event("waiting"); }
onPlayComplete(e) {
if (!Laya.ILaya.Render.isConchApp || !this.videoElement || !this.videoElement.loop)
Laya.ILaya.timer.clear(this, this.renderCanvas);
this.event("ended");
}
load(url) {
if (url.indexOf("blob:") == 0)
this.videoElement.src = url;
else
this.htmlVideo.setSource(url, 1);
}
play() {
this.videoElement.play();
Laya.ILaya.timer.frameLoop(1, this, this.renderCanvas);
}
pause() {
this.videoElement.pause();
Laya.ILaya.timer.clear(this, this.renderCanvas);
}
reload() {
this.videoElement.load();
}
canPlayType(type) {
var typeString;
switch (type) {
case 1:
typeString = "video/mp4";
break;
case 2:
typeString = "video/ogg";
break;
case 8:
typeString = "video/webm";
break;
}
return this.videoElement.canPlayType(typeString);
}
renderCanvas() {
if (this.readyState === 0)
return;
this.htmlVideo['updateTexture']();
this.graphics.clear();
this.graphics.drawTexture(this.internalTexture, 0, 0, this.width, this.height);
}
onDocumentClick() {
if (!this.videoElement || this.videoElement != 0)
return;
if (Laya.Browser.onIOS) {
this.videoElement.load();
}
else {
this.videoElement.play();
this.videoElement.pause();
}
Laya.ILaya.Browser.document.removeEventListener("touchend", this._clickhandle);
}
get buffered() {
return this.videoElement.buffered;
}
get currentSrc() {
return this.videoElement.currentSrc;
}
get currentTime() {
return this.videoElement.currentTime;
}
set currentTime(value) {
this.videoElement.currentTime = value;
this.renderCanvas();
}
set volume(value) {
this.videoElement.volume = value;
}
get volume() {
return this.videoElement.volume;
}
get readyState() {
return this.videoElement.readyState;
}
get videoWidth() {
return this.videoElement.videoWidth;
}
get videoHeight() {
return this.videoElement.videoHeight;
}
get duration() {
return this.videoElement.duration;
}
get ended() {
return this.videoElement.ended;
}
get error() {
return this.videoElement.error;
}
get loop() {
return this.videoElement.loop;
}
set loop(value) {
this.videoElement.loop = value;
}
set x(val) {
super.x = val;
if (Laya.ILaya.Render.isConchApp) {
var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
this.videoElement.style.left = transform.x;
}
}
get x() {
return super.x;
}
set y(val) {
super.y = val;
if (Laya.ILaya.Render.isConchApp) {
var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
this.videoElement.style.top = transform.y;
}
}
get y() {
return super.y;
}
get playbackRate() {
return this.videoElement.playbackRate;
}
set playbackRate(value) {
this.videoElement.playbackRate = value;
}
get muted() {
return this.videoElement.muted;
}
set muted(value) {
this.videoElement.muted = value;
}
get paused() {
return this.videoElement.paused;
}
get preload() {
return this.videoElement.preload;
}
set preload(value) {
this.videoElement.preload = value;
}
get seekable() {
return this.videoElement.seekable;
}
get seeking() {
return this.videoElement.seeking;
}
size(width, height) {
super.size(width, height);
if (Laya.ILaya.Render.isConchApp) {
var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
this.videoElement.width = width * transform.scaleX;
}
else {
this.videoElement.width = width / Laya.ILaya.Browser.pixelRatio;
this.videoElement.height = height / Laya.Browser.pixelRatio;
}
if (this.paused)
this.renderCanvas();
return this;
}
set width(value) {
if (Laya.ILaya.Render.isConchApp) {
var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
this.videoElement.width = value * transform.scaleX;
}
else {
this.videoElement.width = this.width / Laya.ILaya.Browser.pixelRatio;
}
super.width = value;
if (this.paused)
this.renderCanvas();
}
get width() {
return super.width;
}
set height(value) {
if (Laya.ILaya.Render.isConchApp) {
var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
this.videoElement.height = value * transform.scaleY;
}
else {
this.videoElement.height = this.height / Laya.ILaya.Browser.pixelRatio;
}
super.height = value;
}
get height() {
return super.height;
}
destroy(detroyChildren = true) {
super.destroy(detroyChildren);
this.videoElement.removeEventListener("abort", Video.onAbort);
this.videoElement.removeEventListener("canplay", Video.onCanplay);
this.videoElement.removeEventListener("canplaythrough", Video.onCanplaythrough);
this.videoElement.removeEventListener("durationchange", Video.onDurationchange);
this.videoElement.removeEventListener("emptied", Video.onEmptied);
this.videoElement.removeEventListener("error", Video.onError);
this.videoElement.removeEventListener("loadeddata", Video.onLoadeddata);
this.videoElement.removeEventListener("loadedmetadata", Video.onLoadedmetadata);
this.videoElement.removeEventListener("loadstart", Video.onLoadstart);
this.videoElement.removeEventListener("pause", Video.onPause);
this.videoElement.removeEventListener("play", Video.onPlay);
this.videoElement.removeEventListener("playing", Video.onPlaying);
this.videoElement.removeEventListener("progress", Video.onProgress);
this.videoElement.removeEventListener("ratechange", Video.onRatechange);
this.videoElement.removeEventListener("seeked", Video.onSeeked);
this.videoElement.removeEventListener("seeking", Video.onSeeking);
this.videoElement.removeEventListener("stalled", Video.onStalled);
this.videoElement.removeEventListener("suspend", Video.onSuspend);
this.videoElement.removeEventListener("timeupdate", Video.onTimeupdate);
this.videoElement.removeEventListener("volumechange", Video.onVolumechange);
this.videoElement.removeEventListener("waiting", Video.onWaiting);
this.videoElement.removeEventListener("ended", this.onPlayComplete);
this.pause();
this.videoElement.layaTarget = null;
this.videoElement = null;
this.htmlVideo.destroy();
}
syncVideoPosition() {
var stage = Laya.ILaya.stage;
var rec;
rec = Laya.ILaya.Utils.getGlobalPosAndScale(this);
var a = stage._canvasTransform.a, d = stage._canvasTransform.d;
var x = rec.x * stage.clientScaleX * a + stage.offset.x;
var y = rec.y * stage.clientScaleY * d + stage.offset.y;
this.videoElement.style.left = x + 'px';
this.videoElement.style.top = y + 'px';
this.videoElement.width = this.width / Laya.ILaya.Browser.pixelRatio;
this.videoElement.height = this.height / Laya.ILaya.Browser.pixelRatio;
}
}
Video.MP4 = 1;
Video.OGG = 2;
Video.CAMERA = 4;
Video.WEBM = 8;
Video.SUPPORT_PROBABLY = "probably";
Video.SUPPORT_MAYBY = "maybe";
Video.SUPPORT_NO = "";
class Gyroscope extends Laya.EventDispatcher {
constructor(singleton) {
super();
this.onDeviceOrientationChange = this.onDeviceOrientationChange.bind(this);
}
static get instance() {
Gyroscope._instance = Gyroscope._instance || new Gyroscope(0);
return Gyroscope._instance;
}
on(type, caller, listener, args = null) {
super.on(type, caller, listener, args);
Laya.ILaya.Browser.window.addEventListener('deviceorientation', this.onDeviceOrientationChange);
return this;
}
off(type, caller, listener, onceOnly = false) {
if (!this.hasListener(type))
Laya.ILaya.Browser.window.removeEventListener('deviceorientation', this.onDeviceOrientationChange);
return super.off(type, caller, listener, onceOnly);
}
onDeviceOrientationChange(e) {
Gyroscope.info.alpha = e.alpha;
Gyroscope.info.beta = e.beta;
Gyroscope.info.gamma = e.gamma;
if (e.webkitCompassHeading) {
Gyroscope.info.alpha = e.webkitCompassHeading * -1;
Gyroscope.info.compassAccuracy = e.webkitCompassAccuracy;
}
this.event(Laya.Event.CHANGE, [e.absolute, Gyroscope.info]);
}
}
Gyroscope.info = new RotationInfo();
exports.AccelerationInfo = AccelerationInfo;
exports.Accelerator = Accelerator;
exports.Geolocation = Geolocation;
exports.GeolocationInfo = GeolocationInfo;
exports.Gyroscope = Gyroscope;
exports.HtmlVideo = HtmlVideo;
exports.Media = Media;
exports.RotationInfo = RotationInfo;
exports.Shake = Shake;
exports.Video = Video;
exports.WebGLVideo = WebGLVideo;
}(window.Laya = window.Laya || {}, Laya));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,635 @@
(function (exports, Laya) {
'use strict';
class ParticleSetting {
constructor() {
this.textureName = null;
this.textureCount = 1;
this.maxPartices = 100;
this.duration = 1;
this.ageAddScale = 0;
this.emitterVelocitySensitivity = 1;
this.minStartSize = 100;
this.maxStartSize = 100;
this.minEndSize = 100;
this.maxEndSize = 100;
this.minHorizontalVelocity = 0;
this.maxHorizontalVelocity = 0;
this.minVerticalVelocity = 0;
this.maxVerticalVelocity = 0;
this.endVelocity = 1;
this.gravity = new Float32Array([0, 0, 0]);
this.minRotateSpeed = 0;
this.maxRotateSpeed = 0;
this.minStartRadius = 0;
this.maxStartRadius = 0;
this.minEndRadius = 0;
this.maxEndRadius = 0;
this.minHorizontalStartRadian = 0;
this.maxHorizontalStartRadian = 0;
this.minVerticalStartRadian = 0;
this.maxVerticalStartRadian = 0;
this.useEndRadian = true;
this.minHorizontalEndRadian = 0;
this.maxHorizontalEndRadian = 0;
this.minVerticalEndRadian = 0;
this.maxVerticalEndRadian = 0;
this.minStartColor = new Float32Array([1, 1, 1, 1]);
this.maxStartColor = new Float32Array([1, 1, 1, 1]);
this.minEndColor = new Float32Array([1, 1, 1, 1]);
this.maxEndColor = new Float32Array([1, 1, 1, 1]);
this.colorComponentInter = false;
this.disableColor = false;
this.blendState = 0;
this.emitterType = "null";
this.emissionRate = 0;
this.pointEmitterPosition = new Float32Array([0, 0, 0]);
this.pointEmitterPositionVariance = new Float32Array([0, 0, 0]);
this.pointEmitterVelocity = new Float32Array([0, 0, 0]);
this.pointEmitterVelocityAddVariance = new Float32Array([0, 0, 0]);
this.boxEmitterCenterPosition = new Float32Array([0, 0, 0]);
this.boxEmitterSize = new Float32Array([0, 0, 0]);
this.boxEmitterVelocity = new Float32Array([0, 0, 0]);
this.boxEmitterVelocityAddVariance = new Float32Array([0, 0, 0]);
this.sphereEmitterCenterPosition = new Float32Array([0, 0, 0]);
this.sphereEmitterRadius = 1;
this.sphereEmitterVelocity = 0;
this.sphereEmitterVelocityAddVariance = 0;
this.ringEmitterCenterPosition = new Float32Array([0, 0, 0]);
this.ringEmitterRadius = 30;
this.ringEmitterVelocity = 0;
this.ringEmitterVelocityAddVariance = 0;
this.ringEmitterUp = 2;
this.positionVariance = new Float32Array([0, 0, 0]);
}
static checkSetting(setting) {
var key;
for (key in ParticleSetting._defaultSetting) {
if (!(key in setting)) {
setting[key] = ParticleSetting._defaultSetting[key];
}
}
setting.endVelocity = +setting.endVelocity;
setting.gravity[0] = +setting.gravity[0];
setting.gravity[1] = +setting.gravity[1];
setting.gravity[2] = +setting.gravity[2];
}
}
ParticleSetting._defaultSetting = new ParticleSetting();
class ParticleTemplateBase {
constructor() {
}
addParticleArray(position, velocity) {
}
}
class ParticleData {
constructor() {
}
static Create(settings, position, velocity, time) {
var particleData = new ParticleData();
particleData.position = position;
Laya.MathUtil.scaleVector3(velocity, settings.emitterVelocitySensitivity, ParticleData._tempVelocity);
var horizontalVelocity = Laya.MathUtil.lerp(settings.minHorizontalVelocity, settings.maxHorizontalVelocity, Math.random());
var horizontalAngle = Math.random() * Math.PI * 2;
ParticleData._tempVelocity[0] += horizontalVelocity * Math.cos(horizontalAngle);
ParticleData._tempVelocity[2] += horizontalVelocity * Math.sin(horizontalAngle);
ParticleData._tempVelocity[1] += Laya.MathUtil.lerp(settings.minVerticalVelocity, settings.maxVerticalVelocity, Math.random());
particleData.velocity = ParticleData._tempVelocity;
particleData.startColor = ParticleData._tempStartColor;
particleData.endColor = ParticleData._tempEndColor;
var i;
if (settings.disableColor) {
for (i = 0; i < 3; i++) {
particleData.startColor[i] = 1;
particleData.endColor[i] = 1;
}
particleData.startColor[i] = Laya.MathUtil.lerp(settings.minStartColor[i], settings.maxStartColor[i], Math.random());
particleData.endColor[i] = Laya.MathUtil.lerp(settings.minEndColor[i], settings.maxEndColor[i], Math.random());
}
else {
if (settings.colorComponentInter) {
for (i = 0; i < 4; i++) {
particleData.startColor[i] = Laya.MathUtil.lerp(settings.minStartColor[i], settings.maxStartColor[i], Math.random());
particleData.endColor[i] = Laya.MathUtil.lerp(settings.minEndColor[i], settings.maxEndColor[i], Math.random());
}
}
else {
Laya.MathUtil.lerpVector4(settings.minStartColor, settings.maxStartColor, Math.random(), particleData.startColor);
Laya.MathUtil.lerpVector4(settings.minEndColor, settings.maxEndColor, Math.random(), particleData.endColor);
}
}
particleData.sizeRotation = ParticleData._tempSizeRotation;
var sizeRandom = Math.random();
particleData.sizeRotation[0] = Laya.MathUtil.lerp(settings.minStartSize, settings.maxStartSize, sizeRandom);
particleData.sizeRotation[1] = Laya.MathUtil.lerp(settings.minEndSize, settings.maxEndSize, sizeRandom);
particleData.sizeRotation[2] = Laya.MathUtil.lerp(settings.minRotateSpeed, settings.maxRotateSpeed, Math.random());
particleData.radius = ParticleData._tempRadius;
var radiusRandom = Math.random();
particleData.radius[0] = Laya.MathUtil.lerp(settings.minStartRadius, settings.maxStartRadius, radiusRandom);
particleData.radius[1] = Laya.MathUtil.lerp(settings.minEndRadius, settings.maxEndRadius, radiusRandom);
particleData.radian = ParticleData._tempRadian;
particleData.radian[0] = Laya.MathUtil.lerp(settings.minHorizontalStartRadian, settings.maxHorizontalStartRadian, Math.random());
particleData.radian[1] = Laya.MathUtil.lerp(settings.minVerticalStartRadian, settings.maxVerticalStartRadian, Math.random());
var useEndRadian = settings.useEndRadian;
particleData.radian[2] = useEndRadian ? Laya.MathUtil.lerp(settings.minHorizontalEndRadian, settings.maxHorizontalEndRadian, Math.random()) : particleData.radian[0];
particleData.radian[3] = useEndRadian ? Laya.MathUtil.lerp(settings.minVerticalEndRadian, settings.maxVerticalEndRadian, Math.random()) : particleData.radian[1];
particleData.durationAddScale = settings.ageAddScale * Math.random();
particleData.time = time;
return particleData;
}
}
ParticleData._tempVelocity = new Float32Array(3);
ParticleData._tempStartColor = new Float32Array(4);
ParticleData._tempEndColor = new Float32Array(4);
ParticleData._tempSizeRotation = new Float32Array(3);
ParticleData._tempRadius = new Float32Array(2);
ParticleData._tempRadian = new Float32Array(4);
class ParticleTemplateWebGL extends ParticleTemplateBase {
constructor(parSetting) {
super();
this._floatCountPerVertex = 29;
this._firstActiveElement = 0;
this._firstNewElement = 0;
this._firstFreeElement = 0;
this._firstRetiredElement = 0;
this._currentTime = 0;
this.settings = parSetting;
}
reUse(context, pos) {
return 0;
}
initialize() {
var floatStride = 0;
this._vertices = this._mesh._vb.getFloat32Array();
floatStride = this._mesh._stride / 4;
var bufi = 0;
var bufStart = 0;
for (var i = 0; i < this.settings.maxPartices; i++) {
var random = Math.random();
var cornerYSegement = this.settings.textureCount ? 1.0 / this.settings.textureCount : 1.0;
var cornerY;
for (cornerY = 0; cornerY < this.settings.textureCount; cornerY += cornerYSegement) {
if (random < cornerY + cornerYSegement)
break;
}
this._vertices[bufi++] = -1;
this._vertices[bufi++] = -1;
this._vertices[bufi++] = 0;
this._vertices[bufi++] = cornerY;
bufi = (bufStart += floatStride);
this._vertices[bufi++] = 1;
this._vertices[bufi++] = -1;
this._vertices[bufi++] = 1;
this._vertices[bufi++] = cornerY;
bufi = bufStart += floatStride;
this._vertices[bufi++] = 1;
this._vertices[bufi++] = 1;
this._vertices[bufi++] = 1;
this._vertices[bufi++] = cornerY + cornerYSegement;
bufi = bufStart += floatStride;
this._vertices[bufi++] = -1;
this._vertices[bufi++] = 1;
this._vertices[bufi++] = 0;
this._vertices[bufi++] = cornerY + cornerYSegement;
bufi = bufStart += floatStride;
}
}
update(elapsedTime) {
this._currentTime += elapsedTime / 1000;
this.retireActiveParticles();
this.freeRetiredParticles();
if (this._firstActiveElement == this._firstFreeElement)
this._currentTime = 0;
if (this._firstRetiredElement == this._firstActiveElement)
this._drawCounter = 0;
}
retireActiveParticles() {
const epsilon = 0.0001;
var particleDuration = this.settings.duration;
while (this._firstActiveElement != this._firstNewElement) {
var offset = this._firstActiveElement * this._floatCountPerVertex * 4;
var index = offset + 28;
var particleAge = this._currentTime - this._vertices[index];
particleAge *= (1.0 + this._vertices[offset + 27]);
if (particleAge + epsilon < particleDuration)
break;
this._vertices[index] = this._drawCounter;
this._firstActiveElement++;
if (this._firstActiveElement >= this.settings.maxPartices)
this._firstActiveElement = 0;
}
}
freeRetiredParticles() {
while (this._firstRetiredElement != this._firstActiveElement) {
var age = this._drawCounter - this._vertices[this._firstRetiredElement * this._floatCountPerVertex * 4 + 28];
if (age < 3)
break;
this._firstRetiredElement++;
if (this._firstRetiredElement >= this.settings.maxPartices)
this._firstRetiredElement = 0;
}
}
addNewParticlesToVertexBuffer() {
}
addParticleArray(position, velocity) {
var nextFreeParticle = this._firstFreeElement + 1;
if (nextFreeParticle >= this.settings.maxPartices)
nextFreeParticle = 0;
if (nextFreeParticle === this._firstRetiredElement)
return;
var particleData = ParticleData.Create(this.settings, position, velocity, this._currentTime);
var startIndex = this._firstFreeElement * this._floatCountPerVertex * 4;
for (var i = 0; i < 4; i++) {
var j, offset;
for (j = 0, offset = 4; j < 3; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.position[j];
for (j = 0, offset = 7; j < 3; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.velocity[j];
for (j = 0, offset = 10; j < 4; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.startColor[j];
for (j = 0, offset = 14; j < 4; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.endColor[j];
for (j = 0, offset = 18; j < 3; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.sizeRotation[j];
for (j = 0, offset = 21; j < 2; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.radius[j];
for (j = 0, offset = 23; j < 4; j++)
this._vertices[startIndex + i * this._floatCountPerVertex + offset + j] = particleData.radian[j];
this._vertices[startIndex + i * this._floatCountPerVertex + 27] = particleData.durationAddScale;
this._vertices[startIndex + i * this._floatCountPerVertex + 28] = particleData.time;
}
this._firstFreeElement = nextFreeParticle;
}
}
var parvs = "attribute vec4 a_CornerTextureCoordinate;\r\nattribute vec3 a_Position;\r\nattribute vec3 a_Velocity;\r\nattribute vec4 a_StartColor;\r\nattribute vec4 a_EndColor;\r\nattribute vec3 a_SizeRotation;\r\nattribute vec2 a_Radius;\r\nattribute vec4 a_Radian;\r\nattribute float a_AgeAddScale;\r\nattribute float a_Time;\r\n\r\nvarying vec4 v_Color;\r\nvarying vec2 v_TextureCoordinate;\r\n\r\nuniform float u_CurrentTime;\r\nuniform float u_Duration;\r\nuniform float u_EndVelocity;\r\nuniform vec3 u_Gravity;\r\n\r\nuniform vec2 size;\r\nuniform mat4 u_mmat;\r\n\r\nvec4 ComputeParticlePosition(in vec3 position, in vec3 velocity,in float age,in float normalizedAge)\r\n{\r\n\r\n float startVelocity = length(velocity);//起始标量速度\r\n float endVelocity = startVelocity * u_EndVelocity;//结束标量速度\r\n\r\n float velocityIntegral = startVelocity * normalizedAge +(endVelocity - startVelocity) * normalizedAge *normalizedAge/2.0;//计算当前速度的标量(单位空间),vt=v0*t+(1/2)*a*(t^2)\r\n \r\n vec3 addPosition = normalize(velocity) * velocityIntegral * u_Duration;//计算受自身速度影响的位置,转换标量到矢量 \r\n addPosition += u_Gravity * age * normalizedAge;//计算受重力影响的位置\r\n \r\n float radius=mix(a_Radius.x, a_Radius.y, normalizedAge); //计算粒子受半径和角度影响(无需计算角度和半径时,可用宏定义优化屏蔽此计算)\r\n float radianHorizontal =mix(a_Radian.x,a_Radian.z,normalizedAge);\r\n float radianVertical =mix(a_Radian.y,a_Radian.w,normalizedAge);\r\n \r\n float r =cos(radianVertical)* radius;\r\n addPosition.y += sin(radianVertical) * radius;\r\n\t\r\n addPosition.x += cos(radianHorizontal) *r;\r\n addPosition.z += sin(radianHorizontal) *r;\r\n \r\n addPosition.y=-addPosition.y;//2D粒子位置更新需要取负,2D粒子坐标系Y轴正向朝上\r\n position+=addPosition;\r\n return vec4(position,1.0);\r\n}\r\n\r\nfloat ComputeParticleSize(in float startSize,in float endSize, in float normalizedAge)\r\n{ \r\n float size = mix(startSize, endSize, normalizedAge);\r\n return size;\r\n}\r\n\r\nmat2 ComputeParticleRotation(in float rot,in float age)\r\n{ \r\n float rotation =rot * age;\r\n //计算2x2旋转矩阵.\r\n float c = cos(rotation);\r\n float s = sin(rotation);\r\n return mat2(c, -s, s, c);\r\n}\r\n\r\nvec4 ComputeParticleColor(in vec4 startColor,in vec4 endColor,in float normalizedAge)\r\n{\r\n\tvec4 color=mix(startColor,endColor,normalizedAge);\r\n //硬编码设置,使粒子淡入很快,淡出很慢,6.7的缩放因子把置归一在0到1之间,可以谷歌x*(1-x)*(1-x)*6.7的制图表\r\n color.a *= normalizedAge * (1.0-normalizedAge) * (1.0-normalizedAge) * 6.7;\r\n \r\n return color;\r\n}\r\n\r\nvoid main()\r\n{\r\n float age = u_CurrentTime - a_Time;\r\n age *= 1.0 + a_AgeAddScale;\r\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\r\n gl_Position = ComputeParticlePosition(a_Position, a_Velocity, age, normalizedAge);//计算粒子位置\r\n float pSize = ComputeParticleSize(a_SizeRotation.x,a_SizeRotation.y, normalizedAge);\r\n mat2 rotation = ComputeParticleRotation(a_SizeRotation.z, age);\r\n\t\r\n mat4 mat=u_mmat;\r\n gl_Position=vec4((mat*gl_Position).xy,0.0,1.0);\r\n gl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize*vec2(mat[0][0],mat[1][1]);\r\n gl_Position=vec4((gl_Position.x/size.x-0.5)*2.0,(0.5-gl_Position.y/size.y)*2.0,0.0,1.0);\r\n \r\n v_Color = ComputeParticleColor(a_StartColor,a_EndColor, normalizedAge);\r\n v_TextureCoordinate =a_CornerTextureCoordinate.zw;\r\n}\r\n\r\n";
var parps = "#if defined(GL_FRAGMENT_PRECISION_HIGH)\r\nprecision highp float;\r\n#else\r\nprecision mediump float;\r\n#endif\r\n\r\nvarying vec4 v_Color;\r\nvarying vec2 v_TextureCoordinate;\r\nuniform sampler2D u_texture;\r\n\r\nvoid main()\r\n{\t\r\n\tgl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\r\n\tgl_FragColor.xyz *= v_Color.w;\r\n}";
class ParticleShader extends Laya.Shader {
constructor() {
super(parvs, parps, "ParticleShader", null, ['a_CornerTextureCoordinate', 0, 'a_Position', 1, 'a_Velocity', 2, 'a_StartColor', 3,
'a_EndColor', 4, 'a_SizeRotation', 5, 'a_Radius', 6, 'a_Radian', 7, 'a_AgeAddScale', 8, 'a_Time', 9]);
}
}
ParticleShader.vs = parvs;
ParticleShader.ps = parps;
class ParticleShaderValue extends Laya.Value2D {
constructor() {
super(0, 0);
if (!ParticleShaderValue.pShader) {
ParticleShaderValue.pShader = new ParticleShader();
}
}
upload() {
var size = this.size;
size[0] = Laya.RenderState2D.width;
size[1] = Laya.RenderState2D.height;
this.alpha = this.ALPHA * Laya.RenderState2D.worldAlpha;
ParticleShaderValue.pShader.upload(this);
}
}
ParticleShaderValue.pShader = null;
class ParticleTemplate2D extends ParticleTemplateWebGL {
constructor(parSetting) {
super(parSetting);
this.x = 0;
this.y = 0;
this.sv = new ParticleShaderValue();
this._key = {};
var _this = this;
Laya.ILaya.loader.load(this.settings.textureName, Laya.Handler.create(null, function (texture) {
_this.texture = texture;
}), null, Laya.Loader.IMAGE);
this.sv.u_Duration = this.settings.duration;
this.sv.u_Gravity = this.settings.gravity;
this.sv.u_EndVelocity = this.settings.endVelocity;
this._blendFn = Laya.BlendMode.fns[parSetting.blendState];
this._mesh = Laya.MeshParticle2D.getAMesh(this.settings.maxPartices);
this.initialize();
}
getRenderType() { return -111; }
releaseRender() { }
addParticleArray(position, velocity) {
position[0] += this.x;
position[1] += this.y;
super.addParticleArray(position, velocity);
}
addNewParticlesToVertexBuffer() {
var _vertexBuffer2D = this._mesh._vb;
_vertexBuffer2D.clear();
_vertexBuffer2D.append(this._vertices);
var start;
if (this._firstNewElement < this._firstFreeElement) {
start = this._firstNewElement * 4 * this._floatCountPerVertex * 4;
_vertexBuffer2D.subUpload(start, start, start + (this._firstFreeElement - this._firstNewElement) * 4 * this._floatCountPerVertex * 4);
}
else {
start = this._firstNewElement * 4 * this._floatCountPerVertex * 4;
_vertexBuffer2D.subUpload(start, start, start + (this.settings.maxPartices - this._firstNewElement) * 4 * this._floatCountPerVertex * 4);
if (this._firstFreeElement > 0) {
_vertexBuffer2D.setNeedUpload();
_vertexBuffer2D.subUpload(0, 0, this._firstFreeElement * 4 * this._floatCountPerVertex * 4);
}
}
this._firstNewElement = this._firstFreeElement;
}
renderSubmit() {
if (this.texture && this.texture.getIsReady()) {
this.update(Laya.ILaya.timer._delta);
this.sv.u_CurrentTime = this._currentTime;
if (this._firstNewElement != this._firstFreeElement) {
this.addNewParticlesToVertexBuffer();
}
this.blend();
if (this._firstActiveElement != this._firstFreeElement) {
var gl = Laya.WebGLContext.mainContext;
this._mesh.useMesh(gl);
this.sv.u_texture = this.texture._getSource();
this.sv.upload();
if (this._firstActiveElement < this._firstFreeElement) {
gl.drawElements(gl.TRIANGLES, (this._firstFreeElement - this._firstActiveElement) * 6, gl.UNSIGNED_SHORT, this._firstActiveElement * 6 * 2);
}
else {
Laya.WebGLContext.mainContext.drawElements(gl.TRIANGLES, (this.settings.maxPartices - this._firstActiveElement) * 6, gl.UNSIGNED_SHORT, this._firstActiveElement * 6 * 2);
if (this._firstFreeElement > 0)
gl.drawElements(gl.TRIANGLES, this._firstFreeElement * 6, gl.UNSIGNED_SHORT, 0);
}
Laya.Stat.renderBatches++;
}
this._drawCounter++;
}
return 1;
}
updateParticleForNative() {
if (this.texture && this.texture.getIsReady()) {
this.update(Laya.ILaya.timer._delta);
this.sv.u_CurrentTime = this._currentTime;
if (this._firstNewElement != this._firstFreeElement) {
this._firstNewElement = this._firstFreeElement;
}
}
}
getMesh() {
return this._mesh;
}
getConchMesh() {
return this._conchMesh;
}
getFirstNewElement() {
return this._firstNewElement;
}
getFirstFreeElement() {
return this._firstFreeElement;
}
getFirstActiveElement() {
return this._firstActiveElement;
}
getFirstRetiredElement() {
return this._firstRetiredElement;
}
setFirstFreeElement(_value) {
this._firstFreeElement = _value;
}
setFirstNewElement(_value) {
this._firstNewElement = _value;
}
addDrawCounter() {
this._drawCounter++;
}
blend() {
if (Laya.BlendMode.activeBlendFunction !== this._blendFn) {
var gl = Laya.WebGLContext.mainContext;
gl.enable(gl.BLEND);
this._blendFn(gl);
Laya.BlendMode.activeBlendFunction = this._blendFn;
}
}
dispose() {
this._mesh.releaseMesh();
}
}
ParticleTemplate2D.activeBlendType = -1;
class EmitterBase {
constructor() {
this._frameTime = 0;
this._emissionRate = 60;
this._emissionTime = 0;
this.minEmissionTime = 1 / 60;
}
set particleTemplate(particleTemplate) {
this._particleTemplate = particleTemplate;
}
set emissionRate(_emissionRate) {
if (_emissionRate <= 0)
return;
this._emissionRate = _emissionRate;
(_emissionRate > 0) && (this.minEmissionTime = 1 / _emissionRate);
}
get emissionRate() {
return this._emissionRate;
}
start(duration = Number.MAX_VALUE) {
if (this._emissionRate != 0)
this._emissionTime = duration;
}
stop() {
this._emissionTime = 0;
}
clear() {
this._emissionTime = 0;
}
emit() {
}
advanceTime(passedTime = 1) {
this._emissionTime -= passedTime;
if (this._emissionTime < 0)
return;
this._frameTime += passedTime;
if (this._frameTime < this.minEmissionTime)
return;
while (this._frameTime > this.minEmissionTime) {
this._frameTime -= this.minEmissionTime;
this.emit();
}
}
}
class Emitter2D extends EmitterBase {
constructor(_template) {
super();
this.template = _template;
}
set template(template) {
this._particleTemplate = template;
if (!template) {
this._emitFun = null;
this.setting = null;
this._posRange = null;
}
this.setting = template.settings;
this._posRange = this.setting.positionVariance;
if (this._particleTemplate instanceof ParticleTemplate2D) {
this._emitFun = this.webGLEmit;
}
}
get template() {
return this._particleTemplate;
}
emit() {
super.emit();
if (this._emitFun != null)
this._emitFun();
}
getRandom(value) {
return (Math.random() * 2 - 1) * value;
}
webGLEmit() {
var pos = new Float32Array(3);
pos[0] = this.getRandom(this._posRange[0]);
pos[1] = this.getRandom(this._posRange[1]);
pos[2] = this.getRandom(this._posRange[2]);
var v = new Float32Array(3);
v[0] = 0;
v[1] = 0;
v[2] = 0;
this._particleTemplate.addParticleArray(pos, v);
}
canvasEmit() {
var pos = new Float32Array(3);
pos[0] = this.getRandom(this._posRange[0]);
pos[1] = this.getRandom(this._posRange[1]);
pos[2] = this.getRandom(this._posRange[2]);
var v = new Float32Array(3);
v[0] = 0;
v[1] = 0;
v[2] = 0;
this._particleTemplate.addParticleArray(pos, v);
}
}
class Particle2D extends Laya.Sprite {
constructor(setting) {
super();
this._matrix4 = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
this.autoPlay = true;
this.customRenderEnable = true;
if (setting)
this.setParticleSetting(setting);
}
set url(url) {
this.load(url);
}
load(url) {
Laya.ILaya.loader.load(url, Laya.Handler.create(this, this.setParticleSetting), null, Laya.ILaya.Loader.JSON);
}
setParticleSetting(setting) {
if (!setting)
return this.stop();
ParticleSetting.checkSetting(setting);
this.customRenderEnable = true;
this._particleTemplate = new ParticleTemplate2D(setting);
this.graphics._saveToCmd(null, Laya.DrawParticleCmd.create(this._particleTemplate));
if (!this._emitter) {
this._emitter = new Emitter2D(this._particleTemplate);
}
else {
this._emitter.template = this._particleTemplate;
}
if (this.autoPlay) {
this.emitter.start();
this.play();
}
}
get emitter() {
return this._emitter;
}
play() {
Laya.ILaya.timer.frameLoop(1, this, this._loop);
}
stop() {
Laya.ILaya.timer.clear(this, this._loop);
}
_loop() {
this.advanceTime(1 / 60);
}
advanceTime(passedTime = 1) {
if (this._canvasTemplate) {
this._canvasTemplate.advanceTime(passedTime);
}
if (this._emitter) {
this._emitter.advanceTime(passedTime);
}
}
customRender(context, x, y) {
this._matrix4[0] = context._curMat.a;
this._matrix4[1] = context._curMat.b;
this._matrix4[4] = context._curMat.c;
this._matrix4[5] = context._curMat.d;
this._matrix4[12] = context._curMat.tx;
this._matrix4[13] = context._curMat.ty;
var sv = this._particleTemplate.sv;
sv.u_mmat = this._matrix4;
if (this._canvasTemplate) {
this._canvasTemplate.render(context, x, y);
}
}
destroy(destroyChild = true) {
if (this._particleTemplate instanceof ParticleTemplate2D)
this._particleTemplate.dispose();
super.destroy(destroyChild);
}
}
Laya.ClassUtils.regClass("laya.particle.Particle2D", Particle2D);
Laya.ClassUtils.regClass("Laya.Particle2D", Particle2D);
Laya.ILaya.regClass(Particle2D);
class ParticleEmitter {
constructor(templet, particlesPerSecond, initialPosition) {
this._timeLeftOver = 0;
this._tempVelocity = new Float32Array([0, 0, 0]);
this._tempPosition = new Float32Array([0, 0, 0]);
this._templet = templet;
this._timeBetweenParticles = 1.0 / particlesPerSecond;
this._previousPosition = initialPosition;
}
update(elapsedTime, newPosition) {
elapsedTime = elapsedTime / 1000;
if (elapsedTime > 0) {
Laya.MathUtil.subtractVector3(newPosition, this._previousPosition, this._tempVelocity);
Laya.MathUtil.scaleVector3(this._tempVelocity, 1 / elapsedTime, this._tempVelocity);
var timeToSpend = this._timeLeftOver + elapsedTime;
var currentTime = -this._timeLeftOver;
while (timeToSpend > this._timeBetweenParticles) {
currentTime += this._timeBetweenParticles;
timeToSpend -= this._timeBetweenParticles;
Laya.MathUtil.lerpVector3(this._previousPosition, newPosition, currentTime / elapsedTime, this._tempPosition);
this._templet.addParticleArray(this._tempPosition, this._tempVelocity);
}
this._timeLeftOver = timeToSpend;
}
this._previousPosition[0] = newPosition[0];
this._previousPosition[1] = newPosition[1];
this._previousPosition[2] = newPosition[2];
}
}
exports.Emitter2D = Emitter2D;
exports.EmitterBase = EmitterBase;
exports.Particle2D = Particle2D;
exports.ParticleData = ParticleData;
exports.ParticleEmitter = ParticleEmitter;
exports.ParticleSetting = ParticleSetting;
exports.ParticleShader = ParticleShader;
exports.ParticleShaderValue = ParticleShaderValue;
exports.ParticleTemplate2D = ParticleTemplate2D;
exports.ParticleTemplateBase = ParticleTemplateBase;
exports.ParticleTemplateWebGL = ParticleTemplateWebGL;
}(window.Laya = window.Laya || {}, Laya));
@@ -0,0 +1,790 @@
(function (exports, Laya) {
'use strict';
const defaultOptions = {
autoRetryConnnect: true,
retryConnnectCount: 0,
retryConnnectDelay: 10000
};
let WebSocketCls = window.WebSocket;
class SocketManager {
constructor(host, port, name, type, options) {
this.clientId = 0;
this.socket = null;
this.isSupport = false;
this.status = 0;
this.retryConnnectCount = 0;
this.onClose = (ev) => {
let { onClose, autoRetryConnnect, retryConnnectCount } = this.options;
retryConnnectCount = retryConnnectCount || 0;
if (onClose) {
onClose(ev);
}
if (this.status === 0) {
if (autoRetryConnnect &&
(retryConnnectCount == 0 || this.retryConnnectCount < retryConnnectCount)) {
this.delayRetryConnnect();
}
}
};
this._delayRetryConnnectTimer = 0;
this._delayRetryConnnect = () => {
clearTimeout(this._delayRetryConnnectTimer);
this.retryConnnectCount++;
this.reConnect();
};
this.onMessage = (ev) => {
const { onMessage } = this.options;
if (onMessage) {
onMessage(ev);
}
};
this.onError = (ev) => {
const { onError } = this.options;
if (onError) {
onError(ev);
}
};
this.onOpen = (ev) => {
const { onOpen } = this.options;
if (onOpen) {
onOpen(ev);
}
this.retryConnnectCount = 0;
clearTimeout(this._delayRetryConnnectTimer);
};
this.url = 'ws://' + host + ":" + port + '?type=' + type + '&name=' + name;
if (options) {
Object.assign(options, defaultOptions);
this.options = options;
}
else {
this.options = defaultOptions;
}
WebSocketCls = window.WebSocket;
this.isSupport = (typeof WebSocketCls != 'undefined');
if (this.isSupport) {
this.reConnect();
}
else {
console.log('not support websocket');
}
}
closeConnect() {
this.retryConnnectCount = 0;
if (this.socket) {
let socket = this.socket;
socket.onclose = null;
socket.onmessage = null;
socket.onerror = null;
socket.onopen = null;
socket.close();
this.socket = null;
}
this.status = 0;
}
delayRetryConnnect() {
clearTimeout(this._delayRetryConnnectTimer);
if (ProfileHelper.enable) {
this._delayRetryConnnectTimer = setTimeout(this._delayRetryConnnect, this.options.retryConnnectDelay);
}
}
reConnect() {
let socket = new WebSocketCls(this.url);
this.socket = socket;
socket.onclose = this.onClose;
socket.onmessage = this.onMessage;
socket.onerror = this.onError;
socket.onopen = this.onOpen;
}
dispose() {
this.closeConnect();
}
send(msg) {
if (this.socket && this.socket.readyState === 1) {
this.socket.send(msg);
return true;
}
return false;
}
}
const getParameterByName = function (name, url) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url);
if (!results)
return null;
if (!results[2])
return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
};
const idIsInList = (id, list) => {
for (let i = 0; i < list.length; i++) {
let info = list[i];
if (info.id == id) {
return true;
}
}
return false;
};
class ProfileHelper {
constructor() {
this.socketManager = null;
this.selectPlayerId = 0;
this.active = 0;
this.selectPlayerStatus = 0;
this.sendMsg = (type, data, toId = 0) => {
this.socketManager.send(JSON.stringify({
type: type,
data: data,
toId: toId
}));
};
this.sendInternalMsg = (type, data, toId = 0) => {
this.socketManager.send(JSON.stringify({
type: type,
data: data,
toId: toId
}));
};
this.frameDataList = [];
this.sendFramData = (data) => {
if (!this.active) {
return;
}
this.frameDataList.push(data);
if (this.frameDataList.length >= 30) {
this.sendFramDataList(this.frameDataList);
this.frameDataList.length = 0;
}
};
this.sendConfigData = (data = null) => {
let configData = this.performanceDataTool.getPathInfo();
this.sendInternalMsg('getPerformanceConf_back', configData);
};
this.sendFramDataList = (dataList) => {
let list = dataList.map((data) => {
return {
type: "frameData",
data: data
};
});
this.sendInternalMsg("msgList", list);
};
}
static set enable(value) {
if (ProfileHelper._enable === value) {
return;
}
ProfileHelper._enable = value;
if (value) {
const initOption = ProfileHelper.initOption;
if (!initOption) {
throw new Error('没有执行初始化init');
}
const { type, performanceDataTool, onOpen, onMessage, retryConnectCount, retryConnnectDelay } = initOption;
ProfileHelper.init(type, performanceDataTool, onOpen, onMessage, retryConnectCount, retryConnnectDelay);
}
else {
ProfileHelper.dispose();
}
}
static get enable() {
return ProfileHelper._enable;
}
init(type, performanceDataTool, onOpen, onMessage, retryConnectCount, retryConnnectDelay) {
this.frameDataList = [];
if (type === 'player' && !performanceDataTool) {
throw new Error("type为player时,performanceDataTool不为空");
}
var host = '';
var url = '';
var href = '';
if (window && window.location && window.location.href) {
href = window.location.href;
}
var name = getParameterByName('profileName', href) || '';
var port = getParameterByName('profilePort', href) || '1050';
if (ProfileHelper.Host || getParameterByName('profileHost', href)) {
host = ProfileHelper.Host || getParameterByName('profileHost', href);
}
else {
if (href.startsWith('http')) {
var index1 = href.indexOf('//');
var index2 = href.indexOf('/', index1 + 3);
if (index2 === -1) {
index2 = href.length;
}
url = href.substring(index1 + 2, index2);
index2 = url.indexOf(':');
if (index2 >= 0) {
url = url.substring(0, index2);
}
host = url;
}
else {
host = 'localhost';
}
}
this.performanceDataTool = performanceDataTool;
this.heartIntervalHandler = setInterval(() => {
this.sendInternalMsg('heart', {});
}, 1000 * 10);
this.socketManager = new SocketManager(host, port, name, type, {
retryConnectCount: retryConnectCount || defaultOptions.retryConnnectCount,
retryConnnectDelay: retryConnnectDelay || defaultOptions.retryConnnectDelay,
onMessage: (ev) => {
if (!this.socketManager) {
return;
}
if (typeof ev.data == 'string') {
let data = JSON.parse(ev.data);
let msgList = [data];
if (data.type === 'msgList') {
msgList = data.data;
}
msgList.forEach((eventData) => {
switch (eventData.type) {
case 'onSelectMe':
this.sendInternalMsg('onSelectMe_back', eventData.data);
break;
case 'getPerformanceConf':
this.sendConfigData();
break;
case 'selectPlayer_back':
this.selectPlayerId = eventData.data.selectPlayer;
this.selectPlayerStatus = 0;
break;
case 'onReady':
this.socketManager.clientId = eventData.data.id;
this.sendInternalMsg('start', {});
break;
case 'active':
this.active = eventData.data.active;
break;
case 'playerList':
if (this.selectPlayerId) {
if (!idIsInList(this.selectPlayerId, eventData.data)) {
this.selectPlayerId = 0;
this.selectPlayerStatus = 0;
}
}
if (this.selectPlayerId && eventData.data.length > 0 && this.selectPlayerStatus == 0) {
let playerId = eventData.data[0].id;
this.selectPlayerStatus = 1;
this.sendMsg('selectPlayer', { id: playerId });
}
break;
}
});
if (onMessage) {
msgList.forEach((msgData) => {
onMessage(msgData);
});
}
}
},
onOpen: (ev) => {
if (onOpen) {
onOpen(ev);
}
},
onError: (ev) => {
},
onClose: (ev) => {
}
});
}
dispose() {
clearInterval(this.heartIntervalHandler);
if (this.socketManager) {
this.socketManager.dispose();
this.socketManager = null;
}
this.performanceDataTool = null;
}
static init(type, performanceDataTool, onOpen, onMessage, retryConnectCount, retryConnnectDelay) {
if (ProfileHelper.instance) {
ProfileHelper.instance.dispose();
}
ProfileHelper.initOption = {
type,
performanceDataTool,
onOpen,
onMessage,
retryConnectCount,
retryConnnectDelay
};
if (!ProfileHelper._enable) {
return;
}
ProfileHelper.instance = new ProfileHelper();
ProfileHelper.instance.init(type, performanceDataTool, onOpen, onMessage, retryConnectCount, retryConnnectDelay);
}
}
ProfileHelper.sendFramData = (data) => {
if (!ProfileHelper._enable) {
return;
}
if (ProfileHelper.instance) {
ProfileHelper.instance.sendFramData(data);
}
};
ProfileHelper.sendConfigData = (data) => {
if (!ProfileHelper._enable) {
return;
}
if (ProfileHelper.instance) {
ProfileHelper.instance.sendConfigData(data);
}
};
ProfileHelper.dispose = () => {
if (ProfileHelper.instance) {
ProfileHelper.instance.dispose();
}
ProfileHelper.instance = null;
};
class PerformanceDataTool {
constructor() {
this._enable = false;
this._AllPathMap = {};
this._pathColor = {};
this._pathCount = 0;
this._runtimeShowPathIndex = -1;
this._nodeList = [];
this.samplerFramStep = 6;
this._memoryDataMap = {};
this.pointArray = [];
this.fpsArray = [];
}
static InitLayaPerformanceInfo() {
PerformanceDataTool.instance.InitLayaPerformanceInfo();
}
InitLayaPerformanceInfo() {
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_2D, [255, 128, 128, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D, [255, 255, 128, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER, [128, 255, 128, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_UPDATESCRIPT, [128, 255, 255, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS, [0, 128, 255, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_SIMULATE, [255, 0, 0, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_CHARACTORCOLLISION, [255, 128, 0, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_EVENTSCRIPTS, [128, 0, 0, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER, [64, 128, 128, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_SHADOWMAP, [192, 192, 192, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_CLUSTER, [128, 64, 64, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_CULLING, [0, 64, 128, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERDEPTHMDOE, [128, 0, 64, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDEROPAQUE, [128, 0, 255, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERCOMMANDBUFFER, [128, 128, 64, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERTRANSPARENT, [128, 0, 255, 255]);
this.setPathDataColor(PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_POSTPROCESS, [0, 255, 0, 255]);
}
set enable(value) {
if (value) {
this._startFram = Laya.Stat.loopCount;
this.resetReCordData();
this._sp = new Laya.Sprite();
this._sp.pos(0, 400).zOrder = 99;
Laya.Laya.stage.addChild(this._sp);
}
else {
Laya.Laya.stage.removeChild(this._sp);
}
this._enable = value;
}
get enable() {
return this._enable;
}
get enableDataExport() {
return this._enableDataExport;
}
set enableDataExport(value) {
if (value) {
ProfileHelper.init('player', this);
ProfileHelper.enable = value;
this.samplerFramStep = 1;
}
else {
ProfileHelper.enable = value;
}
this._enableDataExport = value;
}
set runtimeShowPath(path) {
let showPathIndex = this._AllPathMap[path];
for (let i in this.pointArray) {
delete this.pointArray[i];
delete PerformanceDataTool.stepLengthArrayMap[i];
}
if (showPathIndex != null)
this._runtimeShowPathIndex = showPathIndex;
else
this._runtimeShowPathIndex = -1;
}
getNodePathIndex(path) {
var id;
if (this._AllPathMap[path] != null)
id = this._AllPathMap[path];
else {
id = this._pathCount++;
this._AllPathMap[path] = id;
ProfileHelper.sendConfigData(this.getPathInfo());
}
return id;
}
getPathInfo() {
let pathInfo = {};
if (Object.keys(this._pathColor).length == 0) {
this.InitLayaPerformanceInfo();
}
pathInfo["_pathColor"] = this._pathColor;
pathInfo["_AllPathMap"] = this._AllPathMap;
return pathInfo;
}
exportPerformanceFile(fromProfiler = false) {
PerformanceDataTool.InitLayaPerformanceInfo();
if (!fromProfiler) {
this.enable = false;
}
let blockstr = [];
let blockStart = [];
let blocklength = [];
let tempNum = 0;
let blockStartPos;
let tempStartPos;
let tempEndPos;
let dataByte = new Laya.Byte();
dataByte.pos = 0;
dataByte.writeUTFString(PerformanceDataTool.VERSION);
blockstr.push("DataInfo01", "Color", "NodeInfo");
dataByte.writeUint16(blockstr.length);
for (let i = 0; i < blockstr.length; i++) {
dataByte.writeUTFString(blockstr[i]);
}
blockStart.length = blockstr.length;
blocklength.length = blockstr.length;
blockStartPos = dataByte.pos;
for (let i = 0; i < blockstr.length; i++) {
dataByte.writeInt32(0);
dataByte.writeInt32(0);
}
blockStart[0] = dataByte.pos;
dataByte.writeInt32(this._nodeList.length);
dataByte.writeInt32(this.samplerFramStep);
dataByte.writeInt32(this._pathCount);
for (let j in this._AllPathMap) {
dataByte.writeUTFString(j);
}
tempStartPos = dataByte.pos;
dataByte.writeInt32(0);
for (let k in this._memoryDataMap) {
dataByte.writeUTFString(k);
tempNum++;
}
tempEndPos = dataByte.pos;
dataByte.pos = tempStartPos;
dataByte.writeInt32(tempNum);
dataByte.pos = tempEndPos;
blocklength[0] = dataByte.pos - blockStart[0];
blockStart[1] = dataByte.pos;
tempStartPos = dataByte.pos;
tempNum = 0;
dataByte.writeInt32(0);
for (let l in this._pathColor) {
var vec4 = this._pathColor[l];
dataByte.writeUTFString(l);
dataByte.writeUint32(vec4[0]);
dataByte.writeUint32(vec4[1]);
dataByte.writeUint32(vec4[2]);
dataByte.writeUint32(vec4[3]);
tempNum++;
}
tempEndPos = dataByte.pos;
dataByte.pos = tempStartPos;
dataByte.writeInt32(tempNum);
dataByte.pos = tempEndPos;
blocklength[1] = dataByte.pos - blockStart[1];
blockStart[2] = dataByte.pos;
for (let n = 0; n < this._nodeList.length; n++) {
let node = this._nodeList[n];
dataByte.writeInt32(node.nodeNum);
for (var ii = 0; ii < node.nodeNum; ii++) {
dataByte.writeFloat32(node.nodeDelty[ii] ? node.nodeDelty[ii] : 0);
}
}
blocklength[2] = dataByte.pos - blockStart[2];
dataByte.pos = blockStartPos;
for (let v = 0; v < blockstr.length; v++) {
dataByte.writeInt32(blockStart[v]);
dataByte.writeInt32(blocklength[v]);
}
return dataByte;
}
BegainSample(samplePath) {
if (!this.enable)
return;
this.update();
this._runtimeNode.getFunStart(this.getNodePathIndex(samplePath));
}
EndSample(samplePath) {
if (!this.enable)
return 0;
return this._runtimeNode.getFunEnd(this.getNodePathIndex(samplePath));
}
AddMemory(memoryPath, size) {
this._memoryDataMap[memoryPath] = this._memoryDataMap[memoryPath] ? (this._memoryDataMap[memoryPath] + size) : size;
}
setPathDataColor(path, color) {
this._pathColor[path] = color;
}
resetReCordData() {
this._nodeList.forEach(element => {
PerforManceNode.revert(element);
});
this._nodeList = [];
this._runtimeNode = null;
this._AllPathMap = {};
this._memoryDataMap = {};
this._pathColor = {};
this._pathCount = 0;
}
exportFrontNode(ob, pathIndex) {
if (!ob || !ob.nodeDelty || pathIndex == -1) {
return;
}
const width = PerformanceDataTool.DrawWidth;
const height = PerformanceDataTool.DrawHeight;
const stepLength = PerformanceDataTool.StepLength;
const fullStepTime = 33;
const bgColor = "rgba(150, 150, 150, 0.8)";
let array, value, percent;
this._sp.graphics.clear();
this._sp.graphics.drawRect(0, 0, width, height, bgColor);
for (let i = 0, len = ob.nodeDelty.length; i < len; i++) {
if (i != pathIndex && i != this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_DELTYTIME)) {
continue;
}
value = ob.nodeDelty[i];
percent = value / fullStepTime;
if (!this.pointArray[i]) {
this.pointArray[i] = [];
}
array = this.pointArray[i];
if (array.length >= stepLength) {
array.shift();
}
array.push(percent);
let color = i.toString(16);
let fillColor = `#${color}${color}C4${color}${color}`;
if (i == this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_DELTYTIME)) {
fillColor = "#FFFFFF";
}
if (!PerformanceDataTool.stepLengthArrayMap[i]) {
PerformanceDataTool.stepLengthArrayMap[i] = new Array(PerformanceDataTool.StepLength * 2);
}
this.updatelineChart(width, height, stepLength, array, fillColor, 1, PerformanceDataTool.stepLengthArrayMap[i]);
}
this._sp.graphics.drawLine(0, height / 2, width, height / 2, "green", 1);
this._sp.graphics.drawLine(0, height / 4 * 3, width, height / 4 * 3, "red", 1);
}
updatelineChart(width, height, stepLength, array, fillColor, style, drawArray) {
switch (style) {
case 1:
let copy = drawArray;
for (let i = 0, len = array.length; i < len; i++) {
copy[i * 2] = width / stepLength * i;
copy[i * 2 + 1] = Math.max(height - array[i] * height / this.samplerFramStep, 0);
}
this._sp.graphics.drawLines(0, 0, copy, fillColor, 1);
break;
case 2:
let widthStep = width / stepLength;
for (let i = 0, len = array.length; i < len; i++) {
this._sp.graphics.drawRect(width / stepLength * i, height, widthStep, -Math.min(array[i] * height, height), fillColor);
}
}
}
update() {
let currentFrame = Laya.Stat.loopCount;
let nodelenth = ((currentFrame - this._startFram) / this.samplerFramStep) | 0;
if (!nodelenth) {
this._runtimeNode = PerforManceNode.create(this._pathCount);
this._runtimeNode.nodeDelty[this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_STARTTIME)] = performance.now();
return;
}
if (nodelenth != this._nodeList.length) {
for (let i in this._memoryDataMap) {
this._runtimeNode.setMemory(this.getNodePathIndex(i), this._memoryDataMap[i]);
}
if (this._runtimeNode) {
this._runtimeNode.nodeDelty[this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_DELTYTIME)] = performance.now() - this._runtimeNode.nodeDelty[this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_STARTTIME)];
this.exportFrontNode(this._runtimeNode, this._runtimeShowPathIndex);
ProfileHelper.sendFramData(this._runtimeNode);
}
this._runtimeNode = PerforManceNode.create(this._pathCount);
this._runtimeNode.nodeDelty[this.getNodePathIndex(PerformanceDataTool.PERFORMANCE_STARTTIME)] = performance.now();
this._nodeList.push(this._runtimeNode);
}
}
static showMemoryData(memoryPath) {
}
static showFunSampleGroup(groupPath) {
}
showFunSampleFun(samplePath) {
this.runtimeShowPath = samplePath;
}
}
PerformanceDataTool.VERSION = "PERFORMANCEDATA:01";
PerformanceDataTool.instance = new PerformanceDataTool();
PerformanceDataTool.PERFORMANCE_DELTYTIME = "deltyTime";
PerformanceDataTool.PERFORMANCE_STARTTIME = "startTime";
PerformanceDataTool.PERFORMANCE_LAYA = "Laya";
PerformanceDataTool.PERFORMANCE_LAYA_3D = "Laya/3D";
PerformanceDataTool.PERFORMANCE_LAYA_2D = "Laya/2D";
PerformanceDataTool.PERFORMANCE_LAYA_3D_PRERENDER = "Laya/3D/PreRender";
PerformanceDataTool.PERFORMANCE_LAYA_3D_UPDATESCRIPT = "Laya/3D/UpdateScript";
PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS = "Laya/3D/Physics";
PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_SIMULATE = "Laya/3D/Physics/simulate";
PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_CHARACTORCOLLISION = "Laya/3D/Physics/updataCharacters&Collisions";
PerformanceDataTool.PERFORMANCE_LAYA_3D_PHYSICS_EVENTSCRIPTS = "Laya/3D/Physics/eventScripts";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER = "Laya/3D/Render";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_SHADOWMAP = "Laya/3D/Render/ShadowMap";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_CLUSTER = "Laya/3D/Render/Cluster";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_CULLING = "Laya/3D/Render/Culling";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERDEPTHMDOE = "Laya/3D/Render/RenderDepthMode";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDEROPAQUE = "Laya/3D/Render/RenderOpaque";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERCOMMANDBUFFER = "Laya/3D/Render/RenderCommandBuffer";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_RENDERTRANSPARENT = "Laya/3D/Render/RenderTransparent";
PerformanceDataTool.PERFORMANCE_LAYA_3D_RENDER_POSTPROCESS = "Laya/3D/Render/PostProcess";
PerformanceDataTool._surpport = false;
PerformanceDataTool.DrawWidth = 250;
PerformanceDataTool.DrawHeight = 250;
PerformanceDataTool.StepLength = 250;
PerformanceDataTool.stepLengthArrayMap = new Array();
class PerforManceNode {
constructor() {
this.inPool = false;
this.nodeNum = 0;
this.nodeStart = [];
this.nodeDelty = [];
this.applyCount = 0;
}
static create(nodeNum) {
let perNode;
perNode = this._pool.length > 0 ? this._pool.pop() : new PerforManceNode();
perNode.resetData(nodeNum);
perNode.inPool = false;
return perNode;
}
static revert(node) {
node.inPool = true;
this._pool.push(node);
node.clearData();
}
clearData() {
this.nodeStart.length = 0;
this.nodeDelty.length = 0;
}
resetData(nodeNum) {
this.nodeNum = nodeNum;
this.nodeStart.length = nodeNum;
this.nodeDelty.length = nodeNum;
}
getFunStart(index) {
this.applyCount++;
this.nodeStart[index] = performance.now();
}
getFunEnd(index) {
if (this.nodeDelty[index])
this.nodeDelty[index] += (this.nodeStart[index] != 0) ? (performance.now() - this.nodeStart[index]) : 0;
else {
this.nodeDelty[index] = (this.nodeStart[index] != 0) ? (performance.now() - this.nodeStart[index]) : 0;
this.nodeNum = this.nodeDelty.length;
}
return this.nodeDelty[index];
}
setMemory(index, value) {
this.nodeDelty[index] = value;
}
getPathData(index) {
return this.nodeDelty[index];
}
}
PerforManceNode._pool = [];
class PerformanceNodeParse {
static parsePerformanceFile(performance, outData) {
performance.pos = 0;
PerformanceNodeParse.performanceData = outData;
PerformanceNodeParse._readData = performance;
PerformanceNodeParse.READ_DATA();
for (let i = 0, n = PerformanceNodeParse._blockStr.length; i < n; i++) {
var blockName = PerformanceNodeParse._blockStr[i];
var fn = PerformanceNodeParse["READ_" + blockName];
if (fn == null)
throw new Error("model file err,no this function:" + blockName);
else {
PerformanceNodeParse._readData.pos = PerformanceNodeParse._blockStart[i];
fn.call(null);
}
}
}
static READ_DATA() {
let data = PerformanceNodeParse._readData;
let version = data.readUTFString();
if (version != "PERFORMANCEDATA:01") {
throw version + "is not standard Version";
}
let blocklenth = PerformanceNodeParse._blockStr.length = data.readUint16();
for (let i = 0; i < blocklenth; i++) {
PerformanceNodeParse._blockStr[i] = data.readUTFString();
}
for (let j = 0; j < blocklenth; j++) {
PerformanceNodeParse._blockStart[j] = data.readInt32();
PerformanceNodeParse._blocklength[j] = data.readInt32();
}
}
static READ_DataInfo01() {
let data = PerformanceNodeParse._readData;
let performanceData = PerformanceNodeParse.performanceData;
PerformanceNodeParse._nodeNums = data.readInt32();
performanceData.samplerFramStep = data.readInt32();
let pathCount = data.readInt32();
for (let i = 0; i < pathCount; i++) {
performanceData.getNodePathIndex(data.readUTFString());
}
let memoryPath = data.readInt32();
for (let j = 0; j < memoryPath; j++) {
performanceData._memoryDataMap[data.readUTFString()] = 1;
}
}
static READ_Color() {
let data = PerformanceNodeParse._readData;
let performanceData = PerformanceNodeParse.performanceData;
let colorlength = data.readInt32();
for (let i = 0; i < colorlength; i++)
performanceData.setPathDataColor(data.readUTFString(), [data.readUint32(), data.readUint32(), data.readUint32(), data.readUint32()]);
}
static READ_NodeInfo() {
let data = PerformanceNodeParse._readData;
let performanceData = PerformanceNodeParse.performanceData;
let perNode;
let length;
for (let i = 0; i < PerformanceNodeParse._nodeNums; i++) {
length = data.readInt32();
perNode = PerforManceNode.create(length);
for (let l = 0, n = length; l < n; l++)
perNode.nodeDelty[l] = data.readFloat32();
performanceData._nodeList[i] = perNode;
}
}
}
PerformanceNodeParse._blockStr = [];
PerformanceNodeParse._blockStart = [];
PerformanceNodeParse._blocklength = [];
PerformanceNodeParse.performanceData = new PerformanceDataTool();
exports.PerforManceNode = PerforManceNode;
exports.PerformanceDataTool = PerformanceDataTool;
exports.PerformanceNodeParse = PerformanceNodeParse;
}(window.Laya = window.Laya || {}, Laya));
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
window.Physics3D = function(initialMemory, interactive) {
window.conch.setGetWorldTransformFunction(interactive.getWorldTransform);
window.conch.setSetWorldTransformFunction(interactive.setWorldTransform);
var conchBullet = window.layaConchBullet;
conchBullet.then = (complete) => {
complete();
};
window.Physics3D = conchBullet;
return conchBullet;
};
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,745 @@
(function (exports, Laya) {
'use strict';
class SpineGLTexture extends Laya.Texture {
constructor(tex) {
super(tex);
}
getImage() {
return {
width: this.sourceWidth,
height: this.sourceHeight
};
}
setFilters(minFilter, magFilter) {
}
setWraps(uWrap, vWrap) {
}
}
var Color = spine.Color;
var SkeletonClipping = spine.SkeletonClipping;
var Vector2 = spine.Vector2;
var Utils = spine.Utils;
var RegionAttachment = spine.RegionAttachment;
var MeshAttachment = spine.MeshAttachment;
var ClippingAttachment = spine.ClippingAttachment;
class Renderable {
constructor(vertices, numVertices, numFloats) {
this.vertices = vertices;
this.numVertices = numVertices;
this.numFloats = numFloats;
}
}
class SpineSkeletonRenderer {
constructor(twoColorTint = true) {
this.vertexEffect = null;
this.tempColor = new Color();
this.tempColor2 = new Color();
this.vertexSize = 2 + 2 + 4;
this.twoColorTint = false;
this.renderable = new Renderable(null, 0, 0);
this.clipper = new SkeletonClipping();
this.temp = new Vector2();
this.temp2 = new Vector2();
this.temp3 = new Color();
this.temp4 = new Color();
this.twoColorTint = twoColorTint;
if (twoColorTint)
this.vertexSize += 4;
this.vertices = Utils.newFloatArray(this.vertexSize * 1024);
}
draw(skeleton, slotRangeStart = -1, slotRangeEnd = -1, spineSkeletonIns, textureList) {
let clipper = this.clipper;
let premultipliedAlpha = this.premultipliedAlpha;
let twoColorTint = false;
let tempPos = this.temp;
let tempUv = this.temp2;
let tempLight = this.temp3;
let tempDark = this.temp4;
let renderable = this.renderable;
let uvs = null;
let triangles = null;
let drawOrder = skeleton.drawOrder;
let attachmentColor = null;
let skeletonColor = skeleton.color;
let vertexSize = 8;
let inRange = false;
if (slotRangeStart == -1)
inRange = true;
for (let i = 0, n = drawOrder.length; i < n; i++) {
let clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;
let slot = drawOrder[i];
if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {
inRange = true;
}
if (!inRange) {
clipper.clipEndWithSlot(slot);
continue;
}
if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {
inRange = false;
}
let attachment = slot.getAttachment();
let name = null;
let texture;
if (attachment instanceof RegionAttachment) {
let region = attachment;
renderable.vertices = this.vertices;
renderable.numVertices = 4;
renderable.numFloats = clippedVertexSize << 2;
region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);
triangles = SpineSkeletonRenderer.QUAD_TRIANGLES;
uvs = region.uvs;
name = region.region.renderObject.page.name;
texture = textureList[name];
attachmentColor = region.color;
}
else if (attachment instanceof MeshAttachment) {
let mesh = attachment;
renderable.vertices = this.vertices;
renderable.numVertices = (mesh.worldVerticesLength >> 1);
renderable.numFloats = renderable.numVertices * clippedVertexSize;
if (renderable.numFloats > renderable.vertices.length) {
renderable.vertices = this.vertices = Utils.newFloatArray(renderable.numFloats);
}
mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
triangles = mesh.triangles;
name = mesh.region.renderObject.page.name;
texture = textureList[name];
uvs = mesh.uvs;
attachmentColor = mesh.color;
}
else if (attachment instanceof ClippingAttachment) {
let clip = (attachment);
clipper.clipStart(slot, clip);
continue;
}
else {
clipper.clipEndWithSlot(slot);
continue;
}
if (texture != null) {
let slotColor = slot.color;
let finalColor = this.tempColor;
finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
if (premultipliedAlpha) {
finalColor.r *= finalColor.a;
finalColor.g *= finalColor.a;
finalColor.b *= finalColor.a;
}
let slotBlendMode = slot.data.blendMode;
if (clipper.isClipping()) {
clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, null, twoColorTint);
let clippedVertices = new Float32Array(clipper.clippedVertices);
let clippedTriangles = clipper.clippedTriangles;
let mVertices = [];
let mUVs = [];
let colors = [];
if (this.vertexEffect != null) {
let vertexEffect = this.vertexEffect;
let verts = clippedVertices;
{
for (let v = 0, n = clippedVertices.length; v < n; v += vertexSize) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
tempUv.x = verts[v + 6];
tempUv.y = verts[v + 7];
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
mVertices.push(verts[v], -verts[v + 1]);
colors.push(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
mUVs.push(verts[v + 6], verts[v + 7]);
}
}
}
else {
let vi = 0;
while (Number.isFinite(clippedVertices[vi + 6]) && Number.isFinite(clippedVertices[vi + 7])) {
mVertices.push(clippedVertices[vi]);
mVertices.push(-clippedVertices[vi + 1]);
colors.push(clippedVertices[vi + 2]);
colors.push(clippedVertices[vi + 3]);
colors.push(clippedVertices[vi + 4]);
colors.push(clippedVertices[vi + 5]);
mUVs.push(clippedVertices[vi + 6]);
mUVs.push(clippedVertices[vi + 7]);
vi += this.vertexSize;
}
}
let alpha = 1;
let color = null;
let colorNum = null;
let blendMode;
switch (slotBlendMode) {
case 1:
blendMode = "light";
break;
case 2:
blendMode = "multiply";
break;
case 3:
blendMode = "screen";
break;
default:
blendMode = "normal";
}
colorNum = ((colors[3] * 255) << 24) + colors[0] * 255 | 0 + ((colors[1] * 255) << 8) + ((colors[2] * 255) << 16);
spineSkeletonIns.graphics.drawTriangles(texture, 0, 0, mVertices, mUVs, new Uint16Array(clippedTriangles), Laya.Matrix.EMPTY, alpha, color, blendMode, colorNum);
}
else {
let verts = renderable.vertices;
let mVertices = [];
let mUVs = [];
let colors = [];
if (this.vertexEffect != null) {
let vertexEffect = this.vertexEffect;
{
for (let v = 0, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
mVertices.push(verts[v], -verts[v + 1]);
colors.push(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
mUVs.push(verts[v + 6], verts[v + 7]);
}
}
}
else {
{
for (let v = 2, u = 0, n = renderable.numFloats; v < n; v += vertexSize, u += 2) {
verts[v] = finalColor.r;
verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b;
verts[v + 3] = finalColor.a;
verts[v + 4] = uvs[u];
verts[v + 5] = uvs[u + 1];
mVertices.push(verts[v - 2], -verts[v - 1]);
colors.push(verts[v], verts[v + 1], verts[v + 2], verts[v + 3]);
mUVs.push(verts[v + 4], verts[v + 5]);
}
}
}
let alpha = 1;
let color = null;
let colorNum = null;
let blendMode;
switch (slotBlendMode) {
case 1:
blendMode = "light";
break;
case 2:
blendMode = "multiply";
break;
case 3:
blendMode = "screen";
break;
default:
blendMode = "normal";
}
colorNum = ((colors[3] * 255) << 24) + colors[0] * 255 | 0 + ((colors[1] * 255) << 8) + ((colors[2] * 255) << 16);
spineSkeletonIns.graphics.drawTriangles(texture, 0, 0, mVertices, mUVs, new Uint16Array(triangles), Laya.Matrix.EMPTY, alpha, color, blendMode, colorNum);
}
}
clipper.clipEndWithSlot(slot);
}
clipper.clipEnd();
}
}
SpineSkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
var TimeKeeper = spine.TimeKeeper;
var Skeleton = spine.Skeleton;
var AnimationState = spine.AnimationState;
var AnimationStateData = spine.AnimationStateData;
class SpineSkeleton extends Laya.Sprite {
constructor(templet = null) {
super();
this.currentPlayTime = 0;
this._pause = true;
this._currAniName = null;
this._playbackRate = 1.0;
this._playAudio = true;
this._soundChannelArr = [];
this.trackIndex = 0;
if (templet)
this.init(templet);
this._ins = this;
}
init(templet) {
var that = this;
this._templet = templet;
this.skeleton = new Skeleton(this._templet.skeletonData);
this.stateData = new AnimationStateData(this.skeleton.data);
this.state = new AnimationState(this.stateData);
this.skeletonRenderer = new SpineSkeletonRenderer(false);
this.timeKeeper = new TimeKeeper();
this.skeletonRenderer.premultipliedAlpha = this._templet._spinePremultipliedAlpha;
this.state.addListener({
start: function (entry) {
},
interrupt: function (entry) {
},
end: function (entry) {
},
dispose: function (entry) {
},
complete: function (entry) {
if (entry.loop) {
that.event(Laya.Event.COMPLETE);
}
else {
that._currAniName = null;
that.event(Laya.Event.STOPPED);
}
},
event: function (entry, event) {
var eventData = {
audioValue: event.data.audioPath,
audioPath: event.data.audioPath,
floatValue: event.floatValue,
intValue: event.intValue,
name: event.data.name,
stringValue: event.stringValue,
time: event.time * 1000,
balance: event.balance,
volume: event.volume
};
that.event(Laya.Event.LABEL, eventData);
var _soundChannel;
if (that._playAudio && eventData.audioValue) {
_soundChannel = Laya.SoundManager.playSound(templet._textureDic.root + eventData.audioValue, 1, Laya.Handler.create(that, that._onAniSoundStoped), null, (that.currentPlayTime * 1000 - eventData.time) / 1000);
Laya.SoundManager.playbackRate = that._playbackRate;
_soundChannel && that._soundChannelArr.push(_soundChannel);
}
},
});
}
play(nameOrIndex, loop, force = true, start = 0, end = 0, freshSkin = true, playAudio = true) {
this._playAudio = playAudio;
start /= 1000;
end /= 1000;
var animationName = nameOrIndex;
if (start < 0 || end < 0)
throw new Error("SpineSkeleton: start and end must large than zero.");
if ((end !== 0) && (start > end))
throw new Error("SpineSkeleton: start must less than end.");
if (typeof animationName == "number") {
animationName = this.getAniNameByIndex(nameOrIndex);
}
if (force || this._pause || this._currAniName != animationName) {
this._currAniName = animationName;
this.state.setAnimation(this.trackIndex, animationName, loop);
let trackEntry = this.state.getCurrent(this.trackIndex);
trackEntry.animationStart = start;
if (!!end && end < trackEntry.animationEnd)
trackEntry.animationEnd = end;
let animationDuration = trackEntry.animation.duration;
this._duration = animationDuration;
this._playStart = start;
this._playEnd = end <= animationDuration ? end : animationDuration;
if (this._pause) {
this._pause = false;
this.timer.frameLoop(1, this, this._update, null, true);
}
this._update();
}
}
_update() {
this.timeKeeper.update();
let delta = this.timeKeeper.delta * this._playbackRate;
let trackEntry = this.state.getCurrent(this.trackIndex);
this.state.update(delta);
this.state.apply(this.skeleton);
let animationLast = trackEntry.animationLast;
this.currentPlayTime = Math.max(0, animationLast);
if (!this.state || !this.skeleton) {
return;
}
this.skeleton.updateWorldTransform();
this._ins.graphics.clear();
this.skeletonRenderer.draw(this.skeleton, -1, -1, this._ins, this._templet._textureDic);
}
getAnimNum() {
return this._templet.skeletonData.animations.length;
}
getAniNameByIndex(index) {
return this._templet.getAniNameByIndex(index);
}
getSlotByName(slotName) {
return this.skeleton.findSlot(slotName);
}
playbackRate(value) {
this._playbackRate = value;
}
showSkinByName(name) {
this.showSkinByIndex(this._templet.getSkinIndexByName(name));
}
showSkinByIndex(skinIndex) {
let newSkine = this.skeleton.data.skins[skinIndex];
this.skeleton.setSkin(newSkine);
this.skeleton.setSlotsToSetupPose();
}
stop() {
if (!this._pause) {
this._pause = true;
this._currAniName = null;
this.timer.clear(this, this._update);
this.state.update(-this.currentPlayTime);
this.currentPlayTime = 0;
this.event(Laya.Event.STOPPED);
if (this._soundChannelArr.length > 0) {
this._onAniSoundStoped(true);
}
}
}
paused() {
if (!this._pause) {
this._pause = true;
this.timer.clear(this, this._update);
this.event(Laya.Event.PAUSED);
if (this._soundChannelArr.length > 0) {
var _soundChannel;
for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
_soundChannel = this._soundChannelArr[i];
if (!_soundChannel.isStopped) {
_soundChannel.pause();
}
}
}
}
}
resume() {
if (this._pause) {
this._pause = false;
this.timer.frameLoop(1, this, this._update, null, true);
if (this._soundChannelArr.length > 0) {
var _soundChannel;
for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
_soundChannel = this._soundChannelArr[i];
if (_soundChannel.audioBuffer) {
_soundChannel.resume();
}
}
}
}
}
_onAniSoundStoped(force) {
var _channel;
for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
_channel = this._soundChannelArr[i];
if (_channel.isStopped || force) {
!_channel.isStopped && _channel.stop();
this._soundChannelArr.splice(i, 1);
len--;
i--;
}
}
}
destroy(destroyChild = true) {
super.destroy(destroyChild);
this._templet._removeReference(1);
this._templet = null;
this.timeKeeper = null;
this.skeleton = null;
this.state.clearListeners();
this.state = null;
this.skeletonRenderer = null;
this.timer.clear(this, this._update);
if (this._soundChannelArr.length > 0) {
this._onAniSoundStoped(true);
}
}
get templet() {
return this._templet;
}
addAnimation(nameOrIndex, loop = false, delay = 0) {
delay /= 1000;
var animationName = nameOrIndex;
if (typeof animationName == "number") {
animationName = this.getAniNameByIndex(animationName);
}
this._currAniName = animationName;
this.state.addAnimation(this.trackIndex, animationName, loop, delay);
}
setMix(fromNameOrIndex, toNameOrIndex, duration) {
duration /= 1000;
var fromName = fromNameOrIndex;
if (typeof fromName == "number") {
fromName = this.getAniNameByIndex(fromName);
}
var toName = toNameOrIndex;
if (typeof toName == "number") {
toName = this.getAniNameByIndex(toName);
}
this.stateData.setMix(fromName, toName, duration);
}
getBoneByName(boneName) {
return this.skeleton.findBone(boneName);
}
getSkeleton() {
return this.skeleton;
}
setSlotAttachment(slotName, attachmentName) {
this.skeleton.setAttachment(slotName, attachmentName);
}
set currentTime(value) {
if (!this._currAniName || !this._templet)
return;
value /= 1000;
if (value < this._playStart || (!!this._playEnd && value > this._playEnd) || value > this._duration)
throw new Error("AnimationPlayer: value must large than playStartTime,small than playEndTime.");
this.state.update(value - this.currentPlayTime);
this.currentPlayTime = value;
}
get playState() {
if (!this._currAniName)
return SpineSkeleton.stopped;
if (this._pause)
return SpineSkeleton.paused;
return SpineSkeleton.playing;
}
}
SpineSkeleton.stopped = 0;
SpineSkeleton.paused = 1;
SpineSkeleton.playing = 2;
Laya.ILaya.regClass(SpineSkeleton);
Laya.ClassUtils.regClass("laya.layaspine.SpineSkeleton", SpineSkeleton);
Laya.ClassUtils.regClass("Laya.SpineSkeleton", SpineSkeleton);
var SharedAssetManager = spine.SharedAssetManager;
var TextureAtlas = spine.TextureAtlas;
var AtlasAttachmentLoader = spine.AtlasAttachmentLoader;
var SkeletonJson = spine.SkeletonJson;
class SpineTemplet extends Laya.Resource {
constructor() {
super();
this._textureDic = {};
this._isDestroyed = false;
this._layaPremultipliedAlpha = true;
this._spinePremultipliedAlpha = false;
}
loadAni(jsonUrl, textureUrlList = null) {
let splitIndex = jsonUrl.lastIndexOf("/") + 1;
let clientId = jsonUrl.slice(0, splitIndex);
jsonUrl = jsonUrl.slice(splitIndex);
let atlasUrl = jsonUrl.replace(".json", ".atlas");
if (!textureUrlList) {
textureUrlList = [jsonUrl.replace(".json", ".png")];
}
this._textureDic.root = clientId;
this._textureUrlList = textureUrlList;
this.clientId = clientId;
this.atlasUrl = atlasUrl;
this.jsonUrl = jsonUrl;
this.assetManager = new SharedAssetManager(clientId);
this.assetManager.loadJson(clientId, jsonUrl);
this.assetManager.loadText(clientId, atlasUrl);
for (var i = 0, len = textureUrlList.length, texture; i < len; i++) {
texture = textureUrlList[i];
this.assetManager.loadTexture(clientId, this.textureLoader.bind(this), texture);
}
window.requestAnimationFrame(this.loop.bind(this));
}
textureLoader(tex) {
var src = tex.url;
var tTextureName, item, textureUrlList = this._textureUrlList;
for (var i = 0, len = textureUrlList.length; i < len; i++) {
item = textureUrlList[i];
if (src.endsWith(`/${item}`)) {
tTextureName = item;
break;
}
}
var tTexture = this._textureDic[tTextureName] = new SpineGLTexture(tex.bitmap);
return tTexture;
}
loop() {
if (this.assetManager.isLoadingComplete(this.clientId)) {
this.parseSpineAni();
return;
}
if (this.assetManager.hasErrors()) {
this.event(Laya.Event.ERROR, "load failed:" + this.assetManager.getErrors());
return;
}
window.requestAnimationFrame(this.loop.bind(this));
}
parseSpineAni() {
if (this._isDestroyed) {
this.destroy();
return;
}
var _this = this;
var atlas = new TextureAtlas(this.assetManager.get(this.clientId, this.atlasUrl), function (path) {
return _this.assetManager.get(_this.clientId, path);
});
var atlasLoader = new AtlasAttachmentLoader(atlas);
this.skeletonJson = new SkeletonJson(atlasLoader);
this.skeletonData = this.skeletonJson.readSkeletonData(this.assetManager.get(this.clientId, this.jsonUrl));
this.event(Laya.Event.COMPLETE, this);
}
buildArmature() {
return new SpineSkeleton(this);
}
getAniNameByIndex(index) {
var tAni = this.skeletonData.animations[index];
if (tAni)
return tAni.name;
return null;
}
getSkinIndexByName(skinName) {
var skins = this.skeletonData.skins;
var tSkinData;
for (var i = 0, n = skins.length; i < n; i++) {
tSkinData = skins[i];
if (tSkinData.name == skinName) {
return i;
}
}
return -1;
}
destroy() {
this._isDestroyed = true;
var tTexture;
for (tTexture in this._textureDic) {
if (tTexture == "root")
continue;
if (tTexture) {
this._textureDic[tTexture].destroy();
}
}
super.destroy();
}
}
var AssetManager = spine.AssetManager;
var AtlasAttachmentLoader$1 = spine.AtlasAttachmentLoader;
var SkeletonBinary = spine.SkeletonBinary;
class SpineTempletBinary extends Laya.Resource {
constructor() {
super();
this._textureDic = {};
this._isDestroyed = false;
this._layaPremultipliedAlpha = true;
this._spinePremultipliedAlpha = false;
}
loadAni(skelUrl, textureUrlList = null) {
let splitIndex = skelUrl.lastIndexOf("/") + 1;
let pathPrefix = skelUrl.slice(0, splitIndex);
skelUrl = skelUrl.slice(splitIndex);
this.skelUrl = skelUrl;
skelUrl = skelUrl.replace(".json", ".skel");
let atlasUrl = skelUrl.replace(".skel", ".atlas");
if (!textureUrlList) {
textureUrlList = [skelUrl.replace(".skel", ".png")];
}
this._textureDic.root = pathPrefix;
this.pathPrefix = pathPrefix;
this.atlasUrl = atlasUrl;
this.textureUrlList = textureUrlList;
this.assetManager = new AssetManager(this.textureLoader.bind(this), pathPrefix);
this.assetManager.loadBinary(this.skelUrl);
this.assetManager.loadTextureAtlas(atlasUrl);
Laya.Laya.timer.frameOnce(1, this, this.loop);
}
textureLoader(tex) {
let src = tex.url;
let tTextureName, item, textureUrlList = this.textureUrlList;
for (let i = 0, len = textureUrlList.length; i < len; i++) {
item = textureUrlList[i];
if (src.endsWith(item)) {
tTextureName = item;
break;
}
}
let tTexture = this._textureDic[tTextureName] = new SpineGLTexture(tex.bitmap);
return tTexture;
}
loop() {
if (this.assetManager.isLoadingComplete()) {
this.parseSpineAni();
return;
}
if (this.assetManager.hasErrors()) {
this.event(Laya.Event.ERROR, "load failed:" + this.assetManager.getErrors());
return;
}
window.requestAnimationFrame(this.loop.bind(this));
}
parseSpineAni() {
if (this._isDestroyed) {
this.destroy();
return;
}
let atlas = this.assetManager.get(this.atlasUrl);
let atlasLoader = new AtlasAttachmentLoader$1(atlas);
this.skeletonBinary = new SkeletonBinary(atlasLoader);
this.skeletonData = this.skeletonBinary.readSkeletonData(this.assetManager.get(this.skelUrl));
this.event(Laya.Event.COMPLETE, this);
}
buildArmature() {
return new SpineSkeleton(this);
}
getAniNameByIndex(index) {
let tAni = this.skeletonData.animations[index];
if (tAni)
return tAni.name;
return null;
}
getSkinIndexByName(skinName) {
let skins = this.skeletonData.skins;
let tSkinData;
for (let i = 0, n = skins.length; i < n; i++) {
tSkinData = skins[i];
if (tSkinData.name == skinName) {
return i;
}
}
return -1;
}
destroy() {
this._isDestroyed = true;
let tTexture;
for (tTexture in this._textureDic) {
if (tTexture == "root")
continue;
if (tTexture) {
this._textureDic[tTexture].destroy();
}
}
super.destroy();
}
}
exports.SpineGLTexture = SpineGLTexture;
exports.SpineSkeleton = SpineSkeleton;
exports.SpineSkeletonRenderer = SpineSkeletonRenderer;
exports.SpineTemplet = SpineTemplet;
exports.SpineTempletBinary = SpineTempletBinary;
}(window.Laya = window.Laya || {}, Laya));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
window.Physics3D=function(n,o){window.conch.setGetWorldTransformFunction(o.getWorldTransform),window.conch.setSetWorldTransformFunction(o.setWorldTransform);var r=window.layaConchBullet;return r.then=n=>{n()},window.Physics3D=r,r};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
var createImageBitmapOK=!!self.createImageBitmap;onmessage=function(e){loadImage2(e.data),isSet||(isSet=!0,setInterval(workerloop,1e3))};var isSet=!0;function workerloop(){myTrace("png:workerloop")}var enableTrace=!1,ifShowTraceToMain=!1;function myTrace(e){enableTrace&&(console.log("png:"+e),ifShowTraceToMain&&showMsgToMain(e))}function loadImage2(e){var a,o=!1;(a=new XMLHttpRequest).open("GET",e,!0),a.responseType="arraybuffer",myTrace("load:"+e),a.onload=function(){var t=a.response||a.mozResponseArrayBuffer;(myTrace("onload:"+e),200!=a.status&&0!=a.status||t.byteLength<10)?o||(o=!0,pngFail(e,"loadFail from onload"+a.status)):doCreateImageBitmap(new Uint8Array(t),e)},a.onerror=function(a){pngFail(e,"loadFail")},a.send(null)}function doCreateImageBitmap(e,a){try{var o=getTimeNow();e=new self.Blob([e],{type:"image/png"}),self.createImageBitmap(e).then((function(e){var t={};t.url=a,t.imageBitmap=e,t.dataType="imageBitmap",t.startTime=o,t.decodeTime=getTimeNow()-o,t.sendTime=getTimeNow(),myTrace("png:Decode By createImageBitmap,"+t.decodeTime,a),t.type="Image",postMessage(t,[t.imageBitmap])})).catch((function(e){showMsgToMain("catch e:"+e),pngFail(a,"parse fail"+e+":ya")}))}catch(e){pngFail(a,"parse fail"+e.toString()+":ya")}}function getTimeNow(){return(new Date).getTime()}function disableWorker(e){var a={};a.url=url,a.imagedata=null,a.type="Disable",a.msg=e,postMessage(a)}function pngFail(e,a){var o={};o.url=e,o.imagedata=null,o.type="Image",o.msg=a,console.log("png:"+a+" "+e),postMessage(o)}function showMsgToMain(e){var a={type:"Msg"};a.msg=e,postMessage(a)}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,132 @@
var createImageBitmapOK=self.createImageBitmap?true:false;
onmessage =function (evt){
var data = evt.data;//通过evt.data获得发送来的数据
loadImage2(data);
if(!isSet)
{
isSet=true;
setInterval(workerloop,1000);
}
}
var isSet=true;
function workerloop()
{
myTrace("png:workerloop");
}
var enableTrace=false;
var ifShowTraceToMain=false;
function myTrace(msg)
{
if(!enableTrace) return;
console.log("png:"+msg)
if(ifShowTraceToMain)
{
showMsgToMain(msg);
}
}
function loadImage2(url)
{
var xhr,
_this = this;
var failed=false;
xhr = new XMLHttpRequest;
xhr.open("GET", url, true);
//showMsgToMain("loadImage2");
xhr.responseType = "arraybuffer";
myTrace("load:"+url);
xhr.onload = function() {
var response=xhr.response || xhr.mozResponseArrayBuffer;
//showMsgToMain("onload:");
myTrace("onload:"+url);
if((xhr.status != 200&&xhr.status!=0)||response.byteLength<10)
{
if(!failed)
{
failed=true;
pngFail(url,"loadFail from onload"+xhr.status);
}
return;
}
var data, png;
data = new Uint8Array(response);
doCreateImageBitmap(data,url);
};
xhr.onerror = function(e){
pngFail(url,"loadFail");
}
xhr.send(null);
}
function doCreateImageBitmap(response,url)
{
try
{
//showMsgToMain("hihidoCreateImageBitmap");
//showMsgToMain("doCreateImageBitmap:"+response);
//var startTime=getTimeNow();
//showMsgToMain("new self.Blob");
var startTime=getTimeNow();
response = new self.Blob([response],{type:"image/png"});
self.createImageBitmap(response).then(function(imageBitmap) {
//showMsgToMain("imageBitmapCreated:");
var data={};
data.url=url;
data.imageBitmap=imageBitmap;
data.dataType="imageBitmap";
data.startTime=startTime;
data.decodeTime=getTimeNow()-startTime;
data.sendTime=getTimeNow();
myTrace("png:Decode By createImageBitmap,"+data.decodeTime,url);
data.type="Image";
postMessage(data,[data.imageBitmap]);
}).catch(
function(e)
{
showMsgToMain("catch e:"+e);
pngFail(url,"parse fail"+e+":ya");
}
)
}catch(e)
{
pngFail(url,"parse fail"+e.toString()+":ya");
}
}
function getTimeNow()
{
return new Date().getTime();
}
function disableWorker(msg)
{
var data={};
data.url=url;
data.imagedata=null;
data.type="Disable";
data.msg=msg;
postMessage(data);
}
function pngFail(url,msg)
{
var data={};
data.url=url;
data.imagedata=null;
data.type="Image";
data.msg=msg;
console.log("png:"+msg+" "+url);
postMessage(data);
}
function showMsgToMain(msg)
{
var data={};
data.type="Msg";
data.msg=msg;
postMessage(data);
}
@@ -0,0 +1 @@
{"type":"Sprite","props":{"y":0,"x":0,"texture":"test/c2.png","presetID":1,"name":"buttle","isPresetRoot":true,"group":-2},"compId":1,"child":[{"type":"Script","props":{"radius":15,"presetID":2,"label":"buttle","isSensor":true,"runtime":"Laya.CircleCollider"},"compId":2},{"type":"Script","props":{"type":"kinematic","presetID":3,"group":-2,"runtime":"Laya.RigidBody"},"compId":3},{"type":"Script","props":{"presetID":4,"runtime":"script/Bullet.ts"},"compId":6}],"loadList":["test/c2.png"],"loadList3D":[]}
@@ -0,0 +1 @@
{"type":"Sprite","props":{"texture":"test/b1.png","presetID":1,"pivotY":50,"pivotX":50,"name":"levelTxt","isPresetRoot":true,"group":1,"gravityScale":0.5},"compId":1,"child":[{"type":"Script","props":{"width":100,"presetID":2,"height":100,"runtime":"Laya.BoxCollider"},"compId":2},{"type":"Script","props":{"type":"dynamic","presetID":3,"group":-1,"gravityScale":0.5,"runtime":"Laya.RigidBody"},"compId":3},{"type":"Text","props":{"y":0,"x":11.5,"width":77,"valign":"middle","text":"1","presetID":4,"name":"levelTxt","height":100,"fontSize":100,"color":"#ffffff","align":"center","runtime":"Laya.Text"},"compId":4},{"type":"Script","props":{"presetID":5,"runtime":"script/DropBox.ts"},"compId":9}],"loadList":["test/b1.png"],"loadList3D":[]}
@@ -0,0 +1,53 @@
D .
D comp
P 316AD948 btn_close.png
P 5B258D17 button.png
P 3C493DD4 check_circle.png
P 98E54F0D checkbox.png
P 6B7AB858 clip_num.png
P 63A22FAC clip_tree_arrow.png
P D749C312 clip_tree_folder.png
P 8E9C8386 colorPicker.png
P 704C5D70 combobox.png
P D566AE8B fontClip.png
P 38AB8F3F fontClip_num.png
P 6EF336AE hscroll$bar.png
P 7FF47AC5 hscroll$down.png
P 3D7B147A hscroll$up.png
P 750BD445 hscroll.png
P 9A5EF899 hslider$bar.png
P 9CED7132 hslider.png
P BA2A0579 html.png
P 8236CD48 image.png
P 4ACB7AEF img_bg.png
P FCD04607 img_bg2.png
P 23FB4D29 img_bg3.png
P 5FD17798 img_bg4.png
P 2BE22124 img_bg5.png
P BA28BD65 img_blank.png
P BA2A0579 label.png
P B017E53E progress$bar.png
P C05839CD progress.png
P 3C493DD4 radio.png
P 3C493DD4 radiogroup.png
P 5BA25C15 tab.png
P A3D7A036 textarea.png
P A3D7A036 textinput.png
P 2DCE1DF9 vscroll$bar.png
P 6FE7EA34 vscroll$down.png
P 0587871F vscroll$up.png
P 5FD17798 vscroll.png
P DDDDFB9E vslider$bar.png
P 01BAE7F5 vslider.png
D sound
R 1DC3ABD8 destroy.wav
R FF0B6E8D hit.wav
D test
P 1DFA6065 b1.png
P 90AE1DE1 b2.png
P 9A09F804 block.png
P 65CC7075 c1.png
P 4D16AC06 c2.png
P 39B957DA p1.png
P 2E1973F5 t1.png
P F8700A3B tra.png
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

@@ -0,0 +1 @@
{"frames":{"b1.png":{"frame":{"h":100,"idx":0,"w":100,"x":155,"y":0},"sourceSize":{"h":100,"w":100},"spriteSourceSize":{"x":0,"y":0}},"b2.png":{"frame":{"h":30,"idx":0,"w":30,"x":57,"y":186},"sourceSize":{"h":30,"w":30},"spriteSourceSize":{"x":0,"y":0}},"block.png":{"frame":{"h":20,"idx":0,"w":20,"x":57,"y":217},"sourceSize":{"h":20,"w":20},"spriteSourceSize":{"x":0,"y":0}},"c1.png":{"frame":{"h":100,"idx":0,"w":100,"x":0,"y":85},"sourceSize":{"h":100,"w":100},"spriteSourceSize":{"x":0,"y":0}},"c2.png":{"frame":{"h":30,"idx":0,"w":30,"x":88,"y":202},"sourceSize":{"h":30,"w":30},"spriteSourceSize":{"x":0,"y":0}},"p1.png":{"frame":{"h":54,"idx":0,"w":56,"x":0,"y":186},"sourceSize":{"h":64,"w":64},"spriteSourceSize":{"x":4,"y":5}},"t1.png":{"frame":{"h":100,"idx":0,"w":100,"x":101,"y":101},"sourceSize":{"h":100,"w":100},"spriteSourceSize":{"x":0,"y":0}},"tra.png":{"frame":{"h":84,"idx":0,"w":154,"x":0,"y":0},"sourceSize":{"h":84,"w":154},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"test.png","prefix":"test/"}}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
{"type":"Scene","props":{"width":640,"runtime":"script/GameUI.ts","name":"gameBox","height":1136},"compId":1,"child":[{"type":"Sprite","props":{"y":1116,"x":-83,"width":805,"texture":"test/block.png","name":"ground","height":20},"compId":3,"child":[{"type":"Script","props":{"y":0,"x":0,"width":805,"label":"ground","height":20,"runtime":"Laya.BoxCollider"},"compId":5},{"type":"Script","props":{"type":"static","runtime":"Laya.RigidBody"},"compId":6}]},{"type":"Sprite","props":{"y":0,"x":0,"name":"gameBox"},"compId":18},{"type":"Sprite","props":{"y":0,"x":0,"name":"UI"},"compId":14,"child":[{"type":"Label","props":{"y":50,"x":158,"width":272,"var":"scoreLbl","height":47,"fontSize":40,"color":"#51c524","align":"center"},"compId":17},{"type":"Label","props":{"y":0,"x":0,"width":640,"var":"tipLbll","valign":"middle","text":"别让箱子掉下来\\n\\n点击屏幕开始游戏","height":1136,"fontSize":40,"color":"#c6302e","align":"center"},"compId":16}]},{"type":"Script","props":{"enabled":true,"dropBox":"@Prefab:prefab/DropBox.prefab","bullet":"@Prefab:prefab/Bullet.prefab","runtime":"script/GameControl.ts"},"compId":20}],"loadList":["test/block.png","prefab/DropBox.prefab","prefab/Bullet.prefab"],"loadList3D":[]}
@@ -0,0 +1 @@
{}