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 | ThreeTexture.toThreeJsTextureFilter | static toThreeJsTextureFilter (filter?: GLenum): THREE.TextureFilter {
switch (filter) {
case glContext.LINEAR:
return THREE.LinearFilter;
default:
return THREE.NearestFilter;
}
} | /**
* 将 WebGL 纹理过滤器枚举类型映射到 THREE 纹理过滤器枚举类型
* @param filter - WebGL 纹理过滤器枚举类型
* @returns THREE 纹理过滤器枚举类型
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L23-L30 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.toThreeJsTextureWrap | static toThreeJsTextureWrap (wrap?: GLenum): THREE.Wrapping {
switch (wrap) {
case glContext.MIRRORED_REPEAT:
return THREE.MirroredRepeatWrapping;
case glContext.REPEAT:
return THREE.RepeatWrapping;
default:
return THREE.ClampToEdgeWrapping;
}
} | /**
* 将 WebGL 纹理环绕方式枚举类型映射到 THREE 纹理环绕方式枚举类型
* @param wrap - WebGL 纹理环绕方式枚举类型
* @returns THREE 纹理环绕方式枚举类型
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L37-L46 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.constructor | constructor (engine: Engine, data?: TextureDataType, options: TextureSourceOptions = {}) {
super(engine);
if (data) {
const { width = 1, height = 1 } = data;
this.texture = this.createTextureByType({
...options as Texture2DSourceOptionsData,
sourceType: TextureSourceType.data,
... | /**
* 构造函数
* @param data - 纹理数据
* @param options - 纹理选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L53-L70 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.updateSource | updateSource (options: TextureSourceOptions) {
this.texture.dispose();
this.texture = this.createTextureByType(options);
this.texture.needsUpdate = true;
} | /**
* 更新纹理数据
* @param options - 纹理选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L76-L81 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.assembleOptions | override assembleOptions (options: TextureSourceOptions): TextureSourceOptions {
const { target = glContext.TEXTURE_2D } = options;
if (!options.sourceType) {
if ('image' in options) {
options.sourceType = TextureSourceType.image;
} else if ('data' in options) {
options.sourceType =... | /**
* 组装纹理选项
* @param options - 纹理选项
* @returns 组装后的纹理选项
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L88-L114 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.dispose | dispose () {
this.texture.dispose();
} | /**
* 释放纹理占用的内存
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L119-L121 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeTexture.fromData | override fromData (data: any): void {
super.fromData(data);
this.texture = this.createTextureByType(data);
this.texture.needsUpdate = true;
} | /**
* 通过图层设置创建贴图
* @param data - 图层设置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/three-texture.ts#L127-L132 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.constructor | constructor (engine: Engine, props?: MaterialProps) {
super(engine, props);
const shader = props?.shader;
const { level } = engine.gpuCapability;
this.shader = new Shader(engine);
this.shader.shaderData = {
...shader,
id: generateGUID(),
dataType: spec.DataType.Shader,
vert... | /**
* 构造函数
*
* @param props - 材质属性
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L45-L96 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.onSetUniformValue | onSetUniformValue (name: string, value: UniformValue) {
let texture;
if (TEXTURE_UNIFORM_MAP.includes(name)) {
texture = (value as ThreeTexture).texture;
}
if (this.material.uniforms[name]) {
this.material.uniforms[name].value = texture ? texture : value;
} else {
this.material.u... | /**
* 设置 uniform 变量值的回调函数
*
* @param name - uniform 变量名
* @param value - uniform 变量值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L104-L116 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.onRemoveUniformValue | onRemoveUniformValue (name: string) {
if (this.material.uniforms[name]) {
this.material.uniforms[name].value = null;
}
} | /**
* 移除 uniform 变量值的回调函数
*
* @param name - uniform 变量名
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L141-L145 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.blending | override get blending () {
return this.material.blending !== THREE.NoBlending;
} | /**
* 获取混合模式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L150-L152 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.blendFunction | override get blendFunction () {
const {
blendSrc, blendDst, blendSrcAlpha, blendDstAlpha,
} = this.material;
return [blendSrc, blendDst, blendSrcAlpha || blendSrc, blendDstAlpha || blendDst];
} | /**
* 获取混合函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L160-L166 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.blendEquation | override get blendEquation () {
const {
blendEquation,
blendEquationAlpha,
} = this.material;
return [blendEquation, blendEquationAlpha || blendEquation];
} | /**
* 获取混合方程式
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L181-L188 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.depthTest | override get depthTest () {
return this.material.depthTest;
} | /**
* 获取深度测试结果
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L201-L203 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.depthMask | override get depthMask () {
return this.material.depthWrite;
} | /**
* 获取深度缓冲区结果
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L211-L213 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.depthFunc | override get depthFunc () {
return this.material.depthFunc;
} | /**
* 获取深度函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L221-L223 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.polygonOffsetFill | override get polygonOffsetFill () {
return this.material.polygonOffset;
} | /**
* 获取多边形偏移开关
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L233-L235 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.polygonOffset | override get polygonOffset () {
return [this.material.polygonOffsetFactor, this.material.polygonOffsetUnits];
} | /**
* 获取多边形偏移
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L243-L245 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.sampleAlphaToCoverage | override get sampleAlphaToCoverage () {
return this.material.alphaToCoverage;
} | /**
* 获取 alpha 抖动
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L258-L260 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilTest | override get stencilTest () {
return this.material.stencilWrite;
} | /**
* 获取模板测试开关
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L268-L270 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilMask | override get stencilMask () {
return [this.material.stencilWriteMask, this.material.stencilWriteMask];
} | /**
* 获取模板缓冲区
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L278-L280 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilRef | override get stencilRef () {
return [this.material.stencilRef, this.material.stencilRef];
} | /**
* 获取模板测试参考值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L290-L292 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilFunc | override get stencilFunc () {
return [this.material.stencilFunc, this.material.stencilFunc];
} | /**
* 获取模版函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L302-L304 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilOpFail | override get stencilOpFail () {
return [this.material.stencilFail, this.material.stencilZFail];
} | /**
* 获取模板测试失败后参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L314-L316 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilOpZFail | override get stencilOpZFail () {
return [this.material.stencilZFail, this.material.stencilZFail];
} | /**
* 获取模版测试通过深度测试失败后参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L326-L328 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.stencilOpZPass | override get stencilOpZPass () {
return [this.material.stencilZPass, this.material.stencilZPass];
} | /**
* 获取模版测试通过并设置深度值参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L338-L340 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.culling | override get culling () {
return this.material.side !== THREE.DoubleSide;
} | /**
* 获取剔除开关
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L350-L352 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | ThreeMaterial.cullFace | override get cullFace () {
return this.material.side;
} | /**
* 获取剔除面
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-threejs/src/material/three-material.ts#L360-L362 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLGeometry.constructor | constructor (engine: Engine, props?: GeometryProps) {
super(engine);
if (props) {
this.processProps(props);
}
} | // TODO: 参数必传的用 props,可选的用 options,如果 props里面还有 options,则 options 需要修改名字(如renderOptions) | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-geometry.ts#L65-L70 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLGeometry.initialize | override initialize (): void {
if (this.initialized) {
return;
}
const engine = this.engine;
assertExist(engine);
engine.addGeometry(this);
const pipelineContext = (this.engine as GLEngine).getGLPipelineContext();
// 创建vbo
Object.keys(this.bufferProps).forEach(name => {
t... | /**
* Geometry 的 GPU 资源初始化方法,在绘制前调用
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-geometry.ts#L87-L112 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLGeometry.getAttributeBufferOption | private getAttributeBufferOption (name: string): GLGPUBufferProps | undefined {
const attribute = this.attributes[name];
return attribute ? this.bufferProps[attribute.dataSource] : undefined;
} | // 根据 attribute 的 datasource 获取 js 端 buffer | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-geometry.ts#L255-L259 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLGPUBuffer.readSubData | readSubData (elementOffset: number, dstBuffer: spec.TypedArray): boolean {
if (isWebGL2(this.pipelineContext.gl)) {
this.pipelineContext.gl.getBufferSubData(this.target, elementOffset * this.bytesPerElement, dstBuffer);
return true;
}
return false;
} | // for test | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-gpu-buffer.ts#L143-L151 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLMaterial.createMaterialStates | createMaterialStates (states: MaterialStates): void {
this.sampleAlphaToCoverage = !!states.sampleAlphaToCoverage;
this.depthTest = states.depthTest;
this.depthMask = states.depthMask;
this.depthRange = states.depthRange;
this.depthFunc = states.depthFunc;
this.colorMask = states.colorMask;
... | // TODO 待废弃 兼容 model/spine 插件 改造后可移除 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-material.ts#L236-L248 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLMaterial.initialize | override initialize (): void {
const engine = this.engine;
this.createShaderVariant();
(this.shaderVariant as GLShaderVariant).initialize();
if (this.initialized) {
return;
}
engine.addMaterial(this);
Object.keys(this.textures).forEach(key => {
const texture = this.textures[key]... | /**shader和texture的GPU资源初始化。 */ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-material.ts#L255-L275 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLMaterial.toData | override toData (): spec.MaterialData {
// @ts-expect-error
const materialData: spec.MaterialData = this.taggedProperties;
if (this.shader) {
// @ts-expect-error
materialData.shader = this.shader;
}
materialData.floats = {};
materialData.ints = {};
materialData.vector4s = {};
... | /**
* @since 2.0.0
* @param sceneData
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-material.ts#L618-L663 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.enable | enable (capability: GLenum) {
const value = this.glCapabilityCache[capability];
if (value !== true) {
this.glCapabilityCache[capability] = true;
this.gl.enable(capability);
}
} | /**
* 对于该上下文开启某种特性
* @param capability
* example:
* gl.enable(gl.DITHER);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L65-L72 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.disable | disable (capability: GLenum) {
const value = this.glCapabilityCache[capability];
if (value !== false) {
this.glCapabilityCache[capability] = false;
this.gl.disable(capability);
}
} | /**
* 基于某种上下文关闭特性
* @param capability
* example:
* gl.disable(gl.DITHER);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L80-L87 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.bindFramebuffer | bindFramebuffer (target: GLenum, framebuffer: WebGLFramebuffer | null) {
if (this.currentFramebuffer[target] !== framebuffer) {
this.currentFramebuffer[target] = framebuffer;
this.gl.bindFramebuffer(target, framebuffer);
}
} | /**
* 绑定framebuffer webgl2新增: gl.DRAW_FRAMEBUFFER 和 gl.READ_FRAMEBUFFER
* @param target
* @param framebuffer
* example:
* const framebuffer = gl.createFramebuffer();
* gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L97-L102 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.bindSystemFramebuffer | bindSystemFramebuffer () {
this.bindFramebuffer(this.gl.FRAMEBUFFER, null);
} | /**
* 绑定系统 framebuffer
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L114-L116 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.useProgram | useProgram (program: WebGLProgram | null) {
this.set1('useProgram', program);
} | /**
* 将定义好的 WebGLProgram 对象添加到当前的渲染状态中。
* @param program
* example:
* gl.useProgram(program);
* gl.useProgram(null);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L125-L127 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.clear | clear (mask: number) {
this.gl.clear(mask);
} | /**
* 使用预设值来清空缓冲
* @param mask
* example:
* gl.clear(gl.DEPTH_BUFFER_BIT);
* gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L136-L138 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.clearDepth | clearDepth (depth: GLclampf) {
this.set1('clearDepth', depth);
} | /**
* 设置深度缓冲区的深度清除值
* @param depth
* example:
* gl.clearDepth(0.5);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L148-L150 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.depthFunc | depthFunc (func: GLenum) {
this.set1('depthFunc', func);
} | /**
* 指定将输入像素深度与当前深度缓冲区值进行比较的函数。
* @param func
* example:
* gl.enable(gl.DEPTH_TEST);
* gl.depthFunc(gl.NEVER);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L159-L161 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.depthMask | depthMask (flag: boolean) {
this.set1('depthMask', flag);
} | /**
* 设置是否启用写入深度缓冲。
* @param flag
* example:
* gl.depthMask(false);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L169-L171 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.depthRange | depthRange (zNear: number, zFar: number) {
this.set2('depthRange', zNear, zFar);
} | /**
* 将 z 值从规范化设备坐标映射到窗口坐标
* @param zNear
* @param zFar
* example:
* gl.depthRange(0.2, 0.6);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L184-L186 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.clearStencil | clearStencil (s: GLint) {
this.set1('clearStencil', s);
} | /**
* 模版测试设置函数和引用值。
* @param func
* @param ref
* @param mask
* example:
* gl.enable(gl.STENCIL_TEST);
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L201-L203 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilMask | stencilMask (mask: number) {
this.stencilMaskSeparate(this.gl.FRONT, mask);
this.stencilMaskSeparate(this.gl.BACK, mask);
} | /**
* 控制启用和禁用模板平面中单个位的正面和背面写入
* @param mask
* example:
* gl.stencilMask(0xff);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L211-L214 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilFunc | stencilFunc (func: GLenum, ref: GLint, mask: GLuint) {
this.stencilFuncSeparate(this.gl.FRONT, func, ref, mask);
this.stencilFuncSeparate(this.gl.BACK, func, ref, mask);
} | /**
* 模版测试设置函数和引用值。
* @param func
* @param ref
* @param mask
* example:
* gl.enable(gl.STENCIL_TEST);
* gl.stencilFunc(gl.LESS, 0, 0b1110011);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L225-L228 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilFuncSeparate | stencilFuncSeparate (face: GLenum, func: GLenum, ref: GLint, mask: GLuint) {
this.set4('stencilFuncSeparate', face, func, ref, mask);
} | /**
* 单面模版测试
* @param face
* @param func
* @param ref
* @param mask
* example:
* gl.enable(gl.STENCIL_TEST);
* gl.stencilFuncSeparate(gl.FRONT, gl.LESS, 0.2, 1110011);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L240-L242 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilMaskSeparate | stencilMaskSeparate (face: GLenum, mask: GLuint) {
this.set2('stencilMaskSeparate', face, mask);
} | /**
* 单面的mask写入
* @param face
* @param mask
* example:
* gl.stencilMaskSeparate(gl.FRONT, 110101);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L251-L253 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilOp | stencilOp (fail: GLenum, zfail: GLenum, zpass: GLenum) {
this.stencilOpSeparate(this.gl.FRONT, fail, zfail, zpass);
this.stencilOpSeparate(this.gl.BACK, fail, zfail, zpass);
} | /**
* 设置正面和背面模板测试操作
* @param fail
* @param zfail
* @param zpass
* example:
* gl.enable(gl.STENCIL_TEST);
* gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L264-L267 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.stencilOpSeparate | stencilOpSeparate (face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) {
this.set4('stencilOpSeparate', face, fail, zfail, zpass);
} | /**
* 设置正面和/或背面模板测试操作
* @param face
* @param fail
* @param zfail
* @param zpass
* example:
* gl.enable(gl.STENCIL_TEST);
* gl.stencilOpSeparate(gl.FRONT, gl.INCR, gl.DECR, gl.INVERT);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L279-L281 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.cullFace | cullFace (mode: GLenum) {
this.set1('cullFace', mode);
} | /**
* 剔除方式
* @param mode
* example:
* gl.enable(gl.CULL_FACE);
* gl.cullFace(gl.FRONT_AND_BACK);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L293-L295 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.frontFace | frontFace (mode: GLenum) {
this.set1('frontFace', mode);
} | /**
* 设置卷绕方向
* @param mode
* example:
* gl.frontFace(gl.CW);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L303-L305 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.clearColor | clearColor (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) {
this.set4('clearColor', red, green, blue, alpha);
} | /**
* 设置颜色写入
* @param red
* @param green
* @param blue
* @param alpha
* example:
* gl.colorMask(true, true, true, false);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L319-L321 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.colorMask | colorMask (red: boolean, green: boolean, blue: boolean, alpha: boolean) {
this.set4('colorMask', red, green, blue, alpha);
} | /**
* 设置颜色写入
* @param red
* @param green
* @param blue
* @param alpha
* example:
* gl.colorMask(true, true, true, false);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L332-L334 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.blendColor | blendColor (red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) {
this.set4('blendColor', red, green, blue, alpha);
} | /**
* 设置源和目标混合因子
* @param red
* @param green
* @param blue
* @param alpha
* example:
* gl.blendColor(0, 0.5, 1, 1);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L345-L347 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.blendFunc | blendFunc (sfactor: GLenum, dfactor: GLenum) {
this.blendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
} | /**
* 用于混合像素算法
* @param sfactor
* @param dfactor
* example:
* gl.enable(gl.BLEND);
* gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L357-L359 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.blendFuncSeparate | blendFuncSeparate (srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) {
this.set4('blendFuncSeparate', srcRGB, dstRGB, srcAlpha, dstAlpha);
} | /**
* 分别设置应用在 RGB 和 Alpha 上的 factor
* @param srcRGB
* @param dstRGB
* @param srcAlpha
* @param dstAlpha
* example:
* gl.enable(gl.BLEND);
* gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L371-L373 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.blendEquation | blendEquation (mode: GLenum) {
this.set1('blendEquation', mode);
} | /**
* 设置混合模式
* @param mode
* example:
* gl.blendEquation(gl.FUNC_ADD);
* gl.blendEquation(gl.FUNC_SUBTRACT);
* gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L383-L385 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.blendEquationSeparate | blendEquationSeparate (modeRGB: GLenum, modeAlpha: GLenum) {
this.set2('blendEquationSeparate', modeRGB, modeAlpha);
} | /**
* 可以分别对 RGB 和 Alpha 做不同的操作处理
* @param modeRGB
* @param modeAlpha
* example:
* gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_SUBTRACT);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L394-L396 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.setPixelStorei | setPixelStorei (pname: GLenum, param: GLenum) {
const currentParam = this.pixelStorei[pname];
if (currentParam !== param) {
this.pixelStorei[pname] = param;
this.gl.pixelStorei(pname, param);
}
} | /**
* 图像预处理
* @param pname
* @param param
* example:
* var tex = gl.createTexture();
* gl.bindTexture(gl.TEXTURE_2D, tex);
* gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L409-L416 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.viewport | viewport (x: number, y: number, width: number, height: number) {
this.set4('viewport', x, y, width, height);
} | /**
* 用来设置视口,即指定从标准设备到窗口坐标的x、y仿射变换。
* @param x
* @param y
* @param width
* @param height
* example:
* gl.viewport(0, 0, width, height);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L427-L429 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.activeTexture | activeTexture (texture: GLenum) {
texture = Math.min(texture, this.maxTextureCount);
if (this.activeTextureIndex !== texture) {
this.activeTextureIndex = texture;
this.gl.activeTexture(texture);
}
} | /**
* 激活指定的纹理单元
* @param texture
* example:
* gl.activeTexture(gl.TEXTURE1);
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L437-L443 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.bindTexture | bindTexture (target: GLenum, texture: WebGLTexture | null, force?: boolean) {
if (this.currentTextureBinding !== texture || force) {
this.gl.bindTexture(target, texture);
this.currentTextureBinding = texture;
}
this.textureUnitDict[this.activeTextureIndex] = texture;
} | // TODO: texture.bind 替换时对于这段逻辑的处理 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L455-L461 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.get | get (name: string): any {
return this.glCapabilityCache[name];
} | // TODO 命名 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L515-L517 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLPipelineContext.getUniforms | getUniforms (program: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[] {
const results: Nullable<WebGLUniformLocation>[] = [];
for (let index = 0; index < uniformsNames.length; index++) {
results.push(this.gl.getUniformLocation(program, uniformsNames[index]));
}
return re... | /**
* 查询所有uniform的location。
* @param program 查询的shader program
* @param uniformsNames 查询的uniform名称列表
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-pipeline-context.ts#L589-L597 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLProgram.setupAttributes | setupAttributes (geometry: GLGeometry) {
const programId = this.id;
const gl = this.pipelineContext.gl;
let vao: GLVertexArrayObject | undefined;
if (geometry.vaos[programId]) {
vao = geometry.vaos[programId];
} else {
vao = new GLVertexArrayObject(this.engine, `${geometry.name}-${progr... | /**
* 绑定 vao 对象并设置顶点属性
* 如果当前环境不支持 vao,则使用 gl 函数依次设置属性。
* @param geometry
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-program.ts#L67-L110 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLRendererInternal.createVAO | createVAO (name?: string): GLVertexArrayObject | undefined {
const ret = new GLVertexArrayObject(this.engine, name);
return ret;
} | /**创建包裹VAO对象。 */ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-renderer-internal.ts#L204-L208 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLShaderLibrary.addShader | addShader (shaderSource: ShaderWithSource, macros?: ShaderMacros): string {
const mergedMacros: ShaderMacros = [];
if (shaderSource.macros) {
mergedMacros.push(...shaderSource.macros);
}
if (macros) {
mergedMacros.push(...macros);
}
const shaderWithMacros = {
...shaderSource,
... | // TODO 创建shader的ShaderWithSource和shader的source类型一样,待优化。 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-shader-library.ts#L66-L112 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLShaderVariant.initialize | initialize () {
if (this.initialized) {
return;
}
// 核心初始化都在 compileShader
// 否则会出现编译了却没有初始化的情况
const pipelineContext = (this.engine as GLEngine).getGLPipelineContext();
pipelineContext.shaderLibrary.compileShader(this);
} | // shader 的 GPU 资源初始化方法,在绘制前调用 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-shader.ts#L30-L39 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLTexture.bind | bind (force?: boolean) {
this.pipelineContext.bindTexture(this.target, this.textureBuffer, force);
} | /**
* 绑定当前 Texture 对象
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-texture.ts#L49-L51 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLTexture.initialize | override initialize (): void {
if (this.initialized) {
return;
}
const glEngine = this.engine as GLEngine;
glEngine.addTexture(this);
this.pipelineContext = glEngine.getGLPipelineContext();
const gl = this.pipelineContext.gl;
const { target = gl.TEXTURE_2D, name } = this.source;
... | /**
* 初始化 Texture 的 GPU 资源
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-texture.ts#L56-L74 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | UniformBlockBuffer.constructor | constructor (
pipelineContext: GLPipelineContext,
private readonly info: UniformBlockSpec,
) {
this.buffer = new GLGPUBuffer(pipelineContext, {
target: glContext.UNIFORM_BUFFER,
name: info.name,
type: glContext.BYTE,
elementCount: info.size,
});
this.dirtyFlags = {};
} | //for debug use | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-uniform-utils.ts#L124-L135 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | GLVertexArrayObject.bindVertexArray | private bindVertexArray (vao: WebGLVertexArrayObject | null) {
if (isWebGL2(this.gl)) {
this.gl.bindVertexArray(vao);
} else {
this.vaoExt?.bindVertexArrayOES(vao);
}
} | /**
* 根据 gpu level 选择对应的绑定函数
* @param vao
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-webgl/src/gl-vertex-array-object.ts#L50-L56 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.constructor | constructor (config: PlayerConfig) {
super();
const {
container, canvas, fps, name, pixelRatio, manualRender, reportGPUTime,
renderFramework: glType, notifyTouch,
interactive = false,
renderOptions = {},
env = '',
} = config;
const { willCaptureImage: preserveDrawingBuffer,... | /**
* 播放器的构造函数
* @param config
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L62-L142 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.setSpeed | setSpeed (speed: number) {
if (!isNaN(speed)) {
this.speed = speed;
}
} | /**
* 设置当前 Player 的播放速度
* @param speed - 播放速度
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L148-L152 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.getSpeed | getSpeed (): number {
return this.speed;
} | /**
* 获取当前 Player 的播放速度
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L157-L159 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.getCompositionByName | getCompositionByName (name: string) {
return this.compositions.find(comp => comp.name === name);
} | /**
* 根据名称查找对应的合成(可能找不到,如果有同名的合成,默认返回第一个)
* @example
* ``` ts
* const composition = player.getCompositionByName('新建合成1');
* ```
* @param name - 目标合成名称
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L169-L171 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.getCompositions | getCompositions () {
return this.compositions;
} | /**
* 获取当前播放的所有合成(请不要修改返回的数组内容)
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L176-L178 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.getAssetManager | getAssetManager (): ReadonlyArray<AssetManager> {
return this.assetManagers;
} | /**
* Gets the array of asset managers.
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L184-L186 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.compositionCount | get compositionCount () {
return this.compositions.length;
} | /**
* 获取当前播放的合成数量
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L191-L193 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.hasPlayable | get hasPlayable () {
return this.compositions.length > 0;
} | /**
* 是否有合成在播放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L198-L200 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.paused | get paused () {
return this.ticker?.getPaused();
} | /**
* 播放器是否已暂停
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L205-L207 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.interactive | get interactive () {
return this.event.enabled;
} | /**
* 获取播放器是否可交互
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L212-L214 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.interactive | set interactive (enable) {
this.event.enabled = enable;
} | /**
* 设置播放器是否可交互
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L219-L221 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.updateTextVariables | private updateTextVariables (scene: Scene, variables: spec.TemplateVariables = {}) {
const renderer = this.renderer;
const engine = renderer.engine;
scene.jsonScene.items.forEach(item => {
if (item.type === spec.ItemType.text || item.type === spec.ItemType.richtext) {
const textVariable = va... | /**
* 根据用户参数修改原始数据
* @param scene
* @param options
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L438-L460 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.play | play () {
if (this.offscreenMode) {
this.resize();
this.offscreenMode = false;
}
this.autoPlaying = true;
this.compositions.map(composition => {
composition.play();
});
this.ticker?.start();
} | /**
* 播放通过 player 加载好的全部合成
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L465-L475 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.gotoAndPlay | gotoAndPlay (time: number) {
if (this.offscreenMode) {
this.resize();
this.offscreenMode = false;
}
this.autoPlaying = true;
this.compositions.map(composition => {
composition.gotoAndPlay(time);
});
if (this.ticker) {
this.ticker.start();
} else {
this.doTick(0,... | /**
* 跳转全部合成到指定时间后播放
* @param time - 指定时间, 单位秒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L481-L495 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.gotoAndStop | gotoAndStop (time: number) {
if (this.offscreenMode) {
this.resize();
this.offscreenMode = false;
}
this.autoPlaying = false;
this.compositions.map(composition => {
composition.gotoAndStop(time);
});
if (!this.ticker || this.ticker?.getPaused()) {
this.doTick(0, true);
... | /**
* 跳转全部合成到指定时间并停留
* @param time - 指定时间, 单位秒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L501-L517 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.playSequence | playSequence (compositions: Composition[]): void {
for (let i = 0; i < compositions.length - 1; i++) {
compositions[i].on('end', () => {
compositions[i + 1].play();
});
}
compositions[0].play();
this.ticker?.start();
} | /**
* 顺序播放一组还未开始播放的合成
* @param compositions - 要播放的合成数组
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L523-L531 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.pause | pause (options?: { offloadTexture?: boolean }) {
if (this.paused) {
return;
}
this.ticker?.pause();
this.emit('pause');
this.emit('update', {
player: this,
playing: false,
});
if (options && options.offloadTexture) {
this.offloadTexture();
}
} | /**
* 暂停播放器
* @param options
* @param options.offloadTexture - 是否卸载贴图纹理,减少内存
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L539-L553 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.resume | async resume () {
if (this.resumePending) {
return;
}
if (this.paused) {
this.resumePending = true;
await Promise.all(this.compositions.map(c => c.reloadTexture()));
this.resumePending = false;
this.handleResume();
}
this.ticker?.resume();
} | /**
* 恢复播放器
* > 如果暂停时卸载了纹理贴图,此函数将自动请求网络重新加载纹理
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L560-L571 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.tick | tick (dt: number) {
this.doTick(dt, this.forceRenderNextFrame);
this.forceRenderNextFrame = false;
} | /**
* player 在定时器每帧的回调
* @param dt - 时间差,毫秒
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L577-L580 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.resizeToAspect | resizeToAspect (aspect: number, scale = 1) {
if (aspect !== this.displayAspect) {
this.displayAspect = aspect;
}
if (scale !== this.displayScale) {
this.displayScale = scale;
}
this.resize();
} | /**
* 调整画布的宽高比
* @param aspect
* @param scale
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L661-L669 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.resize | resize () {
const { parentElement } = this.canvas;
let containerWidth;
let containerHeight;
let canvasWidth;
let canvasHeight;
if (parentElement) {
const size = this.getTargetSize(parentElement);
containerWidth = size[0];
containerHeight = size[1];
canvasWidth = size[2]... | /**
* 将播放器重新和父容器大小对齐
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L674-L721 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.clearCanvas | clearCanvas (immediate?: boolean) {
if (immediate) {
this.renderer.clear({
stencilAction: TextureLoadAction.clear,
clearStencil: 0,
depthAction: TextureLoadAction.clear,
clearDepth: 1,
colorAction: TextureLoadAction.clear,
clearColor: [0, 0, 0, 0],
});
... | /**
* 清空 canvas 的画面
* @param immediate - 如果立即清理,当前画面将会消失,如果 player 还有合成在渲染,可能出现闪烁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L727-L740 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.restore | lost = (e: Event) => {
this.ticker?.pause();
this.compositions.forEach(comp => comp.lost(e));
this.renderer.lost(e);
this.emit('webglcontextlost', e);
broadcastPlayerEvent(this, false);
} | /**
* 播放器在 `webglcontextlost` 时执行的操作
* @param e - Event
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.destroyCurrentCompositions | destroyCurrentCompositions () {
this.compositions.forEach(comp => comp.dispose());
this.compositions.length = 0;
this.baseCompositionIndex = 0;
} | /**
* 销毁当前播放的所有 Composition
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L800-L804 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Player.dispose | dispose (keepCanvas?: boolean): void {
logger.info(`Call player destroyed: ${this.name}.`);
if (this.disposed) {
return;
}
playerMap.delete(this.canvas);
this.pause();
this.ticker?.stop();
this.assetManagers.forEach(assetManager => assetManager.dispose());
this.compositions.forEach... | /**
* 销毁播放器
* @param keepCanvas - 是否保留 canvas 画面,默认不保留,canvas 不能再被使用
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects/src/player.ts#L810-L859 | 20512f4406e62c400b2b4255576cfa628db74a22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.