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
CheckerHelper.assertTreeOptions
static assertTreeOptions (v: ModelTreeOptions) { if (!this.checkNumberUndef(v.animation)) { console.error(`Invalid tree animation ${v.animation}, ${this.stringify(v)}.`); } if (v.animations !== undefined) { if (!Array.isArray(v.animations)) { console.error(`Invalid tree animations ${v.animations}, ${this....
/** * 检查场景树参数 * @param v - 场景树参数 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L2440-L2449
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
CheckerHelper.stringify
static stringify (object: any) { const simpleObject: { [k: string]: any } = {}; for (const prop in object) { // if (typeof(object[prop]) == 'object'){ // continue; // } if (prop === 'internal') { // 与WebGL相关的数据,可以忽略 continue; } if (typeof (object[prop]) =...
/** * 将对象转成 JSON 字符串,需要忽略函数和渲染相关的对象 * @param object - 目标对象 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L2456-L2485
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
CheckerHelper.pow2
static pow2 (index: number): number { let res = 1; while (index-- > 0) { res *= 2; } return res; }
/** * 获取 2 的 index 指数结果 * @param index - 指数 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L2492-L2498
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Float16ArrayWrapper.set
set (number: ArrayLike<number>, startIndex: number) { for (let i = 0; i < number.length; i++) { this.data[i + startIndex] = toHalf(number[i]); } }
/** * 将类数值数组转成半进度浮点,并从起始索引开始添加 * @param number - 类数值数组 * @param startIndex - 起始索引 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L2524-L2528
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Float16ArrayWrapper.bytes
get bytes () { return this.size * 2; }
/** * 获取数组字节数 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/plugin-helper.ts#L2533-L2535
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.constructor
constructor (options: Record<string, any>) { this.resolution = options.resolution ?? new Vector2(512, 512); this.colorAttachments = options.colorAttachments ?? []; this.depthAttachment = options.depthAttachment; }
/** * 构造函数 * @param options - FBO 参数 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L27-L31
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.addDepthAttachment
addDepthAttachment (options: Record<string, any>) { this.depthAttachment = { storageType: options.storageType ?? RenderPassAttachmentStorageType.depth_16_texture, }; }
/** * 添加深度附件 * @param options - 深度附件参数 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L37-L41
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.addDefaultDepthAttachment
addDefaultDepthAttachment () { this.depthAttachment = { storageType: RenderPassAttachmentStorageType.depth_16_texture }; }
/** * 添加默认深度附件,数据格式是 depth_16_texture */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L46-L48
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.deleteDepthAttachment
deleteDepthAttachment () { this.depthAttachment = undefined; }
/** * 删除深度附件 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L53-L55
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.addColorAttachment
addColorAttachment (options: Record<string, any>) { this.colorAttachments.push({ texture: { format: options.format ?? glContext.RGBA, type: options.type ?? glContext.HALF_FLOAT, minFilter: options.filter ?? glContext.LINEAR, magFilter: options.filter ?? glContext.LINEAR, ...
/** * 添加颜色附件 * @param options - 颜色附件参数 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L61-L70
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.deleteColorAttachment
deleteColorAttachment (target: number) { if (target >= 0 && target < this.colorAttachments.length) { this.colorAttachments.splice(target, 1); } }
/** * 删除颜色附件,按照索引值 * @param target - 颜色附件索引值 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L76-L80
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
FBOOptions.viewport
get viewport (): [number, number, number, number] { return [0, 0, this.resolution.x, this.resolution.y]; }
/** * 获取视口大小 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L85-L87
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.constructor
constructor (engine: Engine, priority: number) { const material = Material.create( engine, { shader: { vertex: this.vertexShader, fragment: this.fragmentShader, shared: true, }, } ); material.depthTest = true; material.depthMask = true; ...
/** * 构造函数,创建基础 Mesh 对象 * @param engine - 引擎 * @param priority - 优先级 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L104-L127
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.update
update (modelMatrix: Matrix4, viewProjMatrix: Matrix4, positions: Float32Array, lineColor: Vector3) { const material = this.mesh.material; material.setMatrix('effects_ObjectToWorld', modelMatrix); material.setMatrix('effects_MatrixVP', viewProjMatrix); for (let i = 0; i < positions.length; i += 3) { ...
/** * 更新包围盒着色器 Uniform 数据 * @param modelMatrix - 模型矩阵 * @param viewProjMatrix - 相机投影矩阵 * @param positions - 位置数组 * @param lineColor - 线颜色 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L136-L145
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.dispose
dispose () { this.mesh.dispose(); // @ts-expect-error this.mesh = undefined; }
/** * 销毁,需要销毁 Mesh 对象 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L150-L154
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.vertexShader
get vertexShader (): string { return ` precision highp float; uniform mat4 effects_ObjectToWorld; uniform mat4 effects_MatrixVP; uniform vec3 _PositionList[8]; attribute vec3 aPos; void main(){ int index = int(aPos.x + 0.5); vec4 pos = effects_ObjectToWorld * vec...
/** * 获取顶点着色器代码 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L159-L173
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.fragmentShader
get fragmentShader (): string { return ` precision highp float; uniform vec3 _LineColor; void main(){ gl_FragColor = vec4(_LineColor, 1); } `; }
/** * 获取片段着色器代码 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L178-L187
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
BoxMesh.geometry
get geometry (): GeometryProps { const data = new Float32Array([0, 1, 2, 3, 4, 5, 6, 7]); const index = new Uint32Array([ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7, ]); return { attributes: { aPos: { type: glContext.FLOAT, ...
/** * 获取基础几何体 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ri-helper.ts#L192-L215
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TwoStatesSet.clear
clear () { this.now.clear(); this.last.clear(); }
/** * 清空 last 和 now */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ts-helper.ts#L22-L25
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TwoStatesSet.forward
forward () { const temp = this.last; this.last = this.now; this.now = temp; this.now.clear(); }
/** * 状态前进,当前变成 last,now 被清空 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ts-helper.ts#L30-L36
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TwoStatesSet.forAddedItem
forAddedItem (callbackfn: (value: T) => void) { this.now.forEach(item => { if (!this.last.has(item)) { callbackfn(item); } }); }
/** * 遍历当前帧新加的元素 * * @param callbackfn - 增加新元素的回调 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ts-helper.ts#L43-L49
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TwoStatesSet.forRemovedItem
forRemovedItem (callbackfn: (value: T) => void) { this.last.forEach(item => { if (!this.now.has(item)) { callbackfn(item); } }); }
/** * 遍历当前帧删除的元素 * * @param callbackfn - 删除旧元素的回调 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ts-helper.ts#L56-L62
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TwoStatesSet.forNowItem
forNowItem (callbackfn: (value: T) => void) { this.now.forEach(item => { callbackfn(item); }); }
/** * 遍历当前帧所有的元素 * * @param callbackfn - 当前帧元素的回调 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/model/src/utility/ts-helper.ts#L69-L73
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.setAudioSource
setAudioSource (audio: HTMLAudioElement | AudioBuffer): void { this.audioPlayer.setAudioSource(audio); }
/** * 设置音频资源 * @param audio - 音频资源 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L51-L53
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.setVolume
setVolume (volume: number): void { this.audioPlayer.setVolume(volume); }
/** * 设置音量 * @param volume - 音量 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L59-L61
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.getCurrentTime
getCurrentTime (): number { return this.audioPlayer.getCurrentTime(); }
/** * 获取当前音频的播放时刻 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L66-L68
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.setMuted
setMuted (muted: boolean): void { this.audioPlayer.setMuted(muted); }
/** * 设置是否静音 * @param muted - 是否静音 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L74-L76
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.setLoop
setLoop (loop: boolean): void { this.audioPlayer.setLoop(loop); }
/** * 设置是否循环播放 * @param loop - 是否循环播放 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L82-L84
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioComponent.setPlaybackRate
setPlaybackRate (rate: number): void { this.audioPlayer.setPlaybackRate(rate); }
/** * 设置播放速率 * @param rate - 播放速率 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-component.ts#L90-L92
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AudioPlayer.setAudioSource
setAudioSource (audio: AudioBuffer | HTMLAudioElement) { if (this.audio || this.audioSourceInfo.source) { this.dispose(); } if (audio instanceof AudioBuffer) { const audioContext = new AudioContext(); const gainNode = audioContext.createGain(); gainNode.connect(audioContext.destinat...
/** * 设置音频资源 * @param audio - 音频资源 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/audio/audio-player.ts#L40-L66
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.getDuration
getDuration (): number { return this.video ? this.video.duration : 0; }
/** * 获取当前视频时长 * @returns 视频时长 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L151-L153
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.getCurrentTime
getCurrentTime (): number { return this.video ? this.video.currentTime : 0; }
/** * 获取当前视频播放时刻 * @returns 当前视频播放时刻 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L159-L161
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setThreshold
setThreshold (threshold: number) { this.threshold = threshold; }
/** * 设置阈值(由于视频是单独的 update,有时并不能完全对其 GE 的 update) * @param threshold 阈值 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L167-L169
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setCurrentTime
setCurrentTime (time: number) { if (this.video) { this.video.currentTime = time; } }
/** * 设置当前视频播放时刻 * @param time 视频播放时刻 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L175-L179
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setLoop
setLoop (loop: boolean) { if (this.video) { this.video.loop = loop; } }
/** * 设置视频是否循环播放 * @param loop 是否循环播放 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L185-L189
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setMuted
setMuted (muted: boolean) { if (this.video && this.video.muted !== muted) { this.video.muted = muted; } }
/** * 设置视频是否静音 * @param muted 是否静音 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L195-L199
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setVolume
setVolume (volume: number) { if (this.video && this.video.volume !== volume) { this.video.volume = volume; } }
/** * 设置视频音量 * @param volume 视频音量 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L205-L209
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
VideoComponent.setPlaybackRate
setPlaybackRate (rate: number) { if (!this.video || this.video.playbackRate === rate) { return; } this.video.playbackRate = rate; }
/** * 设置视频播放速率 * @param rate 视频播放速率 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/multimedia/src/video/video-component.ts#L215-L220
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
handleWatch
const handleWatch = (e: Pick<DeviceOrientationEvent, 'alpha' | 'beta' | 'gamma'>) => { if (this.stoped) { return; } alpha = e.alpha || 0; // 垂直于屏幕的轴 0 ~ 360 beta = e.beta || 0; // 横向 X 轴 -180 ~ 180 gamma = e.gamma || 0; // 纵向 Y 轴 -90 ~ 90 isInValidDegRange = angleLimit.call(...
// 最终输出的 y
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/device-orientation.ts#L126-L183
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
switchIOSEvent
function switchIOSEvent (open: boolean, interval?: number) { window.AlipayJSBridge.call( 'watchShake', { monitorGyroscope: false, monitorAccelerometer: !!open, interval: !open ? 10 : parseFloat(interval!.toFixed(3)), }, () => { } ); }
// 开启/关闭 iOS 的陀螺仪监听
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/device-orientation.ts#L282-L292
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
OrientationAdapterAcceler.dispatchMotion
dispatchMotion (motion: AccelerMotionData) { this.transformers.forEach(t => t.update(motion)); }
/** * * @param motion */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/orientation-adapter-acceler.ts#L58-L60
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Filtering.stableFix
stableFix (value: number) { const stableRange = this.options.stableRange || STABLE_RANGE; if (Math.abs(value) < stableRange) { return 0; } return value > stableRange ? value - stableRange : value + stableRange; }
/** * 0deg 左右保持一定的稳定区间 STABLE_RANGE * - 小于 STABLE_RANGE 的算 0 * - 大于 STABLE_RANGE 的减去 STABLE_RANGE * @param value - 输入值 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/utils/filtering.ts#L50-L58
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Filtering.changeLimit
changeLimit (value: number) { const lastValue = this.lastValue; let result = value; if (Math.abs(value - lastValue) > MAX_CHANGE) { result = lastValue < value ? lastValue + MAX_CHANGE : lastValue - MAX_CHANGE; } if (Math.abs(value - lastValue) < MIN_CHANGE) { result = lastValue; } ...
/** * 变幅限制 * - 最大变化 MAX_CHANGE * - 最小变化 MIN_CHANGE * @param value * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/utils/filtering.ts#L67-L80
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
linearRegression
function linearRegression (x: number[], y: number[]) { const result: Record<string, number> = {}; const n = y.length; let sumX = 0; let sumY = 0; let sumXY = 0; let sumXX = 0; let sumYY = 0; for (let i = 0; i < y.length; i++) { sumX += x[i]; sumY += y[i]; sumXY += (x[i] * y[i]); sumXX +...
// 计算出线性回归参数
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/utils/filtering.ts#L99-L124
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
createLinearRegressionFx
function createLinearRegressionFx (values: number[]) { const x: number[] = []; const y: number[] = []; values.forEach((item, index) => { x.push(index); // 数据是连续的,所以直接取数组下标为 x y.push(item); }); const key = linearRegression(x, y); return (x: number) => { return key.a * x + key.b; }; }
// 生成线性回归函数 F(x) = ax + b
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/utils/filtering.ts#L127-L140
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getLinearRegressionFixedVal
function getLinearRegressionFixedVal (valuePool: number[]) { const fx = createLinearRegressionFx(valuePool); // 这个迭代修正很重要 valuePool = valuePool.map((item, index) => { return fx(index); }); return fx(valuePool.length / 2); }
// 获取线性回归后的中位数
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/orientation-transformer/src/utils/filtering.ts#L143-L152
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
RichTextComponent.setOverflow
setOverflow (overflow: spec.TextOverflow) { this.textLayout.overflow = overflow; this.isDirty = true; }
/** * 设置文本溢出模式 * * - clip: 当文本内容超出边界框时,多余的会被截断。 * - display: 该模式下会显示所有文本,会自动调整文本字号以保证显示完整。 * > 当存在多行时,部分行内文本可能存在文本字号变小的情况,其他行为正常情况 * * @param overflow - 文本溢出模式 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/rich-text/src/rich-text-component.ts#L272-L275
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SlotGroup.constructor
constructor (drawOrder: Slot[], props: SlotGroupProps) { this.slotList = drawOrder; this.meshName = props.meshName; this.transform = props.transform; this.listIndex = props.listIndex; this.pma = props.pma; this.renderOptions = props.renderOptions; this.engine = props.engine; }
/** * * @param drawOrder * @param props */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/slot-group.ts#L95-L103
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SlotGroup.update
update () { const clipper = this.clipper; const pma = this.pma; let vertices = this.vertices; let uvs: NumberArrayLike; let triangles: number[] = []; let finalVertices: number[] = []; let finalVerticesLength = 0; let finalIndices: number[] = []; let finalIndicesLength = 0; let ...
/** * 按照 drawOrder 遍历 slot,根据 region、mesh、clip 附件更新 mesh 的 geometry 和 material 信息 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/slot-group.ts#L112-L274
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SlotGroup.render
render (renderer: Renderer) { const worldMatrix = this.transform.getWorldMatrix(); this.meshGroups.forEach(spineMesh => { const mesh = spineMesh.mesh; mesh.worldMatrix = worldMatrix; mesh.render(renderer); }); }
/** * @since 2.0.0 * @internal * @param renderer */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/slot-group.ts#L281-L291
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SlotGroup.findMeshIndex
private findMeshIndex (startIndex: number, blendMode: BlendMode, texture: Texture, vertexNum: number): number { let res = -1; for (let i = startIndex; i < this.meshGroups.length; i++) { const mesh = this.meshGroups[i]; if ( mesh && mesh.blending === blendMode && mesh.textur...
/** * * 从 startIndex 开始,找到材质和顶点数符合限制的 SpineMesh */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/slot-group.ts#L296-L315
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.getBoundingBox
getBoundingBox (): BoundingBoxTriangle { const bounds = this.getBounds(); const res: BoundingBoxTriangle = { type: HitTestType.triangle, area: [], }; if (!bounds) { return res; } const { x, y, width, height } = bounds; const wm = this.transform.getWorldMatrix(); const ...
/** * 返回当前 AABB 包围盒对应的三角形顶点数组 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L240-L270
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setAnimation
setAnimation (animation: string, speed?: number) { if (!this.skeleton || !this.state) { throw new Error('Set animation before skeleton create.'); } if (!this.animationList.length) { throw new Error('animationList is empty, check your spine file.'); } const loop = this.item.endBehavior ==...
/** * 设置单个动画 * @param animation - 动画名 * @param speed - 播放速度 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L296-L323
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setAnimationList
setAnimationList (animationList: string[], speed?: number) { if (!this.skeleton || !this.state) { throw new Error('Set animation before skeleton create.'); } if (!this.animationList.length) { throw new Error('animationList is empty, please check your setting.'); } if (animationList.lengt...
/** * 设置播放一组动画 * @param animationList - 动画名列表 * @param speed - 播放速度 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L330-L367
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setAnimationListLoopEnd
setAnimationListLoopEnd (animationList: string[], speed?: number) { if (!this.skeleton || !this.state) { throw new Error('Set animation before skeleton create.'); } if (!this.animationList.length) { throw new Error('animationList is empty, please check your setting.'); } if (animationLis...
/** * 设置播放一组动画,循环播放最后一个 * @param animationList - 动画名列表 * @param speed - 播放速度 * @since 1.6.0 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L375-L409
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setSpeed
setSpeed (speed: number) { if (!this.state) { return; } this.state.timeScale = speed; }
/** * 设置 Spine 播放的速度 * @param speed - 速度 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L415-L421
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.getSpeed
getSpeed () { return this.state.timeScale || 1; }
/** * 获取 Spine 播放的速度 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L427-L429
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.getActiveAnimation
getActiveAnimation (): string[] { return this.activeAnimation; }
/** * 获取正在播放的动作列表 * @returns */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L435-L437
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.getAnimationState
getAnimationState (): AnimationState { return this.state; }
/** * 获取当前 Spine 中的 AnimationState * @returns * @since 1.6.0 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L444-L446
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setMixDuration
setMixDuration (fromName: string, toName: string, duration: number) { if (!this.animationStateData) { return; } this.animationStateData.setMix(fromName, toName, duration); }
/** * 设置指定动画之间的融合时间,请在 `player.play` 之前进行设置 * @param fromName - 淡出动作 * @param toName - 淡入动作 * @param duration - 融合时间 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L454-L459
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setDefaultMixDuration
setDefaultMixDuration (mixDuration: number) { if (!this.state) { return; } this.animationStateData.defaultMix = mixDuration; if (this.state.tracks[0]) { this.state.tracks[0].mixDuration = mixDuration; } }
/** * 修改所有动作之间的融合时间,请在 `player.play` 之前进行设置 * @param mixDuration - 融合时间 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L465-L473
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.deleteMixForLoop
deleteMixForLoop () { const last = this.activeAnimation[this.activeAnimation.length - 1]; const first = this.activeAnimation[0]; this.animationStateData.setMix(last, first, 0); }
/** * 动画循环时,移除最后一个动作切换到第一个动作的融合效果,请在 `player.play` 之前进行设置 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L478-L483
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.setSkin
setSkin (skin: string) { if (!this.skeleton) { throw new Error('Set skin before skeleton create.'); } if (!skin || (skin !== 'default' && !this.skinList.includes(skin))) { throw new Error(`skin ${skin} not exists in skinList: ${this.skinList}.`); } this.skeleton.setSkinByName(skin); ...
/** * 设置皮肤 * @param skin - 要设置的皮肤 */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L489-L498
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.resize
resize () { const res = this.getBounds(); if (!res || !this.item.composition) { return; } const { width } = res; const scale = this.transform.scale; let scaleFactor; if (this.resizeRule) { const camera = this.item.composition.camera; const { z } = this.transform.getWorldP...
// 将缩放比例设置到当前scale
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L502-L527
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
SpineComponent.convertSizeToOldRule
convertSizeToOldRule (): number { const res = this.getBounds(); if (!res || !this.item.composition || !this.resizeRule) { return 1; } const { width } = res; const scaleFactor = this.scaleFactor; return this.startSize * scaleFactor * width; }
// 转换当前大小为旧缩放规则下的大小
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/spine/src/spine-component.ts#L530-L540
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Core.reset
reset (): void { this.drawCallHook?.reset(); this.programHook?.reset(); }
/** * reset draw call hook */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/core.ts#L45-L48
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Core.release
release (): void { this.drawCallHook?.release(); this.textureHook?.release(); this.shaderHook?.release(); this.programHook?.release(); }
/** * release hook */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/core.ts#L53-L58
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Core.update
update (dt: number): PerformanceData | undefined { const now = performance.now(); this.updateCounter++; if (now - this.updateTime < 1000) { return undefined; } if (this.samplingIndex !== this.samplingFrames) { this.reset(); this.samplingIndex++; return undefined; } ...
/** * update performance data */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/core.ts#L63-L101
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Monitor.update
update (dt: number): void { const data = this.core.update(dt); if (!data || data.triangles === 0) { return; } for (let i = 0, l = this.items.length; i < l; i++) { const dom = this.doms[i]; const item = this.items[i]; const value = data[item as keyof PerformanceData] || 0; ...
/** * Update per frame */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/monitor.ts#L116-L133
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Monitor.reset
reset (): void { this.core.reset(); for (let i = 0, l = this.items.length; i < l; i++) { const dom = this.doms[i]; const item = this.items[i]; const value = this.data[item as keyof PerformanceData] || 0; // see: http://wilsonpage.co.uk/preventing-layout-thrashing/ requestAnimatio...
/** * reset all hooks */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/monitor.ts#L146-L159
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Monitor.release
release (): void { this.core.release(); }
/** * release all hooks */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/monitor.ts#L164-L166
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Monitor.dispose
dispose (): void { this.release(); this.container.remove(); }
/** * dispose the instance */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/monitor.ts#L171-L174
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Stats.constructor
constructor ( public readonly player: Player, private readonly options?: StatsOptions, ) { void this.init(); }
/** * * @param player * @param options */
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/plugin-packages/stats/src/stats.ts#L114-L119
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
setDatGUI
function setDatGUI (composition: Composition) { if (gui) { gui.destroy(); } // @ts-expect-error gui = new window.GUI(); const ParticleFolder = gui.addFolder('Particle'); const BloomFolder = gui.addFolder('Bloom'); const ToneMappingFlolder = gui.addFolder('ToneMapping'); const VignetteFolder = gui.ad...
// dat gui 参数及修改
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/demo/src/post-processing.ts#L65-L103
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getDataTextureMesh
function getDataTextureMesh () { const w = 512; const h = 512; const size = w * h; const data = new Uint8Array(4 * size); const r = Math.floor(Math.random() * 255); const g = Math.floor(Math.random() * 255); const b = Math.floor(Math.random() * 255); for (let i = 0; i < size; i++) { const stride...
// 使用dataTexture创建material
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/demo/src/three-sprite.ts#L58-L88
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getNormalTextureMesh
async function getNormalTextureMesh (texture) { // 加载纹理 const material = new THREE.SpriteMaterial({ map: texture.texture, color: 0xffffff }); const mesh = new THREE.Sprite(material); mesh.position.set(0, 0, 0); mesh.scale.set(1, 1, 1); return mesh; }
// 使用 @galacean/effects-core assetmanager加载的图片创建texture
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/demo/src/three-sprite.ts#L91-L100
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getRawShaderMesh
function getRawShaderMesh (texture) { const vertexShader = ` precision mediump float; attribute vec2 uv; attribute vec3 position; uniform mat4 effects_ObjectToWorld; uniform mat4 effects_MatrixInvV; uniform mat4 uProjection; varying vec2 vUv; void main() { vUv = uv; gl_Position = uProjection *...
// 自定义shader(不带ubo)
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/demo/src/three-sprite.ts#L103-L176
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
getRawShaderLine
function getRawShaderLine () { const vertexShader = ` precision mediump float; attribute vec2 position; uniform mat4 effects_ObjectToWorld; uniform mat4 effects_MatrixInvV; uniform mat4 uProjection; uniform vec4 uColor; varying vec4 vColor; void main() { gl_Position = uProjection * effects_MatrixI...
// 自定义material gl.LINES
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/demo/src/three-sprite.ts#L260-L325
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
_main
async function _main (): Promise<void> { await _init(); for (let i = 0; i < 3; ++i) { _loop(1 / 60); } await _done(); }
// eslint-disable-next-line no-inner-declarations
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/main.ts#L47-L51
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
_loop
function _loop (time: number): void { // Poll and handle events (inputs, window resize, etc.) // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. //...
// Main loop
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/main.ts#L156-L281
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AssetDatabase.loadGUID
override async loadGUID (guid: string): Promise<EffectsObject | undefined> { const packageGuid = AssetDatabase.objectToPackageGuidMap[guid]; if (!packageGuid) { return; } // let effectsPackage = this.effectsPackages[packageGuid]; // 合成播放完会把对象设置为销毁,无法复用 let effectsPackage: EffectsPackage | un...
// }
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/core/asset-data-base.ts#L27-L50
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
AssetDatabase.importAsset
static async importAsset (path: string) { const fileHandle = await this.getFileHandle(path); if (!fileHandle) { return; } const file = await fileHandle.getFile(); const fileReader = new FileReader(); let res: string; try { res = await readFileAsText(file); } catch (error)...
// TODO 只加载 filesummary 到 map
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/core/asset-data-base.ts#L148-L196
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
fmodf
function fmodf (a: float, b: float): float { return a - (Math.floor(a / b) * b); }
// const LLONG_MIN: float = 0; // 0x8000000000000000
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L107-L107
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
UNIQUE
function UNIQUE (key: string): string { return key; }
// #include <stdio.h> // vsnprintf, sscanf, printf
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L116-L116
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
IM_MIN
function IM_MIN (A: float, B: float): float { return A < B ? A : B; }
// Helpers
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L198-L198
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
HelpMarker
function HelpMarker (desc: string): void { ImGui.TextDisabled('(?)'); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.PushTextWrapPos(ImGui.GetFontSize() * 35.0); ImGui.TextUnformatted(desc); ImGui.PopTextWrapPos(); ImGui.EndTooltip(); } }
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L234-L243
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowUserGuide
function /*ImGui.*/ShowUserGuide (): void { const io: ImGui.IO = ImGui.GetIO(); ImGui.BulletText('Double-click on title bar to collapse window.'); ImGui.BulletText( 'Click and drag on lower corner to resize window\n' + '(double-click to auto fit window to its contents).'); ImGui.BulletText('CTRL+Cl...
// Helper to display basic user controls.
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L246-L274
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
TextFilters.FilterImGuiLetters
static FilterImGuiLetters (data: ImGui.InputTextCallbackData<null>): int { if (data.EventChar < 256 && /[imgui]/.test(String.fromCharCode(data.EventChar))) {return 0;} return 1; }
// Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i'
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L1283-L1287
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
Funcs.MyInputTextMultiline
static MyInputTextMultiline (label: string, my_str: ImGui.StringBuffer, size: ImGui.Vec2 = new ImGui.Vec2(0, 0), flags: ImGui.InputTextFlags = 0): boolean { ImGui.ASSERT((flags & ImGui.InputTextFlags.CallbackResize) === 0); // return ImGui.InputTextMultiline(label, my_str.begin(), /*(size_t)*/my_st...
// For example, you code may declare a function 'ImGui.InputText(string label, MyString* my_str)'
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L1398-L1403
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
MyItem.CompareWithSortSpecs
static CompareWithSortSpecs (lhs: MyItem, rhs: MyItem): int { const a: MyItem = /*(const MyItem*)*/lhs; const b: MyItem = /*(const MyItem*)*/rhs; ImGui.ASSERT(MyItem.s_current_sort_specs !== null); for (let n = 0; n < MyItem.s_current_sort_specs.SpecsCount; n++) { // Here we identify columns usin...
// Compare function to be used by qsort()
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L3280-L3315
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
PushStyleCompact
function PushStyleCompact (): void { const style: ImGui.Style = ImGui.GetStyle(); ImGui.PushStyleVar(ImGui.StyleVar.FramePadding, new ImGui.Vec2(style.FramePadding.x, Math.floor/*(float)(int)*/(style.FramePadding.y * 0.60))); ImGui.PushStyleVar(ImGui.StyleVar.ItemSpacing, new ImGui.Vec2(style.ItemSpacing.x, Math...
// const ImGui.TableSortSpecs* MyItem::s_current_sort_specs = null;
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L3321-L3326
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
EditTableSizingFlags
function EditTableSizingFlags (p_flags: ImGui.Access<ImGui.TableFlags>): void { class EnumDesc { constructor (public Value: ImGui.TableFlags, public Name: string, public Tooltip: string) {} } const policies = STATIC_ARRAY<EnumDesc>(5, UNIQUE('policies#4d5a69af'), [ new EnumDesc(ImGui.TableFlags.None, 'Default',...
// Show a combo box with a choice of sizing policies
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L3333-L3370
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowDemoWindowColumns
function ShowDemoWindowColumns (): void { const open: boolean = ImGui.TreeNode('Legacy Columns API'); ImGui.SameLine(); HelpMarker('Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!'); if (!open) {return;} // Basic columns if (ImGui.TreeNode('Basic')) { ImGui.Text(...
// Demonstrate old/legacy Columns API!
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L4921-L5106
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowAboutWindow
function /*ImGui.*/ShowAboutWindow (p_open: ImGui.Access<boolean>): void { if (!ImGui.Begin('About Dear ImGui', p_open, ImGui.WindowFlags.AlwaysAutoResize)) { ImGui.End(); return; } ImGui.Text(`Dear ImGui ${ImGui.GetVersion()}`); ImGui.Separator(); ImGui.Text('By Omar Cornut and all Dear ImGui contri...
//-----------------------------------------------------------------------------
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5278-L5411
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowStyleSelector
function /*ImGui.*/ShowStyleSelector (label: string): boolean { const style_idx = STATIC<int>(UNIQUE('style_idx#8531ae65'), -1); if (ImGui.Combo(label, style_idx.access, 'Dark\0Light\0Classic\0')) { switch (style_idx.value) { case 0: ImGui.StyleColorsDark(); break; case 1: ImGui.StyleColor...
//-----------------------------------------------------------------------------
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5424-L5444
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowFontSelector
function /*ImGui.*/ShowFontSelector (label: string): void { const io: ImGui.IO = ImGui.GetIO(); const font_current: ImGui.Font = ImGui.GetFont(); if (ImGui.BeginCombo(label, font_current.GetDebugName())) { for (let n = 0; n < io.Fonts.Fonts.Size; n++) { const font: ImGui.Font = io.Fonts.Fonts[n]; ...
// Demo helper function to select among loaded fonts.
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5448-L5468
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
NodeFont
function NodeFont (font: ImGui.Font): void { const io: ImGui.IO = ImGui.GetIO(); const style: ImGui.Style = ImGui.GetStyle(); const font_details_opened: boolean = ImGui.TreeNode(font.native.$$.ptr, `Font: \"${font.ConfigData ? font.ConfigData[0].Name : ''}\"\n${font.FontSize.toFixed(2)} px, ${font.Glyphs.Size} gl...
// [Internal] Display details for a single font, called by ShowStyleEditor().
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5471-L5551
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowExampleAppMainMenuBar
function ShowExampleAppMainMenuBar (): void { if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenu('File')) { ShowExampleMenuFile(); ImGui.EndMenu(); } if (ImGui.BeginMenu('Edit')) { if (ImGui.MenuItem('Undo', 'CTRL+Z')) {} if (ImGui.MenuItem('Redo', 'CTRL+Y', false, false)) {} // ...
//-----------------------------------------------------------------------------
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5796-L5813
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ShowExampleMenuFile
function ShowExampleMenuFile (): void { ImGui.MenuItem('(demo menu)', null, false, false); if (ImGui.MenuItem('New')) {} if (ImGui.MenuItem('Open', 'Ctrl+O')) {} if (ImGui.BeginMenu('Open Recent')) { ImGui.MenuItem('fish_hat.c'); ImGui.MenuItem('fish_hat.inl'); ImGui.MenuItem('fish_hat.h'); if (...
// Note that shortcuts are currently provided for display only
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5817-L5888
20512f4406e62c400b2b4255576cfa628db74a22
effects-runtime
github_2023
galacean
typescript
ExampleAppConsole.ClearLog
ClearLog (): void { // for (let i = 0; i < this.Items.Size; i++) // free(this.Items[i]); this.Items.clear(); }
// const Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] === ' ') str_end--; *str_end = STATIC<void>(UNIQUE(" Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] === ' ') str_end--; *str_en...
https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/web-packages/imgui-demo/src/imgui/imgui_demo.ts#L5932-L5936
20512f4406e62c400b2b4255576cfa628db74a22