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 | PMorph.initWeights | initWeights (weights: number[]) {
if (this.morphWeightsArray.length === 0) {
return;
}
const morphWeights = this.morphWeightsArray;
weights.forEach((val, index) => {
if (index < morphWeights.length) {
morphWeights[index] = val;
}
});
} | /**
* 初始化 Morph target 的权重数组
* @param weights - glTF Mesh 的权重数组,长度必须严格一致
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L335-L347 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMorph.hasMorph | hasMorph (): boolean {
return this.morphWeightsLength > 0 && (this.hasPositionMorph || this.hasNormalMorph || this.hasTangentMorph);
} | /**
* 当前状态是否有 Morph 动画:
* 需要判断 weights 数组长度,以及 Position、Normal 和 Tangent 是否有动画
* @returns 返回是否有 Morph 动画
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L364-L366 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMorph.equals | equals (morph: PMorph): boolean {
return this.morphWeightsLength === morph.morphWeightsLength
&& this.hasPositionMorph === morph.hasPositionMorph
&& this.hasNormalMorph === morph.hasNormalMorph
&& this.hasTangentMorph === morph.hasTangentMorph;
} | /**
* 两个 Morph 动画状态是否相等:
* 这里只比较初始状态是否一样,不考虑 weights 数组的情况,提供给 Mesh 进行 Geometry 检查使用
* @param morph - Morph 动画状态对象
* @returns 返回两个 Morph 动画状态是否相等
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L374-L379 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMorph.getAttributeMorphCount | getAttributeMorphCount (attributeNameList: string[], geometry: Geometry): number {
for (let i = 0; i < attributeNameList.length; i++) {
const val = attributeNameList[i];
if (geometry.getAttributeData(val) === undefined) {
return i;
}
}
// 所有名称都找到了,所以要返回数组的长度
return attributeNameList.length;
} | /**
* 统计 Geometry 中 Attribute 名称个数:
* 主要用于统计 Morph 动画中新增的 Attribute 名称的个数,会作为最终的 weights 数组长度使用
* @param attributeNameList - Attribute 名数组列表,只与 Morph Target 中的属性有关
* @param geometry - Geometry 对象,是否有 Morph 动画都可以
* @returns 存在的 Attribute 名称数目
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L392-L403 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PAnimTexture.create | create (jointCount: number, isHalfFloat: boolean, name: string) {
this.width = 4;
this.height = jointCount;
this.isHalfFloat = isHalfFloat;
if (this.isHalfFloat) {
this.buffer = new Float16ArrayWrapper(this.getSize() * 4);
}
const data = this.buffer?.data ?? new Float32Array(this.getSize() * 4);
const type = this.isHalfFloat ? glContext.HALF_FLOAT : glContext.FLOAT;
this.texture = Texture.create(
this.engine,
{
name,
data: {
width: this.width,
height: this.height,
data,
},
target: glContext.TEXTURE_2D,
format: glContext.RGBA,
type,
wrapS: glContext.CLAMP_TO_EDGE,
wrapT: glContext.CLAMP_TO_EDGE,
minFilter: glContext.NEAREST,
magFilter: glContext.NEAREST,
});
} | /**
* 创建动画纹理对象
* @param jointCount - 骨骼数目
* @param isHalfFloat - 是否半浮点精度
* @param name - 名称
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L486-L515 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PAnimTexture.update | update (buffer: Float32Array) {
if (this.buffer !== undefined) {
this.buffer.set(buffer, 0);
}
if (this.texture !== undefined) {
this.texture.updateSource({
sourceType: TextureSourceType.data,
data: {
width: this.width,
height: this.height,
data: this.buffer?.data ?? buffer,
},
target: glContext.TEXTURE_2D,
});
}
} | /**
* 更新动画数据
* @param buffer - 新的动画数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L521-L538 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PAnimTexture.dispose | dispose () {
// @ts-expect-error
this.engine = null;
this.buffer = undefined;
this.texture?.dispose();
} | /**
* 销毁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L543-L548 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PAnimTexture.getSize | getSize () {
return this.width * this.height;
} | /**
* 获取纹理大小
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L554-L556 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PAnimTexture.getTexture | getTexture () {
return this.texture as Texture;
} | /**
* 获取纹理对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/animation.ts#L562-L564 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.loadStaticResources | static async loadStaticResources () {
if (this.brdfLutTexOptions !== undefined) {
// 避免重复创建
return;
}
this.brdfLutTexOptions = await PSkyboxCreator.getBrdfLutTextureOptions();
} | /**
* 加载静态的纹理数据
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L31-L38 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.genSkyboxOptions | static async genSkyboxOptions (engine: Engine, params?: PSkyboxParams): Promise<ModelSkyboxOptions> {
let newParams = params;
if (newParams === undefined) {
newParams = PSkyboxCreator.getSkyboxParams();
}
CompositionCache.skyboxOptions = await PSkyboxCreator.createSkyboxOptions(engine, newParams);
return CompositionCache.skyboxOptions;
} | /**
* 创建天空盒数据,如果传入的 params 为空,会使用内置的天空盒参数
* @param engine - 引擎
* @param params - 天空盒参数
* @returns 天空盒数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L46-L56 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.setup | setup (loadSkybox: boolean) {
this.loadSkybox = loadSkybox;
if (this.brdfLutTexture === undefined || this.brdfLutTexture.isDestroyed) {
if (CompositionCache.brdfLutTexOptions === undefined) {
throw new Error('Please load brdfLutTexOptions at first.');
}
//
const brdfLutTextureName = 'brdfLutTexture';
this.brdfLutTexture = Texture.create(this.engine, CompositionCache.brdfLutTexOptions);
this.deleteTexture(brdfLutTextureName);
this.setTexture(brdfLutTextureName, this.brdfLutTexture);
}
} | /**
* 记录是否加载天空盒,缓存天空盒相关的查询纹理
* @param loadSkybox - 是否加载天空盒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L69-L83 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getTexture | getTexture (name: string): Texture | undefined {
return this.textureCache.get(name);
} | /**
* 获取缓存的纹理对象
* @param name - 名称
* @returns 纹理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L90-L92 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.setTexture | setTexture (name: string, tex: Texture) {
this.textureCache.set(name, tex);
} | /**
* 设置纹理对象缓存
* @param name - 名称
* @param tex - 纹理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L99-L101 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getOrCreateTexture | getOrCreateTexture (name: string, options: TextureSourceOptions): Texture {
const tex = this.textureCache.get(name);
if (tex !== undefined) {
return tex;
}
const newTex = Texture.create(this.engine, options);
this.textureCache.set(name, newTex);
return newTex;
} | /**
* 获取或者创建纹理对象
* @param name - 名称
* @param options - 纹理参数
* @returns 纹理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L109-L120 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.deleteTexture | deleteTexture (name: string): boolean {
const tex = this.textureCache.get(name);
if (tex !== undefined) {
tex.dispose();
}
return this.textureCache.delete(name);
} | /**
* 根据名称删除纹理对象
* @param name - 名称
* @returns 是否删除成功
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L127-L135 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getOrCreateGeometry | getOrCreateGeometry (name: string, geomJson: spec.GeometryOptionsJSON, bins: ArrayBuffer[]): Geometry {
const cachedGeom = this.geometryCache.get(name);
if (cachedGeom !== undefined) {
return cachedGeom;
}
const geom = PluginHelper.createGeometry(this.engine, geomJson, bins);
this.geometryCache.set(name, geom);
return geom;
} | /**
* 获取或者创建几何体
* @param name - 名称
* @param geomJson - 几何体参数
* @param bins - 几何体数据
* @returns 几何体
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L144-L156 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getFilterMesh | getFilterMesh (name: string, material: PMaterialBase): Mesh {
const cachedMesh = this.meshCache.get(name);
if (cachedMesh !== undefined) {
return cachedMesh;
}
const mesh = MeshHelper.createFilterMesh(this.engine, name, material);
this.meshCache.set(name, mesh);
return mesh;
} | /**
* 获取滤波 Mesh
* @param name - 名称
* @param material - 材质
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L164-L176 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getRenderPass | getRenderPass (name: string, priority: number, meshList: Mesh[], fboOptions: FBOOptions): RenderPass {
const cachedPass = this.renderPassCache.get(name);
if (cachedPass !== undefined) {
cachedPass.setMeshes([]);
meshList.forEach(mesh => { cachedPass.addMesh(mesh); });
return cachedPass;
} else {
const renderer = this.engine.renderer;
const renderPass = WebGLHelper.createRenderPass(renderer, name, priority, meshList, fboOptions);
this.renderPassCache.set(name, renderPass);
return renderPass;
}
} | /**
* 获取渲染 Pass
* @param name - 名称
* @param priority - 优先级
* @param meshList - Mesh 列表
* @param fboOptions - FBO 参数
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L194-L210 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.dispose | dispose () {
// @ts-expect-error
this.engine = null;
this.brdfLutTexture = undefined;
this.meshCache.forEach(mesh => {
WebGLHelper.deleteMesh(mesh);
});
this.meshCache.clear();
//
this.textureCache.forEach(texture => {
WebGLHelper.deleteTexture(texture);
});
this.textureCache.clear();
//
this.geometryCache.forEach(geometry => {
WebGLHelper.deleteGeometry(geometry);
});
this.geometryCache.clear();
//
this.renderPassCache.forEach(pass => {
WebGLHelper.deleteRenderPass(pass);
});
this.renderPassCache.clear();
} | /**
* 销毁缓存,释放所有缓存的对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L215-L238 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getRenderPasses | getRenderPasses (): RenderPass[] {
const resList: RenderPass[] = [];
this.renderPassCache.forEach(pass => {
resList.push(pass);
});
return resList;
} | /**
* 获取所有的渲染 Pass
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L244-L252 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getBrdfLutTexture | getBrdfLutTexture (): Texture | undefined {
return this.brdfLutTexture;
} | /**
* 获取纹理对象,用户 IBL 渲染
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L258-L260 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | CompositionCache.getSkyboxOptions | getSkyboxOptions (): ModelSkyboxOptions | undefined {
return CompositionCache.skyboxOptions;
} | /**
* 获取天空盒参数
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/cache.ts#L266-L268 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.constructor | constructor (name: string, width: number, height: number, data: ModelCameraComponentData, owner?: ModelCameraComponent) {
super();
this.type = PObjectType.camera;
this.visible = false;
this.owner = owner;
//
this.name = name;
this.width = width;
this.height = height;
this.nearPlane = data.near ?? 0.001;
this.farPlane = data.far ?? 1000;
this.fov = data.fov ?? 45;
this.aspect = data.aspect ?? (this.width / this.height);
this.clipMode = data.clipMode ?? spec.CameraClipMode.landscape;
this.update();
} | /**
* 构造函数,创建相机对象
* @param camera - 相机数据
* @param width - 画布宽度
* @param height - 画布高度
* @param owner - 所属的相机组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L70-L86 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.update | override update () {
if (this.owner !== undefined) {
this.transform.fromEffectsTransform(this.owner.transform);
}
const reverse = this.clipMode === spec.CameraClipMode.portrait;
this.projectionMatrix.perspective(this.fov * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse);
this.projectionMatrix.premultiply(this.viewportMatrix);
this.viewMatrix = this.matrix.invert();
} | /**
* 更新相机矩阵和投影矩阵,从所属的元素中获取变换数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L91-L101 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.getNewProjectionMatrix | getNewProjectionMatrix (fov: number): Matrix4 {
const reverse = this.clipMode === spec.CameraClipMode.portrait;
return new Matrix4().perspective(Math.min(fov * 1.25, 140) * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse).premultiply(this.viewportMatrix);
} | /**
* 获取新的透视矩阵,视角大小乘 1.25 倍
* @param fov - 视角大小
* @returns 投影矩阵
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L108-L112 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.computeViewAABB | computeViewAABB (box: Box3): Box3 {
const tanTheta = Math.tan(this.fov * deg2rad * 0.5);
const aspect = this.aspect;
let yFarCoord = 0;
let yNearCoord = 0;
let xFarCoord = 0;
let xNearCoord = 0;
if (this.isReversed()) {
xFarCoord = this.farPlane * tanTheta;
xNearCoord = this.nearPlane * tanTheta;
yFarCoord = xFarCoord / aspect;
yNearCoord = xNearCoord / aspect;
} else {
yFarCoord = this.farPlane * tanTheta;
yNearCoord = this.nearPlane * tanTheta;
xFarCoord = aspect * yFarCoord;
xNearCoord = aspect * yNearCoord;
}
box.makeEmpty();
const matrix = this.matrix;
box.expandByPoint(matrix.transformPoint(new Vector3(xFarCoord, yFarCoord, -this.farPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(xFarCoord, -yFarCoord, -this.farPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(-xFarCoord, yFarCoord, -this.farPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(-xFarCoord, -yFarCoord, -this.farPlane)));
//
box.expandByPoint(matrix.transformPoint(new Vector3(xNearCoord, yNearCoord, -this.nearPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(xNearCoord, -yNearCoord, -this.nearPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(-xNearCoord, yNearCoord, -this.nearPlane)));
box.expandByPoint(matrix.transformPoint(new Vector3(-xNearCoord, -yNearCoord, -this.nearPlane)));
return box;
} | /**
* 计算视角中的包围盒大小
* @param box - 包围盒
* @returns 视角中的包围盒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L119-L153 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.getSize | getSize (): Vector2 {
return new Vector2(this.width, this.height);
} | /**
* 获取画布大小
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L159-L161 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.isReversed | isReversed (): boolean {
return this.clipMode === spec.CameraClipMode.portrait;
} | /**
* 是否剪裁上下
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L167-L169 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.getEye | getEye (): Vector3 {
return this.translation;
} | /**
* 获取眼睛位置
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L175-L177 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCamera.setEye | setEye (val: Vector3) {
this.translation = val;
} | /**
* 设置眼睛位置
* @param val - 眼睛位置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L183-L185 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.initial | initial (width: number, height: number) {
this.winWidth = width;
this.winHeight = height;
const camera = this.defaultCamera;
camera.width = width;
camera.height = height;
camera.aspect = width / height;
camera.update();
} | /**
* 初始化画布大小,更新默认相机
* @param width - 画布宽度
* @param height - 画布高度
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L217-L227 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.insert | insert (name: string, data: ModelCameraComponentData, owner?: ModelCameraComponent): PCamera {
const camera = new PCamera(name, this.winWidth, this.winHeight, data, owner);
this.cameraList.push(camera);
return camera;
} | /**
* 插入相机数据,创建新的相机对象
* @param name - 相机名称
* @param data - 相机相关数据
* @param owner - 相机所属组件
* @returns 新的相机对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L236-L242 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.insertCamera | insertCamera (camera: PCamera) {
this.cameraList.push(camera);
} | /**
* 插入相机对象
* @param camera - 相机对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L248-L250 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.remove | remove (camera: PCamera | number) {
if (camera instanceof PCamera) {
const findResult = this.cameraList.findIndex(item => {
return item === camera;
});
if (findResult !== -1) {
this.cameraList.splice(findResult, 1);
}
} else {
if (camera >= 0 && camera < this.cameraList.length) {
this.cameraList.splice(camera, 1);
}
}
} | /**
* 根据对象或者索引,删除相机对象
* @param camera - 索引或相机对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L256-L270 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.dispose | dispose () {
this.cameraList = [];
} | /**
* 销毁相机管理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L275-L277 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.updateDefaultCamera | updateDefaultCamera (
fov: number,
viewportMatrix: Matrix4,
aspect: number,
nearPlane: number,
farPlane: number,
position: Vector3,
rotation: Quaternion,
clipMode: number,
) {
this.defaultCamera.fov = fov;
this.defaultCamera.viewportMatrix = viewportMatrix.clone();
this.defaultCamera.aspect = aspect;
this.defaultCamera.nearPlane = nearPlane;
this.defaultCamera.farPlane = farPlane;
this.defaultCamera.position = position;
this.defaultCamera.rotation = rotation;
this.defaultCamera.aspect = aspect;
this.defaultCamera.clipMode = clipMode;
this.defaultCamera.update();
} | /**
* 更新默认相机状态,并计算新的透视和相机矩阵
* @param fov - 视角
* @param viewportMatrix - 视图矩阵
* @param aspect - 纵横比
* @param nearPlane - 近裁剪平面
* @param farPlane - 远裁剪平面
* @param position - 位置
* @param rotation - 旋转
* @param clipMode - 剪裁模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L290-L310 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.getCameraList | getCameraList (): PCamera[] {
return this.cameraList;
} | /**
* 获取相机对象列表
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L316-L318 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.getDefaultCamera | getDefaultCamera (): PCamera {
return this.defaultCamera;
} | /**
* 获取默认相机对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L324-L326 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.getCameraCount | getCameraCount (): number {
return this.cameraList.length;
} | /**
* 获取相机数目
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L332-L334 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.getActiveCamera | getActiveCamera (): PCamera {
return this.defaultCamera;
} | /**
* 获取激活的相机对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L340-L342 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCameraManager.getAspect | getAspect (): number {
return this.winWidth / this.winHeight;
} | /**
* 获取画布纵横比
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/camera.ts#L348-L350 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.fromMatrix4 | fromMatrix4 (matrix: Matrix4) {
this.setMatrix(matrix);
return this;
} | /**
* 从矩阵设置数据
* @param matrix - 4阶矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L102-L106 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.fromEffectsTransform | fromEffectsTransform (trans: EffectsTransform | BaseTransform) {
if (trans instanceof EffectsTransform) {
this.setMatrix(trans.getWorldMatrix());
} else {
const effectsTrans = new EffectsTransform({
...trans,
valid: true,
});
effectsTrans.setValid(true);
this.setMatrix(effectsTrans.getWorldMatrix());
}
return this;
} | /**
* 从 GE 变换设置数据
* @param trans - GE 变换对象或数据
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L113-L128 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.toEffectsTransform | toEffectsTransform (transform: EffectsTransform) {
const mat = this.getMatrix();
transform.cloneFromMatrix(mat);
return transform;
} | /**
* 转成 GE 变换对象
* @param transform - GE 变换对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L135-L141 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.fromBaseTransform | fromBaseTransform (trans: BaseTransform) {
if (trans.position) {
this.setTranslation(trans.position);
} else {
this.translation.set(0, 0, 0);
}
if (trans.rotation) {
this.setRotation(trans.rotation);
} else {
this.rotation.set(0, 0, 0, 1);
}
if (trans.scale) {
this.setScale(trans.scale);
} else {
this.scale.set(1, 1, 1);
}
return this;
} | /**
* 通过 GE 变换参数设置
* @param trans - GE 变换参数
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L148-L168 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.getTranslation | getTranslation (): Vector3 {
return this.translation;
} | /**
* 获取平移
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L174-L176 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.setTranslation | setTranslation (val: Vector3 | spec.vec3) {
if (val instanceof Vector3) {
this.translation.set(val.x, val.y, val.z);
} else {
this.translation.set(val[0], val[1], val[2]);
}
} | /**
* 设置平移
* @param val - 平移
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L182-L188 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.getPosition | getPosition (): Vector3 {
return this.translation;
} | /**
* 获取位置
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L194-L196 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.setPosition | setPosition (val: Vector3 | spec.vec3) {
if (val instanceof Vector3) {
this.translation.set(val.x, val.y, val.z);
} else {
this.translation.set(val[0], val[1], val[2]);
}
} | /**
* 设置位置
* @param val - 位置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L202-L208 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.getRotation | getRotation (): Quaternion {
return this.rotation;
} | /**
* 获取旋转
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L214-L216 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.setRotation | setRotation (val: Quaternion | Euler | Vector3 | spec.vec4 | spec.vec3) {
if (val instanceof Quaternion) {
this.rotation.set(val.x, val.y, val.z, val.w);
} else if (val instanceof Euler) {
this.rotation.setFromEuler(val);
} else if (val instanceof Vector3) {
this.rotation.setFromEuler(new Euler(val.x, val.y, val.z, EulerOrder.ZYX));
} else if (val.length === 4) {
this.rotation.set(val[0], val[1], val[2], val[3]);
} else {
this.rotation.setFromEuler(new Euler(val[0], val[1], val[2], EulerOrder.ZYX));
}
} | /**
* 设置旋转
* @param val - 旋转,可能是四元数或欧拉角
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L222-L234 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.getScale | getScale (): Vector3 {
return this.scale;
} | /**
* 获取缩放
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L240-L242 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.setScale | setScale (val: Vector3 | spec.vec3) {
if (val instanceof Vector3) {
this.scale.set(val.x, val.y, val.z);
} else {
this.scale.set(val[0], val[1], val[2]);
}
} | /**
* 设置缩放
* @param val - 缩放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L248-L254 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.getMatrix | getMatrix (): Matrix4 {
return new Matrix4().compose(this.getTranslation(), this.getRotation(), this.getScale());
} | /**
* 获取矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L260-L262 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PTransform.setMatrix | setMatrix (mat: Matrix4 | spec.mat4) {
if (mat instanceof Matrix4) {
const res = mat.getTransform();
this.setTranslation(res.translation);
this.setRotation(res.rotation);
this.setScale(res.scale);
} else {
const res = Matrix4.fromArray(mat).getTransform();
this.setTranslation(res.translation);
this.setRotation(res.rotation);
this.setScale(res.scale);
}
} | /**
* 设置矩阵
* @param mat - 4阶矩阵
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L268-L282 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCoordinate.fromPTransform | fromPTransform (trans: PTransform, invert = false) {
this.origin.copyFrom(trans.getPosition());
const rotationMatrix = trans.getRotation().toMatrix4(new Matrix4());
if (invert) {
rotationMatrix.invert();
}
this.fromRotationMatrix(rotationMatrix);
return this;
} | /**
* 从插件变换创建坐标系
* @param trans - 变换
* @param invert - 是否旋转取反
* @returns 坐标系对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L319-L329 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PCoordinate.fromRotationMatrix | fromRotationMatrix (matrix: Matrix4) {
const me = matrix.elements;
this.xAxis.set(me[0], me[1], me[2]);
this.yAxis.set(me[4], me[5], me[6]);
this.zAxis.set(me[8], me[9], me[10]);
} | /**
* 从旋转矩阵创建坐标系
* @param matrix - 矩阵
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L335-L341 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.getInstance | static getInstance (): PGlobalState {
// 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/common.ts#L384-L387 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.reset | reset () {
this.isWebGL2 = false;
this.shaderShared = true;
this.runtimeEnv = PLAYER_OPTIONS_ENV_EDITOR;
this.compatibleMode = 'gltf';
this.visBoundingBox = false;
this.renderMode3D = spec.RenderMode3D.none;
this.renderMode3DUVGridSize = 1 / 16;
} | /**
* 重置数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L402-L410 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.hasRenderMode3D | hasRenderMode3D () {
return this.renderMode3D !== spec.RenderMode3D.none;
} | /**
* 是否可视化渲染中间结果
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L415-L417 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.isEditorEnv | get isEditorEnv () {
return this.runtimeEnv === PLAYER_OPTIONS_ENV_EDITOR;
} | /**
* 是否编辑器模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L422-L424 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.isDeviceEnv | get isDeviceEnv () {
return !this.isEditorEnv;
} | /**
* 是否设备模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L429-L431 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.isTiny3dMode | get isTiny3dMode () {
return this.compatibleMode === 'tiny3d';
} | /**
* 是否 Tiny3d 模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L436-L438 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PGlobalState.isGLTFMode | get isGLTFMode () {
return !this.isTiny3dMode;
} | /**
* 是否 glTF 模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/common.ts#L443-L445 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.constructor | constructor (name: string, data: ModelLightComponentData, owner?: ModelLightComponent) {
super();
this.name = name;
this.type = PObjectType.light;
this.visible = false;
this.owner = owner;
this.direction = new Vector3(0, 0, -1);
this.range = 0;
this.outerConeAngle = 0;
this.innerConeAngle = 0;
//
const { color } = data;
this.color = new Vector3(
color.r,
color.g,
color.b,
);
this.intensity = data.intensity;
this.followCamera = data.followCamera ?? false;
if (data.lightType === spec.LightType.point) {
this.lightType = PLightType.point;
this.range = data.range ?? -1;
} else if (data.lightType === spec.LightType.spot) {
this.lightType = PLightType.spot;
this.range = data.range ?? -1;
this.outerConeAngle = data.outerConeAngle ?? Math.PI;
this.innerConeAngle = data.innerConeAngle ?? 0;
} else if (data.lightType === spec.LightType.directional) {
this.lightType = PLightType.directional;
} else {
this.lightType = PLightType.ambient;
}
this.update();
} | /**
* 创建灯光对象
* @param name - 灯光名称
* @param data - 灯光相关数据
* @param owner - 所属灯光组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L56-L90 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.update | override update () {
if (this.owner !== undefined) {
this.transform.fromEffectsTransform(this.owner.transform);
}
} | /**
* 更新灯光变换
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L95-L99 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.isDirectional | isDirectional (): boolean {
return this.lightType === PLightType.directional;
} | /**
* 是否方向光
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L105-L107 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.isPoint | isPoint (): boolean {
return this.lightType === PLightType.point;
} | /**
* 是否点光源
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L113-L115 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.isSpot | isSpot (): boolean {
return this.lightType === PLightType.spot;
} | /**
* 是否聚光灯
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L121-L123 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.isAmbient | isAmbient (): boolean {
return this.lightType === PLightType.ambient;
} | /**
* 是否环境光
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L129-L131 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.position | override get position (): Vector3 {
return this.translation;
} | /**
* 获取位置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L136-L138 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.getWorldPosition | getWorldPosition (): Vector3 {
return this.translation;
} | /**
* 获取世界坐标中的位置
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L144-L146 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLight.getWorldDirection | getWorldDirection (): Vector3 {
return this.matrix.transformNormal(this.direction, new Vector3());
} | /**
* 获取世界坐标中的方向
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L152-L154 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLightManager.insertItem | insertItem (name: string, inLight: ModelLightComponentData, owner?: ModelLightComponent): PLight {
const light = new PLight(name, inLight, owner);
this.lightList.push(light);
return light;
} | /**
* 通过灯光参数,创建灯光对象,并保存到灯光数组中
* @param inLight - 灯光参数
* @param owner - 所属灯光组件
* @returns 插入的灯光对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L175-L181 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLightManager.insertLight | insertLight (inLight: PLight): PLight {
this.lightList.push(inLight);
return inLight;
} | /**
* 插入灯光对象
* @param inLight - 灯光对象
* @returns 插入的灯光对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L188-L192 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLightManager.remove | remove (inLight: PLight) {
const findResult = this.lightList.findIndex(item => {
return item === inLight;
});
if (findResult !== -1) {
this.lightList.splice(findResult, 1);
}
} | /**
* 删除灯光对象,从灯光数组中查找对象并进行删除,如果没有找到就忽略
* @param inLight - 删除的灯光对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L198-L206 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLightManager.dispose | dispose () {
this.lightList = [];
} | /**
* 销毁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L211-L213 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PLightManager.lightCount | get lightCount (): number {
return this.lightList.length;
} | /**
* 灯光数目
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/light.ts#L218-L220 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.create | create (material: Material) {
this.effectMaterial = material;
this.name = material.name;
this.type = PObjectType.material;
this.materialType = PMaterialType.unlit;
//
this.baseColorTexture = material.getTexture('_BaseColorSampler') ?? undefined;
this.baseColorTextureTrans = PluginHelper.createUVTransform(material, '_BaseColorSampler_ST', '_BaseColorRotation');
this.baseColorFactor = material.getColor('_BaseColorFactor') ?? new Color(1.0, 1.0, 1.0, 1.0);
//
this.ZWrite = material.getFloat('ZWrite') !== 0;
this.ZTest = material.getFloat('ZTest') !== 0;
this.renderType = material.stringTags['RenderType'] as spec.RenderType ?? spec.RenderType.Opaque;
this.alphaClip = material.getFloat('AlphaClip') === 1;
this.alphaCutoff = material.getFloat('_AlphaCutoff') ?? 0;
this.renderFace = material.stringTags['RenderFace'] as spec.RenderFace ?? spec.RenderFace.Front;
} | /**
* 创建无光照材质,支持基础颜色纹理
* @param material - effect 材质对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L294-L310 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.dispose | override dispose () {
super.dispose();
this.baseColorTexture = undefined;
} | /**
* 销毁材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L315-L318 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.getShaderFeatures | override getShaderFeatures (): string[] {
const featureList = super.getShaderFeatures();
featureList.push('MATERIAL_METALLICROUGHNESS 1');
if (this.hasBaseColorTexture()) {
featureList.push('HAS_BASE_COLOR_MAP 1');
}
featureList.push('MATERIAL_UNLIT 1');
return featureList;
} | /**
* 获取着色器特性列表,根据材质状态
* @returns 着色器特性列表
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L324-L335 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.updateUniforms | override updateUniforms (material: Material) {
super.updateUniforms(material);
if (this.baseColorTexture !== undefined) {
material.setInt('_BaseColorUVSet', 0);
material.setMatrix3('_BaseColorUVTransform', this.baseColorTextureTrans);
}
material.setFloat('_MetallicFactor', 0);
material.setFloat('_RoughnessFactor', 0);
material.setFloat('_Exposure', 1.0);
} | /**
* 更新对应的 GE 材质中着色器的 Uniform 数据
* @param material - GE 材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L354-L366 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.hasBaseColorTexture | hasBaseColorTexture (): boolean {
return this.baseColorTexture !== undefined;
} | /**
* 是否有基础颜色纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L372-L374 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.getBaseColorTexture | getBaseColorTexture (): Texture {
return this.baseColorTexture as Texture;
} | /**
* 获取基础颜色纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L380-L382 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.setBaseColorTexture | setBaseColorTexture (val: Texture) {
this.baseColorTexture = val;
} | /**
* 设置基础颜色纹理
* @param val - 纹理对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L388-L390 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.getBaseColorFactor | getBaseColorFactor (): Color {
return this.baseColorFactor;
} | /**
* 获取基础颜色纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L396-L398 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialUnlit.setBaseColorFactor | setBaseColorFactor (val: Color | Vector4 | spec.vec4) {
if (val instanceof Color) {
// for Color
this.baseColorFactor.set(val.r, val.g, val.b, val.a);
} else if (val instanceof Vector4) {
// for Vector4
this.baseColorFactor.set(val.x, val.y, val.z, val.w);
} else {
// for vec4
this.baseColorFactor.set(val[0], val[1], val[2], val[3]);
}
} | /**
* 设置基础颜色值
* @param val - 颜色值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L404-L415 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.create | create (material: Material) {
this.effectMaterial = material;
this.name = material.name;
this.type = PObjectType.material;
this.materialType = PMaterialType.pbr;
//
this.baseColorTexture = material.getTexture('_BaseColorSampler') ?? undefined;
this.baseColorTextureTrans = PluginHelper.createUVTransform(material, '_BaseColorSampler_ST', '_BaseColorRotation');
this.baseColorFactor = material.getColor('_BaseColorFactor') ?? new Color(1.0, 1.0, 1.0, 1.0);
//
this.metallicRoughnessTexture = material.getTexture('_MetallicRoughnessSampler') ?? undefined;
this.metallicRoughnessTextureTrans = PluginHelper.createUVTransform(material, '_MetallicRoughnessSampler_ST', '_MetallicRoughnessRotation');
this.useSpecularAA = material.getFloat('_SpecularAA') === 1;
this.metallicFactor = material.getFloat('_MetallicFactor') ?? 1;
this.roughnessFactor = material.getFloat('_RoughnessFactor') ?? 0;
//
this.normalTexture = material.getTexture('_NormalSampler') ?? undefined;
this.normalTextureTrans = PluginHelper.createUVTransform(material, '_NormalSampler_ST', '_NormalRotation');
this.normalTextureScale = material.getFloat('_NormalScale') ?? 1;
//
this.occlusionTexture = material.getTexture('_OcclusionSampler') ?? undefined;
this.occlusionTextureTrans = PluginHelper.createUVTransform(material, '_OcclusionSampler_ST', '_OcclusionRotation');
this.occlusionTextureStrength = material.getFloat('_OcclusionStrength') ?? 1;
//
this.emissiveTexture = material.getTexture('_EmissiveSampler') ?? undefined;
this.emissiveTextureTrans = PluginHelper.createUVTransform(material, '_EmissiveSampler_ST', '_EmissiveRotation');
this.emissiveFactor = material.getColor('_EmissiveFactor') ?? new Color(0, 0, 0, 1);
this.emissiveIntensity = material.getFloat('_EmissiveIntensity') ?? 1;
//
this.ZWrite = material.getFloat('ZWrite') !== 0;
this.ZTest = material.getFloat('ZTest') !== 0;
this.renderType = material.stringTags['RenderType'] as spec.RenderType ?? spec.RenderType.Opaque;
this.alphaClip = material.getFloat('AlphaClip') === 1;
this.alphaCutoff = material.getFloat('_AlphaCutoff') ?? 0;
this.renderFace = material.stringTags['RenderFace'] as spec.RenderFace ?? spec.RenderFace.Front;
} | /**
* 创建材质
* @param material - effect 材质对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L500-L535 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.dispose | override dispose () {
super.dispose();
this.baseColorTexture = undefined;
this.metallicRoughnessTexture = undefined;
this.normalTexture = undefined;
this.occlusionTexture = undefined;
this.emissiveTexture = undefined;
} | /**
* 销毁材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L540-L547 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getShaderFeatures | override getShaderFeatures (): string[] {
const featureList = super.getShaderFeatures();
featureList.push('MATERIAL_METALLICROUGHNESS 1');
if (this.hasBaseColorTexture()) {
featureList.push('HAS_BASE_COLOR_MAP 1');
if (this.baseColorTextureTrans !== undefined) {
featureList.push('HAS_BASECOLOR_UV_TRANSFORM 1');
}
}
if (this.hasMetallicRoughnessTexture()) {
featureList.push('HAS_METALLIC_ROUGHNESS_MAP 1');
if (this.metallicRoughnessTextureTrans !== undefined) {
featureList.push('HAS_METALLICROUGHNESS_UV_TRANSFORM 1');
}
}
if (this.useSpecularAA) {
featureList.push('USE_SPECULAR_AA 1');
}
if (this.hasNormalTexture()) {
featureList.push('HAS_NORMAL_MAP 1');
if (this.normalTextureTrans !== undefined) {
featureList.push('HAS_NORMAL_UV_TRANSFORM 1');
}
}
if (this.hasOcclusionTexture()) {
featureList.push('HAS_OCCLUSION_MAP 1');
if (this.occlusionTextureTrans !== undefined) {
featureList.push('HAS_OCCLUSION_UV_TRANSFORM 1');
}
}
if (this.hasEmissiveTexture()) {
featureList.push('HAS_EMISSIVE_MAP 1');
if (this.emissiveTextureTrans !== undefined) {
featureList.push('HAS_EMISSIVE_UV_TRANSFORM 1');
}
} else if (this.hasEmissiveValue()) {
featureList.push('HAS_EMISSIVE 1');
}
return featureList;
} | /**
* 获取材质特性列表
* @returns 材质特性列表
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L553-L594 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.updateUniforms | override updateUniforms (material: Material) {
super.updateUniforms(material);
if (this.baseColorTexture !== undefined) {
material.setInt('_BaseColorUVSet', 0);
material.setMatrix3('_BaseColorUVTransform', this.baseColorTextureTrans);
}
//
if (this.metallicRoughnessTexture !== undefined) {
material.setInt('_MetallicRoughnessUVSet', 0);
material.setMatrix3('_MetallicRoughnessUVTransform', this.metallicRoughnessTextureTrans);
}
//
if (this.normalTexture !== undefined) {
material.setInt('_NormalUVSet', 0);
material.setMatrix3('_NormalUVTransform', this.normalTextureTrans);
}
//
if (this.occlusionTexture !== undefined) {
material.setInt('_OcclusionUVSet', 0);
material.setMatrix3('_OcclusionUVTransform', this.occlusionTextureTrans);
}
//
if (this.emissiveTexture !== undefined) {
material.setInt('_EmissiveUVSet', 0);
material.setMatrix3('_EmissiveUVTransform', this.emissiveTextureTrans);
}
material.setFloat('_Exposure', 3.0);
} | /**
* 更新关联的 GE 材质中着色器的 Uniform 数据
* @param material - GE 材质
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L643-L672 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setBaseColorFactor | setBaseColorFactor (val: Color | Vector4 | spec.vec4) {
if (val instanceof Color) {
// for Vector4
this.baseColorFactor.set(val.r, val.g, val.b, val.a);
} else if (val instanceof Vector4) {
// for Vector4
this.baseColorFactor.set(val.x, val.y, val.z, val.w);
} else {
// for vec4
this.baseColorFactor.set(val[0], val[1], val[2], val[3]);
}
} | /**
* 设置基础颜色值
* @param val - 颜色值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L702-L713 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.hasMetallicRoughnessTexture | hasMetallicRoughnessTexture (): boolean {
return this.metallicRoughnessTexture !== undefined;
} | /**
* 是否有金属度粗超度纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L719-L721 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getMetallicRoughnessTexture | getMetallicRoughnessTexture (): Texture {
return this.metallicRoughnessTexture as Texture;
} | /**
* 获取金属度粗超度纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L727-L729 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setMetallicRoughnessTexture | setMetallicRoughnessTexture (val: Texture) {
this.metallicRoughnessTexture = val;
} | /**
* 设置金属度粗超度纹理
* @param val - 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L735-L737 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.hasNormalTexture | hasNormalTexture (): boolean {
return this.normalTexture !== undefined;
} | /**
* 是否有法线纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L743-L745 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.getNormalTexture | getNormalTexture (): Texture {
return this.normalTexture as Texture;
} | /**
* 获取法线纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L751-L753 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.setNormalTexture | setNormalTexture (val: Texture) {
this.normalTexture = val;
} | /**
* 设置法线纹理
* @param val - 纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L759-L761 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | PMaterialPBR.hasOcclusionTexture | hasOcclusionTexture (): boolean {
return this.occlusionTexture !== undefined;
} | /**
* 是否有遮挡纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/runtime/material.ts#L767-L769 | 20512f4406e62c400b2b4255576cfa628db74a22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.