repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getOcclusionTexture | getOcclusionTexture (): Texture {
return this.occlusionTexture as Texture;
} | /**
* 获取遮挡纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L775-L777 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setOcclusionTexture | setOcclusionTexture (val: Texture) {
this.occlusionTexture = val;
} | /**
* 设置遮挡纹理
* @param val - 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L783-L785 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.hasEmissiveTexture | hasEmissiveTexture (): boolean {
return this.emissiveTexture !== undefined;
} | /**
* 是否有自发光纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L791-L793 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getEmissiveTexture | getEmissiveTexture (): Texture {
return this.emissiveTexture as Texture;
} | /**
* 获取自发光纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L799-L801 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setEmissiveTexture | setEmissiveTexture (val: Texture) {
this.emissiveTexture = val;
} | /**
* 设置自发光纹理
* @param val - 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L807-L809 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.hasEmissiveValue | hasEmissiveValue (): boolean {
return this.emissiveFactor.luminance() * this.emissiveIntensity > 0;
} | /**
* 是否有自发光值,包含强度
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L815-L817 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getEmissiveFactor | getEmissiveFactor (): Color {
return this.emissiveFactor;
} | /**
* 获取自发光颜色
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L823-L825 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setEmissiveFactor | setEmissiveFactor (val: Color | Vector3 | spec.vec3) {
if (val instanceof Color) {
// Color
this.emissiveFactor.set(val.r, val.g, val.b, val.a);
} else if (val instanceof Vector3) {
// Vector3
this.emissiveFactor.set(val.x, val.y, val.z, 0);
} else {
// vec3
this.emissive... | /**
* 设置自发光颜色
* @param val - 颜色
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L831-L842 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getEmissiveIntensity | getEmissiveIntensity (): number {
return this.emissiveIntensity;
} | /**
* 获取自发光强度
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L848-L850 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setEmissiveIntensity | setEmissiveIntensity (val: number) {
this.emissiveIntensity = val;
} | /**
* 设置自发光强度
* @param val - 强度
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L856-L858 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.constructor | constructor (
private engine: Engine,
name: string,
meshData: ModelMeshComponentData,
owner: ModelMeshComponent,
parentId?: string,
parent?: VFXItem,
) {
super();
const proxy = new EffectsMeshProxy(meshData, owner, parent);
this.name = name;
this.type = PObjectType.mesh;
t... | /**
* 构造函数,创建 Mesh 对象,并与所属组件和父元素相关联
* @param engine - 引擎
* @param name - 名称
* @param meshData - Mesh 参数
* @param owner - 所属的 Mesh 组件
* @param parentId - 父元素索引
* @param parent - 父元素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L90-L131 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.build | build (scene: PSceneManager) {
if (this.isBuilt) {
return;
}
this.isBuilt = true;
this.subMeshes.forEach(prim => {
prim.build(scene.maxLightCount, scene.skybox);
});
if (PGlobalState.getInstance().visBoundingBox) {
this.boundingBoxMesh = new BoxMesh(this.engine, this.priority... | /**
* 创建 GE 的 Mesh、Geometry 和 Material 对象
* @param scene - 场景管理器
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L138-L151 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.update | override update () {
if (this.owner !== undefined) {
this.transform.fromEffectsTransform(this.owner.transform);
if (this.morph && this.morph.hasMorph() && this.owner.morphWeights.length > 0) {
this.morph.updateWeights(this.owner.morphWeights);
}
}
} | /**
* 更新变换数据和蒙皮数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L156-L164 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.lateUpdate | lateUpdate () {
this.skin?.updateSkinMatrices();
} | /**
* 更新骨骼动画
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L169-L171 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.render | override render (scene: PSceneManager, renderer: Renderer) {
this.updateMaterial(scene);
this.subMeshes.forEach((subMesh, index) => {
renderer.drawGeometry(
subMesh.getEffectsGeometry(),
subMesh.getEffectsMaterial(),
index
);
});
if (this.visBoundingBox && this.boun... | /**
* 渲染 Mesh 对象,需要将内部相关数据传给渲染器
* @param scene - 场景
* @param renderer - 渲染器
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L178-L194 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.dispose | override dispose () {
if (this.isDisposed) {
return;
}
super.dispose();
this.owner = undefined;
this.isDisposed = true;
// @ts-expect-error
this.engine = null;
this.parentItem = undefined;
this.skin?.dispose();
this.skin = undefined;
this.morph?.dispose();
this.mo... | /**
* 销毁,需要主动释放蒙皮、morph 和 Mesh 等相关的对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L200-L222 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.updateMorphWeights | updateMorphWeights (weightsArray: Float32Array) {
if (this.morph === undefined || !this.morph.hasMorph()) {
return;
}
const updatedArray = this.morph.morphWeightsArray;
if (updatedArray === undefined) {
return;
}
if (updatedArray.length != weightsArray.length) {
throw new Er... | /**
* 更新 Morph 动画权重
* 每帧都会更新 Morph 动画权重,需要小心检查 Morph 动画参数
* 对于数组长度对不上的情况,直接报错
*
* @param weightsArray - Morph 动画的权重数组
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L231-L249 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.updateParentInfo | updateParentInfo (parentId: string, parentItem: VFXItem) {
this.parentItemId = parentId;
this.parentItem = parentItem;
if (this.skin !== undefined) {
this.skin.updateParentItem(parentItem);
}
} | /**
* 更新父 VFX 元素
* @param parentId - 父元素索引
* @param parentItem - 父 VFX 元素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L256-L262 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.updateMaterial | updateMaterial (scene: PSceneManager) {
const worldMatrix = this.matrix;
const normalMatrix = worldMatrix.clone().invert().transpose();
const sceneStates = scene.sceneStates;
this.subMeshes.forEach(prim => {
prim.updateMaterial(worldMatrix, normalMatrix, sceneStates);
});
if (this.boundi... | /**
* 根据当前场景状态更新内部材质数据
* @param scene - 场景管理器
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L268-L296 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.hitTesting | hitTesting (rayOrigin: Vector3, rayDirection: Vector3): Vector3[] {
const worldMatrix = this.matrix;
const invWorldMatrix = worldMatrix.clone().invert();
const newOrigin = invWorldMatrix.transformPoint(rayOrigin, new Vector3());
const newDirection = invWorldMatrix.transformNormal(rayDirection, new Vecto... | /**
* 点击测试,对于编辑器模式会进行精准的点击测试,否则就和内部的包围盒进行测试
* @param rayOrigin - 射线原点
* @param rayDirection - 射线方向
* @returns 交点列表
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L304-L342 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.computeBoundingBox | computeBoundingBox (worldMatrix: Matrix4): Box3 {
const box = this.boundingBox.makeEmpty();
const inverseWorldMatrix = worldMatrix.clone().invert();
this.subMeshes.forEach(prim => {
const subbox = prim.computeBoundingBox(inverseWorldMatrix);
box.union(subbox);
});
return box;
} | /**
* 计算包围盒,根据传入的世界矩阵
* @param worldMatrix - 世界矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L349-L360 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.getParentId | getParentId (): string | undefined {
return this.parentItemId;
} | /**
* 获取父节点 id
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L391-L393 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMesh.hasSkin | get hasSkin (): boolean {
return this.skin !== undefined;
} | /**
* 是否有蒙皮
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L398-L400 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.create | create (geometry: Geometry, material: Material, parent: PMesh) {
this.parent = parent;
this.skin = parent.skin;
this.morph = parent.morph;
this.setGeometry(geometry);
this.setMaterial(material);
this.name = parent.name;
this.effectsPriority = parent.priority;
this.geometry.setHide(parent... | /**
* 创建 Primitive 对象
* @param data - Primitive 参数
* @param parent - 所属 Mesh 对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L450-L486 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.build | build (lightCount: number, skybox?: PSkybox) {
const globalState = PGlobalState.getInstance();
const primitiveMacroList = this.getMacroList(lightCount, true, skybox);
const materialMacroList = this.material.getMacroList(primitiveMacroList);
let material: Material;
const isWebGL2 = PGlobalState.getI... | /**
* 创建 GE Mesh、Geometry 和 Material 对象,用于后面的渲染
* @param lightCount - 灯光数目
* @param skybox - 天空盒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L493-L525 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.getFeatureList | private getFeatureList (lightCount: number, pbrPass: boolean, skybox?: PSkybox): string[] {
const featureList: string[] = [];
if (this.geometry.hasNormals()) {
featureList.push('HAS_NORMALS 1');
}
if (this.geometry.hasTangents()) {
featureList.push('HAS_TANGENTS 1');
}
if (this.geom... | // TODO: 待移除? | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L528-L605 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.dispose | dispose () {
// @ts-expect-error
this.engine = null;
this.parent = undefined;
this.skin = undefined;
this.morph = undefined;
this.geometry.dispose();
this.material.dispose();
//
this.jointMatrixList = undefined;
this.jointNormalMatList = undefined;
this.jointMatrixTexture?.di... | /**
* 销毁,需要释放创建的 GE 对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L687-L702 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.updateMaterial | updateMaterial (worldMatrix: Matrix4, nomralMatrix: Matrix4, sceneStates: PSceneStates) {
this.updateUniformsByAnimation(worldMatrix, nomralMatrix);
this.updateUniformsByScene(sceneStates);
this.material.updateUniforms(this.getEffectsMaterial());
} | /**
* 更新内部 GE 材质着色器 Uniform 数据,根据场景状态
* @param worldMatrix - 世界矩阵
* @param nomralMatrix - 法线矩阵
* @param sceneStates - 场景状态
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L710-L714 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.hitTesting | hitTesting (newOrigin: Vector3, newDirection: Vector3, worldMatrix: Matrix4, invWorldMatrix: Matrix4) {
const bounding = this.boundingBox;
const boxt = RayBoxTesting(newOrigin, newDirection, bounding.min, bounding.max);
const bindMatrices: Matrix4[] = [];
if (boxt === undefined) {
return;
}
... | /**
* 点击测试,先进行简单的包围合测试,然后再计算精准的点击测试,这个测试非常耗时不要在移动端上使用
* @param newOrigin - 射线原点
* @param newDirection - 射线方向
* @param worldMatrix - 世界矩阵
* @param invWorldMatrix - 逆世界矩阵
* @returns 射线的 t 参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L724-L747 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.computeBoundingBox | computeBoundingBox (inverseWorldMatrix: Matrix4): Box3 {
if (this.skin === undefined && !this.boundingBox.isEmpty()) {
// 包围盒缓存了,直接返回计算的结果
return this.boundingBox;
}
// 重新计算包围盒
const bindMatrices: Matrix4[] = [];
if (this.skin !== undefined) {
const animMatrices = this.skin.anima... | /**
* 计算包围盒
* @param inverseWorldMatrix - 逆世界矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L754-L776 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.getRenderMode3DDefine | getRenderMode3DDefine (mode: spec.RenderMode3D): string | undefined {
switch (mode) {
case spec.RenderMode3D.uv:
return 'DEBUG_UV';
case spec.RenderMode3D.normal:
return 'DEBUG_NORMAL';
case spec.RenderMode3D.basecolor:
return 'DEBUG_BASECOLOR';
case spec.RenderMode3D... | /**
* 渲染输出模式转成着色器中的宏定义
* @param mode - 渲染输出模式
* @returns 返回相应的宏定义
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L783-L804 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.hasSkin | hasSkin (): boolean {
return this.skin !== undefined;
} | /**
* 是否有蒙皮
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L917-L919 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.getEffectsGeometry | getEffectsGeometry (): Geometry {
return this.geometry.geometry;
} | /**
* 获取 GE 几何体
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L925-L927 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.setGeometry | setGeometry (val: PGeometry | Geometry) {
if (val instanceof PGeometry) {
this.geometry = val;
} else {
this.geometry = new PGeometry(val);
}
} | /**
* 设置几何体
* @param val - 插件或 GE 几何体
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L933-L939 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.setMaterial | setMaterial (val: PMaterial | Material) {
if (val instanceof PMaterialUnlit) {
this.material = val;
} else if (val instanceof PMaterialPBR) {
this.material = val;
} else {
this.material = createPluginMaterial(val);
}
} | /**
* 设置材质
* @param val - 插件材质对象或材质参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L945-L953 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.getEffectsMaterial | getEffectsMaterial (): Material {
return this.material.effectMaterial;
} | /**
* 获取 GE 材质
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L959-L961 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.isUnlitMaterial | isUnlitMaterial (): boolean {
return this.material.materialType === PMaterialType.unlit;
} | /**
* 是否无光照材质
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L967-L969 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.hasMorph | hasMorph (): boolean {
if (this.morph === undefined) {
return false;
}
return this.morph.hasMorph();
} | /**
* 是否有 Morph 动画:
* 需要注意 Morph 对象存在,但还是没有 Morph 动画的情况
* @returns 返回是否有 Morph 动画
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L976-L982 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSubMesh.getWorldBoundingBox | getWorldBoundingBox (): Box3 {
if (this.parent === undefined) {
if (this.boundingBox.isEmpty()) {
this.computeBoundingBox(Matrix4.fromIdentity());
}
return this.boundingBox;
} else {
const matrix = this.parent.matrix;
if (this.boundingBox.isEmpty()) {
this.compute... | /**
* 获取世界坐标下的包围盒
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L988-L1004 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.constructor | constructor (public geometry: Geometry) {
this.attributeNames = geometry.getAttributeNames();
} | /**
* 创建 3D 几何体,根据 GE 几何体
* @param geometry - GE 几何体
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1020-L1022 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.dispose | dispose () {
// @ts-expect-error
this.geometry = undefined;
this.attributeNames = [];
} | /**
* 销毁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1027-L1031 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasAttribute | hasAttribute (name: string): boolean {
const index = this.attributeNames.findIndex(item => {
return item === name;
});
return index !== -1;
} | /**
* 是否有某个属性
* @param name - 属性名
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1038-L1044 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.setHide | setHide (hide: boolean) {
const geomExt = this.geometry as GeometryExt;
if (geomExt.getDrawCount() === 0) {
const indexArray = geomExt.getIndexData();
if (indexArray !== undefined) {
geomExt.setDrawCount(indexArray.length);
}
}
if (hide) {
if (geomExt.getDrawCount() >= ... | /**
* 设置隐藏,通过修改几何体中的渲染数目
* @param hide - 隐藏值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1050-L1069 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.isCompressed | isCompressed (): boolean {
const positionAttrib = this.geometry.getAttributeData('aPos');
if (positionAttrib === undefined) {
return false;
}
// FIXME: get attributes from geometry
//return positionAttrib.normalize === true;
return false;
} | /**
* 是否压缩格式
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1075-L1085 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasPositions | hasPositions (): boolean {
return this.hasAttribute('aPos');
} | /**
* 是否有位置属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1091-L1093 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasNormals | hasNormals (): boolean {
return this.hasAttribute('aNormal');
} | /**
* 是否有法线属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1099-L1101 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasTangents | hasTangents (): boolean {
return this.hasAttribute('aTangent');
} | /**
* 是否有切线属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1107-L1109 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasUVCoords | hasUVCoords (index: number): boolean {
if (index === 1) {
return this.hasAttribute('aUV');
} else {
return this.hasAttribute(`aUV${index}`);
}
} | /**
* 是否有纹理坐标属性
* @param index - 纹理坐标索引
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1116-L1122 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasColors | hasColors (): boolean {
return this.hasAttribute('aColor');
} | /**
* 是否有颜色属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1128-L1130 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasJoints | hasJoints (): boolean {
return this.hasAttribute('aJoints');
} | /**
* 是否有关节点属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1136-L1138 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGeometry.hasWeights | hasWeights (): boolean {
return this.hasAttribute('aWeights');
} | /**
* 是否有权重属性
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1144-L1146 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | EffectsMeshProxy.getMorphObj | getMorphObj (): PMorph | undefined {
if (!this.hasMorphTarget()) {
return;
}
return this.morphObj;
} | /**
* 返回 Morph 对象
* 需要先判断是否有 Morph 动画,如果没有就直接返回 undefined
*
* @returns 缓存的 Morph 对象,或者 undefined
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/mesh.ts#L1186-L1192 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.initial | initial (opts: PSceneOptions) {
this.clean();
this.compName = opts.componentName;
this.renderer = opts.renderer;
this.engine = opts.renderer.engine;
this.sceneCache = opts.sceneCache;
this.enableDynamicSort = opts.enableDynamicSort === true;
this.renderSkybox = opts.renderSkybox;
this.ma... | /**
* 初始化场景管理器,设置全局状态
* @param opts - 场景参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L235-L252 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.dispose | dispose () {
this.itemList.forEach(item => item.dispose());
this.itemList = [];
this.meshList.forEach(mesh => mesh.dispose());
this.meshList = [];
this.lightManager.dispose();
this.cameraManager.dispose();
this.brdfLUT = undefined;
this.skybox?.dispose();
this.skybox = undefined;
... | /**
* 销毁,需要销毁各种管理器和创建的 WebGL 资源
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L291-L308 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.addItem | addItem (item: PMesh | PCamera | PLight | PSkybox) {
if (item instanceof PMesh) {
const mesh = item;
if (mesh.parentItemId !== undefined) {
this.parentId2Mesh.set(mesh.parentItemId, mesh);
}
addItem(this.meshList, mesh);
} else if (item instanceof PSkybox) {
const skybox ... | /**
* 添加插件元素到场景中
* @param item - 插件元素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L314-L342 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.removeItem | removeItem (item: PMesh | PCamera | PLight | PSkybox) {
if (item instanceof PMesh) {
const mesh = item;
if (mesh.parentItemId !== undefined) {
this.parentId2Mesh.delete(mesh.parentItemId);
}
removeItem(this.meshList, mesh);
} else if (item instanceof PSkybox) {
this.skybo... | /**
* 从场景中删除插件元素
* @param item - 插件元素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L348-L366 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.updateDefaultCamera | updateDefaultCamera (camera: CameraOptionsEx, viewportMatrix: Matrix4) {
const effectsTransfrom = new Transform({
...camera,
valid: true,
});
const newTransform = new PTransform().fromEffectsTransform(effectsTransfrom);
this.cameraManager.updateDefaultCamera(
camera.fov,
viewpo... | /**
* 更新默认相机状态,根据传入的相机参数
* @param camera - 相机参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L372-L390 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.tick | tick (deltaTime: number) {
const deltaSeconds = deltaTime;
const camera = this.activeCamera;
const viewMatrix = camera.viewMatrix;
const projectionMatrix = camera.projectionMatrix;
const viewProjectionMatrix = projectionMatrix.clone().multiply(viewMatrix);
this.sceneStates = {
deltaSecond... | /**
* 更新插件场景,需要更新内部的相关的插件对象,特别是 Mesh 对象的骨骼动画
* 并将需要渲染的对象添加到渲染对象集合中
* @param deltaTime - 更新间隔
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L397-L428 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.dynamicSortMeshes | dynamicSortMeshes (states: PSceneStates) {
const meshComponents: ModelMeshComponent[] = [];
const priorityList: number[] = [];
this.meshList.forEach(mesh => {
if (mesh.owner && mesh.owner.enabled) {
const component = mesh.owner;
meshComponents.push(component);
priorityList.pu... | /**
* 动态调整 Mesh 渲染优先级
* 主要是为了和 Tiny 渲染对齐,正常渲染不进行调整
* @param states - 场景中的状态数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L435-L489 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.queryMesh | queryMesh (parentId: string): PMesh | undefined {
const mesh = this.parentId2Mesh.get(parentId);
if (mesh === undefined || !mesh.visible) {
return;
}
return mesh;
} | /**
* 查询场景中的 Mesh
* 通过 parentId 查询 Mesh 对象,可能找不到 Mesh 对象
* @param parentId - Item 中定义的 parentId
* @returns 查询到的 PMesh,或者是没找到。如果 Mesh 不可见,也是没找到。
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L497-L505 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.getSceneAABB | getSceneAABB (box?: Box3): Box3 {
const sceneBox = box ?? new Box3();
this.itemList.forEach(item => {
if (item.type === PObjectType.mesh) {
const mesh = item as PMesh;
if (mesh.owner) {
const transform = mesh.owner.item.getWorldTransform();
const worldMatrix = transfo... | /**
* 获取场景的包围盒
* @param box - 包围盒
* @returns 场景的包围盒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L512-L533 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.getRenderer | getRenderer (): Renderer {
return this.renderer as Renderer;
} | /**
* 获取渲染器
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L556-L558 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.getSceneCache | getSceneCache (): CompositionCache {
return this.sceneCache as CompositionCache;
} | /**
* 获取场景中缓存
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L564-L566 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.activeCamera | get activeCamera (): PCamera {
return this.cameraManager.getActiveCamera();
} | /**
* 获取激活的相机
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L571-L573 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.lightCount | get lightCount (): number {
return this.lightManager.lightCount;
} | /**
* 获取灯光数目
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L578-L580 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSceneManager.shaderLightCount | get shaderLightCount (): number {
return Math.min(10, this.lightManager.lightCount);
} | /**
* 获取着色器灯光数目,最小是 10
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/scene.ts#L585-L587 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PShaderManager.getInstance | static getInstance (): PShaderManager {
// Do you need arguments? Make it a regular static method instead.
return this._instance || (this._instance = new this());
} | /**
* 获取着色器单例对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/shader.ts#L50-L53 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PShaderManager.genShaderCode | genShaderCode (context: PShaderContext): PShaderResults {
const materialType = context.material.materialType;
const func = this.funcMap.get(materialType);
if (func !== undefined) {
return func(context);
} else {
throw new Error(`Invalid material type ${materialType}, shader content ${contex... | /**
* 生成着色器代码
* @param context - 着色器上下文
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/shader.ts#L71-L80 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.constructor | constructor (name: string, data: ModelSkyboxComponentData, owner?: ModelSkyboxComponent) {
super();
this.name = name;
this.type = PObjectType.skybox;
this.visible = false;
this.owner = owner;
const { irradianceCoeffs } = data;
this.renderable = data.renderable;
this.intensity = data.in... | /**
* 构造函数
* @param name - 名称
* @param data - 天空盒参数
* @param owner - 所属天空盒组件元素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L79-L110 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.setup | setup (brdfLUT?: Texture) {
this.brdfLUT = brdfLUT;
} | /**
* 设置 BRDF 查询纹理
* @param brdfLUT - 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L116-L118 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.build | build (scene: PSceneManager) {
if (this.isBuilt) {
return;
}
this.isBuilt = true;
this.skyboxMaterial = new PMaterialSkyboxFilter();
this.skyboxMaterial.create(this);
this.skyboxMaterial.build();
//
const sceneCache = scene.getSceneCache();
this.skyboxMesh = sceneCache.getFil... | /**
* 构建天空盒,创建天空盒材质,从场景缓存中创建天空盒 Mesh
* @param sceneCache - 场景缓存
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L125-L140 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.render | override render (scene: PSceneManager, renderer: Renderer) {
this.updateMaterial(scene);
if (this.visible && this.renderable && this.skyboxMesh !== undefined) {
const mesh = this.skyboxMesh;
renderer.drawGeometry(mesh.geometry, mesh.material);
}
} | /**
* 渲染天空盒
* @param scene - 场景
* @param renderer - 渲染器
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L147-L155 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.dispose | override dispose () {
super.dispose();
this.owner = undefined;
this.diffuseImage = undefined;
//@ts-expect-error
this.specularImage = undefined;
this.brdfLUT = undefined;
this.skyboxMesh = undefined;
this.skyboxMaterial?.dispose();
this.skyboxMaterial = undefined;
} | /**
* 销毁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L160-L170 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.available | get available (): boolean {
if (!this.isValid()) { return false; }
if (this.intensity <= 0 && this.reflectionsIntensity <= 0) { return false; }
if (this.irradianceCoeffs === undefined && this.diffuseImage === undefined) { return false; }
return this.specularImage !== undefined && this.specularMipCoun... | /**
* 是否可用,根据内部的强度、辐射照度系数、漫反射贴图和高光贴图状态
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L190-L198 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.currentIntensity | get currentIntensity (): number {
return this.visible ? this.intensity : 0;
} | /**
* 当前强度,如果不可见返回 0
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L203-L205 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.currentReflectionsIntensity | get currentReflectionsIntensity (): number {
return this.visible ? this.reflectionsIntensity : 0;
} | /**
* 当前反射强度,如果不可见返回 0
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L210-L212 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.hasDiffuseImage | get hasDiffuseImage (): boolean {
return this.diffuseImage !== undefined;
} | /**
* 是否有漫反射贴图
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L217-L219 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkybox.hasIrradianceCoeffs | get hasIrradianceCoeffs (): boolean {
return this.irradianceCoeffs !== undefined;
} | /**
* 是否有辐射照度系数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L224-L226 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialSkyboxFilter.create | create (skybox: PSkybox) {
this.type = PObjectType.material;
this.materialType = PMaterialType.skyboxFilter;
this.ZTest = false;
//
this.name = skybox.name;
this.intensity = skybox.intensity;
this.reflectionsIntensity = skybox.reflectionsIntensity;
this.brdfLUT = skybox.brdfLUT;
this... | /**
* 创建天空盒材质,从天空盒对象
* @param skybox - 天空盒对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L267-L280 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialSkyboxFilter.dispose | override dispose () {
super.dispose();
this.brdfLUT = undefined;
this.irradianceCoeffs = undefined;
this.diffuseImage = undefined;
// @ts-expect-error
this.specularImage = undefined;
} | /**
* 销毁,需要解除资源引用
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L285-L292 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialSkyboxFilter.getShaderFeatures | override getShaderFeatures (): string[] {
const featureList: string[] = [];
featureList.push('USE_IBL 1');
featureList.push('USE_TEX_LOD 1');
if (this.diffuseImage === undefined) { featureList.push('IRRADIANCE_COEFFICIENTS 1'); }
return featureList;
} | /**
* 获取着色器特性列表
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L298-L306 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialSkyboxFilter.updateUniforms | override updateUniforms (material: Material) {
if (this.brdfLUT === undefined) {
throw new Error('Setup brdfLUT for skybox at first.');
}
material.setVector2('_IblIntensity', new Vector2(2.0, 2.0));
material.setTexture('_brdfLUT', this.brdfLUT);
if (this.diffuseImage !== undefined) {
ma... | /**
* 更新着色器 Uniform 数据
* @param material - 对应的 Core 层材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L312-L334 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialSkyboxFilter.setMaterialStates | override setMaterialStates (material: Material) {
material.depthTest = true;
material.depthMask = false;
this.setFaceSideStates(material);
} | /**
* 设置对应的材质状态
* @param material - 对应的 Core 层材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L340-L344 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.getBrdfLutTextureOptions | static async getBrdfLutTextureOptions (): Promise<TextureSourceOptions> {
const brdfURL = 'https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png';
//const brdfURL = 'https://gw.alipayobjects.com/zos/gltf-asset/58540818729423/a4191420-a8cd-432c-8e36-9bd02a67ec85.png';
const brdfLutImage = aw... | /**
* 获取 BRDF 查询纹理选项
* @returns 纹理源选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L454-L474 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.createBrdfLutTexture | static async createBrdfLutTexture (engine: Engine): Promise<Texture> {
const brdfLutOpts = await this.getBrdfLutTextureOptions();
const brdfLutTexture = Texture.create(engine, brdfLutOpts);
return brdfLutTexture;
} | /**
* 创建 BRDF 查询纹理
* @param engine - 引擎
* @returns 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L481-L486 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.createSkyboxOptions | static async createSkyboxOptions (engine: Engine, params: PSkyboxParams): Promise<ModelSkyboxOptions> {
const specularImage = await this.createSpecularCubeMap(engine, params);
const diffuseImage = await this.createDiffuseCubeMap(engine, params);
const { renderable, intensity, reflectionsIntensity, irradianc... | /**
* 创建天空盒选项
* @param engine - 引擎
* @param params - 天空盒参数
* @returns 天空盒选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L494-L511 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.createSkyboxComponentData | static createSkyboxComponentData (params: PSkyboxParams) {
const specularCubeData = PSkyboxCreator.getSpecularCubeMapData(params);
const diffuseCubeData = PSkyboxCreator.getDiffuseCubeMapData(params);
const { renderable, intensity, reflectionsIntensity, irradianceCoeffs, specularImageSize, specularMipCount ... | /**
* 创建天空盒选项
* @param engine - 引擎
* @param params - 天空盒参数
* @returns 天空盒选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L519-L562 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.createSpecularCubeMap | static async createSpecularCubeMap (engine: Engine, params: PSkyboxParams): Promise<Texture> {
// const configOptions: TextureConfigOptions = {
// wrapS: glContext.CLAMP_TO_EDGE,
// wrapT: glContext.CLAMP_TO_EDGE,
// magFilter: glContext.LINEAR,
// minFilter: glContext.LINEAR_MIPMAP_LINEAR,
... | /**
* 创建高光 Cube Map 纹理
* @param engine - 引擎
* @param params - 天空盒参数
* @returns 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L570-L583 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.createDiffuseCubeMap | static async createDiffuseCubeMap (engine: Engine, params: PSkyboxParams): Promise<Texture | null> {
if (params.diffuseImage === undefined) { return null; }
if (params.type === 'url') {
return WebGLHelper.createTextureCubeFromURL(engine, params.diffuseImage);
} else {
return WebGLHelper.createT... | /**
* 创建漫反射纹理
* @param engine - 引擎
* @param params - 天空盒参数
* @returns 纹理或未定义
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L626-L634 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.getSkyboxParams | static getSkyboxParams (skyboxType = PSkyboxType.NFT): PSkyboxURLParams {
const specularImage = this.getSpecularImageList(skyboxType);
const params: PSkyboxURLParams = {
type: 'url',
renderable: true,
intensity: 1.8,
reflectionsIntensity: 1.8,
irradianceCoeffs: this.getIrradianceCo... | /**
* 创建天空盒参数
* @param skyboxType - 天空盒类型
* @returns 天空盒参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L676-L691 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PSkyboxCreator.checkCubeMapImage | private async checkCubeMapImage (imageList: string[]) {
let lastImage!: HTMLImageElement;
const specularImageLists: HTMLImageElement[][] = [];
for (let i = 0; i < imageList.length; i++) {
const image = await loadImage(imageList[i]);
if (i > 0) {
if (i % 6 === 0) {
if (image.w... | // TODO: 待移除? | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/skybox.ts#L694-L718 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | StandardShader.getVertexShaderCode | static getVertexShaderCode (context: PShaderContext): string {
const features = context.featureList;
const materialType = context.material.materialType;
switch (materialType) {
case PMaterialType.unlit:
case PMaterialType.pbr:
case PMaterialType.shadowBase:
return StandardShaderSo... | /**
* 获取顶点着色器代码
* @param context - 着色器上下文
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/shader-libs/standard-shader.ts#L24-L38 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | StandardShader.getFragmentShaderCode | static getFragmentShaderCode (context: PShaderContext): string {
const features = context.featureList;
const materialType = context.material.materialType;
switch (materialType) {
case PMaterialType.unlit:
case PMaterialType.pbr:
return StandardShaderSource.build(metallicRoughnessFrag, f... | /**
* 获取片段着色器代码
* @param context - 着色器上下文
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/shader-libs/standard-shader.ts#L45-L60 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | StandardShader.genFragmentShaderCode | static genFragmentShaderCode (materialType: PMaterialType): string {
switch (materialType) {
case PMaterialType.unlit:
case PMaterialType.pbr:
return metallicRoughnessFrag;
case PMaterialType.shadowBase:
return shadowPassFrag;
case PMaterialType.skyboxFilter:
return s... | /**
* 获取片段着色器代码
* @param materialType - 材质类型
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/shader-libs/standard-shader.ts#L80-L92 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | RayIntersectsBoxWithRotation | function RayIntersectsBoxWithRotation (ray: Ray, matrixData: Matrix4, bounding: ModelItemBounding): Vector3[] | undefined {
const local2World = matrixData;
const world2Local = local2World.clone().invert();
const newRay = ray.clone().applyMatrix(world2Local);
const boxCenter = Vector3.fromArray(bounding.center!... | // 射线与带旋转的包围盒求交 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/hit-test-helper.ts#L31-L49 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | RayBoxTesting | function RayBoxTesting (ro: Vector3, rd: Vector3, bmin: Vector3, bmax: Vector3): number | undefined {
let tmin = 0, tmax = 0;
let tymin = 0, tymax = 0;
let tzmin = 0, tzmax = 0;
const invdirx = 1 / rd.x;
const invdiry = 1 / rd.y;
const invdirz = 1 / rd.z;
if (invdirx >= 0) {
tmin = (bmin.x - ro.x) * ... | /**
* 射线与包围盒求交
* @param ro - 射线原点
* @param rd - 射线方向
* @param bmin - 包围盒左下点
* @param bmax - 包围盒右上点
* @returns 交点参数或者 undefined
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/hit-test-helper.ts#L59-L120 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | RayTriangleTesting | function RayTriangleTesting (ro: Vector3, rd: Vector3, a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean): number | undefined {
// Compute the offset origin, edges, and normal.
// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
edge1.subtr... | /**
* 射线与三角形求交
* @param ro - 射线原点
* @param rd - 射线方向
* @param a - 三角形点
* @param b - 三角形点
* @param c - 三角形点
* @param backfaceCulling - 是否剔除背面
* @returns 交点参数或者 undefined
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/hit-test-helper.ts#L137-L189 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionHitTest | function CompositionHitTest (composition: Composition, x: number, y: number): Region[] {
const regions = composition.hitTest(x, y, true);
const ray = composition.getHitTestRay(x, y);
if (regions.length <= 0) {
return [];
}
const o = ray.origin;
const d = ray.direction;
const nums = regions.map((regi... | /**
* 合成点击测试,支持获取多个交点,并按照远近排序
* @param composition - 合成
* @param x - 点击 x 坐标
* @param y - 点击 y 坐标
* @returns 点击信息列表
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/hit-test-helper.ts#L198-L230 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ToggleItemBounding | function ToggleItemBounding (composition: Composition, itemId: string) {
composition.items?.forEach(item => {
if (item.type === VFX_ITEM_TYPE_3D) {
const meshComponent = item.getComponent(ModelMeshComponent);
if (meshComponent) {
const mesh = meshComponent.content;
if (item.id === it... | /**
* 切换 3D Mesh 元素的包围盒显示标志
* @param composition - 合成
* @param itemId - 元素 id
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/hit-test-helper.ts#L237-L253 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | WebGLHelper.createTexture2D | static async createTexture2D (engine: Engine, image: GLTFImage, texture: GLTFTexture, isBaseColor?: boolean, tiny3dMode?: boolean): Promise<Texture> {
if (image.imageData === undefined) {
console.error(`createTexture2D: Invalid image data from ${image}.`);
// 这里不应该发生的,做个兜底
return Texture.create(e... | /**
* 创建二维纹理对象
* @param engine - 引擎
* @param image - glTF 图像参数
* @param texture - glTF 纹理参数
* @param isBaseColor - 是否基础颜色
* @param tiny3dMode - 是否 Tiny3d 模式
* @returns 二维纹理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L96-L163 | 20512f4406e62c400b2b4255576cfa628db74a22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.