laymur 0.19.2 → 0.20.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/core/elements/UIProgress/UIProgress.d.ts +2 -2
- package/dist/particles/index.d.ts +1 -1
- package/dist/particles/index.js +1 -1
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +6 -5
- package/dist/particles/renderingModules/UIRenderingTexture.js +55 -11
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Texture } from "three";
|
|
2
1
|
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
3
2
|
import { UIColor } from "../../miscellaneous/color/UIColor";
|
|
4
3
|
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
5
4
|
import type { UIProgressMaskFunction } from "../../miscellaneous/mask-function/UIProgressMaskFunction";
|
|
6
5
|
import { UITextureView } from "../../miscellaneous/texture/UITextureView";
|
|
6
|
+
import type { UITextureConfig } from "../../miscellaneous/texture/UITextureView.Internal";
|
|
7
7
|
import { UIElement } from "../UIElement/UIElement";
|
|
8
8
|
import type { UIProgressOptions } from "./UIProgress.Internal";
|
|
9
9
|
/** Progress bar with customizable fill direction */
|
|
@@ -26,7 +26,7 @@ export declare class UIProgress extends UIElement {
|
|
|
26
26
|
* @param texture - Texture to display
|
|
27
27
|
* @param options - Configuration options
|
|
28
28
|
*/
|
|
29
|
-
constructor(layer: UILayer, texture:
|
|
29
|
+
constructor(layer: UILayer, texture: UITextureConfig, options?: Partial<UIProgressOptions>);
|
|
30
30
|
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
31
31
|
get color(): UIColor;
|
|
32
32
|
/** Function controlling fill direction and shape */
|
|
@@ -8,7 +8,7 @@ export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoi
|
|
|
8
8
|
export { UIEmitter } from "./elements/UIEmitter";
|
|
9
9
|
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife";
|
|
10
10
|
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity";
|
|
11
|
-
export {
|
|
11
|
+
export { UIRenderingTexture } from "./renderingModules/UIRenderingTexture";
|
|
12
12
|
export { UISpawnOffset } from "./spawnModules/UISpawnOffset";
|
|
13
13
|
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime";
|
|
14
14
|
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation";
|
package/dist/particles/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { UIBehaviorVelocityNoise } from './behaviorModules/UIBehaviorVelocityNoi
|
|
|
8
8
|
export { UIEmitter } from './elements/UIEmitter.js';
|
|
9
9
|
export { UIRenderingColorOverLife } from './renderingModules/UIRenderingColorOverLife.js';
|
|
10
10
|
export { UIRenderingColorOverVelocity } from './renderingModules/UIRenderingColorOverVelocity.js';
|
|
11
|
-
export {
|
|
11
|
+
export { UIRenderingTexture } from './renderingModules/UIRenderingTexture.js';
|
|
12
12
|
export { UISpawnOffset } from './spawnModules/UISpawnOffset.js';
|
|
13
13
|
export { UISpawnRandomLifetime } from './spawnModules/UISpawnRandomLifetime.js';
|
|
14
14
|
export { UISpawnRandomRotation } from './spawnModules/UISpawnRandomRotation.js';
|
|
@@ -3,12 +3,13 @@ import { UIRenderingModule } from "./UIRenderingModule";
|
|
|
3
3
|
/**
|
|
4
4
|
* Renders particles with a texture.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Accepts a single texture config or an array of configs from the same atlas.
|
|
7
|
+
* When an array is provided, each particle picks one texture randomly using PARTICLE_RANDOM_A.
|
|
8
|
+
* All configs in the array must share the same underlying Three.js Texture object.
|
|
7
9
|
*/
|
|
8
|
-
export declare class
|
|
9
|
-
private readonly texture;
|
|
10
|
+
export declare class UIRenderingTexture extends UIRenderingModule {
|
|
10
11
|
/**
|
|
11
|
-
* @param config -
|
|
12
|
+
* @param config - Single texture config or array of configs (same atlas required for arrays)
|
|
12
13
|
*/
|
|
13
|
-
constructor(config: UITextureConfig);
|
|
14
|
+
constructor(config: UITextureConfig | UITextureConfig[]);
|
|
14
15
|
}
|
|
@@ -2,25 +2,69 @@ import { UITextureView } from '../../core/miscellaneous/texture/UITextureView.js
|
|
|
2
2
|
import source from '../shaders/UIRenderingTexture.glsl.js';
|
|
3
3
|
import { UIRenderingModule } from './UIRenderingModule.js';
|
|
4
4
|
|
|
5
|
+
function buildMultiTextureShader(count) {
|
|
6
|
+
const branches = [];
|
|
7
|
+
for (let i = 0; i < count; i++) {
|
|
8
|
+
if (i === 0) {
|
|
9
|
+
branches.push(` if (idx == 0) t = p_textureTransform0;`);
|
|
10
|
+
}
|
|
11
|
+
else if (i === count - 1) {
|
|
12
|
+
branches.push(` else t = p_textureTransform${i};`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
branches.push(` else if (idx == ${i}) t = p_textureTransform${i};`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return [
|
|
19
|
+
"vec4 draw() {",
|
|
20
|
+
` int idx = int(PARTICLE_RANDOM_A * ${count}.0);`,
|
|
21
|
+
" mat3 t;",
|
|
22
|
+
...branches,
|
|
23
|
+
" vec2 transformedUV = (t * vec3(p_uv, 1.0)).xy;",
|
|
24
|
+
" return srgbTexture2D(p_texture, transformedUV);",
|
|
25
|
+
"}",
|
|
26
|
+
].join("\n");
|
|
27
|
+
}
|
|
5
28
|
/**
|
|
6
29
|
* Renders particles with a texture.
|
|
7
30
|
*
|
|
8
|
-
*
|
|
31
|
+
* Accepts a single texture config or an array of configs from the same atlas.
|
|
32
|
+
* When an array is provided, each particle picks one texture randomly using PARTICLE_RANDOM_A.
|
|
33
|
+
* All configs in the array must share the same underlying Three.js Texture object.
|
|
9
34
|
*/
|
|
10
|
-
class
|
|
35
|
+
class UIRenderingTexture extends UIRenderingModule {
|
|
11
36
|
/**
|
|
12
|
-
* @param config -
|
|
37
|
+
* @param config - Single texture config or array of configs (same atlas required for arrays)
|
|
13
38
|
*/
|
|
14
39
|
constructor(config) {
|
|
15
40
|
super();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
if (!Array.isArray(config) || config.length === 1) {
|
|
42
|
+
const view = new UITextureView(Array.isArray(config) ? config[0] : config);
|
|
43
|
+
this.source = source;
|
|
44
|
+
this.requiredUniforms = {
|
|
45
|
+
texture: view.texture,
|
|
46
|
+
textureTransform: view.calculateUVTransform(),
|
|
47
|
+
};
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (config.length === 0) {
|
|
51
|
+
throw new Error("UIRenderingTexture.constructor: config array cannot be empty");
|
|
52
|
+
}
|
|
53
|
+
const views = config.map((c) => new UITextureView(c));
|
|
54
|
+
const baseTexture = views[0].texture;
|
|
55
|
+
for (let i = 1; i < views.length; i++) {
|
|
56
|
+
if (views[i].texture !== baseTexture) {
|
|
57
|
+
throw new Error(`UIRenderingTexture.constructor: all configs must share the same Three.js Texture (index ${i} differs)`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const uniforms = { texture: baseTexture };
|
|
61
|
+
for (let i = 0; i < views.length; i++) {
|
|
62
|
+
uniforms[`textureTransform${i}`] = views[i].calculateUVTransform();
|
|
63
|
+
}
|
|
64
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
65
|
+
this.requiredUniforms = uniforms;
|
|
66
|
+
this.source = buildMultiTextureShader(views.length);
|
|
23
67
|
}
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
export {
|
|
70
|
+
export { UIRenderingTexture };
|