sparcoon 0.0.1
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 +21 -0
- package/dist/behaviorModules/FXBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/behaviorModules/FXBehaviorDirectionalGravity.js +47 -0
- package/dist/behaviorModules/FXBehaviorModule.d.ts +14 -0
- package/dist/behaviorModules/FXBehaviorModule.js +9 -0
- package/dist/behaviorModules/FXBehaviorPointGravity.d.ts +39 -0
- package/dist/behaviorModules/FXBehaviorPointGravity.js +110 -0
- package/dist/behaviorModules/FXBehaviorScaleOverLife.d.ts +22 -0
- package/dist/behaviorModules/FXBehaviorScaleOverLife.js +66 -0
- package/dist/behaviorModules/FXBehaviorTorqueDamping.d.ts +20 -0
- package/dist/behaviorModules/FXBehaviorTorqueDamping.js +48 -0
- package/dist/behaviorModules/FXBehaviorTorqueNoise.d.ts +26 -0
- package/dist/behaviorModules/FXBehaviorTorqueNoise.js +66 -0
- package/dist/behaviorModules/FXBehaviorVelocityDamping.d.ts +20 -0
- package/dist/behaviorModules/FXBehaviorVelocityDamping.js +49 -0
- package/dist/behaviorModules/FXBehaviorVelocityNoise.d.ts +26 -0
- package/dist/behaviorModules/FXBehaviorVelocityNoise.js +73 -0
- package/dist/color/FXColor.Internal.d.ts +7 -0
- package/dist/color/FXColor.Internal.js +42 -0
- package/dist/color/FXColor.d.ts +234 -0
- package/dist/color/FXColor.js +636 -0
- package/dist/elements/FXEmitter.Internal.d.ts +10 -0
- package/dist/elements/FXEmitter.Internal.js +5 -0
- package/dist/elements/FXEmitter.d.ts +29 -0
- package/dist/elements/FXEmitter.js +154 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +13 -0
- package/dist/instancedParticle/FXInstancedParticle.Internal.js +216 -0
- package/dist/instancedParticle/FXInstancedParticle.d.ts +17 -0
- package/dist/instancedParticle/FXInstancedParticle.js +93 -0
- package/dist/instancedParticle/shared.d.ts +27 -0
- package/dist/instancedParticle/shared.js +123 -0
- package/dist/miscellaneous/FXTransparencyMode.d.ts +7 -0
- package/dist/miscellaneous/asserts.d.ts +21 -0
- package/dist/miscellaneous/asserts.js +48 -0
- package/dist/miscellaneous/math.d.ts +8 -0
- package/dist/miscellaneous/math.js +11 -0
- package/dist/miscellaneous/miscellaneous.d.ts +33 -0
- package/dist/miscellaneous/miscellaneous.js +66 -0
- package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +49 -0
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +6 -0
- package/dist/miscellaneous/texture/FXTextureView.d.ts +72 -0
- package/dist/miscellaneous/texture/FXTextureView.js +234 -0
- package/dist/miscellaneous/webglCapabilities.d.ts +1 -0
- package/dist/miscellaneous/webglCapabilities.js +45 -0
- package/dist/renderingModules/FXRenderingColorOverLife.d.ts +14 -0
- package/dist/renderingModules/FXRenderingColorOverLife.js +32 -0
- package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +15 -0
- package/dist/renderingModules/FXRenderingColorOverVelocity.js +37 -0
- package/dist/renderingModules/FXRenderingModule.d.ts +8 -0
- package/dist/renderingModules/FXRenderingModule.js +9 -0
- package/dist/renderingModules/FXRenderingTexture.d.ts +14 -0
- package/dist/renderingModules/FXRenderingTexture.js +26 -0
- package/dist/shaders/FXRenderingColorOverLife.glsl.js +3 -0
- package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/shaders/FXRenderingTexture.glsl.js +3 -0
- package/dist/spawnModules/FXSpawnBox.d.ts +27 -0
- package/dist/spawnModules/FXSpawnBox.js +67 -0
- package/dist/spawnModules/FXSpawnModule.d.ts +9 -0
- package/dist/spawnModules/FXSpawnModule.js +9 -0
- package/dist/spawnModules/FXSpawnOffset.d.ts +21 -0
- package/dist/spawnModules/FXSpawnOffset.js +49 -0
- package/dist/spawnModules/FXSpawnRandomLifetime.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomLifetime.js +47 -0
- package/dist/spawnModules/FXSpawnRandomRotation.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomRotation.js +45 -0
- package/dist/spawnModules/FXSpawnRandomScale.d.ts +26 -0
- package/dist/spawnModules/FXSpawnRandomScale.js +60 -0
- package/dist/spawnModules/FXSpawnRandomTorque.d.ts +20 -0
- package/dist/spawnModules/FXSpawnRandomTorque.js +45 -0
- package/dist/spawnModules/FXSpawnRandomVelocity.d.ts +26 -0
- package/dist/spawnModules/FXSpawnRandomVelocity.js +64 -0
- package/package.json +55 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Texture, Vector2, Vector3, Vector4, Matrix3, Matrix4 } from 'three';
|
|
2
|
+
import { FXColor } from '../color/FXColor.js';
|
|
3
|
+
|
|
4
|
+
const GLSL_TYPE_INFO_FLOAT = Object.freeze({
|
|
5
|
+
glslTypeName: "float",
|
|
6
|
+
bufferSize: 1,
|
|
7
|
+
instantiable: true,
|
|
8
|
+
});
|
|
9
|
+
const GLSL_TYPE_INFO_SAMPLER2D = Object.freeze({
|
|
10
|
+
glslTypeName: "sampler2D",
|
|
11
|
+
bufferSize: -1,
|
|
12
|
+
instantiable: false,
|
|
13
|
+
});
|
|
14
|
+
const GLSL_TYPE_INFO_VEC2 = Object.freeze({
|
|
15
|
+
glslTypeName: "vec2",
|
|
16
|
+
bufferSize: 2,
|
|
17
|
+
instantiable: true,
|
|
18
|
+
});
|
|
19
|
+
const GLSL_TYPE_INFO_VEC3 = Object.freeze({
|
|
20
|
+
glslTypeName: "vec3",
|
|
21
|
+
bufferSize: 3,
|
|
22
|
+
instantiable: true,
|
|
23
|
+
});
|
|
24
|
+
const GLSL_TYPE_INFO_VEC4 = Object.freeze({
|
|
25
|
+
glslTypeName: "vec4",
|
|
26
|
+
bufferSize: 4,
|
|
27
|
+
instantiable: true,
|
|
28
|
+
});
|
|
29
|
+
const GLSL_TYPE_INFO_MAT3 = Object.freeze({
|
|
30
|
+
glslTypeName: "mat3",
|
|
31
|
+
bufferSize: 9,
|
|
32
|
+
instantiable: true,
|
|
33
|
+
});
|
|
34
|
+
const GLSL_TYPE_INFO_MAT4 = Object.freeze({
|
|
35
|
+
glslTypeName: "mat4",
|
|
36
|
+
bufferSize: 16,
|
|
37
|
+
instantiable: true,
|
|
38
|
+
});
|
|
39
|
+
function resolveGLSLTypeInfo(value) {
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
switch (value) {
|
|
42
|
+
case "number":
|
|
43
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
44
|
+
case "Texture":
|
|
45
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
46
|
+
case "UIColor":
|
|
47
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
48
|
+
case "Vector2":
|
|
49
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
50
|
+
case "Vector3":
|
|
51
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
52
|
+
case "Vector4":
|
|
53
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
54
|
+
case "Matrix3":
|
|
55
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
56
|
+
case "Matrix4":
|
|
57
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type name`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === "function") {
|
|
63
|
+
if (value === Number) {
|
|
64
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
65
|
+
}
|
|
66
|
+
if (value === Texture) {
|
|
67
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
68
|
+
}
|
|
69
|
+
if (value === FXColor) {
|
|
70
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
71
|
+
}
|
|
72
|
+
if (value === Vector2) {
|
|
73
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
74
|
+
}
|
|
75
|
+
if (value === Vector3) {
|
|
76
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
77
|
+
}
|
|
78
|
+
if (value === Vector4) {
|
|
79
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
80
|
+
}
|
|
81
|
+
if (value === Matrix3) {
|
|
82
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
83
|
+
}
|
|
84
|
+
if (value === Matrix4) {
|
|
85
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type constructor`);
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === "number") {
|
|
90
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
91
|
+
}
|
|
92
|
+
if (value instanceof Texture) {
|
|
93
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
94
|
+
}
|
|
95
|
+
if (value instanceof FXColor) {
|
|
96
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
97
|
+
}
|
|
98
|
+
if (value instanceof Vector2) {
|
|
99
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
100
|
+
}
|
|
101
|
+
if (value instanceof Vector3) {
|
|
102
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
103
|
+
}
|
|
104
|
+
if (value instanceof Vector4) {
|
|
105
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
106
|
+
}
|
|
107
|
+
if (value instanceof Matrix3) {
|
|
108
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
109
|
+
}
|
|
110
|
+
if (value instanceof Matrix4) {
|
|
111
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);
|
|
114
|
+
}
|
|
115
|
+
function resolvePropertyUniform(name, material) {
|
|
116
|
+
const uniform = material.uniforms[`p_${name}`];
|
|
117
|
+
if (uniform === undefined) {
|
|
118
|
+
throw new Error(`resolvePropertyUniform.name: unknown uniform`);
|
|
119
|
+
}
|
|
120
|
+
return uniform;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { resolveGLSLTypeInfo, resolvePropertyUniform };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates value is finite number within safe range.
|
|
3
|
+
* @param value Number to validate
|
|
4
|
+
* @param subject Value name for error messages
|
|
5
|
+
* @throws If value is not finite or exceeds safe range
|
|
6
|
+
*/
|
|
7
|
+
export declare function assertValidNumber(value: number, subject: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Validates value is positive (>= EPSILON).
|
|
10
|
+
* @param value Number to validate
|
|
11
|
+
* @param subject Value name for error messages
|
|
12
|
+
* @throws If value is invalid or below EPSILON
|
|
13
|
+
*/
|
|
14
|
+
export declare function assertValidPositiveNumber(value: number, subject: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Validates value is non-negative (>= 0).
|
|
17
|
+
* @param value Number to validate
|
|
18
|
+
* @param subject Value name for error messages
|
|
19
|
+
* @throws If value is invalid or negative
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertValidNonNegativeNumber(value: number, subject: string): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EPSILON } from './math.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates value is finite number within safe range.
|
|
5
|
+
* @param value Number to validate
|
|
6
|
+
* @param subject Value name for error messages
|
|
7
|
+
* @throws If value is not finite or exceeds safe range
|
|
8
|
+
*/
|
|
9
|
+
function assertValidNumber(value, subject) {
|
|
10
|
+
if (process.env.NODE_ENV !== "production") {
|
|
11
|
+
if (!Number.isFinite(value)) {
|
|
12
|
+
throw new Error(`${subject}: value must be a finite number`);
|
|
13
|
+
}
|
|
14
|
+
if (Math.abs(value) > Number.MAX_SAFE_INTEGER) {
|
|
15
|
+
throw new Error(`${subject}: value exceeds maximum safe integer range`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates value is positive (>= EPSILON).
|
|
21
|
+
* @param value Number to validate
|
|
22
|
+
* @param subject Value name for error messages
|
|
23
|
+
* @throws If value is invalid or below EPSILON
|
|
24
|
+
*/
|
|
25
|
+
function assertValidPositiveNumber(value, subject) {
|
|
26
|
+
if (process.env.NODE_ENV !== "production") {
|
|
27
|
+
assertValidNumber(value, subject);
|
|
28
|
+
if (value < EPSILON) {
|
|
29
|
+
throw new Error(`${subject}: value must be greater than or equal to ${EPSILON}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validates value is non-negative (>= 0).
|
|
35
|
+
* @param value Number to validate
|
|
36
|
+
* @param subject Value name for error messages
|
|
37
|
+
* @throws If value is invalid or negative
|
|
38
|
+
*/
|
|
39
|
+
function assertValidNonNegativeNumber(value, subject) {
|
|
40
|
+
if (process.env.NODE_ENV !== "production") {
|
|
41
|
+
assertValidNumber(value, subject);
|
|
42
|
+
if (value < 0) {
|
|
43
|
+
throw new Error(`${subject}: value must be greater than or equal to 0`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { assertValidNonNegativeNumber, assertValidNumber, assertValidPositiveNumber };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const EPSILON = 0.000001;
|
|
2
|
+
export interface Vector3Like {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
readonly z: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function srgbToLinear(color: number): number;
|
|
8
|
+
export declare function linearToSRGB(color: number): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const EPSILON = 1e-6;
|
|
2
|
+
function srgbToLinear(color) {
|
|
3
|
+
return color < 0.04045
|
|
4
|
+
? color * 0.0773993808
|
|
5
|
+
: Math.pow(color * 0.9478672986 + 0.0521327014, 2.4);
|
|
6
|
+
}
|
|
7
|
+
function linearToSRGB(color) {
|
|
8
|
+
return color < 0.0031308 ? color * 12.92 : 1.055 * Math.pow(color, 0.41666) - 0.055;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { EPSILON, linearToSRGB, srgbToLinear };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Vector3Tuple } from "three";
|
|
2
|
+
import { DataTexture } from "three";
|
|
3
|
+
import type { FXColor } from "../color/FXColor";
|
|
4
|
+
import type { Vector3Like } from "../miscellaneous/math";
|
|
5
|
+
import type { FXTextureConfig } from "../miscellaneous/texture/FXTextureView.Internal";
|
|
6
|
+
export interface FXRange {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
}
|
|
10
|
+
export type FXRangeConfig = FXRange | [number, number, number] | number;
|
|
11
|
+
export type FXVector3Config = Vector3Like | Vector3Tuple | number;
|
|
12
|
+
export type FXAspectConfig = number | FXTextureConfig;
|
|
13
|
+
export declare function resolveFXRangeConfig(config: FXRangeConfig): FXRange;
|
|
14
|
+
export declare function resolveFXVector2Config(config: FXVector3Config): Vector3Like;
|
|
15
|
+
export declare function resolveAspect(config: number | FXTextureConfig): number;
|
|
16
|
+
export declare function generateNoise3D(x: number, y: number, z: number): number;
|
|
17
|
+
export declare function buildGradientTexture(colors: FXColor[]): DataTexture;
|
|
18
|
+
export declare const BUILTIN_OFFSET_POSITION_X = 0;
|
|
19
|
+
export declare const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
20
|
+
export declare const BUILTIN_OFFSET_POSITION_Z = 2;
|
|
21
|
+
export declare const BUILTIN_OFFSET_VELOCITY_X = 3;
|
|
22
|
+
export declare const BUILTIN_OFFSET_VELOCITY_Y = 4;
|
|
23
|
+
export declare const BUILTIN_OFFSET_VELOCITY_Z = 5;
|
|
24
|
+
export declare const BUILTIN_OFFSET_SCALE_X = 6;
|
|
25
|
+
export declare const BUILTIN_OFFSET_SCALE_Y = 7;
|
|
26
|
+
export declare const BUILTIN_OFFSET_SCALE_Z = 8;
|
|
27
|
+
export declare const BUILTIN_OFFSET_ROTATION = 9;
|
|
28
|
+
export declare const BUILTIN_OFFSET_TORQUE = 10;
|
|
29
|
+
export declare const BUILTIN_OFFSET_LIFETIME = 11;
|
|
30
|
+
export declare const BUILTIN_OFFSET_AGE = 12;
|
|
31
|
+
export declare const BUILTIN_OFFSET_RANDOM_A = 13;
|
|
32
|
+
export declare const BUILTIN_OFFSET_RANDOM_B = 14;
|
|
33
|
+
export declare const BUILTIN_OFFSET_RANDOM_C = 15;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Texture, DataTexture, RGBAFormat, UnsignedByteType, UVMapping, ClampToEdgeWrapping, LinearFilter, SRGBColorSpace } from 'three';
|
|
2
|
+
|
|
3
|
+
function resolveFXRangeConfig(config) {
|
|
4
|
+
if (typeof config === "number") {
|
|
5
|
+
return { min: config, max: config };
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(config)) {
|
|
8
|
+
return { min: config[0], max: config[1] };
|
|
9
|
+
}
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
12
|
+
function resolveFXVector2Config(config) {
|
|
13
|
+
if (typeof config === "number") {
|
|
14
|
+
return { x: config, y: config, z: config };
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(config)) {
|
|
17
|
+
return { x: config[0], y: config[1], z: config[2] };
|
|
18
|
+
}
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
function resolveAspect(config) {
|
|
22
|
+
if (typeof config === "number") {
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
25
|
+
if (config instanceof Texture) {
|
|
26
|
+
return config.image.naturalWidth / config.image.naturalHeight;
|
|
27
|
+
}
|
|
28
|
+
return config.sourceSize.w / config.sourceSize.h;
|
|
29
|
+
}
|
|
30
|
+
function generateNoise3D(x, y, z) {
|
|
31
|
+
const noise = Math.sin(x * 12.9898 + y * 78.233 + z * 37.719) * 43758.5453123;
|
|
32
|
+
return (noise - Math.floor(noise)) * 2 - 1;
|
|
33
|
+
}
|
|
34
|
+
function buildGradientTexture(colors) {
|
|
35
|
+
const width = colors.length;
|
|
36
|
+
const height = 1;
|
|
37
|
+
const data = new Uint8Array(width * height * 4);
|
|
38
|
+
for (let i = 0; i < width; i++) {
|
|
39
|
+
const color = colors[i];
|
|
40
|
+
const index = i * 4;
|
|
41
|
+
data[index] = Math.round(color.r * 255);
|
|
42
|
+
data[index + 1] = Math.round(color.g * 255);
|
|
43
|
+
data[index + 2] = Math.round(color.b * 255);
|
|
44
|
+
data[index + 3] = Math.round(color.a * 255);
|
|
45
|
+
}
|
|
46
|
+
const texture = new DataTexture(data, width, height, RGBAFormat, UnsignedByteType, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter, 1, SRGBColorSpace);
|
|
47
|
+
texture.needsUpdate = true;
|
|
48
|
+
return texture;
|
|
49
|
+
}
|
|
50
|
+
const BUILTIN_OFFSET_POSITION_X = 0;
|
|
51
|
+
const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
52
|
+
const BUILTIN_OFFSET_POSITION_Z = 2;
|
|
53
|
+
const BUILTIN_OFFSET_VELOCITY_X = 3;
|
|
54
|
+
const BUILTIN_OFFSET_VELOCITY_Y = 4;
|
|
55
|
+
const BUILTIN_OFFSET_VELOCITY_Z = 5;
|
|
56
|
+
const BUILTIN_OFFSET_SCALE_X = 6;
|
|
57
|
+
const BUILTIN_OFFSET_SCALE_Y = 7;
|
|
58
|
+
const BUILTIN_OFFSET_ROTATION = 9;
|
|
59
|
+
const BUILTIN_OFFSET_TORQUE = 10;
|
|
60
|
+
const BUILTIN_OFFSET_LIFETIME = 11;
|
|
61
|
+
const BUILTIN_OFFSET_AGE = 12;
|
|
62
|
+
const BUILTIN_OFFSET_RANDOM_A = 13;
|
|
63
|
+
const BUILTIN_OFFSET_RANDOM_B = 14;
|
|
64
|
+
const BUILTIN_OFFSET_RANDOM_C = 15;
|
|
65
|
+
|
|
66
|
+
export { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z, buildGradientTexture, generateNoise3D, resolveAspect, resolveFXRangeConfig, resolveFXVector2Config };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Texture } from "three";
|
|
2
|
+
export declare const TEXTURE_DEFAULT_TEXTURE: Texture;
|
|
3
|
+
export declare const TEXTURE_DEFAULT_SIZE = 2;
|
|
4
|
+
/** Rectangle coordinates and dimensions in atlas */
|
|
5
|
+
export interface FXTextureRect {
|
|
6
|
+
/** X coordinate in pixels */
|
|
7
|
+
x: number;
|
|
8
|
+
/** Y coordinate in pixels */
|
|
9
|
+
y: number;
|
|
10
|
+
/** Width in pixels */
|
|
11
|
+
w: number;
|
|
12
|
+
/** Height in pixels */
|
|
13
|
+
h: number;
|
|
14
|
+
}
|
|
15
|
+
/** Size dimensions */
|
|
16
|
+
export interface FXTextureSize {
|
|
17
|
+
/** Width in pixels */
|
|
18
|
+
w: number;
|
|
19
|
+
/** Height in pixels */
|
|
20
|
+
h: number;
|
|
21
|
+
}
|
|
22
|
+
/** Transparent padding around visible content */
|
|
23
|
+
export interface FXTextureTrim {
|
|
24
|
+
/** Left padding in world units */
|
|
25
|
+
left: number;
|
|
26
|
+
/** Right padding in world units */
|
|
27
|
+
right: number;
|
|
28
|
+
/** Top padding in world units */
|
|
29
|
+
top: number;
|
|
30
|
+
/** Bottom padding in world units */
|
|
31
|
+
bottom: number;
|
|
32
|
+
}
|
|
33
|
+
/** Configuration for texture atlas sprite */
|
|
34
|
+
export interface FXTextureAtlasConfig {
|
|
35
|
+
/** Source texture atlas */
|
|
36
|
+
texture: Texture;
|
|
37
|
+
/** Rectangle in atlas containing sprite */
|
|
38
|
+
frame: FXTextureRect;
|
|
39
|
+
/** Whether sprite is rotated 90 degrees clockwise */
|
|
40
|
+
rotated?: boolean;
|
|
41
|
+
/** Position and size within original image before trimming */
|
|
42
|
+
spriteSourceSize: FXTextureRect;
|
|
43
|
+
/** Original image dimensions before trimming */
|
|
44
|
+
sourceSize: FXTextureSize;
|
|
45
|
+
/** Scale factor for resolution independence */
|
|
46
|
+
scale?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Texture configuration from direct texture or atlas sprite */
|
|
49
|
+
export type FXTextureConfig = Texture | FXTextureAtlasConfig;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { FerrsignView3 } from "ferrsign";
|
|
2
|
+
import { Matrix3, Texture, Vector2 } from "three";
|
|
3
|
+
import type { FXTextureConfig } from "./FXTextureView.Internal";
|
|
4
|
+
/** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
|
|
5
|
+
export declare class FXTextureView {
|
|
6
|
+
private textureInternal;
|
|
7
|
+
private sourceWidth;
|
|
8
|
+
private sourceHeight;
|
|
9
|
+
private frameX;
|
|
10
|
+
private frameY;
|
|
11
|
+
private frameWidth;
|
|
12
|
+
private frameHeight;
|
|
13
|
+
private rotatedInternal;
|
|
14
|
+
private scaleInternal;
|
|
15
|
+
private trimLeft;
|
|
16
|
+
private trimRight;
|
|
17
|
+
private trimTop;
|
|
18
|
+
private trimBottom;
|
|
19
|
+
private textureDirtyInternal;
|
|
20
|
+
private uvTransformDirtyInternal;
|
|
21
|
+
private trimDirtyInternal;
|
|
22
|
+
private readonly signalDiminsionsChangedInternal;
|
|
23
|
+
/** @param config Texture or atlas configuration */
|
|
24
|
+
constructor(config?: FXTextureConfig);
|
|
25
|
+
/** Original width before trimming in world units */
|
|
26
|
+
get width(): number;
|
|
27
|
+
/** Original height before trimming in world units */
|
|
28
|
+
get height(): number;
|
|
29
|
+
/** Visible width after trimming in world units */
|
|
30
|
+
get trimmedWidth(): number;
|
|
31
|
+
/** Visible height after trimming in world units */
|
|
32
|
+
get trimmedHeight(): number;
|
|
33
|
+
/** Underlying Three.js texture */
|
|
34
|
+
get texture(): Texture;
|
|
35
|
+
/** Whether sprite is rotated in atlas */
|
|
36
|
+
get rotated(): boolean;
|
|
37
|
+
/** Scale factor for resolution independence */
|
|
38
|
+
get scale(): number;
|
|
39
|
+
/** Transparent padding around visible content */
|
|
40
|
+
get trim(): Readonly<{
|
|
41
|
+
left: number;
|
|
42
|
+
right: number;
|
|
43
|
+
top: number;
|
|
44
|
+
bottom: number;
|
|
45
|
+
}>;
|
|
46
|
+
get textureDirty(): boolean;
|
|
47
|
+
/** Whether UV transform inputs changed since last check */
|
|
48
|
+
get uvTransformDirty(): boolean;
|
|
49
|
+
/** Whether trim values changed since last check */
|
|
50
|
+
get trimDirty(): boolean;
|
|
51
|
+
get signalDiminsionsChanged(): FerrsignView3<number, number, FXTextureView>;
|
|
52
|
+
setTextureDirtyFalse(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Calculates UV transform matrix for shader sampling.
|
|
55
|
+
* @param result Matrix to store result in
|
|
56
|
+
* @returns UV transform matrix
|
|
57
|
+
*/
|
|
58
|
+
calculateUVTransform(result?: Matrix3): Matrix3;
|
|
59
|
+
/**
|
|
60
|
+
* Gets original dimensions before trimming.
|
|
61
|
+
* @param result Vector to store result in
|
|
62
|
+
* @returns Width and height in world units
|
|
63
|
+
*/
|
|
64
|
+
getResolution(result?: Vector2): Vector2;
|
|
65
|
+
/**
|
|
66
|
+
* Replaces texture with new configuration.
|
|
67
|
+
* @param config Texture or atlas configuration
|
|
68
|
+
*/
|
|
69
|
+
set(config: FXTextureConfig): void;
|
|
70
|
+
private setFromTexture;
|
|
71
|
+
private setFromAtlasConfig;
|
|
72
|
+
}
|