@galacean/effects-plugin-model 2.3.0-alpha.2 → 2.3.0-beta.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/alipay.js +1 -13387
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -13273
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -13387
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -13273
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +2 -84
- 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 +2 -84
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +3 -942
- package/dist/loader.mjs.map +1 -1
- package/dist/utility/plugin-helper.d.ts +3 -13
- package/dist/weapp.js +1 -13387
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -13273
- package/dist/weapp.mjs.map +1 -1
- package/package.json +4 -4
package/dist/loader.mjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v2.3.0-
|
|
6
|
+
* Version: v2.3.0-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
10
|
-
import { math, Transform, spec, PLAYER_OPTIONS_ENV_EDITOR, glContext, Material, Mesh, Geometry, ShaderFactory, effectsClass, VFXItem, GLSLVersion, Behaviour, AbstractPlugin, registerPlugin, logger, RendererComponent, HitTestType, AnimationClip, TextureSourceType, Texture, RenderPass, TextureLoadAction, DestroyOptions, RenderPassDestroyAttachmentType, getDefaultTextureFactory, Player, loadImage,
|
|
10
|
+
import { math, Transform, spec, PLAYER_OPTIONS_ENV_EDITOR, glContext, Material, Mesh, Geometry, ShaderFactory, effectsClass, VFXItem, GLSLVersion, Behaviour, AbstractPlugin, registerPlugin, logger, RendererComponent, HitTestType, AnimationClip, TextureSourceType, Texture, RenderPass, TextureLoadAction, DestroyOptions, RenderPassDestroyAttachmentType, getDefaultTextureFactory, Player, loadImage, generateGUID, addItem, removeItem, glType2VertexFormatType, Downloader, getStandardJSON, isObject } from '@galacean/effects';
|
|
11
11
|
|
|
12
12
|
var Vector2 = math.Vector2, Vector3 = math.Vector3, Vector4 = math.Vector4, Matrix3 = math.Matrix3, Matrix4 = math.Matrix4, Color = math.Color, Euler = math.Euler, EulerOrder = math.EulerOrder, Quaternion = math.Quaternion, Box3 = math.Box3; math.Sphere; math.Ray; var DEG2RAD = math.DEG2RAD;
|
|
13
13
|
|
|
@@ -1370,8 +1370,6 @@ function getQuadFilterVS() {
|
|
|
1370
1370
|
var engine = composition.renderer.engine;
|
|
1371
1371
|
this.cache = new CompositionCache(engine);
|
|
1372
1372
|
this.cache.setup(false);
|
|
1373
|
-
// FIXME: 先注释元素参数的配置
|
|
1374
|
-
//PluginHelper.setupItem3DOptions(scene, this.cache, composition);
|
|
1375
1373
|
};
|
|
1376
1374
|
/**
|
|
1377
1375
|
* 每次播放都会执行,包括重播,所以这里执行“小的销毁”和新的初始化
|
|
@@ -2098,7 +2096,7 @@ var CameraGestureHandlerImp = /*#__PURE__*/ function() {
|
|
|
2098
2096
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
2099
2097
|
/**
|
|
2100
2098
|
* 插件版本号
|
|
2101
|
-
*/ var version = "2.3.0-
|
|
2099
|
+
*/ var version = "2.3.0-beta.0";
|
|
2102
2100
|
logger.info("Plugin model version: " + version + ".");
|
|
2103
2101
|
if (version !== EFFECTS.version) {
|
|
2104
2102
|
console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
|
|
@@ -3789,86 +3787,6 @@ var normal = new Vector3();
|
|
|
3789
3787
|
}
|
|
3790
3788
|
};
|
|
3791
3789
|
/**
|
|
3792
|
-
* 设置 3D 元素参数,在播放器创建 3D 元素前
|
|
3793
|
-
* @param scene - 场景
|
|
3794
|
-
* @param cache - 缓存
|
|
3795
|
-
* @param composition - 合成
|
|
3796
|
-
* @returns
|
|
3797
|
-
*/ PluginHelper.setupItem3DOptions = function setupItem3DOptions(scene, cache, composition) {
|
|
3798
|
-
var _this = this;
|
|
3799
|
-
if (scene === undefined || scene.bins.length <= 0) {
|
|
3800
|
-
return;
|
|
3801
|
-
}
|
|
3802
|
-
var jsonScene = scene.jsonScene;
|
|
3803
|
-
var compIndexSet = new Set();
|
|
3804
|
-
if (jsonScene.compositionId === undefined) {
|
|
3805
|
-
compIndexSet.add(0);
|
|
3806
|
-
}
|
|
3807
|
-
jsonScene.compositions.forEach(function(comp, index) {
|
|
3808
|
-
if (comp.id === jsonScene.compositionId || composition.refCompositionProps.has(comp.id)) {
|
|
3809
|
-
compIndexSet.add(index);
|
|
3810
|
-
}
|
|
3811
|
-
});
|
|
3812
|
-
compIndexSet.forEach(function(compIndex) {
|
|
3813
|
-
var sceneComp = jsonScene.compositions[compIndex];
|
|
3814
|
-
sceneComp.items.forEach(function(data) {
|
|
3815
|
-
var itemId = data.id;
|
|
3816
|
-
var item = composition.getEngine().jsonSceneData[itemId];
|
|
3817
|
-
if (item.type === spec.ItemType.mesh) {
|
|
3818
|
-
var meshItem = item;
|
|
3819
|
-
var skin = meshItem.content.options.skin;
|
|
3820
|
-
var primitives = meshItem.content.options.primitives;
|
|
3821
|
-
primitives.forEach(function(prim, primId) {
|
|
3822
|
-
if (_instanceof1(prim.geometry, Geometry)) {
|
|
3823
|
-
// 可能已经创建,直接返回
|
|
3824
|
-
return;
|
|
3825
|
-
}
|
|
3826
|
-
var name = "Geom_C" + compIndex + "_I" + itemId + "_P" + primId;
|
|
3827
|
-
var riGeometry = cache.getOrCreateGeometry(name, prim.geometry, scene.bins);
|
|
3828
|
-
var studioPrim = prim;
|
|
3829
|
-
studioPrim.geometry = riGeometry;
|
|
3830
|
-
var material = prim.material;
|
|
3831
|
-
if (material.type === spec.MaterialType.pbr) {
|
|
3832
|
-
var studioMat = studioPrim.material;
|
|
3833
|
-
studioMat.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
|
|
3834
|
-
studioMat.metallicRoughnessTexture = _this.getTextureObj(composition.textures, material.metallicRoughnessTexture);
|
|
3835
|
-
studioMat.normalTexture = _this.getTextureObj(composition.textures, material.normalTexture);
|
|
3836
|
-
studioMat.occlusionTexture = _this.getTextureObj(composition.textures, material.occlusionTexture);
|
|
3837
|
-
studioMat.emissiveTexture = _this.getTextureObj(composition.textures, material.emissiveTexture);
|
|
3838
|
-
} else {
|
|
3839
|
-
var studioMat1 = studioPrim.material;
|
|
3840
|
-
studioMat1.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
|
|
3841
|
-
}
|
|
3842
|
-
});
|
|
3843
|
-
if (skin !== undefined && skin.inverseBindMatrices !== undefined) {
|
|
3844
|
-
var studioSkin = skin;
|
|
3845
|
-
var inverseBindMatrices = typedArrayFromBinary(scene.bins, skin.inverseBindMatrices);
|
|
3846
|
-
if (_instanceof1(inverseBindMatrices, Float32Array)) {
|
|
3847
|
-
studioSkin.inverseBindMatrices = inverseBindMatrices;
|
|
3848
|
-
} else {
|
|
3849
|
-
console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
|
-
} else if (item.type === spec.ItemType.skybox) {
|
|
3853
|
-
var skybox = item;
|
|
3854
|
-
var studioSkybox = item;
|
|
3855
|
-
var options = skybox.content.options;
|
|
3856
|
-
var studioOptions = studioSkybox.content.options;
|
|
3857
|
-
var specularImage = _this.getTextureObj(composition.textures, options.specularImage);
|
|
3858
|
-
if (specularImage === undefined) {
|
|
3859
|
-
console.error("setupItem3DOptions: skybox specualrImage is undefined, " + CheckerHelper.stringify(options) + ".");
|
|
3860
|
-
}
|
|
3861
|
-
studioOptions.specularImage = specularImage;
|
|
3862
|
-
//
|
|
3863
|
-
var diffuseImage = _this.getTextureObj(composition.textures, options.diffuseImage);
|
|
3864
|
-
if (diffuseImage !== undefined) {
|
|
3865
|
-
studioOptions.diffuseImage = diffuseImage;
|
|
3866
|
-
}
|
|
3867
|
-
}
|
|
3868
|
-
});
|
|
3869
|
-
});
|
|
3870
|
-
};
|
|
3871
|
-
/**
|
|
3872
3790
|
* 创建几何体,根据几何参数描述 JSON 和数据数组
|
|
3873
3791
|
* @param engine - 引擎
|
|
3874
3792
|
* @param geomJson - 几何参数描述 JSON
|
|
@@ -4483,863 +4401,6 @@ var AttributeArray = /*#__PURE__*/ function() {
|
|
|
4483
4401
|
};
|
|
4484
4402
|
return HitTestingProxy;
|
|
4485
4403
|
}();
|
|
4486
|
-
/**
|
|
4487
|
-
* 检查辅助类,负责 3D 插件元素数据格式检查和报错
|
|
4488
|
-
*/ var CheckerHelper = /*#__PURE__*/ function() {
|
|
4489
|
-
function CheckerHelper() {}
|
|
4490
|
-
/**
|
|
4491
|
-
* 检查数值
|
|
4492
|
-
* @param v - 数值
|
|
4493
|
-
* @returns
|
|
4494
|
-
*/ CheckerHelper.checkNumber = function checkNumber(v) {
|
|
4495
|
-
return typeof v === "number";
|
|
4496
|
-
};
|
|
4497
|
-
/**
|
|
4498
|
-
* 检查数值或未定义
|
|
4499
|
-
* @param v - 数值或未定义
|
|
4500
|
-
* @returns
|
|
4501
|
-
*/ CheckerHelper.checkNumberUndef = function checkNumberUndef(v) {
|
|
4502
|
-
return v === undefined ? true : this.checkNumber(v);
|
|
4503
|
-
};
|
|
4504
|
-
/**
|
|
4505
|
-
* 检查 0 和 1 之间数值
|
|
4506
|
-
* @param v - 数值
|
|
4507
|
-
* @returns
|
|
4508
|
-
*/ CheckerHelper.checkNumber01 = function checkNumber01(v) {
|
|
4509
|
-
return this.checkNumber(v) && v >= 0 && v <= 1;
|
|
4510
|
-
};
|
|
4511
|
-
/**
|
|
4512
|
-
* 检查 0 和 1 之间数值或未定义
|
|
4513
|
-
* @param v - 数值或未定义
|
|
4514
|
-
* @returns
|
|
4515
|
-
*/ CheckerHelper.checkNumber01Undef = function checkNumber01Undef(v) {
|
|
4516
|
-
return v === undefined ? true : this.checkNumber01(v);
|
|
4517
|
-
};
|
|
4518
|
-
/**
|
|
4519
|
-
* 检查正数
|
|
4520
|
-
* @param v - 数值
|
|
4521
|
-
* @returns
|
|
4522
|
-
*/ CheckerHelper.checkPositive = function checkPositive(v) {
|
|
4523
|
-
return this.checkNumber(v) && v > 0;
|
|
4524
|
-
};
|
|
4525
|
-
/**
|
|
4526
|
-
* 检查非负数
|
|
4527
|
-
* @param v - 数值
|
|
4528
|
-
* @returns
|
|
4529
|
-
*/ CheckerHelper.checkNonnegative = function checkNonnegative(v) {
|
|
4530
|
-
return this.checkNumber(v) && v >= 0;
|
|
4531
|
-
};
|
|
4532
|
-
/**
|
|
4533
|
-
* 检查非负数或未定义
|
|
4534
|
-
* @param v - 数值
|
|
4535
|
-
* @returns
|
|
4536
|
-
*/ CheckerHelper.checkNonnegativeUndef = function checkNonnegativeUndef(v) {
|
|
4537
|
-
return v === undefined ? true : this.checkNonnegative(v);
|
|
4538
|
-
};
|
|
4539
|
-
/**
|
|
4540
|
-
* 检查布尔类型
|
|
4541
|
-
* @param v - 布尔值
|
|
4542
|
-
* @returns
|
|
4543
|
-
*/ CheckerHelper.checkBoolean = function checkBoolean(v) {
|
|
4544
|
-
return typeof v === "boolean";
|
|
4545
|
-
};
|
|
4546
|
-
/**
|
|
4547
|
-
* 检查布尔类型或未定义
|
|
4548
|
-
* @param v - 布尔值或未定义
|
|
4549
|
-
* @returns
|
|
4550
|
-
*/ CheckerHelper.checkBooleanUndef = function checkBooleanUndef(v) {
|
|
4551
|
-
return v === undefined ? true : this.checkBoolean(v);
|
|
4552
|
-
};
|
|
4553
|
-
/**
|
|
4554
|
-
* 检查字符串类型
|
|
4555
|
-
* @param v - 字符串
|
|
4556
|
-
* @returns
|
|
4557
|
-
*/ CheckerHelper.checkString = function checkString(v) {
|
|
4558
|
-
return typeof v === "string";
|
|
4559
|
-
};
|
|
4560
|
-
/**
|
|
4561
|
-
* 检查字符串类型或未定义
|
|
4562
|
-
* @param v - 字符串或未定义
|
|
4563
|
-
* @returns
|
|
4564
|
-
*/ CheckerHelper.checkStringUndef = function checkStringUndef(v) {
|
|
4565
|
-
return v === undefined ? true : this.checkString(v);
|
|
4566
|
-
};
|
|
4567
|
-
/**
|
|
4568
|
-
* 检查浮点数组
|
|
4569
|
-
* @param v - 浮点数组
|
|
4570
|
-
* @returns
|
|
4571
|
-
*/ CheckerHelper.checkFloat32Array = function checkFloat32Array(v) {
|
|
4572
|
-
return _instanceof1(v, Float32Array);
|
|
4573
|
-
};
|
|
4574
|
-
/**
|
|
4575
|
-
* 检查浮点数组或未定义
|
|
4576
|
-
* @param v - 浮点数组或未定义
|
|
4577
|
-
* @returns
|
|
4578
|
-
*/ CheckerHelper.checkFloat32ArrayUndef = function checkFloat32ArrayUndef(v) {
|
|
4579
|
-
return v === undefined ? true : this.checkFloat32Array(v);
|
|
4580
|
-
};
|
|
4581
|
-
/**
|
|
4582
|
-
* 检查父节点索引
|
|
4583
|
-
* @param v - 数值或未定义
|
|
4584
|
-
* @returns
|
|
4585
|
-
*/ CheckerHelper.checkParent = function checkParent(v) {
|
|
4586
|
-
if (v === undefined) {
|
|
4587
|
-
return true;
|
|
4588
|
-
}
|
|
4589
|
-
if (!this.checkNumber(v)) {
|
|
4590
|
-
return false;
|
|
4591
|
-
}
|
|
4592
|
-
return v >= 0;
|
|
4593
|
-
};
|
|
4594
|
-
/**
|
|
4595
|
-
* 检查纹理坐标
|
|
4596
|
-
* @param v - 纹理坐标或未定义
|
|
4597
|
-
* @returns
|
|
4598
|
-
*/ CheckerHelper.checkTexCoord = function checkTexCoord(v) {
|
|
4599
|
-
if (v === undefined) {
|
|
4600
|
-
return true;
|
|
4601
|
-
}
|
|
4602
|
-
if (!this.checkNumber(v)) {
|
|
4603
|
-
return false;
|
|
4604
|
-
}
|
|
4605
|
-
return v >= 0 && v <= 1;
|
|
4606
|
-
};
|
|
4607
|
-
/**
|
|
4608
|
-
* 检查二维向量
|
|
4609
|
-
* @param v - 二维向量
|
|
4610
|
-
* @returns
|
|
4611
|
-
*/ CheckerHelper.checkVec2 = function checkVec2(v) {
|
|
4612
|
-
var _this = this;
|
|
4613
|
-
if (!Array.isArray(v)) {
|
|
4614
|
-
return false;
|
|
4615
|
-
}
|
|
4616
|
-
if (v.length != 2) {
|
|
4617
|
-
return false;
|
|
4618
|
-
}
|
|
4619
|
-
return v.every(function(v) {
|
|
4620
|
-
return _this.checkNumber(v);
|
|
4621
|
-
});
|
|
4622
|
-
};
|
|
4623
|
-
/**
|
|
4624
|
-
* 检查二维向量或未定义
|
|
4625
|
-
* @param v - 二维向量或未定义
|
|
4626
|
-
* @returns
|
|
4627
|
-
*/ CheckerHelper.checkVec2Undef = function checkVec2Undef(v) {
|
|
4628
|
-
return v === undefined ? true : this.checkVec2(v);
|
|
4629
|
-
};
|
|
4630
|
-
/**
|
|
4631
|
-
* 检查三维向量
|
|
4632
|
-
* @param v - 三维向量
|
|
4633
|
-
* @returns
|
|
4634
|
-
*/ CheckerHelper.checkVec3 = function checkVec3(v) {
|
|
4635
|
-
var _this = this;
|
|
4636
|
-
if (!Array.isArray(v)) {
|
|
4637
|
-
return false;
|
|
4638
|
-
}
|
|
4639
|
-
if (v.length != 3) {
|
|
4640
|
-
return false;
|
|
4641
|
-
}
|
|
4642
|
-
return v.every(function(v) {
|
|
4643
|
-
return _this.checkNumber(v);
|
|
4644
|
-
});
|
|
4645
|
-
};
|
|
4646
|
-
/**
|
|
4647
|
-
* 检查三维非负向量
|
|
4648
|
-
* @param v - 三维向量
|
|
4649
|
-
* @returns
|
|
4650
|
-
*/ CheckerHelper.checkNonnegative3 = function checkNonnegative3(v) {
|
|
4651
|
-
var _this = this;
|
|
4652
|
-
if (!Array.isArray(v)) {
|
|
4653
|
-
return false;
|
|
4654
|
-
}
|
|
4655
|
-
if (v.length != 3) {
|
|
4656
|
-
return false;
|
|
4657
|
-
}
|
|
4658
|
-
return v.every(function(v) {
|
|
4659
|
-
return _this.checkNonnegative(v);
|
|
4660
|
-
});
|
|
4661
|
-
};
|
|
4662
|
-
/**
|
|
4663
|
-
* 检查四维向量
|
|
4664
|
-
* @param v - 四维向量
|
|
4665
|
-
* @returns
|
|
4666
|
-
*/ CheckerHelper.checkVec4 = function checkVec4(v) {
|
|
4667
|
-
var _this = this;
|
|
4668
|
-
if (!Array.isArray(v)) {
|
|
4669
|
-
return false;
|
|
4670
|
-
}
|
|
4671
|
-
if (v.length != 4) {
|
|
4672
|
-
return false;
|
|
4673
|
-
}
|
|
4674
|
-
return v.every(function(v) {
|
|
4675
|
-
return _this.checkNumber(v);
|
|
4676
|
-
});
|
|
4677
|
-
};
|
|
4678
|
-
/**
|
|
4679
|
-
* 检查四维向量或未定义
|
|
4680
|
-
* @param v - 四维向量或未定义
|
|
4681
|
-
* @returns
|
|
4682
|
-
*/ CheckerHelper.checkNonnegative4 = function checkNonnegative4(v) {
|
|
4683
|
-
var _this = this;
|
|
4684
|
-
if (!Array.isArray(v)) {
|
|
4685
|
-
return false;
|
|
4686
|
-
}
|
|
4687
|
-
if (v.length != 4) {
|
|
4688
|
-
return false;
|
|
4689
|
-
}
|
|
4690
|
-
return v.every(function(v) {
|
|
4691
|
-
return _this.checkNonnegative(v);
|
|
4692
|
-
});
|
|
4693
|
-
};
|
|
4694
|
-
/**
|
|
4695
|
-
* 检查数值数组
|
|
4696
|
-
* @param v - 数值数组
|
|
4697
|
-
* @returns
|
|
4698
|
-
*/ CheckerHelper.checkNumberArray = function checkNumberArray(v) {
|
|
4699
|
-
var _this = this;
|
|
4700
|
-
if (!Array.isArray(v)) {
|
|
4701
|
-
return false;
|
|
4702
|
-
}
|
|
4703
|
-
return v.every(function(v) {
|
|
4704
|
-
return _this.checkNumber(v);
|
|
4705
|
-
});
|
|
4706
|
-
};
|
|
4707
|
-
/**
|
|
4708
|
-
* 检查纹理对象
|
|
4709
|
-
* @param v - 纹理对象
|
|
4710
|
-
* @returns
|
|
4711
|
-
*/ CheckerHelper.checkTexture = function checkTexture(v) {
|
|
4712
|
-
if (_instanceof1(v, Texture)) {
|
|
4713
|
-
if (v.isDestroyed) {
|
|
4714
|
-
console.error("Texture is destroyed, " + v.name + ".");
|
|
4715
|
-
}
|
|
4716
|
-
return !v.isDestroyed;
|
|
4717
|
-
} else {
|
|
4718
|
-
return false;
|
|
4719
|
-
}
|
|
4720
|
-
};
|
|
4721
|
-
/**
|
|
4722
|
-
* 检查纹理对象或未定义
|
|
4723
|
-
* @param v - 纹理对象或未定义
|
|
4724
|
-
* @returns
|
|
4725
|
-
*/ CheckerHelper.checkTextureUndef = function checkTextureUndef(v) {
|
|
4726
|
-
return v === undefined ? true : this.checkTexture(v);
|
|
4727
|
-
};
|
|
4728
|
-
/**
|
|
4729
|
-
* 检查纹理变换参数
|
|
4730
|
-
* @param v - 纹理变换参数
|
|
4731
|
-
* @returns
|
|
4732
|
-
*/ CheckerHelper.checkTexTransform = function checkTexTransform(v) {
|
|
4733
|
-
if (!this.checkVec2Undef(v.offset)) {
|
|
4734
|
-
return false;
|
|
4735
|
-
}
|
|
4736
|
-
if (!this.checkNumberUndef(v.rotation)) {
|
|
4737
|
-
return false;
|
|
4738
|
-
}
|
|
4739
|
-
if (!this.checkVec2Undef(v.scale)) {
|
|
4740
|
-
return false;
|
|
4741
|
-
}
|
|
4742
|
-
if (v.scale !== undefined) {
|
|
4743
|
-
if (Math.abs(v.scale[0]) < 1e-5 || Math.abs(v.scale[1]) < 1e-5) {
|
|
4744
|
-
// check scale range
|
|
4745
|
-
return false;
|
|
4746
|
-
}
|
|
4747
|
-
}
|
|
4748
|
-
return true;
|
|
4749
|
-
};
|
|
4750
|
-
/**
|
|
4751
|
-
* 检查纹理变换参数或未定义
|
|
4752
|
-
* @param v - 纹理变换参数或未定义
|
|
4753
|
-
* @returns
|
|
4754
|
-
*/ CheckerHelper.checkTexTransformUndef = function checkTexTransformUndef(v) {
|
|
4755
|
-
return v === undefined ? true : this.checkTexTransform(v);
|
|
4756
|
-
};
|
|
4757
|
-
/**
|
|
4758
|
-
* 检查材质混合参数或未定义
|
|
4759
|
-
* @param v - 材质混合参数或未定义
|
|
4760
|
-
* @returns
|
|
4761
|
-
*/ CheckerHelper.checkMatBlending = function checkMatBlending(v) {
|
|
4762
|
-
return v === undefined || v === spec.MaterialBlending.opaque || v === spec.MaterialBlending.masked || v === spec.MaterialBlending.translucent || v === spec.MaterialBlending.additive;
|
|
4763
|
-
};
|
|
4764
|
-
/**
|
|
4765
|
-
* 检查材质单双面模式或未定义
|
|
4766
|
-
* @param v - 材质单双面模式或未定义
|
|
4767
|
-
* @returns
|
|
4768
|
-
*/ CheckerHelper.checkMatSide = function checkMatSide(v) {
|
|
4769
|
-
return v === undefined || v === spec.SideMode.BACK || v === spec.SideMode.DOUBLE || v === spec.SideMode.FRONT;
|
|
4770
|
-
};
|
|
4771
|
-
/**
|
|
4772
|
-
* 检查动画路径模式
|
|
4773
|
-
* @param v - 动画路径模式
|
|
4774
|
-
* @returns
|
|
4775
|
-
*/ CheckerHelper.checkAnimPath = function checkAnimPath(v) {
|
|
4776
|
-
return v === "translation" || v === "rotation" || v === "scale" || v === "weights";
|
|
4777
|
-
};
|
|
4778
|
-
/**
|
|
4779
|
-
* 检查动画插值模式
|
|
4780
|
-
* @param v - 动画插值模式
|
|
4781
|
-
* @returns
|
|
4782
|
-
*/ CheckerHelper.checkAnimInterp = function checkAnimInterp(v) {
|
|
4783
|
-
return v === "LINEAR" || v === "STEP" || v === "CUBICSPLINE";
|
|
4784
|
-
};
|
|
4785
|
-
/**
|
|
4786
|
-
* 检查几何体
|
|
4787
|
-
* @param v - 几何体
|
|
4788
|
-
* @param s - 蒙皮参数
|
|
4789
|
-
*/ CheckerHelper.assertGeometry = function assertGeometry(v, s) {
|
|
4790
|
-
if (!_instanceof1(v, Geometry)) {
|
|
4791
|
-
console.error("Invalid geometry type " + this.stringify(v) + ".");
|
|
4792
|
-
}
|
|
4793
|
-
// @ts-expect-error
|
|
4794
|
-
if (v.isDestroyed === true) {
|
|
4795
|
-
console.error("Geometry object is destroyed.");
|
|
4796
|
-
}
|
|
4797
|
-
if (!this.checkNonnegative(v.getDrawStart())) {
|
|
4798
|
-
console.error("Invalid geometry draw start: " + v.getDrawStart() + ", " + this.stringify(v) + ".");
|
|
4799
|
-
}
|
|
4800
|
-
// // drawCount不再为负
|
|
4801
|
-
// if (!this.checkPositive(v.getDrawCount())) {
|
|
4802
|
-
// throw new Error(`Invalid geometry draw count: ${v.getDrawCount()}, ${this.stringify(v)}`);
|
|
4803
|
-
// }
|
|
4804
|
-
// Geometry具体内容检查,先忽略
|
|
4805
|
-
// const opts = v.options;
|
|
4806
|
-
// const drawCount = Math.abs(v.getDrawCount());
|
|
4807
|
-
// if (opts !== undefined && drawCount > 0) {
|
|
4808
|
-
// let maxLength = v.drawStart + drawCount;
|
|
4809
|
-
// if (opts.index !== undefined) {
|
|
4810
|
-
// const indexArray = opts.index.data;
|
|
4811
|
-
// if (indexArray.length < maxLength) {
|
|
4812
|
-
// throw new Error(`Index length(${indexArray.length}) is less than draw count(${maxLength}), ${this.stringify(v)}`);
|
|
4813
|
-
// }
|
|
4814
|
-
// let maxIndex = 0;
|
|
4815
|
-
// for (let i = 0; i < drawCount; i++) {
|
|
4816
|
-
// maxIndex = Math.max(indexArray[v.drawStart + i], maxIndex);
|
|
4817
|
-
// }
|
|
4818
|
-
// maxLength = maxIndex + 1;
|
|
4819
|
-
// }
|
|
4820
|
-
// const positionAttrib = opts.attributes['aPos'] as Attribute;
|
|
4821
|
-
// if (positionAttrib === undefined) {
|
|
4822
|
-
// throw new Error(`Position attribute is required, ${this.stringify(v)}`);
|
|
4823
|
-
// }
|
|
4824
|
-
// this.assertGeometryBuffer(v, 'aPos', maxLength);
|
|
4825
|
-
// this.assertGeometryBuffer(v, 'aNormal', maxLength);
|
|
4826
|
-
// this.assertGeometryBuffer(v, 'aTangent', maxLength);
|
|
4827
|
-
// this.assertGeometryBuffer(v, 'aUV', maxLength);
|
|
4828
|
-
// this.assertGeometryBuffer(v, 'aJoints', maxLength);
|
|
4829
|
-
// this.assertGeometryBuffer(v, 'aWeights', maxLength);
|
|
4830
|
-
// // 索引检查
|
|
4831
|
-
// if(s !== undefined){
|
|
4832
|
-
// const matLen = s.inverseBindMatrices?.length ?? 0;
|
|
4833
|
-
// if(matLen > 0){
|
|
4834
|
-
// const jointArray = this.createAttributeArray(v, "aJoints");
|
|
4835
|
-
// if(jointArray !== undefined){
|
|
4836
|
-
// for(let i = 0; i < maxLength; i++){
|
|
4837
|
-
// const data = jointArray.getData(i);
|
|
4838
|
-
// if(data === undefined) continue;
|
|
4839
|
-
// if(Math.max(...data) >= matLen){
|
|
4840
|
-
// throw new Error(`Joint index out of range: ${this.stringify(data)}, matrices: ${matLen}`);
|
|
4841
|
-
// }
|
|
4842
|
-
// }
|
|
4843
|
-
// }
|
|
4844
|
-
// }
|
|
4845
|
-
// }
|
|
4846
|
-
// }
|
|
4847
|
-
};
|
|
4848
|
-
/**
|
|
4849
|
-
* 检查几何体缓冲区
|
|
4850
|
-
* @param v - 几何体
|
|
4851
|
-
* @param name - 名称
|
|
4852
|
-
* @param drawCount - 渲染数目
|
|
4853
|
-
*/ CheckerHelper.assertGeometryBuffer = function assertGeometryBuffer(v, name, drawCount) {
|
|
4854
|
-
var attribArray = this.createAttributeArray(v, name);
|
|
4855
|
-
if (attribArray !== undefined) {
|
|
4856
|
-
if (attribArray.getLength() < drawCount) {
|
|
4857
|
-
console.error(name + " Length(" + attribArray.getLength() + ") is less than draw count(" + drawCount + "), " + this.stringify(v) + ".");
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
|
-
};
|
|
4861
|
-
/**
|
|
4862
|
-
* 创建属性数组
|
|
4863
|
-
* @param v - 几何体
|
|
4864
|
-
* @param name - 名称
|
|
4865
|
-
* @returns
|
|
4866
|
-
*/ CheckerHelper.createAttributeArray = function createAttributeArray(v, name) {
|
|
4867
|
-
// @ts-expect-error
|
|
4868
|
-
var attributes = v.attributes;
|
|
4869
|
-
if (attributes === undefined) {
|
|
4870
|
-
return;
|
|
4871
|
-
}
|
|
4872
|
-
var dataAttrib = attributes[name];
|
|
4873
|
-
if (dataAttrib === undefined) {
|
|
4874
|
-
return;
|
|
4875
|
-
}
|
|
4876
|
-
var dataArray = v.getAttributeData(name);
|
|
4877
|
-
if (dataArray === undefined) {
|
|
4878
|
-
return;
|
|
4879
|
-
}
|
|
4880
|
-
//
|
|
4881
|
-
var attribArray = new AttributeArray();
|
|
4882
|
-
attribArray.create(dataAttrib, dataArray);
|
|
4883
|
-
return attribArray;
|
|
4884
|
-
};
|
|
4885
|
-
/**
|
|
4886
|
-
* 检查蒙皮参数
|
|
4887
|
-
* @param v - 蒙皮参数
|
|
4888
|
-
*/ CheckerHelper.assertModelSkinOptions = function assertModelSkinOptions(v) {
|
|
4889
|
-
if (!this.checkStringUndef(v.name)) {
|
|
4890
|
-
console.error("Invalid skin name " + v.name + ", " + this.stringify(v) + ".");
|
|
4891
|
-
}
|
|
4892
|
-
if (!this.checkNumberArray(v.joints)) {
|
|
4893
|
-
console.error("Invalid skin joints " + v.joints + ", " + this.stringify(v) + ".");
|
|
4894
|
-
}
|
|
4895
|
-
if (!this.checkNumberUndef(v.skeleton)) {
|
|
4896
|
-
console.error("Invalid skin skeleton " + v.skeleton + ", " + this.stringify(v) + ".");
|
|
4897
|
-
}
|
|
4898
|
-
if (!this.checkFloat32ArrayUndef(v.inverseBindMatrices)) {
|
|
4899
|
-
console.error("Invalid skin inverseBindMatrices " + v.inverseBindMatrices + ", " + this.stringify(v) + ".");
|
|
4900
|
-
}
|
|
4901
|
-
//
|
|
4902
|
-
if (v.inverseBindMatrices !== undefined) {
|
|
4903
|
-
if (v.inverseBindMatrices.length <= 0 || v.inverseBindMatrices.length % 16 !== 0) {
|
|
4904
|
-
console.error("Invalid skin inverseBindMatrices length " + v.inverseBindMatrices + ", " + this.stringify(v) + ".");
|
|
4905
|
-
}
|
|
4906
|
-
if (v.joints.length * 16 !== v.inverseBindMatrices.length) {
|
|
4907
|
-
console.error("Mismatch: skin joints and inverseBindMatrices length, " + v.joints + ", " + v.inverseBindMatrices + ", " + this.stringify(v) + ".");
|
|
4908
|
-
}
|
|
4909
|
-
var mat = new Matrix4();
|
|
4910
|
-
for(var i = 0; i < v.inverseBindMatrices.length; i += 16){
|
|
4911
|
-
for(var j = 0; j < 16; j++){
|
|
4912
|
-
mat.elements[j] = v.inverseBindMatrices[i + j];
|
|
4913
|
-
}
|
|
4914
|
-
if (Math.abs(mat.determinant()) < 1e-5) {
|
|
4915
|
-
console.error("Determinant of inverseBindMatrices is too small " + mat.determinant() + ", index " + i / 16 + ", " + this.stringify(v) + ".");
|
|
4916
|
-
}
|
|
4917
|
-
}
|
|
4918
|
-
} else {
|
|
4919
|
-
if (v.joints.length <= 0) {
|
|
4920
|
-
console.error("Invalid skin joints length " + v.joints + ", " + this.stringify(v) + ".");
|
|
4921
|
-
}
|
|
4922
|
-
}
|
|
4923
|
-
};
|
|
4924
|
-
/**
|
|
4925
|
-
* 检查材质参数
|
|
4926
|
-
* @param v - 材质参数
|
|
4927
|
-
*/ CheckerHelper.assertMatOptions = function assertMatOptions(v) {
|
|
4928
|
-
if (v.type === spec.MaterialType.unlit) {
|
|
4929
|
-
if (!this.checkString(v.name)) {
|
|
4930
|
-
console.error("Invalid material name " + v.name + ", " + this.stringify(v) + ".");
|
|
4931
|
-
}
|
|
4932
|
-
//
|
|
4933
|
-
if (!this.checkNonnegative4(v.baseColorFactor)) {
|
|
4934
|
-
console.error("Invalid material baseColorFactor " + v.baseColorFactor + ", " + this.stringify(v) + ".");
|
|
4935
|
-
}
|
|
4936
|
-
if (!this.checkTextureUndef(v.baseColorTexture)) {
|
|
4937
|
-
console.error("Invalid material baseColorTexture " + v.baseColorTexture + ", " + this.stringify(v) + ".");
|
|
4938
|
-
}
|
|
4939
|
-
if (!this.checkTexTransformUndef(v.baseColorTextureTransform)) {
|
|
4940
|
-
console.error("Invalid material baseColorTextureTransform " + v.baseColorTextureTransform + ", " + this.stringify(v) + ".");
|
|
4941
|
-
}
|
|
4942
|
-
if (!this.checkTexCoord(v.baseColorTextureCoordinate)) {
|
|
4943
|
-
console.error("Invalid material baseColorTextureCoordinate " + v.baseColorTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
4944
|
-
}
|
|
4945
|
-
//
|
|
4946
|
-
if (!this.checkBooleanUndef(v.depthMask)) {
|
|
4947
|
-
console.error("Invalid material depthMask " + v.depthMask + ", " + this.stringify(v) + ".");
|
|
4948
|
-
}
|
|
4949
|
-
if (!this.checkMatBlending(v.blending)) {
|
|
4950
|
-
console.error("Invalid material blending " + v.blending + ", " + this.stringify(v) + ".");
|
|
4951
|
-
}
|
|
4952
|
-
if (!this.checkMatSide(v.side)) {
|
|
4953
|
-
console.error("Invalid material side " + v.side + ", " + this.stringify(v) + ".");
|
|
4954
|
-
}
|
|
4955
|
-
if (v.blending === spec.MaterialBlending.masked) {
|
|
4956
|
-
if (v.alphaCutOff === undefined) {
|
|
4957
|
-
console.error("Material alphaCutOff is required for mask, " + this.stringify(v) + ".");
|
|
4958
|
-
}
|
|
4959
|
-
}
|
|
4960
|
-
if (!this.checkNumber01Undef(v.alphaCutOff)) {
|
|
4961
|
-
console.error("Invalid material alphaCutOff " + v.alphaCutOff + ", " + this.stringify(v) + ".");
|
|
4962
|
-
}
|
|
4963
|
-
} else if (v.type === spec.MaterialType.pbr) {
|
|
4964
|
-
if (!this.checkString(v.name)) {
|
|
4965
|
-
console.error("Invalid material name " + v.name + ", " + this.stringify(v) + ".");
|
|
4966
|
-
}
|
|
4967
|
-
//
|
|
4968
|
-
if (!this.checkNonnegative4(v.baseColorFactor)) {
|
|
4969
|
-
console.error("Invalid material baseColorFactor " + v.baseColorFactor + ", " + this.stringify(v) + ".");
|
|
4970
|
-
}
|
|
4971
|
-
if (!this.checkTextureUndef(v.baseColorTexture)) {
|
|
4972
|
-
console.error("Invalid material baseColorTexture " + v.baseColorTexture + ", " + this.stringify(v) + ".");
|
|
4973
|
-
}
|
|
4974
|
-
if (!this.checkTexTransformUndef(v.baseColorTextureTransform)) {
|
|
4975
|
-
console.error("Invalid material baseColorTextureTransform " + v.baseColorTextureTransform + ", " + this.stringify(v) + ".");
|
|
4976
|
-
}
|
|
4977
|
-
if (!this.checkTexCoord(v.baseColorTextureCoordinate)) {
|
|
4978
|
-
console.error("Invalid material baseColorTextureCoordinate " + v.baseColorTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
4979
|
-
}
|
|
4980
|
-
//
|
|
4981
|
-
if (!this.checkBooleanUndef(v.useSpecularAA)) {
|
|
4982
|
-
console.error("Invalid material useSpecularAA " + v.useSpecularAA + ", " + this.stringify(v) + ".");
|
|
4983
|
-
}
|
|
4984
|
-
if (!this.checkNumber01(v.metallicFactor)) {
|
|
4985
|
-
console.error("Invalid material metallicFactor " + v.metallicFactor + ", " + this.stringify(v) + ".");
|
|
4986
|
-
}
|
|
4987
|
-
if (!this.checkNonnegative(v.roughnessFactor)) {
|
|
4988
|
-
console.error("Invalid material roughnessFactor " + v.roughnessFactor + ", " + this.stringify(v) + ".");
|
|
4989
|
-
}
|
|
4990
|
-
if (!this.checkTextureUndef(v.metallicRoughnessTexture)) {
|
|
4991
|
-
console.error("Invalid material metallicRoughnessTexture " + v.metallicRoughnessTexture + ", " + this.stringify(v) + ".");
|
|
4992
|
-
}
|
|
4993
|
-
if (!this.checkTexTransformUndef(v.metallicRoughnessTextureTransform)) {
|
|
4994
|
-
console.error("Invalid material metallicRoughnessTextureTransform " + v.metallicRoughnessTextureTransform + ", " + this.stringify(v) + ".");
|
|
4995
|
-
}
|
|
4996
|
-
if (!this.checkTexCoord(v.metallicRoughnessTextureCoordinate)) {
|
|
4997
|
-
console.error("Invalid material metallicRoughnessTextureCoordinate " + v.metallicRoughnessTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
4998
|
-
}
|
|
4999
|
-
//
|
|
5000
|
-
if (!this.checkTextureUndef(v.normalTexture)) {
|
|
5001
|
-
console.error("Invalid material normalTexture " + v.normalTexture + ", " + this.stringify(v) + ".");
|
|
5002
|
-
}
|
|
5003
|
-
if (!this.checkNonnegativeUndef(v.normalTextureScale)) {
|
|
5004
|
-
console.error("Invalid material normalTextureScale " + v.normalTextureScale + ", " + this.stringify(v) + ".");
|
|
5005
|
-
}
|
|
5006
|
-
if (!this.checkTexTransformUndef(v.normalTextureTransform)) {
|
|
5007
|
-
console.error("Invalid material normalTextureTransform " + v.normalTextureTransform + ", " + this.stringify(v) + ".");
|
|
5008
|
-
}
|
|
5009
|
-
if (!this.checkTexCoord(v.normalTextureCoordinate)) {
|
|
5010
|
-
console.error("Invalid material normalTextureCoordinate " + v.normalTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
5011
|
-
}
|
|
5012
|
-
//
|
|
5013
|
-
if (!this.checkTextureUndef(v.occlusionTexture)) {
|
|
5014
|
-
console.error("Invalid material occlusionTexture " + v.occlusionTexture + ", " + this.stringify(v) + ".");
|
|
5015
|
-
}
|
|
5016
|
-
if (!this.checkNumber01Undef(v.occlusionTextureStrength)) {
|
|
5017
|
-
console.error("Invalid material occlusionTextureStrength " + v.occlusionTextureStrength + ", " + this.stringify(v) + ".");
|
|
5018
|
-
}
|
|
5019
|
-
if (!this.checkTexTransformUndef(v.occlusionTextureTransform)) {
|
|
5020
|
-
console.error("Invalid material occlusionTextureTransform " + v.occlusionTextureTransform + ", " + this.stringify(v) + ".");
|
|
5021
|
-
}
|
|
5022
|
-
if (!this.checkTexCoord(v.occlusionTextureCoordinate)) {
|
|
5023
|
-
console.error("Invalid material occlusionTextureCoordinate " + v.occlusionTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
5024
|
-
}
|
|
5025
|
-
//
|
|
5026
|
-
//
|
|
5027
|
-
if (!this.checkNonnegative4(v.emissiveFactor)) {
|
|
5028
|
-
console.error("Invalid material emissiveFactor " + v.emissiveFactor + ", " + this.stringify(v) + ".");
|
|
5029
|
-
}
|
|
5030
|
-
if (!this.checkNonnegative(v.emissiveIntensity)) {
|
|
5031
|
-
console.error("Invalid material emissiveIntensity " + v.emissiveIntensity + ", " + this.stringify(v) + ".");
|
|
5032
|
-
}
|
|
5033
|
-
if (!this.checkTextureUndef(v.emissiveTexture)) {
|
|
5034
|
-
console.error("Invalid material emissiveTexture " + v.emissiveTexture + ", " + this.stringify(v) + ".");
|
|
5035
|
-
}
|
|
5036
|
-
if (!this.checkTexTransformUndef(v.emissiveTextureTransform)) {
|
|
5037
|
-
console.error("Invalid material emissiveTextureTransform " + v.emissiveTextureTransform + ", " + this.stringify(v) + ".");
|
|
5038
|
-
}
|
|
5039
|
-
if (!this.checkTexCoord(v.emissiveTextureCoordinate)) {
|
|
5040
|
-
console.error("Invalid material emissiveTextureCoordinate " + v.emissiveTextureCoordinate + ", " + this.stringify(v) + ".");
|
|
5041
|
-
}
|
|
5042
|
-
//
|
|
5043
|
-
if (!this.checkBooleanUndef(v.depthMask)) {
|
|
5044
|
-
console.error("Invalid material depthMask " + v.depthMask + ", " + this.stringify(v) + ".");
|
|
5045
|
-
}
|
|
5046
|
-
if (!this.checkMatBlending(v.blending)) {
|
|
5047
|
-
console.error("Invalid material blending " + v.blending + ", " + this.stringify(v) + ".");
|
|
5048
|
-
}
|
|
5049
|
-
if (!this.checkMatSide(v.side)) {
|
|
5050
|
-
console.error("Invalid material side " + v.side + ", " + this.stringify(v) + ".");
|
|
5051
|
-
}
|
|
5052
|
-
if (v.blending === spec.MaterialBlending.masked) {
|
|
5053
|
-
if (v.alphaCutOff === undefined) {
|
|
5054
|
-
console.error("Material alphaCutOff is required for mask, " + this.stringify(v) + ".");
|
|
5055
|
-
}
|
|
5056
|
-
}
|
|
5057
|
-
if (!this.checkNumber01Undef(v.alphaCutOff)) {
|
|
5058
|
-
console.error("Invalid material alphaCutOff " + v.alphaCutOff + ", " + this.stringify(v) + ".");
|
|
5059
|
-
}
|
|
5060
|
-
} else {
|
|
5061
|
-
console.error("Invalid material type " + this.stringify(v) + ".");
|
|
5062
|
-
}
|
|
5063
|
-
};
|
|
5064
|
-
/**
|
|
5065
|
-
* 检查 Primitive 参数
|
|
5066
|
-
* @param v - Primitive 参数
|
|
5067
|
-
* @param s - 蒙皮参数
|
|
5068
|
-
* @returns
|
|
5069
|
-
*/ CheckerHelper.assertPrimOptions = function assertPrimOptions(v, s) {
|
|
5070
|
-
this.assertGeometry(v.geometry, s);
|
|
5071
|
-
this.assertMatOptions(v.material);
|
|
5072
|
-
return true;
|
|
5073
|
-
};
|
|
5074
|
-
/**
|
|
5075
|
-
* 检查 Model 插件 Mesh 参数
|
|
5076
|
-
* @param v - Model 插件 Mesh 参数
|
|
5077
|
-
*/ CheckerHelper.assertModelMeshOptions = function assertModelMeshOptions(v) {
|
|
5078
|
-
if (!this.checkParent(v.parent)) {
|
|
5079
|
-
console.error("Invalid mesh parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5080
|
-
}
|
|
5081
|
-
if (v.skin !== undefined) {
|
|
5082
|
-
this.assertModelSkinOptions(v.skin);
|
|
5083
|
-
}
|
|
5084
|
-
var morphList = [];
|
|
5085
|
-
for(var i = 0; i < v.primitives.length; i++){
|
|
5086
|
-
var prim = v.primitives[i];
|
|
5087
|
-
if (!this.assertPrimOptions(prim)) {
|
|
5088
|
-
console.error("Invalid primitive " + prim + ", " + this.stringify(v) + ".");
|
|
5089
|
-
}
|
|
5090
|
-
var morph = new PMorph();
|
|
5091
|
-
morph.create(prim.geometry);
|
|
5092
|
-
morphList.push(morph);
|
|
5093
|
-
}
|
|
5094
|
-
for(var i1 = 1; i1 < morphList.length; i1++){
|
|
5095
|
-
var morph0 = morphList[i1 - 1];
|
|
5096
|
-
var morph1 = morphList[i1];
|
|
5097
|
-
if (!morph0.equals(morph1)) {
|
|
5098
|
-
console.error("Morph states mismatch: " + this.stringify(morph0) + ", " + this.stringify(morph1) + ", " + this.stringify(v) + ".");
|
|
5099
|
-
}
|
|
5100
|
-
}
|
|
5101
|
-
if (!this.checkBooleanUndef(v.hide)) {
|
|
5102
|
-
console.error("Invalid mesh hide " + v.hide + ", " + this.stringify(v) + ".");
|
|
5103
|
-
}
|
|
5104
|
-
};
|
|
5105
|
-
/**
|
|
5106
|
-
* 检查 Model 插件相机参数
|
|
5107
|
-
* @param v - Model 插件相机参数
|
|
5108
|
-
*/ CheckerHelper.assertModelCameraOptions = function assertModelCameraOptions(v) {
|
|
5109
|
-
if (!this.checkParent(v.parent)) {
|
|
5110
|
-
console.error("Invalid camera parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5111
|
-
}
|
|
5112
|
-
if (!this.checkNumberUndef(v.aspect)) {
|
|
5113
|
-
console.error("Invalid camera aspect " + v.aspect + ", " + this.stringify(v) + ".");
|
|
5114
|
-
}
|
|
5115
|
-
if (!this.checkPositive(v.near)) {
|
|
5116
|
-
console.error("Invalid camera near " + v.near + ", " + this.stringify(v) + ".");
|
|
5117
|
-
}
|
|
5118
|
-
if (!this.checkPositive(v.far) || v.far <= v.near) {
|
|
5119
|
-
console.error("Invalid camera far " + v.far + ", " + this.stringify(v) + ".");
|
|
5120
|
-
}
|
|
5121
|
-
if (!this.checkPositive(v.fov)) {
|
|
5122
|
-
console.error("Invalid camera fov " + v.fov + ", " + this.stringify(v) + ".");
|
|
5123
|
-
}
|
|
5124
|
-
if (!this.checkNumber01(v.clipMode)) {
|
|
5125
|
-
console.error("Invalid camera clipMode " + v.clipMode + ", " + this.stringify(v) + ".");
|
|
5126
|
-
}
|
|
5127
|
-
};
|
|
5128
|
-
/**
|
|
5129
|
-
* 检查 Model 插件灯光参数
|
|
5130
|
-
* @param v - Model 插件灯光参数
|
|
5131
|
-
*/ CheckerHelper.assertModelLightOptions = function assertModelLightOptions(v) {
|
|
5132
|
-
if (v.lightType === "directional") {
|
|
5133
|
-
if (!this.checkParent(v.parent)) {
|
|
5134
|
-
console.error("Invalid light parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5135
|
-
}
|
|
5136
|
-
if (!this.checkNonnegative4(v.color)) {
|
|
5137
|
-
console.error("Invalid light color " + v.color + ", " + this.stringify(v) + ".");
|
|
5138
|
-
}
|
|
5139
|
-
if (!this.checkNonnegative(v.intensity)) {
|
|
5140
|
-
console.error("Invalid light intensity " + v.intensity + ", " + this.stringify(v) + ".");
|
|
5141
|
-
}
|
|
5142
|
-
} else if (v.lightType === "point") {
|
|
5143
|
-
if (!this.checkParent(v.parent)) {
|
|
5144
|
-
console.error("Invalid light parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5145
|
-
}
|
|
5146
|
-
if (!this.checkNonnegative4(v.color)) {
|
|
5147
|
-
console.error("Invalid light color " + v.color + ", " + this.stringify(v) + ".");
|
|
5148
|
-
}
|
|
5149
|
-
if (!this.checkNonnegative(v.intensity)) {
|
|
5150
|
-
console.error("Invalid light intensity " + v.intensity + ", " + this.stringify(v) + ".");
|
|
5151
|
-
}
|
|
5152
|
-
if (!this.checkNonnegative(v.range)) {
|
|
5153
|
-
console.error("Invalid light range " + v.range + ", " + this.stringify(v) + ".");
|
|
5154
|
-
}
|
|
5155
|
-
} else if (v.lightType === "spot") {
|
|
5156
|
-
if (!this.checkParent(v.parent)) {
|
|
5157
|
-
console.error("Invalid light parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5158
|
-
}
|
|
5159
|
-
if (!this.checkNonnegative4(v.color)) {
|
|
5160
|
-
console.error("Invalid light color " + v.color + ", " + this.stringify(v) + ".");
|
|
5161
|
-
}
|
|
5162
|
-
if (!this.checkNonnegative(v.intensity)) {
|
|
5163
|
-
console.error("Invalid light intensity " + v.intensity + ", " + this.stringify(v) + ".");
|
|
5164
|
-
}
|
|
5165
|
-
if (!this.checkNonnegative(v.range)) {
|
|
5166
|
-
console.error("Invalid light range " + v.range + ", " + this.stringify(v) + ".");
|
|
5167
|
-
}
|
|
5168
|
-
if (!this.checkNonnegative(v.innerConeAngle)) {
|
|
5169
|
-
console.error("Invalid light innerConeAngle " + v.innerConeAngle + ", " + this.stringify(v) + ".");
|
|
5170
|
-
}
|
|
5171
|
-
if (!this.checkNonnegative(v.outerConeAngle)) {
|
|
5172
|
-
console.error("Invalid light outerConeAngle " + v.outerConeAngle + ", " + this.stringify(v) + ".");
|
|
5173
|
-
}
|
|
5174
|
-
} else if (v.lightType === "ambient") {
|
|
5175
|
-
if (!this.checkParent(v.parent)) {
|
|
5176
|
-
console.error("Invalid light parent " + v.parent + ", " + this.stringify(v) + ".");
|
|
5177
|
-
}
|
|
5178
|
-
if (!this.checkNonnegative4(v.color)) {
|
|
5179
|
-
console.error("Invalid light color " + v.color + ", " + this.stringify(v) + ".");
|
|
5180
|
-
}
|
|
5181
|
-
if (!this.checkNonnegative(v.intensity)) {
|
|
5182
|
-
console.error("Invalid light intensity " + v.intensity + ", " + this.stringify(v) + ".");
|
|
5183
|
-
}
|
|
5184
|
-
} else {
|
|
5185
|
-
console.error("Invalid light type " + this.stringify(v) + ".");
|
|
5186
|
-
}
|
|
5187
|
-
};
|
|
5188
|
-
/**
|
|
5189
|
-
* 检查 Model 插件天空盒参数
|
|
5190
|
-
* @param v - Model 插件天空盒参数
|
|
5191
|
-
*/ CheckerHelper.assertModelSkyboxOptions = function assertModelSkyboxOptions(v) {
|
|
5192
|
-
var _this = this;
|
|
5193
|
-
if (!this.checkBoolean(v.renderable)) {
|
|
5194
|
-
console.error("Invalid skybox renderable " + v.renderable + ", " + this.stringify(v) + ".");
|
|
5195
|
-
}
|
|
5196
|
-
if (!this.checkNonnegative(v.intensity)) {
|
|
5197
|
-
console.error("Invalid skybox intensity " + v.intensity + ", " + this.stringify(v) + ".");
|
|
5198
|
-
}
|
|
5199
|
-
if (!this.checkNonnegative(v.reflectionsIntensity)) {
|
|
5200
|
-
console.error("Invalid skybox reflectionsIntensity " + v.reflectionsIntensity + ", " + this.stringify(v) + ".");
|
|
5201
|
-
}
|
|
5202
|
-
//
|
|
5203
|
-
var c = v.irradianceCoeffs;
|
|
5204
|
-
if (c !== undefined) {
|
|
5205
|
-
if (!Array.isArray(c) || c.length != 9) {
|
|
5206
|
-
console.error("Invalid skybox irradianceCoeffs " + c + ", " + this.stringify(v) + ".");
|
|
5207
|
-
}
|
|
5208
|
-
c.forEach(function(v) {
|
|
5209
|
-
if (!_this.checkVec3(v)) {
|
|
5210
|
-
console.error("Invalid skybox irradianceCoeffs " + c + ", " + _this.stringify(v) + ".");
|
|
5211
|
-
}
|
|
5212
|
-
});
|
|
5213
|
-
} else if (v.diffuseImage !== undefined) {
|
|
5214
|
-
if (!this.checkTexture(v.diffuseImage)) {
|
|
5215
|
-
console.error("Invalid skybox diffuseImage " + v.diffuseImage + ", " + this.stringify(v) + ".");
|
|
5216
|
-
}
|
|
5217
|
-
} else {
|
|
5218
|
-
console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, " + this.stringify(v) + ".");
|
|
5219
|
-
}
|
|
5220
|
-
if (!this.checkTexture(v.specularImage)) {
|
|
5221
|
-
console.error("Invalid skybox specularImage " + v.specularImage + ", " + this.stringify(v) + ".");
|
|
5222
|
-
}
|
|
5223
|
-
if (!this.checkPositive(v.specularImageSize)) {
|
|
5224
|
-
console.error("Invalid skybox specularImageSize " + v.specularImageSize + ", " + this.stringify(v) + ".");
|
|
5225
|
-
}
|
|
5226
|
-
if (!this.checkPositive(v.specularMipCount)) {
|
|
5227
|
-
console.error("Invalid skybox specularMipCount " + v.specularMipCount + ", " + this.stringify(v) + ".");
|
|
5228
|
-
}
|
|
5229
|
-
if (this.pow2(v.specularMipCount) > v.specularImageSize) {
|
|
5230
|
-
console.error("Invalid skybox specularMipCount or specularImageSize, " + this.stringify(v) + ".");
|
|
5231
|
-
}
|
|
5232
|
-
};
|
|
5233
|
-
/**
|
|
5234
|
-
* 检查 Model 插件动画轨道参数
|
|
5235
|
-
* @param v - Model 插件动画轨道参数
|
|
5236
|
-
* @returns
|
|
5237
|
-
*/ CheckerHelper.checkModelAnimTrackOptions = function checkModelAnimTrackOptions(v) {
|
|
5238
|
-
if (!this.checkNonnegative(v.node)) {
|
|
5239
|
-
console.error("Invalid track node " + v.node + ", " + this.stringify(v));
|
|
5240
|
-
return false;
|
|
5241
|
-
}
|
|
5242
|
-
if (!this.checkFloat32Array(v.input)) {
|
|
5243
|
-
console.error("Invalid track input " + v.input + ", " + this.stringify(v));
|
|
5244
|
-
return false;
|
|
5245
|
-
}
|
|
5246
|
-
if (!this.checkFloat32Array(v.output)) {
|
|
5247
|
-
console.error("Invalid track input " + v.output + ", " + this.stringify(v));
|
|
5248
|
-
return false;
|
|
5249
|
-
}
|
|
5250
|
-
if (!this.checkAnimPath(v.path)) {
|
|
5251
|
-
console.error("Invalid track path " + v.path + ", " + this.stringify(v));
|
|
5252
|
-
return false;
|
|
5253
|
-
}
|
|
5254
|
-
if (!this.checkAnimInterp(v.interpolation)) {
|
|
5255
|
-
console.error("Invalid track interpolation " + v.interpolation + ", " + this.stringify(v));
|
|
5256
|
-
return false;
|
|
5257
|
-
}
|
|
5258
|
-
return true;
|
|
5259
|
-
};
|
|
5260
|
-
/**
|
|
5261
|
-
* 检查 Model 插件动画参数
|
|
5262
|
-
* @param v - Model 插件动画参数
|
|
5263
|
-
*/ CheckerHelper.assertModelAnimOptions = function assertModelAnimOptions(v) {
|
|
5264
|
-
var _this = this;
|
|
5265
|
-
if (!this.checkStringUndef(v.name)) {
|
|
5266
|
-
console.error("Invalid animation name " + v.name + ", " + this.stringify(v) + ".");
|
|
5267
|
-
}
|
|
5268
|
-
if (!Array.isArray(v.tracks)) {
|
|
5269
|
-
console.error("Invalid animation tracks " + v.tracks + ", " + this.stringify(v) + ".");
|
|
5270
|
-
}
|
|
5271
|
-
v.tracks.forEach(function(t) {
|
|
5272
|
-
if (!_this.checkModelAnimTrackOptions(t)) {
|
|
5273
|
-
console.error("Invalid animation track " + t + ", " + _this.stringify(v) + ".");
|
|
5274
|
-
}
|
|
5275
|
-
});
|
|
5276
|
-
};
|
|
5277
|
-
/**
|
|
5278
|
-
* 检查场景树参数
|
|
5279
|
-
* @param v - 场景树参数
|
|
5280
|
-
*/ CheckerHelper.assertTreeOptions = function assertTreeOptions(v) {
|
|
5281
|
-
var _this = this;
|
|
5282
|
-
if (!this.checkNumberUndef(v.animation)) {
|
|
5283
|
-
console.error("Invalid tree animation " + v.animation + ", " + this.stringify(v) + ".");
|
|
5284
|
-
}
|
|
5285
|
-
if (v.animations !== undefined) {
|
|
5286
|
-
if (!Array.isArray(v.animations)) {
|
|
5287
|
-
console.error("Invalid tree animations " + v.animations + ", " + this.stringify(v) + ".");
|
|
5288
|
-
}
|
|
5289
|
-
v.animations.forEach(function(anim) {
|
|
5290
|
-
_this.assertModelAnimOptions(anim);
|
|
5291
|
-
});
|
|
5292
|
-
if (v.animation !== undefined) {
|
|
5293
|
-
if (v.animation < -1 || v.animation >= v.animations.length) {
|
|
5294
|
-
console.error("Invalid tree animations " + v.animations + ", " + this.stringify(v) + ".");
|
|
5295
|
-
}
|
|
5296
|
-
}
|
|
5297
|
-
}
|
|
5298
|
-
};
|
|
5299
|
-
/**
|
|
5300
|
-
* 将对象转成 JSON 字符串,需要忽略函数和渲染相关的对象
|
|
5301
|
-
* @param object - 目标对象
|
|
5302
|
-
* @returns
|
|
5303
|
-
*/ CheckerHelper.stringify = function stringify(object) {
|
|
5304
|
-
var simpleObject = {};
|
|
5305
|
-
for(var prop in object){
|
|
5306
|
-
// if (typeof(object[prop]) == 'object'){
|
|
5307
|
-
// continue;
|
|
5308
|
-
// }
|
|
5309
|
-
if (prop === "internal") {
|
|
5310
|
-
continue;
|
|
5311
|
-
}
|
|
5312
|
-
if (typeof object[prop] == "function") {
|
|
5313
|
-
continue;
|
|
5314
|
-
}
|
|
5315
|
-
if (_instanceof1(object[prop], Texture)) {
|
|
5316
|
-
simpleObject[prop] = object[prop].name;
|
|
5317
|
-
continue;
|
|
5318
|
-
}
|
|
5319
|
-
if (_instanceof1(object[prop], Geometry)) {
|
|
5320
|
-
simpleObject[prop] = object[prop].name;
|
|
5321
|
-
continue;
|
|
5322
|
-
}
|
|
5323
|
-
if (_instanceof1(object[prop], Renderer)) {
|
|
5324
|
-
continue;
|
|
5325
|
-
}
|
|
5326
|
-
simpleObject[prop] = object[prop];
|
|
5327
|
-
}
|
|
5328
|
-
return JSON.stringify(simpleObject);
|
|
5329
|
-
};
|
|
5330
|
-
/**
|
|
5331
|
-
* 获取 2 的 index 指数结果
|
|
5332
|
-
* @param index - 指数
|
|
5333
|
-
* @returns
|
|
5334
|
-
*/ CheckerHelper.pow2 = function pow2(index) {
|
|
5335
|
-
var res = 1;
|
|
5336
|
-
while(index-- > 0){
|
|
5337
|
-
res *= 2;
|
|
5338
|
-
}
|
|
5339
|
-
return res;
|
|
5340
|
-
};
|
|
5341
|
-
return CheckerHelper;
|
|
5342
|
-
}();
|
|
5343
4404
|
/**
|
|
5344
4405
|
* 半精度浮点数组类
|
|
5345
4406
|
*/ var Float16ArrayWrapper = /*#__PURE__*/ function() {
|