forked from galacean/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShaderLabUtils.ts
38 lines (34 loc) · 1.13 KB
/
ShaderLabUtils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { ClearableObjectPool, IPoolElement } from "@galacean/engine";
import { GSErrorName } from "./GSError";
import { ShaderRange } from "./common/ShaderRange";
import { ShaderPosition } from "./common/ShaderPosition";
// #if _VERBOSE
import { GSError } from "./GSError";
// #endif
export class ShaderLabUtils {
private static _shaderLabObjectPoolSet: ClearableObjectPool<IPoolElement>[] = [];
static createObjectPool<T extends IPoolElement>(type: new () => T) {
const pool = new ClearableObjectPool<T>(type);
ShaderLabUtils._shaderLabObjectPoolSet.push(pool);
return pool;
}
static clearAllShaderLabObjectPool() {
for (let i = 0, n = ShaderLabUtils._shaderLabObjectPoolSet.length; i < n; i++) {
ShaderLabUtils._shaderLabObjectPoolSet[i].clear();
}
}
static createGSError(
message: string,
errorName: GSErrorName,
source: string,
location: ShaderRange | ShaderPosition,
file?: string
): GSError {
// #if _VERBOSE
return new GSError(errorName, message, location, source, file);
// #else
// @ts-ignore
return new Error(`[${errorName}]: ${message}`);
// #endif
}
}