Commit 4986fdac authored by bp0002's avatar bp0002
Browse files

# fix: Material With ResTab

Showing with 1787 additions and 481 deletions
+1787 -481
import { BABYLON } from "../render3d/babylon";
import { IGLTFNew, IMeshNew, IMeshPrimitiveNew, INewIAnimation, INodeNew } from "./interface";
import { Res, ResTab } from '../interface/index';
import { ExtensionTools, Res, ResTab } from '../interface/index';
import { OfflineProvider } from "../render3d/offline_provider";
export type GLTFRes = Res<any, IGLTFNew>;
......@@ -286,4 +288,22 @@ export class GLTFTool {
babylonMesh.billboardMode = 7;
}
}
}
\ No newline at end of file
}
export const BABYLON_MATERIAL_NEW = "BABYLON_MATERIAL_NEW";
ExtensionTools.RegistStartUp(() => {
ExtensionTools.ResLoadRegist(
BABYLON_MATERIAL_NEW,
undefined,
(link: BABYLON.Material) => {
link.dispose(false, true);
},
function(link: BABYLON.Material) {
if (OfflineProvider.onoffCollectInfo) {
OfflineProvider.piBABYLONResCollect[BABYLON_MATERIAL_NEW] -= 2048;
}
return 2048;
}
);
});
\ No newline at end of file
......@@ -3,19 +3,19 @@ import { BABYLON } from "../../render3d/babylon";
import { GLTFLoader } from "../glTFLoader"
export class PI_material {
public static MaterialFactoryMap: Map<string, (context: string, babylonScene: BABYLON.Scene, materialName: string | undefined, index: number, materialInfo: IMaterial, babylonDrawMode: number) => BABYLON.Material> = new Map();
public static MaterialPropertiesLoadAsyncMap: Map<string, (context: string, material: IMaterial, mat: BABYLON.Material, _loader: GLTFLoader) => void> = new Map();
public static MaterialFactoryMap: Map<string, (context: string, babylonScene: BABYLON.Scene, materialName: string | undefined, index: number, materialInfo: IMaterial, babylonDrawMode: number, notParticleSys?: boolean) => BABYLON.Material> = new Map();
public static MaterialPropertiesLoadAsyncMap: Map<string, (context: string, material: IMaterial, mat: BABYLON.Material, _loader: GLTFLoader, notParticleSys?: boolean) => void> = new Map();
_loader: GLTFLoader;
public createMaterial(context: string, indexMat: number, indexNode: number, material: IMaterial, babylonDrawMode: number): BABYLON.Material {
public createMaterial(context: string, indexMat: number, indexNode: number, material: IMaterial, babylonDrawMode: number, notParticleSys?: boolean): BABYLON.Material {
throw new Error("Not Impl Function!");
}
public loadMaterialPropertiesAsync(context: string, material: any, mat: BABYLON.Material) {
public loadMaterialPropertiesAsync(context: string, material: any, mat: BABYLON.Material, notParticleSys?: boolean) {
throw new Error("Not Impl Function!")
}
public static regist(
shaderName: string,
create: (context: string, babylonScene: BABYLON.Scene, materialName: string | undefined, index: number, materialInfo: IMaterial, babylonDrawMode: number) => BABYLON.Material,
propertiesAsync: (context: string, material: IMaterial, mat: BABYLON.Material, _loader: GLTFLoader) => void
create: (context: string, babylonScene: BABYLON.Scene, materialName: string | undefined, index: number, materialInfo: IMaterial, babylonDrawMode: number, notParticleSys?: boolean) => BABYLON.Material,
propertiesAsync: (context: string, material: IMaterial, mat: BABYLON.Material, _loader: GLTFLoader, notParticleSys?: boolean) => void
) {
PI_material.MaterialFactoryMap.set(shaderName, create);
PI_material.MaterialPropertiesLoadAsyncMap.set(shaderName, propertiesAsync);
......
This diff is collapsed.
......@@ -41,6 +41,8 @@ import { getGlobal } from "pi_utils/util/frame_mgr";
import { loadFile } from "pi_sys/load/object_load";
import { IBakedKeyframes } from "./interface/spine_baked";
import { StandardMaterialData, initStandardMaterialOpt } from "./material/standardmaterial";
export { CustomGeometry } from "./customgeometry/custom_geometry";
export { Sprite } from "./sprite/sprite";
export { SpriteManager } from "./sprite/sprite_manager";
......@@ -177,6 +179,10 @@ export interface IActionD3 {
transparencyMode(mesh: BABYLON.Mesh, val: TransparentcyMode): void;
updateEngineDimensions(width: number, height: number): void;
backFaceCulling(mesh: { material: BABYLON.Material }, val: boolean): void;
uScale(mesh: BABYLON.Mesh, texturePath: string, val: number);
vScale(mesh: BABYLON.Mesh, texturePath: string, val: number);
uOffset(mesh: BABYLON.Mesh, texturePath: string, val: number);
vOffset(mesh: BABYLON.Mesh, texturePath: string, val: number);
}
export interface ICustomScene {
......@@ -338,6 +344,7 @@ export class _BABYLONAction implements IActionD3 {
ExtensionTools.RES_FILE = "RES_FILE";
ExtensionTools.RES_IMAGE = "RES_IMAGE";
ExtensionTools.LoadFile = function (resTab: ResTab, url: string): Promise<ArrayBuffer | ArrayBufferView> {
return loadFile(url);
// return resTab.load(ExtensionTools.RES_FILE, url, []).then((data) => {
// let val = <Uint8Array>data.link;
......@@ -389,6 +396,9 @@ export class _BABYLONAction implements IActionD3 {
ExtensionTools.clearPermanent = function (func: () => void) {
getGlobal().clearPermanent(func);
}
ExtensionTools.getAtom = function(v: number | string | any) {
return v;
}
ExtensionTools.getFileSize = function(file: string) {
return PISYS.Depend.getFile(file)?.size;
}
......@@ -415,6 +425,9 @@ export class _BABYLONAction implements IActionD3 {
}
initial();
if (opt.optimizeMaterialWithResTab) {
initStandardMaterialOpt();
}
registPiStandardFactory();
registDistortionUVFactory();
registEffectMaskFactory();
......@@ -504,13 +517,8 @@ export class _BABYLONAction implements IActionD3 {
alphaMode(mesh: BABYLON.Mesh, val: number) {
mesh.material.alphaMode = val;
}
alpha(mesh: { material: BABYLON.Material, visibility: number }, val: number) {
if (mesh.material instanceof BABYLON.Material) {
mesh.material.alpha = val;
} else {
// 非自定义材质的透明度变化
mesh.visibility = val;
}
alpha(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, val: number) {
(mesh.materialData || <BABYLON.StandardMaterial>mesh.material).alpha = val;
}
autoClearColor(camera: BABYLON.Camera, val: boolean) {
let scene = camera.getScene();
......@@ -538,8 +546,8 @@ export class _BABYLONAction implements IActionD3 {
isDisposed(scene: BABYLON.Scene) {
return scene.isDisposed;
}
alphaCutOff(mesh: { material: BABYLON.Material }, val: number) {
(<BABYLON.StandardMaterial>mesh.material).alphaCutOff = val;
alphaCutOff(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, val: number) {
(mesh.materialData || <BABYLON.StandardMaterial>mesh.material).alphaCutOff = val;
}
mainColor(material: BABYLON.Material, r: number, g: number, b: number) {
(<BABYLON.StandardMaterial>material).emissiveColor.copyFromFloats(r, g, b);
......@@ -553,6 +561,26 @@ export class _BABYLONAction implements IActionD3 {
mesh.material.backFaceCulling = val;
}
}
uScale(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, texturePath: string, val: number) {
if ((mesh.materialData || mesh.material)[texturePath]) {
(mesh.materialData || mesh.material)[texturePath].uScale = val;
}
}
vScale(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, texturePath: string, val: number) {
if ((mesh.materialData || mesh.material)[texturePath]) {
(mesh.materialData || mesh.material)[texturePath].vScale = val;
}
}
uOffset(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, texturePath: string, val: number) {
if ((mesh.materialData || mesh.material)[texturePath]) {
(mesh.materialData || mesh.material)[texturePath].uOffset = val;
}
}
vOffset(mesh: { material: BABYLON.Material, materialData?: StandardMaterialData }, texturePath: string, val: number) {
if ((mesh.materialData || mesh.material)[texturePath]) {
(mesh.materialData || mesh.material)[texturePath].vOffset = val;
}
}
}
export const BABYLONAction = new _BABYLONAction;
......
......@@ -11,6 +11,7 @@ export interface IInitialOption {
DefaultWhitePath: string;
width: number;
height: number;
optimizeMaterialWithResTab?: boolean;
}
export interface GlContext {
......
......@@ -2,23 +2,35 @@ import { IPITextureInfo } from "../material_info";
import { BABYLON } from "../render3d/babylon";
import { ShaderMaterial } from "./shader_material";
import { LoadExtraMaterial } from "../render3d/extends/material";
import { StandardMaterialMesh } from "./standardmaterial";
const KEY_DISTORTION_UV = "DistortionUV";
//laserEffect
BABYLON.Effect.ShadersStore[`${KEY_DISTORTION_UV}VertexShader`] = `
precision highp float;
attribute vec3 position;
attribute vec3 color;
attribute vec2 uv;
attribute vec4 a_diffuseTilloff;
attribute vec4 a_maskTilloff;
attribute vec4 a_opacityTilloff;
attribute vec4 a_distortionInfo;
attribute vec4 a_control;
uniform mat4 worldViewProjection;
uniform mat4 diffuseMatrix;
uniform mat4 maskMatrix;
uniform vec4 distortionInfo;
uniform vec4 control;
varying vec2 vDiffuseUV;
varying vec2 vMaskUV;
varying vec2 vMaskDiff;
varying vec4 vColor;
varying vec2 vOpacityUV;
varying vec4 diffuseMatrix;
varying vec4 maskMatrix;
varying vec4 opacityMatrix;
varying vec4 distortionInfo;
varying vec4 control;
void main(void) {
vec3 positionUpdated = position;
......@@ -26,17 +38,24 @@ BABYLON.Effect.ShadersStore[`${KEY_DISTORTION_UV}VertexShader`] = `
gl_Position = worldViewProjection*vec4(positionUpdated, 1.0);
control = a_control;
distortionInfo = a_distortionInfo;
control = a_control;
float progress = control.x;
float maskValueFlow = control.y;
float maskUVFlow = 1.0 - maskValueFlow;
vec2 diffValue = progress * distortionInfo.zw;
vDiffuseUV = vec2(diffuseMatrix*vec4(uvUpdated, 1.0, 0.0));
vDiffuseUV = vec2(uvUpdated * diffuseMatrix.xy + diffuseMatrix.zw);
vMaskUV = vec2(maskMatrix*vec4(uvUpdated, 1.0, 0.0));
vMaskUV = vec2(uvUpdated * maskMatrix.xy + maskMatrix.zw);
vMaskUV = vMaskUV + maskUVFlow * diffValue;
vMaskDiff = maskValueFlow * diffValue;
vColor = color;
vOpacityUV = vec2(uvUpdated * opacityMatrix.xy + opacityMatrix.zw);
}
`;
......@@ -47,14 +66,18 @@ BABYLON.Effect.ShadersStore[`${KEY_DISTORTION_UV}FragmentShader`] =
varying vec2 vDiffuseUV;
varying vec2 vMaskUV;
varying vec2 vMaskDiff;
varying vec4 vColor;
varying vec2 vOpacityUV;
varying vec4 distortionInfo;
varying vec4 control;
uniform sampler2D diffuseTexture;
uniform sampler2D maskTexture;
uniform sampler2D mask2Texture;
uniform sampler2D opacityTexture;
uniform vec4 tintColor;
uniform vec4 distortionInfo;
uniform mat4 diffuseMatrix;
uniform mat4 maskMatrix;
vec2 uvAddress(vec2 uv, mat4 matrix) {
vec2 mode = vec2(matrix*vec4(0., 0., 0., 1.0));
......@@ -83,13 +106,19 @@ BABYLON.Effect.ShadersStore[`${KEY_DISTORTION_UV}FragmentShader`] =
}
void main(void) {
vec4 textureMask = texture2D(maskTexture, uvAddress(vMaskUV, maskMatrix));
vec4 textureMask2 = texture2D(mask2Texture, uvAddress(vMaskUV, maskMatrix));
vec4 textureMask = texture2D(maskTexture, vMaskUV);
vec4 textureMask2 = texture2D(mask2Texture, vMaskUV);
vec2 uvDiff = vec2(textureMask.r, textureMask2.g) * 2. - 1. + vMaskDiff;
vec4 textureColor = texture2D(diffuseTexture, uvAddress(vDiffuseUV + uvDiff * distortionInfo.xy, diffuseMatrix));
vec4 textureColor = texture2D(diffuseTexture, vDiffuseUV + uvDiff * distortionInfo.xy);
vec4 result = textureColor * tintColor;
gl_FragColor = textureColor * tintColor;
if (control.w > 0.0) {
result *= texture2D(opacityTexture, vOpacityUV).b;
}
result *= mix(vec4(1.0), vColor, control.z);
gl_FragColor = result;
}
`;
......@@ -266,8 +295,8 @@ export class DistortionUVMaterial extends ShaderMaterial {
`${DistortionUVMaterial.KEY_DISTORTION_UV}`,
{
attributes: ["position", "uv", "color"],
uniforms: ["worldViewProjection", "tintColor", "distortionInfo", "diffuseMatrix", "maskMatrix", "mask2Matrix", "control"],
samplers: ["diffuseTexture", "maskTexture", "mask2Texture"],
uniforms: ["worldViewProjection", "tintColor", "distortionInfo", "diffuseMatrix", "maskMatrix", "mask2Matrix", "opacityMatrix", "control"],
samplers: ["diffuseTexture", "maskTexture", "mask2Texture", "opacityTexture"],
needAlphaBlending: true
}
);
......@@ -282,30 +311,62 @@ export class DistortionUVMaterial extends ShaderMaterial {
this.setMatrix('opacityMatrix', this._opacityMatrices);
this.setVector4("control", this._control);
}
public diffuseTexture: BABYLON.Texture;
public maskTexture: BABYLON.Texture;
public mas2Texture: BABYLON.Texture;
public opacityTexture: BABYLON.Texture;
private _diffuseTexture: BABYLON.Texture;
private _maskTexture: BABYLON.Texture;
private _mask2Texture: BABYLON.Texture;
private _opacityTexture: BABYLON.Texture;
public get diffuseTexture(): BABYLON.Texture {
return this._diffuseTexture;
}
public get maskTexture(): BABYLON.Texture {
return this._maskTexture;
}
public get mask2Texture(): BABYLON.Texture {
return this._mask2Texture;
}
public get opacityTexture(): BABYLON.Texture {
return this._opacityTexture;
}
public set diffuseTexture(val: BABYLON.Texture) {
this._diffuseTexture = val;
this.setTexture("diffuseTexture", val);
}
public set maskTexture(val: BABYLON.Texture) {
this._maskTexture = val;
this.setTexture("maskTexture", val);
}
public set mask2Texture(val: BABYLON.Texture) {
this._mask2Texture = val;
this.setTexture("mask2Texture", val);
}
public set opacityTexture(val: BABYLON.Texture) {
this._opacityTexture = val;
this.setTexture("opacityTexture", val);
}
isReady(mesh?: BABYLON.AbstractMesh, useInstances?: boolean): boolean {
let result = !!this.diffuseTexture && !!this.maskTexture && !!this.mas2Texture;
let result = !!this.diffuseTexture && !!this.maskTexture && !!this.mask2Texture;
return result && super.isReady(mesh, useInstances);
}
bind(world: BABYLON.Matrix, mesh?: BABYLON.Mesh, effectOverride?: BABYLON.Effect): void {
this._tintColor.r = this._emissiveColor.r;
this._tintColor.g = this._emissiveColor.g;
this._tintColor.b = this._emissiveColor.b;
this._diffuseMatrices.copyFrom(this.diffuseTexture.getTextureMatrix());
this._maskMatrices.copyFrom(this.maskTexture.getTextureMatrix());
this._mask2Matrices.copyFrom(this.mas2Texture.getTextureMatrix());
bind(world: BABYLON.Matrix, mesh?: StandardMaterialMesh, effectOverride?: BABYLON.Effect): void {
let matData = mesh?.materialData || this;
this._tintColor.r = matData.emissiveColor.r;
this._tintColor.g = matData.emissiveColor.g;
this._tintColor.b = matData.emissiveColor.b;
this._tintColor.a = matData.alpha;
this._diffuseMatrices.copyFrom(matData.diffuseTexture.getTextureMatrix());
this._maskMatrices.copyFrom(matData.maskTexture.getTextureMatrix());
this._mask2Matrices.copyFrom(this.mask2Texture.getTextureMatrix());
if (this.opacityTexture) {
this._opacityMatrices.copyFrom(this.opacityTexture.getTextureMatrix());
this._opacityMatrices.copyFrom(matData.opacityTexture.getTextureMatrix());
}
this._control.x = (Date.now() - this._time) / 1000;
super.bind(world, mesh, effectOverride);
}
dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void {
this.maskTexture?.dispose();
this.mas2Texture?.dispose();
this.mask2Texture?.dispose();
this.opacityTexture?.dispose();
this.diffuseTexture?.dispose();
super.dispose(forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
......@@ -339,7 +400,7 @@ function loadAsync(context: string, materialInfo: IPIMaterialStandard, mat: Dist
if (materialInfo.diffuseTexture) {
promises.push(_loader.loadTextureInfoAsync(context + "/PI_material/diffuseTexture", materialInfo.diffuseTexture, function (texture: BABYLON.Texture) {
mat.diffuseTexture = texture;
mat.setTexture('diffuseTexture', texture);
// mat.setTexture('diffuseTexture', texture);
if (materialInfo.diffuseTexture.offset) {
(<any>texture).uOffset = materialInfo.diffuseTexture.offset[0];
(<any>texture).vOffset = materialInfo.diffuseTexture.offset[1];
......@@ -364,7 +425,7 @@ function loadAsync(context: string, materialInfo: IPIMaterialStandard, mat: Dist
if (materialInfo.maskTexture) {
promises.push(_loader.loadTextureInfoAsync(context + "/PI_material/maskTexture", materialInfo.maskTexture, function (texture: BABYLON.Texture) {
mat.maskTexture = texture;
mat.setTexture('maskTexture', texture);
// mat.setTexture('maskTexture', texture);
if (materialInfo.maskTexture.offset) {
(<any>texture).uOffset = materialInfo.maskTexture.offset[0];
(<any>texture).vOffset = materialInfo.maskTexture.offset[1];
......@@ -376,15 +437,15 @@ function loadAsync(context: string, materialInfo: IPIMaterialStandard, mat: Dist
}));
if (materialInfo.mask2Texture == undefined) {
promises.push(_loader.loadTextureInfoAsync(context + "/PI_material/maskTexture", materialInfo.maskTexture, function (texture: BABYLON.Texture) {
mat.mas2Texture = texture;
mat.setTexture('mask2Texture', texture);
mat.mask2Texture = texture;
// mat.setTexture('mask2Texture', texture);
}));
}
}
if (materialInfo.mask2Texture) {
promises.push(_loader.loadTextureInfoAsync(context + "/PI_material/mask2Texture", materialInfo.mask2Texture, function (texture: BABYLON.Texture) {
mat.mas2Texture = texture;
mat.setTexture('mask2Texture', texture);
mat.mask2Texture = texture;
// mat.setTexture('mask2Texture', texture);
if (materialInfo.mask2Texture.offset) {
(<any>texture).uOffset = materialInfo.mask2Texture.offset[0];
(<any>texture).vOffset = materialInfo.mask2Texture.offset[1];
......@@ -399,7 +460,7 @@ function loadAsync(context: string, materialInfo: IPIMaterialStandard, mat: Dist
if (materialInfo.opacityTexture) {
promises.push(_loader.loadTextureInfoAsync(context + "/PI_material/opacityTexture", materialInfo.opacityTexture, function (texture: BABYLON.Texture) {
mat.opacityTexture = texture;
mat.setTexture('opacityTexture', texture);
// mat.setTexture('opacityTexture', texture);
if (materialInfo.opacityTexture.offset) {
(<any>texture).uOffset = materialInfo.opacityTexture.offset[0];
(<any>texture).vOffset = materialInfo.opacityTexture.offset[1];
......@@ -484,6 +545,31 @@ function loadAsyncNew(context: string, matInfo: any, mat: DistortionUVMaterial,
if (materialInfo.maskTexture) {
LoadExtraMaterial.maskTexture(mat, _loader, context, matInfo);
if (materialInfo.mask2Texture == undefined) {
let info = matInfo;
let texture = <BABYLON.Texture>_loader.loadTextureInfoAsync(context + "/PI_material/maskTexture", info.maskTexture);
if (mat.mask2Texture) {
mat.mask2Texture.dispose();
}
mat.mask2Texture = texture;
// let numbers = info.maskTexture.scale;
// if (numbers) {
// texture.uScale = numbers[0];
// texture.vScale = numbers[1];
// }
// numbers = info.maskTexture.offset;
// if (numbers) {
// texture.uOffset = numbers[0];
// texture.vOffset = numbers[1];
// }
// let tilloff = info.maskTexture.extras?.atlasTilloff;
// if (tilloff) {
// texture.atlasTilloff = tilloff;
// }
}
}
if (materialInfo.mask2Texture) {
LoadExtraMaterial.mask2Texture(mat, _loader, context, matInfo);
}
if (materialInfo.opacityTexture) {
......@@ -555,6 +641,13 @@ export function registDistortionUVFactory() {
);
LoadExtraMaterial.loadCalls.set("DistortionUV", create);
LoadExtraMaterial.loadPropertyCalls.set("DistortionUV", loadAsyncNew);
BABYLON.GLTF2.Loader.Extensions.PI_material.regist(
"distortionUV",
<any>create,
<any>loadAsync
);
LoadExtraMaterial.loadCalls.set("distortionUV", create);
LoadExtraMaterial.loadPropertyCalls.set("distortionUV", loadAsyncNew);
}
// Effect
......
......@@ -38,7 +38,7 @@ export class MainOpacityMaterial extends BABYLON.StandardMaterial {
LoadExtraMaterial.loadCalls.set("main_opacity", this.create);
LoadExtraMaterial.loadPropertyCalls.set("main_opacity", this.load);
}
protected static create(context: string, babylonScene: BABYLON.Scene, materialName: string, index: number, materialInfo: any, babylonDrawMode: number) {
public static create(context: string, babylonScene: BABYLON.Scene, materialName: string, index: number, materialInfo: any, babylonDrawMode: number) {
if (materialInfo) {
let mat = new MainOpacityMaterial(materialName, babylonScene, OpsPass.Transparent);
let info = materialInfo;
......@@ -61,7 +61,7 @@ export class MainOpacityMaterial extends BABYLON.StandardMaterial {
return undefined;
}
}
protected static load(context: string, material: any, mat: any, _loader: GLTFLoader): Promise<void> {
public static load(context: string, material: any, mat: any, _loader: GLTFLoader): Promise<void> {
let info = material;
......
......@@ -3,6 +3,7 @@ import { IPITextureInfo } from "../material_info";
import { ShaderMaterial } from "./shader_material";
import { GLTFLoader } from "../gltf/glTFLoader";
import { LoadExtraMaterial } from "../render3d/extends/material";
import { StandardMaterialMesh } from "./standardmaterial";
export interface IPIMaterialStandard {
/**
......@@ -125,13 +126,22 @@ export class OpacityClipMaterial extends ShaderMaterial {
let result = !!this.diffuseTexture && !!this.maskTexture;
return result && super.isReady(mesh, useInstances);
}
bind(world: BABYLON.Matrix, mesh?: BABYLON.Mesh, effectOverride?: BABYLON.Effect): void {
this._tintColor.r = this._emissiveColor.r;
this._tintColor.g = this._emissiveColor.g;
this._tintColor.b = this._emissiveColor.b;
this._diffuseMatrices.copyFrom(this.diffuseTexture.getTextureMatrix());
this._maskMatrices.copyFrom(this.maskTexture.getTextureMatrix());
bind(world: BABYLON.Matrix, mesh?: StandardMaterialMesh, effectOverride?: BABYLON.Effect): void {
let matData = mesh?.materialData || this;
this._tintColor.r = matData.emissiveColor.r;
this._tintColor.g = matData.emissiveColor.g;
this._tintColor.b = matData.emissiveColor.b;
this._tintColor.a = matData.alpha;
this._diffuseMatrices.copyFrom(matData.diffuseTexture.getTextureMatrix());
this._maskMatrices.copyFrom(matData.maskTexture.getTextureMatrix());
this._control.x = (Date.now() - this._time) / 1000;
this._control.y = matData.alphaCutOff;
this.setColor4('tintColor', this._tintColor);
this.setMatrix('diffuseMatrix', this._diffuseMatrices);
this.setMatrix('maskMatrix', this._maskMatrices);
this.setVector4("control", this._control);
super.bind(world, mesh, effectOverride);
}
dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void {
......
This diff is collapsed.
......@@ -141,7 +141,7 @@ export function initial() {
if (meshParticleConfig.trail) {
let indexMat = meshParticleConfig.trail.material;
let material = this.gltf.materials[indexMat];
let babylonMaterial = this._loadMaterialAsync("/materials/" + indexMat, indexMat, 0, material, null, 0);
let babylonMaterial = this._loadMaterialAsync("/materials/" + indexMat, indexMat, 0, material, null, 0, true);
meshParticle.psTool.trail.mesh.material = babylonMaterial;
meshParticle.psTool.trail.mesh.alphaIndex = material.extensions.PI_material.renderQueue;
}
......@@ -251,7 +251,7 @@ export function initial() {
let trailPromisre = this._loadMaterialAsync("/materials/" + meshParticleConfig.trail.material, material, null, 0, function(babylonMaterial) {
meshParticle.psTool.trail.mesh.material = babylonMaterial;
meshParticle.psTool.trail.mesh.alphaIndex = material.extensions.PI_material.renderQueue;
});
}, true);
promises.push(trailPromisre);
}
meshParticle.setSourceMesh(null);
......@@ -340,7 +340,7 @@ export function initial() {
let trailPromisre = this._loadMaterialAsync("/materials/" + meshParticleConfig.trail.material, material, null, 0, function(babylonMaterial) {
meshParticle.psTool.trail.mesh.material = babylonMaterial;
meshParticle.psTool.trail.mesh.alphaIndex = material.extensions.PI_material.renderQueue;
});
}, true);
promises.push(trailPromisre);
}
} else {
......@@ -413,6 +413,7 @@ export function initial() {
let primitive = primitives[0];
promises.push(this._loadMeshPrimitiveAsync(`${context}/primitives/${primitive.index}`, `${name}`, node, mesh, primitive, (babylonMesh) => {
node._primitiveBabylonMeshes!.push(babylonMesh);
babylonMesh.geometryForMeshParticle = (<any>this).geometryForMeshParticle;
if (node.meshParticle || node.extras?.meshParticle) {
babylonMesh.setEnabled(false);
......@@ -436,6 +437,7 @@ export function initial() {
for (const primitive of primitives) {
promises.push(this._loadMeshPrimitiveAsync(`${context}/primitives/${primitive.index}`, `${name}#${primitive.index}`, node, mesh, primitive, (babylonMesh) => {
node._primitiveBabylonMeshes!.push(babylonMesh);
babylonMesh.geometryForMeshParticle = (<any>this).geometryForMeshParticle;
if (node.meshParticle || node.extras?.meshParticle) {
babylonMesh.setEnabled(false);
......
......@@ -10,7 +10,9 @@ import { UriLoader } from "./gltf/uri";
import { IMeshMaterial, IMeshRenderQueue } from "./interface/mesh";
import { INodeCollider } from "./interface/collider";
import { ExtensionTools, IOfflineAnimationCfg, ITransformNode, Res, ResTab } from './interface/index';
import { GLTF_LOAD_ANIMATION_CHANNEL_ASYNC_LIST } from "render3d/extends/gltf_loader";
import { MaterialBase } from "./material/base";
import { StandardMaterialMesh } from "./material/standardmaterial";
import { IPrefabRes } from "./model_prefab";
declare let module;
let logger;
......@@ -133,7 +135,9 @@ export class Model implements IModel {
setParent(parent: IModel): void {
this.rootImpl.parent = <BABYLON.TransformNode>parent.rootImpl;
}
reuse() {
}
protected _animations?: BABYLON.AnimationGroup[];
public get animations() {
return this._animations;
......@@ -808,9 +812,15 @@ export class ModelObj extends Model implements IModelObj {
item.stop();
item.dispose();
});
this._materials?.forEach((item) => {
item.dispose();
this._meshMap?.forEach((mesh) => {
if ((<any>mesh).materialData) {
mesh.material = undefined;
}
});
// this._materials?.forEach((item) => {
// item.dispose();
// });
(<BABYLON.AbstractMesh>this.rootImpl)?.dispose(false, disposeMaterialAndTextures);
this._gltf = undefined;
......@@ -836,6 +846,9 @@ export class ModelObj extends Model implements IModelObj {
this.setEnabled(false);
this._modifyUseState();
}
public reuse() {
if (this.isDisposed) return;
}
protected _modifyUseState(): void {
if (this._isEnabled == false) {
this.animationMap?.forEach((group) => {
......
......@@ -12,6 +12,7 @@ export interface IPrefabRes {
extendData: any;
_cached: boolean;
unuse(): void;
reuse(): void;
dispose(): void;
}
......@@ -48,12 +49,13 @@ export class NodeObj implements IPrefab {
if (this._isDisposed) {
this._loadPromise = Promise.reject("Disposed!!");
} else {
if (this._data.isLoaded) {
this._loadPromise = Promise.resolve().then(() => {
this._loaded();
return (this);
});
} else if (this._data.loadPromise) {
// if (this._data.isLoaded) {
// this._loadPromise = Promise.resolve().then(() => {
// this._loaded();
// return (this);
// });
// } else
if (this._data.loadPromise) {
this._loadPromise = this._data.loadPromise.then(() => {
this._loaded();
return (this);
......@@ -100,13 +102,13 @@ export class NodeObj implements IPrefab {
return this._data?.rootImpl;
}
get position() {
return this._data?.position;
return this._data?.position || [0, 0, 0];
}
get scale() {
return this._data?.scale;
return this._data?.scale || [1,1,1];
}
get rotate() {
return this._data?.rotate;
return this._data?.rotate || [0, 0, 0];
}
get animOpt() {
return this._data?.animOpt;
......@@ -139,7 +141,7 @@ export class NodeObj implements IPrefab {
let rootImpl = new BABYLON.TransformNode(name, scene.impl);
model.rootImpl = rootImpl;
(<any>model)._loadPromise = Promise.resolve().then(() => {
model.loaded(rootImpl, [rootImpl], [], [], [], [], [], []);
(<any>model).loaded(rootImpl, [rootImpl], [], [], [], [], [], []);
return model;
});
......@@ -340,17 +342,20 @@ export class ModelPrefab extends NodeObj {
if (this._isDisposed) {
reject("Disposed!!");
} else {
if (this._data.isLoaded) {
this._loaded();
resolve(this);
} else {
// if (this._data.isLoaded) {
// this._loaded();
// resolve(this);
// } else {
this._data.loadPromise.then(() => {
this._loaded();
resolve(this);
})
.catch(e => reject(e));
.catch(e => {
console.log(this.name);
reject(e);
});
}
}
// }
}
);
}
......@@ -488,7 +493,7 @@ export class PrefabModelObjPool implements IPrefabPool {
public scene: SceneStruct;
constructor(scene: SceneStruct) {
this.scene = scene;
this.scene.onBeforeDispose(this.clearPrefabs);
this.scene.onBeforeDispose(this._dispose);
this.registPrefabCfg(NodeObj.PrefabInfo, NodeObj.PrefabCreation);
PrefabModelObjPool.registPrefabFactory(NodeObj.PrefabInfo, NodeObj.Creation);
PrefabModelObjPool.registPrefabResFactory(NodeObj.PrefabInfo, NodeObj.CreationResource);
......@@ -538,6 +543,8 @@ export class PrefabModelObjPool implements IPrefabPool {
prefabres = creation(id, this.scene, cfg);
prefabres._cached = true;
this.single_pools.set(key, prefabres);
} else {
prefabres.reuse();
}
let result = create(this.scene, key, this, prefabres) as T;
prefabres.extendData = extendData;
......@@ -564,6 +571,8 @@ export class PrefabModelObjPool implements IPrefabPool {
prefabres._cached = false;
this.others.set(prefabres, prefabres);
}
} else {
prefabres.reuse();
}
let result = create(this.scene, key, this, prefabres) as T;
prefabres.extendData = extendData;
......@@ -571,8 +580,13 @@ export class PrefabModelObjPool implements IPrefabPool {
return result;
}
}
clearPrefabs = () => {
clearPrefabs() {
this.check();
// return;
this._dispose();
}
protected _dispose = () => {
this.pools.forEach((list) => {
list.forEach((item) => {
item.dispose();
......
......@@ -9,8 +9,9 @@ import { IBufferArg, VertexBuffer } from './buffer';
import { PiBABYLONGeometry } from './geometry';
import { GLTFLoader as GLTFLoaderNew } from '../../gltf/glTFLoader';
import { IAccessor, IAnimation as IAnimationNew } from '../../gltf/glTF2Interface';
import { ITempNodeAnimationAbout } from '../../gltf/base';
import { BABYLON_MATERIAL_NEW, ITempNodeAnimationAbout } from '../../gltf/base';
import { ExtensionTools, Res, ResTab } from '../../interface/index';
import { StandardMaterialData } from '../../material/standardmaterial';
declare let module;
let logger;
......@@ -1049,218 +1050,93 @@ export const initGLTFLoader = () => {
this._parent.dispose();
};
(<any>BABYLON.GLTF2.GLTFLoader.prototype)._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
let resTab = this._metadata.resTab;
let key = `${this._scene.uid}#${this._rootUrl}${context}`;
if (!babylonMesh.geometryForMeshParticle) {
let pmat = resTab.get(BABYLON_MATERIAL_NEW, key);
let promise;
if (pmat == undefined) {
if (assign === void 0) { assign = function () { }; }
var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
if (extensionPromise) {
return extensionPromise;
}
material._data = material._data || {};
var babylonData = material._data[babylonDrawMode];
if (!babylonData) {
this.logOpen(context + " " + (material.name || ""));
var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
babylonData = {
babylonMaterial: babylonMaterial,
babylonMeshes: [],
promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial)
};
material._data[babylonDrawMode] = babylonData;
BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(babylonMaterial, context);
this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
this.logClose();
}
pmat = resTab.createRes(key, BABYLON_MATERIAL_NEW, babylonData.babylonMaterial, []);
promise = babylonData.promise;
} else {
promise = Promise.resolve();
}
// /** @hidden */
// (<any>BABYLON.GLTF2.GLTFLoader.prototype)._createTextureAsync = function (context, sampler, image, invertY, assign, textureLoaderOptions) {
// var _this = this;
// if (assign === void 0) { assign = function () { }; }
// var samplerData = this._loadSampler("/samplers/" + sampler.index, sampler);
// var promises = new Array();
// // var deferred = new Deferred();
// let deferred: any = {};
// deferred.promise = new Promise(function (resolve, reject) {
// deferred.resolve = resolve;
// deferred.reject = reject;
// });
// this._babylonScene._blockEntityCollection = this._forAssetContainer;
// var babylonTexture = new BABYLON.Texture(null, this._babylonScene, samplerData.noMipMaps, invertY, samplerData.samplingMode, function () {
// if (!_this._disposed) {
// deferred.resolve();
// }
// }, function (message, exception) {
// if (!_this._disposed) {
// deferred.reject(new Error(context + ": " + ((exception && exception.message) ? exception.message : message || "Failed to load texture")));
// }
// }, undefined, undefined, undefined, image.mimeType, textureLoaderOptions);
// this._babylonScene._blockEntityCollection = false;
// promises.push(deferred.promise);
// // promises.push(this.loadImageAsync(`/images/${image.index}`, image).then((data) => {
// // const name = image.uri || `${this._fileName}#image${image.index}`;
// // const dataUrl = `data:${this._uniqueRootUrl}${name}`;
// // babylonTexture.updateURL(dataUrl, data);
// // }));
// babylonTexture.wrapU = samplerData.wrapU;
// babylonTexture.wrapV = samplerData.wrapV;
// let path = BABYLON.GLTF2.GLTFLoader.formatUrl(this._rootUrl, image.uri);
// // PI_BEGIN - 20200309 扩展纹理uri可以为相对路径
// babylonTexture.updateURL(path);
// // PI_END
// assign(babylonTexture);
// if (_this._textures == undefined) {
// _this._textures = [];
// }
// _this._textures.push([<BABYLON.Texture>babylonTexture, path]);
// return Promise.all(promises).then(function () {
// return babylonTexture;
// });
// };
// /** @hidden */
// // PI_BEGIN - 20200309 扩展可变纹理数据
// // public importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult> {
// // ///////////////////////////////////////
// (<any>BABYLON.GLTF2.GLTFLoader.prototype).importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName, metadata) {
// // PI_END
// var _this = this;
// // return Promise.resolve().then(() => {
// return new Promise(function (resolve, reject) {
// BABYLON.GLTF2.GLTFLoader.PiAsyncCall(function () {
// // PI_BEGIN - 20200309 扩展可变纹理数据
// _this._metadata = metadata;
// // PI_END
// _this._babylonScene = scene;
// _this._rootUrl = rootUrl;
// _this._fileName = fileName || "scene";
// _this._forAssetContainer = forAssetContainer;
// _this._loadData(data);
// var nodes = null;
// if (meshesNames) {
// var nodeMap_1 = {};
// if (_this._gltf.nodes) {
// for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
// var node = _a[_i];
// if (node.name) {
// nodeMap_1[node.name] = node.index;
// }
// }
// }
// var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
// nodes = names.map(function (name) {
// var node = nodeMap_1[name];
// if (node === undefined) {
// throw new Error("Failed to find node '" + name + "'");
// }
// return node;
// });
// }
// // PI_BEGIN - 20200916 - 加载时提取克隆数据
// _this._getMeshes()[0].metadata = _this._getMeshes()[0].metadata || {};
// _this._getMeshes()[0].metadata.cloneData = {
// skeletonCloneInfo: _this._skeletonCloneInfo,
// particleCloneInfo: _this._particleCloneInfo
// };
// // PI_END
// var $p = _this._loadAsync(nodes, function () {
// var tempLocalLights = [];
// var count = _this._babylonLights.length;
// for (var i = 0; i < count; i++) {
// var light = _this._babylonLights[i];
// if (light.onlyWorkInLocal) {
// tempLocalLights.push(light);
// }
// }
// var meshes = _this._getMeshes();
// _this._rootBabylonMesh.metadata.localLights = tempLocalLights;
// if (tempLocalLights.length > 0) {
// count = meshes.length;
// for (var i = 0; i < count; i++) {
// meshes[i].checkLightsOnlyWorkInLocal(tempLocalLights);
// }
// }
// resolve({
// meshes: meshes,
// // PI_BEGIN - 20200916 - 返回粒子记录
// // particleSystems: [],
// particleSystems: _this._particles,
// // PI_END
// // PI_BEGIN - 20200916 - 返回骨骼记录
// skeletons: _this._skeletons,
// // PI_END
// animationGroups: _this._getAnimationGroups(),
// lights: _this._babylonLights,
// transformNodes: _this._getTransformNodes(),
// geometries: _this._getGeometries(),
// xx_skeletons: _this._getSkeletons(),
// textures: _this._textures,
// });
// });
// _this.RecordPromise("importMeshAsync - " + meshesNames, $p);
// }, null);
// });
// };
// BABYLON.SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension, metadata) {
// if (sceneFilename === void 0) { sceneFilename = ""; }
// // if (scene === void 0) { scene = EngineStore.LastCreatedScene; }
// if (onSuccess === void 0) { onSuccess = null; }
// if (onProgress === void 0) { onProgress = null; }
// if (onError === void 0) { onError = null; }
// if (pluginExtension === void 0) { pluginExtension = null; }
// if (metadata === void 0) { metadata = null; }
// if (!scene) {
// // Logger.Error("No scene available to import mesh to");
// return null;
// }
// var fileInfo = BABYLON.SceneLoader._GetFileInfo(rootUrl, sceneFilename);
// if (!fileInfo) {
// return null;
// }
// // PI_BEGIN - 拓展 数据 - 便于出错时调试
// var loadingToken = {
// rootUrl: rootUrl,
// sceneFilename: sceneFilename
// };
// // PI_END
// scene._addPendingData(loadingToken);
// var disposeHandler = function () {
// scene._removePendingData(loadingToken);
// };
// var errorHandler = function (message, exception) {
// var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
// if (onError) {
// onError(scene, errorMessage, exception);
// }
// else {
// // Logger.Error(errorMessage);
// // should the exception be thrown?
// }
// disposeHandler();
// };
// var progressHandler = onProgress ? function (event) {
// try {
// onProgress(event);
// }
// catch (e) {
// errorHandler("Error in onProgress callback", e);
// }
// } : undefined;
// var successHandler = function (meshes, particleSystems, skeletons, animationGroups, textures) {
// scene.importedMeshesFiles.push(fileInfo.url);
// if (onSuccess) {
// try {
// onSuccess(meshes, particleSystems, skeletons, animationGroups, [], [], [], textures);
// }
// catch (e) {
// errorHandler("Error in onSuccess callback", e);
// }
// }
// scene._removePendingData(loadingToken);
// };
// return BABYLON.SceneLoader._LoadData(fileInfo, scene, function (plugin, data, responseURL) {
// if (plugin.rewriteRootURL) {
// fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
// }
// if (plugin.importMesh) {
// var syncedPlugin = plugin;
// var meshes = new Array();
// var particleSystems = new Array();
// var skeletons = new Array();
// if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler, metadata)) {
// return;
// }
// scene.loadingPluginName = plugin.name;
// successHandler(meshes, particleSystems, skeletons, [], []);
// }
// else {
// var asyncedPlugin = plugin;
// asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name, metadata).then(function (result) {
// scene.loadingPluginName = plugin.name;
// successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups, result.textures);
// }).catch(function (error) {
// errorHandler(error.message, error);
// });
// }
// }, progressHandler, errorHandler, disposeHandler, pluginExtension);
// };
if (babylonMesh) {
babylonData.babylonMeshes.push(babylonMesh);
babylonMesh.onDisposeObservable.addOnce(function () {
var index = babylonData.babylonMeshes.indexOf(babylonMesh);
if (index !== -1) {
babylonData.babylonMeshes.splice(index, 1);
}
});
if (!babylonMesh.geometryForMeshParticle) {
babylonMesh.materialData = new StandardMaterialData(this._babylonScene);
babylonMesh.materialData.fromMaterial(<any>pmat.link);
}
}
assign(pmat.link);
return promise.then(function () {
return pmat.link;
});
} else {
if (assign === void 0) { assign = function () { }; }
var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
if (extensionPromise) {
return extensionPromise;
}
material._data = material._data || {};
var babylonData = material._data[babylonDrawMode];
if (!babylonData) {
this.logOpen(context + " " + (material.name || ""));
var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
babylonData = {
babylonMaterial: babylonMaterial,
babylonMeshes: [],
promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial)
};
material._data[babylonDrawMode] = babylonData;
BABYLON.GLTF2.GLTFLoader.AddPointerMetadata(babylonMaterial, context);
this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
this.logClose();
}
if (babylonMesh) {
babylonData.babylonMeshes.push(babylonMesh);
babylonMesh.onDisposeObservable.addOnce(function () {
var index = babylonData.babylonMeshes.indexOf(babylonMesh);
if (index !== -1) {
babylonData.babylonMeshes.splice(index, 1);
}
});
}
assign(babylonData.babylonMaterial);
return babylonData.promise.then(function () {
return babylonData.babylonMaterial;
});
}
};
}
//#endregion
......@@ -1286,4 +1162,3 @@ export class AnimationKey<T extends AnimationValue > {
}
}
This diff is collapsed.
......@@ -4,6 +4,7 @@ import { GLTF_LOAD_ANIMATION_CHANNEL_ASYNC_LIST_NEW, IAnimationChannel } from ".
import { IAnimation } from "../../gltf/glTF2Interface";
import { GLTFLoader } from "../../gltf/glTFLoader";
import { ETempNodeAnimationDataKey } from "../../gltf/base";
import { StandardMaterialMesh } from "../../material/standardmaterial";
export function initGLTFLoadAnimaitonChannelNew() {
// "translation", "rotation", "scale",
......@@ -97,6 +98,69 @@ function _transformNode(loader: GLTFLoader, context: string, animationContext: s
loader.loaderRecord.animationLoaderList.push(promise);
return promise;
}
function _mesh(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup, propPath: string, targetPath: string, animationType: number) {
let animeAbout = loader.loaderRecord.nodeAnimationAbout.get(channel[1]);
let targetNode = <StandardMaterialMesh[]>animeAbout[ETempNodeAnimationDataKey.Mesh];
let promise = loader._loadAnimationKeysAsync(context, animationContext, animation, channel, targetPath).then((keys) => {
const animationName = `${babylonAnimationGroup.name}_channel${babylonAnimationGroup.targetedAnimations.length}`;
const babylonAnimation = new BABYLON.Animation(animationName, propPath, 1, animationType);
babylonAnimation.setKeys(keys.link);
(<AnimationGroup>babylonAnimationGroup).piRecordRes(keys);
if (targetNode) {
// tslint:disable-next-line:no-non-null-assertion
const babylonAnimationTargets = [];
for (const babylonAnimationTarget of targetNode) {
let target = babylonAnimationTarget.materialData || babylonAnimationTarget.material;
target.animations.push(babylonAnimation);
babylonAnimationTargets.push(babylonAnimationTarget.materialData);
}
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonAnimationTargets);
}
});
loader.loaderRecord.animationLoaderList.push(promise);
return promise;
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alpha', 'alpha', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _meshTexture(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup, texturePropPath: string, propPath: string, targetPath: string, animationType: number) {
let animeAbout = loader.loaderRecord.nodeAnimationAbout.get(channel[1]);
let targetNode = <StandardMaterialMesh[]>animeAbout[ETempNodeAnimationDataKey.Mesh];
let promise = loader._loadAnimationKeysAsync(context, animationContext, animation, channel, targetPath).then((keys) => {
const animationName = `${babylonAnimationGroup.name}_channel${babylonAnimationGroup.targetedAnimations.length}`;
const babylonAnimation = new BABYLON.Animation(animationName, propPath, 1, animationType);
babylonAnimation.setKeys(keys.link);
(<AnimationGroup>babylonAnimationGroup).piRecordRes(keys);
if (targetNode) {
// tslint:disable-next-line:no-non-null-assertion
const babylonAnimationTargets = [];
for (const node of targetNode) {
let target = node.materialData || node.material;
const texture = target[texturePropPath];
let sameNameIndex = texture.animations.findIndex((v) => {
return v.name == animationName;
});
if (sameNameIndex >= 0) {
// No thing
} else {
babylonAnimationTargets.push(texture);
const babylonAnimation = new BABYLON.Animation(animationName, propPath, 1, animationType);
babylonAnimation.setKeys(keys.link);
(<AnimationGroup>babylonAnimationGroup).piRecordRes(keys);
texture.animations.push(babylonAnimation);
babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonAnimationTargets);
}
}
}
});
loader.loaderRecord.animationLoaderList.push(promise);
return promise;
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alpha', 'alpha', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _translation(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _transformNode(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'position', BABYLON.Animation.ANIMATIONTYPE_VECTOR3);
}
......@@ -159,16 +223,20 @@ function _material(loader: GLTFLoader, context: string, animationContext: string
return promise;
}
function _color(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'emissiveColor', 'color', BABYLON.Animation.ANIMATIONTYPE_COLOR3);
return _mesh(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'emissiveColor', 'color', BABYLON.Animation.ANIMATIONTYPE_COLOR3);
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'emissiveColor', 'color', BABYLON.Animation.ANIMATIONTYPE_COLOR3);
}
function _alpha(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alpha', 'alpha', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _mesh(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alpha', 'alpha', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alpha', 'alpha', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _alphaCutOff(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alphaCutOff', 'alphaCutOff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _mesh(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alphaCutOff', 'alphaCutOff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'alphaCutOff', 'alphaCutOff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _maskCutoff(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskCutoff', 'maskCutoff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _mesh(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskCutoff', 'maskCutoff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _material(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskCutoff', 'maskCutoff', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
// Texture About
......@@ -202,40 +270,52 @@ function _texture(loader: GLTFLoader, context: string, animationContext: string,
return promise;
}
function _uScale(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vScale(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _uOffset(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vOffset(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'diffuseTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _uScaleOp(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vScaleOp(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _uOffsetOp(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vOffsetOp(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'opacityTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _uScaleM(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uScale', 'uScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vScaleM(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vScale', 'vScale', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _uOffsetM(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'uOffset', 'uOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
function _vOffsetM(loader: GLTFLoader, context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: BABYLON.AnimationGroup) {
return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
return _meshTexture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
// return _texture(loader, context, animationContext, animation, channel, babylonAnimationGroup, 'maskTexture', 'vOffset', 'vOffset', BABYLON.Animation.ANIMATIONTYPE_FLOAT);
}
// Camera About
......
......@@ -7,7 +7,7 @@ import { IPITextureInfo } from "../../material_info";
export class LoadExtraMaterial {
public static init() {
PI_material.prototype.createMaterial = function (this: PI_material, context: string, indexMat: number, indexNode: number, material: IMaterial, babylonDrawMode: number) {
PI_material.prototype.createMaterial = function (this: PI_material, context: string, indexMat: number, indexNode: number, material: IMaterial, babylonDrawMode: number, notParticleSys?: boolean) {
if (material.extensions && material.extensions.PI_material) {
let materialMap = this._loader.babylonScene.pi_material_map;
......@@ -23,7 +23,7 @@ export class LoadExtraMaterial {
let key = materialType;
let call = LoadExtraMaterial.loadCalls.get(key);
if (call) {
let mat = call(context, this._loader.babylonScene, material.name, indexMat, materialInfo, babylonDrawMode);
let mat = call(context, this._loader.babylonScene, material.name, indexMat, materialInfo, babylonDrawMode, notParticleSys);
return mat;
}
......@@ -58,7 +58,7 @@ export class LoadExtraMaterial {
for (let key in matInfo.extras) {
let call = LoadExtraMaterial.loadCalls.get(key);
if (call) {
let mat = call(context, this._loader.babylonScene, material.name, indexMat, matInfo.extras[key], babylonDrawMode);
let mat = call(context, this._loader.babylonScene, material.name, indexMat, matInfo.extras[key], babylonDrawMode, notParticleSys);
return mat;
// if (mat != undefined) {
// flag = true;
......@@ -67,7 +67,7 @@ export class LoadExtraMaterial {
let key2 = matInfo.extras[key].type;
let call = LoadExtraMaterial.loadCalls.get(key2);
if (call) {
let mat = call(context, this._loader.babylonScene, material.name, indexMat, matInfo.extras[key], babylonDrawMode);
let mat = call(context, this._loader.babylonScene, material.name, indexMat, matInfo.extras[key], babylonDrawMode, notParticleSys);
return mat;
// if (mat != undefined) {
// flag = true;
......@@ -87,7 +87,7 @@ export class LoadExtraMaterial {
return null;
}
}
PI_material.prototype.loadMaterialPropertiesAsync = function (this: PI_material, context: string, material: IMaterial, mat: BABYLON.Material) {
PI_material.prototype.loadMaterialPropertiesAsync = function (this: PI_material, context: string, material: IMaterial, mat: BABYLON.Material, notParticleSys?: boolean) {
if (material.extensions && material.extensions.PI_material) {
let materialType = material.extensions.PI_material.type;
let materialInfo = material.extensions.PI_material;
......@@ -101,7 +101,7 @@ export class LoadExtraMaterial {
let key = materialType;
let call = LoadExtraMaterial.loadPropertyCalls.get(key);
if (call) {
return call(context, materialInfo, mat, this._loader);
return call(context, materialInfo, mat, this._loader, notParticleSys);
}
// let loadAsync = PI_material.MaterialPropertiesLoadAsyncMap.get(materialType);
......@@ -117,12 +117,12 @@ export class LoadExtraMaterial {
for (let key in matInfo.extras) {
let call = LoadExtraMaterial.loadPropertyCalls.get(key);
if (call) {
return call(context, matInfo.extras[key], mat, this._loader);
return call(context, matInfo.extras[key], mat, this._loader, notParticleSys);
} else if (matInfo.extras[key].type) {
let key2 = matInfo.extras[key].type;
let call = LoadExtraMaterial.loadPropertyCalls.get(key2);
if (call) {
return call(context, matInfo.extras[key], mat, this._loader);
return call(context, matInfo.extras[key], mat, this._loader, notParticleSys);
}
}
}
......@@ -132,10 +132,15 @@ export class LoadExtraMaterial {
}
}
}
public static loadCalls: Map<string, (context: string, babylonScene: BABYLON.Scene, materialName: string, index: number, materialInfo: BABYLON.GLTF2.Loader.IPIMaterial, babylonDrawMode: number) => BABYLON.Material> = new Map();
public static loadPropertyCalls: Map<string, (context: string, material: BABYLON.GLTF2.Loader.IPIMaterial, mat: BABYLON.Material, _loader: GLTFLoader) => void> = new Map();
public static loadCalls: Map<string, (context: string, babylonScene: BABYLON.Scene, materialName: string, index: number, materialInfo: BABYLON.GLTF2.Loader.IPIMaterial, babylonDrawMode: number, notParticleSys?: boolean) => BABYLON.Material> = new Map();
public static loadPropertyCalls: Map<string, (context: string, material: BABYLON.GLTF2.Loader.IPIMaterial, mat: BABYLON.Material, _loader: GLTFLoader, notParticleSys?: boolean) => void> = new Map();
public static diffuseTexture(mat: { diffuseTexture: BABYLON.Texture }, _loader: GLTFLoader, context: string, info: { diffuseTexture: IPITextureInfo, diffuseLevel?: number, diffuseOU?: number, diffuseOV?: number }) {
public static diffuseTexture(mat: { diffuseTexture: BABYLON.Texture, useAlphaFromDiffuseTexture?: boolean, diffuseTexturePremultiplyAlpha?: boolean }, _loader: GLTFLoader, context: string,
info: {
diffuseTexture: IPITextureInfo, diffuseLevel?: number, diffuseOU?: number, diffuseOV?: number,
useAlphaFromDiffuseTexture?: boolean, diffusePreAlpha?: boolean
}
) {
if (info.diffuseTexture) {
let texture = <BABYLON.Texture>_loader.loadTextureInfoAsync(context + "/PI_material/emissionTexture", info.diffuseTexture);
......@@ -169,6 +174,15 @@ export class LoadExtraMaterial {
if (tilloff) {
texture.atlasTilloff = tilloff;
}
if (info.useAlphaFromDiffuseTexture) {
mat.useAlphaFromDiffuseTexture = info.useAlphaFromDiffuseTexture;
}
if (info.diffuseTexture.hasAlpha) {
texture.hasAlpha = true;
}
if (info.diffusePreAlpha) {
mat.diffuseTexturePremultiplyAlpha = true;
}
} else {
// return Promise.resolve(null);
}
......@@ -212,7 +226,7 @@ export class LoadExtraMaterial {
}
}
public static opacityTexture(mat: { opacityTexture: BABYLON.Texture }, _loader: GLTFLoader, context: string, info: { opacityTexture?: any, opacityLevel?: number, opacityOU?: number, opacityOV?: number }) {
public static opacityTexture(mat: { opacityTexture: BABYLON.Texture, opacityTextureApplyRGB?: boolean }, _loader: GLTFLoader, context: string, info: { opacityTexture?: any, opacityLevel?: number, opacityOU?: number, opacityOV?: number, opacityApplyRGB?: boolean }) {
if (info.opacityTexture) {
let texture = <BABYLON.Texture>_loader.loadTextureInfoAsync(context + "/PI_material/opacityTexture", info.opacityTexture);
if (mat.opacityTexture) {
......@@ -245,6 +259,9 @@ export class LoadExtraMaterial {
if (tilloff) {
texture.atlasTilloff = tilloff;
}
if (info.opacityApplyRGB) {
mat.opacityTextureApplyRGB = true;
}
} else {
// return Promise.resolve(null);
}
......@@ -276,6 +293,33 @@ export class LoadExtraMaterial {
// return Promise.resolve(null);
}
}
public static mask2Texture(mat: { mask2Texture: any }, _loader: GLTFLoader, context: string, info: { mask2Texture?: IPITextureInfo, emissiveMapLevel?: number, emissionOU?: number, emissionOV?: number }) {
if (info.mask2Texture) {
let texture = <BABYLON.Texture>_loader.loadTextureInfoAsync(context + "/PI_material/mask2Texture", info.mask2Texture);
if (mat.mask2Texture) {
mat.mask2Texture.dispose();
}
(<any>mat).mask2Texture = texture;
let numbers = info.mask2Texture.scale;
if (numbers) {
texture.uScale = numbers[0];
texture.vScale = numbers[1];
}
numbers = info.mask2Texture.offset;
if (numbers) {
texture.uOffset = numbers[0];
texture.vOffset = numbers[1];
}
let tilloff = info.mask2Texture.extras?.atlasTilloff;
if (tilloff) {
texture.atlasTilloff = tilloff;
}
// });
} else {
// return Promise.resolve(null);
}
}
public static state(mat: BABYLON.StandardMaterial, info: any, _loader: GLTFLoader) {
let float = info.alpha;
......
......@@ -5,7 +5,7 @@ import { BABYLON } from './render3d/babylon';
import { ITransformCfg } from './interface/modelobj';
import { ModelObj } from './model_obj';
import { OfflineProvider } from './render3d/offline_provider';
import { GLTFLoader } from './gltf/glTFLoader';
import { GLTFLoader, GLTFLodResult } from './gltf/glTFLoader';
import { ITransformNode } from './interface/transform';
import { ExtensionTools } from './interface/index';
......@@ -180,7 +180,7 @@ export class LoaderTool {
* @param targetPath 如果赋值(完整路径)将忽略 model 配置的路径
* @param targetFile 如果赋值(完整路径)将忽略 model 配置的路径
*/
public static insertMeshAsync(model: ModelObj, targetPath?: string, targetFile?: string) {
public static insertMeshAsync(model: ModelObj, targetPath?: string, targetFile?: string): Promise<GLTFLodResult> {
const name = model.name;
const path = model.path;
const fileName = model.fileName;
......@@ -194,6 +194,44 @@ export class LoaderTool {
let loader = new GLTFLoader(sceneImpl, model.resTab, targetPath, targetFile, fileName, undefined, model.gltfModifyConfig);
return loader.loadAsync();
} else {
return new Promise(
function (resolve, reject) {
BABYLON.SceneLoader.ImportMesh(
modelName,
targetPath,
targetFile,
sceneImpl,
(meshes, particleSystems, skeletons, animationGroups, transformNodes, geometries, lights) => {
// resolve({
// meshes: meshes,
// particleSystems: particleSystems,
// skeletons: skeletons,
// animationGroups: animationGroups,
// transformNodes: transformNodes,
// geometries: geometries,
// lights: lights
// });
resolve({
_root_: meshes[0],
nodes: transformNodes,
meshes: meshes,
particles: particleSystems,
materials: [],
animationGroups: animationGroups,
// skeletons: skeletons,
// gltf: (<any>res).gltf
})
},
(e) => {
logger.info('%o', e);
}, function (scene, message, exception) {
reject(exception || new Error(message));
}, undefined, model.gltfModifyConfig
);
}
);
return BABYLON.SceneLoader.ImportMeshAsync(
modelName,
targetPath,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment