@galacean/effects-threejs 0.0.1-alpha.0 → 0.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +1 -1
- package/dist/index.js +399 -119
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +399 -119
- package/dist/index.mjs.map +1 -1
- package/dist/three-composition.d.ts +1 -5
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v0.0.1-alpha.
|
|
6
|
+
* Version: v0.0.1-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -6121,8 +6121,8 @@ var PLAYER_OPTIONS_ENV_EDITOR = 'editor';
|
|
|
6121
6121
|
var FILTER_NAME_NONE = 'none';
|
|
6122
6122
|
var DEG2RAD = 0.017453292519943295;
|
|
6123
6123
|
var HELP_LINK = {
|
|
6124
|
-
'Filter not imported': 'https://
|
|
6125
|
-
'Item duration can\'t be less than 0': 'https://
|
|
6124
|
+
'Filter not imported': 'https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg',
|
|
6125
|
+
'Item duration can\'t be less than 0': 'https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg',
|
|
6126
6126
|
};
|
|
6127
6127
|
|
|
6128
6128
|
/**
|
|
@@ -6665,7 +6665,7 @@ function asserts(condition, msg) {
|
|
|
6665
6665
|
* Name: @galacean/effects-specification
|
|
6666
6666
|
* Description: Galacean Effects JSON Specification
|
|
6667
6667
|
* Author: Ant Group CO., Ltd.
|
|
6668
|
-
* Version:
|
|
6668
|
+
* Version: v1.0.0
|
|
6669
6669
|
*/
|
|
6670
6670
|
|
|
6671
6671
|
/*********************************************/
|
|
@@ -7138,7 +7138,7 @@ var ItemEndBehavior$1;
|
|
|
7138
7138
|
(function (ItemEndBehavior) {
|
|
7139
7139
|
ItemEndBehavior[ItemEndBehavior["destroy"] = END_BEHAVIOR_DESTROY$1] = "destroy";
|
|
7140
7140
|
ItemEndBehavior[ItemEndBehavior["loop"] = END_BEHAVIOR_RESTART$1] = "loop";
|
|
7141
|
-
ItemEndBehavior[ItemEndBehavior["
|
|
7141
|
+
ItemEndBehavior[ItemEndBehavior["freeze"] = END_BEHAVIOR_FREEZE$1] = "freeze";
|
|
7142
7142
|
})(ItemEndBehavior$1 || (ItemEndBehavior$1 = {}));
|
|
7143
7143
|
var ParentItemEndBehavior$1;
|
|
7144
7144
|
(function (ParentItemEndBehavior) {
|
|
@@ -9738,12 +9738,11 @@ var VFXItem = /** @class */ (function () {
|
|
|
9738
9738
|
*/
|
|
9739
9739
|
this._frozen = false;
|
|
9740
9740
|
var id = props.id, name = props.name, delay = props.delay, parentId = props.parentId, endBehavior = props.endBehavior, transform = props.transform, _a = props.listIndex, listIndex = _a === void 0 ? 0 : _a, _b = props.duration, duration = _b === void 0 ? 0 : _b;
|
|
9741
|
-
var rootTransform = composition.rootTransform;
|
|
9742
9741
|
this.composition = composition;
|
|
9743
9742
|
this.id = id;
|
|
9744
9743
|
this.name = name;
|
|
9745
9744
|
this.delay = delay;
|
|
9746
|
-
this.transform = new Transform(__assign$1({ name: this.name }, transform),
|
|
9745
|
+
this.transform = new Transform(__assign$1({ name: this.name }, transform), composition.transform);
|
|
9747
9746
|
this.parentId = parentId;
|
|
9748
9747
|
this.duration = duration;
|
|
9749
9748
|
this.delayInms = (delay || 0) * 1000;
|
|
@@ -9751,6 +9750,7 @@ var VFXItem = /** @class */ (function () {
|
|
|
9751
9750
|
this.endBehavior = endBehavior;
|
|
9752
9751
|
this.lifetime = -(this.delayInms / this.durInms);
|
|
9753
9752
|
this.listIndex = listIndex;
|
|
9753
|
+
this.speed = 1;
|
|
9754
9754
|
this.onConstructed(props);
|
|
9755
9755
|
if (duration <= 0) {
|
|
9756
9756
|
throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
|
|
@@ -9829,6 +9829,20 @@ var VFXItem = /** @class */ (function () {
|
|
|
9829
9829
|
enumerable: false,
|
|
9830
9830
|
configurable: true
|
|
9831
9831
|
});
|
|
9832
|
+
/**
|
|
9833
|
+
* 设置元素的动画速度
|
|
9834
|
+
* @param speed - 速度
|
|
9835
|
+
*/
|
|
9836
|
+
VFXItem.prototype.setSpeed = function (speed) {
|
|
9837
|
+
this.speed = speed;
|
|
9838
|
+
};
|
|
9839
|
+
/**
|
|
9840
|
+
* 获取元素的动画速度
|
|
9841
|
+
* @returns
|
|
9842
|
+
*/
|
|
9843
|
+
VFXItem.prototype.getSpeed = function () {
|
|
9844
|
+
return this.speed;
|
|
9845
|
+
};
|
|
9832
9846
|
/**
|
|
9833
9847
|
* 重置元素状态属性
|
|
9834
9848
|
*/
|
|
@@ -9884,11 +9898,12 @@ var VFXItem = /** @class */ (function () {
|
|
|
9884
9898
|
};
|
|
9885
9899
|
/**
|
|
9886
9900
|
* 内部使用的更新回调,请不要重写此方法,重写 `onItemUpdate` 方法
|
|
9887
|
-
* @param
|
|
9901
|
+
* @param deltaTime
|
|
9888
9902
|
*/
|
|
9889
|
-
VFXItem.prototype.onUpdate = function (
|
|
9903
|
+
VFXItem.prototype.onUpdate = function (deltaTime) {
|
|
9890
9904
|
var _a, _b;
|
|
9891
9905
|
if (this.started && !this.frozen && this.composition) {
|
|
9906
|
+
var dt = deltaTime * this.speed;
|
|
9892
9907
|
var time = (this.timeInms += dt);
|
|
9893
9908
|
this.time += dt / 1000;
|
|
9894
9909
|
var now = time - this.delayInms;
|
|
@@ -9900,7 +9915,6 @@ var VFXItem = /** @class */ (function () {
|
|
|
9900
9915
|
this.composition.itemLifetimeEvent(this, true);
|
|
9901
9916
|
}
|
|
9902
9917
|
if (!this.delaying) {
|
|
9903
|
-
var endBehavior = this.endBehavior;
|
|
9904
9918
|
var lifetime = now / this.durInms;
|
|
9905
9919
|
var ended = this.isEnded(now);
|
|
9906
9920
|
var shouldUpdate = true;
|
|
@@ -9912,36 +9926,37 @@ var VFXItem = /** @class */ (function () {
|
|
|
9912
9926
|
this.composition.itemLifetimeEvent(this, false);
|
|
9913
9927
|
this.onEnd();
|
|
9914
9928
|
}
|
|
9915
|
-
|
|
9929
|
+
// 注意:不要定义私有变量替换 this.endBehavior,直接使用 this 上的!!!(Chrome 下会出现 endBehavior 为 5 时,能进入以下判断)
|
|
9930
|
+
if (this.endBehavior !== END_BEHAVIOR_FORWARD$1 && this.endBehavior !== END_BEHAVIOR_RESTART$1) {
|
|
9916
9931
|
this.ended = true;
|
|
9917
9932
|
this.transform.setValid(false);
|
|
9918
|
-
if (endBehavior === END_BEHAVIOR_PAUSE$1 ||
|
|
9919
|
-
endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1) {
|
|
9933
|
+
if (this.endBehavior === END_BEHAVIOR_PAUSE$1 ||
|
|
9934
|
+
this.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1) {
|
|
9920
9935
|
(_b = (_a = this.composition).handlePlayerPause) === null || _b === void 0 ? void 0 : _b.call(_a, this);
|
|
9921
9936
|
}
|
|
9922
|
-
else if (endBehavior === END_BEHAVIOR_FREEZE$1) {
|
|
9937
|
+
else if (this.endBehavior === END_BEHAVIOR_FREEZE$1) {
|
|
9923
9938
|
this.transform.setValid(true);
|
|
9924
9939
|
shouldUpdate = true;
|
|
9925
9940
|
lifetime = 1;
|
|
9926
9941
|
}
|
|
9927
9942
|
if (!this.reusable) {
|
|
9928
|
-
if (endBehavior === END_BEHAVIOR_DESTROY$1 ||
|
|
9929
|
-
endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 ||
|
|
9930
|
-
endBehavior === END_BEHAVIOR_DESTROY_CHILDREN$1) {
|
|
9943
|
+
if (this.endBehavior === END_BEHAVIOR_DESTROY$1 ||
|
|
9944
|
+
this.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 ||
|
|
9945
|
+
this.endBehavior === END_BEHAVIOR_DESTROY_CHILDREN$1) {
|
|
9931
9946
|
return this.dispose();
|
|
9932
9947
|
}
|
|
9933
|
-
else if (endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
9948
|
+
else if (this.endBehavior === END_BEHAVIOR_PAUSE$1) {
|
|
9934
9949
|
this.endBehavior = END_BEHAVIOR_FORWARD$1;
|
|
9935
9950
|
}
|
|
9936
9951
|
}
|
|
9937
|
-
else if (endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
9952
|
+
else if (this.endBehavior === END_BEHAVIOR_DESTROY$1) {
|
|
9938
9953
|
this.setVisible(false);
|
|
9939
9954
|
}
|
|
9940
9955
|
lifetime = Math.min(lifetime, 1);
|
|
9941
9956
|
}
|
|
9942
9957
|
else {
|
|
9943
9958
|
shouldUpdate = true;
|
|
9944
|
-
if (endBehavior === END_BEHAVIOR_RESTART$1) {
|
|
9959
|
+
if (this.endBehavior === END_BEHAVIOR_RESTART$1) {
|
|
9945
9960
|
this.ended = true;
|
|
9946
9961
|
lifetime = lifetime % 1;
|
|
9947
9962
|
}
|
|
@@ -9990,6 +10005,22 @@ var VFXItem = /** @class */ (function () {
|
|
|
9990
10005
|
VFXItem.prototype.onEnd = function () {
|
|
9991
10006
|
// OVERRIDE
|
|
9992
10007
|
};
|
|
10008
|
+
/**
|
|
10009
|
+
* 通过指定 r、g、b、a 值设置元素的颜色
|
|
10010
|
+
* @param {number} r
|
|
10011
|
+
* @param {number} g
|
|
10012
|
+
* @param {number} b
|
|
10013
|
+
* @param {number} a
|
|
10014
|
+
* @internal
|
|
10015
|
+
*/
|
|
10016
|
+
VFXItem.prototype.setColor = function (r, g, b, a) {
|
|
10017
|
+
};
|
|
10018
|
+
/**
|
|
10019
|
+
* 设置元素的透明度
|
|
10020
|
+
* @param opacity - 透明度值,范围 [0,1]
|
|
10021
|
+
*/
|
|
10022
|
+
VFXItem.prototype.setOpacity = function (opacity) {
|
|
10023
|
+
};
|
|
9993
10024
|
/**
|
|
9994
10025
|
* 获取元素显隐属性
|
|
9995
10026
|
*/
|
|
@@ -10041,6 +10072,57 @@ var VFXItem = /** @class */ (function () {
|
|
|
10041
10072
|
VFXItem.prototype.getNodeTransform = function (itemId) {
|
|
10042
10073
|
return this.transform;
|
|
10043
10074
|
};
|
|
10075
|
+
/**
|
|
10076
|
+
* 设置元素在 3D 坐标轴上相对移动
|
|
10077
|
+
*/
|
|
10078
|
+
VFXItem.prototype.translate = function (x, y, z) {
|
|
10079
|
+
this.transform.translate(x, y, z);
|
|
10080
|
+
};
|
|
10081
|
+
/**
|
|
10082
|
+
* 设置元素在 3D 坐标轴上相对旋转(角度)
|
|
10083
|
+
*/
|
|
10084
|
+
VFXItem.prototype.rotate = function (x, y, z) {
|
|
10085
|
+
var q = [0, 0, 0, 1];
|
|
10086
|
+
quatFromRotation(q, x, y, z);
|
|
10087
|
+
quatStar(q, q);
|
|
10088
|
+
this.transform.rotateByQuat(q);
|
|
10089
|
+
};
|
|
10090
|
+
/**
|
|
10091
|
+
* 设置元素在 3D 坐标轴上相对缩放
|
|
10092
|
+
*/
|
|
10093
|
+
VFXItem.prototype.scale = function (x, y, z) {
|
|
10094
|
+
this.transform.scaleBy(x, y, z);
|
|
10095
|
+
};
|
|
10096
|
+
/**
|
|
10097
|
+
* 设置元素的在画布上的像素位置
|
|
10098
|
+
*/
|
|
10099
|
+
VFXItem.prototype.setPositionByPixel = function (x, y) {
|
|
10100
|
+
if (this.composition) {
|
|
10101
|
+
var z = this.transform.getWorldPosition()[2];
|
|
10102
|
+
var _a = __read$1(this.composition.camera.getInverseVPRatio(z), 2), rx = _a[0], ry = _a[1];
|
|
10103
|
+
var width = this.composition.renderer.getWidth() / 2;
|
|
10104
|
+
var height = this.composition.renderer.getHeight() / 2;
|
|
10105
|
+
this.transform.setPosition(2 * x * rx / width, -2 * y * ry / height, z);
|
|
10106
|
+
}
|
|
10107
|
+
};
|
|
10108
|
+
/**
|
|
10109
|
+
* 设置元素在 3D 坐标轴的位置
|
|
10110
|
+
*/
|
|
10111
|
+
VFXItem.prototype.setPosition = function (x, y, z) {
|
|
10112
|
+
this.transform.setPosition(x, y, z);
|
|
10113
|
+
};
|
|
10114
|
+
/**
|
|
10115
|
+
* 设置元素在 3D 坐标轴的角度
|
|
10116
|
+
*/
|
|
10117
|
+
VFXItem.prototype.setRotation = function (x, y, z) {
|
|
10118
|
+
this.transform.setRotation(x, y, z);
|
|
10119
|
+
};
|
|
10120
|
+
/**
|
|
10121
|
+
* 设置元素在 3D 坐标轴的缩放
|
|
10122
|
+
*/
|
|
10123
|
+
VFXItem.prototype.setScale = function (x, y, z) {
|
|
10124
|
+
this.transform.setScale(x, y, z);
|
|
10125
|
+
};
|
|
10044
10126
|
/**
|
|
10045
10127
|
* 获取元素包围盒
|
|
10046
10128
|
* @override
|
|
@@ -10095,6 +10177,15 @@ var VFXItem = /** @class */ (function () {
|
|
|
10095
10177
|
}
|
|
10096
10178
|
this.started = false;
|
|
10097
10179
|
};
|
|
10180
|
+
VFXItem.prototype.translateByPixel = function (x, y) {
|
|
10181
|
+
if (this.composition) {
|
|
10182
|
+
var z = this.transform.getWorldPosition()[2];
|
|
10183
|
+
var _a = __read$1(this.composition.camera.getInverseVPRatio(z), 2), rx = _a[0], ry = _a[1];
|
|
10184
|
+
var width = this.composition.renderer.getWidth() / 2;
|
|
10185
|
+
var height = this.composition.renderer.getHeight() / 2;
|
|
10186
|
+
this.transform.translate(2 * x * rx / width, -2 * y * ry / height, 0);
|
|
10187
|
+
}
|
|
10188
|
+
};
|
|
10098
10189
|
/**
|
|
10099
10190
|
* 销毁元素
|
|
10100
10191
|
*/
|
|
@@ -11154,6 +11245,21 @@ function generateHalfFloatTexture(engine, data, width, height) {
|
|
|
11154
11245
|
});
|
|
11155
11246
|
}
|
|
11156
11247
|
|
|
11248
|
+
var RUNTIME_ENV = 'runtime_env';
|
|
11249
|
+
var LOG_TYPE = 'galacean-effects';
|
|
11250
|
+
var RENDER_PREFER_LOOKUP_TEXTURE = 'lookup_texture';
|
|
11251
|
+
// 数据模板使用 offscreen canvas 绘制
|
|
11252
|
+
var TEMPLATE_USE_OFFSCREEN_CANVAS = 'offscreen_canvas';
|
|
11253
|
+
// 后处理配置相关
|
|
11254
|
+
var POST_PROCESS_SETTINGS = 'post_process_settings';
|
|
11255
|
+
var config = {};
|
|
11256
|
+
function getConfig(name) {
|
|
11257
|
+
return config[name];
|
|
11258
|
+
}
|
|
11259
|
+
function setConfig(name, value) {
|
|
11260
|
+
return config[name] = value;
|
|
11261
|
+
}
|
|
11262
|
+
|
|
11157
11263
|
var HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)
|
|
11158
11264
|
var COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
|
|
11159
11265
|
//const COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
|
|
@@ -11202,15 +11308,24 @@ var KTXTexture = /** @class */ (function () {
|
|
|
11202
11308
|
// value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
|
|
11203
11309
|
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
|
11204
11310
|
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
|
11205
|
-
console.warn(
|
|
11311
|
+
console.warn({
|
|
11312
|
+
content: 'only 2D textures currently supported',
|
|
11313
|
+
type: LOG_TYPE,
|
|
11314
|
+
});
|
|
11206
11315
|
return;
|
|
11207
11316
|
}
|
|
11208
11317
|
if (this.numberOfArrayElements !== 0) {
|
|
11209
|
-
console.warn(
|
|
11318
|
+
console.warn({
|
|
11319
|
+
content: 'texture arrays not currently supported',
|
|
11320
|
+
type: LOG_TYPE,
|
|
11321
|
+
});
|
|
11210
11322
|
return;
|
|
11211
11323
|
}
|
|
11212
11324
|
if (this.numberOfFaces !== facesExpected) {
|
|
11213
|
-
console.warn(
|
|
11325
|
+
console.warn({
|
|
11326
|
+
content: 'number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces,
|
|
11327
|
+
type: LOG_TYPE,
|
|
11328
|
+
});
|
|
11214
11329
|
return;
|
|
11215
11330
|
}
|
|
11216
11331
|
// we now have a completely validated file, so could use existence of loadType as success
|
|
@@ -11897,20 +12012,6 @@ function generateEmptyTypedArray(type) {
|
|
|
11897
12012
|
return new Float32Array(0);
|
|
11898
12013
|
}
|
|
11899
12014
|
|
|
11900
|
-
var RUNTIME_ENV = 'runtime_env';
|
|
11901
|
-
var RENDER_PREFER_LOOKUP_TEXTURE = 'lookup_texture';
|
|
11902
|
-
// 数据模板使用 offscreen canvas 绘制
|
|
11903
|
-
var TEMPLATE_USE_OFFSCREEN_CANVAS = 'offscreen_canvas';
|
|
11904
|
-
// 后处理配置相关
|
|
11905
|
-
var POST_PROCESS_SETTINGS = 'post_process_settings';
|
|
11906
|
-
var config = {};
|
|
11907
|
-
function getConfig(name) {
|
|
11908
|
-
return config[name];
|
|
11909
|
-
}
|
|
11910
|
-
function setConfig(name, value) {
|
|
11911
|
-
return config[name] = value;
|
|
11912
|
-
}
|
|
11913
|
-
|
|
11914
12015
|
var seed$8 = 1;
|
|
11915
12016
|
/**
|
|
11916
12017
|
* Mesh 抽象类
|
|
@@ -14247,14 +14348,10 @@ var SpriteMesh = /** @class */ (function () {
|
|
|
14247
14348
|
var uSize = [1, 1, 1, 0];
|
|
14248
14349
|
var uQuat = [0, 0, 1, 1];
|
|
14249
14350
|
var uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]];
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14351
|
+
if (!isNaN(item.getCustomOpacity())) {
|
|
14352
|
+
uColor[3] = item.getCustomOpacity();
|
|
14353
|
+
}
|
|
14253
14354
|
selfData.transform.assignWorldTRS(uPos, uQuat, uSize);
|
|
14254
|
-
// TODO 兼容改变锚点,位置不移动
|
|
14255
|
-
// if (selfData.startSize) {
|
|
14256
|
-
// selfData.transform.scaleBy(selfData.startSize[0], selfData.startSize[1], 1);
|
|
14257
|
-
// }
|
|
14258
14355
|
/* 要过包含父节点颜色/透明度变化的动画的帧对比 打开这段兼容代码 */
|
|
14259
14356
|
// vecMulCombine(uColor, selfData.color, parentData.color);
|
|
14260
14357
|
/***********************/
|
|
@@ -15435,6 +15532,9 @@ var CalculateItem = /** @class */ (function () {
|
|
|
15435
15532
|
get: function () {
|
|
15436
15533
|
return this.basicTransform.scale;
|
|
15437
15534
|
},
|
|
15535
|
+
set: function (scale) {
|
|
15536
|
+
this.basicTransform.scale = scale;
|
|
15537
|
+
},
|
|
15438
15538
|
enumerable: false,
|
|
15439
15539
|
configurable: true
|
|
15440
15540
|
});
|
|
@@ -15633,6 +15733,21 @@ var SpriteItem = /** @class */ (function (_super) {
|
|
|
15633
15733
|
}
|
|
15634
15734
|
return ret;
|
|
15635
15735
|
};
|
|
15736
|
+
/**
|
|
15737
|
+
* @internal
|
|
15738
|
+
*/
|
|
15739
|
+
SpriteItem.prototype.setColor = function (r, g, b, a) {
|
|
15740
|
+
this.customColor = [r, g, b, a];
|
|
15741
|
+
};
|
|
15742
|
+
SpriteItem.prototype.setOpacity = function (opacity) {
|
|
15743
|
+
this.customOpacity = opacity;
|
|
15744
|
+
};
|
|
15745
|
+
/**
|
|
15746
|
+
* @internal
|
|
15747
|
+
*/
|
|
15748
|
+
SpriteItem.prototype.getCustomOpacity = function () {
|
|
15749
|
+
return this.customOpacity;
|
|
15750
|
+
};
|
|
15636
15751
|
SpriteItem.prototype.getRenderData = function (_time, init) {
|
|
15637
15752
|
var ret = _super.prototype.getRenderData.call(this, _time, init);
|
|
15638
15753
|
var colorInc = vecFill(tempColor, 1);
|
|
@@ -15640,18 +15755,23 @@ var SpriteItem = /** @class */ (function (_super) {
|
|
|
15640
15755
|
var time = _time < 0 ? _time : Math.max(_time, 0.);
|
|
15641
15756
|
var duration = this.options.duration;
|
|
15642
15757
|
var life = time / duration < 0 ? 0 : (time / duration > 1 ? 1 : time / duration);
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
if (colorOverLifetime) {
|
|
15646
|
-
colorInc = getColorFromGradientStops(colorOverLifetime, life, true);
|
|
15647
|
-
colorChanged = true;
|
|
15648
|
-
}
|
|
15649
|
-
if (opacityOverLifetime) {
|
|
15650
|
-
colorInc[3] *= opacityOverLifetime.getValue(life);
|
|
15651
|
-
colorChanged = true;
|
|
15758
|
+
if (this.customColor) {
|
|
15759
|
+
ret.color = this.customColor;
|
|
15652
15760
|
}
|
|
15653
|
-
|
|
15654
|
-
|
|
15761
|
+
else {
|
|
15762
|
+
var opacityOverLifetime = this.opacityOverLifetime;
|
|
15763
|
+
var colorOverLifetime = this.colorOverLifetime;
|
|
15764
|
+
if (colorOverLifetime) {
|
|
15765
|
+
colorInc = getColorFromGradientStops(colorOverLifetime, life, true);
|
|
15766
|
+
colorChanged = true;
|
|
15767
|
+
}
|
|
15768
|
+
if (opacityOverLifetime) {
|
|
15769
|
+
colorInc[3] *= opacityOverLifetime.getValue(life);
|
|
15770
|
+
colorChanged = true;
|
|
15771
|
+
}
|
|
15772
|
+
if (colorChanged || init) {
|
|
15773
|
+
ret.color = vecMulCombine(this.startColor, colorInc, this.options.startColor);
|
|
15774
|
+
}
|
|
15655
15775
|
}
|
|
15656
15776
|
var ta = this.textureSheetAnimation;
|
|
15657
15777
|
if (ta) {
|
|
@@ -15756,6 +15876,15 @@ var SpriteVFXItem = /** @class */ (function (_super) {
|
|
|
15756
15876
|
this.transform.assignWorldTRS(pos);
|
|
15757
15877
|
return pos;
|
|
15758
15878
|
};
|
|
15879
|
+
/**
|
|
15880
|
+
* @internal
|
|
15881
|
+
*/
|
|
15882
|
+
SpriteVFXItem.prototype.setColor = function (r, g, b, a) {
|
|
15883
|
+
this.content.setColor(r, g, b, a);
|
|
15884
|
+
};
|
|
15885
|
+
SpriteVFXItem.prototype.setOpacity = function (opacity) {
|
|
15886
|
+
this.content.setOpacity(opacity);
|
|
15887
|
+
};
|
|
15759
15888
|
/**
|
|
15760
15889
|
* 获取图层包围盒的类型和世界坐标
|
|
15761
15890
|
* @returns
|
|
@@ -18438,6 +18567,32 @@ var ParticleSystem = /** @class */ (function () {
|
|
|
18438
18567
|
this.trailMesh.mesh.setVisible(visible);
|
|
18439
18568
|
}
|
|
18440
18569
|
};
|
|
18570
|
+
ParticleSystem.prototype.setOpacity = function (opacity) {
|
|
18571
|
+
var material = this.particleMesh.mesh.material;
|
|
18572
|
+
var geometry = this.particleMesh.mesh.geometry;
|
|
18573
|
+
var originalColor = material.getVector4('uOpacityOverLifetimeValue') || [1, 1, 1, 1];
|
|
18574
|
+
material.setVector4('uOpacityOverLifetimeValue', [originalColor[0], originalColor[1], originalColor[2], opacity]);
|
|
18575
|
+
var data = geometry.getAttributeData('aColor') || [];
|
|
18576
|
+
for (var i = 0; i < data.length; i += 32) {
|
|
18577
|
+
data[i * 8 + 7] = opacity;
|
|
18578
|
+
}
|
|
18579
|
+
};
|
|
18580
|
+
/**
|
|
18581
|
+
* @internal
|
|
18582
|
+
*/
|
|
18583
|
+
ParticleSystem.prototype.setColor = function (r, g, b, a) {
|
|
18584
|
+
var material = this.particleMesh.mesh.material;
|
|
18585
|
+
var geometry = this.particleMesh.mesh.geometry;
|
|
18586
|
+
var originalColor = material.getVector4('uOpacityOverLifetimeValue') || [1, 1, 1, 1];
|
|
18587
|
+
material.setVector4('uOpacityOverLifetimeValue', [originalColor[0], originalColor[1], originalColor[2], a]);
|
|
18588
|
+
var data = geometry.getAttributeData('aColor') || [];
|
|
18589
|
+
for (var i = 0; i < data.length; i += 32) {
|
|
18590
|
+
data[i * 8 + 4] = r;
|
|
18591
|
+
data[i * 8 + 5] = g;
|
|
18592
|
+
data[i * 8 + 6] = b;
|
|
18593
|
+
data[i * 8 + 7] = a;
|
|
18594
|
+
}
|
|
18595
|
+
};
|
|
18441
18596
|
ParticleSystem.prototype.setParentTransform = function (transform) {
|
|
18442
18597
|
this.parentTransform = transform;
|
|
18443
18598
|
};
|
|
@@ -18988,6 +19143,15 @@ var ParticleVFXItem = /** @class */ (function (_super) {
|
|
|
18988
19143
|
content.meshes.forEach(function (mesh) { return mesh.dispose({ material: { textures: DestroyOptions.keep } }); });
|
|
18989
19144
|
}
|
|
18990
19145
|
};
|
|
19146
|
+
/**
|
|
19147
|
+
* @internal
|
|
19148
|
+
*/
|
|
19149
|
+
ParticleVFXItem.prototype.setColor = function (r, g, b, a) {
|
|
19150
|
+
this.content.setColor(r, g, b, a);
|
|
19151
|
+
};
|
|
19152
|
+
ParticleVFXItem.prototype.setOpacity = function (opacity) {
|
|
19153
|
+
this.content.setOpacity(opacity);
|
|
19154
|
+
};
|
|
18991
19155
|
ParticleVFXItem.prototype.stopParticleEmission = function () {
|
|
18992
19156
|
if (this.content) {
|
|
18993
19157
|
this.content.emissionStopped = true;
|
|
@@ -19296,6 +19460,9 @@ var CalculateVFXItem = /** @class */ (function (_super) {
|
|
|
19296
19460
|
/********************/
|
|
19297
19461
|
}
|
|
19298
19462
|
};
|
|
19463
|
+
CalculateVFXItem.prototype.setScale = function (x, y, z) {
|
|
19464
|
+
this.content.startSize = [x, y, z];
|
|
19465
|
+
};
|
|
19299
19466
|
CalculateVFXItem.prototype.getHitTestParams = function (force) {
|
|
19300
19467
|
};
|
|
19301
19468
|
CalculateVFXItem.prototype.getRenderData = function () {
|
|
@@ -20879,11 +21046,12 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20879
21046
|
var layout = this.textLayout;
|
|
20880
21047
|
var fontScale = style.fontScale;
|
|
20881
21048
|
var width = (layout.width + style.fontOffset) * fontScale;
|
|
21049
|
+
var height = layout.height * fontScale;
|
|
20882
21050
|
var fontSize = style.fontSize * fontScale;
|
|
20883
21051
|
var lineHeight = layout.lineHeight * fontScale;
|
|
20884
21052
|
this.char = this.text.split('');
|
|
20885
21053
|
this.canvas.width = width;
|
|
20886
|
-
this.canvas.height =
|
|
21054
|
+
this.canvas.height = height;
|
|
20887
21055
|
context.clearRect(0, 0, width, this.canvas.height);
|
|
20888
21056
|
// fix bug 1/255
|
|
20889
21057
|
context.fillStyle = 'rgba(255, 255, 255, 0.0039)';
|
|
@@ -20948,12 +21116,16 @@ var TextItem = /** @class */ (function (_super) {
|
|
|
20948
21116
|
}
|
|
20949
21117
|
//与 toDataURL() 两种方式都需要像素读取操作
|
|
20950
21118
|
var imageData = context.getImageData(0, 0, this.canvas.width, this.canvas.height);
|
|
20951
|
-
(_a = this.mesh) === null || _a === void 0 ? void 0 : _a.mesh.material.setTexture('uSampler0', Texture.createWithData(this.engine,
|
|
21119
|
+
(_a = this.mesh) === null || _a === void 0 ? void 0 : _a.mesh.material.setTexture('uSampler0', Texture.createWithData(this.engine, {
|
|
21120
|
+
data: new Uint8Array(imageData.data),
|
|
21121
|
+
width: imageData.width,
|
|
21122
|
+
height: imageData.height,
|
|
21123
|
+
}, {
|
|
20952
21124
|
flipY: true,
|
|
20953
21125
|
magFilter: glContext.LINEAR,
|
|
20954
21126
|
minFilter: glContext.LINEAR,
|
|
20955
|
-
wrapS: glContext.
|
|
20956
|
-
wrapT: glContext.
|
|
21127
|
+
wrapS: glContext.CLAMP_TO_EDGE,
|
|
21128
|
+
wrapT: glContext.CLAMP_TO_EDGE,
|
|
20957
21129
|
}));
|
|
20958
21130
|
this.isDirty = false;
|
|
20959
21131
|
};
|
|
@@ -21097,7 +21269,7 @@ var TextLoader = /** @class */ (function (_super) {
|
|
|
21097
21269
|
return _this;
|
|
21098
21270
|
}
|
|
21099
21271
|
TextLoader.prototype.onCompositionDestroyed = function (composition) {
|
|
21100
|
-
if (composition.reusable
|
|
21272
|
+
if (composition.reusable) {
|
|
21101
21273
|
this.addItems.forEach(function (vfxitem) {
|
|
21102
21274
|
var _a;
|
|
21103
21275
|
(_a = vfxitem.content.mesh) === null || _a === void 0 ? void 0 : _a.mesh.dispose({ material: { textures: DestroyOptions.keep } });
|
|
@@ -22051,6 +22223,16 @@ var Camera = /** @class */ (function () {
|
|
|
22051
22223
|
Camera.prototype.getModelViewProjection = function (out, model) {
|
|
22052
22224
|
return mat4multiply(out, this.viewProjectionMatrix, model);
|
|
22053
22225
|
};
|
|
22226
|
+
/**
|
|
22227
|
+
* 获取归一化坐标和 3D 世界坐标的换算比例
|
|
22228
|
+
* @param z - 当前的位置 z
|
|
22229
|
+
*/
|
|
22230
|
+
Camera.prototype.getInverseVPRatio = function (z) {
|
|
22231
|
+
var pos = [0, 0, 0];
|
|
22232
|
+
var nz = vec3MulMat4(pos, [0, 0, z], this.getViewProjectionMatrix())[2];
|
|
22233
|
+
vec3MulMat4(pos, [1, 1, nz], this.getInverseViewProjectionMatrix());
|
|
22234
|
+
return pos;
|
|
22235
|
+
};
|
|
22054
22236
|
/**
|
|
22055
22237
|
* 设置相机的旋转四元数
|
|
22056
22238
|
* @param value - 旋转四元数
|
|
@@ -22241,7 +22423,7 @@ var filters = {
|
|
|
22241
22423
|
* Name: @galacean/effects-specification
|
|
22242
22424
|
* Description: Galacean Effects JSON Specification
|
|
22243
22425
|
* Author: Ant Group CO., Ltd.
|
|
22244
|
-
* Version:
|
|
22426
|
+
* Version: v1.0.0
|
|
22245
22427
|
*/
|
|
22246
22428
|
|
|
22247
22429
|
/*********************************************/
|
|
@@ -22712,7 +22894,7 @@ var ItemEndBehavior;
|
|
|
22712
22894
|
(function (ItemEndBehavior) {
|
|
22713
22895
|
ItemEndBehavior[ItemEndBehavior["destroy"] = END_BEHAVIOR_DESTROY] = "destroy";
|
|
22714
22896
|
ItemEndBehavior[ItemEndBehavior["loop"] = END_BEHAVIOR_RESTART] = "loop";
|
|
22715
|
-
ItemEndBehavior[ItemEndBehavior["
|
|
22897
|
+
ItemEndBehavior[ItemEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
22716
22898
|
})(ItemEndBehavior || (ItemEndBehavior = {}));
|
|
22717
22899
|
var ParentItemEndBehavior;
|
|
22718
22900
|
(function (ParentItemEndBehavior) {
|
|
@@ -22958,7 +23140,12 @@ function __read(o, n) {
|
|
|
22958
23140
|
finally { if (e) throw e.error; }
|
|
22959
23141
|
}
|
|
22960
23142
|
return ar;
|
|
22961
|
-
}
|
|
23143
|
+
}
|
|
23144
|
+
|
|
23145
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
23146
|
+
var e = new Error(message);
|
|
23147
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
23148
|
+
};
|
|
22962
23149
|
|
|
22963
23150
|
function arrAdd(arr, item) {
|
|
22964
23151
|
if (!arr.includes(item)) {
|
|
@@ -23580,7 +23767,7 @@ function version21Migration(json) {
|
|
|
23580
23767
|
composition.items.forEach(function (item) {
|
|
23581
23768
|
if (item.type === ItemType.null) {
|
|
23582
23769
|
if (item.endBehavior === ItemEndBehavior.destroy) {
|
|
23583
|
-
item.endBehavior = ItemEndBehavior.
|
|
23770
|
+
item.endBehavior = ItemEndBehavior.freeze;
|
|
23584
23771
|
}
|
|
23585
23772
|
}
|
|
23586
23773
|
});
|
|
@@ -23588,6 +23775,24 @@ function version21Migration(json) {
|
|
|
23588
23775
|
json.version = '2.1';
|
|
23589
23776
|
return json;
|
|
23590
23777
|
}
|
|
23778
|
+
/**
|
|
23779
|
+
* 2.2 以下版本数据适配(mars-player@2.5.0 及以上版本支持 2.2 以下数据的适配)
|
|
23780
|
+
*/
|
|
23781
|
+
function version22Migration(json) {
|
|
23782
|
+
var _a;
|
|
23783
|
+
var singleVersion = (_a = json.version) === null || _a === void 0 ? void 0 : _a.split('.');
|
|
23784
|
+
if (!singleVersion || Number(singleVersion[0]) > 2 || (Number(singleVersion[0]) === 2 && Number(singleVersion[1]) >= 2)) {
|
|
23785
|
+
return json;
|
|
23786
|
+
}
|
|
23787
|
+
json.compositions.forEach(function (composition) {
|
|
23788
|
+
composition.items.forEach(function (item) {
|
|
23789
|
+
if (item.type === ItemType.mesh || item.type === ItemType.light) {
|
|
23790
|
+
item.endBehavior = item.endBehavior === 1 ? ItemEndBehavior.destroy : item.endBehavior;
|
|
23791
|
+
}
|
|
23792
|
+
});
|
|
23793
|
+
});
|
|
23794
|
+
return json;
|
|
23795
|
+
}
|
|
23591
23796
|
|
|
23592
23797
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
23593
23798
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -23597,6 +23802,8 @@ function getStandardJSON(json) {
|
|
|
23597
23802
|
if (!json || typeof json !== 'object') {
|
|
23598
23803
|
throw Error('expect a json object');
|
|
23599
23804
|
}
|
|
23805
|
+
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
23806
|
+
version22Migration(json);
|
|
23600
23807
|
if (v0.test(json.version)) {
|
|
23601
23808
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
23602
23809
|
return version21Migration(getStandardJSONFromV0(json));
|
|
@@ -24195,7 +24402,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
24195
24402
|
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
24196
24403
|
_d.sent();
|
|
24197
24404
|
totalTime = performance.now() - startTime;
|
|
24198
|
-
console.
|
|
24405
|
+
console.info({
|
|
24406
|
+
content: "".concat(timeLabel, ": ").concat(totalTime.toFixed(4), "ms, ").concat(timeInfos.join(' ')),
|
|
24407
|
+
type: LOG_TYPE,
|
|
24408
|
+
});
|
|
24199
24409
|
window.clearTimeout(loadTimer);
|
|
24200
24410
|
scene.totalTime = totalTime;
|
|
24201
24411
|
scene.startTime = startTime;
|
|
@@ -24319,7 +24529,10 @@ var AssetManager = /** @class */ (function () {
|
|
|
24319
24529
|
return [3 /*break*/, 4];
|
|
24320
24530
|
case 3:
|
|
24321
24531
|
_b.sent();
|
|
24322
|
-
console.warn(
|
|
24532
|
+
console.warn({
|
|
24533
|
+
content: "Invalid fonts source: ".concat(font.fontURL),
|
|
24534
|
+
type: LOG_TYPE,
|
|
24535
|
+
});
|
|
24323
24536
|
return [3 /*break*/, 4];
|
|
24324
24537
|
case 4: return [2 /*return*/];
|
|
24325
24538
|
}
|
|
@@ -24726,6 +24939,9 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
24726
24939
|
this.tempQueue.length = 0;
|
|
24727
24940
|
this.itemsToRemove.length = 0;
|
|
24728
24941
|
};
|
|
24942
|
+
CompVFXItem.prototype.handleVisibleChanged = function (visible) {
|
|
24943
|
+
this.items.forEach(function (item) { return item.setVisible(visible); });
|
|
24944
|
+
};
|
|
24729
24945
|
CompVFXItem.prototype.getUpdateTime = function (t) {
|
|
24730
24946
|
var startTime = this.startTimeInms;
|
|
24731
24947
|
var now = this.timeInms;
|
|
@@ -24793,6 +25009,7 @@ var CompVFXItem = /** @class */ (function (_super) {
|
|
|
24793
25009
|
};
|
|
24794
25010
|
/**
|
|
24795
25011
|
* 获取指定元素当前时刻真正起作用的父元素, 需要在元素生命周期内获取
|
|
25012
|
+
* @internal
|
|
24796
25013
|
* @param item - 指定元素
|
|
24797
25014
|
* @return 当父元素生命周期结束时,返回空
|
|
24798
25015
|
*/
|
|
@@ -24903,17 +25120,22 @@ var Composition = /** @class */ (function () {
|
|
|
24903
25120
|
this.paused = false;
|
|
24904
25121
|
this.lastVideoUpdateTime = 0;
|
|
24905
25122
|
this.postLoaders = [];
|
|
24906
|
-
var
|
|
25123
|
+
var _b = props.reusable, reusable = _b === void 0 ? false : _b, _c = props.speed, speed = _c === void 0 ? 1 : _c, _d = props.baseRenderOrder, baseRenderOrder = _d === void 0 ? 0 : _d, renderer = props.renderer, handlePlayerPause = props.handlePlayerPause, handleMessageItem = props.handleMessageItem, handleEnd = props.handleEnd, event = props.event, width = props.width, height = props.height;
|
|
24907
25124
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
24908
25125
|
scene.jsonScene.imgUsage = undefined;
|
|
24909
|
-
if (
|
|
25126
|
+
if (reusable) {
|
|
25127
|
+
this.keepResource = true;
|
|
24910
25128
|
scene.textures = undefined;
|
|
24911
25129
|
scene.consumed = true;
|
|
24912
25130
|
}
|
|
24913
|
-
var
|
|
25131
|
+
var _e = this.compositionSourceManager, sourceContent = _e.sourceContent, pluginSystem = _e.pluginSystem, imgUsage = _e.imgUsage, totalTime = _e.totalTime, renderLevel = _e.renderLevel;
|
|
24914
25132
|
assertExist(sourceContent);
|
|
24915
25133
|
var vfxItem = new CompVFXItem(sourceContent, this);
|
|
24916
25134
|
var imageUsage = (!reusable && imgUsage);
|
|
25135
|
+
this.transform = new Transform({
|
|
25136
|
+
name: this.name,
|
|
25137
|
+
});
|
|
25138
|
+
vfxItem.transform = this.transform;
|
|
24917
25139
|
this.globalVolume = sourceContent.globalVolume;
|
|
24918
25140
|
this.width = width;
|
|
24919
25141
|
this.height = height;
|
|
@@ -24924,21 +25146,19 @@ var Composition = /** @class */ (function () {
|
|
|
24924
25146
|
this.event = event;
|
|
24925
25147
|
this.statistic = { loadTime: totalTime !== null && totalTime !== void 0 ? totalTime : 0, loadStart: (_a = scene.startTime) !== null && _a !== void 0 ? _a : 0, firstFrameTime: 0 };
|
|
24926
25148
|
this.reusable = reusable;
|
|
25149
|
+
this.speed = speed;
|
|
24927
25150
|
this.renderLevel = renderLevel;
|
|
24928
|
-
this.
|
|
24929
|
-
this.handleMessageItem = handleMessageItem;
|
|
24930
|
-
this.handleEnd = handleEnd;
|
|
24931
|
-
this.rootTransform = new Transform();
|
|
24932
|
-
vfxItem.transform = this.rootTransform;
|
|
24933
|
-
this.autoRefTex = !keepResource && imageUsage && vfxItem.endBehavior !== END_BEHAVIOR_RESTART$1;
|
|
25151
|
+
this.autoRefTex = !this.keepResource && imageUsage && vfxItem.endBehavior !== END_BEHAVIOR_RESTART$1;
|
|
24934
25152
|
this.content = vfxItem;
|
|
24935
25153
|
this.name = vfxItem.name;
|
|
24936
|
-
this.rootTransform.name = this.name;
|
|
24937
25154
|
this.pluginSystem = pluginSystem;
|
|
24938
25155
|
this.pluginSystem.initializeComposition(this, scene);
|
|
24939
25156
|
this.camera = new Camera(this.name, __assign$1(__assign$1({}, sourceContent === null || sourceContent === void 0 ? void 0 : sourceContent.camera), { aspect: width / height }));
|
|
24940
25157
|
this.url = scene.url;
|
|
24941
25158
|
this.assigned = true;
|
|
25159
|
+
this.handlePlayerPause = handlePlayerPause;
|
|
25160
|
+
this.handleMessageItem = handleMessageItem;
|
|
25161
|
+
this.handleEnd = handleEnd;
|
|
24942
25162
|
this.createRenderFrame();
|
|
24943
25163
|
this.reset();
|
|
24944
25164
|
}
|
|
@@ -24983,6 +25203,12 @@ var Composition = /** @class */ (function () {
|
|
|
24983
25203
|
enumerable: false,
|
|
24984
25204
|
configurable: true
|
|
24985
25205
|
});
|
|
25206
|
+
/**
|
|
25207
|
+
* 获取合成的时长
|
|
25208
|
+
*/
|
|
25209
|
+
Composition.prototype.getDuration = function () {
|
|
25210
|
+
return this.content.duration;
|
|
25211
|
+
};
|
|
24986
25212
|
Object.defineProperty(Composition.prototype, "isDestroyed", {
|
|
24987
25213
|
/**
|
|
24988
25214
|
* 获取销毁状态
|
|
@@ -25000,7 +25226,7 @@ var Composition = /** @class */ (function () {
|
|
|
25000
25226
|
this.content.reset();
|
|
25001
25227
|
this.prepareRender();
|
|
25002
25228
|
this.reset();
|
|
25003
|
-
this.
|
|
25229
|
+
this.transform.setValid(true);
|
|
25004
25230
|
this.content.start();
|
|
25005
25231
|
this.forwardTime(this.startTime);
|
|
25006
25232
|
this.content.onUpdate(0);
|
|
@@ -25020,11 +25246,25 @@ var Composition = /** @class */ (function () {
|
|
|
25020
25246
|
Composition.prototype.getIndex = function () {
|
|
25021
25247
|
return this.renderOrder;
|
|
25022
25248
|
};
|
|
25249
|
+
/**
|
|
25250
|
+
* 设置合成的动画速度
|
|
25251
|
+
* @param speed - 速度
|
|
25252
|
+
*/
|
|
25253
|
+
Composition.prototype.setSpeed = function (speed) {
|
|
25254
|
+
this.speed = speed;
|
|
25255
|
+
};
|
|
25256
|
+
/**
|
|
25257
|
+
* 获取合成的动画速度
|
|
25258
|
+
* @returns
|
|
25259
|
+
*/
|
|
25260
|
+
Composition.prototype.getSpeed = function () {
|
|
25261
|
+
return this.speed;
|
|
25262
|
+
};
|
|
25023
25263
|
Composition.prototype.play = function () {
|
|
25024
|
-
if (this.
|
|
25025
|
-
this.
|
|
25264
|
+
if (this.content.ended && this.reusable) {
|
|
25265
|
+
this.restart();
|
|
25026
25266
|
}
|
|
25027
|
-
this.
|
|
25267
|
+
this.gotoAndPlay(this.time);
|
|
25028
25268
|
};
|
|
25029
25269
|
/**
|
|
25030
25270
|
* 暂停合成的播放
|
|
@@ -25039,12 +25279,16 @@ var Composition = /** @class */ (function () {
|
|
|
25039
25279
|
this.paused = false;
|
|
25040
25280
|
};
|
|
25041
25281
|
Composition.prototype.gotoAndPlay = function (time) {
|
|
25282
|
+
this.resume();
|
|
25283
|
+
if (!this.content.started) {
|
|
25284
|
+
this.content.start();
|
|
25285
|
+
this.forwardTime(this.startTime);
|
|
25286
|
+
}
|
|
25287
|
+
this.forwardTime(time);
|
|
25042
25288
|
};
|
|
25043
|
-
Composition.prototype.
|
|
25044
|
-
|
|
25045
|
-
|
|
25046
|
-
Composition.prototype.start = function () {
|
|
25047
|
-
this.content.start();
|
|
25289
|
+
Composition.prototype.gotoAndStop = function (time) {
|
|
25290
|
+
this.gotoAndPlay(time);
|
|
25291
|
+
this.pause();
|
|
25048
25292
|
};
|
|
25049
25293
|
/**
|
|
25050
25294
|
*
|
|
@@ -25061,29 +25305,29 @@ var Composition = /** @class */ (function () {
|
|
|
25061
25305
|
};
|
|
25062
25306
|
/**
|
|
25063
25307
|
* 跳到指定时间点(不做任何播放行为)
|
|
25064
|
-
*
|
|
25065
|
-
* @param time - 时间点(秒),可正可负
|
|
25308
|
+
* @param time - 指定的时间
|
|
25066
25309
|
*/
|
|
25067
25310
|
Composition.prototype.setTime = function (time) {
|
|
25311
|
+
var pause = this.paused;
|
|
25312
|
+
if (pause) {
|
|
25313
|
+
this.resume();
|
|
25314
|
+
}
|
|
25315
|
+
this.forwardTime(time, true);
|
|
25316
|
+
if (pause) {
|
|
25317
|
+
this.pause();
|
|
25318
|
+
}
|
|
25068
25319
|
};
|
|
25069
|
-
|
|
25070
|
-
|
|
25071
|
-
|
|
25072
|
-
|
|
25073
|
-
|
|
25074
|
-
var
|
|
25075
|
-
|
|
25076
|
-
|
|
25077
|
-
|
|
25078
|
-
var t = Math.abs(time);
|
|
25079
|
-
for (var ss = reverse ? -step : step; t > step; t -= step) {
|
|
25080
|
-
this.update(ss);
|
|
25081
|
-
}
|
|
25082
|
-
if (t > 0) {
|
|
25083
|
-
var ss = reverse ? -t : t;
|
|
25084
|
-
this.update(ss);
|
|
25085
|
-
}
|
|
25320
|
+
Composition.prototype.forwardTime = function (time, skipRender) {
|
|
25321
|
+
if (skipRender === void 0) { skipRender = false; }
|
|
25322
|
+
var deltaTime = (this.startTime + Math.max(0, time)) * 1000 - this.content.timeInms;
|
|
25323
|
+
var reverse = deltaTime < 0;
|
|
25324
|
+
var step = 15;
|
|
25325
|
+
var t = Math.abs(deltaTime);
|
|
25326
|
+
var ss = reverse ? -step : step;
|
|
25327
|
+
for (t; t > step; t -= step) {
|
|
25328
|
+
this.update(ss, skipRender);
|
|
25086
25329
|
}
|
|
25330
|
+
this.update(reverse ? -t : t, skipRender);
|
|
25087
25331
|
};
|
|
25088
25332
|
/**
|
|
25089
25333
|
* 重置状态函数
|
|
@@ -25125,14 +25369,19 @@ var Composition = /** @class */ (function () {
|
|
|
25125
25369
|
* @returns 销毁合成标志位
|
|
25126
25370
|
*/
|
|
25127
25371
|
Composition.prototype.shouldDispose = function () {
|
|
25372
|
+
if (this.reusable) {
|
|
25373
|
+
return false;
|
|
25374
|
+
}
|
|
25128
25375
|
var _a = this.content, ended = _a.ended, endBehavior = _a.endBehavior;
|
|
25129
25376
|
return ended && (!endBehavior || endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1);
|
|
25130
25377
|
};
|
|
25131
25378
|
/**
|
|
25132
25379
|
* 合成更新,针对所有 item 的更新
|
|
25133
25380
|
* @param deltaTime - 更新的时间步长
|
|
25381
|
+
* @param skipRender - 是否需要渲染
|
|
25134
25382
|
*/
|
|
25135
|
-
Composition.prototype.update = function (deltaTime) {
|
|
25383
|
+
Composition.prototype.update = function (deltaTime, skipRender) {
|
|
25384
|
+
if (skipRender === void 0) { skipRender = false; }
|
|
25136
25385
|
if (!this.assigned || this.paused) {
|
|
25137
25386
|
return;
|
|
25138
25387
|
}
|
|
@@ -25149,7 +25398,9 @@ var Composition = /** @class */ (function () {
|
|
|
25149
25398
|
this.dispose();
|
|
25150
25399
|
}
|
|
25151
25400
|
else {
|
|
25152
|
-
|
|
25401
|
+
if (!skipRender) {
|
|
25402
|
+
this.prepareRender();
|
|
25403
|
+
}
|
|
25153
25404
|
}
|
|
25154
25405
|
};
|
|
25155
25406
|
/**
|
|
@@ -25437,7 +25688,10 @@ var Composition = /** @class */ (function () {
|
|
|
25437
25688
|
(_a = this.rendererOptions) === null || _a === void 0 ? void 0 : _a.emptyTexture.dispose();
|
|
25438
25689
|
(_b = this.pluginSystem) === null || _b === void 0 ? void 0 : _b.destroyComposition(this);
|
|
25439
25690
|
this.update = function () {
|
|
25440
|
-
console.error(
|
|
25691
|
+
console.error({
|
|
25692
|
+
content: "Update disposed composition: ".concat(_this.name, "."),
|
|
25693
|
+
type: LOG_TYPE,
|
|
25694
|
+
});
|
|
25441
25695
|
};
|
|
25442
25696
|
this.handlePlayerPause = noop;
|
|
25443
25697
|
this.dispose = noop;
|
|
@@ -25456,6 +25710,34 @@ var Composition = /** @class */ (function () {
|
|
|
25456
25710
|
Composition.prototype.setEditorTransform = function (scale, dx, dy) {
|
|
25457
25711
|
this.renderFrame.editorTransform = [scale, scale, dx, dy];
|
|
25458
25712
|
};
|
|
25713
|
+
/**
|
|
25714
|
+
* 合成整体在水平方向移动 x 像素,垂直方向移动 y 像素
|
|
25715
|
+
*/
|
|
25716
|
+
Composition.prototype.translateByPixel = function (x, y) {
|
|
25717
|
+
if (!this.renderer) {
|
|
25718
|
+
console.warn('Can not translate position when container not assigned');
|
|
25719
|
+
return;
|
|
25720
|
+
}
|
|
25721
|
+
this.content.translateByPixel(x, y);
|
|
25722
|
+
};
|
|
25723
|
+
/**
|
|
25724
|
+
* 设置合成在 3D 坐标轴上相对移动
|
|
25725
|
+
*/
|
|
25726
|
+
Composition.prototype.translate = function (x, y, z) {
|
|
25727
|
+
this.content.translate(x, y, z);
|
|
25728
|
+
};
|
|
25729
|
+
/**
|
|
25730
|
+
* 设置合成在 3D 坐标轴上相对旋转(角度)
|
|
25731
|
+
*/
|
|
25732
|
+
Composition.prototype.rotate = function (x, y, z) {
|
|
25733
|
+
this.content.rotate(x, y, z);
|
|
25734
|
+
};
|
|
25735
|
+
/**
|
|
25736
|
+
* 设置合成在 3D 坐标轴上相对缩放
|
|
25737
|
+
*/
|
|
25738
|
+
Composition.prototype.scale = function (x, y, z) {
|
|
25739
|
+
this.content.scale(x, y, z);
|
|
25740
|
+
};
|
|
25459
25741
|
/**
|
|
25460
25742
|
* 卸载贴图纹理方法,减少内存
|
|
25461
25743
|
*/
|
|
@@ -25495,14 +25777,6 @@ var Composition = /** @class */ (function () {
|
|
|
25495
25777
|
};
|
|
25496
25778
|
return Composition;
|
|
25497
25779
|
}());
|
|
25498
|
-
/**
|
|
25499
|
-
* 根据 id 查找对应的合成,可能找不到
|
|
25500
|
-
* @param compositions - 合成列表
|
|
25501
|
-
* @param id - 目标合成 id
|
|
25502
|
-
*/
|
|
25503
|
-
function getComposition(compositions, id) {
|
|
25504
|
-
return compositions.find(function (f) { return f.id === id; });
|
|
25505
|
-
}
|
|
25506
25780
|
|
|
25507
25781
|
/**
|
|
25508
25782
|
* Engine 基类,负责维护所有 GPU 资源的销毁
|
|
@@ -25608,7 +25882,10 @@ var Engine = /** @class */ (function () {
|
|
|
25608
25882
|
info.push("Tex ".concat(this.textures.length));
|
|
25609
25883
|
}
|
|
25610
25884
|
if (info.length > 0) {
|
|
25611
|
-
console.warn(
|
|
25885
|
+
console.warn({
|
|
25886
|
+
content: "Release GPU memory: ".concat(info.join(', ')),
|
|
25887
|
+
type: LOG_TYPE,
|
|
25888
|
+
});
|
|
25612
25889
|
}
|
|
25613
25890
|
this.renderPasses.forEach(function (pass) {
|
|
25614
25891
|
pass.dispose();
|
|
@@ -27249,8 +27526,11 @@ Geometry.create = function (engine, options) {
|
|
|
27249
27526
|
Mesh.create = function (engine, props) {
|
|
27250
27527
|
return new ThreeMesh(engine, props);
|
|
27251
27528
|
};
|
|
27252
|
-
var version = "0.0.1-alpha.
|
|
27253
|
-
console.info(
|
|
27529
|
+
var version = "0.0.1-alpha.2";
|
|
27530
|
+
console.info({
|
|
27531
|
+
content: '[Galacean Effects THREEJS] version: ' + "0.0.1-alpha.2",
|
|
27532
|
+
type: LOG_TYPE,
|
|
27533
|
+
});
|
|
27254
27534
|
|
|
27255
|
-
export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DEG2RAD, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, NumberEpsilon, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, VFX_ITEM_TYPE_TREE, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, clamp$1 as clamp, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, dotInTriangle, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops,
|
|
27535
|
+
export { AbstractPlugin, AssetManager, BYTES_TYPE_MAP, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateItem, CalculateLoader, CalculateVFXItem, Camera, CameraController, CameraVFXItem, CameraVFXItemLoader, Composition, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DEG2RAD, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, Engine, EventSystem, FILTER_NAME_NONE, FilterMode, FilterSpriteVFXItem, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractItem, InteractLoader, InteractMesh, InteractVFXItem, KTXTexture, LOG_TYPE, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, NumberEpsilon, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleLoader, ParticleMesh, ParticleSystem, ParticleVFXItem, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, Shader, ShaderCompileResultStatus, ShaderType, SpriteItem, SpriteLoader, SpriteMesh, SpriteVFXItem, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextItem, TextLoader, TextMesh, TextVFXItem, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeMaterial, ThreeTexture, Ticker, TimelineComponent, Transform, VFXItem, VFX_ITEM_TYPE_TREE, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrameFrag, alphaMaskFrag, assertExist, asserts, blend, bloomMixVert, bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMoveVert, canvasPool, clamp$1 as clamp, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copyFrag, createCopyShader, createFilter, createFilterShaders, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delayFrag, deserializeMipmapTexture, distortionFrag, distortionVert, dotInTriangle, earcut, enlargeBuffer, ensureVec3, filters, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMat4TR, getMat4TRS, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, intersectRayBox, intersectRaySphere, intersectRayTriangle, isAndroid, isArray, isFunction, isIOS, isIdentityMatrix, isObject, isScene, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, isZeroVec, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, mat3FromQuat, mat3FromRotation, mat3FromRotationZ, mat4Clone, mat4Determinate, mat4ToIdentityMatrix, mat4create, mat4fromRotationTranslationScale, mat4invert, mat4multiply, mat4perspective, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, quatFromRotation, quatMultiply, quatStar, random, registerFilter, registerFilters, registerPlugin, removeItem, requestAsync, rotateByQuat, rotateVec2, rotationFromMat3, screenMeshVert, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vec3Cross, vec3MulMat3, vec3MulMat4, vec3RotateByMat4, vecAdd, vecAssign, vecDot, vecFill, vecMinus, vecMulCombine, vecMulScalar, vecNormalize, vecSquareDistance, version };
|
|
27256
27536
|
//# sourceMappingURL=index.mjs.map
|