Add renderer interface

This commit is contained in:
MrKBear 2022-02-07 20:39:45 +08:00
parent 5eac002106
commit c7c40bddea
3 changed files with 95 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import { Emitter, EventType } from "@Model/Emitter";
export type GLContext = WebGL2RenderingContext | WebGLRenderingContext;

View File

@ -1,8 +1,12 @@
import { Individual } from "./Individual";
import { Group } from "./Group";
import { Emitter, EventType, EventMixin } from "./Emitter";
export {
Individual,
Group
Group,
Emitter,
EventType,
EventMixin
}

90
source/Model/Renderer.ts Normal file
View File

@ -0,0 +1,90 @@
import { Emitter, EventType } from "@Model/Emitter";
/**
*
*/
type IAnyObject = Record<string, any>;
/**
*
*/
interface IRendererParam {
/**
*
*/
points?: IAnyObject
/**
*
*/
cube?: IAnyObject
}
/**
*
*/
interface ICommonParam {
/**
*
*/
color?: ObjectData;
/**
*
*/
radius?: number;
}
/**
*
*/
type ObjectID = Symbol | string | number;
/**
*
*/
type ObjectData = Array<number> | Float32Array | Float64Array;
/**
* API
*/
abstract class AbstractRenderer<
P extends IRendererParam,
E extends Record<EventType, any> = {}
> extends Emitter<E> {
/**
* @function start
* \
* \
* \
* ObjectID ID \
* ObjectID ID
*
* @param id
*/
abstract clean(id?: ObjectID | ObjectID[]): this;
/**
* @function points
*
* @param id 使
* @param position
*/
abstract points(id: ObjectID, position: ObjectData, param?: P["points"] & ICommonParam): this;
/**
* @function cube
*
* @param id 使
* @param position
*
* 注意: 这里的半径指的是立方体重心与立方体任意一面几何中心的距离
*/
abstract cube(id: ObjectID, position: ObjectData, param?: P["cube"] & ICommonParam): this;
}
export default AbstractRenderer;
export { AbstractRenderer };