API Doc update (#5481)

* update

* API Doc update

* API Doc update

* API Doc update

* API Doc update
This commit is contained in:
ftershock
2019-10-12 10:18:27 +08:00
committed by pandamicro
parent d581995f23
commit de32d9b22d
34 changed files with 391 additions and 435 deletions
+1 -3
View File
@@ -41,9 +41,7 @@ import { Enum } from '../../value-types';
import { CameraDefaultMask } from '../../pipeline/define';
/**
* @en
* The projection type
* @zh
* The projection type<br/>
* 投影类型。
* @static
* @enum CameraComponent.Projection
+2 -2
View File
@@ -36,8 +36,8 @@ import { builtinResMgr } from '../builtin';
import { RenderableComponent } from './renderable-component';
/**
* @en Shadow projection mode
* @zh 阴影投射方式。
* Shadow projection mode<br/>
* 阴影投射方式。
*/
const ModelShadowCastingMode = Enum({
/**
+13 -12
View File
@@ -121,25 +121,25 @@ export class AnimationClip extends Asset {
}
/**
* 动画帧率,单位为帧/秒。
* @zh 动画帧率,单位为帧/秒。
*/
@property
public sample = 60;
/**
* 动画的播放速度。
* @zh 动画的播放速度。
*/
@property
public speed = 1;
/**
* 动画的循环模式。
* @zh 动画的循环模式。
*/
@property
public wrapMode = AnimationWrapMode.Normal;
/**
* 动画的曲线数据。
* @zh 动画的曲线数据。
* @deprecated 请转用 `this.curves`
*/
@property
@@ -149,7 +149,7 @@ export class AnimationClip extends Asset {
private _curves: ITargetCurveData[] = [];
/**
* 动画包含的事件数据。
* @zh 动画包含的事件数据。
*/
@property({visible: false})
public events: IAnimationEventData[] = [];
@@ -177,7 +177,7 @@ export class AnimationClip extends Asset {
protected _hash = 0;
/**
* 动画的周期。
* @zh 动画的周期。
*/
get duration () {
return this._duration;
@@ -188,7 +188,7 @@ export class AnimationClip extends Asset {
}
/**
* 动画所有时间轴。
* @zh 动画所有时间轴。
*/
get keys () {
return this._keys;
@@ -250,8 +250,8 @@ export class AnimationClip extends Asset {
}
/**
* 提交曲线数据的修改。
* 当你修改了 `this.curveDatas`、`this.keys` 或 `this.duration`时,
* @zh 提交曲线数据的修改。<br/>
* 当你修改了 `this.curveDatas`、`this.keys` 或 `this.duration`时,<br/>
* 必须调用 `this.updateCurveDatas()` 使修改生效。
* @deprecated
*/
@@ -261,7 +261,7 @@ export class AnimationClip extends Asset {
}
/**
* 提交事件数据的修改。
* @zh 提交事件数据的修改。<br/>
* 当你修改了 `this.events` 时,必须调用 `this.updateEventDatas()` 使修改生效。
* @protected
*/
@@ -270,7 +270,8 @@ export class AnimationClip extends Asset {
}
/**
* Gets the event group shall be processed at specified ratio.
* @en Gets the event group shall be processed at specified ratio.
* @zh 获取事件组应按指定比例处理。
* @param ratio The ratio.
* @protected
*/
@@ -283,7 +284,7 @@ export class AnimationClip extends Asset {
}
/**
* 返回本动画是否包含事件数据。
* @zh 返回本动画是否包含事件数据。
* @protected
*/
public hasEvents () {
+2 -1
View File
@@ -425,7 +425,8 @@ export class AnimationComponent extends Component implements IEventTarget {
}
/**
* IEventTarget implementations, they will be overwrote with the same implementation in EventTarget by applyMixins
* @en IEventTarget implementations, they will be overwrote with the same implementation in EventTarget by applyMixins
* @zh IEventTarget 实现,它们将被 applyMixins 在 EventTarget 中用相同的实现覆盖。
*/
public targetOff (keyOrTarget?: string | Object | undefined): void {}
public once (type: string, callback: Function, target?: Object | undefined): Function | undefined {
+2 -1
View File
@@ -182,7 +182,8 @@ export class SimpleTexture extends TextureBase {
}
/**
* This method is overrided by derived classes to provide GFX texture info.
* @en This method is overrided by derived classes to provide GFX texture info.
* @zh 这个方法被派生类重写以提供GFX纹理信息。
* @param presumed The presumed GFX texture info.
*/
protected _getGfxTextureCreateInfo (presumed: PresumedGFXTextureInfo): IGFXTextureInfo | null {
+8 -4
View File
@@ -454,7 +454,7 @@ class Component extends CCObject {
* @en Schedules a callback function that runs only once, with a delay of 0 or larger.
* @zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
* @method scheduleOnce
* @see [[Node.schedule]]
* @see [[schedule]]
* @param {function} callback 回调函数。
* @param {Number} delay 第一次执行前等待的时间(延时执行)。
* @example
@@ -527,10 +527,14 @@ class Component extends CCObject {
protected lateUpdate? (dt: number): void;
/**
* `__preload` is called before every onLoad.
* It is used to initialize the builtin components internally,
* to avoid checking whether onLoad is called before every public method calls.
* @en `__preload` is called before every onLoad.<br/>
* It is used to initialize the builtin components internally,<br/>
* to avoid checking whether onLoad is called before every public method calls.<br/>
* This method should be removed if script priority is supported.
* @zh `__preload` 在每次onLoad之前调用。<br/>
* 它用于在内部初始化内置组件,<br/>
* 以避免在每次公有方法调用之前检查是否调用了onLoad。<br/>
* 如果支持脚本优先级,则应删除此方法。
* @private
*/
protected __preload? (): void;
+10 -12
View File
@@ -37,8 +37,8 @@
// tslint:disable:no-empty-interface
/**
* @en Some JavaScript decorators which can be accessed with "cc._decorator".
* @zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
* Some JavaScript decorators which can be accessed with "cc._decorator".
* 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
* (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整)
*
* @submodule _decorator
@@ -312,26 +312,26 @@ export type SimplePropertyType = Function | string | typeof CCString | typeof CC
export type PropertyType = SimplePropertyType | SimplePropertyType[];
/**
* cc 属性选项。
* @zh cc 属性选项。
*/
export interface IPropertyOptions extends IExposedAttributes {
}
/**
* 标注属性为 cc 属性。
* @zh 标注属性为 cc 属性。
* @param options 选项。
*/
export function property (options?: IPropertyOptions): PropertyDecorator;
/**
* 标注属性为 cc 属性。
* @zh 标注属性为 cc 属性。<br/>
* 等价于`@property({type})`。
* @param type cc 属性的类型。
*/
export function property (type: PropertyType): PropertyDecorator;
/**
* 标注属性为 cc 属性。
* @zh 标注属性为 cc 属性。<br/>
* 等价于`@property()`。
*/
export function property (target: Object, propertyKey: string | symbol): void;
@@ -373,12 +373,10 @@ function createDummyDecorator (argCheckFunc) {
}
/**
* @en
* Makes a CCClass that inherit from component execute in edit mode.<br>
* By default, all components are only executed in play mode,
* which means they will not have their callback functions executed while the Editor is in edit mode.
* @zh
* 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
* Makes a CCClass that inherit from component execute in edit mode.<br/>
* By default, all components are only executed in play mode,<br/>
* which means they will not have their callback functions executed while the Editor is in edit mode.<br/>
* 允许继承自 Component 的 CCClass 在编辑器里执行。<br/>
* 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
*
* @method executeInEditMode
+4 -4
View File
@@ -237,16 +237,16 @@ export class Director extends EventTarget {
public static readonly EVENT_AFTER_DRAW = 'director_after_draw';
/**
* @en The event which will be triggered before the physics process.
* @zh 物理过程之前所触发的事件。
* The event which will be triggered before the physics process.<br/>
* 物理过程之前所触发的事件。
* @event Director.EVENT_BEFORE_PHYSICS
* @readonly
*/
public static readonly EVENT_BEFORE_PHYSICS = 'director_before_physics';
/**
* @en The event which will be triggered after the physics process.
* @zh 物理过程之后所触发的事件。
* The event which will be triggered after the physics process.<br/>
* 物理过程之后所触发的事件。
* @event Director.EVENT_AFTER_PHYSICS
* @readonly
*/
+26 -74
View File
@@ -21,9 +21,7 @@ import triangle from './triangle';
// tslint:disable:no-shadowed-variable
/**
* @en
* ray-plane intersect
* @zh
* ray-plane intersect<br/>
* 射线与平面的相交性检测。
* @param {ray} ray 射线
* @param {plane} plane 平面
@@ -43,9 +41,7 @@ const ray_plane = (function () {
})();
/**
* @en
* line-plane intersect
* @zh
* line-plane intersect<br/>
* 线段与平面的相交性检测。
* @param {line} line 线段
* @param {plane} plane 平面
@@ -64,9 +60,7 @@ const line_plane = (function () {
// based on http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/raytri/
/**
* @en
* ray-triangle intersect
* @zh
* ray-triangle intersect<br/>
* 射线与三角形的相交性检测。
* @param {ray} ray 射线
* @param {triangle} triangle 三角形
@@ -104,9 +98,7 @@ const ray_triangle = (function () {
})();
/**
* @en
* line-triangle intersect
* @zh
* line-triangle intersect<br/>
* 线段与三角形的相交性检测。
* @param {line} line 线段
* @param {triangle} triangle 三角形
@@ -169,9 +161,7 @@ const line_triangle = (function () {
})();
/**
* @en
* line-quad intersect
* @zh
* line-quad intersect<br/>
* 线段与四边形的相交性检测。
* @param {Vec3} p 线段的一点
* @param {Vec3} q 线段的另一点
@@ -262,9 +252,7 @@ const line_quad = (function () {
})();
/**
* @en
* ray-sphere intersect
* @zh
* ray-sphere intersect<br/>
* 射线和球的相交性检测。
* @param {ray} ray 射线
* @param {sphere} sphere 球
@@ -293,9 +281,7 @@ const ray_sphere = (function () {
})();
/**
* @en
* ray-aabb intersect
* @zh
* ray-aabb intersect<br/>
* 射线和轴对齐包围盒的相交性检测。
* @param {ray} ray 射线
* @param {aabb} aabb 轴对齐包围盒
@@ -323,9 +309,7 @@ const ray_aabb = (function () {
})();
/**
* @en
* ray-obb intersect
* @zh
* ray-obb intersect<br/>
* 射线和方向包围盒的相交性检测。
* @param {ray} ray 射线
* @param {obb} obb 方向包围盒
@@ -401,9 +385,7 @@ const ray_obb = (function () {
})();
/**
* @en
* aabb-aabb intersect
* @zh
* aabb-aabb intersect<br/>
* 轴对齐包围盒和轴对齐包围盒的相交性检测。
* @param {aabb} aabb1 轴对齐包围盒1
* @param {aabb} aabb2 轴对齐包围盒2
@@ -490,9 +472,7 @@ function getInterval (vertices: any[] | Vec3[], axis: Vec3) {
}
/**
* @en
* aabb-obb intersect
* @zh
* aabb-obb intersect<br/>
* 轴对齐包围盒和方向包围盒的相交性检测。
* @param {aabb} aabb 轴对齐包围盒
* @param {obb} obb 方向包围盒
@@ -543,9 +523,7 @@ const aabb_obb = (function () {
})();
/**
* @en
* aabb-plane intersect
* @zh
* aabb-plane intersect<br/>
* 轴对齐包围盒和平面的相交性检测。
* @param {aabb} aabb 轴对齐包围盒
* @param {plane} plane 平面
@@ -562,9 +540,7 @@ const aabb_plane = function (aabb: aabb, plane: plane): number {
};
/**
* @en
* aabb-frustum intersect, faster but has false positive corner cases
* @zh
* aabb-frustum intersect, faster but has false positive corner cases<br/>
* 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。
* @param {aabb} aabb 轴对齐包围盒
* @param {frustum} frustum 锥台
@@ -582,9 +558,7 @@ const aabb_frustum = function (aabb: aabb, frustum: frustum): number {
// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/
/**
* @en
* aabb-frustum intersect, handles most of the false positives correctly
* @zh
* aabb-frustum intersect, handles most of the false positives correctly<br/>
* 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。
* @param {aabb} aabb 轴对齐包围盒
* @param {frustum} frustum 锥台
@@ -634,9 +608,7 @@ const aabb_frustum_accurate = (function () {
})();
/**
* @en
* obb-point intersect
* @zh
* obb-point intersect<br/>
* 方向包围盒和点的相交性检测。
* @param {obb} obb 方向包围盒
* @param {Vec3} point 点
@@ -653,9 +625,7 @@ const obb_point = (function () {
})();
/**
* @en
* obb-plane intersect
* @zh
* obb-plane intersect<br/>
* 方向包围盒和平面的相交性检测。
* @param {obb} obb 方向包围盒
* @param {plane} plane 平面
@@ -679,9 +649,7 @@ const obb_plane = (function () {
})();
/**
* @en
* obb-frustum intersect, faster but has false positive corner cases
* @zh
* obb-frustum intersect, faster but has false positive corner cases<br/>
* 方向包围盒和锥台相交性检测,速度快,但有错误情况。
* @param {obb} obb 方向包围盒
* @param {frustum} frustum 锥台
@@ -699,9 +667,7 @@ const obb_frustum = function (obb: obb, frustum: frustum): number {
// https://cesium.com/blog/2017/02/02/tighter-frustum-culling-and-why-you-may-want-to-disregard-it/
/**
* @en
* obb-frustum intersect, handles most of the false positives correctly
* @zh
* obb-frustum intersect, handles most of the false positives correctly<br/>
* 方向包围盒和锥台相交性检测,正确处理大多数错误情况。
* @param {obb} obb 方向包围盒
* @param {frustum} frustum 锥台
@@ -757,9 +723,7 @@ const obb_frustum_accurate = (function () {
})();
/**
* @en
* obb-obb intersect
* @zh
* obb-obb intersect<br/>
* 方向包围盒和方向包围盒的相交性检测。
* @param {obb} obb1 方向包围盒1
* @param {obb} obb2 方向包围盒2
@@ -808,11 +772,9 @@ const obb_obb = (function () {
})();
/**
* @en
* sphere-plane intersect, not necessarily faster than obb-plane
* due to the length calculation of the plane normal to factor out
* the unnomalized plane distance
* @zh
* sphere-plane intersect, not necessarily faster than obb-plane<br/>
* due to the length calculation of the plane normal to factor out<br/>
* the unnomalized plane distance<br/>
* 球与平面的相交性检测。
* @param {sphere} sphere 球
* @param {plane} plane 平面
@@ -827,9 +789,7 @@ const sphere_plane = function (sphere: sphere, plane: plane): number {
};
/**
* @en
* sphere-frustum intersect, faster but has false positive corner cases
* @zh
* sphere-frustum intersect, faster but has false positive corner cases<br/>
* 球和锥台的相交性检测,速度快,但有错误情况。
* @param {sphere} sphere 球
* @param {frustum} frustum 锥台
@@ -847,9 +807,7 @@ const sphere_frustum = function (sphere: sphere, frustum: frustum): number {
// https://stackoverflow.com/questions/20912692/view-frustum-culling-corner-cases
/**
* @en
* sphere-frustum intersect, handles the false positives correctly
* @zh
* sphere-frustum intersect, handles the false positives correctly<br/>
* 球和锥台的相交性检测,正确处理大多数错误情况。
* @param {sphere} sphere 球
* @param {frustum} frustum 锥台
@@ -880,9 +838,7 @@ const sphere_frustum_accurate = (function () {
})();
/**
* @en
* sphere-sphere intersect
* @zh
* sphere-sphere intersect<br/>
* 球和球的相交性检测。
* @param {sphere} sphere0 球0
* @param {sphere} sphere1 球1
@@ -894,9 +850,7 @@ const sphere_sphere = function (sphere0: sphere, sphere1: sphere): boolean {
};
/**
* @en
* sphere-aabb intersect
* @zh
* sphere-aabb intersect<br/>
* 球和轴对齐包围盒的相交性检测。
* @param {sphere} sphere 球
* @param {aabb} aabb 轴对齐包围盒
@@ -911,9 +865,7 @@ const sphere_aabb = (function () {
})();
/**
* @en
* sphere-obb intersect
* @zh
* sphere-obb intersect<br/>
* 球和方向包围盒的相交性检测。
* @param {sphere} sphere 球
* @param {obb} obb 方向包围盒
+10 -5
View File
@@ -103,7 +103,8 @@ class OctreeBlock {
export default class Octree {
/**
* Create sub blocks and populate them with given entries
* @en Create sub blocks and populate them with given entries
* @zh 创建子块,并用给定的条目填充它们
* @param {Vec3} worldMin - min position of the parent bounding box
* @param {Vec3} worldMax - max position of the parent bounding box
* @param {Array<Object>} entries - the entries to be inserted
@@ -162,8 +163,9 @@ export default class Octree {
}
/**
* Build this octree from given entries.
* @en Build this octree from given entries.<br/>
* Root Boundary is the bounding box of all the entries.
* @zh 从给定的项中构建这个八叉树。根边界是所有这些条目的边界框。
* @param {Array<Object>} entries - a collection of entries to be queried later
* @param {function(entry: Object): Object} getBoundingShape
* - a function takes an entry and returns its primitive info
@@ -193,7 +195,8 @@ export default class Octree {
}
/**
* Add an entry to this tree. Should be called after `build`.
* @en Add an entry to this tree. Should be called after `build`.
* @zh 在这个树中添加一个条目。应该在构建之后调用。
* @param {Object} entry - the new entry
*/
public addEntry (entry) {
@@ -207,7 +210,8 @@ export default class Octree {
}
/**
* Remove an entry from this tree. Should be called after `build`.
* @en Remove an entry from this tree. Should be called after `build`.
* @zh 从这个树中删除一个条目。应该在构建之后调用。
* @param {Object} entry - the entry to be removed
*/
public removeEntry (entry) {
@@ -221,7 +225,8 @@ export default class Octree {
}
/**
* Select all the entries overlapping the given primitive
* @en Select all the entries overlapping the given primitive
* @zh 选择与给定原始项重叠的所有项
* @param {Object} shape - the selecting primitive
* @return {Set<Object>} the resulting set of entries
*/
+3 -2
View File
@@ -75,8 +75,9 @@ export default class sphere {
}
/**
* Set the components of a sphere to the given values
*
* @en Set the components of a sphere to the given values
* @zh 将球体的属性设置为给定的值。
*
* @param {sphere} out 接受操作的 sphere。
* @param cx 形状的相对于原点的 X 坐标。
* @param cy 形状的相对于原点的 Y 坐标。
+2 -2
View File
@@ -764,14 +764,14 @@ export class CCLoader extends Pipeline {
* For example, if you release a texture, the texture asset and its gl texture data will be freed up.<br>
* In complexe project, you can use this function with [[getDependsRecursively]] to free up memory in critical circumstances.<br>
* Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors.<br>
* If you only want to remove the cache of an asset, please use [[pipeline.removeItem]]
* If you only want to remove the cache of an asset, please use [[Pipeline.removeItem]]
* @zh
* 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。<br>
* 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。<br>
* 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。<br>
* 在复杂项目中,我们建议你结合 [[getDependsRecursively]] 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。<br>
* 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。<br>
* 如果你只想删除一个资源的缓存引用,请使用 [[pipeline.removeItem]]
* 如果你只想删除一个资源的缓存引用,请使用 [[Pipeline.removeItem]]
*
* @example
* ```typescript
+2 -1
View File
@@ -225,7 +225,8 @@ export default class Downloader implements IPipe {
}
/**
* Add custom supported types handler or modify existing type handler.
* @en Add custom supported types handler or modify existing type handler.
* @zh 添加自定义支持的类型处理程序或修改现有的类型处理程序。
* @method addHandlers
* @param {Object} extMap Custom supported types with corresponded handler
*/
+2 -2
View File
@@ -458,9 +458,9 @@ export class LoadingItems extends CallbacksInvoker {
* @en Add urls to the LoadingItems queue.
* @zh 向一个 LoadingItems 队列添加加载项。
* @method append
* @param {Array} urlList The url list to be appended, the url can be object or string
* @param {Array} urlList 要追加的url列表,url可以是对象或字符串
* @param {any} [owner]
* @return {Array} The accepted url list, some invalid items could be refused.
* @return {Array} 在已接受的url列表中,可以拒绝某些无效项
*/
append (urlList, owner?) {
if (!this.active) {
+2 -2
View File
@@ -378,10 +378,10 @@ export class Pipeline {
* @en Removes an completed item in pipeline.
* It will only remove the cache in the pipeline or loader, its dependencies won't be released.
* cc.loader provided another method to completely cleanup the resource and its dependencies,
* please refer to [[Loader.release]]
* please refer to [[CCLoader.release]]
* @zh 移除指定的已完成 item。
* 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
* cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 [[Loader.release]]
* cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 [[CCLoader.release]]
* @method removeItem
* @param {Object} id The id of the item
* @return {Boolean} succeed or not
+2 -1
View File
@@ -78,7 +78,8 @@ class SAXParser {
*/
class PlistParser extends SAXParser {
/**
* parse a xml string as plist object.
* @en parse a xml string as plist object.
* @zh 将xml字符串解析为plist对象。
* @param {String} xmlTxt - plist xml contents
* @return {*} plist object
*/
+18 -12
View File
@@ -19,6 +19,7 @@ export const INT_MIN = -1 << (INT_BITS - 1);
/**
* @en Returns -1, 0, +1 depending on sign of x.
* @zh 根据x的符号返回 -1,0,+1。
*/
export function sign (v: number) {
return ((v > 0) as unknown as number) - ((v < 0) as unknown as number);
@@ -26,6 +27,7 @@ export function sign (v: number) {
/**
* @en Computes absolute value of integer.
* @zh 计算整数的绝对值。
*/
export function abs (v: number) {
const mask = v >> (INT_BITS - 1);
@@ -34,6 +36,7 @@ export function abs (v: number) {
/**
* @en Computes minimum of integers x and y.
* @zh 计算整数x和y中的最小值。
*/
export function min (x: number, y: number) {
return y ^ ((x ^ y) & -(x < y));
@@ -41,6 +44,7 @@ export function min (x: number, y: number) {
/**
* @en Computes maximum of integers x and y.
* @zh 计算整数x和y中的最大值。
*/
export function max (x: number, y: number) {
return x ^ ((x ^ y) & -(x < y));
@@ -48,13 +52,14 @@ export function max (x: number, y: number) {
/**
* @en Checks if a number is a power of two.
* @zh 检查一个数字是否是2的幂。
*/
export function isPow2 (v: number) {
return !(v & (v - 1)) && (!!v);
}
/**
* @en Computes log base 2 of v.
* Computes log base 2 of v.
*/
export function log2 (v: number) {
let r: number;
@@ -67,7 +72,7 @@ export function log2 (v: number) {
}
/**
* @en Computes log base 10 of v.
* Computes log base 10 of v.
*/
export function log10 (v: number) {
return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 :
@@ -76,7 +81,7 @@ export function log10 (v: number) {
}
/**
* @en Counts number of bits.
* Counts number of bits.
*/
export function popCount (v: number) {
v = v - ((v >>> 1) & 0x55555555);
@@ -86,6 +91,7 @@ export function popCount (v: number) {
/**
* @en Counts number of trailing zeros.
* @zh 计算数字后面零的数量。
*/
export function countTrailingZeros (v: number) {
let c = 32;
@@ -100,7 +106,7 @@ export function countTrailingZeros (v: number) {
}
/**
* @en Rounds to next power of 2.
* Rounds to next power of 2.
*/
export function nextPow2 (v: number) {
v += ((v === 0) as unknown as number);
@@ -114,7 +120,7 @@ export function nextPow2 (v: number) {
}
/**
* @en Rounds down to previous power of 2.
* Rounds down to previous power of 2.
*/
export function prevPow2 (v: number) {
v |= v >>> 1;
@@ -126,7 +132,7 @@ export function prevPow2 (v: number) {
}
/**
* @en Computes parity of word.
* Computes parity of word.
*/
export function parity (v: number) {
v ^= v >>> 16;
@@ -153,7 +159,7 @@ const REVERSE_TABLE: number[] = new Array(256);
})(REVERSE_TABLE);
/**
* @en Reverse bits in a 32 bit word.
* Reverse bits in a 32 bit word.
*/
export function reverse (v: number) {
return (REVERSE_TABLE[v & 0xff] << 24) |
@@ -163,7 +169,7 @@ export function reverse (v: number) {
}
/**
* @en Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes.
* Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes.
*/
export function interleave2 (x: number, y: number) {
x &= 0xFFFF;
@@ -182,7 +188,7 @@ export function interleave2 (x: number, y: number) {
}
/**
* @en Extracts the nth interleaved component.
* Extracts the nth interleaved component.
*/
export function deinterleave2 (v: number, n: number) {
v = (v >>> n) & 0x55555555;
@@ -194,7 +200,7 @@ export function deinterleave2 (v: number, n: number) {
}
/**
* @en Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes.
* Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes.
*/
export function interleave3 (x: number, y: number, z: number) {
x &= 0x3FF;
@@ -220,7 +226,7 @@ export function interleave3 (x: number, y: number, z: number) {
}
/**
* @en Extracts nth interleaved component of a 3-tuple.
* Extracts nth interleaved component of a 3-tuple.
*/
export function deinterleave3 (v: number, n: number) {
v = (v >>> n) & 1227133513;
@@ -232,7 +238,7 @@ export function deinterleave3 (v: number, n: number) {
}
/**
* @en Computes next combination in colexicographic order (this is
* Computes next combination in colexicographic order (this is
* mistakenly called nextPermutation on the bit twiddling hacks page).
*/
export function nextCombination (v: number) {
+24 -24
View File
@@ -41,8 +41,8 @@ let _b: number = 0;
let _a: number = 0;
/**
* 通过 Red、Green、Blue 颜色通道表示颜色,并通过 Alpha 通道表示不透明度。
* 每个通道都为取值范围 [0, 255] 的整数。
* @zh 通过 Red、Green、Blue 颜色通道表示颜色,并通过 Alpha 通道表示不透明度。<br/>
* 每个通道都为取值范围 [0, 255] 的整数。<br/>
*/
export class Color extends ValueType {
@@ -225,7 +225,7 @@ export class Color extends ValueType {
}
/**
* 获取或设置当前颜色的 Red 通道。
* @zh 获取或设置当前颜色的 Red 通道。
*/
get r () {
return this._val & 0x000000ff;
@@ -237,7 +237,7 @@ export class Color extends ValueType {
}
/**
* 获取或设置当前颜色的 Green 通道。
* @zh 获取或设置当前颜色的 Green 通道。
*/
get g () {
return (this._val & 0x0000ff00) >> 8;
@@ -249,7 +249,7 @@ export class Color extends ValueType {
}
/**
* 获取或设置当前颜色的 Blue 通道。
* @zh 获取或设置当前颜色的 Blue 通道。
*/
get b () {
return (this._val & 0x00ff0000) >> 16;
@@ -261,7 +261,7 @@ export class Color extends ValueType {
}
/**
* 获取或设置当前颜色的 Alpha 通道。
* @zh 获取或设置当前颜色的 Alpha 通道。
*/
get a () {
return (this._val & 0xff000000) >>> 24;
@@ -291,14 +291,14 @@ export class Color extends ValueType {
constructor (other: Color);
/**
* 用十六进制颜色字符串中构造颜色。
* @zh 用十六进制颜色字符串中构造颜色。
* @param hexString 十六进制颜色字符串。
*/
// tslint:disable-next-line: unified-signatures
constructor (hexString: string);
/**
* 构造具有指定通道的颜色。
* @zh 构造具有指定通道的颜色。
* @param [r=0] 指定的 Red 通道。
* @param [g=0] 指定的 Green 通道。
* @param [b=0] 指定的 Blue 通道。
@@ -327,7 +327,7 @@ export class Color extends ValueType {
}
/**
* 克隆当前颜色。
* @zh 克隆当前颜色。
*/
public clone () {
const ret = new Color();
@@ -336,7 +336,7 @@ export class Color extends ValueType {
}
/**
* 判断当前颜色是否与指定颜色相等。
* @zh 判断当前颜色是否与指定颜色相等。
* @param other 相比较的颜色。
* @returns 两颜色的各通道都相等时返回 `true`;否则返回 `false`。
*/
@@ -345,7 +345,7 @@ export class Color extends ValueType {
}
/**
* 根据指定的插值比率,从当前颜色到目标颜色之间做插值。
* @zh 根据指定的插值比率,从当前颜色到目标颜色之间做插值。
* @param to 目标颜色。
* @param ratio 插值比率,范围为 [0,1]。
*/
@@ -363,7 +363,7 @@ export class Color extends ValueType {
}
/**
* 返回当前颜色的字符串表示。
* @zh 返回当前颜色的字符串表示。
* @returns 当前颜色的字符串表示。
*/
public toString () {
@@ -375,7 +375,7 @@ export class Color extends ValueType {
}
/**
* 将当前颜色转换为 CSS 格式。
* @zh 将当前颜色转换为 CSS 格式。
* @param opt 格式选项。
* @returns 当前颜色的 CSS 格式。
*/
@@ -399,10 +399,10 @@ export class Color extends ValueType {
}
/**
* 从十六进制颜色字符串中读入当前颜色。
* 十六进制颜色字符串应该以可选的 "#" 开头,紧跟最多 8 个代表十六进制数字的字符;
* 每两个连续字符代表的数值依次作为 Red、Green、Blue 和 Alpha 通道;
* 缺省的颜色通道将视为 0;缺省的透明通道将视为 255。
* @zh 从十六进制颜色字符串中读入当前颜色。<br/>
* 十六进制颜色字符串应该以可选的 "#" 开头,紧跟最多 8 个代表十六进制数字的字符;<br/>
* 每两个连续字符代表的数值依次作为 Red、Green、Blue 和 Alpha 通道;<br/>
* 缺省的颜色通道将视为 0;缺省的透明通道将视为 255。<br/>
* @param hexString 十六进制颜色字符串。
* @returns `this`
*/
@@ -417,7 +417,7 @@ export class Color extends ValueType {
}
/**
* 转换当前颜色为十六进制颜色字符串。
* @zh 转换当前颜色为十六进制颜色字符串。
* @param fmt 格式选项。
* - `'#rrggbbaa'` 获取Red、Green、Blue、Alpha通道的十六进制值(**两位**,高位补 0)并依次连接;
* - `'#rrggbb` 与 `'#rrggbbaa'` 类似但不包括 Alpha 通道。
@@ -454,7 +454,7 @@ export class Color extends ValueType {
}
/**
* 将当前颜色转换为 RGB 整数值。
* @zh 将当前颜色转换为 RGB 整数值。
* @returns RGB 整数值。从最低有效位开始,每8位分别是 Red、Green、Blue 通道的值。
* @example
* ```
@@ -467,7 +467,7 @@ export class Color extends ValueType {
}
/**
* 从 HSV 颜色中读入当前颜色。
* @zh 从 HSV 颜色中读入当前颜色。
* @param h H 通道。
* @param s S 通道。
* @param v V 通道。
@@ -544,7 +544,7 @@ export class Color extends ValueType {
}
/**
* 转换当前颜色为 HSV 颜色。
* @zh 转换当前颜色为 HSV 颜色。
* @returns HSV 颜色。成员 `h`、`s`、`v` 分别代表 HSV 颜色的 H、S、V 通道。
* @example
* ```
@@ -578,14 +578,14 @@ export class Color extends ValueType {
}
/**
* 设置当前颜色使其与指定颜色相等。
* @zh 设置当前颜色使其与指定颜色相等。
* @param other 相比较的颜色。
* @returns 当前颜色。
*/
public set (other: Color);
/**
* 设置当前颜色使其与指定通道值相等。
* @zh 设置当前颜色使其与指定通道值相等。
* @param [r=0] 指定的 Red 通道。
* @param [g=0] 指定的 Green 通道。
* @param [b=0] 指定的 Blue 通道。
@@ -610,7 +610,7 @@ export class Color extends ValueType {
}
/**
* 将当前颜色乘以与指定颜色
* @zh 将当前颜色乘以与指定颜色
* @param other 指定的颜色。
*/
public multiply (other: Color) {
+14 -14
View File
@@ -204,7 +204,7 @@ export class Mat3 extends ValueType {
}
/**
* 取四阶矩阵的前三阶,与三阶矩阵相乘
* @zh 取四阶矩阵的前三阶,与三阶矩阵相乘
*/
public static multiplyMat4 <Out extends IMat3Like> (out: Out, a: Out, b: IMat4Like) {
_a00 = a.m00; _a01 = a.m01; _a02 = a.m02;
@@ -670,7 +670,7 @@ export class Mat3 extends ValueType {
}
/**
* 克隆当前矩阵。
* @zh 克隆当前矩阵。
*/
public clone () {
const t = this;
@@ -681,7 +681,7 @@ export class Mat3 extends ValueType {
}
/**
* 设置当前矩阵使其与指定矩阵相等。
* @zh 设置当前矩阵使其与指定矩阵相等。
* @param other 相比较的矩阵。
* @return this
*/
@@ -711,7 +711,7 @@ export class Mat3 extends ValueType {
}
/**
* 判断当前矩阵是否在误差范围内与指定矩阵相等。
* @zh 判断当前矩阵是否在误差范围内与指定矩阵相等。
* @param other 相比较的矩阵。
* @param epsilon 允许的误差,应为非负数。
* @return 两矩阵的各元素都分别相等时返回 `true`;否则返回 `false`。
@@ -731,7 +731,7 @@ export class Mat3 extends ValueType {
}
/**
* 判断当前矩阵是否与指定矩阵相等。
* @zh 判断当前矩阵是否与指定矩阵相等。
* @param other 相比较的矩阵。
* @return 两矩阵的各元素都分别相等时返回 `true`;否则返回 `false`。
*/
@@ -772,7 +772,7 @@ export class Mat3 extends ValueType {
}
/**
* 计算当前矩阵的转置矩阵。
* @zh 计算当前矩阵的转置矩阵。
*/
public transpose () {
const a01 = this.m01, a02 = this.m02, a12 = this.m05;
@@ -786,7 +786,7 @@ export class Mat3 extends ValueType {
}
/**
* 计算当前矩阵的逆矩阵。
* @zh 计算当前矩阵的逆矩阵。
*/
public invert () {
_a00 = this.m00; _a01 = this.m01; _a02 = this.m02;
@@ -830,7 +830,7 @@ export class Mat3 extends ValueType {
}
/**
* 矩阵加法。将当前矩阵与指定矩阵的相加,结果返回给当前矩阵。
* @zh 矩阵加法。将当前矩阵与指定矩阵的相加,结果返回给当前矩阵。
* @param mat 相加的矩阵
*/
public add (mat: Mat3) {
@@ -847,7 +847,7 @@ export class Mat3 extends ValueType {
}
/**
* 计算矩阵减法。将当前矩阵减去指定矩阵的结果赋值给当前矩阵。
* @zh 计算矩阵减法。将当前矩阵减去指定矩阵的结果赋值给当前矩阵。
* @param mat 减数矩阵。
*/
public subtract (mat: Mat3) {
@@ -864,7 +864,7 @@ export class Mat3 extends ValueType {
}
/**
* 矩阵乘法。将当前矩阵左乘指定矩阵的结果赋值给当前矩阵。
* @zh 矩阵乘法。将当前矩阵左乘指定矩阵的结果赋值给当前矩阵。
* @param mat 指定的矩阵。
*/
public multiply (mat: Mat3) {
@@ -891,7 +891,7 @@ export class Mat3 extends ValueType {
}
/**
* 矩阵数乘。将当前矩阵与指定标量的数乘结果赋值给当前矩阵。
* @zh 矩阵数乘。将当前矩阵与指定标量的数乘结果赋值给当前矩阵。
* @param scalar 指定的标量。
*/
public multiplyScalar (scalar: number) {
@@ -908,7 +908,7 @@ export class Mat3 extends ValueType {
}
/**
* 将当前矩阵左乘缩放矩阵的结果赋值给当前矩阵,缩放矩阵由各个轴的缩放给出。
* @zh 将当前矩阵左乘缩放矩阵的结果赋值给当前矩阵,缩放矩阵由各个轴的缩放给出。
* @param vec 各个轴的缩放。
*/
public scale (vec: Vec3) {
@@ -929,7 +929,7 @@ export class Mat3 extends ValueType {
}
/**
* 将当前矩阵左乘旋转矩阵的结果赋值给当前矩阵,旋转矩阵由旋转轴和旋转角度给出。
* @zh 将当前矩阵左乘旋转矩阵的结果赋值给当前矩阵,旋转矩阵由旋转轴和旋转角度给出。
* @param mat 矩阵
* @param rad 旋转角度(弧度制)
*/
@@ -956,7 +956,7 @@ export class Mat3 extends ValueType {
}
/**
* 重置当前矩阵的值,使其表示指定四元数表示的旋转变换。
* @zh 重置当前矩阵的值,使其表示指定四元数表示的旋转变换。
* @param q 四元数表示的旋转变换。
* @returns this
*/
+18 -18
View File
@@ -1442,7 +1442,7 @@ export class Mat4 extends ValueType {
}
}
/**
* 克隆当前矩阵。
* @zh 克隆当前矩阵。
*/
public clone () {
const t = this;
@@ -1454,7 +1454,7 @@ export class Mat4 extends ValueType {
}
/**
* 设置当前矩阵使其与指定矩阵相等。
* @zh 设置当前矩阵使其与指定矩阵相等。
* @param other 相比较的矩阵。
* @return this
*/
@@ -1489,7 +1489,7 @@ export class Mat4 extends ValueType {
}
/**
* 判断当前矩阵是否在误差范围内与指定矩阵相等。
* @zh 判断当前矩阵是否在误差范围内与指定矩阵相等。
* @param other 相比较的矩阵。
* @param epsilon 允许的误差,应为非负数。
* @return 两矩阵的各元素都分别相等时返回 `true`;否则返回 `false`。
@@ -1516,7 +1516,7 @@ export class Mat4 extends ValueType {
}
/**
* 判断当前矩阵是否与指定矩阵相等。
* @zh 判断当前矩阵是否与指定矩阵相等。
* @param other 相比较的矩阵。
* @return 两矩阵的各元素都分别相等时返回 `true`;否则返回 `false`。
*/
@@ -1565,7 +1565,7 @@ export class Mat4 extends ValueType {
}
/**
* 计算当前矩阵的转置矩阵。
* @zh 计算当前矩阵的转置矩阵。
*/
public transpose () {
const a01 = this.m01, a02 = this.m02, a03 = this.m03, a12 = this.m06, a13 = this.m07, a23 = this.m11;
@@ -1585,7 +1585,7 @@ export class Mat4 extends ValueType {
}
/**
* 计算当前矩阵的逆矩阵。
* @zh 计算当前矩阵的逆矩阵。
*/
public invert () {
_a00 = this.m00; _a01 = this.m01; _a02 = this.m02; _a03 = this.m03;
@@ -1660,7 +1660,7 @@ export class Mat4 extends ValueType {
}
/**
* 矩阵加法。将当前矩阵与指定矩阵的相加,结果返回给当前矩阵。
* @zh 矩阵加法。将当前矩阵与指定矩阵的相加,结果返回给当前矩阵。
* @param mat 相加的矩阵
*/
public add (mat: Mat4) {
@@ -1684,7 +1684,7 @@ export class Mat4 extends ValueType {
}
/**
* 计算矩阵减法。将当前矩阵减去指定矩阵的结果赋值给当前矩阵。
* @zh 计算矩阵减法。将当前矩阵减去指定矩阵的结果赋值给当前矩阵。
* @param mat 减数矩阵。
*/
public subtract (mat: Mat4) {
@@ -1708,7 +1708,7 @@ export class Mat4 extends ValueType {
}
/**
* 矩阵乘法。将当前矩阵左乘指定矩阵的结果赋值给当前矩阵。
* @zh 矩阵乘法。将当前矩阵左乘指定矩阵的结果赋值给当前矩阵。
* @param mat 指定的矩阵。
*/
public multiply (mat: Mat4) {
@@ -1745,7 +1745,7 @@ export class Mat4 extends ValueType {
}
/**
* 矩阵数乘。将当前矩阵与指定标量的数乘结果赋值给当前矩阵。
* @zh 矩阵数乘。将当前矩阵与指定标量的数乘结果赋值给当前矩阵。
* @param scalar 指定的标量。
*/
public multiplyScalar (scalar: number) {
@@ -1769,7 +1769,7 @@ export class Mat4 extends ValueType {
}
/**
* 将当前矩阵左乘位移矩阵的结果赋值给当前矩阵,位移矩阵由各个轴的位移给出。
* @zh 将当前矩阵左乘位移矩阵的结果赋值给当前矩阵,位移矩阵由各个轴的位移给出。
* @param vec 位移向量。
*/
public translate (vec: Vec3) {
@@ -1781,7 +1781,7 @@ export class Mat4 extends ValueType {
}
/**
* 将当前矩阵左乘缩放矩阵的结果赋值给当前矩阵,缩放矩阵由各个轴的缩放给出。
* @zh 将当前矩阵左乘缩放矩阵的结果赋值给当前矩阵,缩放矩阵由各个轴的缩放给出。
* @param vec 各个轴的缩放。
*/
public scale (vec: Vec3) {
@@ -1806,7 +1806,7 @@ export class Mat4 extends ValueType {
}
/**
* 将当前矩阵左乘旋转矩阵的结果赋值给当前矩阵,旋转矩阵由旋转轴和旋转角度给出。
* @zh 将当前矩阵左乘旋转矩阵的结果赋值给当前矩阵,旋转矩阵由旋转轴和旋转角度给出。
* @param mat 矩阵
* @param rad 旋转角度(弧度制)
* @param axis 旋转轴
@@ -1856,7 +1856,7 @@ export class Mat4 extends ValueType {
}
/**
* 从当前矩阵中计算出位移变换的部分,并以各个轴上位移的形式赋值给出口向量。
* @zh 从当前矩阵中计算出位移变换的部分,并以各个轴上位移的形式赋值给出口向量。
* @param out 返回向量,当未指定时将创建为新的向量。
*/
public getTranslation (out: Vec3) {
@@ -1868,7 +1868,7 @@ export class Mat4 extends ValueType {
}
/**
* 从当前矩阵中计算出缩放变换的部分,并以各个轴上缩放的形式赋值给出口向量。
* @zh 从当前矩阵中计算出缩放变换的部分,并以各个轴上缩放的形式赋值给出口向量。
* @param out 返回值,当未指定时将创建为新的向量。
*/
public getScale (out: Vec3) {
@@ -1890,7 +1890,7 @@ export class Mat4 extends ValueType {
}
/**
* 从当前矩阵中计算出旋转变换的部分,并以四元数的形式赋值给出口四元数。
* @zh 从当前矩阵中计算出旋转变换的部分,并以四元数的形式赋值给出口四元数。
* @param out 返回值,当未指定时将创建为新的四元数。
*/
public getRotation (out: Quat) {
@@ -1927,7 +1927,7 @@ export class Mat4 extends ValueType {
}
/**
* 重置当前矩阵的值,使其表示指定的旋转、缩放、位移依次组合的变换。
* @zh 重置当前矩阵的值,使其表示指定的旋转、缩放、位移依次组合的变换。
* @param q 四元数表示的旋转变换。
* @param v 位移变换,表示为各个轴的位移。
* @param s 缩放变换,表示为各个轴的缩放。
@@ -1973,7 +1973,7 @@ export class Mat4 extends ValueType {
}
/**
* 重置当前矩阵的值,使其表示指定四元数表示的旋转变换。
* @zh 重置当前矩阵的值,使其表示指定四元数表示的旋转变换。
* @param q 四元数表示的旋转变换。
* @return `this`
*/
+8 -9
View File
@@ -538,8 +538,7 @@ export class Quat extends ValueType {
}
/**
* @zh
* 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX
* @zh 根据四元数计算欧拉角,返回角度 x, y 在 [-180, 180] 区间内, z 默认在 [-90, 90] 区间内,旋转顺序为 YZX
* @param outerZ z 取值范围区间改为 [-180, -90] U [90, 180]
*/
public static toEuler <Out extends IVec3Like> (out: Out, q: IQuatLike, outerZ?: boolean) {
@@ -654,21 +653,21 @@ export class Quat extends ValueType {
}
/**
* 克隆当前四元数。
* @zh 克隆当前四元数。
*/
public clone () {
return new Quat(this.x, this.y, this.z, this.w);
}
/**
* 设置当前四元数使其与指定四元数相等。
* @zh 设置当前四元数使其与指定四元数相等。
* @param other 相比较的四元数。
* @returns `this`
*/
public set (other: Quat): Quat;
/**
* 设置当前四元数指定元素值。
* @zh 设置当前四元数指定元素值。
* @param x 四元数 x 元素值
* @param y 四元数 y 元素值
* @param z 四元数 z 元素值
@@ -693,7 +692,7 @@ export class Quat extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定向量相等。
* @zh 判断当前向量是否在误差范围内与指定向量相等。
* @param other 相比较的向量。
* @param epsilon 允许的误差,应为非负数。
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
@@ -706,7 +705,7 @@ export class Quat extends ValueType {
}
/**
* 判断当前四元数是否与指定四元数相等。
* @zh 判断当前四元数是否与指定四元数相等。
* @param other 相比较的四元数。
* @returns 两四元数的各分量都相等时返回 `true`;否则返回 `false`。
*/
@@ -715,7 +714,7 @@ export class Quat extends ValueType {
}
/**
* 将当前四元数转化为欧拉角(x-y-z)并赋值给出口向量。
* @zh 将当前四元数转化为欧拉角(x-y-z)并赋值给出口向量。
* @param out 出口向量。
*/
public getEulerAngles (out: Vec3) {
@@ -723,7 +722,7 @@ export class Quat extends ValueType {
}
/**
* 根据指定的插值比率,从当前四元数到目标四元数之间做插值。
* @zh 根据指定的插值比率,从当前四元数到目标四元数之间做插值。
* @param to 目标四元数。
* @param ratio 插值比率,范围为 [0,1]。
*/
+26 -25
View File
@@ -9,10 +9,11 @@ const _r2d = 180.0 / Math.PI;
export const EPSILON = 0.000001;
/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* @en Tests whether or not the arguments have approximately the same value, within an absolute<br/>
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less<br/>
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @zh 在glMatrix的绝对或相对容差范围内,测试参数是否具有近似相同的值。<br/>
* EPSILON(小于等于1.0的值采用绝对公差,大于1.0的值采用相对公差)
* @param a The first number to test.
* @param b The second number to test.
* @return True if the numbers are approximately equal, false otherwise.
@@ -22,8 +23,8 @@ export function equals (a: number, b: number) {
}
/**
* Tests whether or not the arguments have approximately the same value by given maxDiff
*
* @en Tests whether or not the arguments have approximately the same value by given maxDiff<br/>
* @zh 通过给定的最大差异,测试参数是否具有近似相同的值。
* @param a The first number to test.
* @param b The second number to test.
* @param maxDiff Maximum difference.
@@ -35,8 +36,8 @@ export function approx (a: number, b: number, maxDiff: number) {
}
/**
* Clamps a value between a minimum float and maximum float value.
*
* @en Clamps a value between a minimum float and maximum float value.<br/>
* @zh 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。
* @param val
* @param min
* @param max
@@ -52,8 +53,8 @@ export function clamp (val: number, min: number, max: number) {
}
/**
* Clamps a value between 0 and 1.
*
* @en Clamps a value between 0 and 1.<br/>
* @zh 将值限制在0和1之间。
* @param val
*/
export function clamp01 (val: number) {
@@ -70,8 +71,8 @@ export function lerp (from: number, to: number, ratio: number) {
}
/**
* Convert Degree To Radian
*
* @en Convert Degree To Radian<br/>
* @zh 把角度换算成弧度。
* @param {Number} a Angle in Degrees
*/
export function toRadian (a: number) {
@@ -79,8 +80,8 @@ export function toRadian (a: number) {
}
/**
* Convert Radian To Degree
*
* @en Convert Radian To Degree<br/>
* @zh 把弧度换算成角度。
* @param {Number} a Angle in Radian
*/
export function toDegree (a: number) {
@@ -93,8 +94,8 @@ export function toDegree (a: number) {
export const random = Math.random;
/**
* Returns a floating-point random number between min (inclusive) and max (exclusive).
*
* @en Returns a floating-point random number between min (inclusive) and max (exclusive).<br/>
* @zh 返回最小(包含)和最大(不包含)之间的浮点随机数。
* @method randomRange
* @param min
* @param max
@@ -105,8 +106,8 @@ export function randomRange (min: number, max: number) {
}
/**
* Returns a random integer between min (inclusive) and max (exclusive).
*
* @en Returns a random integer between min (inclusive) and max (exclusive).<br/>
* @zh 返回最小(包含)和最大(不包含)之间的随机整数。
* @param min
* @param max
* @return The random integer.
@@ -139,8 +140,8 @@ export function pseudoRandomRange (seed: number, min: number, max: number) {
}
/**
* Returns a pseudo-random integer between min (inclusive) and max (exclusive).
*
* @en Returns a pseudo-random integer between min (inclusive) and max (exclusive).<br/>
* @zh 返回最小(包含)和最大(不包含)之间的浮点伪随机数。
* @param seed
* @param min
* @param max
@@ -151,8 +152,8 @@ export function pseudoRandomRangeInt (seed: number, min: number, max: number) {
}
/**
* Returns the next power of two for the value.
*
* Returns the next power of two for the value.<br/>
*
* @param val
* @return The the next power of two.
*/
@@ -168,8 +169,8 @@ export function nextPow2 (val: number) {
}
/**
* Returns float remainder for t / length.
*
* @en Returns float remainder for t / length.<br/>
* @zh 返回t / length的浮点余数。
* @param t Time start at 0.
* @param length Time of one cycle.
* @return The Time wrapped in the first cycle.
@@ -192,8 +193,8 @@ export function pingPong (t: number, length: number) {
}
/**
* Returns ratio of a value within a given range.
*
* @en Returns ratio of a value within a given range.<br/>
* @zh 返回给定范围内的值的比率。
* @param from Start value.
* @param to End value.
* @param value Given value.
+31 -31
View File
@@ -414,21 +414,21 @@ export class Vec2 extends ValueType {
}
/**
* 克隆当前向量。
* @zh 克隆当前向量。
*/
public clone () {
return new Vec2(this.x, this.y);
}
/**
* 设置当前向量使其与指定向量相等。
* @zh 设置当前向量使其与指定向量相等。
* @param other 相比较的向量。
* @return `this`
*/
public set (other: Vec2);
/**
* 设置当前向量的具体分量值。
* @zh 设置当前向量的具体分量值。
* @param x 要设置的 x 分量的值
* @param y 要设置的 y 分量的值
* @return `this`
@@ -447,7 +447,7 @@ export class Vec2 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定向量相等。
* @zh 判断当前向量是否在误差范围内与指定向量相等。
* @param other 相比较的向量。
* @param epsilon 允许的误差,应为非负数。
* @return 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
@@ -462,7 +462,7 @@ export class Vec2 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定分量的向量相等。
* @zh 判断当前向量是否在误差范围内与指定分量的向量相等。
* @param x 相比较的向量的 x 分量。
* @param y 相比较的向量的 y 分量。
* @param epsilon 允许的误差,应为非负数。
@@ -478,7 +478,7 @@ export class Vec2 extends ValueType {
}
/**
* 判断当前向量是否与指定向量相等。
* @zh 判断当前向量是否与指定向量相等。
* @param other 相比较的向量。
* @return 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
*/
@@ -487,7 +487,7 @@ export class Vec2 extends ValueType {
}
/**
* 判断当前向量是否与指定分量的向量相等。
* @zh 判断当前向量是否与指定分量的向量相等。
* @param x 指定向量的 x 分量。
* @param y 指定向量的 y 分量。
* @return 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
@@ -497,15 +497,15 @@ export class Vec2 extends ValueType {
}
/**
* 返回当前向量的字符串表示。
* @return 当前向量的字符串表示。
* @zh 返回当前向量的字符串表示。
* @returns 当前向量的字符串表示。
*/
public toString () {
return `(${this.x.toFixed(2)}, ${this.y.toFixed(2)})`;
}
/**
* 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @zh 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @param to 目标向量。
* @param ratio 插值比率,范围为 [0,1]。
*/
@@ -518,7 +518,7 @@ export class Vec2 extends ValueType {
}
/**
* 设置当前向量的值,使其各个分量都处于指定的范围内。
* @zh 设置当前向量的值,使其各个分量都处于指定的范围内。
* @param minInclusive 每个分量都代表了对应分量允许的最小值。
* @param maxInclusive 每个分量都代表了对应分量允许的最大值。
* @return `this`
@@ -530,7 +530,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量加法。将当前向量与指定向量的相加
* @zh 向量加法。将当前向量与指定向量的相加
* @param other 指定的向量。
*/
public add (other: Vec2) {
@@ -540,7 +540,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量加法。将当前向量与指定分量的向量相加
* @zh 向量加法。将当前向量与指定分量的向量相加
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
*/
@@ -551,7 +551,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定向量
* @zh 向量减法。将当前向量减去指定向量
* @param other 减数向量。
*/
public subtract (other: Vec2) {
@@ -561,7 +561,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定分量的向量
* @zh 向量减法。将当前向量减去指定分量的向量
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
*/
@@ -572,7 +572,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量数乘。将当前向量数乘指定标量
* @zh 向量数乘。将当前向量数乘指定标量
* @param scalar 标量乘数。
*/
public multiplyScalar (scalar: number) {
@@ -583,7 +583,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量乘法。将当前向量乘以与指定向量的结果赋值给当前向量。
* @zh 向量乘法。将当前向量乘以与指定向量的结果赋值给当前向量。
* @param other 指定的向量。
*/
public multiply (other: Vec2) {
@@ -594,7 +594,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @zh 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
*/
@@ -605,7 +605,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param other 指定的向量
*/
public divide (other: Vec2) {
@@ -615,7 +615,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
*/
@@ -626,7 +626,7 @@ export class Vec2 extends ValueType {
}
/**
* 将当前向量的各个分量取反
* @zh 将当前向量的各个分量取反
*/
public negative () {
this.x = -this.x;
@@ -635,7 +635,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量点乘。
* @zh 向量点乘。
* @param other 指定的向量。
* @return 当前向量与指定向量点乘的结果。
*/
@@ -644,7 +644,7 @@ export class Vec2 extends ValueType {
}
/**
* 向量叉乘。
* @zh 向量叉乘。
* @param other 指定的向量。
* @return `out`
*/
@@ -669,7 +669,7 @@ export class Vec2 extends ValueType {
}
/**
* 将当前向量归一化。
* @zh 将当前向量归一化。
*/
public normalize () {
_x = this.x;
@@ -684,7 +684,7 @@ export class Vec2 extends ValueType {
}
/**
* 获取当前向量和指定向量之间的角度。
* @zh 获取当前向量和指定向量之间的角度。
* @param other 指定的向量。
* @return 当前向量和指定向量之间的角度(弧度制);若当前向量和指定向量中存在零向量,将返回 0。
*/
@@ -704,8 +704,8 @@ export class Vec2 extends ValueType {
}
/**
* 获取当前向量和指定向量之间的有符号角度。
* 有符号角度的取值范围为 (-180, 180],当前向量可以通过逆时针旋转有符号角度与指定向量同向。
* @zh 获取当前向量和指定向量之间的有符号角度。<br/>
* 有符号角度的取值范围为 (-180, 180],当前向量可以通过逆时针旋转有符号角度与指定向量同向。<br/>
* @param other 指定的向量。
* @return 当前向量和指定向量之间的有符号角度(弧度制);若当前向量和指定向量中存在零向量,将返回 0。
*/
@@ -715,7 +715,7 @@ export class Vec2 extends ValueType {
}
/**
* 将当前向量的旋转
* @zh 将当前向量的旋转
* @param radians 旋转角度(弧度制)。
*/
public rotate (radians: number) {
@@ -730,7 +730,7 @@ export class Vec2 extends ValueType {
}
/**
* 计算当前向量在指定向量上的投影向量。
* @zh 计算当前向量在指定向量上的投影向量。
* @param other 指定的向量。
*/
public project (other: Vec2) {
@@ -741,8 +741,8 @@ export class Vec2 extends ValueType {
}
/**
* 将当前向量视为 z 分量为 0、w 分量为 1 的四维向量,
* 应用四维矩阵变换到当前矩阵
* @zh 将当前向量视为 z 分量为 0、w 分量为 1 的四维向量,<br/>
* 应用四维矩阵变换到当前矩阵<br/>
* @param matrix 变换矩阵。
*/
public transformMat4 (matrix: Mat4) {
+26 -27
View File
@@ -661,21 +661,21 @@ export class Vec3 extends ValueType {
}
/**
* 克隆当前向量。
* @zh 克隆当前向量。
*/
public clone () {
return new Vec3(this.x, this.y, this.z);
}
/**
* 设置当前向量使其与指定向量相等。
* @zh 设置当前向量使其与指定向量相等。
* @param other 相比较的向量。
* @returns `this`
*/
public set (other: Vec3);
/**
* 设置当前向量的具体分量值。
* @zh 设置当前向量的具体分量值。
* @param x 要设置的 x 分量的值
* @param y 要设置的 y 分量的值
* @param z 要设置的 z 分量的值
@@ -697,7 +697,7 @@ export class Vec3 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定向量相等。
* @zh 判断当前向量是否在误差范围内与指定向量相等。
* @param other 相比较的向量。
* @param epsilon 允许的误差,应为非负数。
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
@@ -714,7 +714,7 @@ export class Vec3 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定分量的向量相等。
* @zh 判断当前向量是否在误差范围内与指定分量的向量相等。
* @param x 相比较的向量的 x 分量。
* @param y 相比较的向量的 y 分量。
* @param z 相比较的向量的 z 分量。
@@ -733,7 +733,7 @@ export class Vec3 extends ValueType {
}
/**
* 判断当前向量是否与指定向量相等。
* @zh 判断当前向量是否与指定向量相等。
* @param other 相比较的向量。
* @returns 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
*/
@@ -742,7 +742,7 @@ export class Vec3 extends ValueType {
}
/**
* 判断当前向量是否与指定分量的向量相等。
* @zh 判断当前向量是否与指定分量的向量相等。
* @param x 指定向量的 x 分量。
* @param y 指定向量的 y 分量。
* @param z 指定向量的 z 分量。
@@ -753,7 +753,7 @@ export class Vec3 extends ValueType {
}
/**
* 返回当前向量的字符串表示。
* @zh 返回当前向量的字符串表示。
* @returns 当前向量的字符串表示。
*/
public toString () {
@@ -761,7 +761,7 @@ export class Vec3 extends ValueType {
}
/**
* 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @zh 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @param to 目标向量。
* @param ratio 插值比率,范围为 [0,1]。
*/
@@ -773,7 +773,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量加法。将当前向量与指定向量的相加
* @zh 向量加法。将当前向量与指定向量的相加
* @param other 指定的向量。
*/
public add (other: Vec3) {
@@ -784,7 +784,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量加法。将当前向量与指定分量的向量相加
* @zh 向量加法。将当前向量与指定分量的向量相加
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -797,7 +797,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定向量的结果。
* @zh 向量减法。将当前向量减去指定向量的结果。
* @param other 减数向量。
*/
public subtract (other: Vec3) {
@@ -808,7 +808,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定分量的向量
* @zh 向量减法。将当前向量减去指定分量的向量
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -821,7 +821,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量数乘。将当前向量数乘指定标量
* @zh 向量数乘。将当前向量数乘指定标量
* @param scalar 标量乘数。
*/
public multiplyScalar (scalar: number) {
@@ -833,7 +833,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量乘法。将当前向量乘以与指定向量的结果赋值给当前向量。
* @zh 向量乘法。将当前向量乘以与指定向量的结果赋值给当前向量。
* @param other 指定的向量。
*/
public multiply (other: Vec3) {
@@ -845,7 +845,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @zh 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -858,7 +858,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param other 指定的向量
*/
public divide (other: Vec3) {
@@ -869,7 +869,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -882,7 +882,7 @@ export class Vec3 extends ValueType {
}
/**
* 将当前向量的各个分量取反
* @zh 将当前向量的各个分量取反
*/
public negative () {
this.x = -this.x;
@@ -892,7 +892,7 @@ export class Vec3 extends ValueType {
}
/**
* 设置当前向量的值,使其各个分量都处于指定的范围内。
* @zh 设置当前向量的值,使其各个分量都处于指定的范围内。
* @param minInclusive 每个分量都代表了对应分量允许的最小值。
* @param maxInclusive 每个分量都代表了对应分量允许的最大值。
* @returns `this`
@@ -905,7 +905,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量点乘。
* @zh 向量点乘。
* @param other 指定的向量。
* @returns 当前向量与指定向量点乘的结果。
*/
@@ -914,7 +914,7 @@ export class Vec3 extends ValueType {
}
/**
* 向量叉乘。将当前向量左叉乘指定向量
* @zh 向量叉乘。将当前向量左叉乘指定向量
* @param other 指定的向量。
*/
public cross (other: Vec3) {
@@ -928,7 +928,7 @@ export class Vec3 extends ValueType {
}
/**
* 计算向量的长度(模)。
* @zh 计算向量的长度(模)。
* @returns 向量的长度(模)。
*/
public length () {
@@ -936,7 +936,7 @@ export class Vec3 extends ValueType {
}
/**
* 计算向量长度(模)的平方。
* @zh 计算向量长度(模)的平方。
* @returns 向量长度(模)的平方。
*/
public lengthSqr () {
@@ -944,7 +944,7 @@ export class Vec3 extends ValueType {
}
/**
* 将当前向量归一化
* @zh 将当前向量归一化
*/
public normalize () {
_x = this.x;
@@ -962,8 +962,7 @@ export class Vec3 extends ValueType {
}
/**
* 将当前向量视为 w 分量为 1 的四维向量,
* 应用四维矩阵变换到当前矩阵
* @zh 将当前向量视为 w 分量为 1 的四维向量,应用四维矩阵变换到当前矩阵
* @param matrix 变换矩阵。
*/
public transformMat4 (matrix: Mat4) {
+26 -26
View File
@@ -492,21 +492,21 @@ export class Vec4 extends ValueType {
}
/**
* 克隆当前向量。
* @zh 克隆当前向量。
*/
public clone () {
return new Vec4(this.x, this.y, this.z, this.w);
}
/**
* 设置当前向量使其与指定向量相等。
* @zh 设置当前向量使其与指定向量相等。
* @param other 相比较的向量。
* @returns `this`
*/
public set (other: Vec4);
/**
* 设置当前向量的具体分量值。
* @zh 设置当前向量的具体分量值。
* @param x 要设置的 x 分量的值
* @param y 要设置的 y 分量的值
* @param z 要设置的 z 分量的值
@@ -531,7 +531,7 @@ export class Vec4 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定向量相等。
* @zh 判断当前向量是否在误差范围内与指定向量相等。
* @param other 相比较的向量。
* @param epsilon 允许的误差,应为非负数。
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
@@ -544,7 +544,7 @@ export class Vec4 extends ValueType {
}
/**
* 判断当前向量是否在误差范围内与指定分量的向量相等。
* @zh 判断当前向量是否在误差范围内与指定分量的向量相等。
* @param x 相比较的向量的 x 分量。
* @param y 相比较的向量的 y 分量。
* @param z 相比较的向量的 z 分量。
@@ -560,7 +560,7 @@ export class Vec4 extends ValueType {
}
/**
* 判断当前向量是否与指定向量相等。
* @zh 判断当前向量是否与指定向量相等。
* @param other 相比较的向量。
* @returns 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
*/
@@ -569,7 +569,7 @@ export class Vec4 extends ValueType {
}
/**
* 判断当前向量是否与指定分量的向量相等。
* @zh 判断当前向量是否与指定分量的向量相等。
* @param x 指定向量的 x 分量。
* @param y 指定向量的 y 分量。
* @param z 指定向量的 z 分量。
@@ -581,7 +581,7 @@ export class Vec4 extends ValueType {
}
/**
* 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @zh 根据指定的插值比率,从当前向量到目标向量之间做插值。
* @param to 目标向量。
* @param ratio 插值比率,范围为 [0,1]。
*/
@@ -598,7 +598,7 @@ export class Vec4 extends ValueType {
}
/**
* 返回当前向量的字符串表示。
* @zh 返回当前向量的字符串表示。
* @returns 当前向量的字符串表示。
*/
public toString () {
@@ -606,7 +606,7 @@ export class Vec4 extends ValueType {
}
/**
* 设置当前向量的值,使其各个分量都处于指定的范围内。
* @zh 设置当前向量的值,使其各个分量都处于指定的范围内。
* @param minInclusive 每个分量都代表了对应分量允许的最小值。
* @param maxInclusive 每个分量都代表了对应分量允许的最大值。
* @returns `this`
@@ -620,7 +620,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量加法。将当前向量与指定向量的相加
* @zh 向量加法。将当前向量与指定向量的相加
* @param other 指定的向量。
*/
public add (other: Vec4) {
@@ -632,7 +632,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量加法。将当前向量与指定分量的向量相加
* @zh 向量加法。将当前向量与指定分量的向量相加
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -647,7 +647,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定向量
* @zh 向量减法。将当前向量减去指定向量
* @param other 减数向量。
*/
public subtract (other: Vec4) {
@@ -659,7 +659,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量减法。将当前向量减去指定分量的向量
* @zh 向量减法。将当前向量减去指定分量的向量
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -674,7 +674,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量数乘。将当前向量数乘指定标量
* @zh 向量数乘。将当前向量数乘指定标量
* @param scalar 标量乘数。
*/
public multiplyScalar (scalar: number) {
@@ -687,7 +687,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量乘法。将当前向量乘以指定向量
* @zh 向量乘法。将当前向量乘以指定向量
* @param other 指定的向量。
*/
public multiply (other: Vec4) {
@@ -700,7 +700,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @zh 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -715,7 +715,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param other 指定的向量
*/
public divide (other: Vec4) {
@@ -727,7 +727,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @zh 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
* @param x 指定的向量的 x 分量。
* @param y 指定的向量的 y 分量。
* @param z 指定的向量的 z 分量。
@@ -742,7 +742,7 @@ export class Vec4 extends ValueType {
}
/**
* 将当前向量的各个分量取反
* @zh 将当前向量的各个分量取反
*/
public negative () {
this.x = -this.x;
@@ -753,7 +753,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量点乘。
* @zh 向量点乘。
* @param other 指定的向量。
* @returns 当前向量与指定向量点乘的结果。
*/
@@ -762,7 +762,7 @@ export class Vec4 extends ValueType {
}
/**
* 向量叉乘。视当前向量和指定向量为三维向量(舍弃 w 分量),将当前向量左叉乘指定向量
* @zh 向量叉乘。视当前向量和指定向量为三维向量(舍弃 w 分量),将当前向量左叉乘指定向量
* @param other 指定的向量。
*/
public cross (vector: Vec4) {
@@ -776,7 +776,7 @@ export class Vec4 extends ValueType {
}
/**
* 计算向量的长度(模)。
* @zh 计算向量的长度(模)。
* @returns 向量的长度(模)。
*/
public length () {
@@ -788,7 +788,7 @@ export class Vec4 extends ValueType {
}
/**
* 计算向量长度(模)的平方。
* @zh 计算向量长度(模)的平方。
* @returns 向量长度(模)的平方。
*/
public lengthSqr () {
@@ -800,7 +800,7 @@ export class Vec4 extends ValueType {
}
/**
* 将当前向量归一化
* @zh 将当前向量归一化
*/
public normalize () {
_x = this.x;
@@ -819,7 +819,7 @@ export class Vec4 extends ValueType {
}
/**
* 应用四维矩阵变换到当前矩阵
* @zh 应用四维矩阵变换到当前矩阵
* @param matrix 变换矩阵。
*/
public transformMat4 (matrix: Mat4) {
+1 -2
View File
@@ -162,8 +162,7 @@ export class RenderView {
private _flows: RenderFlow[] = [];
/**
* @zh
* 构造函数。
* 构造函数。<br/>
* @param root Root类实例。
* @param camera 相机。
*/
@@ -44,15 +44,12 @@ export interface ILinstenerMask {
}
/**
* @en
* <p>
* <p><br/>
* The base class of event listener. <br/>
* If you need custom listener which with different callback, you need to inherit this class. <br/>
* For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
* EventListenerTouchOneByOne, EventListenerCustom.
* </p>
*
* @zh
* EventListenerTouchOneByOne, EventListenerCustom.<br/>
* </p><br/>
* 封装用户的事件处理逻辑。<br/>
* 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 [[create]] 。
*/
@@ -62,43 +59,43 @@ export class EventListener {
return this._onEvent;
}
/**
* @en The type code of unknown event listener.
* @en The type code of unknown event listener.<br/>
* @zh 未知的事件监听器类型
*/
public static UNKNOWN = 0;
/**
* @en The type code of one by one touch event listener.
* @en The type code of one by one touch event listener.<br/>
* @zh 触摸事件监听器类型,触点会一个一个得分开被派发
*/
public static TOUCH_ONE_BY_ONE = 1;
/**
* @en The type code of all at once touch event listener.
* @en The type code of all at once touch event listener.<br/>
* @zh 触摸事件监听器类型,触点会被一次性全部派发
*/
public static TOUCH_ALL_AT_ONCE = 2;
/**
* @en The type code of keyboard event listener.
* @en The type code of keyboard event listener.<br/>
* @zh 键盘事件监听器类型
*/
public static KEYBOARD = 3;
/**
* @en The type code of mouse event listener.
* @en The type code of mouse event listener.<br/>
* @zh 鼠标事件监听器类型
*/
public static MOUSE = 4;
/**
* @en The type code of acceleration event listener.
* @en The type code of acceleration event listener.<br/>
* @zh 加速器事件监听器类型
*/
public static ACCELERATION = 6;
/**
* @en The type code of custom event listener.
* @en The type code of custom event listener.<br/>
* @zh 自定义事件监听器类型
*/
public static CUSTOM = 8;
@@ -112,11 +109,10 @@ export class EventListener {
};
/**
* @en
* Create a EventListener object with configuration including the event type, handlers and other parameters.
* In handlers, this refer to the event listener object itself.
* You can also pass custom parameters in the configuration object,
* all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
* @en Create a EventListener object with configuration including the event type, handlers and other parameters.<br/>
* In handlers, this refer to the event listener object itself.<br/>
* You can also pass custom parameters in the configuration object,<br/>
* all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.<br/>
* @zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
* @param {Object} argObj a json object
*/
@@ -190,23 +186,23 @@ export class EventListener {
/**
* @en
* <p>
* Sets paused state for the listener
* The paused state is only used for scene graph priority listeners.
* `EventDispatcher::resumeAllEventListenersForTarget(node)` will set the paused state to `true`,
* while `EventDispatcher::pauseAllEventListenersForTarget(node)` will set it to `false`.
* @note 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events,
* call `setEnabled(false)` instead.
* 2) In `Node`'s onEnter and onExit, the `paused state` of the listeners
* which associated with that node will be automatically updated.
* </p>
* <p><br/>
* Sets paused state for the listener<br/>
* The paused state is only used for scene graph priority listeners.<br/>
* `EventDispatcher::resumeAllEventListenersForTarget(node)` will set the paused state to `true`,<br/>
* while `EventDispatcher::pauseAllEventListenersForTarget(node)` will set it to `false`.<br/>
* @note 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events,<br/>
* call `setEnabled(false)` instead.<br/>
* 2) In `Node`'s onEnter and onExit, the `paused state` of the listeners<br/>
* which associated with that node will be automatically updated.<br/>
* </p><br/>
* @zh
* *为侦听器设置暂停状态
* 暂停状态仅用于场景图优先级侦听器。
* `EventDispatcher :: resumeAllEventListenersForTarget(node)`将暂停状态设置为`true`,
* 而`EventDispatcher :: pauseAllEventListenersForTarget(node)`将它设置为`false`。
* 注意:
* - 固定优先级侦听器永远不会被暂停。 如果固定优先级不想接收事件,改为调用`setEnabled(false)`。
* *为侦听器设置暂停状态<br/>
* 暂停状态仅用于场景图优先级侦听器。<br/>
* `EventDispatcher :: resumeAllEventListenersForTarget(node)`将暂停状态设置为`true`,<br/>
* 而`EventDispatcher :: pauseAllEventListenersForTarget(node)`将它设置为`false`。<br/>
* 注意:<br/>
* - 固定优先级侦听器永远不会被暂停。 如果固定优先级不想接收事件,改为调用`setEnabled(false)`。<br/>
* - 在“Node”的onEnter和onExit中,监听器的“暂停状态”与该节点关联的*将自动更新。
*/
public _setPaused (paused: boolean) {
@@ -214,30 +210,24 @@ export class EventListener {
}
/**
* @en
* Checks whether the listener is paused.
* @zh
* 检查侦听器是否已暂停。
* @en Checks whether the listener is paused.<br/>
* @zh 检查侦听器是否已暂停。
*/
public _isPaused () {
return this._paused;
}
/**
* @en
* Marks the listener was registered by EventDispatcher.
* @zh
* 标记监听器已由 EventDispatcher 注册。
* @en Marks the listener was registered by EventDispatcher.<br/>
* @zh 标记监听器已由 EventDispatcher 注册。
*/
public _setRegistered (registered: boolean) {
this._registered = registered;
}
/**
* @en
* Checks whether the listener was registered by EventDispatcher
* @zh
* 检查监听器是否已由 EventDispatcher 注册。
* @en Checks whether the listener was registered by EventDispatcher<br/>
* @zh 检查监听器是否已由 EventDispatcher 注册。
* @private
*/
public _isRegistered () {
@@ -245,13 +235,11 @@ export class EventListener {
}
/**
* @en
* Gets the type of this listener
* note: It's different from `EventType`, e.g.
* TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce
* @zh
* 获取此侦听器的类型
     * 注意:它与`EventType`不同,例如
* @en Gets the type of this listener<br/>
* note: It's different from `EventType`, e.g.<br/>
* TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce<br/>
* @zh 获取此侦听器的类型<br/>
     * 注意:它与`EventType`不同,例如<br/>
     * TouchEvent 有两种事件监听器 - EventListenerOneByOne,EventListenerAllAtOnce
*/
public _getType () {
@@ -259,11 +247,9 @@ export class EventListener {
}
/**
* @en
* Gets the listener ID of this listener
* When event is being dispatched, listener ID is used as key for searching listeners according to event type.
* @zh
* 获取此侦听器的侦听器 ID。
* @en Gets the listener ID of this listener<br/>
* When event is being dispatched, listener ID is used as key for searching listeners according to event type.<br/>
* @zh 获取此侦听器的侦听器 ID。<br/>
* 调度事件时,侦听器 ID 用作根据事件类型搜索侦听器的键。
*/
public _getListenerID () {
@@ -271,13 +257,11 @@ export class EventListener {
}
/**
* @en
* Sets the fixed priority for this listener
* note: This method is only used for `fixed priority listeners`,
* it needs to access a non-zero value. 0 is reserved for scene graph priority listeners
* @zh
* 设置此侦听器的固定优先级。
* 注意:此方法仅用于“固定优先级侦听器”,
* @en Sets the fixed priority for this listener<br/>
* note: This method is only used for `fixed priority listeners`,<br/>
* it needs to access a non-zero value. 0 is reserved for scene graph priority listeners<br/>
* @zh 设置此侦听器的固定优先级。<br/>
* 注意:此方法仅用于“固定优先级侦听器”,<br/>
* 它需要访问非零值。 0保留给场景图优先级侦听器。
*/
public _setFixedPriority (fixedPriority: number) {
@@ -285,10 +269,8 @@ export class EventListener {
}
/**
* @en
* Gets the fixed priority of this listener
* @zh
* 获取此侦听器的固定优先级。
* @en Gets the fixed priority of this listener<br/>
* @zh 获取此侦听器的固定优先级。
* @return 如果它是场景图优先级侦听器则返回 0 ,则对于固定优先级侦听器则不为零
*/
public _getFixedPriority () {
@@ -296,10 +278,8 @@ export class EventListener {
}
/**
* @en
* Sets scene graph priority for this listener
* @zh
* 设置此侦听器的场景图优先级。
* @en Sets scene graph priority for this listener<br/>
* @zh 设置此侦听器的场景图优先级。
* @param {Node} node
*/
public _setSceneGraphPriority (node: any) {
@@ -308,10 +288,8 @@ export class EventListener {
}
/**
* @en
* Gets scene graph priority of this listener
* @zh
* 获取此侦听器的场景图优先级。
* @en Gets scene graph priority of this listener<br/>
* @zh 获取此侦听器的场景图优先级。
* @return 如果它是固定优先级侦听器,则为场景图优先级侦听器非 null 。
*/
public _getSceneGraphPriority () {
@@ -319,7 +297,7 @@ export class EventListener {
}
/**
* @en Checks whether the listener is available.
* @en Checks whether the listener is available.<br/>
* @zh 检测监听器是否有效
*/
public checkAvailable () {
@@ -327,7 +305,7 @@ export class EventListener {
}
/**
* @en Clones the listener, its subclasses have to override this method.
* @en Clones the listener, its subclasses have to override this method.<br/>
* @zh 克隆监听器,它的子类必须重写此方法。
*/
public clone (): EventListener | null {
@@ -335,23 +313,25 @@ export class EventListener {
}
/**
* @en Enables or disables the listener
* note: Only listeners with `enabled` state will be able to receive events.
* When an listener was initialized, it's enabled by default.
* An event listener can receive events when it is enabled and is not paused.
* paused state is always false when it is a fixed priority listener.
* @zh 启用或禁用监听器。
* 注意:只有处于“启用”状态的侦听器才能接收事件。
     * 初始化侦听器时,默认情况下启用它。
     * 事件侦听器可以在启用且未暂停时接收事件。
     * 当固定优先级侦听器时,暂停状态始终为false。
* @en
* Enables or disables the listener<br/>
* note: Only listeners with `enabled` state will be able to receive events.<br/>
* When an listener was initialized, it's enabled by default.<br/>
* An event listener can receive events when it is enabled and is not paused.<br/>
* paused state is always false when it is a fixed priority listener.<br/>
* @zh
* 启用或禁用监听器。<br/>
* 注意:只有处于“启用”状态的侦听器才能接收事件。<br/>
     * 初始化侦听器时,默认情况下启用它。<br/>
     * 事件侦听器可以在启用且未暂停时接收事件。<br/>
     * 当固定优先级侦听器时,暂停状态始终为false。<br/>
*/
public setEnabled (enabled: boolean) {
this._isEnabled = enabled;
}
/**
* @en Checks whether the listener is enabled
* @en Checks whether the listener is enabled<br/>
* @zh 检查监听器是否可用。
*/
public isEnabled () {
@@ -36,31 +36,32 @@ import eventManager from './event-manager';
import inputManager from './input-manager';
import { Touch } from './touch';
/**
* @en
* The System event, it currently supports keyboard events and accelerometer events.<br>
* You can get the SystemEvent instance with cc.systemEvent.<br>
* example:
* ```
* cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* cc.systemEvent.off(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* ```
* @zh
* 系统事件,它目前支持按键事件和重力感应事件。<br>
* 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。<br>
* @example
* ```
* cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* cc.systemEvent.off(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* ```
* @class SystemEvent
* @extends EventTarget
*/
let keyboardListener: EventListener | null = null;
let accelerationListener: EventListener | null = null;
let touchListener: EventListener | null = null;
let mouseListener: EventListener | null = null;
/**
* @en
* The System event, it currently supports keyboard events and accelerometer events.<br/>
* You can get the SystemEvent instance with cc.systemEvent.<br/>
* @example
* ```
* cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* cc.systemEvent.off(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* ```
* @zh
* 系统事件,它目前支持按键事件和重力感应事件。<br/>
* 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。<br/>
* @example
* ```
* cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* cc.systemEvent.off(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
* ```
* @class SystemEvent
* @extends EventTarget
*/
export class SystemEvent extends EventTarget {
public static EventType = SystemEventType;
constructor () {
+1
View File
@@ -26,6 +26,7 @@ function applyDefaultCircleOptions (options?: RecursivePartial<ICircleOptions>):
}
/**
* @en
* Generate a circle with radius 1, centered at origin.
* @zh
* 生成一个圆,其半径是单位1,中心点在原点。
+10 -2
View File
@@ -87,15 +87,18 @@ function getConstructor (typeOrClassName: string | Function): Function | null {
@ccclass('cc._BaseNode')
export class BaseNode extends CCObject implements IBaseNode, ISchedulable {
/**
* Gets all components attached to this node.
* @en Gets all components attached to this node.
* @zh 获取附加到此节点的所有组件。
*/
get components (): ReadonlyArray<Component> {
return this._components;
}
/**
* If true, the node is an persist node which won't be destroyed during scene transition.
* @en If true, the node is an persist node which won't be destroyed during scene transition.<br/>
* If false, the node will be destroyed automatically when loading a new scene. Default is false.
* @zh 如果为true,则该节点是一个常驻节点,不会在场景转换期间被销毁。<br/>
* 如果为false,节点将在加载新场景时自动销毁。默认为false。
* @property _persistNode
* @type {Boolean}
* @default false
@@ -573,7 +576,9 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable {
* @zh
* 插入子节点到指定位置
* @param child - the child node to be inserted
* 要插入的子节点
* @param siblingIndex - the sibling index to place the child in
* 用于放置子节点的同级索引
* @example
* ```
* node.insertChild(child, 2);
@@ -761,6 +766,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable {
* @zh
* 移除节点中指定的子节点。
* @param child - The child node which will be removed.
* 将被移除的子节点
* @example
* ```
* node.removeChild(newNode);
@@ -799,6 +805,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable {
* @en Is this node a child of the given node?
* @zh 是否是指定节点的子节点?
* @return True if this node is a child, deep child or identical to the given node.
* @return 如果此节点是子节点、深度子节点或与给定节点相同,则为True。
* @example
* ```
* node.isChildOf(newNode);
@@ -1046,6 +1053,7 @@ export class BaseNode extends CCObject implements IBaseNode, ISchedulable {
* 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
* 如果你已经获得组件引用,你也可以直接调用 component.destroy()
* @deprecated please destroy the component to remove it.
* 请销毁组件以移除它。
* @example
* ```
* node.removeComponent(cc.SpriteComponent);
+1 -2
View File
@@ -82,8 +82,7 @@ export class Layers {
}
/**
* @zh
* 添加一个新层,用户可编辑 0 - 19 位为用户自定义层
* @zh 添加一个新层,用户可编辑 0 - 19 位为用户自定义层
* @param name 层名字
* @param bitNum 层序号
*/
+2 -1
View File
@@ -137,7 +137,8 @@ function _onLoadInEditor (comp) {
}
/**
* The class used to perform activating and deactivating operations of node and component.
* @en The class used to perform activating and deactivating operations of node and component.
* @zh 用于执行节点和组件的激活和停用操作的类。
*/
export default class NodeActivator {
public resetComp: any;
+1 -1
View File
@@ -464,7 +464,7 @@ export class GraphicsComponent extends UIRenderComponent {
/**
* @zh
* 辅助材质实例化。可用于只取数据而无实体情况下渲染使用。特殊情况可参考:[[_instanceMaterial]]
* 辅助材质实例化。可用于只取数据而无实体情况下渲染使用。特殊情况可参考:[[instanceMaterial]]
*/
public helpInstanceMaterial () {
let mat: Material | null = null;
+1 -2
View File
@@ -73,8 +73,7 @@ function debounce (func: Function, wait: number, immediate?: boolean) {
}
/**
* @zh
* 富文本池。
* 富文本池。<br/>
*/
const pool = new Pool((labelSeg: ILabelSegment) => {
if (CC_EDITOR) {