@galacean/effects-plugin-model 0.0.1-alpha.0 → 0.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/dist/gltf/loader-ext.d.ts +1 -5
- package/dist/gltf/loader-helper.d.ts +3 -3
- package/dist/gltf/loader-impl.d.ts +16 -16
- package/dist/gltf/protocol.d.ts +14 -14
- package/dist/index.d.ts +29 -29
- package/dist/index.js +205 -205
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +203 -203
- package/dist/loader.mjs +134 -134
- package/dist/plugin/model-tree-item.d.ts +2 -2
- package/dist/plugin/model-tree-vfx-item.d.ts +3 -3
- package/dist/plugin/model-vfx-item.d.ts +4 -4
- package/dist/runtime/animation.d.ts +8 -9
- package/dist/runtime/cache.d.ts +3 -3
- package/dist/runtime/camera.d.ts +3 -3
- package/dist/runtime/common.d.ts +3 -3
- package/dist/runtime/light.d.ts +3 -3
- package/dist/runtime/material.d.ts +4 -4
- package/dist/runtime/mesh.d.ts +11 -11
- package/dist/runtime/scene.d.ts +3 -3
- package/dist/runtime/skybox.d.ts +3 -3
- package/dist/utility/hit-test-helper.d.ts +2 -2
- package/dist/utility/plugin-helper.d.ts +25 -25
- package/package.json +4 -4
package/dist/loader.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v0.0.1-alpha.
|
|
6
|
+
* Version: v0.0.1-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { Transform, spec, PLAYER_OPTIONS_ENV_EDITOR, glContext, TextureSourceType, Texture, RenderPass, TextureLoadAction, DestroyOptions, RenderPassDestroyAttachmentType, DEG2RAD, Geometry, Renderer, Mesh, getDefaultTextureFactory, Player, loadImage } from '@galacean/effects';
|
|
@@ -5853,7 +5853,7 @@ var LoaderHelper = /** @class */ (function () {
|
|
|
5853
5853
|
scale: transform.scale.xyz,
|
|
5854
5854
|
};
|
|
5855
5855
|
};
|
|
5856
|
-
LoaderHelper.
|
|
5856
|
+
LoaderHelper.getEffectsTransformFromMat4 = function (mat) {
|
|
5857
5857
|
var transform = new Transform({
|
|
5858
5858
|
valid: true,
|
|
5859
5859
|
});
|
|
@@ -5882,7 +5882,7 @@ var LoaderHelper = /** @class */ (function () {
|
|
|
5882
5882
|
var mat = Matrix4.IDENTITY.clone().rotate(c, a);
|
|
5883
5883
|
return LoaderHelper.getTransformFromMat4(mat);
|
|
5884
5884
|
};
|
|
5885
|
-
LoaderHelper.
|
|
5885
|
+
LoaderHelper.getEffectsTransformFromDirection = function (d) {
|
|
5886
5886
|
var d0 = Vector3.fromArray([0, 0, 1]);
|
|
5887
5887
|
var d1 = d.clone().normalize();
|
|
5888
5888
|
var a = Vector3.cross(d0, d1);
|
|
@@ -5893,15 +5893,15 @@ var LoaderHelper = /** @class */ (function () {
|
|
|
5893
5893
|
var b = Vector3.dot(d1, d0);
|
|
5894
5894
|
var c = Math.acos(b);
|
|
5895
5895
|
var mat = Matrix4.IDENTITY.clone().rotate(c, a);
|
|
5896
|
-
return LoaderHelper.
|
|
5896
|
+
return LoaderHelper.getEffectsTransformFromMat4(mat);
|
|
5897
5897
|
};
|
|
5898
5898
|
LoaderHelper.getTransformFromTransDir = function (t, d) {
|
|
5899
5899
|
var transform = LoaderHelper.getTransformFromDirection(d);
|
|
5900
5900
|
transform.position = t.xyz;
|
|
5901
5901
|
return transform;
|
|
5902
5902
|
};
|
|
5903
|
-
LoaderHelper.
|
|
5904
|
-
var transform = LoaderHelper.
|
|
5903
|
+
LoaderHelper.getEffectsTransformFromTransDir = function (t, d) {
|
|
5904
|
+
var transform = LoaderHelper.getEffectsTransformFromDirection(d);
|
|
5905
5905
|
transform.position = t.xyz;
|
|
5906
5906
|
return transform;
|
|
5907
5907
|
};
|
|
@@ -6194,18 +6194,18 @@ var PTransform = /** @class */ (function () {
|
|
|
6194
6194
|
this.setMatrix(matrix);
|
|
6195
6195
|
return this;
|
|
6196
6196
|
};
|
|
6197
|
-
PTransform.prototype.
|
|
6197
|
+
PTransform.prototype.fromEffectsTransform = function (trans) {
|
|
6198
6198
|
if (trans instanceof Transform) {
|
|
6199
6199
|
this.setMatrix(trans.getWorldMatrix());
|
|
6200
6200
|
}
|
|
6201
6201
|
else {
|
|
6202
|
-
var
|
|
6203
|
-
|
|
6204
|
-
this.setMatrix(
|
|
6202
|
+
var effectsTrans = new Transform(__assign(__assign({}, trans), { valid: true }));
|
|
6203
|
+
effectsTrans.setValid(true);
|
|
6204
|
+
this.setMatrix(effectsTrans.getWorldMatrix());
|
|
6205
6205
|
}
|
|
6206
6206
|
return this;
|
|
6207
6207
|
};
|
|
6208
|
-
PTransform.prototype.
|
|
6208
|
+
PTransform.prototype.toEffectsTransform = function (transform) {
|
|
6209
6209
|
var mat = this.getMatrix();
|
|
6210
6210
|
transform.cloneFromMatrix(mat.toArray());
|
|
6211
6211
|
return transform;
|
|
@@ -6974,7 +6974,7 @@ var PMorph = /** @class */ (function (_super) {
|
|
|
6974
6974
|
return _this;
|
|
6975
6975
|
}
|
|
6976
6976
|
/**
|
|
6977
|
-
* 通过
|
|
6977
|
+
* 通过 Geometry 数据创建 Morph 动画相关状态,并进行必要的正确性检查
|
|
6978
6978
|
*
|
|
6979
6979
|
* @param geometry - Mesh 的几何对象,是否包含 Morph 动画都是可以的
|
|
6980
6980
|
*/
|
|
@@ -7078,7 +7078,7 @@ var PMorph = /** @class */ (function (_super) {
|
|
|
7078
7078
|
* 主要用于统计 Morph 动画中新增的 Attribute 名称的个数,会作为最终的 weights 数组长度使用
|
|
7079
7079
|
*
|
|
7080
7080
|
* @param attributeNameList - Attribute 名数组列表,只与 Morph Target 中的属性有关
|
|
7081
|
-
* @param geometry -
|
|
7081
|
+
* @param geometry - Geometry 对象,是否有 Morph 动画都可以
|
|
7082
7082
|
* @returns 存在的 Attribute 名称数目
|
|
7083
7083
|
*/
|
|
7084
7084
|
PMorph.prototype.getAttributeMorphCount = function (attributeNameList, geometry) {
|
|
@@ -7245,7 +7245,6 @@ var PAnimTrack = /** @class */ (function () {
|
|
|
7245
7245
|
};
|
|
7246
7246
|
/**
|
|
7247
7247
|
* 生成 Mesh 元素的父节点
|
|
7248
|
-
* 为 Mesh 元素生成 Mars 中的父节点,这里是和燃燃确定的生成方式
|
|
7249
7248
|
*
|
|
7250
7249
|
* @param parentId - 父节点 id 名称
|
|
7251
7250
|
* @param nodeIndex - Mesh 节点索引
|
|
@@ -7390,10 +7389,10 @@ var PAnimation = /** @class */ (function (_super) {
|
|
|
7390
7389
|
return PAnimationManager;
|
|
7391
7390
|
})(PObject));
|
|
7392
7391
|
|
|
7393
|
-
var
|
|
7394
|
-
function
|
|
7392
|
+
var WebGLHelper = /** @class */ (function () {
|
|
7393
|
+
function WebGLHelper() {
|
|
7395
7394
|
}
|
|
7396
|
-
|
|
7395
|
+
WebGLHelper.createTexture2D = function (engine, image, texture, isBaseColor, tiny3dMode) {
|
|
7397
7396
|
return __awaiter(this, void 0, void 0, function () {
|
|
7398
7397
|
var blob, urlCreator, imageUrl, imageObj;
|
|
7399
7398
|
return __generator(this, function (_a) {
|
|
@@ -7425,7 +7424,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7425
7424
|
// || minFilter === glContext.LINEAR_MIPMAP_NEAREST) {
|
|
7426
7425
|
minFilter = glContext.LINEAR_MIPMAP_LINEAR;
|
|
7427
7426
|
//}
|
|
7428
|
-
if (!
|
|
7427
|
+
if (!WebGLHelper.isPow2(imageObj.width) || !WebGLHelper.isPow2(imageObj.height)) {
|
|
7429
7428
|
minFilter = glContext.LINEAR;
|
|
7430
7429
|
}
|
|
7431
7430
|
//
|
|
@@ -7459,7 +7458,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7459
7458
|
});
|
|
7460
7459
|
});
|
|
7461
7460
|
};
|
|
7462
|
-
|
|
7461
|
+
WebGLHelper.createTextureList = function (engine, images, textures) {
|
|
7463
7462
|
return __awaiter(this, void 0, void 0, function () {
|
|
7464
7463
|
var outTextures;
|
|
7465
7464
|
var _this = this;
|
|
@@ -7475,7 +7474,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7475
7474
|
});
|
|
7476
7475
|
});
|
|
7477
7476
|
};
|
|
7478
|
-
|
|
7477
|
+
WebGLHelper.getTextureCubeData = function (images) {
|
|
7479
7478
|
return __awaiter(this, void 0, void 0, function () {
|
|
7480
7479
|
var cubeData, _a;
|
|
7481
7480
|
return __generator(this, function (_b) {
|
|
@@ -7515,7 +7514,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7515
7514
|
});
|
|
7516
7515
|
});
|
|
7517
7516
|
};
|
|
7518
|
-
|
|
7517
|
+
WebGLHelper.getTextureCubeMipmapData = function (images) {
|
|
7519
7518
|
return __awaiter(this, void 0, void 0, function () {
|
|
7520
7519
|
var mipmaps, i, _a, _b;
|
|
7521
7520
|
return __generator(this, function (_c) {
|
|
@@ -7539,7 +7538,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7539
7538
|
});
|
|
7540
7539
|
});
|
|
7541
7540
|
};
|
|
7542
|
-
|
|
7541
|
+
WebGLHelper.createTextureCubeFromURL = function (engine, cubeImage) {
|
|
7543
7542
|
return __awaiter(this, void 0, void 0, function () {
|
|
7544
7543
|
var textureOptions;
|
|
7545
7544
|
return __generator(this, function (_a) {
|
|
@@ -7556,7 +7555,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7556
7555
|
});
|
|
7557
7556
|
});
|
|
7558
7557
|
};
|
|
7559
|
-
|
|
7558
|
+
WebGLHelper.createTextureCubeMipmapFromURL = function (engine, cubeImages) {
|
|
7560
7559
|
return __awaiter(this, void 0, void 0, function () {
|
|
7561
7560
|
var textureOptions;
|
|
7562
7561
|
return __generator(this, function (_a) {
|
|
@@ -7573,12 +7572,12 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7573
7572
|
});
|
|
7574
7573
|
});
|
|
7575
7574
|
};
|
|
7576
|
-
|
|
7575
|
+
WebGLHelper.createTextureCubeFromBuffer = function (engine, cubeImages) {
|
|
7577
7576
|
return __awaiter(this, void 0, void 0, function () {
|
|
7578
7577
|
var cubemap;
|
|
7579
7578
|
return __generator(this, function (_a) {
|
|
7580
7579
|
switch (_a.label) {
|
|
7581
|
-
case 0: return [4 /*yield*/,
|
|
7580
|
+
case 0: return [4 /*yield*/, WebGLHelper.getTextureCubeData(cubeImages)];
|
|
7582
7581
|
case 1:
|
|
7583
7582
|
cubemap = _a.sent();
|
|
7584
7583
|
return [2 /*return*/, Texture.create(engine, __assign({ name: 'createTextureCubeFromBuffer', sourceType: TextureSourceType.image, cube: cubemap, target: glContext.TEXTURE_CUBE_MAP }, this.cubemapTexConfig))];
|
|
@@ -7586,12 +7585,12 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7586
7585
|
});
|
|
7587
7586
|
});
|
|
7588
7587
|
};
|
|
7589
|
-
|
|
7588
|
+
WebGLHelper.createTextureCubeMipmapFromBuffer = function (engine, cubeImages, level0Size) {
|
|
7590
7589
|
return __awaiter(this, void 0, void 0, function () {
|
|
7591
7590
|
var mipmaps, mipCount, index, url, imageData;
|
|
7592
7591
|
return __generator(this, function (_a) {
|
|
7593
7592
|
switch (_a.label) {
|
|
7594
|
-
case 0: return [4 /*yield*/,
|
|
7593
|
+
case 0: return [4 /*yield*/, WebGLHelper.getTextureCubeMipmapData(cubeImages)];
|
|
7595
7594
|
case 1:
|
|
7596
7595
|
mipmaps = _a.sent();
|
|
7597
7596
|
mipCount = 0;
|
|
@@ -7613,7 +7612,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7613
7612
|
});
|
|
7614
7613
|
});
|
|
7615
7614
|
};
|
|
7616
|
-
|
|
7615
|
+
WebGLHelper.getTexture = function (index, textures) {
|
|
7617
7616
|
if (index < 0 || index >= textures.length) {
|
|
7618
7617
|
return undefined;
|
|
7619
7618
|
}
|
|
@@ -7621,7 +7620,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7621
7620
|
return textures[index];
|
|
7622
7621
|
}
|
|
7623
7622
|
};
|
|
7624
|
-
|
|
7623
|
+
WebGLHelper.createTextureFromImage = function (engine, image) {
|
|
7625
7624
|
var options = {
|
|
7626
7625
|
name: 'createTextureFromImage',
|
|
7627
7626
|
image: image,
|
|
@@ -7634,7 +7633,7 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7634
7633
|
};
|
|
7635
7634
|
return Texture.create(engine, options);
|
|
7636
7635
|
};
|
|
7637
|
-
|
|
7636
|
+
WebGLHelper.createRenderPass = function (renderer, name, priority, meshData, fboOpts) {
|
|
7638
7637
|
var meshList = meshData instanceof Mesh ? [meshData] : meshData;
|
|
7639
7638
|
return new RenderPass(renderer, {
|
|
7640
7639
|
name: name,
|
|
@@ -7655,10 +7654,10 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7655
7654
|
viewport: fboOpts.viewport,
|
|
7656
7655
|
});
|
|
7657
7656
|
};
|
|
7658
|
-
|
|
7657
|
+
WebGLHelper.deleteTexture = function (texture) {
|
|
7659
7658
|
texture.dispose();
|
|
7660
7659
|
};
|
|
7661
|
-
|
|
7660
|
+
WebGLHelper.deleteMesh = function (mesh) {
|
|
7662
7661
|
mesh.dispose({
|
|
7663
7662
|
geometries: DestroyOptions.destroy,
|
|
7664
7663
|
material: {
|
|
@@ -7666,10 +7665,10 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7666
7665
|
},
|
|
7667
7666
|
});
|
|
7668
7667
|
};
|
|
7669
|
-
|
|
7668
|
+
WebGLHelper.deleteGeometry = function (geometry) {
|
|
7670
7669
|
geometry.dispose();
|
|
7671
7670
|
};
|
|
7672
|
-
|
|
7671
|
+
WebGLHelper.deleteRenderPass = function (pass) {
|
|
7673
7672
|
pass.dispose({
|
|
7674
7673
|
meshes: {
|
|
7675
7674
|
geometries: DestroyOptions.destroy,
|
|
@@ -7688,14 +7687,14 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7688
7687
|
* @param mesh - gl mesh 对象
|
|
7689
7688
|
* @return 是否半透明
|
|
7690
7689
|
*/
|
|
7691
|
-
|
|
7690
|
+
WebGLHelper.isTransparentMesh = function (mesh) {
|
|
7692
7691
|
return mesh.material.blending === true;
|
|
7693
7692
|
};
|
|
7694
7693
|
/**
|
|
7695
7694
|
* renderer 是否支持 Float 纹理
|
|
7696
7695
|
* @returns
|
|
7697
7696
|
*/
|
|
7698
|
-
|
|
7697
|
+
WebGLHelper.isSupportFloatTexture = function (engine) {
|
|
7699
7698
|
var capability = engine.gpuCapability;
|
|
7700
7699
|
return capability.detail.floatTexture !== 0;
|
|
7701
7700
|
};
|
|
@@ -7703,27 +7702,27 @@ var MarsRIHelper = /** @class */ (function () {
|
|
|
7703
7702
|
* renderer 是否支持 HalfFloat 纹理
|
|
7704
7703
|
* @returns
|
|
7705
7704
|
*/
|
|
7706
|
-
|
|
7705
|
+
WebGLHelper.isSupportHalfFloatTexture = function (engine) {
|
|
7707
7706
|
var capability = engine.gpuCapability;
|
|
7708
7707
|
return capability.detail.halfFloatTexture !== 0;
|
|
7709
7708
|
};
|
|
7710
|
-
|
|
7709
|
+
WebGLHelper.isPow2 = function (v) {
|
|
7711
7710
|
return !(v & (v - 1)) && (!!v);
|
|
7712
7711
|
};
|
|
7713
|
-
|
|
7712
|
+
WebGLHelper.cubemapTexConfig = {
|
|
7714
7713
|
name: 'cubemap texture',
|
|
7715
7714
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
7716
7715
|
wrapT: glContext.CLAMP_TO_EDGE,
|
|
7717
7716
|
magFilter: glContext.LINEAR,
|
|
7718
7717
|
minFilter: glContext.LINEAR,
|
|
7719
7718
|
};
|
|
7720
|
-
|
|
7719
|
+
WebGLHelper.cubemapMipTexConfig = {
|
|
7721
7720
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
7722
7721
|
wrapT: glContext.CLAMP_TO_EDGE,
|
|
7723
7722
|
magFilter: glContext.LINEAR,
|
|
7724
7723
|
minFilter: glContext.LINEAR_MIPMAP_LINEAR,
|
|
7725
7724
|
};
|
|
7726
|
-
return
|
|
7725
|
+
return WebGLHelper;
|
|
7727
7726
|
}());
|
|
7728
7727
|
var PluginHelper = /** @class */ (function () {
|
|
7729
7728
|
function PluginHelper() {
|
|
@@ -7866,12 +7865,12 @@ var PluginHelper = /** @class */ (function () {
|
|
|
7866
7865
|
rotationMat.multiplyByPoint3(deltaPos);
|
|
7867
7866
|
var newCamPos = deltaPos.clone().addVector(targetPos);
|
|
7868
7867
|
var viewMatrix = new Matrix4().lookAt(newCamPos, targetPos, new Vector3(0, 1, 0)).inverse();
|
|
7869
|
-
var
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
return
|
|
7868
|
+
var effectsTransform = new Transform();
|
|
7869
|
+
effectsTransform.setValid(true);
|
|
7870
|
+
effectsTransform.cloneFromMatrix(viewMatrix.toArray());
|
|
7871
|
+
return effectsTransform;
|
|
7873
7872
|
};
|
|
7874
|
-
PluginHelper.
|
|
7873
|
+
PluginHelper.preprocessEffectsScene = function (scene, runtimeEnv, compatibleMode, autoAdjustScene) {
|
|
7875
7874
|
var _this = this;
|
|
7876
7875
|
var deviceEnv = (runtimeEnv !== PLAYER_OPTIONS_ENV_EDITOR);
|
|
7877
7876
|
var tiny3dMode = (compatibleMode === 'tiny3d');
|
|
@@ -8192,7 +8191,8 @@ var WebHelper = /** @class */ (function () {
|
|
|
8192
8191
|
a.href = url;
|
|
8193
8192
|
a.click();
|
|
8194
8193
|
};
|
|
8195
|
-
WebHelper.createPlayer = function () {
|
|
8194
|
+
WebHelper.createPlayer = function (manualRender) {
|
|
8195
|
+
if (manualRender === void 0) { manualRender = true; }
|
|
8196
8196
|
var canvas = document.createElement('canvas');
|
|
8197
8197
|
canvas.width = 512;
|
|
8198
8198
|
canvas.height = 512;
|
|
@@ -8201,7 +8201,7 @@ var WebHelper = /** @class */ (function () {
|
|
|
8201
8201
|
renderFramework: 'webgl2',
|
|
8202
8202
|
env: PLAYER_OPTIONS_ENV_EDITOR,
|
|
8203
8203
|
willCaptureImage: true,
|
|
8204
|
-
manualRender:
|
|
8204
|
+
manualRender: manualRender,
|
|
8205
8205
|
});
|
|
8206
8206
|
};
|
|
8207
8207
|
WebHelper.sleep = function (ms) {
|
|
@@ -8512,7 +8512,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8512
8512
|
CheckerHelper.checkTextureUndef = function (v) {
|
|
8513
8513
|
return v === undefined ? true : this.checkTexture(v);
|
|
8514
8514
|
};
|
|
8515
|
-
CheckerHelper.
|
|
8515
|
+
CheckerHelper.checkTexTransform = function (v) {
|
|
8516
8516
|
if (!this.checkVec2Undef(v.offset)) {
|
|
8517
8517
|
return false;
|
|
8518
8518
|
}
|
|
@@ -8530,17 +8530,17 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8530
8530
|
}
|
|
8531
8531
|
return true;
|
|
8532
8532
|
};
|
|
8533
|
-
CheckerHelper.
|
|
8534
|
-
return v === undefined ? true : this.
|
|
8533
|
+
CheckerHelper.checkTexTransformUndef = function (v) {
|
|
8534
|
+
return v === undefined ? true : this.checkTexTransform(v);
|
|
8535
8535
|
};
|
|
8536
|
-
CheckerHelper.
|
|
8536
|
+
CheckerHelper.checkMatBlending = function (v) {
|
|
8537
8537
|
return v === undefined
|
|
8538
8538
|
|| v === spec.MaterialBlending.opaque
|
|
8539
8539
|
|| v === spec.MaterialBlending.masked
|
|
8540
8540
|
|| v === spec.MaterialBlending.translucent
|
|
8541
8541
|
|| v === spec.MaterialBlending.additive;
|
|
8542
8542
|
};
|
|
8543
|
-
CheckerHelper.
|
|
8543
|
+
CheckerHelper.checkMatSide = function (v) {
|
|
8544
8544
|
return v === undefined || v === spec.SideMode.BACK || v === spec.SideMode.DOUBLE || v === spec.SideMode.FRONT;
|
|
8545
8545
|
};
|
|
8546
8546
|
CheckerHelper.checkAnimPath = function (v) {
|
|
@@ -8635,7 +8635,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8635
8635
|
attribArray.create(dataAttrib, dataArray);
|
|
8636
8636
|
return attribArray;
|
|
8637
8637
|
};
|
|
8638
|
-
CheckerHelper.
|
|
8638
|
+
CheckerHelper.assertModelSkinOptions = function (v) {
|
|
8639
8639
|
if (!this.checkStringUndef(v.name)) {
|
|
8640
8640
|
console.error("Invalid skin name ".concat(v.name, ", ").concat(this.stringify(v)));
|
|
8641
8641
|
}
|
|
@@ -8672,7 +8672,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8672
8672
|
}
|
|
8673
8673
|
}
|
|
8674
8674
|
};
|
|
8675
|
-
CheckerHelper.
|
|
8675
|
+
CheckerHelper.assertMatOptions = function (v) {
|
|
8676
8676
|
if (v.type === spec.MaterialType.unlit) {
|
|
8677
8677
|
if (!this.checkString(v.name)) {
|
|
8678
8678
|
console.error("Invalid material name ".concat(v.name, ", ").concat(this.stringify(v)));
|
|
@@ -8684,7 +8684,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8684
8684
|
if (!this.checkTextureUndef(v.baseColorTexture)) {
|
|
8685
8685
|
console.error("Invalid material baseColorTexture ".concat(v.baseColorTexture, ", ").concat(this.stringify(v)));
|
|
8686
8686
|
}
|
|
8687
|
-
if (!this.
|
|
8687
|
+
if (!this.checkTexTransformUndef(v.baseColorTextureTransform)) {
|
|
8688
8688
|
console.error("Invalid material baseColorTextureTransform ".concat(v.baseColorTextureTransform, ", ").concat(this.stringify(v)));
|
|
8689
8689
|
}
|
|
8690
8690
|
if (!this.checkTexCoord(v.baseColorTextureCoordinate)) {
|
|
@@ -8694,10 +8694,10 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8694
8694
|
if (!this.checkBooleanUndef(v.depthMask)) {
|
|
8695
8695
|
console.error("Invalid material depthMask ".concat(v.depthMask, ", ").concat(this.stringify(v)));
|
|
8696
8696
|
}
|
|
8697
|
-
if (!this.
|
|
8697
|
+
if (!this.checkMatBlending(v.blending)) {
|
|
8698
8698
|
console.error("Invalid material blending ".concat(v.blending, ", ").concat(this.stringify(v)));
|
|
8699
8699
|
}
|
|
8700
|
-
if (!this.
|
|
8700
|
+
if (!this.checkMatSide(v.side)) {
|
|
8701
8701
|
console.error("Invalid material side ".concat(v.side, ", ").concat(this.stringify(v)));
|
|
8702
8702
|
}
|
|
8703
8703
|
if (v.blending === spec.MaterialBlending.masked) {
|
|
@@ -8720,7 +8720,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8720
8720
|
if (!this.checkTextureUndef(v.baseColorTexture)) {
|
|
8721
8721
|
console.error("Invalid material baseColorTexture ".concat(v.baseColorTexture, ", ").concat(this.stringify(v)));
|
|
8722
8722
|
}
|
|
8723
|
-
if (!this.
|
|
8723
|
+
if (!this.checkTexTransformUndef(v.baseColorTextureTransform)) {
|
|
8724
8724
|
console.error("Invalid material baseColorTextureTransform ".concat(v.baseColorTextureTransform, ", ").concat(this.stringify(v)));
|
|
8725
8725
|
}
|
|
8726
8726
|
if (!this.checkTexCoord(v.baseColorTextureCoordinate)) {
|
|
@@ -8739,7 +8739,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8739
8739
|
if (!this.checkTextureUndef(v.metallicRoughnessTexture)) {
|
|
8740
8740
|
console.error("Invalid material metallicRoughnessTexture ".concat(v.metallicRoughnessTexture, ", ").concat(this.stringify(v)));
|
|
8741
8741
|
}
|
|
8742
|
-
if (!this.
|
|
8742
|
+
if (!this.checkTexTransformUndef(v.metallicRoughnessTextureTransform)) {
|
|
8743
8743
|
console.error("Invalid material metallicRoughnessTextureTransform ".concat(v.metallicRoughnessTextureTransform, ", ").concat(this.stringify(v)));
|
|
8744
8744
|
}
|
|
8745
8745
|
if (!this.checkTexCoord(v.metallicRoughnessTextureCoordinate)) {
|
|
@@ -8752,7 +8752,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8752
8752
|
if (!this.checkNonnegativeUndef(v.normalTextureScale)) {
|
|
8753
8753
|
console.error("Invalid material normalTextureScale ".concat(v.normalTextureScale, ", ").concat(this.stringify(v)));
|
|
8754
8754
|
}
|
|
8755
|
-
if (!this.
|
|
8755
|
+
if (!this.checkTexTransformUndef(v.normalTextureTransform)) {
|
|
8756
8756
|
console.error("Invalid material normalTextureTransform ".concat(v.normalTextureTransform, ", ").concat(this.stringify(v)));
|
|
8757
8757
|
}
|
|
8758
8758
|
if (!this.checkTexCoord(v.normalTextureCoordinate)) {
|
|
@@ -8765,7 +8765,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8765
8765
|
if (!this.checkNumber01Undef(v.occlusionTextureStrength)) {
|
|
8766
8766
|
console.error("Invalid material occlusionTextureStrength ".concat(v.occlusionTextureStrength, ", ").concat(this.stringify(v)));
|
|
8767
8767
|
}
|
|
8768
|
-
if (!this.
|
|
8768
|
+
if (!this.checkTexTransformUndef(v.occlusionTextureTransform)) {
|
|
8769
8769
|
console.error("Invalid material occlusionTextureTransform ".concat(v.occlusionTextureTransform, ", ").concat(this.stringify(v)));
|
|
8770
8770
|
}
|
|
8771
8771
|
if (!this.checkTexCoord(v.occlusionTextureCoordinate)) {
|
|
@@ -8782,7 +8782,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8782
8782
|
if (!this.checkTextureUndef(v.emissiveTexture)) {
|
|
8783
8783
|
console.error("Invalid material emissiveTexture ".concat(v.emissiveTexture, ", ").concat(this.stringify(v)));
|
|
8784
8784
|
}
|
|
8785
|
-
if (!this.
|
|
8785
|
+
if (!this.checkTexTransformUndef(v.emissiveTextureTransform)) {
|
|
8786
8786
|
console.error("Invalid material emissiveTextureTransform ".concat(v.emissiveTextureTransform, ", ").concat(this.stringify(v)));
|
|
8787
8787
|
}
|
|
8788
8788
|
if (!this.checkTexCoord(v.emissiveTextureCoordinate)) {
|
|
@@ -8792,10 +8792,10 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8792
8792
|
if (!this.checkBooleanUndef(v.depthMask)) {
|
|
8793
8793
|
console.error("Invalid material depthMask ".concat(v.depthMask, ", ").concat(this.stringify(v)));
|
|
8794
8794
|
}
|
|
8795
|
-
if (!this.
|
|
8795
|
+
if (!this.checkMatBlending(v.blending)) {
|
|
8796
8796
|
console.error("Invalid material blending ".concat(v.blending, ", ").concat(this.stringify(v)));
|
|
8797
8797
|
}
|
|
8798
|
-
if (!this.
|
|
8798
|
+
if (!this.checkMatSide(v.side)) {
|
|
8799
8799
|
console.error("Invalid material side ".concat(v.side, ", ").concat(this.stringify(v)));
|
|
8800
8800
|
}
|
|
8801
8801
|
if (v.blending === spec.MaterialBlending.masked) {
|
|
@@ -8811,22 +8811,22 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8811
8811
|
console.error("Invalid material type ".concat(this.stringify(v)));
|
|
8812
8812
|
}
|
|
8813
8813
|
};
|
|
8814
|
-
CheckerHelper.
|
|
8814
|
+
CheckerHelper.assertPrimOptions = function (v, s) {
|
|
8815
8815
|
this.assertGeometry(v.geometry, s);
|
|
8816
|
-
this.
|
|
8816
|
+
this.assertMatOptions(v.material);
|
|
8817
8817
|
return true;
|
|
8818
8818
|
};
|
|
8819
|
-
CheckerHelper.
|
|
8819
|
+
CheckerHelper.assertModelMeshOptions = function (v) {
|
|
8820
8820
|
if (!this.checkParent(v.parent)) {
|
|
8821
8821
|
console.error("Invalid mesh parent ".concat(v.parent, ", ").concat(this.stringify(v)));
|
|
8822
8822
|
}
|
|
8823
8823
|
if (v.skin !== undefined) {
|
|
8824
|
-
this.
|
|
8824
|
+
this.assertModelSkinOptions(v.skin);
|
|
8825
8825
|
}
|
|
8826
8826
|
var morphList = [];
|
|
8827
8827
|
for (var i = 0; i < v.primitives.length; i++) {
|
|
8828
8828
|
var prim = v.primitives[i];
|
|
8829
|
-
if (!this.
|
|
8829
|
+
if (!this.assertPrimOptions(prim)) {
|
|
8830
8830
|
console.error("Invalid primitive ".concat(prim, ", ").concat(this.stringify(v)));
|
|
8831
8831
|
}
|
|
8832
8832
|
var morph = new PMorph();
|
|
@@ -8844,7 +8844,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8844
8844
|
console.error("Invalid mesh hide ".concat(v.hide, ", ").concat(this.stringify(v)));
|
|
8845
8845
|
}
|
|
8846
8846
|
};
|
|
8847
|
-
CheckerHelper.
|
|
8847
|
+
CheckerHelper.assertModelCameraOptions = function (v) {
|
|
8848
8848
|
if (!this.checkParent(v.parent)) {
|
|
8849
8849
|
console.error("Invalid camera parent ".concat(v.parent, ", ").concat(this.stringify(v)));
|
|
8850
8850
|
}
|
|
@@ -8864,7 +8864,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8864
8864
|
console.error("Invalid camera clipMode ".concat(v.clipMode, ", ").concat(this.stringify(v)));
|
|
8865
8865
|
}
|
|
8866
8866
|
};
|
|
8867
|
-
CheckerHelper.
|
|
8867
|
+
CheckerHelper.assertModelLightOptions = function (v) {
|
|
8868
8868
|
if (v.lightType === 'directional') {
|
|
8869
8869
|
if (!this.checkParent(v.parent)) {
|
|
8870
8870
|
console.error("Invalid light parent ".concat(v.parent, ", ").concat(this.stringify(v)));
|
|
@@ -8925,7 +8925,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8925
8925
|
console.error("Invalid light type ".concat(this.stringify(v)));
|
|
8926
8926
|
}
|
|
8927
8927
|
};
|
|
8928
|
-
CheckerHelper.
|
|
8928
|
+
CheckerHelper.assertModelSkyboxOptions = function (v) {
|
|
8929
8929
|
var _this = this;
|
|
8930
8930
|
if (!this.checkBoolean(v.renderable)) {
|
|
8931
8931
|
console.error("Invalid skybox renderable ".concat(v.renderable, ", ").concat(this.stringify(v)));
|
|
@@ -8969,7 +8969,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8969
8969
|
console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(v)));
|
|
8970
8970
|
}
|
|
8971
8971
|
};
|
|
8972
|
-
CheckerHelper.
|
|
8972
|
+
CheckerHelper.checkModelAnimTrackOptions = function (v) {
|
|
8973
8973
|
if (!this.checkNonnegative(v.node)) {
|
|
8974
8974
|
console.error("Invalid track node ".concat(v.node, ", ").concat(this.stringify(v)));
|
|
8975
8975
|
return false;
|
|
@@ -8992,7 +8992,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
8992
8992
|
}
|
|
8993
8993
|
return true;
|
|
8994
8994
|
};
|
|
8995
|
-
CheckerHelper.
|
|
8995
|
+
CheckerHelper.assertModelAnimOptions = function (v) {
|
|
8996
8996
|
var _this = this;
|
|
8997
8997
|
if (!this.checkStringUndef(v.name)) {
|
|
8998
8998
|
console.error("Invalid animation name ".concat(v.name, ", ").concat(this.stringify(v)));
|
|
@@ -9001,7 +9001,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
9001
9001
|
console.error("Invalid animation tracks ".concat(v.tracks, ", ").concat(this.stringify(v)));
|
|
9002
9002
|
}
|
|
9003
9003
|
v.tracks.forEach(function (t) {
|
|
9004
|
-
if (!_this.
|
|
9004
|
+
if (!_this.checkModelAnimTrackOptions(t)) {
|
|
9005
9005
|
console.error("Invalid animation track ".concat(t, ", ").concat(_this.stringify(v)));
|
|
9006
9006
|
}
|
|
9007
9007
|
});
|
|
@@ -9015,7 +9015,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
9015
9015
|
if (!Array.isArray(v.animations)) {
|
|
9016
9016
|
console.error("Invalid tree animations ".concat(v.animations, ", ").concat(this.stringify(v)));
|
|
9017
9017
|
}
|
|
9018
|
-
v.animations.forEach(function (anim) { _this.
|
|
9018
|
+
v.animations.forEach(function (anim) { _this.assertModelAnimOptions(anim); });
|
|
9019
9019
|
if (v.animation !== undefined) {
|
|
9020
9020
|
if (v.animation < -1 || v.animation >= v.animations.length) {
|
|
9021
9021
|
console.error("Invalid tree animations ".concat(v.animations, ", ").concat(this.stringify(v)));
|
|
@@ -9030,7 +9030,7 @@ var CheckerHelper = /** @class */ (function () {
|
|
|
9030
9030
|
// continue;
|
|
9031
9031
|
// }
|
|
9032
9032
|
if (prop === 'internal') {
|
|
9033
|
-
//
|
|
9033
|
+
// 与WebGL相关的数据,可以忽略
|
|
9034
9034
|
continue;
|
|
9035
9035
|
}
|
|
9036
9036
|
if (typeof (object[prop]) == 'function') {
|
|
@@ -10115,10 +10115,10 @@ var PSkyboxCreator = /** @class */ (function () {
|
|
|
10115
10115
|
minFilter: glContext.LINEAR_MIPMAP_LINEAR,
|
|
10116
10116
|
});
|
|
10117
10117
|
if (params.type === 'url') {
|
|
10118
|
-
return [2 /*return*/,
|
|
10118
|
+
return [2 /*return*/, WebGLHelper.createTextureCubeMipmapFromURL(engine, params.specularImage)];
|
|
10119
10119
|
}
|
|
10120
10120
|
else {
|
|
10121
|
-
return [2 /*return*/,
|
|
10121
|
+
return [2 /*return*/, WebGLHelper.createTextureCubeMipmapFromBuffer(engine, params.specularImage, params.specularImageSize)];
|
|
10122
10122
|
}
|
|
10123
10123
|
});
|
|
10124
10124
|
});
|
|
@@ -10130,10 +10130,10 @@ var PSkyboxCreator = /** @class */ (function () {
|
|
|
10130
10130
|
return [2 /*return*/];
|
|
10131
10131
|
}
|
|
10132
10132
|
if (params.type === 'url') {
|
|
10133
|
-
return [2 /*return*/,
|
|
10133
|
+
return [2 /*return*/, WebGLHelper.createTextureCubeFromURL(engine, params.diffuseImage)];
|
|
10134
10134
|
}
|
|
10135
10135
|
else {
|
|
10136
|
-
return [2 /*return*/,
|
|
10136
|
+
return [2 /*return*/, WebGLHelper.createTextureCubeFromBuffer(engine, params.diffuseImage)];
|
|
10137
10137
|
}
|
|
10138
10138
|
});
|
|
10139
10139
|
});
|
|
@@ -10348,14 +10348,14 @@ var PSkyboxCreator = /** @class */ (function () {
|
|
|
10348
10348
|
}());
|
|
10349
10349
|
|
|
10350
10350
|
var globalGLTFLoader;
|
|
10351
|
-
function
|
|
10351
|
+
function getDefaultEffectsGLTFLoader(engine, options) {
|
|
10352
10352
|
if (!globalGLTFLoader) {
|
|
10353
10353
|
globalGLTFLoader = new LoaderImpl();
|
|
10354
10354
|
}
|
|
10355
10355
|
globalGLTFLoader.initial(engine, options);
|
|
10356
10356
|
return globalGLTFLoader;
|
|
10357
10357
|
}
|
|
10358
|
-
function
|
|
10358
|
+
function setDefaultEffectsGLTFLoader(loader) {
|
|
10359
10359
|
globalGLTFLoader = loader;
|
|
10360
10360
|
}
|
|
10361
10361
|
var LoaderImpl = /** @class */ (function () {
|
|
@@ -10365,11 +10365,11 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10365
10365
|
this.engine = engine;
|
|
10366
10366
|
this._loaderOptions = options !== null && options !== void 0 ? options : {};
|
|
10367
10367
|
};
|
|
10368
|
-
LoaderImpl.prototype.processLight = function (lights,
|
|
10368
|
+
LoaderImpl.prototype.processLight = function (lights, fromGLTF) {
|
|
10369
10369
|
var _this = this;
|
|
10370
10370
|
lights.forEach(function (l) {
|
|
10371
10371
|
if (l.color === undefined) {
|
|
10372
|
-
if (
|
|
10372
|
+
if (fromGLTF) {
|
|
10373
10373
|
l.color = [255, 255, 255, 255];
|
|
10374
10374
|
}
|
|
10375
10375
|
else {
|
|
@@ -10377,26 +10377,26 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10377
10377
|
}
|
|
10378
10378
|
}
|
|
10379
10379
|
else {
|
|
10380
|
-
l.color[0] = _this.scaleColorVal(l.color[0],
|
|
10381
|
-
l.color[1] = _this.scaleColorVal(l.color[1],
|
|
10382
|
-
l.color[2] = _this.scaleColorVal(l.color[2],
|
|
10383
|
-
l.color[3] = _this.scaleColorVal(l.color[3],
|
|
10380
|
+
l.color[0] = _this.scaleColorVal(l.color[0], fromGLTF);
|
|
10381
|
+
l.color[1] = _this.scaleColorVal(l.color[1], fromGLTF);
|
|
10382
|
+
l.color[2] = _this.scaleColorVal(l.color[2], fromGLTF);
|
|
10383
|
+
l.color[3] = _this.scaleColorVal(l.color[3], fromGLTF);
|
|
10384
10384
|
}
|
|
10385
10385
|
});
|
|
10386
10386
|
};
|
|
10387
|
-
LoaderImpl.prototype.processCamera = function (cameras,
|
|
10388
|
-
var scale =
|
|
10387
|
+
LoaderImpl.prototype.processCamera = function (cameras, fromGLTF) {
|
|
10388
|
+
var scale = fromGLTF ? 180.0 / Math.PI : Math.PI / 180.0;
|
|
10389
10389
|
cameras.forEach(function (camera) {
|
|
10390
10390
|
if (camera.perspective !== undefined) {
|
|
10391
10391
|
camera.perspective.yfov *= scale;
|
|
10392
10392
|
}
|
|
10393
10393
|
});
|
|
10394
10394
|
};
|
|
10395
|
-
LoaderImpl.prototype.processMaterial = function (materials,
|
|
10395
|
+
LoaderImpl.prototype.processMaterial = function (materials, fromGLTF) {
|
|
10396
10396
|
var _this = this;
|
|
10397
10397
|
materials.forEach(function (mat) {
|
|
10398
10398
|
if (mat.baseColorFactor === undefined) {
|
|
10399
|
-
if (
|
|
10399
|
+
if (fromGLTF) {
|
|
10400
10400
|
mat.baseColorFactor = [255, 255, 255, 255];
|
|
10401
10401
|
}
|
|
10402
10402
|
else {
|
|
@@ -10404,13 +10404,13 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10404
10404
|
}
|
|
10405
10405
|
}
|
|
10406
10406
|
else {
|
|
10407
|
-
mat.baseColorFactor[0] = _this.scaleColorVal(mat.baseColorFactor[0],
|
|
10408
|
-
mat.baseColorFactor[1] = _this.scaleColorVal(mat.baseColorFactor[1],
|
|
10409
|
-
mat.baseColorFactor[2] = _this.scaleColorVal(mat.baseColorFactor[2],
|
|
10410
|
-
mat.baseColorFactor[3] = _this.scaleColorVal(mat.baseColorFactor[3],
|
|
10407
|
+
mat.baseColorFactor[0] = _this.scaleColorVal(mat.baseColorFactor[0], fromGLTF);
|
|
10408
|
+
mat.baseColorFactor[1] = _this.scaleColorVal(mat.baseColorFactor[1], fromGLTF);
|
|
10409
|
+
mat.baseColorFactor[2] = _this.scaleColorVal(mat.baseColorFactor[2], fromGLTF);
|
|
10410
|
+
mat.baseColorFactor[3] = _this.scaleColorVal(mat.baseColorFactor[3], fromGLTF);
|
|
10411
10411
|
}
|
|
10412
10412
|
if (mat.emissiveFactor === undefined) {
|
|
10413
|
-
if (
|
|
10413
|
+
if (fromGLTF) {
|
|
10414
10414
|
mat.emissiveFactor = [255, 255, 255, 255];
|
|
10415
10415
|
}
|
|
10416
10416
|
else {
|
|
@@ -10418,12 +10418,12 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10418
10418
|
}
|
|
10419
10419
|
}
|
|
10420
10420
|
else {
|
|
10421
|
-
mat.emissiveFactor[0] = _this.scaleColorVal(mat.emissiveFactor[0],
|
|
10422
|
-
mat.emissiveFactor[1] = _this.scaleColorVal(mat.emissiveFactor[1],
|
|
10423
|
-
mat.emissiveFactor[2] = _this.scaleColorVal(mat.emissiveFactor[2],
|
|
10424
|
-
mat.emissiveFactor[3] = _this.scaleColorVal(mat.emissiveFactor[3],
|
|
10421
|
+
mat.emissiveFactor[0] = _this.scaleColorVal(mat.emissiveFactor[0], fromGLTF);
|
|
10422
|
+
mat.emissiveFactor[1] = _this.scaleColorVal(mat.emissiveFactor[1], fromGLTF);
|
|
10423
|
+
mat.emissiveFactor[2] = _this.scaleColorVal(mat.emissiveFactor[2], fromGLTF);
|
|
10424
|
+
mat.emissiveFactor[3] = _this.scaleColorVal(mat.emissiveFactor[3], fromGLTF);
|
|
10425
10425
|
}
|
|
10426
|
-
if (
|
|
10426
|
+
if (fromGLTF && mat.occlusionTexture !== undefined && mat.occlusionTexture.strength === undefined) {
|
|
10427
10427
|
mat.occlusionTexture.strength = _this.isTiny3dMode() ? 0 : 1;
|
|
10428
10428
|
}
|
|
10429
10429
|
});
|
|
@@ -10516,7 +10516,7 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10516
10516
|
return proxy.material;
|
|
10517
10517
|
};
|
|
10518
10518
|
LoaderImpl.prototype.createTexture2D = function (image, texture, isBaseColor) {
|
|
10519
|
-
return
|
|
10519
|
+
return WebGLHelper.createTexture2D(this.engine, image, texture, isBaseColor, this.isTiny3dMode());
|
|
10520
10520
|
};
|
|
10521
10521
|
LoaderImpl.prototype.createTextureCube = function (cubeImages, level0Size) {
|
|
10522
10522
|
var _this = this;
|
|
@@ -10550,11 +10550,11 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10550
10550
|
//
|
|
10551
10551
|
if (mipmaps.length == 1) {
|
|
10552
10552
|
// no mipmaps
|
|
10553
|
-
return
|
|
10553
|
+
return WebGLHelper.createTextureCubeFromBuffer(this.engine, mipmaps[0]);
|
|
10554
10554
|
}
|
|
10555
10555
|
else {
|
|
10556
10556
|
// has mipmaps
|
|
10557
|
-
return
|
|
10557
|
+
return WebGLHelper.createTextureCubeMipmapFromBuffer(this.engine, mipmaps, level0Size !== null && level0Size !== void 0 ? level0Size : Math.pow(2, mipmaps.length - 1));
|
|
10558
10558
|
}
|
|
10559
10559
|
};
|
|
10560
10560
|
LoaderImpl.prototype.createSkybox = function (ibl) {
|
|
@@ -10601,24 +10601,24 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10601
10601
|
var params = PSkyboxCreator.getSkyboxParams(typ);
|
|
10602
10602
|
return PSkyboxCreator.createSkyboxOptions(this.engine, params);
|
|
10603
10603
|
};
|
|
10604
|
-
LoaderImpl.prototype.scaleColorVal = function (val,
|
|
10605
|
-
return
|
|
10604
|
+
LoaderImpl.prototype.scaleColorVal = function (val, fromGLTF) {
|
|
10605
|
+
return fromGLTF ? LoaderHelper.scaleTo255(val) : LoaderHelper.scaleTo1(val);
|
|
10606
10606
|
};
|
|
10607
|
-
LoaderImpl.prototype.scaleColorVec = function (vec,
|
|
10607
|
+
LoaderImpl.prototype.scaleColorVec = function (vec, fromGLTF) {
|
|
10608
10608
|
var _this = this;
|
|
10609
|
-
return vec.map(function (val) { return _this.scaleColorVal(val,
|
|
10609
|
+
return vec.map(function (val) { return _this.scaleColorVal(val, fromGLTF); });
|
|
10610
10610
|
};
|
|
10611
10611
|
LoaderImpl.prototype.loadScene = function (options) {
|
|
10612
10612
|
var _a;
|
|
10613
10613
|
return __awaiter(this, void 0, void 0, function () {
|
|
10614
|
-
var gltfResource,
|
|
10614
|
+
var gltfResource, modelItems, treeId, itemSkybox, sceneAABB;
|
|
10615
10615
|
var _this = this;
|
|
10616
10616
|
return __generator(this, function (_b) {
|
|
10617
10617
|
switch (_b.label) {
|
|
10618
10618
|
case 0:
|
|
10619
10619
|
this._clear();
|
|
10620
10620
|
this._sceneOptions = options;
|
|
10621
|
-
this.engine = (_a = options.
|
|
10621
|
+
this.engine = (_a = options.effects.renderer) === null || _a === void 0 ? void 0 : _a.engine;
|
|
10622
10622
|
this._loaderOptions = { compatibleMode: options.gltf.compatibleMode };
|
|
10623
10623
|
gltfResource = options.gltf.resource;
|
|
10624
10624
|
if (typeof gltfResource === 'string' || gltfResource instanceof Uint8Array) {
|
|
@@ -10637,30 +10637,30 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10637
10637
|
return [4 /*yield*/, this._preprocess()];
|
|
10638
10638
|
case 1:
|
|
10639
10639
|
_b.sent();
|
|
10640
|
-
|
|
10640
|
+
modelItems = [];
|
|
10641
10641
|
treeId = 'sceneTree';
|
|
10642
|
-
|
|
10642
|
+
modelItems.push(this._createItemTree(treeId, this._gltfScene));
|
|
10643
10643
|
itemSkybox = this._createItemSkybox();
|
|
10644
10644
|
if (itemSkybox !== undefined) {
|
|
10645
|
-
|
|
10645
|
+
modelItems.push(itemSkybox);
|
|
10646
10646
|
}
|
|
10647
10647
|
this._gltfScene.nodes.forEach(function (node) {
|
|
10648
10648
|
if (node.mesh !== undefined) {
|
|
10649
10649
|
var itemMesh = _this._createItemMesh(node, treeId);
|
|
10650
10650
|
if (itemMesh !== undefined) {
|
|
10651
|
-
|
|
10651
|
+
modelItems.push(itemMesh);
|
|
10652
10652
|
}
|
|
10653
10653
|
}
|
|
10654
10654
|
if (node.light !== undefined) {
|
|
10655
10655
|
var itemLight = _this._createItemLight(node, treeId);
|
|
10656
10656
|
if (itemLight !== undefined) {
|
|
10657
|
-
|
|
10657
|
+
modelItems.push(itemLight);
|
|
10658
10658
|
}
|
|
10659
10659
|
}
|
|
10660
10660
|
if (node.camera !== undefined) {
|
|
10661
10661
|
var itemCamera = _this._createItemCamera(node, treeId);
|
|
10662
10662
|
if (itemCamera !== undefined) {
|
|
10663
|
-
|
|
10663
|
+
modelItems.push(itemCamera);
|
|
10664
10664
|
}
|
|
10665
10665
|
}
|
|
10666
10666
|
});
|
|
@@ -10673,7 +10673,7 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10673
10673
|
});
|
|
10674
10674
|
return [2 /*return*/, {
|
|
10675
10675
|
source: this.getRemarkString(),
|
|
10676
|
-
items:
|
|
10676
|
+
items: modelItems,
|
|
10677
10677
|
sceneAABB: {
|
|
10678
10678
|
min: sceneAABB.min.toArray(),
|
|
10679
10679
|
max: sceneAABB.max.toArray(),
|
|
@@ -10767,7 +10767,7 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10767
10767
|
var texIndex = texInfo.index;
|
|
10768
10768
|
var tex = this._gltfTextures[texIndex];
|
|
10769
10769
|
var img = this._gltfImages[tex.source];
|
|
10770
|
-
return
|
|
10770
|
+
return WebGLHelper.createTexture2D(this.engine, img, tex, isBaseColor, this.isTiny3dMode()).then(function (tex) {
|
|
10771
10771
|
_this.getTextureManager().addTexture(matIndex, texIndex, tex, isBaseColor);
|
|
10772
10772
|
});
|
|
10773
10773
|
};
|
|
@@ -10998,7 +10998,7 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
10998
10998
|
// 硬编码,内部指定的播放全部动画的索引值
|
|
10999
10999
|
return -88888888;
|
|
11000
11000
|
}
|
|
11001
|
-
var animationInfo = this._sceneOptions.
|
|
11001
|
+
var animationInfo = this._sceneOptions.effects.playAnimation;
|
|
11002
11002
|
if (animationInfo === undefined) {
|
|
11003
11003
|
return -1;
|
|
11004
11004
|
}
|
|
@@ -11023,10 +11023,10 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
11023
11023
|
}
|
|
11024
11024
|
};
|
|
11025
11025
|
LoaderImpl.prototype.isPlayAnimation = function () {
|
|
11026
|
-
return this._sceneOptions.
|
|
11026
|
+
return this._sceneOptions.effects.playAnimation !== undefined;
|
|
11027
11027
|
};
|
|
11028
11028
|
LoaderImpl.prototype.isPlayAllAnimation = function () {
|
|
11029
|
-
return this._sceneOptions.
|
|
11029
|
+
return this._sceneOptions.effects.playAllAnimation === true;
|
|
11030
11030
|
};
|
|
11031
11031
|
LoaderImpl.prototype.getRemarkString = function () {
|
|
11032
11032
|
var remark = this._sceneOptions.gltf.remark;
|
|
@@ -11048,11 +11048,11 @@ var LoaderImpl = /** @class */ (function () {
|
|
|
11048
11048
|
};
|
|
11049
11049
|
LoaderImpl.prototype.getItemDuration = function () {
|
|
11050
11050
|
var _a;
|
|
11051
|
-
return (_a = this._sceneOptions.
|
|
11051
|
+
return (_a = this._sceneOptions.effects.duration) !== null && _a !== void 0 ? _a : 9999;
|
|
11052
11052
|
};
|
|
11053
11053
|
LoaderImpl.prototype.getItemEndBehavior = function () {
|
|
11054
11054
|
var _a;
|
|
11055
|
-
return (_a = this._sceneOptions.
|
|
11055
|
+
return (_a = this._sceneOptions.effects.endBehavior) !== null && _a !== void 0 ? _a : spec.ItemEndBehavior.loop;
|
|
11056
11056
|
};
|
|
11057
11057
|
LoaderImpl.prototype.getSkyboxType = function () {
|
|
11058
11058
|
var typeName = this._sceneOptions.gltf.skyboxType;
|
|
@@ -11699,8 +11699,8 @@ var CameraGestureHandlerImp = /** @class */ (function () {
|
|
|
11699
11699
|
return this.composition.camera.getOptions();
|
|
11700
11700
|
}
|
|
11701
11701
|
var camera = this.composition.camera;
|
|
11702
|
-
var
|
|
11703
|
-
var cameraTransform = new PTransform().
|
|
11702
|
+
var effectsTransfrom = new Transform(__assign(__assign({}, camera.getOptions()), { valid: true }));
|
|
11703
|
+
var cameraTransform = new PTransform().fromEffectsTransform(effectsTransfrom);
|
|
11704
11704
|
var cameraCoordiante = new PCoordinate().fromPTransform(cameraTransform);
|
|
11705
11705
|
// compute move direction
|
|
11706
11706
|
var xAxis = (_a = event.xAxis) !== null && _a !== void 0 ? _a : 0;
|
|
@@ -11891,7 +11891,7 @@ var CameraGestureHandlerImp = /** @class */ (function () {
|
|
|
11891
11891
|
var newDistance = distance !== null && distance !== void 0 ? distance : 5;
|
|
11892
11892
|
var targetPoint = Vector3.fromArray(point);
|
|
11893
11893
|
//
|
|
11894
|
-
var transform = new PTransform().
|
|
11894
|
+
var transform = new PTransform().fromEffectsTransform(item.transform);
|
|
11895
11895
|
var coordinate = new PCoordinate().fromPTransform(transform);
|
|
11896
11896
|
var lookatDir = coordinate.zAxis.clone().multiplyScalar(1.0);
|
|
11897
11897
|
//
|
|
@@ -11917,7 +11917,7 @@ var CameraGestureHandlerImp = /** @class */ (function () {
|
|
|
11917
11917
|
// const newLookatDir = targetPoint.clone().subVector(cameraPos).normalize();
|
|
11918
11918
|
// const newOffset = newLookatDir.clone().multiplyScalar(newDistance);
|
|
11919
11919
|
// const newPosition = targetPoint.clone().subVector(newOffset);
|
|
11920
|
-
// const oldTransform = new PTransform().
|
|
11920
|
+
// const oldTransform = new PTransform().fromEffectsTransform(item.transform);
|
|
11921
11921
|
// const oldCoordinate = new PCoordinate().fromPTransform(oldTransform)
|
|
11922
11922
|
// const oldLookatDir = oldCoordinate.zAxis.clone().multiplyScalar(-1.0);
|
|
11923
11923
|
// const rotateAxis = oldLookatDir.cross(newLookatDir);
|
|
@@ -12028,13 +12028,13 @@ var CameraGestureHandlerImp = /** @class */ (function () {
|
|
|
12028
12028
|
this.startParams.target = '';
|
|
12029
12029
|
};
|
|
12030
12030
|
CameraGestureHandlerImp.prototype.updateCameraTransform = function (cameraOptions) {
|
|
12031
|
-
var
|
|
12032
|
-
|
|
12033
|
-
this.cameraTransform.
|
|
12031
|
+
var effectsTransfrom = new Transform(cameraOptions);
|
|
12032
|
+
effectsTransfrom.setValid(true);
|
|
12033
|
+
this.cameraTransform.fromEffectsTransform(effectsTransfrom);
|
|
12034
12034
|
this.cameraCoordiante.fromPTransform(this.cameraTransform);
|
|
12035
12035
|
};
|
|
12036
12036
|
return CameraGestureHandlerImp;
|
|
12037
12037
|
}());
|
|
12038
12038
|
|
|
12039
|
-
export { CameraGestureHandlerImp, CameraGestureType, LoaderHelper, LoaderImpl,
|
|
12039
|
+
export { CameraGestureHandlerImp, CameraGestureType, LoaderHelper, LoaderImpl, getDefaultEffectsGLTFLoader, setDefaultEffectsGLTFLoader };
|
|
12040
12040
|
//# sourceMappingURL=loader.mjs.map
|