@antv/l7-renderer 2.25.5 → 2.25.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/package.json +4 -4
  2. package/es/device/DeviceAttribute.d.ts +0 -13
  3. package/es/device/DeviceAttribute.js +0 -30
  4. package/es/device/DeviceBuffer.d.ts +0 -18
  5. package/es/device/DeviceBuffer.js +0 -51
  6. package/es/device/DeviceCache.d.ts +0 -14
  7. package/es/device/DeviceCache.js +0 -198
  8. package/es/device/DeviceElements.d.ts +0 -13
  9. package/es/device/DeviceElements.js +0 -42
  10. package/es/device/DeviceFramebuffer.d.ts +0 -24
  11. package/es/device/DeviceFramebuffer.js +0 -81
  12. package/es/device/DeviceModel.d.ts +0 -61
  13. package/es/device/DeviceModel.js +0 -488
  14. package/es/device/DeviceTexture2D.d.ts +0 -23
  15. package/es/device/DeviceTexture2D.js +0 -132
  16. package/es/device/constants.d.ts +0 -35
  17. package/es/device/constants.js +0 -117
  18. package/es/device/index.d.ts +0 -68
  19. package/es/device/index.js +0 -311
  20. package/es/device/utils/HashMap.d.ts +0 -24
  21. package/es/device/utils/HashMap.js +0 -86
  22. package/es/device/utils/pipeline.d.ts +0 -1
  23. package/es/device/utils/pipeline.js +0 -6
  24. package/es/device/utils/typedarray.d.ts +0 -7
  25. package/es/device/utils/typedarray.js +0 -33
  26. package/es/device/utils/webgl.d.ts +0 -1
  27. package/es/device/utils/webgl.js +0 -10
  28. package/es/index.d.ts +0 -3
  29. package/es/index.js +0 -7
  30. package/es/regl/ReglAttribute.d.ts +0 -16
  31. package/es/regl/ReglAttribute.js +0 -29
  32. package/es/regl/ReglBuffer.d.ts +0 -17
  33. package/es/regl/ReglBuffer.js +0 -33
  34. package/es/regl/ReglElements.d.ts +0 -14
  35. package/es/regl/ReglElements.js +0 -27
  36. package/es/regl/ReglFramebuffer.d.ts +0 -16
  37. package/es/regl/ReglFramebuffer.js +0 -31
  38. package/es/regl/ReglModel.d.ts +0 -46
  39. package/es/regl/ReglModel.js +0 -302
  40. package/es/regl/ReglRenderbuffer.d.ts +0 -16
  41. package/es/regl/ReglRenderbuffer.js +0 -24
  42. package/es/regl/ReglTexture2D.d.ts +0 -22
  43. package/es/regl/ReglTexture2D.js +0 -94
  44. package/es/regl/constants.d.ts +0 -43
  45. package/es/regl/constants.js +0 -133
  46. package/es/regl/index.d.ts +0 -56
  47. package/es/regl/index.js +0 -227
  48. package/lib/device/DeviceAttribute.d.ts +0 -13
  49. package/lib/device/DeviceAttribute.js +0 -50
  50. package/lib/device/DeviceBuffer.d.ts +0 -18
  51. package/lib/device/DeviceBuffer.js +0 -71
  52. package/lib/device/DeviceCache.d.ts +0 -14
  53. package/lib/device/DeviceCache.js +0 -214
  54. package/lib/device/DeviceElements.d.ts +0 -13
  55. package/lib/device/DeviceElements.js +0 -62
  56. package/lib/device/DeviceFramebuffer.d.ts +0 -24
  57. package/lib/device/DeviceFramebuffer.js +0 -101
  58. package/lib/device/DeviceModel.d.ts +0 -61
  59. package/lib/device/DeviceModel.js +0 -495
  60. package/lib/device/DeviceTexture2D.d.ts +0 -23
  61. package/lib/device/DeviceTexture2D.js +0 -151
  62. package/lib/device/constants.d.ts +0 -35
  63. package/lib/device/constants.js +0 -141
  64. package/lib/device/index.d.ts +0 -68
  65. package/lib/device/index.js +0 -332
  66. package/lib/device/utils/HashMap.d.ts +0 -24
  67. package/lib/device/utils/HashMap.js +0 -113
  68. package/lib/device/utils/pipeline.d.ts +0 -1
  69. package/lib/device/utils/pipeline.js +0 -30
  70. package/lib/device/utils/typedarray.d.ts +0 -7
  71. package/lib/device/utils/typedarray.js +0 -58
  72. package/lib/device/utils/webgl.d.ts +0 -1
  73. package/lib/device/utils/webgl.js +0 -34
  74. package/lib/index.d.ts +0 -3
  75. package/lib/index.js +0 -42
  76. package/lib/regl/ReglAttribute.d.ts +0 -16
  77. package/lib/regl/ReglAttribute.js +0 -49
  78. package/lib/regl/ReglBuffer.d.ts +0 -17
  79. package/lib/regl/ReglBuffer.js +0 -53
  80. package/lib/regl/ReglElements.d.ts +0 -14
  81. package/lib/regl/ReglElements.js +0 -47
  82. package/lib/regl/ReglFramebuffer.d.ts +0 -16
  83. package/lib/regl/ReglFramebuffer.js +0 -51
  84. package/lib/regl/ReglModel.d.ts +0 -46
  85. package/lib/regl/ReglModel.js +0 -311
  86. package/lib/regl/ReglRenderbuffer.d.ts +0 -16
  87. package/lib/regl/ReglRenderbuffer.js +0 -44
  88. package/lib/regl/ReglTexture2D.d.ts +0 -22
  89. package/lib/regl/ReglTexture2D.js +0 -107
  90. package/lib/regl/constants.d.ts +0 -43
  91. package/lib/regl/constants.js +0 -170
  92. package/lib/regl/index.d.ts +0 -56
  93. package/lib/regl/index.js +0 -256
@@ -1,35 +0,0 @@
1
- import { AddressMode, BlendFactor, BlendMode, BufferFrequencyHint, CompareFunction, CullMode, Format, PrimitiveTopology, StencilOp } from '@antv/g-device-api';
2
- import type { TypedArray } from './utils/typedarray';
3
- export declare const typedArrayCtorMap: {
4
- [key: string]: new (data: number[]) => TypedArray;
5
- };
6
- export declare const primitiveMap: {
7
- [key: string]: PrimitiveTopology;
8
- };
9
- export declare const sizeFormatMap: {
10
- [key: number]: Format;
11
- };
12
- export declare const hintMap: {
13
- [key: string]: BufferFrequencyHint;
14
- };
15
- export declare const wrapModeMap: {
16
- [key: string]: AddressMode;
17
- };
18
- export declare const depthFuncMap: {
19
- [key: string]: CompareFunction;
20
- };
21
- export declare const cullFaceMap: {
22
- [key: string]: CullMode;
23
- };
24
- export declare const blendEquationMap: {
25
- [key: string]: BlendMode;
26
- };
27
- export declare const blendFuncMap: {
28
- [key: string]: BlendFactor;
29
- };
30
- export declare const stencilOpMap: {
31
- [key: string]: StencilOp;
32
- };
33
- export declare const stencilFuncMap: {
34
- [key: string]: CompareFunction;
35
- };
@@ -1,141 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/device/constants.ts
20
- var constants_exports = {};
21
- __export(constants_exports, {
22
- blendEquationMap: () => blendEquationMap,
23
- blendFuncMap: () => blendFuncMap,
24
- cullFaceMap: () => cullFaceMap,
25
- depthFuncMap: () => depthFuncMap,
26
- hintMap: () => hintMap,
27
- primitiveMap: () => primitiveMap,
28
- sizeFormatMap: () => sizeFormatMap,
29
- stencilFuncMap: () => stencilFuncMap,
30
- stencilOpMap: () => stencilOpMap,
31
- typedArrayCtorMap: () => typedArrayCtorMap,
32
- wrapModeMap: () => wrapModeMap
33
- });
34
- module.exports = __toCommonJS(constants_exports);
35
- var import_g_device_api = require("@antv/g-device-api");
36
- var import_l7_core = require("@antv/l7-core");
37
- var typedArrayCtorMap = {
38
- [import_l7_core.gl.FLOAT]: Float32Array,
39
- [import_l7_core.gl.UNSIGNED_BYTE]: Uint8Array,
40
- [import_l7_core.gl.SHORT]: Int16Array,
41
- [import_l7_core.gl.UNSIGNED_SHORT]: Uint16Array,
42
- [import_l7_core.gl.INT]: Int32Array,
43
- [import_l7_core.gl.UNSIGNED_INT]: Uint32Array
44
- };
45
- var primitiveMap = {
46
- [import_l7_core.gl.POINTS]: import_g_device_api.PrimitiveTopology.POINTS,
47
- [import_l7_core.gl.LINES]: import_g_device_api.PrimitiveTopology.LINES,
48
- [import_l7_core.gl.LINE_LOOP]: import_g_device_api.PrimitiveTopology.LINES,
49
- [import_l7_core.gl.LINE_STRIP]: import_g_device_api.PrimitiveTopology.LINE_STRIP,
50
- [import_l7_core.gl.TRIANGLES]: import_g_device_api.PrimitiveTopology.TRIANGLES,
51
- [import_l7_core.gl.TRIANGLE_FAN]: import_g_device_api.PrimitiveTopology.TRIANGLES,
52
- [import_l7_core.gl.TRIANGLE_STRIP]: import_g_device_api.PrimitiveTopology.TRIANGLE_STRIP
53
- };
54
- var sizeFormatMap = {
55
- [1]: import_g_device_api.Format.F32_R,
56
- [2]: import_g_device_api.Format.F32_RG,
57
- [3]: import_g_device_api.Format.F32_RGB,
58
- [4]: import_g_device_api.Format.F32_RGBA
59
- };
60
- var hintMap = {
61
- [import_l7_core.gl.STATIC_DRAW]: import_g_device_api.BufferFrequencyHint.STATIC,
62
- [import_l7_core.gl.DYNAMIC_DRAW]: import_g_device_api.BufferFrequencyHint.DYNAMIC,
63
- [import_l7_core.gl.STREAM_DRAW]: import_g_device_api.BufferFrequencyHint.DYNAMIC
64
- };
65
- var wrapModeMap = {
66
- [import_l7_core.gl.REPEAT]: import_g_device_api.AddressMode.REPEAT,
67
- [import_l7_core.gl.CLAMP_TO_EDGE]: import_g_device_api.AddressMode.CLAMP_TO_EDGE,
68
- [import_l7_core.gl.MIRRORED_REPEAT]: import_g_device_api.AddressMode.MIRRORED_REPEAT
69
- };
70
- var depthFuncMap = {
71
- [import_l7_core.gl.NEVER]: import_g_device_api.CompareFunction.NEVER,
72
- [import_l7_core.gl.ALWAYS]: import_g_device_api.CompareFunction.ALWAYS,
73
- [import_l7_core.gl.LESS]: import_g_device_api.CompareFunction.LESS,
74
- [import_l7_core.gl.LEQUAL]: import_g_device_api.CompareFunction.LEQUAL,
75
- [import_l7_core.gl.GREATER]: import_g_device_api.CompareFunction.GREATER,
76
- [import_l7_core.gl.GEQUAL]: import_g_device_api.CompareFunction.GEQUAL,
77
- [import_l7_core.gl.EQUAL]: import_g_device_api.CompareFunction.EQUAL,
78
- [import_l7_core.gl.NOTEQUAL]: import_g_device_api.CompareFunction.NOTEQUAL
79
- };
80
- var cullFaceMap = {
81
- [import_l7_core.gl.FRONT]: import_g_device_api.CullMode.FRONT,
82
- [import_l7_core.gl.BACK]: import_g_device_api.CullMode.BACK
83
- };
84
- var blendEquationMap = {
85
- [import_l7_core.gl.FUNC_ADD]: import_g_device_api.BlendMode.ADD,
86
- [import_l7_core.gl.MIN_EXT]: import_g_device_api.BlendMode.MIN,
87
- [import_l7_core.gl.MAX_EXT]: import_g_device_api.BlendMode.MAX,
88
- [import_l7_core.gl.FUNC_SUBTRACT]: import_g_device_api.BlendMode.SUBSTRACT,
89
- [import_l7_core.gl.FUNC_REVERSE_SUBTRACT]: import_g_device_api.BlendMode.REVERSE_SUBSTRACT
90
- };
91
- var blendFuncMap = {
92
- [import_l7_core.gl.ZERO]: import_g_device_api.BlendFactor.ZERO,
93
- [import_l7_core.gl.ONE]: import_g_device_api.BlendFactor.ONE,
94
- [import_l7_core.gl.SRC_COLOR]: import_g_device_api.BlendFactor.SRC,
95
- [import_l7_core.gl.ONE_MINUS_SRC_COLOR]: import_g_device_api.BlendFactor.ONE_MINUS_SRC,
96
- [import_l7_core.gl.SRC_ALPHA]: import_g_device_api.BlendFactor.SRC_ALPHA,
97
- [import_l7_core.gl.ONE_MINUS_SRC_ALPHA]: import_g_device_api.BlendFactor.ONE_MINUS_SRC_ALPHA,
98
- [import_l7_core.gl.DST_COLOR]: import_g_device_api.BlendFactor.DST,
99
- [import_l7_core.gl.ONE_MINUS_DST_COLOR]: import_g_device_api.BlendFactor.ONE_MINUS_DST,
100
- [import_l7_core.gl.DST_ALPHA]: import_g_device_api.BlendFactor.DST_ALPHA,
101
- [import_l7_core.gl.ONE_MINUS_DST_ALPHA]: import_g_device_api.BlendFactor.ONE_MINUS_DST_ALPHA,
102
- [import_l7_core.gl.CONSTANT_COLOR]: import_g_device_api.BlendFactor.CONST,
103
- [import_l7_core.gl.ONE_MINUS_CONSTANT_COLOR]: import_g_device_api.BlendFactor.ONE_MINUS_CONSTANT,
104
- [import_l7_core.gl.CONSTANT_ALPHA]: import_g_device_api.BlendFactor.CONST,
105
- [import_l7_core.gl.ONE_MINUS_CONSTANT_ALPHA]: import_g_device_api.BlendFactor.ONE_MINUS_CONSTANT,
106
- [import_l7_core.gl.SRC_ALPHA_SATURATE]: import_g_device_api.BlendFactor.SRC_ALPHA_SATURATE
107
- };
108
- var stencilOpMap = {
109
- [import_l7_core.gl.REPLACE]: import_g_device_api.StencilOp.REPLACE,
110
- [import_l7_core.gl.KEEP]: import_g_device_api.StencilOp.KEEP,
111
- [import_l7_core.gl.ZERO]: import_g_device_api.StencilOp.ZERO,
112
- [import_l7_core.gl.INVERT]: import_g_device_api.StencilOp.INVERT,
113
- [import_l7_core.gl.INCR]: import_g_device_api.StencilOp.INCREMENT_CLAMP,
114
- [import_l7_core.gl.DECR]: import_g_device_api.StencilOp.DECREMENT_CLAMP,
115
- [import_l7_core.gl.INCR_WRAP]: import_g_device_api.StencilOp.INCREMENT_WRAP,
116
- [import_l7_core.gl.DECR_WRAP]: import_g_device_api.StencilOp.DECREMENT_WRAP
117
- };
118
- var stencilFuncMap = {
119
- [import_l7_core.gl.ALWAYS]: import_g_device_api.CompareFunction.ALWAYS,
120
- [import_l7_core.gl.EQUAL]: import_g_device_api.CompareFunction.EQUAL,
121
- [import_l7_core.gl.GEQUAL]: import_g_device_api.CompareFunction.GEQUAL,
122
- [import_l7_core.gl.GREATER]: import_g_device_api.CompareFunction.GREATER,
123
- [import_l7_core.gl.LEQUAL]: import_g_device_api.CompareFunction.LEQUAL,
124
- [import_l7_core.gl.LESS]: import_g_device_api.CompareFunction.LESS,
125
- [import_l7_core.gl.NEVER]: import_g_device_api.CompareFunction.NEVER,
126
- [import_l7_core.gl.NOTEQUAL]: import_g_device_api.CompareFunction.NOTEQUAL
127
- };
128
- // Annotate the CommonJS export names for ESM import in node:
129
- 0 && (module.exports = {
130
- blendEquationMap,
131
- blendFuncMap,
132
- cullFaceMap,
133
- depthFuncMap,
134
- hintMap,
135
- primitiveMap,
136
- sizeFormatMap,
137
- stencilFuncMap,
138
- stencilOpMap,
139
- typedArrayCtorMap,
140
- wrapModeMap
141
- });
@@ -1,68 +0,0 @@
1
- import type { RenderPass, RenderTarget, SwapChain } from '@antv/g-device-api';
2
- import type { IAttribute, IAttributeInitializationOptions, IBuffer, IBufferInitializationOptions, IClearOptions, IElements, IElementsInitializationOptions, IExtensions, IFramebuffer, IFramebufferInitializationOptions, IModel, IModelInitializationOptions, IReadPixelsOptions, IRenderConfig, IRendererService, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
3
- import { RenderCache } from './DeviceCache';
4
- import DeviceFramebuffer from './DeviceFramebuffer';
5
- /**
6
- * Device API renderer
7
- */
8
- export default class DeviceRendererService implements IRendererService {
9
- uniformBuffers: IBuffer[];
10
- extensionObject: IExtensions;
11
- private device;
12
- swapChain: SwapChain;
13
- private $container;
14
- private canvas;
15
- width: number;
16
- height: number;
17
- private isDirty;
18
- /**
19
- * Current render pass.
20
- */
21
- renderPass: RenderPass;
22
- preRenderPass: RenderPass;
23
- mainColorRT: RenderTarget;
24
- mainDepthRT: RenderTarget;
25
- renderCache: RenderCache;
26
- /**
27
- * Current FBO.
28
- */
29
- currentFramebuffer: DeviceFramebuffer | null;
30
- queryVerdorInfo: () => string;
31
- private viewportOrigin;
32
- init(canvas: HTMLCanvasElement, cfg: IRenderConfig): Promise<void>;
33
- private createMainColorDepthRT;
34
- beginFrame(): void;
35
- endFrame(): void;
36
- getPointSizeRange(): any;
37
- testExtension(name: string): boolean;
38
- createModel: (options: IModelInitializationOptions) => IModel;
39
- createAttribute: (options: IAttributeInitializationOptions) => IAttribute;
40
- createBuffer: (options: IBufferInitializationOptions) => IBuffer;
41
- createElements: (options: IElementsInitializationOptions) => IElements;
42
- createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
43
- createFramebuffer: (options: IFramebufferInitializationOptions) => DeviceFramebuffer;
44
- useFramebuffer: (framebuffer: IFramebuffer | null, drawCommands: () => void) => void;
45
- useFramebufferAsync: (framebuffer: IFramebuffer | null, drawCommands: () => Promise<void>) => Promise<void>;
46
- clear: (options: IClearOptions) => void;
47
- viewport: ({ width, height, }: {
48
- x: number;
49
- y: number;
50
- width: number;
51
- height: number;
52
- }) => void;
53
- readPixels: (options: IReadPixelsOptions) => Uint8Array;
54
- readPixelsAsync: (options: IReadPixelsOptions) => Promise<Uint8Array>;
55
- getViewportSize: () => {
56
- width: number;
57
- height: number;
58
- };
59
- getContainer: () => HTMLElement | null;
60
- getCanvas: () => HTMLCanvasElement;
61
- getGLContext: () => WebGLRenderingContext;
62
- setState(): void;
63
- setBaseState(): void;
64
- setCustomLayerDefaults(): void;
65
- setDirty(flag: boolean): void;
66
- getDirty(): boolean;
67
- destroy: () => void;
68
- }
@@ -1,332 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __async = (__this, __arguments, generator) => {
29
- return new Promise((resolve, reject) => {
30
- var fulfilled = (value) => {
31
- try {
32
- step(generator.next(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var rejected = (value) => {
38
- try {
39
- step(generator.throw(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
- step((generator = generator.apply(__this, __arguments)).next());
46
- });
47
- };
48
-
49
- // src/device/index.ts
50
- var device_exports = {};
51
- __export(device_exports, {
52
- default: () => DeviceRendererService
53
- });
54
- module.exports = __toCommonJS(device_exports);
55
- var import_g_device_api = require("@antv/g-device-api");
56
- var import_l7_utils = require("@antv/l7-utils");
57
- var import_DeviceAttribute = __toESM(require("./DeviceAttribute"));
58
- var import_DeviceBuffer = __toESM(require("./DeviceBuffer"));
59
- var import_DeviceCache = require("./DeviceCache");
60
- var import_DeviceElements = __toESM(require("./DeviceElements"));
61
- var import_DeviceFramebuffer = __toESM(require("./DeviceFramebuffer"));
62
- var import_DeviceModel = __toESM(require("./DeviceModel"));
63
- var import_DeviceTexture2D = __toESM(require("./DeviceTexture2D"));
64
- var import_webgl = require("./utils/webgl");
65
- var { isUndefined } = import_l7_utils.lodashUtil;
66
- var DeviceRendererService = class {
67
- constructor() {
68
- this.uniformBuffers = [];
69
- this.queryVerdorInfo = () => {
70
- return this.device.queryVendorInfo().platformString;
71
- };
72
- this.createModel = (options) => new import_DeviceModel.default(this.device, options, this);
73
- this.createAttribute = (options) => new import_DeviceAttribute.default(this.device, options);
74
- this.createBuffer = (options) => new import_DeviceBuffer.default(this.device, options);
75
- this.createElements = (options) => new import_DeviceElements.default(this.device, options);
76
- this.createTexture2D = (options) => new import_DeviceTexture2D.default(this.device, options);
77
- this.createFramebuffer = (options) => new import_DeviceFramebuffer.default(this.device, options);
78
- this.useFramebuffer = (framebuffer, drawCommands) => {
79
- this.currentFramebuffer = framebuffer;
80
- this.beginFrame();
81
- drawCommands();
82
- this.endFrame();
83
- this.currentFramebuffer = null;
84
- };
85
- this.useFramebufferAsync = (framebuffer, drawCommands) => __async(this, null, function* () {
86
- this.currentFramebuffer = framebuffer;
87
- this.preRenderPass = this.renderPass;
88
- this.beginFrame();
89
- yield drawCommands();
90
- this.endFrame();
91
- this.currentFramebuffer = null;
92
- this.renderPass = this.preRenderPass;
93
- });
94
- this.clear = (options) => {
95
- const { color, depth, stencil, framebuffer = null } = options;
96
- if (framebuffer) {
97
- framebuffer.clearOptions = { color, depth, stencil };
98
- } else {
99
- const platformString = this.queryVerdorInfo();
100
- if (platformString === "WebGL1") {
101
- const gl = this.getGLContext();
102
- if (!isUndefined(stencil)) {
103
- gl.clearStencil(stencil);
104
- gl.clear(gl.STENCIL_BUFFER_BIT);
105
- } else if (!isUndefined(depth)) {
106
- gl.clearDepth(depth);
107
- gl.clear(gl.DEPTH_BUFFER_BIT);
108
- }
109
- } else if (platformString === "WebGL2") {
110
- const gl = this.getGLContext();
111
- if (!isUndefined(stencil)) {
112
- gl.clearBufferiv(gl.STENCIL, 0, [stencil]);
113
- } else if (!isUndefined(depth)) {
114
- gl.clearBufferfv(gl.DEPTH, 0, [depth]);
115
- }
116
- }
117
- }
118
- };
119
- this.viewport = ({
120
- // x,
121
- // y,
122
- width,
123
- height
124
- }) => {
125
- this.swapChain.configureSwapChain(width, height);
126
- this.createMainColorDepthRT(width, height);
127
- this.width = width;
128
- this.height = height;
129
- };
130
- this.readPixels = (options) => {
131
- const { framebuffer, x, y, width, height } = options;
132
- const readback = this.device.createReadback();
133
- const texture = framebuffer["colorTexture"];
134
- const result = readback.readTextureSync(
135
- texture,
136
- x,
137
- /**
138
- * Origin is at lower-left corner. Width / height is already multiplied by dpr.
139
- * WebGPU needs flipY
140
- */
141
- this.viewportOrigin === import_g_device_api.ViewportOrigin.LOWER_LEFT ? y : this.height - y,
142
- width,
143
- height,
144
- new Uint8Array(width * height * 4)
145
- );
146
- if (this.viewportOrigin !== import_g_device_api.ViewportOrigin.LOWER_LEFT) {
147
- for (let j = 0; j < result.length; j += 4) {
148
- const t = result[j];
149
- result[j] = result[j + 2];
150
- result[j + 2] = t;
151
- }
152
- }
153
- readback.destroy();
154
- return result;
155
- };
156
- this.readPixelsAsync = (options) => __async(this, null, function* () {
157
- const { framebuffer, x, y, width, height } = options;
158
- const readback = this.device.createReadback();
159
- const texture = framebuffer["colorTexture"];
160
- const result = yield readback.readTexture(
161
- texture,
162
- x,
163
- /**
164
- * Origin is at lower-left corner. Width / height is already multiplied by dpr.
165
- * WebGPU needs flipY
166
- */
167
- this.viewportOrigin === import_g_device_api.ViewportOrigin.LOWER_LEFT ? y : this.height - y,
168
- width,
169
- height,
170
- new Uint8Array(width * height * 4)
171
- );
172
- if (this.viewportOrigin !== import_g_device_api.ViewportOrigin.LOWER_LEFT) {
173
- for (let j = 0; j < result.length; j += 4) {
174
- const t = result[j];
175
- result[j] = result[j + 2];
176
- result[j + 2] = t;
177
- }
178
- }
179
- readback.destroy();
180
- return result;
181
- });
182
- this.getViewportSize = () => {
183
- return {
184
- width: this.width,
185
- height: this.height
186
- };
187
- };
188
- this.getContainer = () => {
189
- var _a;
190
- return (_a = this.canvas) == null ? void 0 : _a.parentElement;
191
- };
192
- this.getCanvas = () => {
193
- return this.canvas;
194
- };
195
- this.getGLContext = () => {
196
- return this.device["gl"];
197
- };
198
- this.destroy = () => {
199
- var _a;
200
- this.canvas = null;
201
- (_a = this.uniformBuffers) == null ? void 0 : _a.forEach((buffer) => {
202
- buffer.destroy();
203
- });
204
- this.device.destroy();
205
- this.renderCache.destroy();
206
- };
207
- }
208
- init(canvas, cfg) {
209
- return __async(this, null, function* () {
210
- const { enableWebGPU, shaderCompilerPath, antialias } = cfg;
211
- this.canvas = canvas;
212
- const deviceContribution = enableWebGPU ? new import_g_device_api.WebGPUDeviceContribution({
213
- shaderCompilerPath
214
- }) : new import_g_device_api.WebGLDeviceContribution({
215
- // Use WebGL2 first and downgrade to WebGL1 if WebGL2 is not supported.
216
- targets: ["webgl2", "webgl1"],
217
- antialias,
218
- onContextLost(e) {
219
- console.warn("context lost", e);
220
- },
221
- onContextCreationError(e) {
222
- console.warn("context creation error", e);
223
- },
224
- onContextRestored(e) {
225
- console.warn("context restored", e);
226
- }
227
- });
228
- const swapChain = yield deviceContribution.createSwapChain(canvas);
229
- swapChain.configureSwapChain(canvas.width, canvas.height);
230
- this.device = swapChain.getDevice();
231
- this.swapChain = swapChain;
232
- this.renderCache = new import_DeviceCache.RenderCache(this.device);
233
- this.currentFramebuffer = null;
234
- this.viewportOrigin = this.device.queryVendorInfo().viewportOrigin;
235
- const gl = this.device["gl"];
236
- this.extensionObject = {
237
- // @ts-ignore
238
- OES_texture_float: !(0, import_webgl.isWebGL2)(gl) && this.device["OES_texture_float"]
239
- };
240
- this.createMainColorDepthRT(canvas.width, canvas.height);
241
- });
242
- }
243
- createMainColorDepthRT(width, height) {
244
- if (this.mainColorRT) {
245
- this.mainColorRT.destroy();
246
- }
247
- if (this.mainDepthRT) {
248
- this.mainDepthRT.destroy();
249
- }
250
- this.mainColorRT = this.device.createRenderTargetFromTexture(
251
- this.device.createTexture({
252
- format: import_g_device_api.Format.U8_RGBA_RT,
253
- width,
254
- height,
255
- usage: import_g_device_api.TextureUsage.RENDER_TARGET
256
- })
257
- );
258
- this.mainDepthRT = this.device.createRenderTargetFromTexture(
259
- this.device.createTexture({
260
- format: import_g_device_api.Format.D24_S8,
261
- width,
262
- height,
263
- usage: import_g_device_api.TextureUsage.RENDER_TARGET
264
- })
265
- );
266
- }
267
- beginFrame() {
268
- this.device.beginFrame();
269
- const { currentFramebuffer, swapChain, mainColorRT, mainDepthRT } = this;
270
- const colorAttachment = currentFramebuffer ? currentFramebuffer["colorRenderTarget"] : mainColorRT;
271
- const colorResolveTo = currentFramebuffer ? null : swapChain.getOnscreenTexture();
272
- const depthStencilAttachment = currentFramebuffer ? currentFramebuffer["depthRenderTarget"] : mainDepthRT;
273
- const { color = [0, 0, 0, 0], depth = 1, stencil = 0 } = (
274
- // @ts-ignore
275
- (currentFramebuffer == null ? void 0 : currentFramebuffer.clearOptions) || {}
276
- );
277
- const colorClearColor = colorAttachment ? (0, import_g_device_api.colorNewFromRGBA)(color[0] * 255, color[1] * 255, color[2] * 255, color[3]) : import_g_device_api.TransparentBlack;
278
- const depthClearValue = depthStencilAttachment ? depth : void 0;
279
- const stencilClearValue = depthStencilAttachment ? stencil : void 0;
280
- const renderPass = this.device.createRenderPass({
281
- colorAttachment: [colorAttachment],
282
- colorResolveTo: [colorResolveTo],
283
- colorClearColor: [colorClearColor],
284
- // colorStore: [!!currentFramebuffer],
285
- colorStore: [true],
286
- depthStencilAttachment,
287
- depthClearValue,
288
- stencilClearValue
289
- });
290
- this.renderPass = renderPass;
291
- }
292
- endFrame() {
293
- this.device.submitPass(this.renderPass);
294
- this.device.endFrame();
295
- }
296
- getPointSizeRange() {
297
- const gl = this.device["gl"];
298
- return gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
299
- }
300
- testExtension(name) {
301
- return !!this.getGLContext().getExtension(name);
302
- }
303
- // TODO: 临时方法
304
- setState() {
305
- const gl = this.getGLContext();
306
- if (gl) {
307
- gl.disable(gl.CULL_FACE);
308
- gl.blendEquation(gl.FUNC_ADD);
309
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
310
- }
311
- }
312
- setBaseState() {
313
- const gl = this.getGLContext();
314
- if (gl) {
315
- gl.disable(gl.CULL_FACE);
316
- gl.blendEquation(gl.FUNC_ADD);
317
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
318
- }
319
- }
320
- setCustomLayerDefaults() {
321
- const gl = this.getGLContext();
322
- if (gl) {
323
- gl.disable(gl.CULL_FACE);
324
- }
325
- }
326
- setDirty(flag) {
327
- this.isDirty = flag;
328
- }
329
- getDirty() {
330
- return this.isDirty;
331
- }
332
- };
@@ -1,24 +0,0 @@
1
- export declare function hashCodeNumberUpdate(hash: number, v?: number): number;
2
- export declare function hashCodeNumberFinish(hash: number): number;
3
- export declare function nullHashFunc(): number;
4
- export type EqualFunc<K> = (a: K, b: K) => boolean;
5
- export type HashFunc<K> = (a: K) => number;
6
- declare class HashBucket<K, V> {
7
- keys: K[];
8
- values: V[];
9
- }
10
- export declare class HashMap<K, V> {
11
- private keyEqualFunc;
12
- private keyHashFunc;
13
- buckets: Map<number, HashBucket<K, V>>;
14
- constructor(keyEqualFunc: EqualFunc<K>, keyHashFunc: HashFunc<K>);
15
- private findBucketIndex;
16
- private findBucket;
17
- get(k: K): V | null;
18
- add(k: K, v: V): void;
19
- delete(k: K): void;
20
- clear(): void;
21
- size(): number;
22
- values(): IterableIterator<V>;
23
- }
24
- export {};