@lightningjs/renderer 2.2.0 → 2.3.0
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/dist/src/common/IAnimationController.d.ts +1 -1
- package/dist/src/core/CoreNode.js +6 -5
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/Stage.d.ts +1 -0
- package/dist/src/core/Stage.js +2 -1
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/animations/CoreAnimationController.js +3 -2
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
- package/dist/src/core/renderers/CoreRenderer.d.ts +1 -0
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +0 -9
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -1
- package/dist/src/core/utils.d.ts +1 -1
- package/dist/src/main-api/Inspector.js +9 -0
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/src/main-api/Renderer.d.ts +10 -0
- package/dist/src/main-api/Renderer.js +2 -0
- package/dist/src/main-api/Renderer.js.map +1 -1
- package/dist/src/main-api/RendererMain.js +1 -1
- package/dist/src/main-api/RendererMain.js.map +1 -1
- package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js.map +1 -1
- package/dist/src/render-drivers/main/MainCoreDriver.js.map +1 -1
- package/dist/src/render-drivers/main/MainOnlyNode.js.map +1 -1
- package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +8 -4
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +53 -24
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +6 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -1
- package/dist/src/render-drivers/threadx/worker/renderer.js.map +1 -1
- package/dist/src/render-drivers/utils.js +6 -1
- package/dist/src/render-drivers/utils.js.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.js +2 -2
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/common/IAnimationController.ts +5 -1
- package/src/core/CoreNode.ts +7 -7
- package/src/core/Stage.ts +3 -0
- package/src/core/animations/CoreAnimationController.ts +3 -2
- package/src/core/renderers/CoreRenderer.ts +1 -0
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +5 -1
- package/src/core/renderers/webgl/WebGlCoreShader.ts +0 -11
- package/src/main-api/Inspector.ts +12 -0
- package/src/main-api/Renderer.ts +13 -0
- package/src/utils.ts +2 -1
- package/dist/src/core/Matrix2DContext.d.ts +0 -15
- package/dist/src/core/Matrix2DContext.js +0 -45
- package/dist/src/core/Matrix2DContext.js.map +0 -1
- package/dist/src/core/lib/SpatialHash.d.ts +0 -38
- package/dist/src/core/lib/SpatialHash.js +0 -93
- package/dist/src/core/lib/SpatialHash.js.map +0 -1
- package/dist/src/core/lib/glm/common.d.ts +0 -162
- package/dist/src/core/lib/glm/common.js +0 -81
- package/dist/src/core/lib/glm/common.js.map +0 -1
- package/dist/src/core/lib/glm/index.d.ts +0 -11
- package/dist/src/core/lib/glm/index.js +0 -30
- package/dist/src/core/lib/glm/index.js.map +0 -1
- package/dist/src/core/lib/glm/mat2.d.ts +0 -219
- package/dist/src/core/lib/glm/mat2.js +0 -396
- package/dist/src/core/lib/glm/mat2.js.map +0 -1
- package/dist/src/core/lib/glm/mat2d.d.ts +0 -237
- package/dist/src/core/lib/glm/mat2d.js +0 -442
- package/dist/src/core/lib/glm/mat2d.js.map +0 -1
- package/dist/src/core/lib/glm/mat3.d.ts +0 -283
- package/dist/src/core/lib/glm/mat3.js +0 -680
- package/dist/src/core/lib/glm/mat3.js.map +0 -1
- package/dist/src/core/lib/glm/mat4.d.ts +0 -550
- package/dist/src/core/lib/glm/mat4.js +0 -1802
- package/dist/src/core/lib/glm/mat4.js.map +0 -1
- package/dist/src/core/lib/glm/quat.d.ts +0 -363
- package/dist/src/core/lib/glm/quat.js +0 -693
- package/dist/src/core/lib/glm/quat.js.map +0 -1
- package/dist/src/core/lib/glm/quat2.d.ts +0 -356
- package/dist/src/core/lib/glm/quat2.js +0 -754
- package/dist/src/core/lib/glm/quat2.js.map +0 -1
- package/dist/src/core/lib/glm/vec2.d.ts +0 -365
- package/dist/src/core/lib/glm/vec2.js +0 -569
- package/dist/src/core/lib/glm/vec2.js.map +0 -1
- package/dist/src/core/lib/glm/vec3.d.ts +0 -406
- package/dist/src/core/lib/glm/vec3.js +0 -720
- package/dist/src/core/lib/glm/vec3.js.map +0 -1
- package/dist/src/core/lib/glm/vec4.d.ts +0 -330
- package/dist/src/core/lib/glm/vec4.js +0 -608
- package/dist/src/core/lib/glm/vec4.js.map +0 -1
- package/dist/src/core/lib/renderToTexture.d.ts +0 -1
- package/dist/src/core/lib/renderToTexture.js +0 -2
- package/dist/src/core/lib/renderToTexture.js.map +0 -1
- package/dist/src/core/lib/textcompression-utils.d.ts +0 -1
- package/dist/src/core/lib/textcompression-utils.js +0 -2
- package/dist/src/core/lib/textcompression-utils.js.map +0 -1
- package/dist/src/core/lib/txcompression-utils.d.ts +0 -1
- package/dist/src/core/lib/txcompression-utils.js +0 -2
- package/dist/src/core/lib/txcompression-utils.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlRenderTexture.d.ts +0 -29
- package/dist/src/core/renderers/webgl/WebGlRenderTexture.js +0 -86
- package/dist/src/core/renderers/webgl/WebGlRenderTexture.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/DistortShader.d.ts +0 -44
- package/dist/src/core/renderers/webgl/shaders/DistortShader.js +0 -172
- package/dist/src/core/renderers/webgl/shaders/DistortShader.js.map +0 -1
- package/dist/src/core/renderers/webgl/shaders/RefractionShader.d.ts +0 -78
- package/dist/src/core/renderers/webgl/shaders/RefractionShader.js +0 -172
- package/dist/src/core/renderers/webgl/shaders/RefractionShader.js.map +0 -1
- package/dist/src/core/scene/Scene.d.ts +0 -59
- package/dist/src/core/scene/Scene.js +0 -106
- package/dist/src/core/scene/Scene.js.map +0 -1
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +0 -20
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +0 -55
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +0 -1
- package/dist/src/main-api/IRenderDriver.d.ts +0 -20
- package/dist/src/main-api/IRenderDriver.js +0 -20
- package/dist/src/main-api/IRenderDriver.js.map +0 -1
- package/dist/src/main-api/IShaderController.d.ts +0 -14
- package/dist/src/main-api/IShaderController.js +0 -30
- package/dist/src/main-api/IShaderController.js.map +0 -1
- package/dist/src/render-drivers/main/MainOnlyShaderController.d.ts +0 -6
- package/dist/src/render-drivers/main/MainOnlyShaderController.js +0 -15
- package/dist/src/render-drivers/main/MainOnlyShaderController.js.map +0 -1
- package/dist/src/render-drivers/main/MainRenderDriver.d.ts +0 -17
- package/dist/src/render-drivers/main/MainRenderDriver.js +0 -88
- package/dist/src/render-drivers/main/MainRenderDriver.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.d.ts +0 -6
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.js +0 -15
- package/dist/src/render-drivers/threadx/ThreadXMainShaderController.js.map +0 -1
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.d.ts +0 -21
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +0 -198
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js.map +0 -1
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
|
|
2
|
-
import { EventEmitter } from '../../../common/EventEmitter.js';
|
|
3
|
-
/**
|
|
4
|
-
* A wrapper around a WebGLTexture that handles loading the texture data
|
|
5
|
-
* from a Texture source and uploading it to the GPU as well as freeing
|
|
6
|
-
* the uploaded texture.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* When accessing the ctxTexture property, the texture will be loaded if
|
|
10
|
-
* it hasn't been already. ctxTexture will always return a valid WebGLTexture
|
|
11
|
-
* and trigger the loading/uploading of the texture's data if it hasn't been
|
|
12
|
-
* loaded yet.
|
|
13
|
-
*/
|
|
14
|
-
export declare class WebGlRenderTexture extends EventEmitter {
|
|
15
|
-
protected glw: WebGlContextWrapper;
|
|
16
|
-
protected _nativeCtxTexture: WebGLTexture | null;
|
|
17
|
-
private _w;
|
|
18
|
-
private _h;
|
|
19
|
-
private _framebuffer;
|
|
20
|
-
private _texture;
|
|
21
|
-
private _glw;
|
|
22
|
-
constructor(glw: WebGlContextWrapper, width: number, height: number);
|
|
23
|
-
bind(): void;
|
|
24
|
-
unbind(): void;
|
|
25
|
-
get w(): number;
|
|
26
|
-
get h(): number;
|
|
27
|
-
get framebuffer(): WebGLFramebuffer | null;
|
|
28
|
-
get texture(): WebGLTexture | null;
|
|
29
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { EventEmitter } from '../../../common/EventEmitter.js';
|
|
20
|
-
/**
|
|
21
|
-
* A wrapper around a WebGLTexture that handles loading the texture data
|
|
22
|
-
* from a Texture source and uploading it to the GPU as well as freeing
|
|
23
|
-
* the uploaded texture.
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* When accessing the ctxTexture property, the texture will be loaded if
|
|
27
|
-
* it hasn't been already. ctxTexture will always return a valid WebGLTexture
|
|
28
|
-
* and trigger the loading/uploading of the texture's data if it hasn't been
|
|
29
|
-
* loaded yet.
|
|
30
|
-
*/
|
|
31
|
-
export class WebGlRenderTexture extends EventEmitter {
|
|
32
|
-
glw;
|
|
33
|
-
_nativeCtxTexture = null;
|
|
34
|
-
_w = 0;
|
|
35
|
-
_h = 0;
|
|
36
|
-
_framebuffer = null;
|
|
37
|
-
_texture = null;
|
|
38
|
-
_glw;
|
|
39
|
-
constructor(glw, width, height) {
|
|
40
|
-
super();
|
|
41
|
-
this.glw = glw;
|
|
42
|
-
this._glw = glw;
|
|
43
|
-
this._w = width;
|
|
44
|
-
this._h = height;
|
|
45
|
-
// Create Framebuffer object
|
|
46
|
-
this._framebuffer = glw.createFramebuffer();
|
|
47
|
-
if (!this._framebuffer) {
|
|
48
|
-
throw new Error('Unable to create framebuffer');
|
|
49
|
-
}
|
|
50
|
-
// Bind the framebuffer
|
|
51
|
-
glw.bindFramebuffer(this._framebuffer);
|
|
52
|
-
// Create a render texture
|
|
53
|
-
const texture = glw.createTexture();
|
|
54
|
-
if (!texture) {
|
|
55
|
-
throw new Error('Unable to create texture');
|
|
56
|
-
}
|
|
57
|
-
glw.bindTexture(texture);
|
|
58
|
-
glw.texImage2D(0, glw.RGBA, width, height, 0, glw.RGBA, glw.UNSIGNED_BYTE, null);
|
|
59
|
-
glw.texParameteri(glw.TEXTURE_MAG_FILTER, glw.LINEAR);
|
|
60
|
-
glw.texParameteri(glw.TEXTURE_MIN_FILTER, glw.LINEAR);
|
|
61
|
-
glw.texParameteri(glw.TEXTURE_WRAP_S, glw.CLAMP_TO_EDGE);
|
|
62
|
-
glw.texParameteri(glw.TEXTURE_WRAP_T, glw.CLAMP_TO_EDGE);
|
|
63
|
-
// Attach the texture to the framebuffer
|
|
64
|
-
glw.framebufferTexture2D(glw.COLOR_ATTACHMENT0, texture, 0);
|
|
65
|
-
this._texture = texture;
|
|
66
|
-
}
|
|
67
|
-
bind() {
|
|
68
|
-
this._glw.bindFramebuffer(this._framebuffer);
|
|
69
|
-
}
|
|
70
|
-
unbind() {
|
|
71
|
-
this._glw.bindFramebuffer(null);
|
|
72
|
-
}
|
|
73
|
-
get w() {
|
|
74
|
-
return this._w;
|
|
75
|
-
}
|
|
76
|
-
get h() {
|
|
77
|
-
return this._h;
|
|
78
|
-
}
|
|
79
|
-
get framebuffer() {
|
|
80
|
-
return this._framebuffer;
|
|
81
|
-
}
|
|
82
|
-
get texture() {
|
|
83
|
-
return this._texture;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=WebGlRenderTexture.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebGlRenderTexture.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlRenderTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAStC;IARF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,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QACzD,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QAEzD,wCAAwC;QACxC,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAE5D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Point } from '../../../../common/CommonTypes.js';
|
|
2
|
-
import type { WebGlCoreRenderer } from '../WebGlCoreRenderer.js';
|
|
3
|
-
import { WebGlCoreShader, type DimensionsShaderProp } from '../WebGlCoreShader.js';
|
|
4
|
-
import type { WebGlCoreCtxTexture } from '../WebGlCoreCtxTexture.js';
|
|
5
|
-
import type { ShaderProgramSources } from '../internal/ShaderUtils.js';
|
|
6
|
-
/**
|
|
7
|
-
* Properties of the {@link DistortShaderProps} shader
|
|
8
|
-
*/
|
|
9
|
-
export interface DistortShaderProps extends DimensionsShaderProp {
|
|
10
|
-
/**
|
|
11
|
-
* Use normalized values rather than pixle values
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
normalized?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* x & y coordinates of the top left point
|
|
17
|
-
* @default null
|
|
18
|
-
*/
|
|
19
|
-
topLeft?: Point | null;
|
|
20
|
-
/**
|
|
21
|
-
* x & y coordinates of the top right point
|
|
22
|
-
* @default null
|
|
23
|
-
*/
|
|
24
|
-
topRight?: Point | null;
|
|
25
|
-
/**
|
|
26
|
-
* x & y coordinates of the bottom right point
|
|
27
|
-
* @default null
|
|
28
|
-
*/
|
|
29
|
-
bottomRight?: Point | null;
|
|
30
|
-
/**
|
|
31
|
-
* x & y coordinates of the bottom left point
|
|
32
|
-
* @default null
|
|
33
|
-
*/
|
|
34
|
-
bottomLeft?: Point | null;
|
|
35
|
-
}
|
|
36
|
-
export declare class DistortShader extends WebGlCoreShader {
|
|
37
|
-
constructor(renderer: WebGlCoreRenderer);
|
|
38
|
-
static z$__type__Props: DistortShaderProps;
|
|
39
|
-
static resolveDefaults(props: DistortShaderProps): Required<DistortShaderProps>;
|
|
40
|
-
bindTextures(textures: WebGlCoreCtxTexture[]): void;
|
|
41
|
-
protected bindProps(props: Required<DistortShaderProps>): void;
|
|
42
|
-
canBatchShaderProps(propsA: Required<DistortShaderProps>, propsB: Required<DistortShaderProps>): boolean;
|
|
43
|
-
static shaderSources: ShaderProgramSources;
|
|
44
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { WebGlCoreShader, } from '../WebGlCoreShader.js';
|
|
20
|
-
export class DistortShader extends WebGlCoreShader {
|
|
21
|
-
constructor(renderer) {
|
|
22
|
-
super({
|
|
23
|
-
renderer,
|
|
24
|
-
attributes: ['a_position', 'a_textureCoordinate', 'a_color'],
|
|
25
|
-
uniforms: [
|
|
26
|
-
{ name: 'u_resolution', uniform: 'uniform2fv' },
|
|
27
|
-
{ name: 'u_pixelRatio', uniform: 'uniform1f' },
|
|
28
|
-
{ name: 'u_texture', uniform: 'uniform2f' },
|
|
29
|
-
{ name: 'u_dimensions', uniform: 'uniform2fv' },
|
|
30
|
-
{ name: 'u_topLeft', uniform: 'uniform2fv' },
|
|
31
|
-
{ name: 'u_topRight', uniform: 'uniform2fv' },
|
|
32
|
-
{ name: 'u_bottomRight', uniform: 'uniform2fv' },
|
|
33
|
-
{ name: 'u_bottomLeft', uniform: 'uniform2fv' },
|
|
34
|
-
],
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
static z$__type__Props;
|
|
38
|
-
static resolveDefaults(props) {
|
|
39
|
-
return {
|
|
40
|
-
normalized: props.normalized || false,
|
|
41
|
-
topLeft: props.topLeft || null,
|
|
42
|
-
topRight: props.topRight || null,
|
|
43
|
-
bottomRight: props.bottomRight || null,
|
|
44
|
-
bottomLeft: props.bottomLeft || null,
|
|
45
|
-
$dimensions: {
|
|
46
|
-
width: 0,
|
|
47
|
-
height: 0,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
bindTextures(textures) {
|
|
52
|
-
const { glw } = this;
|
|
53
|
-
glw.activeTexture(0);
|
|
54
|
-
glw.bindTexture(textures[0].ctxTexture);
|
|
55
|
-
}
|
|
56
|
-
bindProps(props) {
|
|
57
|
-
const width = props.normalized ? 1 : props.$dimensions.width;
|
|
58
|
-
const height = props.normalized ? 1 : props.$dimensions.height;
|
|
59
|
-
const topLeft = [
|
|
60
|
-
(props.topLeft?.x || 0) / width,
|
|
61
|
-
(props.topLeft?.y || 0) / height,
|
|
62
|
-
];
|
|
63
|
-
const topRight = [
|
|
64
|
-
(props.topRight?.x || width) / width,
|
|
65
|
-
(props.topRight?.y || 0) / height,
|
|
66
|
-
];
|
|
67
|
-
const bottomRight = [
|
|
68
|
-
(props.bottomRight?.x || width) / width,
|
|
69
|
-
(props.bottomRight?.y || height) / height,
|
|
70
|
-
];
|
|
71
|
-
const bottomLeft = [
|
|
72
|
-
(props.bottomLeft?.x || 0) / width,
|
|
73
|
-
(props.bottomLeft?.y || height) / height,
|
|
74
|
-
];
|
|
75
|
-
this.setUniform('u_topLeft', new Float32Array(topLeft));
|
|
76
|
-
this.setUniform('u_topRight', new Float32Array(topRight));
|
|
77
|
-
this.setUniform('u_bottomRight', new Float32Array(bottomRight));
|
|
78
|
-
this.setUniform('u_bottomLeft', new Float32Array(bottomLeft));
|
|
79
|
-
}
|
|
80
|
-
canBatchShaderProps(propsA, propsB) {
|
|
81
|
-
return JSON.stringify(propsA) === JSON.stringify(propsB);
|
|
82
|
-
}
|
|
83
|
-
static shaderSources = {
|
|
84
|
-
vertex: `
|
|
85
|
-
# ifdef GL_FRAGMENT_PRESICISON_HIGH
|
|
86
|
-
precision highp float;
|
|
87
|
-
# else
|
|
88
|
-
precision mediump float;
|
|
89
|
-
# endif
|
|
90
|
-
|
|
91
|
-
attribute vec2 a_position;
|
|
92
|
-
attribute vec2 a_textureCoordinate;
|
|
93
|
-
attribute vec4 a_color;
|
|
94
|
-
|
|
95
|
-
uniform vec2 u_resolution;
|
|
96
|
-
uniform float u_pixelRatio;
|
|
97
|
-
|
|
98
|
-
varying vec4 v_color;
|
|
99
|
-
varying vec2 v_textureCoordinate;
|
|
100
|
-
|
|
101
|
-
void main() {
|
|
102
|
-
vec2 normalized = a_position * u_pixelRatio / u_resolution;
|
|
103
|
-
vec2 zero_two = normalized * 2.0;
|
|
104
|
-
vec2 clip_space = zero_two - 1.0;
|
|
105
|
-
|
|
106
|
-
// pass to fragment
|
|
107
|
-
v_color = a_color;
|
|
108
|
-
v_textureCoordinate = a_textureCoordinate;
|
|
109
|
-
|
|
110
|
-
// flip y
|
|
111
|
-
gl_Position = vec4(clip_space * vec2(1.0, -1.0), 0, 1);
|
|
112
|
-
}
|
|
113
|
-
`,
|
|
114
|
-
fragment: `
|
|
115
|
-
# ifdef GL_FRAGMENT_PRESICISON_HIGH
|
|
116
|
-
precision highp float;
|
|
117
|
-
# else
|
|
118
|
-
precision mediump float;
|
|
119
|
-
# endif
|
|
120
|
-
|
|
121
|
-
uniform sampler2D u_texture;
|
|
122
|
-
uniform vec2 u_topLeft;
|
|
123
|
-
uniform vec2 u_topRight;
|
|
124
|
-
uniform vec2 u_bottomLeft;
|
|
125
|
-
uniform vec2 u_bottomRight;
|
|
126
|
-
|
|
127
|
-
varying vec2 v_textureCoordinate;
|
|
128
|
-
varying vec4 v_color;
|
|
129
|
-
|
|
130
|
-
float xross(in vec2 a, in vec2 b) {
|
|
131
|
-
return a.x * b.y - a.y * b.x;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
vec2 invBilinear(in vec2 p, in vec2 a, in vec2 b, in vec2 c, in vec2 d ){
|
|
135
|
-
vec2 e = b-a;
|
|
136
|
-
vec2 f = d-a;
|
|
137
|
-
vec2 g = a-b+c-d;
|
|
138
|
-
vec2 h = p-a;
|
|
139
|
-
|
|
140
|
-
float k2 = xross(g, f);
|
|
141
|
-
float k1 = xross(e, f) + xross(h, g);
|
|
142
|
-
float k0 = xross(h, e);
|
|
143
|
-
|
|
144
|
-
float w = k1*k1 - 4.0*k0*k2;
|
|
145
|
-
|
|
146
|
-
if( w<0.0 ) return vec2(-1.0);
|
|
147
|
-
|
|
148
|
-
w = sqrt(w);
|
|
149
|
-
|
|
150
|
-
// will fail for k0=0, which is only on the ba edge
|
|
151
|
-
float v = 2.0*k0/(-k1 - w);
|
|
152
|
-
if( v<0.0 || v>1.0 ) v = 2.0*k0/(-k1 + w);
|
|
153
|
-
|
|
154
|
-
float u = (h.x - f.x*v)/(e.x + g.x*v);
|
|
155
|
-
if( u<0.0 || u>1.0 || v<0.0 || v>1.0 ) return vec2(-1.0);
|
|
156
|
-
return vec2( u, v );
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
void main(void){
|
|
160
|
-
vec4 color = vec4(0.0);
|
|
161
|
-
vec2 texUv = invBilinear(v_textureCoordinate, u_topLeft, u_topRight, u_bottomRight, u_bottomLeft);
|
|
162
|
-
|
|
163
|
-
if (texUv.x > -0.5) {
|
|
164
|
-
color = texture2D(u_texture, texUv) * v_color;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
gl_FragColor = color;
|
|
168
|
-
}
|
|
169
|
-
`,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
//# sourceMappingURL=DistortShader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DistortShader.js","sourceRoot":"","sources":["../../../../../../src/core/renderers/webgl/shaders/DistortShader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EACL,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAyC/B,MAAM,OAAO,aAAc,SAAQ,eAAe;IAChD,YAAY,QAA2B;QACrC,KAAK,CAAC;YACJ,QAAQ;YACR,UAAU,EAAE,CAAC,YAAY,EAAE,qBAAqB,EAAE,SAAS,CAAC;YAC5D,QAAQ,EAAE;gBACR,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC/C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC9C,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC3C,EAAE,IAAI,EAAE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AM,CAAU,aAAa,GAAyB;QACpD,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BP;QACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuDT;KACF,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { WebGlCoreRenderer } from '../WebGlCoreRenderer.js';
|
|
2
|
-
import { WebGlCoreShader, type DimensionsShaderProp } from '../WebGlCoreShader.js';
|
|
3
|
-
import type { WebGlCoreCtxTexture } from '../WebGlCoreCtxTexture.js';
|
|
4
|
-
import type { ShaderProgramSources } from '../internal/ShaderUtils.js';
|
|
5
|
-
/**
|
|
6
|
-
* Properties of the {@link DistortShaderProps} shader
|
|
7
|
-
*/
|
|
8
|
-
export interface DistortShaderProps extends DimensionsShaderProp {
|
|
9
|
-
/**
|
|
10
|
-
* Use normalized values rather than pixle values
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
normalized?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Clipping x
|
|
16
|
-
* @default 0
|
|
17
|
-
*/
|
|
18
|
-
clipX?: number;
|
|
19
|
-
/**
|
|
20
|
-
* Clipping x
|
|
21
|
-
* @default 0
|
|
22
|
-
*/
|
|
23
|
-
clipY?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Clipping x
|
|
26
|
-
* @default 0
|
|
27
|
-
*/
|
|
28
|
-
clipW?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Clipping x
|
|
31
|
-
* @default 0
|
|
32
|
-
*/
|
|
33
|
-
clipH?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Refraction aggeresion
|
|
36
|
-
* @default 0
|
|
37
|
-
*/
|
|
38
|
-
aggressionH?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Refraction aggeresion
|
|
41
|
-
* @default 0
|
|
42
|
-
*/
|
|
43
|
-
aggressionV?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Refraction aggeresion
|
|
46
|
-
* @default 0
|
|
47
|
-
*/
|
|
48
|
-
biasH?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Refraction aggeresion
|
|
51
|
-
* @default 0
|
|
52
|
-
*/
|
|
53
|
-
biasV?: number;
|
|
54
|
-
/**
|
|
55
|
-
* Refraction aggeresion
|
|
56
|
-
* @default 0
|
|
57
|
-
*/
|
|
58
|
-
radius?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Refraction aggeresion
|
|
61
|
-
* @default 0
|
|
62
|
-
*/
|
|
63
|
-
thicknessH?: number;
|
|
64
|
-
/**
|
|
65
|
-
* Refraction aggeresion
|
|
66
|
-
* @default 0
|
|
67
|
-
*/
|
|
68
|
-
thicknessV?: number;
|
|
69
|
-
}
|
|
70
|
-
export declare class RefractionShader extends WebGlCoreShader {
|
|
71
|
-
constructor(renderer: WebGlCoreRenderer);
|
|
72
|
-
static z$__type__Props: DistortShaderProps;
|
|
73
|
-
static resolveDefaults(props: DistortShaderProps): Required<DistortShaderProps>;
|
|
74
|
-
bindTextures(textures: WebGlCoreCtxTexture[]): void;
|
|
75
|
-
protected bindProps(props: Required<DistortShaderProps>): void;
|
|
76
|
-
canBatchShaderProps(propsA: Required<DistortShaderProps>, propsB: Required<DistortShaderProps>): boolean;
|
|
77
|
-
static shaderSources: ShaderProgramSources;
|
|
78
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
import { WebGlCoreShader, } from '../WebGlCoreShader.js';
|
|
20
|
-
export class RefractionShader extends WebGlCoreShader {
|
|
21
|
-
constructor(renderer) {
|
|
22
|
-
super({
|
|
23
|
-
renderer,
|
|
24
|
-
attributes: ['a_position', 'a_textureCoordinate', 'a_color'],
|
|
25
|
-
uniforms: [
|
|
26
|
-
{ name: 'u_resolution', uniform: 'uniform2fv' },
|
|
27
|
-
{ name: 'u_pixelRatio', uniform: 'uniform1f' },
|
|
28
|
-
{ name: 'u_texture', uniform: 'uniform2f' },
|
|
29
|
-
{ name: 'u_dimensions', uniform: 'uniform2fv' },
|
|
30
|
-
{ name: 'u_screencorner', uniform: 'uniform2fv' },
|
|
31
|
-
{ name: 'u_halfSize', uniform: 'uniform2fv' },
|
|
32
|
-
{ name: 'u_bias', uniform: 'uniform2fv' },
|
|
33
|
-
{ name: 'u_radius', uniform: 'uniform1f' },
|
|
34
|
-
{ name: 'u_thicknessH', uniform: 'uniform1f' },
|
|
35
|
-
{ name: 'u_aggressionH', uniform: 'uniform1f' },
|
|
36
|
-
{ name: 'u_thicknessV', uniform: 'uniform1f' },
|
|
37
|
-
{ name: 'u_aggressionV', uniform: 'uniform1f' },
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
static z$__type__Props;
|
|
42
|
-
static resolveDefaults(props) {
|
|
43
|
-
return {
|
|
44
|
-
normalized: props.normalized || false,
|
|
45
|
-
clipX: props.clipX || 0,
|
|
46
|
-
clipY: props.clipY || 0,
|
|
47
|
-
clipW: props.clipW || 0,
|
|
48
|
-
clipH: props.clipH || 0,
|
|
49
|
-
aggressionH: props.aggressionH || 3,
|
|
50
|
-
aggressionV: props.aggressionV || 3,
|
|
51
|
-
biasH: props.biasH || 50,
|
|
52
|
-
biasV: props.biasV || 50,
|
|
53
|
-
radius: props.radius || 10,
|
|
54
|
-
thicknessH: props.thicknessH || 64,
|
|
55
|
-
thicknessV: props.thicknessV || 64,
|
|
56
|
-
$dimensions: {
|
|
57
|
-
width: 0,
|
|
58
|
-
height: 0,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
bindTextures(textures) {
|
|
63
|
-
const { glw } = this;
|
|
64
|
-
glw.activeTexture(0);
|
|
65
|
-
glw.bindTexture(textures[0].ctxTexture);
|
|
66
|
-
}
|
|
67
|
-
bindProps(props) {
|
|
68
|
-
const width = props.normalized ? 1 : props.$dimensions.width;
|
|
69
|
-
const height = props.normalized ? 1 : props.$dimensions.height;
|
|
70
|
-
const x = props.clipX;
|
|
71
|
-
const y = props.clipY;
|
|
72
|
-
const w = width - props.clipW;
|
|
73
|
-
const h = height - props.clipH;
|
|
74
|
-
this.setUniform('u_screencorner', new Float32Array([x, y]));
|
|
75
|
-
this.setUniform('u_halfSize', new Float32Array([w / 2, h / 2]));
|
|
76
|
-
this.setUniform('u_bias', new Float32Array([props.biasH / 100, props.biasV / 100]));
|
|
77
|
-
this.setUniform('u_radius', props.radius + 0.5);
|
|
78
|
-
this.setUniform('u_thicknessH', props.thicknessH + 0.5);
|
|
79
|
-
this.setUniform('u_aggressionH', props.aggressionH);
|
|
80
|
-
this.setUniform('u_thicknessV', props.thicknessV + 0.5);
|
|
81
|
-
this.setUniform('u_aggressionV', props.aggressionV);
|
|
82
|
-
}
|
|
83
|
-
canBatchShaderProps(propsA, propsB) {
|
|
84
|
-
return JSON.stringify(propsA) === JSON.stringify(propsB);
|
|
85
|
-
}
|
|
86
|
-
static shaderSources = {
|
|
87
|
-
vertex: `
|
|
88
|
-
# ifdef GL_FRAGMENT_PRESICISON_HIGH
|
|
89
|
-
precision highp float;
|
|
90
|
-
# else
|
|
91
|
-
precision mediump float;
|
|
92
|
-
# endif
|
|
93
|
-
|
|
94
|
-
attribute vec2 a_position;
|
|
95
|
-
attribute vec2 a_textureCoordinate;
|
|
96
|
-
attribute vec4 a_color;
|
|
97
|
-
|
|
98
|
-
uniform vec2 u_resolution;
|
|
99
|
-
uniform float u_pixelRatio;
|
|
100
|
-
uniform vec2 u_screencorner;
|
|
101
|
-
|
|
102
|
-
varying vec4 v_color;
|
|
103
|
-
varying vec2 v_textureCoordinate;
|
|
104
|
-
varying vec2 v_vertexPosition;
|
|
105
|
-
|
|
106
|
-
void main() {
|
|
107
|
-
vec2 normalized = a_position * u_pixelRatio;
|
|
108
|
-
vec2 screenSpace = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
|
|
109
|
-
|
|
110
|
-
v_color = a_color;
|
|
111
|
-
v_textureCoordinate = a_textureCoordinate;
|
|
112
|
-
v_vertexPosition = a_position - u_screencorner;
|
|
113
|
-
|
|
114
|
-
gl_Position = vec4(normalized.x * screenSpace.x - 1.0, normalized.y * -abs(screenSpace.y) + 1.0, 0.0, 1.0);
|
|
115
|
-
gl_Position.y = -sign(screenSpace.y) * gl_Position.y;
|
|
116
|
-
}
|
|
117
|
-
`,
|
|
118
|
-
fragment: `
|
|
119
|
-
#ifdef GL_ES
|
|
120
|
-
precision lowp float;
|
|
121
|
-
#endif
|
|
122
|
-
|
|
123
|
-
uniform sampler2D u_texture;
|
|
124
|
-
uniform float u_aggressionH;
|
|
125
|
-
uniform float u_aggressionV;
|
|
126
|
-
uniform vec2 u_bias;
|
|
127
|
-
uniform float u_radius;
|
|
128
|
-
uniform float u_thicknessH;
|
|
129
|
-
uniform float u_thicknessV;
|
|
130
|
-
uniform vec2 u_screenCorner;
|
|
131
|
-
uniform vec2 u_halfSize;
|
|
132
|
-
|
|
133
|
-
varying vec4 v_color;
|
|
134
|
-
varying vec2 v_textureCoordinate;
|
|
135
|
-
varying vec2 v_vertexPosition;
|
|
136
|
-
|
|
137
|
-
float sdRoundBox(vec2 p, vec2 b, float r)
|
|
138
|
-
{
|
|
139
|
-
vec2 q = abs(p)-b+r;
|
|
140
|
-
return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
void main() {
|
|
144
|
-
vec2 vPos = v_vertexPosition - (u_screenCorner + u_halfSize);
|
|
145
|
-
float sdUnmodified = sdRoundBox(vPos, u_halfSize, u_radius);
|
|
146
|
-
|
|
147
|
-
float fEffectExtentH = u_thicknessH + u_radius;
|
|
148
|
-
float fEffectExtentV = u_thicknessV + u_radius;
|
|
149
|
-
float fHFactor = smoothstep(fEffectExtentH-u_halfSize.x, -u_halfSize.x, vPos.x) + smoothstep(u_halfSize.x-fEffectExtentH, u_halfSize.x, vPos.x);
|
|
150
|
-
float fVFactor = smoothstep(fEffectExtentV-u_halfSize.y, -u_halfSize.y, vPos.y) + smoothstep(u_halfSize.y-fEffectExtentV, u_halfSize.y, vPos.y);
|
|
151
|
-
|
|
152
|
-
float fVaryingThickness = max(u_thicknessV * fVFactor, u_thicknessH * fHFactor);
|
|
153
|
-
float fDistance = smoothstep(-fVaryingThickness, 0.0, sdUnmodified);
|
|
154
|
-
|
|
155
|
-
if (fDistance > 0.0) {
|
|
156
|
-
vec2 vNormal = 1.8 * normalize(vPos);
|
|
157
|
-
vNormal.x = clamp(vNormal.x, -1.0, 1.0) * fHFactor;
|
|
158
|
-
vNormal.y = clamp(vNormal.y, -1.0, 1.0) * fVFactor;
|
|
159
|
-
float fVaryingAggression = max(u_aggressionV * fVFactor, u_aggressionH * fHFactor);
|
|
160
|
-
float distanceWithAggression = pow(fDistance, fVaryingAggression);
|
|
161
|
-
|
|
162
|
-
vec2 vSample = v_textureCoordinate - u_bias * distanceWithAggression * fVaryingThickness * vNormal / u_halfSize;
|
|
163
|
-
vec4 refract = texture2D(u_texture, vSample);
|
|
164
|
-
gl_FragColor = mix(refract, vec4(0.0), smoothstep(0.0, 1.0, sdUnmodified)) * v_color;
|
|
165
|
-
} else {
|
|
166
|
-
gl_FragColor = texture2D(u_texture, v_textureCoordinate) * v_color;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
`,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
//# sourceMappingURL=RefractionShader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RefractionShader.js","sourceRoot":"","sources":["../../../../../../src/core/renderers/webgl/shaders/RefractionShader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAkF/B,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IACnD,YAAY,QAA2B;QACrC,KAAK,CAAC;YACJ,QAAQ;YACR,UAAU,EAAE,CAAC,YAAY,EAAE,qBAAqB,EAAE,SAAS,CAAC;YAC5D,QAAQ,EAAE;gBACR,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC/C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC9C,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC3C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC/C,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE;gBACjD,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC7C,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;gBACzC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC1C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC9C,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC/C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO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AAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAU,aAAa,GAAyB;QACpD,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BP;QACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmDT;KACF,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { CoreNode } from '../CoreNode.js';
|
|
2
|
-
export type NodeTypes = Node;
|
|
3
|
-
export declare class Scene {
|
|
4
|
-
/**
|
|
5
|
-
* Root node of the scene
|
|
6
|
-
*
|
|
7
|
-
* @type {Node}
|
|
8
|
-
* @memberof Scene
|
|
9
|
-
*/
|
|
10
|
-
root: CoreNode;
|
|
11
|
-
constructor(root: CoreNode);
|
|
12
|
-
/**
|
|
13
|
-
* Get all nodes of a specific type
|
|
14
|
-
* @param type
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
getNodeByType(type: string): Node[];
|
|
18
|
-
/**
|
|
19
|
-
* Find a node by id
|
|
20
|
-
* @param id
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
getNodeById(id: string): Node | null;
|
|
24
|
-
/**
|
|
25
|
-
* Create a new node
|
|
26
|
-
* @param parent
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* create a new RectangleNode
|
|
31
|
-
* @param w
|
|
32
|
-
* @param h
|
|
33
|
-
* @param parent
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* Create a new CircleNode
|
|
38
|
-
* @param r
|
|
39
|
-
* @param parent
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* Create a new TextNode
|
|
44
|
-
* @param text
|
|
45
|
-
* @param parent
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* Setup and attaching Node
|
|
50
|
-
* @param node
|
|
51
|
-
* @param parent
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
/**
|
|
55
|
-
* Update the scene
|
|
56
|
-
* @param delta
|
|
57
|
-
*/
|
|
58
|
-
update(delta: number): void;
|
|
59
|
-
}
|