@galacean/engine 2.0.0-alpha.29 → 2.0.0-alpha.30
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/browser.js +657 -761
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/bundled.module.js +657 -761
- package/dist/bundled.module.js.map +1 -1
- package/dist/bundled.module.min.js +1 -1
- package/dist/bundled.module.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -28278,7 +28278,7 @@
|
|
|
28278
28278
|
BasicResources._maskReadOutsideRenderStates = null;
|
|
28279
28279
|
BasicResources._maskWriteIncrementRenderStates = null;
|
|
28280
28280
|
BasicResources._maskWriteDecrementRenderStates = null;
|
|
28281
|
-
function _is_native_reflect_construct
|
|
28281
|
+
function _is_native_reflect_construct() {
|
|
28282
28282
|
// Since Reflect.construct can't be properly polyfilled, some
|
|
28283
28283
|
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
|
28284
28284
|
// Those polyfills don't allow us to subclass built-ins, so we need to
|
|
@@ -28288,14 +28288,14 @@
|
|
|
28288
28288
|
// TypeError: this is not a Boolean object.
|
|
28289
28289
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
28290
28290
|
} catch (_) {}
|
|
28291
|
-
return (_is_native_reflect_construct
|
|
28291
|
+
return (_is_native_reflect_construct = function _is_native_reflect_construct() {
|
|
28292
28292
|
return !!result;
|
|
28293
28293
|
})();
|
|
28294
28294
|
}
|
|
28295
|
-
function _construct
|
|
28296
|
-
if (_is_native_reflect_construct
|
|
28295
|
+
function _construct(Parent, args, Class) {
|
|
28296
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
28297
28297
|
else {
|
|
28298
|
-
_construct
|
|
28298
|
+
_construct = function construct(Parent, args, Class) {
|
|
28299
28299
|
var a = [
|
|
28300
28300
|
null
|
|
28301
28301
|
];
|
|
@@ -28306,7 +28306,7 @@
|
|
|
28306
28306
|
return instance;
|
|
28307
28307
|
};
|
|
28308
28308
|
}
|
|
28309
|
-
return _construct
|
|
28309
|
+
return _construct.apply(null, arguments);
|
|
28310
28310
|
}
|
|
28311
28311
|
var ComponentCloner = /*#__PURE__*/ function() {
|
|
28312
28312
|
function ComponentCloner() {}
|
|
@@ -28359,7 +28359,7 @@
|
|
|
28359
28359
|
args[_key - 1] = arguments[_key];
|
|
28360
28360
|
}
|
|
28361
28361
|
ComponentsDependencies._addCheck(this, type);
|
|
28362
|
-
var component = _construct
|
|
28362
|
+
var component = _construct(type, [].concat([
|
|
28363
28363
|
this
|
|
28364
28364
|
], args));
|
|
28365
28365
|
this._components.push(component);
|
|
@@ -28518,7 +28518,7 @@
|
|
|
28518
28518
|
for(var i = 0, n = components.length; i < n; i++){
|
|
28519
28519
|
componentConstructors[i] = components[i].constructor;
|
|
28520
28520
|
}
|
|
28521
|
-
var cloneEntity = _construct
|
|
28521
|
+
var cloneEntity = _construct(Entity, [].concat([
|
|
28522
28522
|
this.engine,
|
|
28523
28523
|
this.name
|
|
28524
28524
|
], componentConstructors));
|
|
@@ -39766,30 +39766,48 @@
|
|
|
39766
39766
|
}
|
|
39767
39767
|
this._emitBySubBurst(middleTime, playTime, duration);
|
|
39768
39768
|
} else {
|
|
39769
|
-
|
|
39769
|
+
if (lastPlayTime < duration) {
|
|
39770
|
+
this._emitBySubBurst(lastPlayTime, Math.min(playTime, duration), duration);
|
|
39771
|
+
}
|
|
39770
39772
|
}
|
|
39771
39773
|
};
|
|
39772
39774
|
_proto._emitBySubBurst = function _emitBySubBurst(lastPlayTime, playTime, duration) {
|
|
39773
|
-
var generator =
|
|
39774
|
-
var rand = this._burstRand;
|
|
39775
|
-
var bursts = this.bursts;
|
|
39776
|
-
// Calculate the relative time of the burst
|
|
39775
|
+
var _this = this, generator = _this._generator, rand = _this._burstRand, bursts = _this.bursts;
|
|
39777
39776
|
var baseTime = Math.floor(lastPlayTime / duration) * duration;
|
|
39778
39777
|
var startTime = lastPlayTime % duration;
|
|
39779
39778
|
var endTime = startTime + (playTime - lastPlayTime);
|
|
39779
|
+
var pendingIndex = -1;
|
|
39780
39780
|
var index = this._currentBurstIndex;
|
|
39781
39781
|
for(var n = bursts.length; index < n; index++){
|
|
39782
39782
|
var burst = bursts[index];
|
|
39783
39783
|
var burstTime = burst.time;
|
|
39784
|
-
if (burstTime
|
|
39785
|
-
|
|
39786
|
-
|
|
39787
|
-
|
|
39788
|
-
|
|
39789
|
-
|
|
39784
|
+
if (burstTime >= endTime) break;
|
|
39785
|
+
var cycles = burst.cycles, repeatInterval = burst.repeatInterval;
|
|
39786
|
+
if (cycles === 1) {
|
|
39787
|
+
if (burstTime >= startTime) {
|
|
39788
|
+
generator._emit(baseTime + burstTime, burst.count.evaluate(undefined, rand.random()));
|
|
39789
|
+
}
|
|
39790
|
+
} else {
|
|
39791
|
+
var maxCycles = cycles === Infinity ? Math.ceil((duration - burstTime) / repeatInterval) : cycles;
|
|
39792
|
+
// Absorb float drift: (startTime - burstTime) / repeatInterval may land at cycle + 1e-15
|
|
39793
|
+
// when it should be exactly cycle, and ceil would then skip ahead to cycle + 1.
|
|
39794
|
+
var tolerance = MathUtil.zeroTolerance;
|
|
39795
|
+
var lastCycle = Math.ceil((endTime - burstTime) / repeatInterval - tolerance) - 1;
|
|
39796
|
+
var first = Math.max(0, Math.ceil((startTime - burstTime) / repeatInterval - tolerance));
|
|
39797
|
+
var last = Math.min(maxCycles - 1, lastCycle);
|
|
39798
|
+
for(var c = first; c <= last; c++){
|
|
39799
|
+
var effectiveTime = burstTime + c * repeatInterval;
|
|
39800
|
+
if (effectiveTime >= duration) break;
|
|
39801
|
+
generator._emit(baseTime + effectiveTime, burst.count.evaluate(undefined, rand.random()));
|
|
39802
|
+
}
|
|
39803
|
+
// `_currentBurstIndex` caches next frame's scan start, so only the earliest unfinished
|
|
39804
|
+
// burst can be the entry point — skipping past it would drop its remaining cycles
|
|
39805
|
+
if (pendingIndex < 0 && lastCycle < maxCycles - 1) {
|
|
39806
|
+
pendingIndex = index;
|
|
39807
|
+
}
|
|
39790
39808
|
}
|
|
39791
39809
|
}
|
|
39792
|
-
this._currentBurstIndex = index;
|
|
39810
|
+
this._currentBurstIndex = pendingIndex >= 0 ? pendingIndex : index;
|
|
39793
39811
|
};
|
|
39794
39812
|
_create_class$2(EmissionModule, [
|
|
39795
39813
|
{
|
|
@@ -42922,10 +42940,39 @@
|
|
|
42922
42940
|
}(EffectMaterial);
|
|
42923
42941
|
/**
|
|
42924
42942
|
* A burst is a particle emission event, where a number of particles are all emitted at the same time
|
|
42925
|
-
*/ var Burst = function
|
|
42926
|
-
|
|
42927
|
-
|
|
42928
|
-
|
|
42943
|
+
*/ var Burst = /*#__PURE__*/ function() {
|
|
42944
|
+
function Burst(time, count, cycles, repeatInterval) {
|
|
42945
|
+
this.time = time;
|
|
42946
|
+
this.count = count;
|
|
42947
|
+
this._cycles = Math.max(cycles != null ? cycles : 1, 1);
|
|
42948
|
+
this._repeatInterval = Math.max(repeatInterval != null ? repeatInterval : 0.01, 0.01);
|
|
42949
|
+
}
|
|
42950
|
+
_create_class$2(Burst, [
|
|
42951
|
+
{
|
|
42952
|
+
key: "cycles",
|
|
42953
|
+
get: /**
|
|
42954
|
+
* Number of times to repeat the burst.
|
|
42955
|
+
*/ function get() {
|
|
42956
|
+
return this._cycles;
|
|
42957
|
+
},
|
|
42958
|
+
set: function set(value) {
|
|
42959
|
+
this._cycles = Math.max(value, 1);
|
|
42960
|
+
}
|
|
42961
|
+
},
|
|
42962
|
+
{
|
|
42963
|
+
key: "repeatInterval",
|
|
42964
|
+
get: /**
|
|
42965
|
+
* Time interval between each repeated burst.
|
|
42966
|
+
*/ function get() {
|
|
42967
|
+
return this._repeatInterval;
|
|
42968
|
+
},
|
|
42969
|
+
set: function set(value) {
|
|
42970
|
+
this._repeatInterval = Math.max(value, 0.01);
|
|
42971
|
+
}
|
|
42972
|
+
}
|
|
42973
|
+
]);
|
|
42974
|
+
return Burst;
|
|
42975
|
+
}();
|
|
42929
42976
|
__decorate$1([
|
|
42930
42977
|
deepClone
|
|
42931
42978
|
], Burst.prototype, "count", void 0);
|
|
@@ -48301,35 +48348,23 @@
|
|
|
48301
48348
|
}
|
|
48302
48349
|
return array;
|
|
48303
48350
|
}
|
|
48304
|
-
function
|
|
48305
|
-
|
|
48306
|
-
|
|
48307
|
-
|
|
48308
|
-
|
|
48309
|
-
|
|
48310
|
-
|
|
48311
|
-
|
|
48312
|
-
|
|
48313
|
-
}
|
|
48314
|
-
return
|
|
48315
|
-
return !!result;
|
|
48316
|
-
})();
|
|
48351
|
+
function _object_without_properties_loose(source, excluded) {
|
|
48352
|
+
if (source == null) return {};
|
|
48353
|
+
var target = {};
|
|
48354
|
+
var sourceKeys = Object.keys(source);
|
|
48355
|
+
var key, i;
|
|
48356
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
48357
|
+
key = sourceKeys[i];
|
|
48358
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
48359
|
+
target[key] = source[key];
|
|
48360
|
+
}
|
|
48361
|
+
return target;
|
|
48317
48362
|
}
|
|
48318
|
-
function
|
|
48319
|
-
if (
|
|
48320
|
-
|
|
48321
|
-
_construct = function construct(Parent, args, Class) {
|
|
48322
|
-
var a = [
|
|
48323
|
-
null
|
|
48324
|
-
];
|
|
48325
|
-
a.push.apply(a, args);
|
|
48326
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
48327
|
-
var instance = new Constructor();
|
|
48328
|
-
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
48329
|
-
return instance;
|
|
48330
|
-
};
|
|
48363
|
+
function resolveRefItem(refs, index, owner, label) {
|
|
48364
|
+
if (!Number.isInteger(index) || index < 0 || index >= refs.length) {
|
|
48365
|
+
throw new Error(owner + ": invalid ref index " + index + " for " + label);
|
|
48331
48366
|
}
|
|
48332
|
-
return
|
|
48367
|
+
return refs[index];
|
|
48333
48368
|
}
|
|
48334
48369
|
var ParserType = /*#__PURE__*/ function(ParserType) {
|
|
48335
48370
|
ParserType[ParserType["Prefab"] = 0] = "Prefab";
|
|
@@ -48344,32 +48379,20 @@
|
|
|
48344
48379
|
this.engine = engine;
|
|
48345
48380
|
this.type = type;
|
|
48346
48381
|
this.resource = resource;
|
|
48347
|
-
this.
|
|
48348
|
-
this
|
|
48349
|
-
this.components = new Map();
|
|
48350
|
-
this.componentConfigMap = new Map();
|
|
48351
|
-
this.rootIds = [];
|
|
48352
|
-
this.strippedIds = [];
|
|
48353
|
-
this._tasks = new Set();
|
|
48382
|
+
this./** Runtime Entity instances, indexed by the flat entities[] position. */ entityInstances = [];
|
|
48383
|
+
this./** Components waiting for props/calls application (Stage 4). */ pendingComponents = [];
|
|
48354
48384
|
this._loaded = 0;
|
|
48355
48385
|
this._total = 0;
|
|
48356
48386
|
this.resourceManager = engine.resourceManager;
|
|
48357
48387
|
}
|
|
48358
48388
|
var _proto = ParserContext.prototype;
|
|
48359
48389
|
_proto.clear = function clear() {
|
|
48360
|
-
this.
|
|
48361
|
-
this.
|
|
48362
|
-
|
|
48363
|
-
|
|
48364
|
-
this.rootIds.length = 0;
|
|
48365
|
-
this.strippedIds.length = 0;
|
|
48366
|
-
};
|
|
48367
|
-
/** @internal */ _proto._addDependentAsset = function _addDependentAsset(url, promise) {
|
|
48390
|
+
this.entityInstances.length = 0;
|
|
48391
|
+
this.pendingComponents.length = 0;
|
|
48392
|
+
};
|
|
48393
|
+
/** @internal */ _proto._addDependentAsset = function _addDependentAsset(promise) {
|
|
48368
48394
|
var _this = this;
|
|
48369
|
-
var tasks = this._tasks;
|
|
48370
|
-
if (tasks.has(url)) return;
|
|
48371
48395
|
++this._total;
|
|
48372
|
-
tasks.add(url);
|
|
48373
48396
|
promise.finally(function() {
|
|
48374
48397
|
++_this._loaded;
|
|
48375
48398
|
_this._setTaskCompleteProgress(_this._loaded, _this._total);
|
|
@@ -48378,230 +48401,198 @@
|
|
|
48378
48401
|
return ParserContext;
|
|
48379
48402
|
}();
|
|
48380
48403
|
var ReflectionParser = /*#__PURE__*/ function() {
|
|
48381
|
-
function ReflectionParser(_context) {
|
|
48404
|
+
function ReflectionParser(_context, _refs) {
|
|
48382
48405
|
this._context = _context;
|
|
48406
|
+
this._refs = _refs;
|
|
48383
48407
|
}
|
|
48384
48408
|
var _proto = ReflectionParser.prototype;
|
|
48385
|
-
|
|
48386
|
-
|
|
48387
|
-
|
|
48388
|
-
|
|
48389
|
-
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : true;
|
|
48390
|
-
var transform = entity.transform;
|
|
48391
|
-
var transformConfig = entityConfig.transform;
|
|
48392
|
-
if (transformConfig) {
|
|
48393
|
-
_this.parsePropsAndMethods(transform, transformConfig);
|
|
48394
|
-
} else {
|
|
48395
|
-
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
48396
|
-
if (position) transform.position.copyFrom(position);
|
|
48397
|
-
if (rotation) transform.rotation.copyFrom(rotation);
|
|
48398
|
-
if (scale) transform.scale.copyFrom(scale);
|
|
48399
|
-
}
|
|
48400
|
-
var _entityConfig_layer;
|
|
48401
|
-
entity.layer = (_entityConfig_layer = entityConfig.layer) != null ? _entityConfig_layer : entity.layer;
|
|
48402
|
-
// @ts-ignore
|
|
48403
|
-
_this._context.type === ParserType.Prefab && entity._markAsTemplate(_this._context.resource);
|
|
48404
|
-
return entity;
|
|
48405
|
-
});
|
|
48406
|
-
};
|
|
48407
|
-
_proto.parseClassObject = function parseClassObject(item) {
|
|
48408
|
-
var _this = this;
|
|
48409
|
-
var Class = Loader.getClass(item.class);
|
|
48410
|
-
var _item_constructParams;
|
|
48411
|
-
var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
|
|
48412
|
-
return Promise.all(params.map(function(param) {
|
|
48413
|
-
return _this.parseBasicType(param);
|
|
48414
|
-
})).then(function(resultParams) {
|
|
48415
|
-
return _construct(Class, [].concat(resultParams));
|
|
48416
|
-
}).then(function(instance) {
|
|
48417
|
-
return _this.parsePropsAndMethods(instance, item);
|
|
48418
|
-
});
|
|
48419
|
-
};
|
|
48420
|
-
_proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
|
|
48409
|
+
/**
|
|
48410
|
+
* Apply v2 props to a component/object instance.
|
|
48411
|
+
* Each prop value is resolved recursively (handling $ref, $type, $entity, $component, $signal).
|
|
48412
|
+
*/ _proto.parseProps = function parseProps(instance, props) {
|
|
48421
48413
|
var promises = [];
|
|
48422
|
-
if (
|
|
48423
|
-
for(var methodName in item.methods){
|
|
48424
|
-
var methodParams = item.methods[methodName];
|
|
48425
|
-
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
48426
|
-
promises.push(this.parseMethod(instance, methodName, methodParams[i]));
|
|
48427
|
-
}
|
|
48428
|
-
}
|
|
48429
|
-
}
|
|
48430
|
-
if (item.props) {
|
|
48414
|
+
if (props) {
|
|
48431
48415
|
var _this, _loop = function _loop(key) {
|
|
48432
|
-
var
|
|
48433
|
-
|
|
48434
|
-
return instance[key] = v;
|
|
48416
|
+
var promise = _this._resolveValue(props[key], instance[key]).then(function(v) {
|
|
48417
|
+
instance[key] = v;
|
|
48435
48418
|
});
|
|
48436
48419
|
promises.push(promise);
|
|
48437
48420
|
};
|
|
48438
|
-
for(var key in
|
|
48421
|
+
for(var key in props)_this = this, _loop(key);
|
|
48439
48422
|
}
|
|
48440
48423
|
return Promise.all(promises).then(function() {
|
|
48441
48424
|
return instance;
|
|
48442
48425
|
});
|
|
48443
48426
|
};
|
|
48444
|
-
|
|
48427
|
+
/**
|
|
48428
|
+
* Execute calls sequentially on a target instance.
|
|
48429
|
+
* Call args are resolved with the same v2 value rules as props.
|
|
48430
|
+
*/ _proto.parseCalls = function parseCalls(instance, calls) {
|
|
48431
|
+
var _loop = function _loop(i, n) {
|
|
48432
|
+
var call = calls[i];
|
|
48433
|
+
chain = chain.then(function() {
|
|
48434
|
+
var method = instance == null ? void 0 : instance[call.method];
|
|
48435
|
+
if (typeof method !== "function") {
|
|
48436
|
+
return Promise.reject(new Error('Call target does not have method "' + call.method + '"'));
|
|
48437
|
+
}
|
|
48438
|
+
var _call_args;
|
|
48439
|
+
return Promise.all(((_call_args = call.args) != null ? _call_args : []).map(function(arg) {
|
|
48440
|
+
return _this._resolveValue(arg);
|
|
48441
|
+
})).then(function(resolvedArgs) {
|
|
48442
|
+
return Promise.resolve(method.apply(instance, resolvedArgs));
|
|
48443
|
+
}).then(function(result) {
|
|
48444
|
+
if (!call.result) return result;
|
|
48445
|
+
if (result == null || (typeof result === "undefined" ? "undefined" : _type_of1(result)) !== "object" && typeof result !== "function") {
|
|
48446
|
+
return Promise.reject(new Error('Call "' + call.method + '" returned ' + result + " and cannot be mutated by result"));
|
|
48447
|
+
}
|
|
48448
|
+
return _this.parseMutationBlock(result, call.result);
|
|
48449
|
+
});
|
|
48450
|
+
});
|
|
48451
|
+
};
|
|
48445
48452
|
var _this = this;
|
|
48446
|
-
|
|
48447
|
-
var
|
|
48448
|
-
|
|
48449
|
-
|
|
48450
|
-
|
|
48451
|
-
var _instance;
|
|
48452
|
-
var methodResult = (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
48453
|
-
if (isMethodObject && methodParams.result) {
|
|
48454
|
-
return _this.parsePropsAndMethods(methodResult, methodParams.result);
|
|
48455
|
-
} else {
|
|
48456
|
-
return methodResult;
|
|
48457
|
-
}
|
|
48453
|
+
if (!(calls == null ? void 0 : calls.length)) return Promise.resolve(instance);
|
|
48454
|
+
var chain = Promise.resolve();
|
|
48455
|
+
for(var i = 0, n = calls.length; i < n; i++)_loop(i);
|
|
48456
|
+
return chain.then(function() {
|
|
48457
|
+
return instance;
|
|
48458
48458
|
});
|
|
48459
48459
|
};
|
|
48460
|
-
|
|
48461
|
-
|
|
48462
|
-
|
|
48463
|
-
return Promise.
|
|
48464
|
-
|
|
48465
|
-
|
|
48466
|
-
|
|
48467
|
-
|
|
48468
|
-
|
|
48469
|
-
]).then(function(param) {
|
|
48470
|
-
var target = param[0], resolvedArgs = param[1];
|
|
48471
|
-
if (target) {
|
|
48472
|
-
var _signal;
|
|
48473
|
-
(_signal = signal).on.apply(_signal, [].concat([
|
|
48474
|
-
target,
|
|
48475
|
-
listener.methodName
|
|
48476
|
-
], resolvedArgs));
|
|
48477
|
-
}
|
|
48478
|
-
});
|
|
48479
|
-
})).then(function() {
|
|
48480
|
-
return signal;
|
|
48460
|
+
/**
|
|
48461
|
+
* Apply props and calls from the same mutation block without imposing ordering between them.
|
|
48462
|
+
*/ _proto.parseMutationBlock = function parseMutationBlock(target, block) {
|
|
48463
|
+
if (!block) return Promise.resolve(target);
|
|
48464
|
+
return Promise.all([
|
|
48465
|
+
this.parseProps(target, block.props),
|
|
48466
|
+
this.parseCalls(target, block.calls)
|
|
48467
|
+
]).then(function() {
|
|
48468
|
+
return target;
|
|
48481
48469
|
});
|
|
48482
48470
|
};
|
|
48483
|
-
|
|
48484
|
-
|
|
48485
|
-
|
|
48486
|
-
|
|
48487
|
-
|
|
48471
|
+
/**
|
|
48472
|
+
* Resolve a v2 value with $ prefix detection.
|
|
48473
|
+
*
|
|
48474
|
+
* Priority:
|
|
48475
|
+
* 1. null/undefined/primitive → passthrough
|
|
48476
|
+
* 2. Array → recurse each element
|
|
48477
|
+
* 3. { $ref } → asset reference
|
|
48478
|
+
* 4. { $type } → polymorphic type construct
|
|
48479
|
+
* 5. { $entity } → entity reference by path (flat index + optional children descent)
|
|
48480
|
+
* 6. { $component } → component reference
|
|
48481
|
+
* 7. { $signal } → signal binding
|
|
48482
|
+
* 8. plain object → recurse values (modify originValue in place if exists)
|
|
48483
|
+
*/ _proto._resolveValue = function _resolveValue(value, originValue) {
|
|
48484
|
+
var _this, _loop = function _loop(key) {
|
|
48485
|
+
promises.push(_this._resolveValue(obj[key], target[key]).then(function(v) {
|
|
48486
|
+
return target[key] = v;
|
|
48488
48487
|
}));
|
|
48489
|
-
}
|
|
48490
|
-
|
|
48491
|
-
|
|
48492
|
-
|
|
48493
|
-
|
|
48494
|
-
|
|
48495
|
-
|
|
48496
|
-
|
|
48497
|
-
|
|
48498
|
-
|
|
48499
|
-
|
|
48500
|
-
|
|
48501
|
-
|
|
48502
|
-
|
|
48503
|
-
|
|
48504
|
-
return resource;
|
|
48505
|
-
});
|
|
48506
|
-
} else if (ReflectionParser._isComponentRef(value)) {
|
|
48507
|
-
var entity = this._resolveEntityByPath(value.entityPath);
|
|
48508
|
-
if (!entity) return Promise.resolve(null);
|
|
48509
|
-
var type = Loader.getClass(value.componentType);
|
|
48510
|
-
if (!type) return Promise.resolve(null);
|
|
48511
|
-
var _entity_getComponents_value_componentIndex;
|
|
48512
|
-
return Promise.resolve((_entity_getComponents_value_componentIndex = entity.getComponents(type, [])[value.componentIndex]) != null ? _entity_getComponents_value_componentIndex : null);
|
|
48513
|
-
} else if (ReflectionParser._isEntityRef(value)) {
|
|
48514
|
-
return Promise.resolve(this._resolveEntityByPath(value.entityPath));
|
|
48515
|
-
} else if (ReflectionParser._isSignalRef(value)) {
|
|
48516
|
-
return this.parseSignal(value);
|
|
48517
|
-
} else if (originValue) {
|
|
48518
|
-
var _this2, _loop = function _loop(key) {
|
|
48519
|
-
if (key === "methods") {
|
|
48520
|
-
var methods = value[key];
|
|
48521
|
-
for(var methodName in methods){
|
|
48522
|
-
var methodParams = methods[methodName];
|
|
48523
|
-
for(var i = 0, count = methodParams.length; i < count; i++){
|
|
48524
|
-
var params = methodParams[i];
|
|
48525
|
-
var promise = _this2.parseMethod(originValue, methodName, params);
|
|
48526
|
-
promises.push(promise);
|
|
48527
|
-
}
|
|
48528
|
-
}
|
|
48529
|
-
} else {
|
|
48530
|
-
promises.push(_this2.parseBasicType(value[key], originValue[key]).then(function(v) {
|
|
48531
|
-
return originValue[key] = v;
|
|
48532
|
-
}));
|
|
48533
|
-
}
|
|
48534
|
-
};
|
|
48535
|
-
var promises = [];
|
|
48536
|
-
for(var key in value)_this2 = this, _loop(key);
|
|
48537
|
-
return Promise.all(promises).then(function() {
|
|
48538
|
-
return originValue;
|
|
48539
|
-
});
|
|
48488
|
+
};
|
|
48489
|
+
var _this1 = this;
|
|
48490
|
+
if (value == null || (typeof value === "undefined" ? "undefined" : _type_of1(value)) !== "object") return Promise.resolve(value);
|
|
48491
|
+
if (Array.isArray(value)) return Promise.all(value.map(function(v) {
|
|
48492
|
+
return _this1._resolveValue(v);
|
|
48493
|
+
}));
|
|
48494
|
+
var obj = value;
|
|
48495
|
+
// $ref — asset reference (index into refs array)
|
|
48496
|
+
if ("$ref" in obj) {
|
|
48497
|
+
var _this2 = this, context = _this2._context;
|
|
48498
|
+
var refItem;
|
|
48499
|
+
try {
|
|
48500
|
+
refItem = resolveRefItem(this._refs, obj.$ref, "ReflectionParser", "$ref");
|
|
48501
|
+
} catch (error) {
|
|
48502
|
+
return Promise.reject(error);
|
|
48540
48503
|
}
|
|
48541
|
-
|
|
48542
|
-
|
|
48543
|
-
|
|
48544
|
-
};
|
|
48545
|
-
_proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
|
|
48546
|
-
var _this = this;
|
|
48547
|
-
// @ts-ignore
|
|
48548
|
-
var assetUrl = entityConfig.assetUrl;
|
|
48549
|
-
var engine = this._context.engine;
|
|
48550
|
-
if (assetUrl) {
|
|
48551
|
-
return engine.resourceManager // @ts-ignore
|
|
48552
|
-
.getResourceByRef({
|
|
48553
|
-
url: assetUrl,
|
|
48554
|
-
key: entityConfig.key,
|
|
48555
|
-
isClone: entityConfig.isClone
|
|
48556
|
-
}).then(function(entity) {
|
|
48557
|
-
// @ts-ignore
|
|
48558
|
-
var resource = engine.resourceManager._objectPool[assetUrl];
|
|
48559
|
-
if (resource && _this._context.type === ParserType.Prefab) {
|
|
48504
|
+
// @ts-ignore
|
|
48505
|
+
return context.resourceManager.getResourceByRef(refItem).then(function(resource) {
|
|
48506
|
+
if (resource && context.type === ParserType.Prefab) {
|
|
48560
48507
|
// @ts-ignore
|
|
48561
|
-
|
|
48508
|
+
context.resource._addDependenceAsset(resource);
|
|
48562
48509
|
}
|
|
48563
|
-
|
|
48564
|
-
return entity;
|
|
48510
|
+
return resource;
|
|
48565
48511
|
});
|
|
48566
|
-
} else {
|
|
48567
|
-
var transform = entityConfig.transform;
|
|
48568
|
-
var entity = new Entity(engine, entityConfig.name, transform ? Loader.getClass(transform.class) : Transform);
|
|
48569
|
-
return Promise.resolve(entity);
|
|
48570
48512
|
}
|
|
48571
|
-
|
|
48572
|
-
|
|
48573
|
-
|
|
48574
|
-
|
|
48575
|
-
|
|
48576
|
-
|
|
48577
|
-
|
|
48578
|
-
|
|
48513
|
+
// $type — polymorphic type: construct instance and apply remaining props
|
|
48514
|
+
if ("$type" in obj) {
|
|
48515
|
+
var $type = obj.$type, rest = _object_without_properties_loose(obj, [
|
|
48516
|
+
"$type"
|
|
48517
|
+
]);
|
|
48518
|
+
var typeName = $type;
|
|
48519
|
+
var Class = Loader.getClass(typeName);
|
|
48520
|
+
if (!Class) return Promise.reject(new Error('Loader.getClass: class "' + typeName + '" is not registered'));
|
|
48521
|
+
var instance = new Class();
|
|
48522
|
+
if (Object.keys(rest).length > 0) {
|
|
48523
|
+
return this.parseProps(instance, rest);
|
|
48524
|
+
}
|
|
48525
|
+
return Promise.resolve(instance);
|
|
48579
48526
|
}
|
|
48580
|
-
|
|
48581
|
-
|
|
48582
|
-
|
|
48583
|
-
|
|
48584
|
-
|
|
48585
|
-
|
|
48586
|
-
|
|
48587
|
-
|
|
48588
|
-
|
|
48589
|
-
|
|
48590
|
-
|
|
48591
|
-
|
|
48592
|
-
|
|
48527
|
+
// $entity — entity reference by path (first element = flat index, subsequent = children indices)
|
|
48528
|
+
if ("$entity" in obj) {
|
|
48529
|
+
return Promise.resolve(this._resolveEntityRef(obj.$entity));
|
|
48530
|
+
}
|
|
48531
|
+
// $component — component reference: { entity, type, index }
|
|
48532
|
+
if ("$component" in obj) {
|
|
48533
|
+
return Promise.resolve(this._resolveComponent(obj.$component));
|
|
48534
|
+
}
|
|
48535
|
+
// $signal — signal binding: register listeners on the existing Signal instance
|
|
48536
|
+
if ("$signal" in obj) {
|
|
48537
|
+
return this._resolveSignal(originValue, obj.$signal);
|
|
48538
|
+
}
|
|
48539
|
+
// Plain object — recurse each value, modifying originValue in place or building a new object
|
|
48540
|
+
var target = originValue && (typeof originValue === "undefined" ? "undefined" : _type_of1(originValue)) === "object" && !Array.isArray(originValue) ? originValue : {};
|
|
48541
|
+
var promises = [];
|
|
48542
|
+
for(var key in obj)_this = this, _loop(key);
|
|
48543
|
+
return Promise.all(promises).then(function() {
|
|
48544
|
+
return target;
|
|
48545
|
+
});
|
|
48593
48546
|
};
|
|
48594
|
-
|
|
48595
|
-
|
|
48547
|
+
_proto._resolveSignal = function _resolveSignal(signal, listeners) {
|
|
48548
|
+
var _this = this;
|
|
48549
|
+
if (!signal || typeof signal.on !== "function") {
|
|
48550
|
+
return Promise.reject(new Error("$signal requires a pre-initialized Signal instance on the target property"));
|
|
48551
|
+
}
|
|
48552
|
+
var promises = listeners.map(function(listener) {
|
|
48553
|
+
var targetComponent = _this._resolveComponent(listener.target.$component);
|
|
48554
|
+
if (!targetComponent) return Promise.resolve();
|
|
48555
|
+
var _listener_args;
|
|
48556
|
+
return Promise.all(((_listener_args = listener.args) != null ? _listener_args : []).map(function(a) {
|
|
48557
|
+
return _this._resolveValue(a);
|
|
48558
|
+
})).then(function(resolvedArgs) {
|
|
48559
|
+
var _signal;
|
|
48560
|
+
(_signal = signal).on.apply(_signal, [].concat([
|
|
48561
|
+
targetComponent,
|
|
48562
|
+
listener.methodName
|
|
48563
|
+
], resolvedArgs));
|
|
48564
|
+
});
|
|
48565
|
+
});
|
|
48566
|
+
return Promise.all(promises).then(function() {
|
|
48567
|
+
return signal;
|
|
48568
|
+
});
|
|
48596
48569
|
};
|
|
48597
|
-
|
|
48598
|
-
|
|
48570
|
+
_proto._resolveComponent = function _resolveComponent(comp) {
|
|
48571
|
+
var entity = this._resolveEntityRef(comp.entity);
|
|
48572
|
+
if (!entity) return null;
|
|
48573
|
+
var type = Loader.getClass(comp.type);
|
|
48574
|
+
if (!type) return null;
|
|
48575
|
+
var buffer = ReflectionParser._componentBuffer;
|
|
48576
|
+
buffer.length = 0;
|
|
48577
|
+
entity.getComponents(type, buffer);
|
|
48578
|
+
var _buffer_comp_index;
|
|
48579
|
+
var result = (_buffer_comp_index = buffer[comp.index]) != null ? _buffer_comp_index : null;
|
|
48580
|
+
buffer.length = 0;
|
|
48581
|
+
return result;
|
|
48599
48582
|
};
|
|
48600
|
-
|
|
48601
|
-
|
|
48583
|
+
_proto._resolveEntityRef = function _resolveEntityRef(path) {
|
|
48584
|
+
if (!path || path.length === 0) return null;
|
|
48585
|
+
var _this__context_entityInstances_path_;
|
|
48586
|
+
var entity = (_this__context_entityInstances_path_ = this._context.entityInstances[path[0]]) != null ? _this__context_entityInstances_path_ : null;
|
|
48587
|
+
for(var i = 1, n = path.length; entity && i < n; i++){
|
|
48588
|
+
var _entity_children_path_i;
|
|
48589
|
+
entity = (_entity_children_path_i = entity.children[path[i]]) != null ? _entity_children_path_i : null;
|
|
48590
|
+
}
|
|
48591
|
+
return entity;
|
|
48602
48592
|
};
|
|
48603
48593
|
return ReflectionParser;
|
|
48604
48594
|
}();
|
|
48595
|
+
/** @internal shared with HierarchyParser; each use must length=0 -> getComponents -> read -> length=0 synchronously. */ ReflectionParser._componentBuffer = [];
|
|
48605
48596
|
/**
|
|
48606
48597
|
* HDR (Radiance RGBE) image decoder.
|
|
48607
48598
|
*
|
|
@@ -48898,38 +48889,6 @@
|
|
|
48898
48889
|
return !!right[Symbol.hasInstance](left);
|
|
48899
48890
|
} else return _instanceof(left, right);
|
|
48900
48891
|
}
|
|
48901
|
-
function _array_like_to_array(arr, len) {
|
|
48902
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
48903
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
48904
|
-
return arr2;
|
|
48905
|
-
}
|
|
48906
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
48907
|
-
if (!o) return;
|
|
48908
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
48909
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
48910
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
48911
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
48912
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
48913
|
-
}
|
|
48914
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
48915
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
48916
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
48917
|
-
// Fallback for engines without symbol support
|
|
48918
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
48919
|
-
if (it) o = it;
|
|
48920
|
-
var i = 0;
|
|
48921
|
-
return function() {
|
|
48922
|
-
if (i >= o.length) return {
|
|
48923
|
-
done: true
|
|
48924
|
-
};
|
|
48925
|
-
return {
|
|
48926
|
-
done: false,
|
|
48927
|
-
value: o[i++]
|
|
48928
|
-
};
|
|
48929
|
-
};
|
|
48930
|
-
}
|
|
48931
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48932
|
-
}
|
|
48933
48892
|
/**
|
|
48934
48893
|
* The Prefab resource.
|
|
48935
48894
|
*/ var PrefabResource = /*#__PURE__*/ function(ReferResource1) {
|
|
@@ -48961,8 +48920,9 @@
|
|
|
48961
48920
|
};
|
|
48962
48921
|
_proto._onDestroy = function _onDestroy() {
|
|
48963
48922
|
var _this = this;
|
|
48923
|
+
var _this__root;
|
|
48964
48924
|
ReferResource1.prototype._onDestroy.call(this);
|
|
48965
|
-
this._root.destroy();
|
|
48925
|
+
(_this__root = this._root) == null ? void 0 : _this__root.destroy();
|
|
48966
48926
|
this._dependenceAssets.forEach(function(asset) {
|
|
48967
48927
|
if (_instanceof1(asset, ReferResource)) {
|
|
48968
48928
|
// @ts-ignore
|
|
@@ -48977,316 +48937,259 @@
|
|
|
48977
48937
|
var _this = this;
|
|
48978
48938
|
this.data = data;
|
|
48979
48939
|
this.context = context;
|
|
48980
|
-
|
|
48981
|
-
|
|
48940
|
+
if (data.version !== "2.0") {
|
|
48941
|
+
var resourceType = context.type === ParserType.Scene ? "scene" : "prefab";
|
|
48942
|
+
throw new Error("Unsupported " + resourceType + ' format version "' + data.version + '". Expected "2.0".');
|
|
48943
|
+
}
|
|
48982
48944
|
this._engine = this.context.engine;
|
|
48983
|
-
this._organizeEntities = this._organizeEntities.bind(this);
|
|
48984
|
-
this._parseComponents = this._parseComponents.bind(this);
|
|
48985
|
-
this._parsePrefabModification = this._parsePrefabModification.bind(this);
|
|
48986
|
-
this._parseAddedComponents = this._parseAddedComponents.bind(this);
|
|
48987
|
-
this._parseComponentsPropsAndMethods = this._parseComponentsPropsAndMethods.bind(this);
|
|
48988
|
-
this._parsePrefabRemovedEntities = this._parsePrefabRemovedEntities.bind(this);
|
|
48989
|
-
this._parsePrefabRemovedComponents = this._parsePrefabRemovedComponents.bind(this);
|
|
48990
|
-
this._clearAndResolve = this._clearAndResolve.bind(this);
|
|
48991
48945
|
this.promise = new Promise(function(resolve, reject) {
|
|
48992
48946
|
_this._reject = reject;
|
|
48993
48947
|
_this._resolve = resolve;
|
|
48994
48948
|
});
|
|
48995
|
-
this._reflectionParser = new ReflectionParser(context);
|
|
48949
|
+
this._reflectionParser = new ReflectionParser(context, data.refs);
|
|
48996
48950
|
}
|
|
48997
48951
|
var _proto = HierarchyParser.prototype;
|
|
48998
|
-
|
|
48999
|
-
this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parseAddedComponents).then(this._parseComponentsPropsAndMethods).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject);
|
|
49000
|
-
};
|
|
49001
|
-
_proto._applyEntityData = function _applyEntityData(entity, entityConfig) {
|
|
49002
|
-
if (entityConfig === void 0) entityConfig = {};
|
|
49003
|
-
var _entityConfig_isActive;
|
|
49004
|
-
entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
|
|
49005
|
-
var _entityConfig_name;
|
|
49006
|
-
entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
|
|
49007
|
-
var transform = entity.transform;
|
|
49008
|
-
var transformConfig = entityConfig.transform;
|
|
49009
|
-
if (transformConfig) {
|
|
49010
|
-
this._reflectionParser.parsePropsAndMethods(transform, transformConfig);
|
|
49011
|
-
} else {
|
|
49012
|
-
var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
|
|
49013
|
-
if (position) transform.position.copyFrom(position);
|
|
49014
|
-
if (rotation) transform.rotation.copyFrom(rotation);
|
|
49015
|
-
if (scale) transform.scale.copyFrom(scale);
|
|
49016
|
-
}
|
|
49017
|
-
if (entityConfig.layer) entity.layer = entityConfig.layer;
|
|
49018
|
-
return entity;
|
|
49019
|
-
};
|
|
49020
|
-
_proto._parseEntities = function _parseEntities() {
|
|
48952
|
+
_proto.start = function start() {
|
|
49021
48953
|
var _this = this;
|
|
49022
|
-
|
|
49023
|
-
|
|
49024
|
-
|
|
49025
|
-
|
|
49026
|
-
|
|
49027
|
-
|
|
49028
|
-
|
|
49029
|
-
|
|
49030
|
-
|
|
49031
|
-
return _this.
|
|
49032
|
-
});
|
|
49033
|
-
|
|
49034
|
-
|
|
49035
|
-
|
|
49036
|
-
|
|
49037
|
-
|
|
49038
|
-
|
|
49039
|
-
|
|
49040
|
-
|
|
49041
|
-
|
|
49042
|
-
|
|
49043
|
-
|
|
49044
|
-
|
|
49045
|
-
|
|
49046
|
-
|
|
49047
|
-
|
|
49048
|
-
|
|
49049
|
-
|
|
49050
|
-
for(var i = 0, l = entitiesConfig.length; i < l; i++){
|
|
49051
|
-
var entityConfig = entitiesConfig[i];
|
|
49052
|
-
if (entityConfig.strippedId) {
|
|
49053
|
-
continue;
|
|
49054
|
-
}
|
|
49055
|
-
var entity = entityMap.get(entityConfig.id);
|
|
49056
|
-
this._addComponents(entity, entityConfig.components);
|
|
49057
|
-
}
|
|
49058
|
-
};
|
|
49059
|
-
_proto._parsePrefabModification = function _parsePrefabModification() {
|
|
49060
|
-
var _loop = function _loop(i, l) {
|
|
49061
|
-
var entityConfig = entitiesConfig[i];
|
|
49062
|
-
var id = entityConfig.id, modifications = entityConfig.modifications;
|
|
49063
|
-
if (modifications == null ? void 0 : modifications.length) {
|
|
49064
|
-
var _promises;
|
|
49065
|
-
var rootEntity = entityMap.get(id);
|
|
49066
|
-
(_promises = promises).push.apply(_promises, [].concat(modifications.map(function(modification) {
|
|
49067
|
-
var target = modification.target, props = modification.props, methods = modification.methods;
|
|
49068
|
-
var entityId = target.entityId, componentId = target.componentId;
|
|
49069
|
-
var context = _this._prefabContextMap.get(rootEntity);
|
|
49070
|
-
var targetEntity = context.entityMap.get(entityId);
|
|
49071
|
-
var targetComponent = context.components.get(componentId);
|
|
49072
|
-
if (targetComponent) {
|
|
49073
|
-
return _this._reflectionParser.parsePropsAndMethods(targetComponent, {
|
|
49074
|
-
props: props,
|
|
49075
|
-
methods: methods
|
|
49076
|
-
});
|
|
49077
|
-
} else if (targetEntity) {
|
|
49078
|
-
return Promise.resolve(_this._applyEntityData(targetEntity, props));
|
|
49079
|
-
}
|
|
49080
|
-
})));
|
|
48954
|
+
this._parseEntities().then(function() {
|
|
48955
|
+
return _this._organizeEntities();
|
|
48956
|
+
}).then(function() {
|
|
48957
|
+
return _this._parseComponents();
|
|
48958
|
+
}).then(function() {
|
|
48959
|
+
return _this._parseComponentsPropsAndCalls();
|
|
48960
|
+
}).then(function() {
|
|
48961
|
+
return _this._parsePrefabOverrides();
|
|
48962
|
+
}).then(function() {
|
|
48963
|
+
return _this._clearAndResolve();
|
|
48964
|
+
}).then(this._resolve).catch(this._reject);
|
|
48965
|
+
};
|
|
48966
|
+
_proto._onEntityCreated = function _onEntityCreated(_entity) {};
|
|
48967
|
+
// ---------------------------------------------------------------------------
|
|
48968
|
+
// Stage 1: Create entity instances
|
|
48969
|
+
// ---------------------------------------------------------------------------
|
|
48970
|
+
_proto._parseEntities = function _parseEntities() {
|
|
48971
|
+
var _this, _loop = function _loop(i, n) {
|
|
48972
|
+
var entityConfig = entities[i];
|
|
48973
|
+
if (HierarchyParser._isPrefabInstanceEntity(entityConfig)) {
|
|
48974
|
+
promises.push(_this._loadPrefabInstance(entityConfig, engine).then(function(entity) {
|
|
48975
|
+
entityInstances[i] = entity;
|
|
48976
|
+
}));
|
|
48977
|
+
} else {
|
|
48978
|
+
var entity = new Entity(engine, entityConfig.name);
|
|
48979
|
+
HierarchyParser._applyEntityProps(entity, entityConfig);
|
|
48980
|
+
_this._onEntityCreated(entity);
|
|
48981
|
+
entityInstances[i] = entity;
|
|
49081
48982
|
}
|
|
49082
48983
|
};
|
|
49083
|
-
var
|
|
49084
|
-
var
|
|
49085
|
-
var
|
|
48984
|
+
var entities = this.data.entities;
|
|
48985
|
+
var entityInstances = this.context.entityInstances;
|
|
48986
|
+
var engine = this._engine;
|
|
49086
48987
|
var promises = [];
|
|
49087
|
-
for(var i = 0,
|
|
48988
|
+
for(var i = 0, n = entities.length; i < n; i++)_this = this, _loop(i);
|
|
49088
48989
|
return Promise.all(promises);
|
|
49089
48990
|
};
|
|
49090
|
-
|
|
49091
|
-
|
|
49092
|
-
|
|
49093
|
-
|
|
49094
|
-
|
|
49095
|
-
|
|
49096
|
-
|
|
49097
|
-
var
|
|
49098
|
-
|
|
49099
|
-
|
|
49100
|
-
|
|
49101
|
-
|
|
49102
|
-
|
|
49103
|
-
|
|
49104
|
-
|
|
49105
|
-
var entityConfig = entitiesConfig[i];
|
|
49106
|
-
var id = entityConfig.id, removedEntities = entityConfig.removedEntities;
|
|
49107
|
-
if (removedEntities == null ? void 0 : removedEntities.length) {
|
|
49108
|
-
var rootEntity = entityMap.get(id);
|
|
49109
|
-
for(var j = 0, m = removedEntities.length; j < m; j++){
|
|
49110
|
-
var target = removedEntities[j];
|
|
49111
|
-
var entityId = target.entityId;
|
|
49112
|
-
var context = this._prefabContextMap.get(rootEntity);
|
|
49113
|
-
var targetEntity = context.entityMap.get(entityId);
|
|
49114
|
-
if (targetEntity) {
|
|
49115
|
-
targetEntity.destroy();
|
|
49116
|
-
}
|
|
49117
|
-
}
|
|
48991
|
+
// ---------------------------------------------------------------------------
|
|
48992
|
+
// Stage 2: Build parent-child hierarchy
|
|
48993
|
+
// ---------------------------------------------------------------------------
|
|
48994
|
+
_proto._organizeEntities = function _organizeEntities() {
|
|
48995
|
+
var entities = this.data.entities;
|
|
48996
|
+
var entityInstances = this.context.entityInstances;
|
|
48997
|
+
for(var i = 0, n = entities.length; i < n; i++){
|
|
48998
|
+
var entityConfig = entities[i];
|
|
48999
|
+
// Prefab instance entities manage their own children.
|
|
49000
|
+
if (HierarchyParser._isPrefabInstanceEntity(entityConfig)) continue;
|
|
49001
|
+
var children = entityConfig.children;
|
|
49002
|
+
if (!children) continue;
|
|
49003
|
+
var parent = entityInstances[i];
|
|
49004
|
+
for(var j = 0, m = children.length; j < m; j++){
|
|
49005
|
+
parent.addChild(entityInstances[children[j]]);
|
|
49118
49006
|
}
|
|
49119
49007
|
}
|
|
49008
|
+
var rootIndices = this._getRootIndices();
|
|
49009
|
+
for(var i1 = 0, n1 = rootIndices.length; i1 < n1; i1++){
|
|
49010
|
+
this._handleRootEntity(rootIndices[i1]);
|
|
49011
|
+
}
|
|
49120
49012
|
};
|
|
49121
|
-
|
|
49122
|
-
|
|
49123
|
-
|
|
49124
|
-
|
|
49125
|
-
|
|
49126
|
-
|
|
49127
|
-
|
|
49128
|
-
|
|
49129
|
-
|
|
49130
|
-
|
|
49131
|
-
|
|
49132
|
-
|
|
49133
|
-
|
|
49134
|
-
|
|
49135
|
-
|
|
49136
|
-
|
|
49137
|
-
|
|
49138
|
-
|
|
49013
|
+
// ---------------------------------------------------------------------------
|
|
49014
|
+
// Stage 3: Add components to entities
|
|
49015
|
+
// ---------------------------------------------------------------------------
|
|
49016
|
+
_proto._parseComponents = function _parseComponents() {
|
|
49017
|
+
var entities = this.data.entities;
|
|
49018
|
+
var allComponents = this.data.components;
|
|
49019
|
+
var entityInstances = this.context.entityInstances;
|
|
49020
|
+
var pendingComponents = this.context.pendingComponents;
|
|
49021
|
+
var refs = this.data.refs;
|
|
49022
|
+
for(var i = 0, n = entities.length; i < n; i++){
|
|
49023
|
+
var entityConfig = entities[i];
|
|
49024
|
+
if (HierarchyParser._isPrefabInstanceEntity(entityConfig)) continue;
|
|
49025
|
+
var entity = entityInstances[i];
|
|
49026
|
+
var componentIndices = entityConfig.components;
|
|
49027
|
+
if (!componentIndices) continue;
|
|
49028
|
+
for(var j = 0, m = componentIndices.length; j < m; j++){
|
|
49029
|
+
var config = allComponents[componentIndices[j]];
|
|
49030
|
+
var instance = HierarchyParser._addComponentFromConfig(entity, config, refs);
|
|
49031
|
+
pendingComponents.push({
|
|
49032
|
+
instance: instance,
|
|
49033
|
+
config: config
|
|
49034
|
+
});
|
|
49139
49035
|
}
|
|
49140
49036
|
}
|
|
49141
49037
|
};
|
|
49142
|
-
|
|
49143
|
-
|
|
49144
|
-
|
|
49145
|
-
|
|
49146
|
-
|
|
49147
|
-
|
|
49148
|
-
|
|
49149
|
-
|
|
49038
|
+
// ---------------------------------------------------------------------------
|
|
49039
|
+
// Stage 4: Apply props and execute calls on components
|
|
49040
|
+
// ---------------------------------------------------------------------------
|
|
49041
|
+
_proto._parseComponentsPropsAndCalls = function _parseComponentsPropsAndCalls() {
|
|
49042
|
+
var pendingComponents = this.context.pendingComponents;
|
|
49043
|
+
var reflectionParser = this._reflectionParser;
|
|
49044
|
+
var promises = [];
|
|
49045
|
+
for(var i = 0, n = pendingComponents.length; i < n; i++){
|
|
49046
|
+
var _pendingComponents_i = pendingComponents[i], instance = _pendingComponents_i.instance, config = _pendingComponents_i.config;
|
|
49047
|
+
promises.push(reflectionParser.parseMutationBlock(instance, config));
|
|
49150
49048
|
}
|
|
49049
|
+
return Promise.all(promises);
|
|
49151
49050
|
};
|
|
49152
|
-
|
|
49153
|
-
|
|
49154
|
-
|
|
49155
|
-
|
|
49156
|
-
|
|
49157
|
-
|
|
49158
|
-
|
|
49159
|
-
|
|
49160
|
-
|
|
49051
|
+
// ---------------------------------------------------------------------------
|
|
49052
|
+
// Stage 5: Apply prefab instance overrides
|
|
49053
|
+
// ---------------------------------------------------------------------------
|
|
49054
|
+
_proto._parsePrefabOverrides = function _parsePrefabOverrides() {
|
|
49055
|
+
var entities = this.data.entities;
|
|
49056
|
+
var entityInstances = this.context.entityInstances;
|
|
49057
|
+
var promises = [];
|
|
49058
|
+
for(var i = 0, n = entities.length; i < n; i++){
|
|
49059
|
+
var entityConfig = entities[i];
|
|
49060
|
+
if (!HierarchyParser._isPrefabInstanceEntity(entityConfig)) continue;
|
|
49061
|
+
var overrides = entityConfig.instance.overrides;
|
|
49062
|
+
if (!overrides) continue;
|
|
49063
|
+
this._applyOverrides(entityInstances[i], overrides, promises);
|
|
49161
49064
|
}
|
|
49162
|
-
return
|
|
49163
|
-
return _this._applyEntityData(entity, entityConfig);
|
|
49164
|
-
});
|
|
49065
|
+
return Promise.all(promises);
|
|
49165
49066
|
};
|
|
49166
|
-
_proto.
|
|
49167
|
-
var
|
|
49168
|
-
var
|
|
49169
|
-
|
|
49170
|
-
|
|
49067
|
+
_proto._applyOverrides = function _applyOverrides(rootEntity, overrides, promises) {
|
|
49068
|
+
var refs = this.data.refs;
|
|
49069
|
+
var reflectionParser = this._reflectionParser;
|
|
49070
|
+
// entityProps — entity-level property overrides
|
|
49071
|
+
if (overrides.entityProps) {
|
|
49072
|
+
for(var j = 0, m = overrides.entityProps.length; j < m; j++){
|
|
49073
|
+
var override = overrides.entityProps[j];
|
|
49074
|
+
HierarchyParser._applyEntityProps(HierarchyParser._resolveEntity(rootEntity, override.path), override);
|
|
49075
|
+
}
|
|
49076
|
+
}
|
|
49077
|
+
// componentProps — component-level property overrides
|
|
49078
|
+
if (overrides.componentProps) {
|
|
49079
|
+
for(var j1 = 0, m1 = overrides.componentProps.length; j1 < m1; j1++){
|
|
49080
|
+
var override1 = overrides.componentProps[j1];
|
|
49081
|
+
var entity = HierarchyParser._resolveEntity(rootEntity, override1.path);
|
|
49082
|
+
var target = HierarchyParser._resolveComponent(entity, override1.selector);
|
|
49083
|
+
promises.push(reflectionParser.parseMutationBlock(target, override1));
|
|
49084
|
+
}
|
|
49085
|
+
}
|
|
49086
|
+
// addedComponents — attach top-level components[index] to a prefab entity and parse props
|
|
49087
|
+
if (overrides.addedComponents) {
|
|
49088
|
+
var allComponents = this.data.components;
|
|
49089
|
+
for(var j2 = 0, m2 = overrides.addedComponents.length; j2 < m2; j2++){
|
|
49090
|
+
var added = overrides.addedComponents[j2];
|
|
49091
|
+
var entity1 = HierarchyParser._resolveEntity(rootEntity, added.target);
|
|
49092
|
+
var config = allComponents[added.component];
|
|
49093
|
+
var component = HierarchyParser._addComponentFromConfig(entity1, config, refs);
|
|
49094
|
+
promises.push(reflectionParser.parseMutationBlock(component, config));
|
|
49095
|
+
}
|
|
49096
|
+
}
|
|
49097
|
+
// addedEntities — attach already-created top-level entityInstances[index] as a child
|
|
49098
|
+
if (overrides.addedEntities) {
|
|
49099
|
+
var entityInstances = this.context.entityInstances;
|
|
49100
|
+
for(var j3 = 0, m3 = overrides.addedEntities.length; j3 < m3; j3++){
|
|
49101
|
+
var added1 = overrides.addedEntities[j3];
|
|
49102
|
+
var parent = HierarchyParser._resolveEntity(rootEntity, added1.parent);
|
|
49103
|
+
parent.addChild(entityInstances[added1.entity]);
|
|
49104
|
+
}
|
|
49105
|
+
}
|
|
49106
|
+
// removedEntities — pre-resolve all targets then destroy (destroy shifts sibling indices)
|
|
49107
|
+
if (overrides.removedEntities) {
|
|
49108
|
+
var removed = overrides.removedEntities;
|
|
49109
|
+
var targets = new Array(removed.length);
|
|
49110
|
+
for(var j4 = 0, m4 = removed.length; j4 < m4; j4++){
|
|
49111
|
+
targets[j4] = HierarchyParser._resolveEntity(rootEntity, removed[j4]);
|
|
49112
|
+
}
|
|
49113
|
+
for(var j5 = 0, m5 = targets.length; j5 < m5; j5++){
|
|
49114
|
+
targets[j5].destroy();
|
|
49115
|
+
}
|
|
49116
|
+
}
|
|
49117
|
+
// removedComponents — pre-resolve all targets then destroy (destroy shifts component indices)
|
|
49118
|
+
if (overrides.removedComponents) {
|
|
49119
|
+
var targets1 = [];
|
|
49120
|
+
for(var j6 = 0, m6 = overrides.removedComponents.length; j6 < m6; j6++){
|
|
49121
|
+
var override2 = overrides.removedComponents[j6];
|
|
49122
|
+
var entity2 = HierarchyParser._resolveEntity(rootEntity, override2.path);
|
|
49123
|
+
var selectors = override2.selectors;
|
|
49124
|
+
for(var k = 0, p = selectors.length; k < p; k++){
|
|
49125
|
+
targets1.push(HierarchyParser._resolveComponent(entity2, selectors[k]));
|
|
49126
|
+
}
|
|
49127
|
+
}
|
|
49128
|
+
for(var j7 = 0, m7 = targets1.length; j7 < m7; j7++){
|
|
49129
|
+
targets1[j7].destroy();
|
|
49130
|
+
}
|
|
49131
|
+
}
|
|
49171
49132
|
};
|
|
49172
|
-
|
|
49133
|
+
// ---------------------------------------------------------------------------
|
|
49134
|
+
// Prefab instance loading
|
|
49135
|
+
// ---------------------------------------------------------------------------
|
|
49136
|
+
_proto._loadPrefabInstance = function _loadPrefabInstance(entityConfig, engine) {
|
|
49173
49137
|
var _this = this;
|
|
49174
|
-
var
|
|
49138
|
+
var instance = entityConfig.instance;
|
|
49139
|
+
var refItem;
|
|
49140
|
+
try {
|
|
49141
|
+
refItem = resolveRefItem(this.data.refs, instance.asset, "HierarchyParser", "instance.asset");
|
|
49142
|
+
} catch (error) {
|
|
49143
|
+
return Promise.reject(error);
|
|
49144
|
+
}
|
|
49175
49145
|
return engine.resourceManager // @ts-ignore
|
|
49176
|
-
.getResourceByRef({
|
|
49177
|
-
url: assetUrl
|
|
49178
|
-
}).then(function(prefabResource) {
|
|
49146
|
+
.getResourceByRef(refItem).then(function(prefabResource) {
|
|
49179
49147
|
var entity = _instanceof1(prefabResource, PrefabResource) ? prefabResource.instantiate() : prefabResource.instantiateSceneRoot();
|
|
49180
|
-
|
|
49181
|
-
_this._generateInstanceContext(entity, instanceContext, "");
|
|
49182
|
-
_this._prefabContextMap.set(entity, instanceContext);
|
|
49183
|
-
var cbArray = _this._prefabPromiseMap.get(entityConfig.id);
|
|
49184
|
-
if (cbArray) {
|
|
49185
|
-
for(var i = 0, n = cbArray.length; i < n; i++){
|
|
49186
|
-
cbArray[i].resolve(instanceContext);
|
|
49187
|
-
}
|
|
49188
|
-
}
|
|
49148
|
+
_this._onEntityCreated(entity);
|
|
49189
49149
|
return entity;
|
|
49190
49150
|
});
|
|
49191
49151
|
};
|
|
49192
|
-
|
|
49193
|
-
|
|
49194
|
-
|
|
49195
|
-
|
|
49196
|
-
|
|
49197
|
-
|
|
49198
|
-
|
|
49199
|
-
|
|
49200
|
-
reject: reject
|
|
49201
|
-
});
|
|
49202
|
-
_this._prefabPromiseMap.set(entityConfig.prefabInstanceId, cbArray);
|
|
49203
|
-
}).then(function(context) {
|
|
49204
|
-
var entityId = entityConfig.prefabSource.entityId;
|
|
49205
|
-
return context.entityMap.get(entityId);
|
|
49206
|
-
});
|
|
49207
|
-
};
|
|
49208
|
-
_proto._parseChildren = function _parseChildren(parentId) {
|
|
49209
|
-
var _this_context = this.context, entityConfigMap = _this_context.entityConfigMap, entityMap = _this_context.entityMap;
|
|
49210
|
-
var children = entityConfigMap.get(parentId).children;
|
|
49211
|
-
if (children && children.length > 0) {
|
|
49212
|
-
var parent = entityMap.get(parentId);
|
|
49213
|
-
for(var i = 0; i < children.length; i++){
|
|
49214
|
-
var childId = children[i];
|
|
49215
|
-
var entity = entityMap.get(childId);
|
|
49216
|
-
parent.addChild(entity);
|
|
49217
|
-
this._parseChildren(childId);
|
|
49218
|
-
}
|
|
49152
|
+
// ---------------------------------------------------------------------------
|
|
49153
|
+
// Utilities
|
|
49154
|
+
// ---------------------------------------------------------------------------
|
|
49155
|
+
/** Resolve an entity inside a prefab instance by walking the child-index path from root */ HierarchyParser._resolveEntity = function _resolveEntity(root, path) {
|
|
49156
|
+
var entity = root;
|
|
49157
|
+
for(var i = 0, n = path.length; i < n; i++){
|
|
49158
|
+
entity = entity.children[path[i]];
|
|
49159
|
+
if (!entity) throw new Error("HierarchyParser: override target entity not found at path [" + path + "], failed at depth " + i);
|
|
49219
49160
|
}
|
|
49161
|
+
return entity;
|
|
49220
49162
|
};
|
|
49221
|
-
|
|
49222
|
-
var
|
|
49223
|
-
|
|
49224
|
-
var
|
|
49225
|
-
|
|
49226
|
-
|
|
49227
|
-
|
|
49228
|
-
|
|
49229
|
-
|
|
49230
|
-
|
|
49231
|
-
componentConfigMap.set(componentId, componentConfig);
|
|
49232
|
-
this._addComponentPlugin(componentId, component);
|
|
49233
|
-
}
|
|
49234
|
-
};
|
|
49235
|
-
_proto._generateInstanceContext = function _generateInstanceContext(entity, context, path) {
|
|
49236
|
-
var entityMap = context.entityMap, components = context.components;
|
|
49237
|
-
var componentsMap = {};
|
|
49238
|
-
var componentIndexMap = {};
|
|
49239
|
-
entityMap.set(path, entity);
|
|
49240
|
-
// @ts-ignore
|
|
49241
|
-
entity._components.forEach(function(component) {
|
|
49242
|
-
// @ts-ignore
|
|
49243
|
-
var name = Loader.getClassName(component.constructor);
|
|
49244
|
-
if (!componentsMap[name]) {
|
|
49245
|
-
componentsMap[name] = entity.getComponents(component.constructor, []);
|
|
49246
|
-
componentIndexMap[name] = 0;
|
|
49247
|
-
}
|
|
49248
|
-
components.set(path + ":" + name + "/" + componentIndexMap[name]++, component);
|
|
49249
|
-
});
|
|
49250
|
-
for(var i = 0, n = entity.children.length; i < n; i++){
|
|
49251
|
-
var child = entity.children[i];
|
|
49252
|
-
var childPath = path ? path + "/" + i : "" + i;
|
|
49253
|
-
this._generateInstanceContext(child, context, childPath);
|
|
49254
|
-
}
|
|
49163
|
+
/** Resolve a component on an entity by type name + per-type index */ HierarchyParser._resolveComponent = function _resolveComponent(entity, selector) {
|
|
49164
|
+
var type = Loader.getClass(selector.type);
|
|
49165
|
+
if (!type) throw new Error('HierarchyParser: override target component type "' + selector.type + '" is not registered');
|
|
49166
|
+
var buffer = ReflectionParser._componentBuffer;
|
|
49167
|
+
buffer.length = 0;
|
|
49168
|
+
entity.getComponents(type, buffer);
|
|
49169
|
+
var result = buffer[selector.index];
|
|
49170
|
+
buffer.length = 0;
|
|
49171
|
+
if (!result) throw new Error("HierarchyParser: override target component not found: " + selector.type + "/" + selector.index);
|
|
49172
|
+
return result;
|
|
49255
49173
|
};
|
|
49256
|
-
|
|
49257
|
-
var
|
|
49258
|
-
var
|
|
49259
|
-
|
|
49260
|
-
|
|
49261
|
-
|
|
49262
|
-
|
|
49263
|
-
|
|
49264
|
-
|
|
49265
|
-
|
|
49266
|
-
|
|
49267
|
-
|
|
49268
|
-
|
|
49174
|
+
/** Resolve component class from config and add to entity. Throws if class is not registered. */ HierarchyParser._addComponentFromConfig = function _addComponentFromConfig(entity, config, refs) {
|
|
49175
|
+
var key = config.script != null ? resolveRefItem(refs, config.script, "HierarchyParser", "component.script").url : config.type;
|
|
49176
|
+
var Class = Loader.getClass(key);
|
|
49177
|
+
if (!Class) throw new Error('Loader.getClass: class "' + key + '" is not registered');
|
|
49178
|
+
return entity.addComponent(Class);
|
|
49179
|
+
};
|
|
49180
|
+
HierarchyParser._isPrefabInstanceEntity = function _isPrefabInstanceEntity(entityConfig) {
|
|
49181
|
+
return "instance" in entityConfig;
|
|
49182
|
+
};
|
|
49183
|
+
/** Apply entity-level props (name, isActive, layer, transform) to an entity. */ HierarchyParser._applyEntityProps = function _applyEntityProps(entity, props) {
|
|
49184
|
+
if (props.name != null) entity.name = props.name;
|
|
49185
|
+
if (props.isActive != null) entity.isActive = props.isActive;
|
|
49186
|
+
if (props.layer != null) entity.layer = props.layer;
|
|
49187
|
+
if (props.position) entity.transform.position.set(props.position[0], props.position[1], props.position[2]);
|
|
49188
|
+
if (props.rotation) entity.transform.rotation.set(props.rotation[0], props.rotation[1], props.rotation[2]);
|
|
49189
|
+
if (props.scale) entity.transform.scale.set(props.scale[0], props.scale[1], props.scale[2]);
|
|
49269
49190
|
};
|
|
49270
|
-
_proto._addComponentPlugin = function _addComponentPlugin(componentId, component) {};
|
|
49271
|
-
_proto._addEntityPlugin = function _addEntityPlugin(entityId, entity) {};
|
|
49272
49191
|
return HierarchyParser;
|
|
49273
49192
|
}();
|
|
49274
|
-
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
49275
|
-
MaterialLoaderType["Vector2"] = "Vector2";
|
|
49276
|
-
MaterialLoaderType["Vector3"] = "Vector3";
|
|
49277
|
-
MaterialLoaderType["Vector4"] = "Vector4";
|
|
49278
|
-
MaterialLoaderType["Color"] = "Color";
|
|
49279
|
-
MaterialLoaderType["Float"] = "Float";
|
|
49280
|
-
MaterialLoaderType["Texture"] = "Texture";
|
|
49281
|
-
MaterialLoaderType["Boolean"] = "Boolean";
|
|
49282
|
-
MaterialLoaderType["Integer"] = "Integer";
|
|
49283
|
-
return MaterialLoaderType;
|
|
49284
|
-
}({});
|
|
49285
|
-
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
49286
|
-
SpecularMode["Sky"] = "Sky";
|
|
49287
|
-
SpecularMode["Custom"] = "Custom";
|
|
49288
|
-
return SpecularMode;
|
|
49289
|
-
}({});
|
|
49290
49193
|
/** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser) {
|
|
49291
49194
|
_inherits(SceneParser, HierarchyParser);
|
|
49292
49195
|
function SceneParser(data, context, scene) {
|
|
@@ -49300,90 +49203,40 @@
|
|
|
49300
49203
|
*/ _proto._collectDependentAssets = function _collectDependentAssets(data) {
|
|
49301
49204
|
var context = this.context;
|
|
49302
49205
|
var resourceManager = context.resourceManager;
|
|
49303
|
-
|
|
49304
|
-
var
|
|
49305
|
-
var ambient = scene.ambient;
|
|
49306
|
-
if (ambient) {
|
|
49307
|
-
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
49308
|
-
var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
|
|
49309
|
-
var customAmbientLight = ambient.customAmbientLight, ambientLight = ambient.ambientLight;
|
|
49310
|
-
if (useCustomAmbient && customAmbientLight) {
|
|
49311
|
-
// @ts-ignore
|
|
49312
|
-
context._addDependentAsset(customAmbientLight.url, resourceManager.getResourceByRef(customAmbientLight));
|
|
49313
|
-
}
|
|
49314
|
-
if (ambientLight && (!useCustomAmbient || useSH)) {
|
|
49315
|
-
// @ts-ignore
|
|
49316
|
-
context._addDependentAsset(ambientLight.url, resourceManager.getResourceByRef(ambientLight));
|
|
49317
|
-
}
|
|
49318
|
-
}
|
|
49319
|
-
var background = scene.background;
|
|
49320
|
-
var backgroundMode = background.mode;
|
|
49321
|
-
if (backgroundMode === BackgroundMode.Texture) {
|
|
49322
|
-
var texture = background.texture;
|
|
49206
|
+
var refs = data.refs;
|
|
49207
|
+
for(var i = 0, n = refs.length; i < n; i++){
|
|
49323
49208
|
// @ts-ignore
|
|
49324
|
-
|
|
49325
|
-
} else if (backgroundMode === BackgroundMode.Sky) {
|
|
49326
|
-
var skyMesh = background.skyMesh, skyMaterial = background.skyMaterial;
|
|
49327
|
-
if (skyMesh && skyMaterial) {
|
|
49328
|
-
// @ts-ignore
|
|
49329
|
-
context._addDependentAsset(skyMesh.url, resourceManager.getResourceByRef(skyMesh));
|
|
49330
|
-
// @ts-ignore
|
|
49331
|
-
context._addDependentAsset(skyMaterial.url, resourceManager.getResourceByRef(skyMaterial));
|
|
49332
|
-
}
|
|
49209
|
+
context._addDependentAsset(resourceManager.getResourceByRef(refs[i]));
|
|
49333
49210
|
}
|
|
49334
49211
|
};
|
|
49335
|
-
_proto.
|
|
49336
|
-
|
|
49337
|
-
|
|
49212
|
+
_proto._getRootIndices = function _getRootIndices() {
|
|
49213
|
+
return this.data.scene.entities;
|
|
49214
|
+
};
|
|
49215
|
+
_proto._handleRootEntity = function _handleRootEntity(index) {
|
|
49216
|
+
this.scene.addRootEntity(this.context.entityInstances[index]);
|
|
49338
49217
|
};
|
|
49339
49218
|
_proto._clearAndResolve = function _clearAndResolve() {
|
|
49340
49219
|
this.context.clear();
|
|
49341
49220
|
return this.scene;
|
|
49342
49221
|
};
|
|
49343
|
-
_proto._parseDependentAssets = function _parseDependentAssets(file) {
|
|
49344
|
-
var entities = file.entities;
|
|
49345
|
-
for(var i = 0, n = entities.length; i < n; i++){
|
|
49346
|
-
var entity = entities[i];
|
|
49347
|
-
if (!!entity.assetUrl) {
|
|
49348
|
-
var context = this.context;
|
|
49349
|
-
var url = entity.assetUrl, key = entity.key;
|
|
49350
|
-
// @ts-ignore
|
|
49351
|
-
context._addDependentAsset(url, context.resourceManager.getResourceByRef({
|
|
49352
|
-
url: url,
|
|
49353
|
-
key: key
|
|
49354
|
-
}));
|
|
49355
|
-
} else if (entity.strippedId) {
|
|
49356
|
-
continue;
|
|
49357
|
-
} else {
|
|
49358
|
-
var components = entity.components;
|
|
49359
|
-
for(var j = 0, m = components.length; j < m; j++){
|
|
49360
|
-
var component = components[j];
|
|
49361
|
-
this._searchDependentAssets(component.methods);
|
|
49362
|
-
this._searchDependentAssets(component.props);
|
|
49363
|
-
}
|
|
49364
|
-
}
|
|
49365
|
-
}
|
|
49366
|
-
};
|
|
49367
|
-
_proto._searchDependentAssets = function _searchDependentAssets(value) {
|
|
49368
|
-
if (Array.isArray(value)) {
|
|
49369
|
-
for(var i = 0, n = value.length; i < n; i++){
|
|
49370
|
-
this._searchDependentAssets(value[i]);
|
|
49371
|
-
}
|
|
49372
|
-
} else if (!!value && (typeof value === "undefined" ? "undefined" : _type_of1(value)) === "object") {
|
|
49373
|
-
// @ts-ignore
|
|
49374
|
-
if (ReflectionParser._isAssetRef(value)) {
|
|
49375
|
-
var context = this.context;
|
|
49376
|
-
// @ts-ignore
|
|
49377
|
-
context._addDependentAsset(value.url, context.resourceManager.getResourceByRef(value));
|
|
49378
|
-
} else {
|
|
49379
|
-
for(var key in value){
|
|
49380
|
-
this._searchDependentAssets(value[key]);
|
|
49381
|
-
}
|
|
49382
|
-
}
|
|
49383
|
-
}
|
|
49384
|
-
};
|
|
49385
49222
|
return SceneParser;
|
|
49386
49223
|
}(HierarchyParser);
|
|
49224
|
+
var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
|
|
49225
|
+
SpecularMode["Sky"] = "Sky";
|
|
49226
|
+
SpecularMode["Custom"] = "Custom";
|
|
49227
|
+
return SpecularMode;
|
|
49228
|
+
}({});
|
|
49229
|
+
var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
|
|
49230
|
+
MaterialLoaderType["Vector2"] = "Vector2";
|
|
49231
|
+
MaterialLoaderType["Vector3"] = "Vector3";
|
|
49232
|
+
MaterialLoaderType["Vector4"] = "Vector4";
|
|
49233
|
+
MaterialLoaderType["Color"] = "Color";
|
|
49234
|
+
MaterialLoaderType["Float"] = "Float";
|
|
49235
|
+
MaterialLoaderType["Texture"] = "Texture";
|
|
49236
|
+
MaterialLoaderType["Boolean"] = "Boolean";
|
|
49237
|
+
MaterialLoaderType["Integer"] = "Integer";
|
|
49238
|
+
return MaterialLoaderType;
|
|
49239
|
+
}({});
|
|
49387
49240
|
/**
|
|
49388
49241
|
* Decode engine binary resource.
|
|
49389
49242
|
* @param arrayBuffer - array buffer of decode binary file
|
|
@@ -50844,6 +50697,38 @@
|
|
|
50844
50697
|
]);
|
|
50845
50698
|
return GLTFResource;
|
|
50846
50699
|
}(ReferResource);
|
|
50700
|
+
function _array_like_to_array(arr, len) {
|
|
50701
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
50702
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
50703
|
+
return arr2;
|
|
50704
|
+
}
|
|
50705
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
50706
|
+
if (!o) return;
|
|
50707
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
50708
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50709
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
50710
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
50711
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
50712
|
+
}
|
|
50713
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
50714
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
50715
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
50716
|
+
// Fallback for engines without symbol support
|
|
50717
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
50718
|
+
if (it) o = it;
|
|
50719
|
+
var i = 0;
|
|
50720
|
+
return function() {
|
|
50721
|
+
if (i >= o.length) return {
|
|
50722
|
+
done: true
|
|
50723
|
+
};
|
|
50724
|
+
return {
|
|
50725
|
+
done: false,
|
|
50726
|
+
value: o[i++]
|
|
50727
|
+
};
|
|
50728
|
+
};
|
|
50729
|
+
}
|
|
50730
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50731
|
+
}
|
|
50847
50732
|
/**
|
|
50848
50733
|
* Module for glTF 2.0 Interface
|
|
50849
50734
|
*/ /**
|
|
@@ -53094,15 +52979,17 @@
|
|
|
53094
52979
|
return _this;
|
|
53095
52980
|
}
|
|
53096
52981
|
var _proto = PrefabParser.prototype;
|
|
53097
|
-
_proto.
|
|
53098
|
-
if (entityConfig === void 0) entityConfig = {};
|
|
53099
|
-
HierarchyParser.prototype._applyEntityData.call(this, entity, entityConfig);
|
|
52982
|
+
_proto._onEntityCreated = function _onEntityCreated(entity) {
|
|
53100
52983
|
// @ts-ignore
|
|
53101
52984
|
entity._markAsTemplate(this.context.resource);
|
|
53102
|
-
return entity;
|
|
53103
52985
|
};
|
|
53104
|
-
_proto.
|
|
53105
|
-
|
|
52986
|
+
_proto._getRootIndices = function _getRootIndices() {
|
|
52987
|
+
return [
|
|
52988
|
+
this.data.root
|
|
52989
|
+
];
|
|
52990
|
+
};
|
|
52991
|
+
_proto._handleRootEntity = function _handleRootEntity(index) {
|
|
52992
|
+
this.prefabResource._root = this.context.entityInstances[index];
|
|
53106
52993
|
};
|
|
53107
52994
|
_proto._clearAndResolve = function _clearAndResolve() {
|
|
53108
52995
|
this.context.clear();
|
|
@@ -53113,9 +53000,7 @@
|
|
|
53113
53000
|
var context = new ParserContext(engine, ParserType.Prefab, prefabResource);
|
|
53114
53001
|
var parser = new PrefabParser(data, context, prefabResource);
|
|
53115
53002
|
parser.start();
|
|
53116
|
-
return parser.promise
|
|
53117
|
-
return prefabResource;
|
|
53118
|
-
});
|
|
53003
|
+
return parser.promise;
|
|
53119
53004
|
};
|
|
53120
53005
|
return PrefabParser;
|
|
53121
53006
|
}(HierarchyParser);
|
|
@@ -54223,6 +54108,122 @@
|
|
|
54223
54108
|
"renderTarget"
|
|
54224
54109
|
])
|
|
54225
54110
|
], RenderTargetLoader);
|
|
54111
|
+
function loadRef(refs, index, resourceManager, label) {
|
|
54112
|
+
var ref = resolveRefItem(refs, index, "SceneLoader", label);
|
|
54113
|
+
// @ts-ignore
|
|
54114
|
+
return resourceManager.getResourceByRef(ref);
|
|
54115
|
+
}
|
|
54116
|
+
/**
|
|
54117
|
+
* Apply scene-level data (ambient, background, shadow, fog, AO) to a Scene.
|
|
54118
|
+
* @internal
|
|
54119
|
+
*/ function applySceneData(scene, sceneData, resourceManager, refs) {
|
|
54120
|
+
var promises = [];
|
|
54121
|
+
try {
|
|
54122
|
+
// parse ambient light
|
|
54123
|
+
var ambient = sceneData.ambient;
|
|
54124
|
+
if (ambient) {
|
|
54125
|
+
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
54126
|
+
var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
|
|
54127
|
+
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
54128
|
+
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
54129
|
+
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
54130
|
+
var solidColor = ambient.diffuseSolidColor;
|
|
54131
|
+
if (solidColor) {
|
|
54132
|
+
scene.ambientLight.diffuseSolidColor.set(solidColor[0], solidColor[1], solidColor[2], solidColor[3]);
|
|
54133
|
+
}
|
|
54134
|
+
if (useCustomAmbient && ambient.customAmbientLight != null) {
|
|
54135
|
+
promises.push(loadRef(refs, ambient.customAmbientLight, resourceManager, "scene.ambient.customAmbientLight").then(function(ambientLight) {
|
|
54136
|
+
scene.ambientLight.specularTexture = ambientLight == null ? void 0 : ambientLight.specularTexture;
|
|
54137
|
+
}));
|
|
54138
|
+
}
|
|
54139
|
+
if (ambient.ambientLight != null && (!useCustomAmbient || useSH)) {
|
|
54140
|
+
promises.push(loadRef(refs, ambient.ambientLight, resourceManager, "scene.ambient.ambientLight").then(function(ambientLight) {
|
|
54141
|
+
if (!useCustomAmbient) {
|
|
54142
|
+
scene.ambientLight.specularTexture = ambientLight == null ? void 0 : ambientLight.specularTexture;
|
|
54143
|
+
}
|
|
54144
|
+
if (useSH) {
|
|
54145
|
+
scene.ambientLight.diffuseSphericalHarmonics = ambientLight == null ? void 0 : ambientLight.diffuseSphericalHarmonics;
|
|
54146
|
+
}
|
|
54147
|
+
}));
|
|
54148
|
+
}
|
|
54149
|
+
}
|
|
54150
|
+
// parse background
|
|
54151
|
+
var background = sceneData.background;
|
|
54152
|
+
scene.background.mode = background.mode;
|
|
54153
|
+
switch(scene.background.mode){
|
|
54154
|
+
case BackgroundMode.SolidColor:
|
|
54155
|
+
{
|
|
54156
|
+
var color = background.color;
|
|
54157
|
+
scene.background.solidColor.set(color[0], color[1], color[2], color[3]);
|
|
54158
|
+
break;
|
|
54159
|
+
}
|
|
54160
|
+
case BackgroundMode.Sky:
|
|
54161
|
+
if (background.skyMesh != null && background.skyMaterial != null) {
|
|
54162
|
+
promises.push(loadRef(refs, background.skyMesh, resourceManager, "scene.background.skyMesh").then(function(mesh) {
|
|
54163
|
+
scene.background.sky.mesh = mesh;
|
|
54164
|
+
}), loadRef(refs, background.skyMaterial, resourceManager, "scene.background.skyMaterial").then(function(material) {
|
|
54165
|
+
scene.background.sky.material = material;
|
|
54166
|
+
}));
|
|
54167
|
+
} else {
|
|
54168
|
+
Logger.warn("Sky background mode requires skyMesh and skyMaterial");
|
|
54169
|
+
}
|
|
54170
|
+
break;
|
|
54171
|
+
case BackgroundMode.Texture:
|
|
54172
|
+
if (background.texture != null) {
|
|
54173
|
+
promises.push(loadRef(refs, background.texture, resourceManager, "scene.background.texture").then(function(texture) {
|
|
54174
|
+
scene.background.texture = texture;
|
|
54175
|
+
}));
|
|
54176
|
+
var _background_textureFillMode;
|
|
54177
|
+
scene.background.textureFillMode = (_background_textureFillMode = background.textureFillMode) != null ? _background_textureFillMode : scene.background.textureFillMode;
|
|
54178
|
+
}
|
|
54179
|
+
break;
|
|
54180
|
+
}
|
|
54181
|
+
} catch (error) {
|
|
54182
|
+
return Promise.reject(error);
|
|
54183
|
+
}
|
|
54184
|
+
// parse shadow
|
|
54185
|
+
var shadow = sceneData.shadow;
|
|
54186
|
+
if (shadow) {
|
|
54187
|
+
if (shadow.castShadows != undefined) scene.castShadows = shadow.castShadows;
|
|
54188
|
+
if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
|
|
54189
|
+
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
54190
|
+
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
54191
|
+
if (shadow.enableTransparentShadow != undefined) scene.enableTransparentShadow = shadow.enableTransparentShadow;
|
|
54192
|
+
if (shadow.shadowTwoCascadeSplits != undefined) scene.shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits;
|
|
54193
|
+
if (shadow.shadowFourCascadeSplits) {
|
|
54194
|
+
var splits = shadow.shadowFourCascadeSplits;
|
|
54195
|
+
scene.shadowFourCascadeSplits.set(splits[0], splits[1], splits[2]);
|
|
54196
|
+
}
|
|
54197
|
+
if (shadow.shadowFadeBorder != undefined) scene.shadowFadeBorder = shadow.shadowFadeBorder;
|
|
54198
|
+
}
|
|
54199
|
+
// parse fog
|
|
54200
|
+
var fog = sceneData.fog;
|
|
54201
|
+
if (fog) {
|
|
54202
|
+
if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
|
|
54203
|
+
if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
|
|
54204
|
+
if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
|
|
54205
|
+
if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
|
|
54206
|
+
if (fog.fogColor) scene.fogColor.set(fog.fogColor[0], fog.fogColor[1], fog.fogColor[2], fog.fogColor[3]);
|
|
54207
|
+
}
|
|
54208
|
+
// Post Process
|
|
54209
|
+
if (sceneData.postProcess) {
|
|
54210
|
+
Logger.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead.");
|
|
54211
|
+
}
|
|
54212
|
+
// Ambient Occlusion
|
|
54213
|
+
var ambientOcclusion = sceneData.ambientOcclusion;
|
|
54214
|
+
if (ambientOcclusion) {
|
|
54215
|
+
var sceneAO = scene.ambientOcclusion;
|
|
54216
|
+
if (ambientOcclusion.enabledAmbientOcclusion != undefined) sceneAO.enabled = ambientOcclusion.enabledAmbientOcclusion;
|
|
54217
|
+
if (ambientOcclusion.quality != undefined) sceneAO.quality = ambientOcclusion.quality;
|
|
54218
|
+
if (ambientOcclusion.intensity != undefined) sceneAO.intensity = ambientOcclusion.intensity;
|
|
54219
|
+
if (ambientOcclusion.radius != undefined) sceneAO.radius = ambientOcclusion.radius;
|
|
54220
|
+
if (ambientOcclusion.bias != undefined) sceneAO.bias = ambientOcclusion.bias;
|
|
54221
|
+
if (ambientOcclusion.power != undefined) sceneAO.power = ambientOcclusion.power;
|
|
54222
|
+
if (ambientOcclusion.bilateralThreshold != undefined) sceneAO.bilateralThreshold = ambientOcclusion.bilateralThreshold;
|
|
54223
|
+
if (ambientOcclusion.minHorizonAngle != undefined) sceneAO.minHorizonAngle = ambientOcclusion.minHorizonAngle;
|
|
54224
|
+
}
|
|
54225
|
+
return Promise.all(promises).then(function() {});
|
|
54226
|
+
}
|
|
54226
54227
|
var SceneLoader = /*#__PURE__*/ function(Loader) {
|
|
54227
54228
|
_inherits(SceneLoader, Loader);
|
|
54228
54229
|
function SceneLoader() {
|
|
@@ -54236,120 +54237,15 @@
|
|
|
54236
54237
|
._request(item.url, _extends({}, item, {
|
|
54237
54238
|
type: "json"
|
|
54238
54239
|
})).then(function(data) {
|
|
54239
|
-
var
|
|
54240
|
-
var scene = new Scene(engine, (
|
|
54240
|
+
var _data_scene_name;
|
|
54241
|
+
var scene = new Scene(engine, (_data_scene_name = data.scene.name) != null ? _data_scene_name : "");
|
|
54241
54242
|
var context = new ParserContext(engine, ParserType.Scene, scene);
|
|
54242
54243
|
var parser = new SceneParser(data, context, scene);
|
|
54243
54244
|
parser._collectDependentAssets(data);
|
|
54244
54245
|
context._setTaskCompleteProgress = setTaskCompleteProgress;
|
|
54245
54246
|
parser.start();
|
|
54246
54247
|
return parser.promise.then(function() {
|
|
54247
|
-
|
|
54248
|
-
// parse ambient light
|
|
54249
|
-
var ambient = data.scene.ambient;
|
|
54250
|
-
if (ambient) {
|
|
54251
|
-
var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
|
|
54252
|
-
var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
|
|
54253
|
-
scene.ambientLight.diffuseIntensity = ambient.diffuseIntensity;
|
|
54254
|
-
scene.ambientLight.specularIntensity = ambient.specularIntensity;
|
|
54255
|
-
scene.ambientLight.diffuseMode = ambient.diffuseMode;
|
|
54256
|
-
scene.ambientLight.diffuseSolidColor.copyFrom(ambient.diffuseSolidColor);
|
|
54257
|
-
if (useCustomAmbient && ambient.customAmbientLight) {
|
|
54258
|
-
promises.push(resourceManager.getResourceByRef(ambient.customAmbientLight).then(function(ambientLight) {
|
|
54259
|
-
scene.ambientLight.specularTexture = ambientLight == null ? void 0 : ambientLight.specularTexture;
|
|
54260
|
-
}));
|
|
54261
|
-
}
|
|
54262
|
-
if (ambient.ambientLight && (!useCustomAmbient || useSH)) {
|
|
54263
|
-
promises.push(resourceManager.getResourceByRef(ambient.ambientLight).then(function(ambientLight) {
|
|
54264
|
-
if (!useCustomAmbient) {
|
|
54265
|
-
scene.ambientLight.specularTexture = ambientLight == null ? void 0 : ambientLight.specularTexture;
|
|
54266
|
-
}
|
|
54267
|
-
if (useSH) {
|
|
54268
|
-
scene.ambientLight.diffuseSphericalHarmonics = ambientLight == null ? void 0 : ambientLight.diffuseSphericalHarmonics;
|
|
54269
|
-
}
|
|
54270
|
-
}));
|
|
54271
|
-
}
|
|
54272
|
-
}
|
|
54273
|
-
// parse background
|
|
54274
|
-
var background = data.scene.background;
|
|
54275
|
-
scene.background.mode = background.mode;
|
|
54276
|
-
switch(scene.background.mode){
|
|
54277
|
-
case BackgroundMode.SolidColor:
|
|
54278
|
-
scene.background.solidColor.copyFrom(background.color);
|
|
54279
|
-
break;
|
|
54280
|
-
case BackgroundMode.Sky:
|
|
54281
|
-
if (background.skyMesh && background.skyMaterial) {
|
|
54282
|
-
// @ts-ignore
|
|
54283
|
-
var skyMeshPromise = resourceManager.getResourceByRef(background.skyMesh).then(function(mesh) {
|
|
54284
|
-
scene.background.sky.mesh = mesh;
|
|
54285
|
-
});
|
|
54286
|
-
// @ts-ignore
|
|
54287
|
-
// prettier-ignore
|
|
54288
|
-
var skyMaterialPromise = resourceManager.getResourceByRef(background.skyMaterial).then(function(material) {
|
|
54289
|
-
scene.background.sky.material = material;
|
|
54290
|
-
});
|
|
54291
|
-
promises.push(skyMeshPromise, skyMaterialPromise);
|
|
54292
|
-
} else {
|
|
54293
|
-
Logger.warn("Sky background mode requires skyMesh and skyMaterial");
|
|
54294
|
-
}
|
|
54295
|
-
break;
|
|
54296
|
-
case BackgroundMode.Texture:
|
|
54297
|
-
if (background.texture) {
|
|
54298
|
-
// @ts-ignore
|
|
54299
|
-
// prettier-ignore
|
|
54300
|
-
var backgroundPromise = resourceManager.getResourceByRef(background.texture).then(function(texture) {
|
|
54301
|
-
scene.background.texture = texture;
|
|
54302
|
-
});
|
|
54303
|
-
promises.push(backgroundPromise);
|
|
54304
|
-
var _background_textureFillMode;
|
|
54305
|
-
scene.background.textureFillMode = (_background_textureFillMode = background.textureFillMode) != null ? _background_textureFillMode : scene.background.textureFillMode;
|
|
54306
|
-
}
|
|
54307
|
-
break;
|
|
54308
|
-
}
|
|
54309
|
-
// parse shadow
|
|
54310
|
-
var shadow = data.scene.shadow;
|
|
54311
|
-
if (shadow) {
|
|
54312
|
-
if (shadow.castShadows != undefined) scene.castShadows = shadow.castShadows;
|
|
54313
|
-
if (shadow.shadowResolution != undefined) scene.shadowResolution = shadow.shadowResolution;
|
|
54314
|
-
if (shadow.shadowDistance != undefined) scene.shadowDistance = shadow.shadowDistance;
|
|
54315
|
-
if (shadow.shadowCascades != undefined) scene.shadowCascades = shadow.shadowCascades;
|
|
54316
|
-
if (shadow.enableTransparentShadow != undefined) {
|
|
54317
|
-
scene.enableTransparentShadow = shadow.enableTransparentShadow;
|
|
54318
|
-
}
|
|
54319
|
-
var _shadow_shadowTwoCascadeSplits;
|
|
54320
|
-
scene.shadowTwoCascadeSplits = (_shadow_shadowTwoCascadeSplits = shadow.shadowTwoCascadeSplits) != null ? _shadow_shadowTwoCascadeSplits : scene.shadowTwoCascadeSplits;
|
|
54321
|
-
shadow.shadowFourCascadeSplits && scene.shadowFourCascadeSplits.copyFrom(shadow.shadowFourCascadeSplits);
|
|
54322
|
-
var _shadow_shadowFadeBorder;
|
|
54323
|
-
scene.shadowFadeBorder = (_shadow_shadowFadeBorder = shadow.shadowFadeBorder) != null ? _shadow_shadowFadeBorder : scene.shadowFadeBorder;
|
|
54324
|
-
}
|
|
54325
|
-
// parse fog
|
|
54326
|
-
var fog = data.scene.fog;
|
|
54327
|
-
if (fog) {
|
|
54328
|
-
if (fog.fogMode != undefined) scene.fogMode = fog.fogMode;
|
|
54329
|
-
if (fog.fogStart != undefined) scene.fogStart = fog.fogStart;
|
|
54330
|
-
if (fog.fogEnd != undefined) scene.fogEnd = fog.fogEnd;
|
|
54331
|
-
if (fog.fogDensity != undefined) scene.fogDensity = fog.fogDensity;
|
|
54332
|
-
if (fog.fogColor != undefined) scene.fogColor.copyFrom(fog.fogColor);
|
|
54333
|
-
}
|
|
54334
|
-
// Post Process
|
|
54335
|
-
var postProcessData = data.scene.postProcess;
|
|
54336
|
-
if (postProcessData) {
|
|
54337
|
-
Logger.warn("Post Process is not supported in scene yet, please add PostProcess component in entity instead.");
|
|
54338
|
-
}
|
|
54339
|
-
// Ambient Occlusion
|
|
54340
|
-
var ambientOcclusion = data.scene.ambientOcclusion;
|
|
54341
|
-
if (ambientOcclusion) {
|
|
54342
|
-
var sceneAmbientOcclusion = scene.ambientOcclusion;
|
|
54343
|
-
sceneAmbientOcclusion.enabled = ambientOcclusion.enabledAmbientOcclusion;
|
|
54344
|
-
sceneAmbientOcclusion.intensity = ambientOcclusion.intensity;
|
|
54345
|
-
sceneAmbientOcclusion.radius = ambientOcclusion.radius;
|
|
54346
|
-
sceneAmbientOcclusion.bias = ambientOcclusion.bias;
|
|
54347
|
-
sceneAmbientOcclusion.power = ambientOcclusion.power;
|
|
54348
|
-
sceneAmbientOcclusion.quality = ambientOcclusion.quality;
|
|
54349
|
-
sceneAmbientOcclusion.bilateralThreshold = ambientOcclusion.bilateralThreshold;
|
|
54350
|
-
sceneAmbientOcclusion.minHorizonAngle = ambientOcclusion.minHorizonAngle;
|
|
54351
|
-
}
|
|
54352
|
-
return Promise.all(promises).then(function() {
|
|
54248
|
+
return applySceneData(scene, data.scene, resourceManager, data.refs).then(function() {
|
|
54353
54249
|
resolve(scene);
|
|
54354
54250
|
});
|
|
54355
54251
|
});
|
|
@@ -54857,7 +54753,7 @@
|
|
|
54857
54753
|
], EXT_texture_webp);
|
|
54858
54754
|
|
|
54859
54755
|
//@ts-ignore
|
|
54860
|
-
var version = "2.0.0-alpha.
|
|
54756
|
+
var version = "2.0.0-alpha.30";
|
|
54861
54757
|
console.log("Galacean Engine Version: " + version);
|
|
54862
54758
|
for(var key in CoreObjects){
|
|
54863
54759
|
Loader.registerClass(key, CoreObjects[key]);
|