@galacean/effects-threejs 2.0.0-alpha.8 → 2.0.0-alpha.9
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/dist/index.js +217 -218
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +216 -218
- package/dist/index.mjs.map +1 -1
- package/dist/material/three-material.d.ts +3 -0
- package/dist/three-display-object.d.ts +1 -2
- package/package.json +2 -2
package/dist/index.js
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: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.9
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -9621,6 +9621,36 @@ var seed$9 = 1;
|
|
|
9621
9621
|
type: glContext.UNSIGNED_BYTE
|
|
9622
9622
|
}, options);
|
|
9623
9623
|
};
|
|
9624
|
+
/**
|
|
9625
|
+
* 通过 URL 创建 Texture 对象。
|
|
9626
|
+
* @param url - 要创建的 Texture URL
|
|
9627
|
+
* @since 2.0.0
|
|
9628
|
+
*/ Texture.fromImage = function fromImage(url, engine) {
|
|
9629
|
+
return _async_to_generator(function() {
|
|
9630
|
+
var image, texture;
|
|
9631
|
+
return __generator(this, function(_state) {
|
|
9632
|
+
switch(_state.label){
|
|
9633
|
+
case 0:
|
|
9634
|
+
return [
|
|
9635
|
+
4,
|
|
9636
|
+
loadImage(url)
|
|
9637
|
+
];
|
|
9638
|
+
case 1:
|
|
9639
|
+
image = _state.sent();
|
|
9640
|
+
texture = Texture.create(engine, {
|
|
9641
|
+
sourceType: exports.TextureSourceType.image,
|
|
9642
|
+
image: image,
|
|
9643
|
+
id: generateGUID$1()
|
|
9644
|
+
});
|
|
9645
|
+
texture.initialize();
|
|
9646
|
+
return [
|
|
9647
|
+
2,
|
|
9648
|
+
texture
|
|
9649
|
+
];
|
|
9650
|
+
}
|
|
9651
|
+
});
|
|
9652
|
+
})();
|
|
9653
|
+
};
|
|
9624
9654
|
_create_class(Texture, [
|
|
9625
9655
|
{
|
|
9626
9656
|
key: "isDestroyed",
|
|
@@ -10593,14 +10623,10 @@ var seed$7 = 1;
|
|
|
10593
10623
|
if (!this.getVisible()) {
|
|
10594
10624
|
return;
|
|
10595
10625
|
}
|
|
10596
|
-
var material = this.material;
|
|
10597
|
-
var geo = this.geometry;
|
|
10598
10626
|
if (renderer.renderingData.currentFrame.globalUniforms) {
|
|
10599
10627
|
renderer.setGlobalMatrix("effects_ObjectToWorld", this.worldMatrix);
|
|
10600
10628
|
}
|
|
10601
|
-
|
|
10602
|
-
geo.flush();
|
|
10603
|
-
renderer.drawGeometry(geo, material);
|
|
10629
|
+
renderer.drawGeometry(this.geometry, this.material);
|
|
10604
10630
|
};
|
|
10605
10631
|
/**
|
|
10606
10632
|
* 获取当前 Mesh 的第一个 geometry。
|
|
@@ -13719,6 +13745,23 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13719
13745
|
*/ _proto.getVisible = function getVisible() {
|
|
13720
13746
|
return this.visible;
|
|
13721
13747
|
};
|
|
13748
|
+
/**
|
|
13749
|
+
* 设置当前图层的颜色
|
|
13750
|
+
* > Tips: 透明度也属于颜色的一部分,当有透明度/颜色 K 帧变化时,该 API 会失效
|
|
13751
|
+
* @since 2.0.0
|
|
13752
|
+
* @param color - 颜色值
|
|
13753
|
+
*/ _proto.setColor = function setColor(color) {
|
|
13754
|
+
this.color = color;
|
|
13755
|
+
this.material.setVector4("_Color", new Vector4().setFromArray(color));
|
|
13756
|
+
};
|
|
13757
|
+
/**
|
|
13758
|
+
* 设置当前 Mesh 的纹理
|
|
13759
|
+
* @since 2.0.0
|
|
13760
|
+
* @param texture - 纹理对象
|
|
13761
|
+
*/ _proto.setTexture = function setTexture(texture) {
|
|
13762
|
+
this.renderer.texture = texture;
|
|
13763
|
+
this.material.setTexture("uSampler0", texture);
|
|
13764
|
+
};
|
|
13722
13765
|
_proto.render = function render(renderer) {
|
|
13723
13766
|
if (!this.getVisible()) {
|
|
13724
13767
|
return;
|
|
@@ -13729,8 +13772,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13729
13772
|
renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
|
|
13730
13773
|
}
|
|
13731
13774
|
this.material.setVector2("_Size", this.transform.size);
|
|
13732
|
-
// 执行 Geometry 的数据刷新
|
|
13733
|
-
geo.flush();
|
|
13734
13775
|
renderer.drawGeometry(geo, material);
|
|
13735
13776
|
};
|
|
13736
13777
|
_proto.start = function start() {
|
|
@@ -14123,7 +14164,7 @@ exports.SpriteComponent = __decorate([
|
|
|
14123
14164
|
|
|
14124
14165
|
var RUNTIME_ENV = "runtime_env";
|
|
14125
14166
|
var RENDER_PREFER_LOOKUP_TEXTURE = "lookup_texture";
|
|
14126
|
-
//
|
|
14167
|
+
// 文本元素使用 offscreen canvas 绘制
|
|
14127
14168
|
var TEMPLATE_USE_OFFSCREEN_CANVAS = "offscreen_canvas";
|
|
14128
14169
|
// 后处理配置相关
|
|
14129
14170
|
var POST_PROCESS_SETTINGS = "post_process_settings";
|
|
@@ -17996,12 +18037,6 @@ var TextStyle = function TextStyle(options) {
|
|
|
17996
18037
|
}
|
|
17997
18038
|
};
|
|
17998
18039
|
|
|
17999
|
-
var DEFAULT_FONTS = [
|
|
18000
|
-
"serif",
|
|
18001
|
-
"sans-serif",
|
|
18002
|
-
"monospace",
|
|
18003
|
-
"courier"
|
|
18004
|
-
];
|
|
18005
18040
|
var CanvasPool = /*#__PURE__*/ function() {
|
|
18006
18041
|
function CanvasPool() {
|
|
18007
18042
|
this.elements = [];
|
|
@@ -18011,12 +18046,11 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
18011
18046
|
this.elements.forEach(function(e) {
|
|
18012
18047
|
return e.remove();
|
|
18013
18048
|
});
|
|
18014
|
-
//
|
|
18015
|
-
this.elements =
|
|
18049
|
+
// clearing the array
|
|
18050
|
+
this.elements.length = 0;
|
|
18016
18051
|
};
|
|
18017
18052
|
_proto.getCanvas = function getCanvas() {
|
|
18018
|
-
if (this.elements.length) {
|
|
18019
|
-
// @ts-expect-error
|
|
18053
|
+
if (this.elements.length !== 0) {
|
|
18020
18054
|
return this.elements.shift();
|
|
18021
18055
|
}
|
|
18022
18056
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
@@ -18031,12 +18065,13 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
18031
18065
|
return defCanvas;
|
|
18032
18066
|
}
|
|
18033
18067
|
};
|
|
18034
|
-
_proto.saveCanvas = function saveCanvas(
|
|
18035
|
-
|
|
18068
|
+
_proto.saveCanvas = function saveCanvas(canvas) {
|
|
18069
|
+
canvas.width = 1;
|
|
18070
|
+
canvas.height = 1;
|
|
18036
18071
|
if (this.elements.length < 3) {
|
|
18037
|
-
addItem(this.elements,
|
|
18072
|
+
addItem(this.elements, canvas);
|
|
18038
18073
|
} else {
|
|
18039
|
-
|
|
18074
|
+
canvas.remove();
|
|
18040
18075
|
}
|
|
18041
18076
|
};
|
|
18042
18077
|
return CanvasPool;
|
|
@@ -18045,117 +18080,13 @@ var canvasPool = new CanvasPool();
|
|
|
18045
18080
|
function getDefaultTemplateCanvasPool() {
|
|
18046
18081
|
return canvasPool;
|
|
18047
18082
|
}
|
|
18048
|
-
function getBackgroundImage(template, variables) {
|
|
18049
|
-
var templateBackground;
|
|
18050
|
-
var _template_background;
|
|
18051
|
-
var _ref = (_template_background = template == null ? void 0 : template.background) != null ? _template_background : {}, name = _ref.name, url = _ref.url;
|
|
18052
|
-
if (name) {
|
|
18053
|
-
if (variables && variables[name]) {
|
|
18054
|
-
templateBackground = variables[name];
|
|
18055
|
-
} else if (url) {
|
|
18056
|
-
templateBackground = url;
|
|
18057
|
-
}
|
|
18058
|
-
}
|
|
18059
|
-
return templateBackground;
|
|
18060
|
-
}
|
|
18061
|
-
function drawImageByTemplate(image, template, variables) {
|
|
18062
|
-
return _drawImageByTemplate.apply(this, arguments);
|
|
18063
|
-
}
|
|
18064
|
-
function _drawImageByTemplate() {
|
|
18065
|
-
_drawImageByTemplate = _async_to_generator(function(image, template, variables) {
|
|
18066
|
-
var drawImage, templateBackground, _tmp;
|
|
18067
|
-
return __generator(this, function(_state) {
|
|
18068
|
-
switch(_state.label){
|
|
18069
|
-
case 0:
|
|
18070
|
-
if (!image) {
|
|
18071
|
-
throw Error("image not provided");
|
|
18072
|
-
}
|
|
18073
|
-
if (!template) {
|
|
18074
|
-
return [
|
|
18075
|
-
2,
|
|
18076
|
-
image
|
|
18077
|
-
];
|
|
18078
|
-
}
|
|
18079
|
-
drawImage = image;
|
|
18080
|
-
// 获取动态换图的图片对象或 url 地址
|
|
18081
|
-
templateBackground = getBackgroundImage(template, variables);
|
|
18082
|
-
if (!(templateBackground && templateBackground !== image.src)) return [
|
|
18083
|
-
3,
|
|
18084
|
-
4
|
|
18085
|
-
];
|
|
18086
|
-
if (!isString(templateBackground)) return [
|
|
18087
|
-
3,
|
|
18088
|
-
2
|
|
18089
|
-
];
|
|
18090
|
-
return [
|
|
18091
|
-
4,
|
|
18092
|
-
loadImage(templateBackground)
|
|
18093
|
-
];
|
|
18094
|
-
case 1:
|
|
18095
|
-
_tmp = _state.sent();
|
|
18096
|
-
return [
|
|
18097
|
-
3,
|
|
18098
|
-
3
|
|
18099
|
-
];
|
|
18100
|
-
case 2:
|
|
18101
|
-
_tmp = templateBackground;
|
|
18102
|
-
_state.label = 3;
|
|
18103
|
-
case 3:
|
|
18104
|
-
drawImage = _tmp;
|
|
18105
|
-
_state.label = 4;
|
|
18106
|
-
case 4:
|
|
18107
|
-
return [
|
|
18108
|
-
2,
|
|
18109
|
-
drawImage
|
|
18110
|
-
];
|
|
18111
|
-
}
|
|
18112
|
-
});
|
|
18113
|
-
});
|
|
18114
|
-
return _drawImageByTemplate.apply(this, arguments);
|
|
18115
|
-
}
|
|
18116
|
-
/**
|
|
18117
|
-
* @param url
|
|
18118
|
-
* @param template
|
|
18119
|
-
* @param variables
|
|
18120
|
-
* @param options
|
|
18121
|
-
* @returns
|
|
18122
|
-
*/ function combineImageTemplate(url, template, variables) {
|
|
18123
|
-
return _combineImageTemplate.apply(this, arguments);
|
|
18124
|
-
}
|
|
18125
|
-
function _combineImageTemplate() {
|
|
18126
|
-
_combineImageTemplate = _async_to_generator(function(url, template, variables) {
|
|
18127
|
-
var image;
|
|
18128
|
-
return __generator(this, function(_state) {
|
|
18129
|
-
switch(_state.label){
|
|
18130
|
-
case 0:
|
|
18131
|
-
if (!(typeof url === "string")) return [
|
|
18132
|
-
3,
|
|
18133
|
-
2
|
|
18134
|
-
];
|
|
18135
|
-
return [
|
|
18136
|
-
4,
|
|
18137
|
-
loadImage(url)
|
|
18138
|
-
];
|
|
18139
|
-
case 1:
|
|
18140
|
-
image = _state.sent();
|
|
18141
|
-
return [
|
|
18142
|
-
3,
|
|
18143
|
-
3
|
|
18144
|
-
];
|
|
18145
|
-
case 2:
|
|
18146
|
-
image = url;
|
|
18147
|
-
_state.label = 3;
|
|
18148
|
-
case 3:
|
|
18149
|
-
return [
|
|
18150
|
-
2,
|
|
18151
|
-
drawImageByTemplate(image, template, variables)
|
|
18152
|
-
];
|
|
18153
|
-
}
|
|
18154
|
-
});
|
|
18155
|
-
});
|
|
18156
|
-
return _combineImageTemplate.apply(this, arguments);
|
|
18157
|
-
}
|
|
18158
18083
|
|
|
18084
|
+
var DEFAULT_FONTS = [
|
|
18085
|
+
"serif",
|
|
18086
|
+
"sans-serif",
|
|
18087
|
+
"monospace",
|
|
18088
|
+
"courier"
|
|
18089
|
+
];
|
|
18159
18090
|
exports.TextComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
18160
18091
|
_inherits(TextComponent, SpriteComponent);
|
|
18161
18092
|
function TextComponent(engine, props) {
|
|
@@ -18538,14 +18469,10 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
18538
18469
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
18539
18470
|
};
|
|
18540
18471
|
_proto.render = function render(renderer) {
|
|
18541
|
-
var material = this.material;
|
|
18542
|
-
var geo = this.geometry;
|
|
18543
18472
|
if (renderer.renderingData.currentFrame.globalUniforms) {
|
|
18544
18473
|
renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
|
|
18545
18474
|
}
|
|
18546
|
-
|
|
18547
|
-
geo.flush();
|
|
18548
|
-
renderer.drawGeometry(geo, material);
|
|
18475
|
+
renderer.drawGeometry(this.geometry, this.material);
|
|
18549
18476
|
};
|
|
18550
18477
|
/**
|
|
18551
18478
|
* 获取当前 Mesh 的可见性。
|
|
@@ -21370,10 +21297,110 @@ function passRenderLevel(l, renderLevel) {
|
|
|
21370
21297
|
return false;
|
|
21371
21298
|
}
|
|
21372
21299
|
|
|
21373
|
-
function
|
|
21300
|
+
function isSceneJSON(scene) {
|
|
21374
21301
|
// TODO: 判断不太优雅,后期试情况优化
|
|
21375
21302
|
return isObject(scene) && "jsonScene" in scene;
|
|
21376
21303
|
}
|
|
21304
|
+
function isSceneURL(scene) {
|
|
21305
|
+
return isObject(scene) && "url" in scene;
|
|
21306
|
+
}
|
|
21307
|
+
function isSceneWithOptions(scene) {
|
|
21308
|
+
// TODO: 判断不太优雅,后期试情况优化
|
|
21309
|
+
return isObject(scene) && "options" in scene;
|
|
21310
|
+
}
|
|
21311
|
+
|
|
21312
|
+
function getBackgroundImage(template, variables) {
|
|
21313
|
+
var templateBackground;
|
|
21314
|
+
var _template_background;
|
|
21315
|
+
var _ref = (_template_background = template == null ? void 0 : template.background) != null ? _template_background : {}, name = _ref.name, url = _ref.url;
|
|
21316
|
+
if (name) {
|
|
21317
|
+
if (variables && variables[name]) {
|
|
21318
|
+
templateBackground = variables[name];
|
|
21319
|
+
} else if (url) {
|
|
21320
|
+
templateBackground = url;
|
|
21321
|
+
}
|
|
21322
|
+
}
|
|
21323
|
+
return templateBackground;
|
|
21324
|
+
}
|
|
21325
|
+
/**
|
|
21326
|
+
* @param url
|
|
21327
|
+
* @param template
|
|
21328
|
+
* @param variables
|
|
21329
|
+
* @param options
|
|
21330
|
+
* @returns
|
|
21331
|
+
*/ function combineImageTemplate(url, template, variables) {
|
|
21332
|
+
return _combineImageTemplate.apply(this, arguments);
|
|
21333
|
+
}
|
|
21334
|
+
function _combineImageTemplate() {
|
|
21335
|
+
_combineImageTemplate = _async_to_generator(function(url, template, variables) {
|
|
21336
|
+
var image, drawImage, templateBackground, _tmp;
|
|
21337
|
+
return __generator(this, function(_state) {
|
|
21338
|
+
switch(_state.label){
|
|
21339
|
+
case 0:
|
|
21340
|
+
if (!(typeof url === "string")) return [
|
|
21341
|
+
3,
|
|
21342
|
+
2
|
|
21343
|
+
];
|
|
21344
|
+
return [
|
|
21345
|
+
4,
|
|
21346
|
+
loadImage(url)
|
|
21347
|
+
];
|
|
21348
|
+
case 1:
|
|
21349
|
+
image = _state.sent();
|
|
21350
|
+
return [
|
|
21351
|
+
3,
|
|
21352
|
+
3
|
|
21353
|
+
];
|
|
21354
|
+
case 2:
|
|
21355
|
+
image = url;
|
|
21356
|
+
_state.label = 3;
|
|
21357
|
+
case 3:
|
|
21358
|
+
if (!image) {
|
|
21359
|
+
throw new Error("image not provided.");
|
|
21360
|
+
}
|
|
21361
|
+
if (!template) {
|
|
21362
|
+
return [
|
|
21363
|
+
2,
|
|
21364
|
+
image
|
|
21365
|
+
];
|
|
21366
|
+
}
|
|
21367
|
+
drawImage = image;
|
|
21368
|
+
// 获取动态换图的图片对象或 url 地址
|
|
21369
|
+
templateBackground = getBackgroundImage(template, variables);
|
|
21370
|
+
if (!(templateBackground && isString(templateBackground) && templateBackground !== image.src)) return [
|
|
21371
|
+
3,
|
|
21372
|
+
7
|
|
21373
|
+
];
|
|
21374
|
+
if (!isString(templateBackground)) return [
|
|
21375
|
+
3,
|
|
21376
|
+
5
|
|
21377
|
+
];
|
|
21378
|
+
return [
|
|
21379
|
+
4,
|
|
21380
|
+
loadImage(templateBackground)
|
|
21381
|
+
];
|
|
21382
|
+
case 4:
|
|
21383
|
+
_tmp = _state.sent();
|
|
21384
|
+
return [
|
|
21385
|
+
3,
|
|
21386
|
+
6
|
|
21387
|
+
];
|
|
21388
|
+
case 5:
|
|
21389
|
+
_tmp = templateBackground;
|
|
21390
|
+
_state.label = 6;
|
|
21391
|
+
case 6:
|
|
21392
|
+
drawImage = _tmp;
|
|
21393
|
+
_state.label = 7;
|
|
21394
|
+
case 7:
|
|
21395
|
+
return [
|
|
21396
|
+
2,
|
|
21397
|
+
drawImage
|
|
21398
|
+
];
|
|
21399
|
+
}
|
|
21400
|
+
});
|
|
21401
|
+
});
|
|
21402
|
+
return _combineImageTemplate.apply(this, arguments);
|
|
21403
|
+
}
|
|
21377
21404
|
|
|
21378
21405
|
var seed$1 = 1;
|
|
21379
21406
|
/**
|
|
@@ -21402,22 +21429,19 @@ var seed$1 = 1;
|
|
|
21402
21429
|
};
|
|
21403
21430
|
/**
|
|
21404
21431
|
* 根据用户传入的参数修改场景数据
|
|
21405
|
-
*/ _proto.updateSceneData = function updateSceneData(
|
|
21432
|
+
*/ _proto.updateSceneData = function updateSceneData(items) {
|
|
21406
21433
|
var variables = this.options.variables;
|
|
21407
|
-
if (!variables || Object.keys(variables).length
|
|
21408
|
-
return
|
|
21409
|
-
}
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
|
|
21413
|
-
|
|
21414
|
-
|
|
21415
|
-
item.content.options.text = textVariable;
|
|
21416
|
-
}
|
|
21434
|
+
if (!variables || Object.keys(variables).length === 0) {
|
|
21435
|
+
return;
|
|
21436
|
+
}
|
|
21437
|
+
items.forEach(function(item) {
|
|
21438
|
+
if (item.type === ItemType$1.text) {
|
|
21439
|
+
var textVariable = variables[item.name];
|
|
21440
|
+
if (textVariable) {
|
|
21441
|
+
item.content.options.text = textVariable;
|
|
21417
21442
|
}
|
|
21418
|
-
}
|
|
21443
|
+
}
|
|
21419
21444
|
});
|
|
21420
|
-
return compositions;
|
|
21421
21445
|
};
|
|
21422
21446
|
/**
|
|
21423
21447
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
@@ -21442,7 +21466,7 @@ var seed$1 = 1;
|
|
|
21442
21466
|
cancelLoading = true;
|
|
21443
21467
|
_this.removeTimer(loadTimer);
|
|
21444
21468
|
var totalTime = performance.now() - startTime;
|
|
21445
|
-
reject("Load time out: totalTime: " + totalTime.toFixed(4) + "ms " + timeInfos.join(" ") + ", url: " + assetUrl);
|
|
21469
|
+
reject(new Error("Load time out: totalTime: " + totalTime.toFixed(4) + "ms " + timeInfos.join(" ") + ", url: " + assetUrl));
|
|
21446
21470
|
}, _this.timeout * 1000);
|
|
21447
21471
|
_this.timers.push(loadTimer);
|
|
21448
21472
|
});
|
|
@@ -21477,9 +21501,9 @@ var seed$1 = 1;
|
|
|
21477
21501
|
];
|
|
21478
21502
|
case 3:
|
|
21479
21503
|
e = _state.sent();
|
|
21480
|
-
throw new Error("
|
|
21504
|
+
throw new Error("Load error in " + label + ", " + e);
|
|
21481
21505
|
case 4:
|
|
21482
|
-
throw new Error("
|
|
21506
|
+
throw new Error("Load canceled.");
|
|
21483
21507
|
}
|
|
21484
21508
|
});
|
|
21485
21509
|
});
|
|
@@ -21513,7 +21537,7 @@ var seed$1 = 1;
|
|
|
21513
21537
|
rawJSON = _state.sent();
|
|
21514
21538
|
_state.label = 3;
|
|
21515
21539
|
case 3:
|
|
21516
|
-
if (!
|
|
21540
|
+
if (!isSceneJSON(rawJSON)) return [
|
|
21517
21541
|
3,
|
|
21518
21542
|
6
|
|
21519
21543
|
];
|
|
@@ -21543,7 +21567,7 @@ var seed$1 = 1;
|
|
|
21543
21567
|
for(i1 = 0; i1 < scene.images.length; i1++){
|
|
21544
21568
|
scene.textureOptions[i1].image = scene.images[i1];
|
|
21545
21569
|
}
|
|
21546
|
-
|
|
21570
|
+
_this.updateSceneData(scene.jsonScene.items);
|
|
21547
21571
|
_state.label = 5;
|
|
21548
21572
|
case 5:
|
|
21549
21573
|
return [
|
|
@@ -21592,7 +21616,7 @@ var seed$1 = 1;
|
|
|
21592
21616
|
];
|
|
21593
21617
|
case 10:
|
|
21594
21618
|
loadedTextures = _state.sent();
|
|
21595
|
-
|
|
21619
|
+
_this.updateSceneData(jsonScene.items);
|
|
21596
21620
|
scene = {
|
|
21597
21621
|
url: url,
|
|
21598
21622
|
renderLevel: _this.options.renderLevel,
|
|
@@ -21815,7 +21839,7 @@ var seed$1 = 1;
|
|
|
21815
21839
|
_this_options = _this.options, useCompressedTexture = _this_options.useCompressedTexture, variables = _this_options.variables;
|
|
21816
21840
|
baseUrl = _this.baseUrl;
|
|
21817
21841
|
jobs = images.map(/*#__PURE__*/ _async_to_generator(function(img, idx) {
|
|
21818
|
-
var png, webp, imageURL, webpURL, template,
|
|
21842
|
+
var png, webp, imageURL, webpURL, template, background, url, isVideo, loadFn, resultImage, compressed, src, bufferURL, _ref, url1, image;
|
|
21819
21843
|
return __generator(this, function(_state) {
|
|
21820
21844
|
switch(_state.label){
|
|
21821
21845
|
case 0:
|
|
@@ -21832,17 +21856,15 @@ var seed$1 = 1;
|
|
|
21832
21856
|
webpURL = webp && new URL(webp, baseUrl).href;
|
|
21833
21857
|
if (!("template" in img)) return [
|
|
21834
21858
|
3,
|
|
21835
|
-
|
|
21859
|
+
8
|
|
21836
21860
|
];
|
|
21837
21861
|
// 1. 数据模板
|
|
21838
21862
|
template = img.template;
|
|
21839
|
-
//
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
background = isTemplateV2 ? template.background : undefined;
|
|
21843
|
-
if (!(isTemplateV2 && background)) return [
|
|
21863
|
+
// 获取数据模板 background 参数
|
|
21864
|
+
background = template.background;
|
|
21865
|
+
if (!background) return [
|
|
21844
21866
|
3,
|
|
21845
|
-
|
|
21867
|
+
7
|
|
21846
21868
|
];
|
|
21847
21869
|
url = getBackgroundImage(template, variables);
|
|
21848
21870
|
isVideo = background.type === BackgroundType$1.video;
|
|
@@ -21895,48 +21917,10 @@ var seed$1 = 1;
|
|
|
21895
21917
|
case 7:
|
|
21896
21918
|
return [
|
|
21897
21919
|
3,
|
|
21898
|
-
|
|
21920
|
+
9
|
|
21899
21921
|
];
|
|
21900
21922
|
case 8:
|
|
21901
|
-
|
|
21902
|
-
8,
|
|
21903
|
-
11,
|
|
21904
|
-
,
|
|
21905
|
-
12
|
|
21906
|
-
]);
|
|
21907
|
-
return [
|
|
21908
|
-
4,
|
|
21909
|
-
loadWebPOptional(imageURL, webpURL)
|
|
21910
|
-
];
|
|
21911
|
-
case 9:
|
|
21912
|
-
resultImage1 = _state.sent();
|
|
21913
|
-
return [
|
|
21914
|
-
4,
|
|
21915
|
-
combineImageTemplate(resultImage1.image, template, variables)
|
|
21916
|
-
];
|
|
21917
|
-
case 10:
|
|
21918
|
-
return [
|
|
21919
|
-
2,
|
|
21920
|
-
_state.sent()
|
|
21921
|
-
];
|
|
21922
|
-
case 11:
|
|
21923
|
-
_state.sent();
|
|
21924
|
-
throw new Error("Failed to load. Check the template, URL: " + imageURL + ".");
|
|
21925
|
-
case 12:
|
|
21926
|
-
return [
|
|
21927
|
-
3,
|
|
21928
|
-
14
|
|
21929
|
-
];
|
|
21930
|
-
case 13:
|
|
21931
|
-
if ("type" in img && img.type === "video") {
|
|
21932
|
-
// 视频
|
|
21933
|
-
// TODO: 2024.03.28 后面考虑下掉非推荐的视频元素使用方式
|
|
21934
|
-
console.warn("The video element is deprecated. Use template BackgroundType.video instead.");
|
|
21935
|
-
return [
|
|
21936
|
-
2,
|
|
21937
|
-
loadVideo(img.url)
|
|
21938
|
-
];
|
|
21939
|
-
} else if ("compressed" in img && useCompressedTexture && compressedTexture) {
|
|
21923
|
+
if ("compressed" in img && useCompressedTexture && compressedTexture) {
|
|
21940
21924
|
// 2. 压缩纹理
|
|
21941
21925
|
compressed = img.compressed;
|
|
21942
21926
|
if (compressedTexture === COMPRESSED_TEXTURE.ASTC) {
|
|
@@ -21956,6 +21940,7 @@ var seed$1 = 1;
|
|
|
21956
21940
|
];
|
|
21957
21941
|
}
|
|
21958
21942
|
} else if ("sourceType" in img) {
|
|
21943
|
+
// TODO: 确定是否有用
|
|
21959
21944
|
return [
|
|
21960
21945
|
2,
|
|
21961
21946
|
img
|
|
@@ -21966,13 +21951,13 @@ var seed$1 = 1;
|
|
|
21966
21951
|
img
|
|
21967
21952
|
];
|
|
21968
21953
|
}
|
|
21969
|
-
_state.label =
|
|
21970
|
-
case
|
|
21954
|
+
_state.label = 9;
|
|
21955
|
+
case 9:
|
|
21971
21956
|
return [
|
|
21972
21957
|
4,
|
|
21973
21958
|
loadWebPOptional(imageURL, webpURL)
|
|
21974
21959
|
];
|
|
21975
|
-
case
|
|
21960
|
+
case 10:
|
|
21976
21961
|
_ref = _state.sent(), url1 = _ref.url, image = _ref.image;
|
|
21977
21962
|
_this.assets[idx] = {
|
|
21978
21963
|
url: url1,
|
|
@@ -22826,6 +22811,15 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
22826
22811
|
this.speed = speed;
|
|
22827
22812
|
};
|
|
22828
22813
|
/**
|
|
22814
|
+
* 设置合成的可见性
|
|
22815
|
+
* @since 2.0.0
|
|
22816
|
+
* @param visible - 是否可见
|
|
22817
|
+
*/ _proto.setVisible = function setVisible(visible) {
|
|
22818
|
+
this.items.forEach(function(item) {
|
|
22819
|
+
item.setVisible(visible);
|
|
22820
|
+
});
|
|
22821
|
+
};
|
|
22822
|
+
/**
|
|
22829
22823
|
* 获取合成的动画速度
|
|
22830
22824
|
* @returns
|
|
22831
22825
|
*/ _proto.getSpeed = function getSpeed() {
|
|
@@ -24962,6 +24956,12 @@ var _obj3;
|
|
|
24962
24956
|
_proto.setVector4 = function setVector4(name, value) {
|
|
24963
24957
|
this.setUniform(name, value);
|
|
24964
24958
|
};
|
|
24959
|
+
_proto.getColor = function getColor(name) {
|
|
24960
|
+
return this.uniforms[name].value;
|
|
24961
|
+
};
|
|
24962
|
+
_proto.setColor = function setColor(name, value) {
|
|
24963
|
+
this.setUniform(name, value);
|
|
24964
|
+
};
|
|
24965
24965
|
_proto.getQuaternion = function getQuaternion(name) {
|
|
24966
24966
|
return this.uniforms[name].value;
|
|
24967
24967
|
};
|
|
@@ -26053,9 +26053,11 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
26053
26053
|
opts = _extends({
|
|
26054
26054
|
autoplay: true
|
|
26055
26055
|
}, options);
|
|
26056
|
-
if (
|
|
26057
|
-
source = url.
|
|
26058
|
-
|
|
26056
|
+
if (isSceneURL(url)) {
|
|
26057
|
+
source = url.url;
|
|
26058
|
+
if (isSceneWithOptions(url)) {
|
|
26059
|
+
opts = _extends({}, opts, url.options || {});
|
|
26060
|
+
}
|
|
26059
26061
|
} else {
|
|
26060
26062
|
source = url;
|
|
26061
26063
|
}
|
|
@@ -26140,10 +26142,6 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
26140
26142
|
]);
|
|
26141
26143
|
return ThreeDisplayObject;
|
|
26142
26144
|
}(THREE__namespace.Group);
|
|
26143
|
-
function isSceneWithOptions(scene) {
|
|
26144
|
-
// TODO: 判断不太优雅,后期试情况优化
|
|
26145
|
-
return isObject(scene) && "scene" in scene;
|
|
26146
|
-
}
|
|
26147
26145
|
|
|
26148
26146
|
exports.ThreeSpriteComponent = /*#__PURE__*/ function(SpriteComponent) {
|
|
26149
26147
|
_inherits(ThreeSpriteComponent, SpriteComponent);
|
|
@@ -26280,7 +26278,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
26280
26278
|
*/ Mesh.create = function(engine, props) {
|
|
26281
26279
|
return new ThreeMesh(engine, props);
|
|
26282
26280
|
};
|
|
26283
|
-
var version = "2.0.0-alpha.
|
|
26281
|
+
var version = "2.0.0-alpha.9";
|
|
26284
26282
|
logger.info("THREEJS plugin version: " + version);
|
|
26285
26283
|
|
|
26286
26284
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -26457,7 +26455,8 @@ exports.isArray = isArray;
|
|
|
26457
26455
|
exports.isFunction = isFunction;
|
|
26458
26456
|
exports.isIOS = isIOS;
|
|
26459
26457
|
exports.isObject = isObject;
|
|
26460
|
-
exports.
|
|
26458
|
+
exports.isSceneJSON = isSceneJSON;
|
|
26459
|
+
exports.isSceneURL = isSceneURL;
|
|
26461
26460
|
exports.isSceneWithOptions = isSceneWithOptions;
|
|
26462
26461
|
exports.isSimulatorCellPhone = isSimulatorCellPhone;
|
|
26463
26462
|
exports.isString = isString;
|