@openglobus/og 0.28.7 → 1.0.0-rc2
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.
- package/LICENSE.md +218 -4
- package/README.md +31 -18
- package/lib/Deferred.d.ts +2 -2
- package/lib/Events.d.ts +1 -1
- package/lib/Globe.d.ts +8 -5
- package/lib/Object3d.d.ts +17 -14
- package/lib/Popup.d.ts +2 -2
- package/lib/assets/LabelWorker.worker-DYd7xn3M.js.map +1 -0
- package/lib/assets/PlainSegmentWorker.worker-JsKldq-e.js.map +1 -0
- package/lib/assets/TerrainWorker.worker-CqUJvMOv.js.map +1 -0
- package/lib/bv/index.d.ts +2 -2
- package/lib/camera/Camera.d.ts +280 -27
- package/lib/camera/Frustum.d.ts +100 -15
- package/lib/camera/PlanetCamera.d.ts +93 -8
- package/lib/camera/index.d.ts +2 -2
- package/lib/control/CameraFrameComposer.d.ts +2 -2
- package/lib/control/CameraFrameHandler.d.ts +1 -1
- package/lib/control/CompassButton.d.ts +2 -2
- package/lib/control/EarthCoordinates.d.ts +5 -2
- package/lib/control/FramebufferPreview.d.ts +3 -3
- package/lib/control/GeoImageDragControl.d.ts +1 -1
- package/lib/control/LayerAnimation.d.ts +2 -2
- package/lib/control/LayerSwitcher.d.ts +3 -0
- package/lib/control/Lighting.d.ts +4 -2
- package/lib/control/Navigation.d.ts +15 -11
- package/lib/control/OrthoSwitcher.d.ts +18 -0
- package/lib/control/SimpleTouchNavigation.d.ts +44 -0
- package/lib/control/Sun.d.ts +4 -2
- package/lib/control/TouchNavigation.d.ts +4 -8
- package/lib/control/atmosphere/Atmosphere.d.ts +2 -0
- package/lib/control/atmosphere/AtmosphereConfig.d.ts +2 -6
- package/lib/control/cameraDepthHandler/CameraDepthHandler.d.ts +17 -3
- package/lib/control/cameraDepthHandler/camera_depth.d.ts +2 -2
- package/lib/control/drawing/LineStringDrawingScene.d.ts +1 -0
- package/lib/control/drawing/PolygonDrawingScene.d.ts +14 -14
- package/lib/control/elevationProfile/ElevationProfile.d.ts +1 -1
- package/lib/control/elevationProfile/ElevationProfileLegend.d.ts +1 -1
- package/lib/control/elevationProfile/ElevationProfileScene.d.ts +9 -12
- package/lib/control/elevationProfile/ElevationProfileView.d.ts +16 -5
- package/lib/control/entityEditor/EntityEditor.d.ts +19 -0
- package/lib/control/{geoObjectEditor/GeoObjectEditorDialog.d.ts → entityEditor/EntityEditorDialog.d.ts} +9 -8
- package/lib/control/{geoObjectEditor/GeoObjectEditorScene.d.ts → entityEditor/EntityEditorScene.d.ts} +12 -12
- package/lib/control/{geoObjectEditor → entityEditor}/colors.d.ts +2 -2
- package/lib/control/entityTree/EntityTree.d.ts +46 -0
- package/lib/control/entityTree/EntityTreeView.d.ts +24 -0
- package/lib/control/heightRuler/HeightRulerScene.d.ts +3 -2
- package/lib/control/index.d.ts +5 -3
- package/lib/control/ruler/RulerScene.d.ts +8 -8
- package/lib/control/selection/SelectionScene.d.ts +6 -6
- package/lib/control/timeline/TimelineControl.d.ts +2 -2
- package/lib/control/timeline/TimelineModel.d.ts +1 -1
- package/lib/control/timeline/TimelineView.d.ts +52 -13
- package/lib/control/visibleExtent/segment.d.ts +7 -0
- package/lib/ellipsoid/index.d.ts +4 -4
- package/lib/entity/Entity.d.ts +114 -100
- package/lib/entity/EntityCollection.d.ts +95 -70
- package/lib/entity/{BaseBillboard.d.ts → billboard/BaseBillboard.d.ts} +16 -17
- package/lib/entity/{BaseBillboardHandler.d.ts → billboard/BaseBillboardHandler.d.ts} +24 -9
- package/lib/entity/{Billboard.d.ts → billboard/Billboard.d.ts} +11 -7
- package/lib/entity/{BillboardHandler.d.ts → billboard/BillboardHandler.d.ts} +1 -1
- package/lib/entity/{GeoObject.d.ts → geoObject/GeoObject.d.ts} +7 -6
- package/lib/entity/{GeoObjectHandler.d.ts → geoObject/GeoObjectHandler.d.ts} +29 -11
- package/lib/entity/{InstanceData.d.ts → geoObject/InstanceData.d.ts} +18 -13
- package/lib/entity/{Geometry.d.ts → geometry/Geometry.d.ts} +10 -10
- package/lib/entity/{GeometryHandler.d.ts → geometry/GeometryHandler.d.ts} +7 -7
- package/lib/entity/index.d.ts +8 -8
- package/lib/entity/{Label.d.ts → label/Label.d.ts} +12 -13
- package/lib/entity/{LabelHandler.d.ts → label/LabelHandler.d.ts} +31 -7
- package/lib/entity/{LabelWorker.d.ts → label/LabelWorker.d.ts} +3 -3
- package/lib/entity/{PointCloud.d.ts → pointCloud/PointCloud.d.ts} +18 -12
- package/lib/entity/{PointCloudHandler.d.ts → pointCloud/PointCloudHandler.d.ts} +4 -4
- package/lib/entity/polyline/Polyline.d.ts +242 -0
- package/lib/entity/polyline/PolylineBatchRenderer.d.ts +443 -0
- package/lib/entity/{PolylineHandler.d.ts → polyline/PolylineHandler.d.ts} +19 -7
- package/lib/entity/{Ray.d.ts → ray/Ray.d.ts} +27 -9
- package/lib/entity/{RayHandler.d.ts → ray/RayHandler.d.ts} +18 -8
- package/lib/entity/{Strip.d.ts → strip/Strip.d.ts} +21 -17
- package/lib/entity/{StripHandler.d.ts → strip/StripHandler.d.ts} +11 -6
- package/lib/index.d.ts +47 -42
- package/lib/layer/BaseGeoImage.d.ts +20 -17
- package/lib/layer/CanvasTiles.d.ts +14 -12
- package/lib/layer/GeoImage.d.ts +1 -1
- package/lib/layer/GeoTexture2d.d.ts +2 -2
- package/lib/layer/KML.d.ts +19 -18
- package/lib/layer/Layer.d.ts +72 -53
- package/lib/layer/Vector.d.ts +47 -30
- package/lib/layer/WMS.d.ts +1 -1
- package/lib/layer/XYZ.d.ts +11 -12
- package/lib/layer/index.d.ts +12 -12
- package/lib/math/Line2.d.ts +1 -1
- package/lib/math/Line3.d.ts +1 -1
- package/lib/math/Mat3.d.ts +3 -13
- package/lib/math/Mat4.d.ts +16 -10
- package/lib/math/Plane.d.ts +1 -1
- package/lib/math/Quat.d.ts +14 -12
- package/lib/math/Ray.d.ts +4 -3
- package/lib/math/Vec2.d.ts +25 -17
- package/lib/math/Vec3.d.ts +33 -31
- package/lib/math/Vec4.d.ts +1 -1
- package/lib/math/coder.d.ts +1 -1
- package/lib/math/index.d.ts +13 -14
- package/lib/mercator.d.ts +4 -4
- package/lib/og.css +1 -1
- package/lib/og.es.js +1 -1
- package/lib/og.es.js.map +1 -1
- package/lib/quadTree/EntityCollectionNode.d.ts +10 -10
- package/lib/quadTree/EntityCollectionsTreeStrategy.d.ts +5 -5
- package/lib/quadTree/QuadTreeStrategy.d.ts +3 -4
- package/lib/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +4 -4
- package/lib/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +4 -4
- package/lib/renderer/AtmosphereDeferredShading.d.ts +12 -0
- package/lib/renderer/IDeferredShadingPass.d.ts +8 -0
- package/lib/renderer/ITransparencyPass.d.ts +8 -0
- package/lib/renderer/PhongDeferredShading.d.ts +16 -0
- package/lib/renderer/Renderer.d.ts +166 -99
- package/lib/renderer/RendererEvents.d.ts +15 -5
- package/lib/renderer/WOITPass.d.ts +14 -0
- package/lib/res/fonts/Ephesis-Regular.json +1 -0
- package/lib/res/fonts/Ephesis-Regular.png +0 -0
- package/lib/res/fonts/Karla-Bold.json +1 -0
- package/lib/res/fonts/Karla-Bold.png +0 -0
- package/lib/res/fonts/Karla-Italic.json +1 -0
- package/lib/res/fonts/Karla-Italic.png +0 -0
- package/lib/res/fonts/Karla-Light.json +1 -0
- package/lib/res/fonts/Karla-Light.png +0 -0
- package/lib/res/fonts/Karla-Medium.json +1 -0
- package/lib/res/fonts/Karla-Medium.png +0 -0
- package/lib/res/fonts/Roboto-Regular.json +1 -37147
- package/lib/res/fonts/Roboto-Regular.png +0 -0
- package/lib/res/fonts/arial.json +1 -4321
- package/lib/res/fonts/arial.png +0 -0
- package/lib/res/night-4326.png +0 -0
- package/lib/res/night.png +0 -0
- package/lib/scene/AltitudeNearPlaneStrategy.d.ts +17 -0
- package/lib/scene/Axes.d.ts +4 -3
- package/lib/scene/Planet.d.ts +244 -69
- package/lib/scene/{RenderNode.d.ts → Scene.d.ts} +49 -46
- package/lib/scene/SkyBox.d.ts +5 -3
- package/lib/scene/index.d.ts +2 -2
- package/lib/segment/Segment.d.ts +29 -15
- package/lib/segment/SegmentLonLat.d.ts +0 -1
- package/lib/shadeModeConstants.d.ts +7 -0
- package/lib/shaders/applyDeferredDepth.d.ts +2 -0
- package/lib/shaders/atmos/atmos.d.ts +3 -3
- package/lib/shaders/billboard/billboard.d.ts +4 -3
- package/lib/shaders/deferredShading/deferredShading.d.ts +2 -0
- package/lib/shaders/deferredShading/deferredShadingAtmos.d.ts +3 -0
- package/lib/shaders/depth.d.ts +2 -2
- package/lib/shaders/geo_object/geo_object.d.ts +8 -4
- package/lib/shaders/label/label.d.ts +4 -4
- package/lib/shaders/pointCloud.d.ts +2 -2
- package/lib/shaders/polyline/polyline.d.ts +7 -3
- package/lib/shaders/ray/ray.d.ts +3 -2
- package/lib/shaders/screenFrame.d.ts +2 -2
- package/lib/shaders/segment/segment.d.ts +7 -0
- package/lib/shaders/skybox.d.ts +2 -2
- package/lib/shaders/strip/strip.d.ts +3 -0
- package/lib/shaders/tone_mapping/toneMapping.d.ts +2 -2
- package/lib/shaders/weightedOITResolve.d.ts +2 -0
- package/lib/terrain/BilTerrain.d.ts +1 -1
- package/lib/terrain/EmptyTerrain.d.ts +5 -6
- package/lib/terrain/GlobusTerrain.d.ts +18 -23
- package/lib/terrain/RgbTerrain.d.ts +8 -8
- package/lib/terrain/index.d.ts +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/ui/Button.d.ts +7 -5
- package/lib/ui/ButtonGroup.d.ts +1 -1
- package/lib/ui/Checkbox.d.ts +2 -2
- package/lib/ui/Color.d.ts +2 -2
- package/lib/ui/Dialog.d.ts +30 -3
- package/lib/ui/Input.d.ts +7 -2
- package/lib/ui/Slider.d.ts +5 -2
- package/lib/ui/ToggleButton.d.ts +2 -2
- package/lib/ui/View.d.ts +1 -1
- package/lib/ui/icons.d.ts +1 -1
- package/lib/ui/index.d.ts +9 -9
- package/lib/utils/FontAtlas.d.ts +57 -8
- package/lib/utils/GeoImageCreator.d.ts +2 -2
- package/lib/utils/ImagesCacheManager.d.ts +3 -3
- package/lib/utils/Loader.d.ts +2 -2
- package/lib/utils/PlainSegmentWorker.d.ts +2 -2
- package/lib/utils/TerrainWorker.d.ts +2 -2
- package/lib/utils/TextureAtlas.d.ts +7 -2
- package/lib/utils/TextureResourceManager.d.ts +162 -0
- package/lib/utils/VectorTileCreator.d.ts +1 -1
- package/lib/utils/colorSpace.d.ts +9 -0
- package/lib/utils/gltf/gltfParser.d.ts +9 -2
- package/lib/utils/gltf/types.d.ts +20 -2
- package/lib/utils/shared.d.ts +11 -5
- package/lib/utils/textureResourceMeta.d.ts +9 -0
- package/lib/webgl/BaseFramebuffer.d.ts +7 -0
- package/lib/webgl/Framebuffer.d.ts +9 -6
- package/lib/webgl/Handler.d.ts +81 -99
- package/lib/webgl/ShaderProgram.d.ts +190 -0
- package/lib/webgl/index.d.ts +2 -2
- package/lib/webgl/variableHandlers.d.ts +2 -1
- package/package.json +77 -76
- package/lib/assets/LabelWorker.worker-BT1uJgYn.js.map +0 -1
- package/lib/assets/PlainSegmentWorker.worker-CT1cj8jj.js.map +0 -1
- package/lib/assets/TerrainWorker.worker-DmikdfB2.js.map +0 -1
- package/lib/control/OldMouseNavigation.d.ts +0 -65
- package/lib/control/ZoomControl.d.ts +0 -28
- package/lib/control/geoObjectEditor/GeoObjectEditor.d.ts +0 -13
- package/lib/control/visibleExtent/drawnode.d.ts +0 -7
- package/lib/entity/Polyline.d.ts +0 -417
- package/lib/light/LightSource.d.ts +0 -36
- package/lib/res/fonts/Roboto-Regular.ttf.cfg +0 -1340
- package/lib/res/fonts/Roboto-Regular.ttf.png +0 -0
- package/lib/res/fonts/arial.ttf.cfg +0 -1570
- package/lib/res/fonts/arial.ttf.png +0 -0
- package/lib/scene/BaseNode.d.ts +0 -61
- package/lib/shaders/drawnode/drawnode.d.ts +0 -8
- package/lib/webgl/Program.d.ts +0 -161
- package/lib/webgl/ProgramController.d.ts +0 -87
- /package/lib/control/{geoObjectEditor → entityEditor}/ArrowEntity.d.ts +0 -0
- /package/lib/control/{geoObjectEditor → entityEditor}/AxisTrackEntity.d.ts +0 -0
- /package/lib/control/{geoObjectEditor → entityEditor}/MoveAxisEntity.d.ts +0 -0
- /package/lib/control/{geoObjectEditor → entityEditor}/MovePlaneEntity.d.ts +0 -0
- /package/lib/control/{geoObjectEditor → entityEditor}/RotateEntity.d.ts +0 -0
- /package/lib/entity/{LabelWorker.worker.d.ts → label/LabelWorker.worker.d.ts} +0 -0
package/lib/webgl/Handler.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { EventsHandler } from "../Events";
|
|
|
4
4
|
import type { TypedArray } from "../utils/shared";
|
|
5
5
|
import { Vec2 } from "../math/Vec2";
|
|
6
6
|
import type { NumberArray2 } from "../math/Vec2";
|
|
7
|
-
import {
|
|
8
|
-
import { Program } from "./Program";
|
|
7
|
+
import { ShaderProgram } from "./ShaderProgram";
|
|
9
8
|
import { Stack } from "../Stack";
|
|
10
9
|
export type WebGLContextExt = {
|
|
11
10
|
type: string;
|
|
@@ -100,17 +99,17 @@ declare class Handler {
|
|
|
100
99
|
*/
|
|
101
100
|
gl: WebGLContextExt | null;
|
|
102
101
|
/**
|
|
103
|
-
* Shader program
|
|
102
|
+
* Shader program list.
|
|
104
103
|
* @public
|
|
105
|
-
* @type {Record<string,
|
|
104
|
+
* @type {Record<string, ShaderProgram>}
|
|
106
105
|
*/
|
|
107
|
-
programs: Record<string,
|
|
106
|
+
programs: Record<string, ShaderProgram>;
|
|
108
107
|
/**
|
|
109
|
-
* Current active shader program
|
|
108
|
+
* Current active shader program.
|
|
110
109
|
* @public
|
|
111
|
-
* @type {
|
|
110
|
+
* @type {ShaderProgram}
|
|
112
111
|
*/
|
|
113
|
-
activeProgram:
|
|
112
|
+
activeProgram: ShaderProgram | null;
|
|
114
113
|
/**
|
|
115
114
|
* Handler parameters.
|
|
116
115
|
* @private
|
|
@@ -157,24 +156,23 @@ declare class Handler {
|
|
|
157
156
|
createTexture: Record<string, CreateTextureFunc>;
|
|
158
157
|
createTextureDefault: CreateTextureFunc;
|
|
159
158
|
ONCANVASRESIZE: Function | null;
|
|
160
|
-
createTexture_n: CreateTextureFunc;
|
|
161
|
-
createTexture_l: CreateTextureFunc;
|
|
162
|
-
createTexture_mm: CreateTextureFunc;
|
|
163
|
-
createTexture_a: CreateTextureFunc;
|
|
164
159
|
intersectionObserver?: IntersectionObserver;
|
|
165
160
|
resizeObserver?: ResizeObserver;
|
|
166
161
|
protected _requestAnimationFrameId: number;
|
|
162
|
+
protected _clipControlZeroToOne: boolean;
|
|
163
|
+
clipControl: ((origin: number, depth: number) => void) | undefined;
|
|
164
|
+
protected _getMipmapLevels(width: number, height: number): number;
|
|
167
165
|
constructor(canvasTarget: string | HTMLCanvasElement | undefined, params?: IHandlerParameters);
|
|
168
166
|
set frameDelay(delay: number);
|
|
169
167
|
isInitialized(): boolean;
|
|
170
168
|
protected _createCanvas(): void;
|
|
171
169
|
/**
|
|
172
170
|
* The return value is null if the extension is not supported, or an extension object otherwise.
|
|
173
|
-
* @param {
|
|
171
|
+
* @param {WebGL2RenderingContext | null} gl - WebGl context pointer.
|
|
174
172
|
* @param {string} name - Extension name.
|
|
175
173
|
* @returns {any} -
|
|
176
174
|
*/
|
|
177
|
-
static getExtension(gl:
|
|
175
|
+
static getExtension(gl: WebGL2RenderingContext | null, name: string): any | undefined;
|
|
178
176
|
/**
|
|
179
177
|
* Returns a drawing context on the canvas, or null if the context identifier is not supported.
|
|
180
178
|
* @param {HTMLCanvasElement} canvas - HTML canvas object.
|
|
@@ -189,24 +187,24 @@ declare class Handler {
|
|
|
189
187
|
*/
|
|
190
188
|
setFrameCallback(callback: Function): void;
|
|
191
189
|
/**
|
|
192
|
-
* Creates empty texture.
|
|
190
|
+
* Creates an empty immutable 2D texture (WebGL2).
|
|
193
191
|
* @public
|
|
194
|
-
* @param {number} [width=1] -
|
|
195
|
-
* @param {number} [height=1] -
|
|
196
|
-
* @param {string} [filter="NEAREST"] -
|
|
197
|
-
* @param {string} [internalFormat="
|
|
198
|
-
* @param {string} [
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
201
|
-
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
192
|
+
* @param {number} [width=1] - Texture width in pixels.
|
|
193
|
+
* @param {number} [height=1] - Texture height in pixels.
|
|
194
|
+
* @param {string} [filter="NEAREST"] - GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER value.
|
|
195
|
+
* @param {string} [internalFormat="RGBA8"] - Sized internal format (e.g. "RGBA8", "RGBA16F", "R16F").
|
|
196
|
+
* @param {string} [param="CLAMP_TO_EDGE"] - GL_TEXTURE_WRAP_S/T value.
|
|
197
|
+
* @param {number} [levels=1] - Number of mipmap levels (immutable storage).
|
|
198
|
+
* @returns {WebGLTexture | null} - Created WebGL texture object.
|
|
202
199
|
*/
|
|
203
|
-
createEmptyTexture2DExt(width?: number, height?: number, filter?: string, internalFormat?: string,
|
|
200
|
+
createEmptyTexture2DExt(width?: number, height?: number, filter?: string, internalFormat?: string, param?: string, levels?: number): WebGLTexture | null;
|
|
204
201
|
/**
|
|
205
202
|
* Creates Empty NEAREST filtered texture.
|
|
206
203
|
* @public
|
|
207
204
|
* @param {number} width - Empty texture width.
|
|
208
205
|
* @param {number} height - Empty texture height.
|
|
209
|
-
* @param {number} [internalFormat]
|
|
206
|
+
* @param {number} [internalFormat] - Internal texture format, `gl.RGBA` by default.
|
|
207
|
+
* @param {number} [texParami] - Wrap mode for S/T axes, `gl.CLAMP_TO_EDGE` by default.
|
|
210
208
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
211
209
|
*/
|
|
212
210
|
createEmptyTexture_n(width: number, height: number, internalFormat?: number | null, texParami?: number | null): WebGLTexture | null;
|
|
@@ -223,53 +221,13 @@ declare class Handler {
|
|
|
223
221
|
/**
|
|
224
222
|
* Creates NEAREST filter texture.
|
|
225
223
|
* @public
|
|
226
|
-
* @param {HTMLCanvasElement | Image} image - Image or Canvas object.
|
|
227
|
-
* @param {number} [internalFormat]
|
|
228
|
-
* @param {number} [texParami]
|
|
229
|
-
* @param {WebGLTexture | null} [texture=null]
|
|
230
|
-
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
231
|
-
*/
|
|
232
|
-
createTexture_n_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
|
|
233
|
-
/**
|
|
234
|
-
* Creates LINEAR filter texture.
|
|
235
|
-
* @public
|
|
236
|
-
* @param {ImageSource} image - Image or Canvas object.
|
|
237
|
-
* @param {number} [internalFormat]
|
|
238
|
-
* @param {number} [texParami]
|
|
239
|
-
* @param {WebGLTexture | null} [texture]
|
|
240
|
-
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
241
|
-
*/
|
|
242
|
-
createTexture_l_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
|
|
243
|
-
/**
|
|
244
|
-
* Creates MIPMAP filter texture.
|
|
245
|
-
* @public
|
|
246
|
-
* @param {ImageSource} image - Image or Canvas object.
|
|
247
|
-
* @param {number} [internalFormat]
|
|
248
|
-
* @param {number} [texParami]
|
|
249
|
-
* @param {WebGLTexture | null} [texture]
|
|
250
|
-
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
251
|
-
*/
|
|
252
|
-
createTexture_mm_webgl1(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
|
|
253
|
-
/**
|
|
254
|
-
* Creates ANISOTROPY filter texture.
|
|
255
|
-
* @public
|
|
256
224
|
* @param {ImageSource} image - Image or Canvas object.
|
|
257
225
|
* @param {number} [internalFormat]
|
|
258
226
|
* @param {number} [texParami]
|
|
259
227
|
* @param {WebGLTexture | null} [texture]
|
|
260
228
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
261
229
|
*/
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Creates NEAREST filter texture.
|
|
265
|
-
* @public
|
|
266
|
-
* @param {ImageSource} image - Image or Canvas object.
|
|
267
|
-
* @param {number} [internalFormat]
|
|
268
|
-
* @param {number} [texParami]
|
|
269
|
-
* @param {WebGLTexture | null} [texture]
|
|
270
|
-
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
271
|
-
*/
|
|
272
|
-
createTexture_n_webgl2(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTexture | null;
|
|
230
|
+
createTexture_n(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTextureExt | null;
|
|
273
231
|
/**
|
|
274
232
|
* Creates LINEAR filter texture.
|
|
275
233
|
* @public
|
|
@@ -279,7 +237,7 @@ declare class Handler {
|
|
|
279
237
|
* @param {WebGLTexture | null} [texture]
|
|
280
238
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
281
239
|
*/
|
|
282
|
-
|
|
240
|
+
createTexture_l(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTextureExt | null;
|
|
283
241
|
/**
|
|
284
242
|
* Creates MIPMAP filter texture.
|
|
285
243
|
* @public
|
|
@@ -289,7 +247,7 @@ declare class Handler {
|
|
|
289
247
|
* @param {WebGLTexture | null} [texture]
|
|
290
248
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
291
249
|
*/
|
|
292
|
-
|
|
250
|
+
createTexture_mm(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTextureExt | null;
|
|
293
251
|
/**
|
|
294
252
|
* Creates ANISOTROPY filter texture.
|
|
295
253
|
* @public
|
|
@@ -299,7 +257,7 @@ declare class Handler {
|
|
|
299
257
|
* @param {WebGLTexture | null} [texture]
|
|
300
258
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
301
259
|
*/
|
|
302
|
-
|
|
260
|
+
createTexture_a(image: ImageSource, internalFormat?: number | null, texParami?: number | null, texture?: WebGLTexture | null): WebGLTextureExt | null;
|
|
303
261
|
/**
|
|
304
262
|
* Creates cube texture.
|
|
305
263
|
* @public
|
|
@@ -310,17 +268,19 @@ declare class Handler {
|
|
|
310
268
|
* @param {string} params.ny - Negative Y or bottom image url.
|
|
311
269
|
* @param {string} params.pz - Positive Z or face image url.
|
|
312
270
|
* @param {string} params.nz - Negative Z or back image url.
|
|
271
|
+
* @param {number} [colorSpace=gl.SRGB8_ALPHA8] - Cube texture internal format (for example gl.SRGB8_ALPHA8 or gl.RGBA8).
|
|
272
|
+
* @param {number} [textureFilter=gl.LINEAR] - Cube texture filter (for example gl.LINEAR or gl.NEAREST).
|
|
313
273
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
314
274
|
*/
|
|
315
|
-
loadCubeMapTexture(params: Texture3DParams):
|
|
275
|
+
loadCubeMapTexture(params: Texture3DParams, colorSpace?: number | null, textureFilter?: number | null): WebGLTextureExt | null;
|
|
316
276
|
/**
|
|
317
277
|
* Adds shader program to the handler.
|
|
318
278
|
* @public
|
|
319
|
-
* @param {
|
|
279
|
+
* @param {ShaderProgram} program - Shader program.
|
|
320
280
|
* @param {boolean} [activate] - If false program will not compile.
|
|
321
|
-
* @return {
|
|
281
|
+
* @return {ShaderProgram} -
|
|
322
282
|
*/
|
|
323
|
-
addProgram(program:
|
|
283
|
+
addProgram(program: ShaderProgram, activate?: boolean): ShaderProgram;
|
|
324
284
|
/**
|
|
325
285
|
* Removes shader program from handler.
|
|
326
286
|
* @public
|
|
@@ -330,15 +290,15 @@ declare class Handler {
|
|
|
330
290
|
/**
|
|
331
291
|
* Adds shader programs to the handler.
|
|
332
292
|
* @public
|
|
333
|
-
* @param {Array.<
|
|
293
|
+
* @param {Array.<ShaderProgram>} programsArr - Shader program array.
|
|
334
294
|
*/
|
|
335
|
-
addPrograms(programsArr:
|
|
295
|
+
addPrograms(programsArr: ShaderProgram[]): void;
|
|
336
296
|
/**
|
|
337
297
|
* Used in addProgram
|
|
338
298
|
* @protected
|
|
339
|
-
* @param {
|
|
299
|
+
* @param {ShaderProgram} program - ShaderProgram
|
|
340
300
|
*/
|
|
341
|
-
protected
|
|
301
|
+
protected _initProgram(program: ShaderProgram): void;
|
|
342
302
|
/**
|
|
343
303
|
* Used in init function.
|
|
344
304
|
* @private
|
|
@@ -353,7 +313,7 @@ declare class Handler {
|
|
|
353
313
|
*/
|
|
354
314
|
initializeExtension(extensionStr: string, showLog?: boolean): any;
|
|
355
315
|
/**
|
|
356
|
-
* Main function that
|
|
316
|
+
* Main function that initializes handler.
|
|
357
317
|
* @public
|
|
358
318
|
*/
|
|
359
319
|
initialize(): void;
|
|
@@ -363,41 +323,54 @@ declare class Handler {
|
|
|
363
323
|
* @protected
|
|
364
324
|
*/
|
|
365
325
|
protected _setDefaults(): void;
|
|
326
|
+
/**
|
|
327
|
+
* Returns true when clip-control depth range is currently ZERO_TO_ONE.
|
|
328
|
+
* @public
|
|
329
|
+
* @returns {boolean} -
|
|
330
|
+
*/
|
|
331
|
+
get isClipControlZeroToOne(): boolean;
|
|
332
|
+
/**
|
|
333
|
+
* Switches clip-control depth range between ZERO_TO_ONE and NEGATIVE_ONE_TO_ONE.
|
|
334
|
+
* If EXT_clip_control is unavailable, the internal ZERO_TO_ONE flag is reset to false.
|
|
335
|
+
* @public
|
|
336
|
+
* @param {boolean} useZeroToOne - True sets ZERO_TO_ONE, false sets NEGATIVE_ONE_TO_ONE.
|
|
337
|
+
*/
|
|
338
|
+
setClipControlZeroToOne(useZeroToOne: boolean): void;
|
|
366
339
|
getCanvasSize(): NumberArray2;
|
|
367
340
|
/**
|
|
368
|
-
* Creates
|
|
341
|
+
* Creates ARRAY_BUFFER storage for frequently updated data.
|
|
369
342
|
* @public
|
|
370
|
-
* @param {number} itemSize -
|
|
371
|
-
* @param {number} numItems -
|
|
372
|
-
* @param {number} [usage=
|
|
373
|
-
* @param {number} [bytes=4] -
|
|
343
|
+
* @param {number} itemSize - Number of scalar components per item.
|
|
344
|
+
* @param {number} numItems - Number of items.
|
|
345
|
+
* @param {number} [usage=STREAM_DRAW] - GL usage hint (STATIC_DRAW, DYNAMIC_DRAW or STREAM_DRAW).
|
|
346
|
+
* @param {number} [bytes=4] - Bytes per scalar component.
|
|
374
347
|
* @return {WebGLBufferExt} -
|
|
375
348
|
*/
|
|
376
349
|
createStreamArrayBuffer(itemSize: number, numItems: number, usage?: number, bytes?: number): WebGLBufferExt;
|
|
377
350
|
/**
|
|
378
|
-
*
|
|
351
|
+
* Uploads data to an existing ARRAY_BUFFER via bufferSubData.
|
|
379
352
|
* @public
|
|
380
|
-
* @param {WebGLBufferExt} buffer -
|
|
381
|
-
* @param {TypedArray} array -
|
|
382
|
-
* @param {number} [offset=0] -
|
|
353
|
+
* @param {WebGLBufferExt} buffer - Target ARRAY_BUFFER.
|
|
354
|
+
* @param {TypedArray} array - Source data to upload.
|
|
355
|
+
* @param {number} [offset=0] - Byte offset in the target buffer.
|
|
383
356
|
* @return {WebGLBufferExt} -
|
|
384
357
|
*/
|
|
385
358
|
setStreamArrayBuffer(buffer: WebGLBufferExt, array: TypedArray, offset?: number): WebGLBufferExt;
|
|
386
359
|
/**
|
|
387
|
-
* Creates
|
|
360
|
+
* Creates and initializes ARRAY_BUFFER from a typed array.
|
|
388
361
|
* @public
|
|
389
|
-
* @param {TypedArray} array -
|
|
390
|
-
* @param {number} itemSize -
|
|
391
|
-
* @param {number} numItems -
|
|
392
|
-
* @param {number} [usage=STATIC_DRAW] -
|
|
362
|
+
* @param {TypedArray} array - Source data.
|
|
363
|
+
* @param {number} itemSize - Number of scalar components per item.
|
|
364
|
+
* @param {number} [numItems] - Number of items (computed from array length when omitted).
|
|
365
|
+
* @param {number} [usage=STATIC_DRAW] - GL usage hint (STATIC_DRAW, DYNAMIC_DRAW or STREAM_DRAW).
|
|
393
366
|
* @return {WebGLBufferExt} -
|
|
394
367
|
*/
|
|
395
368
|
createArrayBuffer(array: TypedArray, itemSize: number, numItems?: number, usage?: number): WebGLBufferExt;
|
|
396
369
|
/**
|
|
397
|
-
* Creates
|
|
370
|
+
* Creates ARRAY_BUFFER storage with a specific byte length and no initial data.
|
|
398
371
|
* @public
|
|
399
|
-
* @param {number} size -
|
|
400
|
-
* @param {number} [usage=STATIC_DRAW] -
|
|
372
|
+
* @param {number} size - Buffer size in bytes.
|
|
373
|
+
* @param {number} [usage=STATIC_DRAW] - GL usage hint (STATIC_DRAW, DYNAMIC_DRAW or STREAM_DRAW).
|
|
401
374
|
* @return {WebGLBufferExt} -
|
|
402
375
|
*/
|
|
403
376
|
createArrayBufferLength(size: number, usage?: number): WebGLBufferExt;
|
|
@@ -472,14 +445,23 @@ declare class Handler {
|
|
|
472
445
|
*/
|
|
473
446
|
protected _animationFrameCallback(): void;
|
|
474
447
|
/**
|
|
475
|
-
* Creates default texture
|
|
448
|
+
* Creates a default 2x2 texture and passes it to callback.
|
|
449
|
+
* If `params.color` is set, a solid color texture is created.
|
|
450
|
+
* If `params.url` is set, the image is loaded asynchronously.
|
|
451
|
+
* Otherwise a fallback gray texture is created.
|
|
452
|
+
* @public
|
|
453
|
+
* @param {IDefaultTextureParams | null} params - Texture source parameters.
|
|
454
|
+
* @param {function(WebGLTextureExt): void} success - Callback with created texture.
|
|
455
|
+
*/
|
|
456
|
+
createDefaultTexture(params: IDefaultTextureParams | null, success: (texture: WebGLTextureExt) => void, internalFormat?: number | null): void;
|
|
457
|
+
/**
|
|
458
|
+
* Deletes texture if it is not marked as default.
|
|
476
459
|
* @public
|
|
477
|
-
* @param {
|
|
478
|
-
* @param {function(WebGLTextureExt): void} [success] - Creation callback.
|
|
460
|
+
* @param {WebGLTextureExt | null | undefined} texture - Texture to delete.
|
|
479
461
|
*/
|
|
480
|
-
createDefaultTexture(params: IDefaultTextureParams | null, success: (texture: WebGLTextureExt) => void): void;
|
|
481
462
|
deleteTexture(texture: WebGLTextureExt | null | undefined): void;
|
|
482
463
|
/**
|
|
464
|
+
* Releases handler resources, WebGL objects, observers and canvas.
|
|
483
465
|
* @public
|
|
484
466
|
*/
|
|
485
467
|
destroy(): void;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { ProgramVariable } from "./variableHandlers";
|
|
2
|
+
import type { Handler, WebGLBufferExt } from "./Handler";
|
|
3
|
+
type WebGLProgramExt = WebGLProgram & {
|
|
4
|
+
[id: string]: WebGLUniformLocation | number | null;
|
|
5
|
+
};
|
|
6
|
+
type ProgramBinding = WebGLUniformLocation | number;
|
|
7
|
+
type ProgramMaterial = {
|
|
8
|
+
attributes: Record<string, any>;
|
|
9
|
+
uniforms: Record<string, any>;
|
|
10
|
+
vertexShader: string;
|
|
11
|
+
fragmentShader: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Represents more comfortable using WebGL shader program.
|
|
15
|
+
* @class
|
|
16
|
+
* @param {string} name - ShaderProgram name.
|
|
17
|
+
* @param {ProgramMaterial} material - Object stores uniforms, attributes and program codes:
|
|
18
|
+
* @param {Record<string, any>} material.uniforms - Uniforms definition section.
|
|
19
|
+
* @param {Record<string, any>} material.attributes - Attributes definition section.
|
|
20
|
+
* @param {string} material.vertexShader - Vertex glsl code.
|
|
21
|
+
* @param {string} material.fragmentShader - Fragment glsl code.
|
|
22
|
+
*/
|
|
23
|
+
declare class ShaderProgram {
|
|
24
|
+
[id: string]: any;
|
|
25
|
+
/**
|
|
26
|
+
* Shader program name.
|
|
27
|
+
* @public
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
protected _handler: Handler | null;
|
|
32
|
+
_activated: boolean;
|
|
33
|
+
attributes: {
|
|
34
|
+
[id: string]: number;
|
|
35
|
+
};
|
|
36
|
+
uniforms: {
|
|
37
|
+
[id: string]: WebGLUniformLocation;
|
|
38
|
+
};
|
|
39
|
+
protected _attributes: Record<string, ProgramVariable>;
|
|
40
|
+
protected _uniforms: Record<string, ProgramVariable>;
|
|
41
|
+
vertexShader: string;
|
|
42
|
+
fragmentShader: string;
|
|
43
|
+
drawElementsInstanced: Function | null;
|
|
44
|
+
vertexAttribDivisor: Function | null;
|
|
45
|
+
/**
|
|
46
|
+
* Webgl context.
|
|
47
|
+
* @public
|
|
48
|
+
* @type {WebGL2RenderingContext | null}
|
|
49
|
+
*/
|
|
50
|
+
gl: WebGL2RenderingContext | null;
|
|
51
|
+
/**
|
|
52
|
+
* All program variables.
|
|
53
|
+
* @protected
|
|
54
|
+
* @type {Record<string, ProgramVariable>}
|
|
55
|
+
*/
|
|
56
|
+
protected _variables: Record<string, ProgramVariable>;
|
|
57
|
+
/**
|
|
58
|
+
* ShaderProgram pointer.
|
|
59
|
+
* @protected
|
|
60
|
+
* @type {WebGLProgramExt | null}
|
|
61
|
+
*/
|
|
62
|
+
protected _p: WebGLProgramExt | null;
|
|
63
|
+
/**
|
|
64
|
+
* Texture counter.
|
|
65
|
+
* @public
|
|
66
|
+
* @type {number}
|
|
67
|
+
*/
|
|
68
|
+
_textureID: number;
|
|
69
|
+
/**
|
|
70
|
+
* ShaderProgram attributes array.
|
|
71
|
+
* @protected
|
|
72
|
+
* @type {number[]}
|
|
73
|
+
*/
|
|
74
|
+
protected _attribArrays: number[];
|
|
75
|
+
/**
|
|
76
|
+
* ShaderProgram attributes divisors.
|
|
77
|
+
* @protected
|
|
78
|
+
* @type {number[]}
|
|
79
|
+
*/
|
|
80
|
+
protected _attribDivisor: number[];
|
|
81
|
+
protected _bindings: Record<string, ProgramBinding>;
|
|
82
|
+
protected _dynamicBindingNames: Set<string>;
|
|
83
|
+
constructor(name: string, material: ProgramMaterial);
|
|
84
|
+
/**
|
|
85
|
+
* Attaches this shader program to a handler.
|
|
86
|
+
* @param {Handler} handler - WebGL handler.
|
|
87
|
+
* @returns {ShaderProgram}
|
|
88
|
+
*/
|
|
89
|
+
attach(handler: Handler): this;
|
|
90
|
+
/**
|
|
91
|
+
* Initializes this shader program using handler WebGL context.
|
|
92
|
+
* @returns {ShaderProgram}
|
|
93
|
+
*/
|
|
94
|
+
initialize(): this;
|
|
95
|
+
protected _bindVariable(name: string, location: ProgramBinding): void;
|
|
96
|
+
/**
|
|
97
|
+
* Binds attribute buffer and sets its pointer.
|
|
98
|
+
* @param {ShaderProgram} program - Shader program instance.
|
|
99
|
+
* @param {ProgramVariable} variable - Attribute variable descriptor.
|
|
100
|
+
*/
|
|
101
|
+
static bindBuffer(program: ShaderProgram, variable: ProgramVariable): void;
|
|
102
|
+
/**
|
|
103
|
+
* Makes this shader program current in WebGL context.
|
|
104
|
+
*/
|
|
105
|
+
use(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Activates this shader program and disables previously active one.
|
|
108
|
+
* @returns {ShaderProgram}
|
|
109
|
+
*/
|
|
110
|
+
activate(): this;
|
|
111
|
+
/**
|
|
112
|
+
* Deactivates this shader program.
|
|
113
|
+
* @returns {ShaderProgram}
|
|
114
|
+
*/
|
|
115
|
+
deactivate(): this;
|
|
116
|
+
/**
|
|
117
|
+
* Returns `true` if this shader program is active.
|
|
118
|
+
* @returns {boolean}
|
|
119
|
+
*/
|
|
120
|
+
isActive(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Removes this shader program from its handler and releases WebGL program.
|
|
123
|
+
*/
|
|
124
|
+
remove(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Sets provided shader variables and applies them.
|
|
127
|
+
* Automatically activates this shader program.
|
|
128
|
+
* @param {Record<string, any>} material - Variable values by variable name.
|
|
129
|
+
* @returns {ShaderProgram}
|
|
130
|
+
*/
|
|
131
|
+
set(material: Record<string, any>): this;
|
|
132
|
+
/**
|
|
133
|
+
* Applies currently stored shader variable values.
|
|
134
|
+
*/
|
|
135
|
+
apply(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Draws indexed geometry from provided index buffer.
|
|
138
|
+
* @param {number} mode - WebGL draw mode.
|
|
139
|
+
* @param {WebGLBufferExt} buffer - Index buffer.
|
|
140
|
+
* @returns {ShaderProgram}
|
|
141
|
+
*/
|
|
142
|
+
drawIndexBuffer(mode: number, buffer: WebGLBufferExt): this;
|
|
143
|
+
/**
|
|
144
|
+
* Draws non-indexed geometry.
|
|
145
|
+
* @param {number} mode - WebGL draw mode.
|
|
146
|
+
* @param {number} numItems - Vertex count to draw.
|
|
147
|
+
* @returns {ShaderProgram}
|
|
148
|
+
*/
|
|
149
|
+
drawArrays(mode: number, numItems: number): this;
|
|
150
|
+
/**
|
|
151
|
+
* Check and log for a shader compile errors and warnings. Returns True - if no errors otherwise returns False.
|
|
152
|
+
* @private
|
|
153
|
+
* @param {WebGLShader} shader - WebGl shader program.
|
|
154
|
+
* @param {string} src - Shader program source.
|
|
155
|
+
* @returns {boolean} -
|
|
156
|
+
*/
|
|
157
|
+
protected _getShaderCompileStatus(shader: WebGLShader, src: string): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Returns compiled vertex shader program pointer.
|
|
160
|
+
* @private
|
|
161
|
+
* @param {string} src - Vertex shader source code.
|
|
162
|
+
* @returns {Object} -
|
|
163
|
+
*/
|
|
164
|
+
protected _createVertexShader(src: string): WebGLShader | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Returns compiled fragment shader program pointer.
|
|
167
|
+
* @private
|
|
168
|
+
* @param {string} src - Vertex shader source code.
|
|
169
|
+
* @returns {Object} -
|
|
170
|
+
*/
|
|
171
|
+
protected _createFragmentShader(src: string): WebGLShader | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Disables all attribute arrays used by this shader program.
|
|
174
|
+
*/
|
|
175
|
+
disableAttribArrays(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Enables all attribute arrays used by this shader program.
|
|
178
|
+
*/
|
|
179
|
+
enableAttribArrays(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Deletes underlying WebGL program.
|
|
182
|
+
*/
|
|
183
|
+
delete(): void;
|
|
184
|
+
/**
|
|
185
|
+
* Compiles shaders, links WebGL program and resolves variable locations.
|
|
186
|
+
* @param {WebGL2RenderingContext} gl - WebGL context.
|
|
187
|
+
*/
|
|
188
|
+
createProgram(gl: WebGL2RenderingContext): void;
|
|
189
|
+
}
|
|
190
|
+
export { ShaderProgram };
|
package/lib/webgl/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { Framebuffer } from "./Framebuffer";
|
|
|
2
2
|
import { Handler } from "./Handler";
|
|
3
3
|
import type { WebGLContextExt, WebGLBufferExt, WebGLTextureExt, ImageSource } from "./Handler";
|
|
4
4
|
import { Multisample } from "./Multisample";
|
|
5
|
-
import {
|
|
5
|
+
import { ShaderProgram } from "./ShaderProgram";
|
|
6
6
|
import { types } from "./types";
|
|
7
|
-
export { Framebuffer, Handler, Multisample, types,
|
|
7
|
+
export { Framebuffer, Handler, Multisample, types, ShaderProgram, WebGLContextExt, WebGLBufferExt, WebGLTextureExt, ImageSource };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @module og/webgl/variableHandlers
|
|
3
3
|
*/
|
|
4
4
|
import type { WebGLBufferExt } from "./Handler";
|
|
5
|
+
import type { WebGLTextureExt } from "./Handler";
|
|
5
6
|
export type VariableHandler = {
|
|
6
7
|
u: {
|
|
7
8
|
[id: number]: Function;
|
|
@@ -14,7 +15,7 @@ export type ProgramVariable = {
|
|
|
14
15
|
type: string | number;
|
|
15
16
|
func: Function;
|
|
16
17
|
_pName: WebGLUniformLocation | number;
|
|
17
|
-
value: number | Float32Array | Int32Array | WebGLBufferExt;
|
|
18
|
+
value: number | Float32Array | Int32Array | WebGLBufferExt | WebGLTextureExt | WebGLTextureExt[];
|
|
18
19
|
itemType: string | number;
|
|
19
20
|
normalized: boolean;
|
|
20
21
|
divisor: number;
|