@galacean/effects-threejs 2.3.0-beta.3 → 2.3.0
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 +80 -126
- 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 +80 -126
- package/dist/index.mjs.map +1 -1
- package/dist/three-display-object.d.ts +3 -3
- 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.3.0
|
|
6
|
+
* Version: v2.3.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -32101,7 +32101,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
32101
32101
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
32102
32102
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
32103
32103
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
32104
|
-
var version$1 = "2.3.0
|
|
32104
|
+
var version$1 = "2.3.0";
|
|
32105
32105
|
logger.info("Core version: " + version$1 + ".");
|
|
32106
32106
|
|
|
32107
32107
|
var _obj;
|
|
@@ -33361,6 +33361,7 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
33361
33361
|
_this.baseCompositionIndex = 0;
|
|
33362
33362
|
var width = options.width, height = options.height, camera = options.camera;
|
|
33363
33363
|
_this.renderer = new ThreeRenderer(context);
|
|
33364
|
+
_this.assetService = new AssetService(_this.renderer.engine);
|
|
33364
33365
|
_this.width = width;
|
|
33365
33366
|
_this.height = height;
|
|
33366
33367
|
_this.camera = camera;
|
|
@@ -33370,63 +33371,109 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
33370
33371
|
_proto.loadScene = function loadScene(scene, options) {
|
|
33371
33372
|
var _this = this;
|
|
33372
33373
|
return _async_to_generator(function() {
|
|
33373
|
-
var
|
|
33374
|
+
var last, scenes, compositions, _options_autoplay, autoplay, baseOrder, _scenes, i, compositionNames, firstFrameTime, _iterator, _step, composition;
|
|
33374
33375
|
return __generator(this, function(_state) {
|
|
33375
33376
|
switch(_state.label){
|
|
33376
33377
|
case 0:
|
|
33378
|
+
assertExist(_this.renderer, "Renderer is not exist, maybe the Player has been disabled or in gl 'debug-disable' mode.");
|
|
33379
|
+
last = performance.now();
|
|
33380
|
+
scenes = [];
|
|
33381
|
+
compositions = [];
|
|
33382
|
+
autoplay = (_options_autoplay = options == null ? void 0 : options.autoplay) != null ? _options_autoplay : true;
|
|
33377
33383
|
baseOrder = _this.baseCompositionIndex;
|
|
33378
|
-
if (
|
|
33379
|
-
|
|
33380
|
-
|
|
33381
|
-
|
|
33382
|
-
|
|
33384
|
+
if (isArray(scene)) {
|
|
33385
|
+
(_scenes = scenes).push.apply(_scenes, [].concat(scene));
|
|
33386
|
+
} else {
|
|
33387
|
+
scenes.push(scene);
|
|
33388
|
+
}
|
|
33383
33389
|
return [
|
|
33384
33390
|
4,
|
|
33385
|
-
Promise.all(
|
|
33386
|
-
var
|
|
33391
|
+
Promise.all(scenes.map(/*#__PURE__*/ _async_to_generator(function(url, index) {
|
|
33392
|
+
var _this_assetService_assembleSceneLoadOptions, source, opts, assetManager, _$scene, composition;
|
|
33387
33393
|
return __generator(this, function(_state) {
|
|
33388
33394
|
switch(_state.label){
|
|
33389
33395
|
case 0:
|
|
33396
|
+
_this_assetService_assembleSceneLoadOptions = _this.assetService.assembleSceneLoadOptions(url, _extends({
|
|
33397
|
+
autoplay: autoplay
|
|
33398
|
+
}, options)), source = _this_assetService_assembleSceneLoadOptions.source, opts = _this_assetService_assembleSceneLoadOptions.options;
|
|
33399
|
+
assetManager = new AssetManager(opts);
|
|
33390
33400
|
return [
|
|
33391
33401
|
4,
|
|
33392
|
-
|
|
33402
|
+
assetManager.loadScene(source, _this.renderer, {
|
|
33403
|
+
env: _this.env
|
|
33404
|
+
})
|
|
33393
33405
|
];
|
|
33394
33406
|
case 1:
|
|
33395
|
-
|
|
33396
|
-
|
|
33407
|
+
_$scene = _state.sent();
|
|
33408
|
+
_this.assetService.prepareAssets(_$scene, assetManager.getAssets());
|
|
33409
|
+
_this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
|
|
33410
|
+
_this.assetService.initializeTexture(_$scene);
|
|
33411
|
+
_$scene.pluginSystem.precompile(_$scene.jsonScene.compositions, _this.renderer, options);
|
|
33412
|
+
composition = _this.createComposition(_$scene, opts);
|
|
33413
|
+
_this.baseCompositionIndex += 1;
|
|
33414
|
+
composition.setIndex(baseOrder + index);
|
|
33415
|
+
compositions[index] = composition;
|
|
33397
33416
|
return [
|
|
33398
|
-
2
|
|
33399
|
-
res
|
|
33417
|
+
2
|
|
33400
33418
|
];
|
|
33401
33419
|
}
|
|
33402
33420
|
});
|
|
33403
33421
|
})))
|
|
33404
33422
|
];
|
|
33405
33423
|
case 1:
|
|
33406
|
-
|
|
33407
|
-
|
|
33408
|
-
|
|
33409
|
-
|
|
33410
|
-
|
|
33411
|
-
|
|
33412
|
-
|
|
33413
|
-
|
|
33414
|
-
|
|
33415
|
-
|
|
33416
|
-
|
|
33417
|
-
|
|
33418
|
-
|
|
33419
|
-
|
|
33420
|
-
|
|
33421
|
-
|
|
33424
|
+
_state.sent();
|
|
33425
|
+
for(i = 0; i < compositions.length; i++){
|
|
33426
|
+
if (autoplay) {
|
|
33427
|
+
compositions[i].play();
|
|
33428
|
+
} else {
|
|
33429
|
+
compositions[i].pause();
|
|
33430
|
+
}
|
|
33431
|
+
}
|
|
33432
|
+
compositionNames = compositions.map(function(composition) {
|
|
33433
|
+
return composition.name;
|
|
33434
|
+
});
|
|
33435
|
+
firstFrameTime = performance.now() - last;
|
|
33436
|
+
for(_iterator = _create_for_of_iterator_helper_loose(compositions); !(_step = _iterator()).done;){
|
|
33437
|
+
composition = _step.value;
|
|
33438
|
+
composition.statistic.firstFrameTime = firstFrameTime;
|
|
33439
|
+
}
|
|
33440
|
+
logger.info("First frame [" + compositionNames + "]: " + firstFrameTime.toFixed(4) + "ms.");
|
|
33422
33441
|
return [
|
|
33423
33442
|
2,
|
|
33424
|
-
|
|
33443
|
+
isArray(scene) ? compositions : compositions[0]
|
|
33425
33444
|
];
|
|
33426
33445
|
}
|
|
33427
33446
|
});
|
|
33428
33447
|
})();
|
|
33429
33448
|
};
|
|
33449
|
+
_proto.createComposition = function createComposition(scene, options) {
|
|
33450
|
+
var _this = this;
|
|
33451
|
+
if (options === void 0) options = {};
|
|
33452
|
+
var composition = new ThreeComposition(_extends({}, options, {
|
|
33453
|
+
width: this.width,
|
|
33454
|
+
height: this.height,
|
|
33455
|
+
renderer: this.renderer,
|
|
33456
|
+
handleItemMessage: function(message) {
|
|
33457
|
+
_this.dispatchEvent({
|
|
33458
|
+
type: "message",
|
|
33459
|
+
message: message
|
|
33460
|
+
});
|
|
33461
|
+
}
|
|
33462
|
+
}), scene);
|
|
33463
|
+
composition.on("end", function() {
|
|
33464
|
+
_this.dispatchEvent({
|
|
33465
|
+
type: "end",
|
|
33466
|
+
composition: composition
|
|
33467
|
+
});
|
|
33468
|
+
});
|
|
33469
|
+
this.renderer.engine.setOptions({
|
|
33470
|
+
threeCamera: this.camera,
|
|
33471
|
+
threeGroup: this,
|
|
33472
|
+
composition: composition
|
|
33473
|
+
});
|
|
33474
|
+
this.compositions.push(composition);
|
|
33475
|
+
return composition;
|
|
33476
|
+
};
|
|
33430
33477
|
_proto.pause = function pause() {
|
|
33431
33478
|
this.dispatchEvent({
|
|
33432
33479
|
type: "pause"
|
|
@@ -33440,99 +33487,6 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
33440
33487
|
composition.resume();
|
|
33441
33488
|
});
|
|
33442
33489
|
};
|
|
33443
|
-
_proto.createComposition = function createComposition(url, options) {
|
|
33444
|
-
if (options === void 0) options = {};
|
|
33445
|
-
var _this = this;
|
|
33446
|
-
return _async_to_generator(function() {
|
|
33447
|
-
var last, opts, source, scene, engine, i, composition, firstFrameTime;
|
|
33448
|
-
return __generator(this, function(_state) {
|
|
33449
|
-
switch(_state.label){
|
|
33450
|
-
case 0:
|
|
33451
|
-
last = performance.now();
|
|
33452
|
-
opts = _extends({
|
|
33453
|
-
autoplay: true
|
|
33454
|
-
}, options);
|
|
33455
|
-
source = url;
|
|
33456
|
-
if (exports.Scene.isURL(url)) {
|
|
33457
|
-
if (!exports.Scene.isJSONObject(url)) {
|
|
33458
|
-
source = url.url;
|
|
33459
|
-
}
|
|
33460
|
-
if (exports.Scene.isWithOptions(url)) {
|
|
33461
|
-
opts = _extends({}, opts, url.options || {});
|
|
33462
|
-
}
|
|
33463
|
-
}
|
|
33464
|
-
if (_this.assetManager) {
|
|
33465
|
-
_this.assetManager.updateOptions(opts);
|
|
33466
|
-
} else {
|
|
33467
|
-
_this.assetManager = new AssetManager(opts);
|
|
33468
|
-
}
|
|
33469
|
-
return [
|
|
33470
|
-
4,
|
|
33471
|
-
_this.assetManager.loadScene(source, _this.renderer, {
|
|
33472
|
-
env: _this.env
|
|
33473
|
-
})
|
|
33474
|
-
];
|
|
33475
|
-
case 1:
|
|
33476
|
-
scene = _state.sent();
|
|
33477
|
-
engine = _this.renderer.engine;
|
|
33478
|
-
// TODO 多 json 之间目前不共用资源,如果后续需要多 json 共用,这边缓存机制需要额外处理
|
|
33479
|
-
engine.clearResources();
|
|
33480
|
-
engine.addPackageDatas(scene);
|
|
33481
|
-
for(i = 0; i < scene.textureOptions.length; i++){
|
|
33482
|
-
scene.textureOptions[i] = engine.assetLoader.loadGUID(scene.textureOptions[i].id);
|
|
33483
|
-
scene.textureOptions[i].initialize();
|
|
33484
|
-
}
|
|
33485
|
-
if (!engine.database) return [
|
|
33486
|
-
3,
|
|
33487
|
-
3
|
|
33488
|
-
];
|
|
33489
|
-
return [
|
|
33490
|
-
4,
|
|
33491
|
-
engine.createVFXItems(scene)
|
|
33492
|
-
];
|
|
33493
|
-
case 2:
|
|
33494
|
-
_state.sent();
|
|
33495
|
-
_state.label = 3;
|
|
33496
|
-
case 3:
|
|
33497
|
-
composition = new ThreeComposition(_extends({}, opts, {
|
|
33498
|
-
width: _this.width,
|
|
33499
|
-
height: _this.height,
|
|
33500
|
-
renderer: _this.renderer,
|
|
33501
|
-
handleItemMessage: function(message) {
|
|
33502
|
-
_this.dispatchEvent({
|
|
33503
|
-
type: "message",
|
|
33504
|
-
message: message
|
|
33505
|
-
});
|
|
33506
|
-
}
|
|
33507
|
-
}), scene);
|
|
33508
|
-
composition.on("end", function() {
|
|
33509
|
-
_this.dispatchEvent({
|
|
33510
|
-
type: "end",
|
|
33511
|
-
composition: composition
|
|
33512
|
-
});
|
|
33513
|
-
});
|
|
33514
|
-
_this.renderer.engine.setOptions({
|
|
33515
|
-
threeCamera: _this.camera,
|
|
33516
|
-
threeGroup: _this,
|
|
33517
|
-
composition: composition
|
|
33518
|
-
});
|
|
33519
|
-
if (opts.autoplay) {
|
|
33520
|
-
composition.play();
|
|
33521
|
-
} else {
|
|
33522
|
-
composition.pause();
|
|
33523
|
-
}
|
|
33524
|
-
firstFrameTime = performance.now() - last + composition.statistic.loadTime;
|
|
33525
|
-
composition.statistic.firstFrameTime = firstFrameTime;
|
|
33526
|
-
logger.info("First frame: [" + composition.name + "]" + firstFrameTime.toFixed(4) + "ms.");
|
|
33527
|
-
_this.compositions.push(composition);
|
|
33528
|
-
return [
|
|
33529
|
-
2,
|
|
33530
|
-
composition
|
|
33531
|
-
];
|
|
33532
|
-
}
|
|
33533
|
-
});
|
|
33534
|
-
})();
|
|
33535
|
-
};
|
|
33536
33490
|
/**
|
|
33537
33491
|
*
|
|
33538
33492
|
* @param delta
|
|
@@ -33747,7 +33701,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33747
33701
|
*/ Mesh.create = function(engine, props) {
|
|
33748
33702
|
return new ThreeMesh(engine, props);
|
|
33749
33703
|
};
|
|
33750
|
-
var version = "2.3.0
|
|
33704
|
+
var version = "2.3.0";
|
|
33751
33705
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33752
33706
|
|
|
33753
33707
|
exports.AbstractPlugin = AbstractPlugin;
|