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 | Composition.getHitTestRay | getHitTestRay (x: number, y: number): Ray {
const { x: a, y: b, z: c, w: d } = this.renderFrame.editorTransform;
return setRayFromCamera((x - c) / a, (y - d) / b, this.camera);
} | /**
* 获取指定位置和相机连成的射线
* @param x
* @param y
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L731-L735 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.getEngine | getEngine () {
return this.renderer?.engine;
} | /**
* 获取 engine 对象
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L741-L743 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.hitTest | hitTest (x: number, y: number, force?: boolean, options?: CompositionHitTestOptions): Region[] {
if (this.isDestroyed || !this.interactive) {
return [];
}
const regions: Region[] = [];
const ray = this.getHitTestRay(x, y);
this.rootItem.getComponent(CompositionComponent)?.hitTest(ray, x, y, regions, force, options);
this.refContent.forEach(ref => {
ref.getComponent(CompositionComponent)?.hitTest(ray, x, y, regions, force, options);
});
return regions;
} | /**
* Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,原点在左上角
* @param x - 鼠标或触点的 x,已经归一化到[-1, 1]
* @param y - 鼠标或触点的 y,已经归一化到[-1, 1]
* @param force - 是否强制求交,没有交互信息的 Item 也要进行求交测试
* @param options - 最大求交数和求交时的回调
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L752-L765 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.addInteractiveItem | addInteractiveItem (item: VFXItem, type: spec.InteractType) {
if (type === spec.InteractType.MESSAGE) {
this.handleItemMessage({
name: item.name,
phrase: spec.MESSAGE_ITEM_PHRASE_BEGIN,
id: item.id,
compositionId: this.id,
});
item.emit('message', {
name: item.name,
phrase: spec.MESSAGE_ITEM_PHRASE_BEGIN,
id: item.id,
});
return item.id;
}
} | /**
* InteractItem 生命周期开始时的调用
* @param item - 交互元素
* @param type - 交互类型
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L772-L788 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.removeInteractiveItem | removeInteractiveItem (item: VFXItem, type: spec.InteractType) {
// MESSAGE ITEM 的结束行为
if (type === spec.InteractType.MESSAGE) {
this.handleItemMessage({
name: item.name,
phrase: spec.MESSAGE_ITEM_PHRASE_END,
id: item.id,
compositionId: this.id,
});
item.emit('message', {
name: item.name,
phrase: spec.MESSAGE_ITEM_PHRASE_END,
id: item.id,
});
}
} | /**
* InteractItem 生命周期结束时的调用
* @param item - 交互元素
* @param type - 交互类型
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L795-L810 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.destroyTextures | destroyTextures (textures: (Texture | null | undefined)[]) {
for (let i = 0; i < textures.length; i++) {
const texture: Texture | null | undefined = textures[i];
if (!texture) {
continue;
}
if (texture.sourceType === TextureSourceType.data && !(this.texInfo[texture.getInstanceId()])) {
if (
texture !== this.rendererOptions?.emptyTexture &&
texture !== this.renderFrame.transparentTexture &&
texture !== this.getEngine().emptyTexture
) {
texture.dispose();
}
continue;
}
if (this.autoRefTex) {
// texInfo的类型有点不明确,改成<string, number>不会提前删除texture
const c = --this.texInfo[texture.getInstanceId()];
if (!c) {
if (__DEBUG__) {
console.debug(`Destroy no ref texture: ${texture?.id}.`);
if (isNaN(c)) {
logger.error(`Texture ${texture?.id} not found usage.`);
}
}
texture.dispose();
}
}
}
} | /**
* 销毁插件 Item 中保存的纹理数组
* @internal
* @param textures - 需要销毁的数组
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L817-L849 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.destroyItem | destroyItem (item: VFXItem) {
// 预合成元素销毁时销毁其中的item
if (item.type == spec.ItemType.composition) {
if (item.endBehavior !== spec.EndBehavior.freeze) {
const contentItems = item.getComponent(CompositionComponent).items;
contentItems.forEach(it => this.pluginSystem.plugins.forEach(loader => loader.onCompositionItemRemoved(this, it)));
}
} else {
// this.content.removeItem(item);
// 预合成中的元素移除
// this.refContent.forEach(content => content.removeItem(item));
removeItem(this.items, item);
this.pluginSystem.plugins.forEach(loader => loader.onCompositionItemRemoved(this, item));
}
} | /**
* 销毁 Item
* @internal
* @param item - 需要销毁的 item
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L856-L871 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.dispose | dispose (): void {
if (this.destroyed) {
return;
}
this.destroyed = true;
const textureDisposes: Record<string, () => void> = {};
const textures = this.textures;
if (textures) {
if (this.keepResource) {
textures.forEach(tex => {
if (tex?.dispose) {
textureDisposes[tex.id] = tex.dispose;
tex.dispose = noop;
}
});
} else {
// textures.forEach(tex => tex && tex.dispose());
}
}
this.rootItem.dispose();
// FIXME: 注意这里增加了renderFrame销毁
this.renderFrame.dispose();
this.rendererOptions?.emptyTexture.dispose();
this.pluginSystem?.destroyComposition(this);
this.update = () => {
if (!__DEBUG__) {
logger.error(`Update disposed composition: ${this.name}.`);
}
};
this.dispose = noop;
if (textures && this.keepResource) {
textures.forEach(tex => tex.dispose = textureDisposes[tex.id]);
}
this.compositionSourceManager.dispose();
this.refCompositionProps.clear();
if (this.renderer.env === PLAYER_OPTIONS_ENV_EDITOR) {
return;
}
this.renderer.clear({
stencilAction: TextureLoadAction.clear,
clearStencil: 0,
depthAction: TextureLoadAction.clear,
clearDepth: 1,
colorAction: TextureLoadAction.clear,
clearColor: [0, 0, 0, 0],
});
} | /**
* 合成对象销毁
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L889-L938 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.setEditorTransform | setEditorTransform (scale: number, dx: number, dy: number) {
this.renderFrame.editorTransform.set(scale, scale, dx, dy);
} | /**
* 编辑器使用的 transform 修改方法
* @internal
* @param scale - 缩放比例
* @param dx - x偏移量
* @param dy - y偏移量
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L947-L949 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.translateByPixel | translateByPixel (x: number, y: number) {
if (!this.renderer) {
console.warn('Renderer not assigned. Operation aborted.');
return;
}
this.rootItem.translateByPixel(x, y);
} | /**
* 合成整体在水平方向移动 x 像素,垂直方向移动 y 像素
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L954-L961 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.setPositionByPixel | setPositionByPixel (x: number, y: number) {
if (!this.renderer) {
console.warn('Renderer not assigned. Operation aborted.');
return;
}
this.rootItem.setPositionByPixel(x, y);
} | /**
* 设置合成在画布上的像素位置
* Tips:
* - 坐标原点在 canvas 左上角,x 正方向水平向右, y 正方向垂直向下
* - 设置后会覆盖原有的位置信息
* @param x - x 坐标
* @param y - y 坐标
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L971-L978 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.translate | translate (x: number, y: number, z: number) {
this.rootItem.translate(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上相对当前的位移
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L983-L985 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.setPosition | setPosition (x: number, y: number, z: number) {
this.rootItem.setPosition(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上相对原点的位移
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L990-L992 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.rotate | rotate (x: number, y: number, z: number) {
this.rootItem.rotate(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上相对当前的旋转(角度)
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L997-L999 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.setRotation | setRotation (x: number, y: number, z: number) {
this.rootItem.setRotation(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上的相对原点的旋转(角度)
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L1004-L1006 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.scale | scale (x: number, y: number, z: number) {
this.rootItem.scale(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上相对当前的缩放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L1010-L1012 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.setScale | setScale (x: number, y: number, z: number) {
this.rootItem.setScale(x, y, z);
} | /**
* 设置合成在 3D 坐标轴上的缩放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L1017-L1019 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.offloadTexture | offloadTexture () {
if (!this.textureOffloaded) {
this.textures.forEach(tex => tex && tex.offloadData());
this.textureOffloaded = true;
}
} | /**
* 卸载贴图纹理方法,减少内存
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L1024-L1029 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Composition.reloadTexture | async reloadTexture () {
if (this.textureOffloaded) {
await Promise.all(this.textures.map(tex => tex?.reloadData()));
this.textureOffloaded = false;
}
} | /**
* 重新加载纹理
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/composition.ts#L1045-L1050 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Downloader.downloadJSON | downloadJSON (url: string, onSuccess: SuccessHandler<JSONValue>, onError: ErrorHandler) {
this.download(url, 'json', onSuccess, onError);
} | /**
* 下载一个 JSON 文件
* @param url - 要下载的 JSON 文件的 URL
* @param onSuccess - 下载成功后的回调函数
* @param onError - 下载失败后的回调函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/downloader.ts#L33-L35 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Downloader.downloadBinary | downloadBinary (url: string, onSuccess: SuccessHandler<ArrayBuffer>, onError: ErrorHandler) {
this.download(url, 'arraybuffer', onSuccess, onError);
} | /**
* 下载一个二进制文件
* @param url - 要下载的二进制文件的 URL
* @param onSuccess - 下载成功后的回调函数
* @param onError - 下载失败后的回调函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/downloader.ts#L43-L45 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Downloader.downloadBlob | downloadBlob (url: string, onSuccess: SuccessHandler<Blob>, onError: ErrorHandler) {
this.download(url, 'blob', onSuccess, onError);
} | /**
* 下载一个 Blob 文件
* @param url - 要下载的 Blob 文件的 URL
* @param onSuccess - 下载成功后的回调函数
* @param onError - 下载失败后的回调函数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/downloader.ts#L53-L55 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Engine.constructor | constructor () {
this.jsonSceneData = {};
this.objectInstance = {};
this.assetLoader = new AssetLoader(this);
this.emptyTexture = generateWhiteTexture(this);
this.transparentTexture = generateTransparentTexture(this);
} | /**
*
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/engine.ts#L48-L54 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Engine.dispose | dispose (): void {
if (this.destroyed) {
return;
}
this.destroyed = true;
const info: string[] = [];
if (this.renderPasses.length > 0) {
info.push(`Pass ${this.renderPasses.length}`);
}
if (this.meshes.length > 0) {
info.push(`Mesh ${this.meshes.length}`);
}
if (this.geometries.length > 0) {
info.push(`Geom ${this.geometries.length}`);
}
if (this.textures.length > 0) {
info.push(`Tex ${this.textures.length}`);
}
if (info.length > 0) {
logger.warn(`Release GPU memory: ${info.join(', ')}.`);
}
this.renderPasses.forEach(pass => pass.dispose());
this.meshes.forEach(mesh => mesh.dispose());
this.geometries.forEach(geo => geo.dispose());
this.materials.forEach(mat => mat.dispose());
this.textures.forEach(tex => tex.dispose());
this.textures = [];
this.materials = [];
this.geometries = [];
this.meshes = [];
this.renderPasses = [];
// @ts-expect-error
this.renderer = null;
} | /**
* 销毁所有缓存的资源
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/engine.ts#L245-L283 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | SerializationHelper.checkDataPath | static checkDataPath (value: unknown): value is spec.DataPath {
return !!(isObject(value)
&& Object.keys(value).length === 1
&& 'id' in value
&& isString(value.id)
&& value.id.length === 32);
} | // check value is { id: 7e69662e964e4892ae8933f24562395b } | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/serialization-helper.ts#L235-L241 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | SerializationHelper.checkGLTFNode | static checkGLTFNode (value: any): boolean {
return isObject(value)
&& value.nodeIndex !== undefined
&& value.isJoint !== undefined;
} | // TODO 测试函数,2.0 上线后移除 | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/serialization-helper.ts#L244-L248 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.deltaTime | get deltaTime () {
return this.dt;
} | /**
* 获取定时器当前帧更新的时间
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L28-L30 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.getFPS | getFPS () {
return this.targetFPS;
} | /**
* FPS 帧率设置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L35-L37 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.getPaused | getPaused () {
return this.paused;
} | /**
* 获取定时器暂停标志位
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L50-L52 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.start | start () {
this.paused = false;
this.dt = 0;
if (!this.intervalId) {
this.lastTime = performance.now();
const raf = requestAnimationFrame || function (func) {
return window.setTimeout(func, 16.7);
};
const runLoop = () => {
this.intervalId = raf(runLoop);
if (!this.paused) {
this.tick();
}
};
runLoop();
}
} | /**
* 定时器开始方法
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L57-L75 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.stop | stop () {
(cancelAnimationFrame || window.clearTimeout)(this.intervalId);
this.intervalId = 0;
this.lastTime = 0;
this.paused = true;
this.dt = 0;
this.tickers = [];
} | /**
* 定时器停止方法
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L80-L87 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.pause | pause () {
this.paused = true;
this.dt = 0;
} | /**
* 定时器暂停方法
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L92-L95 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.resume | resume () {
this.paused = false;
this.dt = 0;
} | /**
* 定时器恢复方法
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L100-L103 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.tick | tick () {
if (this.paused) {
return;
}
const startTime = performance.now();
this.dt = startTime - this.lastTime;
if (this.dt >= this.interval) {
this.lastTime = startTime;
if (this.resetTickers) {
this.tickers = this.tickers.filter(tick => tick);
this.resetTickers = false;
}
for (let i = 0, len = this.tickers.length; i < len; i++) {
const tick = this.tickers[i];
tick(this.dt);
}
}
} | /**
* 定时器 tick 方法
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L108-L129 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Ticker.add | add (ticker: (dt: number) => void) {
if (typeof ticker !== 'function') {
throw new Error('The tick object must implement the tick method.');
}
this.tickers.push(ticker);
} | /**
* 定时器添加计时方法
* @param ticker - 定时器类
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/ticker.ts#L135-L140 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getRotation | static getRotation (quat: Quaternion, out: Euler): Euler {
const newQuat = tempQuat.copyFrom(quat);
newQuat.conjugate();
return out.setFromQuaternion(newQuat);
} | /**
* 转换右手坐标系左手螺旋对应的四元数到对应的旋转角
* @param quat - 四元数
* @param out - 欧拉角
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L32-L38 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.constructor | constructor (props: TransformProps = {}, parent?: Transform) {
this.name = `transform_${seed++}`;
if (props) {
this.setTransform(props);
}
if (parent) {
this.parentTransform = parent;
}
if (props.valid !== undefined) {
this.setValid(props.valid);
}
} | /**
*
* @param props
* @param parent
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L115-L126 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setPosition | setPosition (x: number, y: number, z: number) {
if (this.position.x !== x || this.position.y !== y || this.position.z !== z) {
this.position.x = x;
this.position.y = y;
this.position.z = z;
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 设置位置
* @param x
* @param y
* @param z
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L173-L181 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.translate | translate (x: number, y: number, z: number) {
if (x !== 0 || y !== 0 || z !== 0) {
this.position.x += x;
this.position.y += y;
this.position.z += z;
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 在当前位置的基础上添加位置偏移
* @param x
* @param y
* @param z
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L189-L197 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setRotation | setRotation (x: number, y: number, z: number) {
if (this.rotation.x !== x || this.rotation.y !== y || this.rotation.z !== z) {
this.rotation.x = x;
this.rotation.y = y;
this.rotation.z = z;
this.quat.setFromEuler(this.rotation);
this.quat.conjugate();
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 设置旋转
* @param x
* @param y
* @param z
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L204-L214 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setQuaternion | setQuaternion (x: number, y: number, z: number, w: number) {
if (this.quat.x !== x || this.quat.y !== y || this.quat.z !== z || this.quat.w !== w) {
this.quat.x = x;
this.quat.y = y;
this.quat.z = z;
this.quat.w = w;
this.rotation.setFromQuaternion(this.quat);
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 设置四元数
* @param x
* @param y
* @param z
* @param w
* @private
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L224-L234 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setScale | setScale (x: number, y: number, z: number) {
if (this.scale.x !== x || this.scale.y !== y || this.scale.z !== z) {
this.scale.x = x;
this.scale.y = y;
this.scale.z = z;
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 设置缩放
* @param x
* @param y
* @param z
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L242-L250 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.rotateByQuat | rotateByQuat (quat: Quaternion) {
this.quat.multiply(quat);
this.rotation.setFromQuaternion(this.quat);
this.dirtyFlags.localData = true;
this.dispatchValueChange();
} | /**
* 在当前旋转的基础上使用四元素添加旋转
* @param quat
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L265-L270 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.scaleBy | scaleBy (x: number, y: number, z: number) {
this.scale.x *= x;
this.scale.y *= y;
this.scale.z *= z;
this.dirtyFlags.localData = true;
this.dispatchValueChange();
} | /**
* 在当前缩放基础上设置缩放系数
* @param x
* @param y
* @param z
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L278-L284 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setAnchor | setAnchor (x: number, y: number) {
if (this.anchor.x !== x || this.anchor.y !== y) {
this.anchor.x = x;
this.anchor.y = y;
this.dirtyFlags.localData = true;
this.dispatchValueChange();
}
} | /**
* 设置锚点
* @param x
* @param y
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L291-L298 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setTransform | setTransform (props: TransformProps, reverseEuler?: boolean) {
const { position, rotation, scale, size, quat, name, anchor } = props;
if (name) {
this.name = name;
}
if (position) {
if (position instanceof Vector3) {
this.setPosition(position.x, position.y, position.z);
} else {
this.setPosition(position[0], position[1], position[2]);
}
}
if (quat) {
if (quat instanceof Quaternion) {
this.setQuaternion(quat.x, quat.y, quat.z, quat.w);
} else {
this.setQuaternion(quat[0], quat[1], quat[2], quat[3]);
}
} else if (rotation) {
const mul = reverseEuler ? -1 : 1;
if (rotation instanceof Euler) {
this.setRotation(rotation.x * mul, rotation.y * mul, rotation.z * mul);
} else {
this.setRotation(rotation[0] * mul, rotation[1] * mul, rotation[2] * mul);
}
}
if (scale) {
if (scale instanceof Vector3) {
this.setScale(scale.x, scale.y, scale.z);
} else {
this.setScale(scale[0], scale[1], scale[2]);
}
}
if (size) {
this.setSize(size.x, size.y);
}
if (anchor) {
if (anchor instanceof Vector2) {
this.setAnchor(anchor.x, anchor.y);
} else {
this.setAnchor(anchor[0], anchor[1]);
}
}
} | /**
* 批量设置 transform 属性
* @param props - 要设置的属性
* @param reverseEuler - 设置 rotation时,欧拉角是否需要取负值
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L305-L350 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.addChild | addChild (child: Transform) {
addItem(this.children, child);
} | /**
* 添加子变换
* @param child - 要添加的子变换
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L356-L358 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.removeChild | removeChild (child: Transform) {
removeItem(this.children, child);
} | /**
* 移除子变换
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L363-L365 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getRotation | getRotation (): Euler {
return Transform.getRotation(this.quat, new Euler());
} | /**
* 获取当前的旋转量
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L371-L373 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getQuaternion | getQuaternion (): Quaternion {
return this.quat;
} | /**
* 获取当前的四元数
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L379-L381 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.updateLocalMatrix | updateLocalMatrix () {
if (this.valid) {
if (this.dirtyFlags.localData) {
this.localMatrix.compose(this.position, this.quat, this.scale, this.anchor);
this.dirtyFlags.localMatrix = true;
}
this.dirtyFlags.localData = false;
} else {
if (!this.localMatrix.isIdentity()) {
this.localMatrix.identity();
this.dirtyFlags.localMatrix = true;
}
}
} | /**
* 更新元素自身变换矩阵
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L386-L399 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getMatrix | getMatrix (): Matrix4 {
this.updateLocalMatrix();
return this.localMatrix;
} | /**
* 获取自身变换对应的模型矩阵
* 数据修改且需要生效时更新自身矩阵
* 当变换不需要生效时返回单位矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L407-L411 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getParentMatrix | getParentMatrix (): Matrix4 | undefined {
if (this.parent) {
this.parentMatrix = this.parent.getWorldMatrix();
this.dirtyFlags.parentMatrix = this.dirtyFlags.parentMatrix || this.parent.dirtyFlags.localMatrix || this.parent.dirtyFlags.worldMatrix;
}
return this.parentMatrix;
} | /**
* 获取父矩阵,如果有多级父节点,返回整体变换
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L416-L423 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getWorldMatrix | getWorldMatrix (): Matrix4 {
const localMatrix = this.getMatrix();
const parentMatrix = this.getParentMatrix();
if (this.dirtyFlags.localMatrix || this.dirtyFlags.parentMatrix) {
if (parentMatrix) {
this.worldMatrix.multiplyMatrices(parentMatrix, localMatrix);
} else {
this.worldMatrix.copyFrom(localMatrix);
}
this.dirtyFlags.worldMatrix = true;
this.dirtyFlags.localMatrix = false;
this.dirtyFlags.parentMatrix = false;
}
return this.worldMatrix;
} | /**
* 获取包含自身变换和父变换的模型变换矩阵
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L429-L445 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getWorldScale | getWorldScale (): Vector3 {
const cache = this.worldTRSCache;
if (this.dirtyFlags.worldMatrix) {
const mat = this.getWorldMatrix();
mat.decompose(cache.position, cache.quat, cache.scale);
this.dirtyFlags.worldMatrix = false;
}
return this.worldTRSCache.scale.clone();
} | /**
* 获取联合变换后的最终缩放因子
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L451-L462 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getWorldPosition | getWorldPosition (): Vector3 {
this.updateTRSCache();
return this.worldTRSCache.position.clone();
} | /**
* 获取联合变换后的最终位置
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L468-L472 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getWorldRotation | getWorldRotation (): Euler {
this.updateTRSCache();
return Transform.getRotation(this.worldTRSCache.quat, new Euler());
} | /**
* 获取联合变换后的最终旋转量
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L478-L482 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.assignWorldTRS | assignWorldTRS (position?: Vector3, quat?: Quaternion, scale?: Vector3) {
this.updateTRSCache();
if (position) {
position.copyFrom(this.worldTRSCache.position);
}
if (quat) {
quat.copyFrom(this.worldTRSCache.quat);
}
if (scale) {
scale.copyFrom(this.worldTRSCache.scale);
}
} | /**
* 根据世界变换矩阵计算位移、旋转、缩放向量
* @param position
* @param quat
* @param scale
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L490-L501 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.cloneFromMatrix | cloneFromMatrix (m4: Matrix4, scale?: Vector3) {
m4.decompose(this.position, this.quat, this.scale);
if (scale) {
scale.copyFrom(this.scale);
}
this.dirtyFlags.localData = true;
this.dispatchValueChange();
} | /**
* 拆解并复制指定矩阵到自身变换
* @param m4
* @param scale
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L509-L516 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.setValid | setValid (val: boolean) {
if (this.valid !== val) {
this.valid = val;
if (!val) {
this.localMatrix.identity();
this.dirtyFlags.localMatrix = true;
} else {
this.dirtyFlags.localData = true;
}
this.dispatchValueChange();
}
} | /**
* 设置 Transform 生效 / 失效, 默认元素生命周期开始后生效,结束后失效
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L521-L532 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | Transform.getValid | getValid (): boolean {
return this.valid;
} | /**
* 获取 Transform 是否生效
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/transform.ts#L537-L539 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isComposition | static isComposition (item: VFXItem) {
return item.type === spec.ItemType.composition;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L111-L113 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isSprite | static isSprite (item: VFXItem) {
return item.type === spec.ItemType.sprite;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L120-L122 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isParticle | static isParticle (item: VFXItem) {
return item.type === spec.ItemType.particle;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L129-L131 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isNull | static isNull (item: VFXItem) {
return item.type === spec.ItemType.null;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L138-L140 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isTree | static isTree (item: VFXItem) {
return item.type === spec.ItemType.tree;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L147-L149 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isCamera | static isCamera (item: VFXItem) {
return item.type === spec.ItemType.camera;
} | /**
*
* @param item
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L156-L158 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isAncestor | static isAncestor (
ancestorCandidate: VFXItem,
descendantCandidate: VFXItem,
) {
let current = descendantCandidate.parent;
while (current) {
if (current === ancestorCandidate) {
return true;
}
current = current.parent;
}
return false;
} | /**
*
* @param ancestorCandidate
* @param descendantCandidate
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L166-L180 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.constructor | constructor (
engine: Engine,
props?: spec.Item,
) {
super(engine);
this.name = 'VFXItem';
this.transform.name = this.name;
this.transform.engine = engine;
if (props) {
this.fromData(props as spec.VFXItemData);
}
} | /**
*
* @param engine
* @param props
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L187-L198 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.content | get content (): VFXItemContent {
return this._content;
} | /**
* 返回元素创建的数据
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L203-L205 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.compositionReusable | get compositionReusable (): boolean {
return this.composition?.reusable ?? false;
} | /**
* 播放完成后是否需要再使用,是的话生命周期结束后不会 dispose
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L210-L212 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.renderOrder | get renderOrder () {
return this.listIndex;
} | /**
* 元素在合成中的索引
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L217-L219 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.on | on<E extends keyof ItemEvent> (
eventName: E,
listener: EventEmitterListener<ItemEvent[E]>,
options?: EventEmitterOptions,
) {
this.eventProcessor.on(eventName, listener, options);
} | /**
* 元素监听事件
* @param eventName - 事件名称
* @param listener - 事件监听器
* @param options - 事件监听器选项
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L236-L242 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.off | off<E extends keyof ItemEvent> (
eventName: E,
listener: EventEmitterListener<ItemEvent[E]>,
) {
this.eventProcessor.off(eventName, listener);
} | /**
* 移除事件监听器
* @param eventName - 事件名称
* @param listener - 事件监听器
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L250-L255 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.once | once<E extends keyof ItemEvent> (
eventName: E,
listener: EventEmitterListener<ItemEvent[E]>,
) {
this.eventProcessor.once(eventName, listener);
} | /**
* 一次性监听事件
* @param eventName - 事件名称
* @param listener - 事件监听器
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L262-L267 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.emit | emit<E extends keyof ItemEvent> (
eventName: E,
...args: ItemEvent[E]
) {
this.eventProcessor.emit(eventName, ...args);
} | /**
* 触发事件
* @param eventName - 事件名称
* @param args - 事件参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L274-L279 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getListeners | getListeners<E extends keyof ItemEvent> (eventName: E) {
return this.eventProcessor.getListeners(eventName);
} | /**
* 获取事件名称对应的所有监听器
* @param eventName - 事件名称
* @returns - 返回事件名称对应的所有监听器
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L286-L288 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setSpeed | setSpeed (speed: number) {
this.speed = speed;
} | /**
* 设置元素的动画速度
* @param speed - 速度
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L294-L296 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getSpeed | getSpeed () {
return this.speed;
} | /**
* 获取元素的动画速度
* @returns
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L302-L304 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.addComponent | addComponent<T extends Component> (classConstructor: Constructor<T>): T {
const newComponent = new classConstructor(this.engine);
this.components.push(newComponent);
newComponent.setVFXItem(this);
return newComponent;
} | /**
* 添加组件
* @param classConstructor - 要添加的组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L310-L317 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getComponent | getComponent<T extends Component> (classConstructor: Constructor<T>): T {
let res;
for (const com of this.components) {
if (com instanceof classConstructor) {
res = com;
break;
}
}
return res as T;
} | /**
* 获取某一类型的组件。如果当前元素绑定了多个同类型的组件只返回第一个
* @param classConstructor - 要获取的组件类型
* @returns 查询结果中符合类型的第一个组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L324-L336 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getComponents | getComponents<T extends Component> (classConstructor: Constructor<T>) {
const res = [];
for (const com of this.components) {
if (com instanceof classConstructor) {
res.push(com);
}
}
return res;
} | /**
* 获取某一类型的所有组件
* @param classConstructor - 要获取的组件
* @returns 一个组件列表,包含所有符合类型的组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L343-L353 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setColor | setColor (r: number, g: number, b: number, a: number) {
} | /**
* 通过指定 r、g、b、a 值设置元素的颜色
* @param {number} r
* @param {number} g
* @param {number} b
* @param {number} a
* @internal
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L383-L385 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setOpacity | setOpacity (opacity: number) {
} | /**
* 设置元素的透明度
* @param opacity - 透明度值,范围 [0,1]
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L392-L394 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setActive | setActive (value: boolean) {
if (this.active !== value) {
this.active = !!value;
this.onActiveChanged();
}
} | /**
* 激活或停用 VFXItem
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L399-L404 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isActive | get isActive () {
return this.active;
} | /**
* 当前 VFXItem 是否激活
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L409-L411 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setVisible | setVisible (visible: boolean) {
for (const component of this.components) {
component.enabled = visible;
}
this.visible = visible;
} | /**
* 设置元素的显隐,该设置会批量开关元素组件
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L416-L421 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.isVisible | get isVisible () {
return this.visible;
} | /**
* 元素组件显隐状态
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L426-L428 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getVisible | getVisible () {
return this.visible;
} | /**
* 元素组件显隐状态
* @deprecated use isVisible instead
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L434-L436 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getWorldTransform | getWorldTransform (transform?: Transform): Transform {
const tf = transform ?? new Transform({
valid: true,
});
tf.cloneFromMatrix(this.transform.getWorldMatrix());
return tf;
} | /**
* 获取元素变换包括位置、旋转、缩放
* @param transform 将元素变换拷贝到该对象,并将其作为返回值
* @returns 元素变换的拷贝
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L443-L451 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.translate | translate (x: number, y: number, z: number) {
this.transform.translate(x, y, z);
} | /**
* 设置元素在 3D 坐标轴上相对移动
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L456-L458 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.rotate | rotate (x: number, y: number, z: number) {
const euler = new Euler(x, y, z);
const q = Quaternion.fromEuler(euler);
q.conjugate();
this.transform.rotateByQuat(q);
} | /**
* 设置元素在 3D 坐标轴上相对旋转(角度)
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L462-L468 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.scale | scale (x: number, y: number, z: number) {
this.transform.scaleBy(x, y, z);
} | /**
* 设置元素在 3D 坐标轴上相对缩放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L472-L474 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setPositionByPixel | setPositionByPixel (x: number, y: number) {
if (this.composition) {
const { z } = this.transform.getWorldPosition();
const { x: rx, y: ry } = this.composition.camera.getInverseVPRatio(z);
const width = this.composition.renderer.getWidth() / 2;
const height = this.composition.renderer.getHeight() / 2;
this.transform.setPosition((2 * x / width - 1) * rx, (1 - 2 * y / height) * ry, z);
}
} | /**
* 设置元素在画布上的像素位置
* Tips:
* - 坐标原点在 canvas 左上角,x 正方向水平向右, y 正方向垂直向下
* - 设置后会覆盖原有的位置信息
* @param x - x 坐标
* @param y - y 坐标
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L484-L493 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setPosition | setPosition (x: number, y: number, z: number) {
this.transform.setPosition(x, y, z);
} | /**
* 设置元素在 3D 坐标轴的位置
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L497-L499 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setRotation | setRotation (x: number, y: number, z: number) {
this.transform.setRotation(x, y, z);
} | /**
* 设置元素在 3D 坐标轴的角度
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L503-L505 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.setScale | setScale (x: number, y: number, z: number) {
this.transform.setScale(x, y, z);
} | /**
* 设置元素在 3D 坐标轴的缩放
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L509-L511 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getBoundingBox | getBoundingBox (): void | BoundingBoxData {
// OVERRIDE
} | /**
* 获取元素包围盒
* @override
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L517-L519 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getHitTestParams | getHitTestParams (force?: boolean): void | HitTestBoxParams | HitTestTriangleParams | HitTestSphereParams | HitTestCustomParams {
// OVERRIDE
} | /**
* 获取元素用于计算光线投射的面片类型和参数
* @override
* @param force - 元素没有开启交互也返回参数
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L526-L528 | 20512f4406e62c400b2b4255576cfa628db74a22 |
effects-runtime | github_2023 | galacean | typescript | VFXItem.getCurrentPosition | getCurrentPosition (): Vector3 {
const pos = new Vector3();
this.transform.assignWorldTRS(pos);
return pos;
} | /**
* 获取元素当前世界坐标
*/ | https://github.com/galacean/effects-runtime/blob/20512f4406e62c400b2b4255576cfa628db74a22/packages/effects-core/src/vfx-item.ts#L533-L539 | 20512f4406e62c400b2b4255576cfa628db74a22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.