sparcoon 0.7.3 → 0.9.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/README.md +124 -76
- package/dist/artifact/FXArtifact.d.ts +120 -0
- package/dist/artifact/FXArtifact.js +1 -0
- package/dist/coreLayout.d.ts +22 -0
- package/dist/coreLayout.js +32 -0
- package/dist/editor/index.d.ts +8 -0
- package/dist/editor/index.js +17 -0
- package/dist/effect/FXEffect.d.ts +77 -0
- package/dist/effect/FXEffect.js +454 -0
- package/dist/effect/FXEffectSampling.Internal.d.ts +24 -0
- package/dist/effect/FXEffectSampling.Internal.js +165 -0
- package/dist/effect/FXEffectSpec.d.ts +115 -0
- package/dist/effect/FXEffectSpec.js +1 -0
- package/dist/emitter/FXEmitter.Internal.d.ts +23 -58
- package/dist/emitter/FXEmitter.Internal.js +13 -29
- package/dist/emitter/FXEmitter.d.ts +54 -46
- package/dist/emitter/FXEmitter.js +357 -186
- package/dist/emitter/FXFromArtifactsOptions.d.ts +13 -0
- package/dist/emitter/FXFromArtifactsOptions.js +1 -0
- package/dist/emitter/FXObjectMotion.Internal.d.ts +33 -0
- package/dist/emitter/FXObjectMotion.Internal.js +87 -0
- package/dist/emitter/FXSimulationHolder.d.ts +1 -0
- package/dist/emitter/FXSimulationHolder.js +43 -0
- package/dist/index.d.ts +11 -39
- package/dist/index.js +13 -36
- package/dist/instancedParticle/FXInstancedParticle.d.ts +1 -22
- package/dist/instancedParticle/FXInstancedParticle.js +145 -85
- package/dist/instancedParticle/glTypeInfo.d.ts +5 -0
- package/dist/instancedParticle/glTypeInfo.js +3 -0
- package/dist/instancedParticle/primitiveGeometry.d.ts +10 -0
- package/dist/instancedParticle/primitiveGeometry.js +30 -0
- package/dist/miscellaneous/asserts.d.ts +1 -18
- package/dist/miscellaneous/asserts.js +21 -28
- package/dist/miscellaneous/fxMath.d.ts +26 -0
- package/dist/miscellaneous/fxMath.js +261 -0
- package/dist/miscellaneous/math.d.ts +2 -7
- package/dist/miscellaneous/math.js +8 -9
- package/dist/miscellaneous/texture/fxDataTexture.d.ts +26 -0
- package/dist/miscellaneous/texture/fxDataTexture.js +20 -0
- package/dist/render/FXArtifactMaterial.Internal.d.ts +16 -0
- package/dist/render/FXArtifactMaterial.Internal.js +944 -0
- package/dist/render/FXArtifactMaterial.d.ts +1 -0
- package/dist/render/FXArtifactMaterial.js +79 -0
- package/dist/render/FXMaterialOptions.d.ts +27 -0
- package/dist/render/FXMaterialOptions.js +5 -0
- package/dist/render/FXMesh.d.ts +47 -0
- package/dist/render/FXMesh.js +99 -0
- package/dist/render/FXMeshMaterial.d.ts +40 -0
- package/dist/render/FXMeshMaterial.js +77 -0
- package/dist/world/FXWorld.d.ts +52 -0
- package/dist/world/FXWorld.js +104 -0
- package/package.json +49 -29
- package/dist/_virtual/2d.js +0 -3
- package/dist/_virtual/3d.js +0 -3
- package/dist/_virtual/4d.js +0 -3
- package/dist/_virtual/mod.js +0 -5
- package/dist/_virtual/mod2.js +0 -3
- package/dist/emitter/behavior/FXBehavior.d.ts +0 -24
- package/dist/emitter/behavior/FXBehavior.js +0 -10
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.d.ts +0 -23
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.js +0 -72
- package/dist/emitter/behavior/FXBehaviorPointForce.d.ts +0 -36
- package/dist/emitter/behavior/FXBehaviorPointForce.js +0 -94
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.d.ts +0 -24
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.js +0 -55
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.js +0 -48
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.js +0 -67
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.d.ts +0 -19
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.js +0 -41
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.js +0 -50
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.js +0 -76
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.d.ts +0 -22
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.js +0 -55
- package/dist/emitter/spawn/FXSpawn.d.ts +0 -11
- package/dist/emitter/spawn/FXSpawn.js +0 -10
- package/dist/emitter/spawn/FXSpawnBox.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnBox.js +0 -50
- package/dist/emitter/spawn/FXSpawnLifetime.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnLifetime.js +0 -44
- package/dist/emitter/spawn/FXSpawnOffset.d.ts +0 -21
- package/dist/emitter/spawn/FXSpawnOffset.js +0 -49
- package/dist/emitter/spawn/FXSpawnPoint.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnPoint.js +0 -46
- package/dist/emitter/spawn/FXSpawnRotation.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnRotation.js +0 -42
- package/dist/emitter/spawn/FXSpawnScale.d.ts +0 -22
- package/dist/emitter/spawn/FXSpawnScale.js +0 -56
- package/dist/emitter/spawn/FXSpawnSphere.d.ts +0 -36
- package/dist/emitter/spawn/FXSpawnSphere.js +0 -87
- package/dist/emitter/spawn/FXSpawnTorque.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnTorque.js +0 -42
- package/dist/emitter/spawn/FXSpawnVelocity.d.ts +0 -29
- package/dist/emitter/spawn/FXSpawnVelocity.js +0 -91
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +0 -2
- package/dist/instancedParticle/shared.d.ts +0 -19
- package/dist/instancedParticle/shared.js +0 -116
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +0 -24
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +0 -275
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +0 -75
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +0 -63
- package/dist/materials/FXMaterial/FXBlending.Internal.d.ts +0 -24
- package/dist/materials/FXMaterial/FXBlending.Internal.js +0 -64
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.js +0 -144
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.js +0 -175
- package/dist/materials/FXMaterial/FXMaterial.d.ts +0 -70
- package/dist/materials/FXMaterial/FXMaterial.js +0 -51
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +0 -103
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +0 -21
- package/dist/miscellaneous/color/FXColor.Internal.d.ts +0 -7
- package/dist/miscellaneous/color/FXColor.Internal.js +0 -42
- package/dist/miscellaneous/color/FXColor.d.ts +0 -234
- package/dist/miscellaneous/color/FXColor.js +0 -636
- package/dist/miscellaneous/curve/FXCurve1D.Internal.d.ts +0 -20
- package/dist/miscellaneous/curve/FXCurve1D.d.ts +0 -17
- package/dist/miscellaneous/curve/FXCurve1D.js +0 -94
- package/dist/miscellaneous/miscellaneous.d.ts +0 -34
- package/dist/miscellaneous/miscellaneous.js +0 -85
- package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +0 -49
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +0 -6
- package/dist/miscellaneous/texture/FXTextureView.d.ts +0 -72
- package/dist/miscellaneous/texture/FXTextureView.js +0 -234
- package/dist/miscellaneous/webglCapabilities.d.ts +0 -1
- package/dist/miscellaneous/webglCapabilities.js +0 -45
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +0 -93
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +0 -142
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +0 -196
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +0 -24
- package/dist/nodes/FXNode.d.ts +0 -5
- package/dist/nodes/FXNode.js +0 -10
- package/dist/nodes/blending/FXNodeBlending.d.ts +0 -6
- package/dist/nodes/blending/FXNodeBlending.js +0 -9
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.d.ts +0 -19
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.js +0 -65
- package/dist/nodes/color/FXNodeColor.d.ts +0 -6
- package/dist/nodes/color/FXNodeColor.js +0 -9
- package/dist/nodes/color/FXNodeColorOverLife.d.ts +0 -22
- package/dist/nodes/color/FXNodeColorOverLife.js +0 -64
- package/dist/nodes/color/FXNodeSphericalClip.d.ts +0 -21
- package/dist/nodes/color/FXNodeSphericalClip.js +0 -54
- package/dist/nodes/normal/FXNodeFlatNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeFlatNormal.js +0 -16
- package/dist/nodes/normal/FXNodeNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeNormal.js +0 -9
- package/dist/nodes/normal/FXNodeSphericalNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeSphericalNormal.js +0 -23
- package/dist/nodes/texture/FXNodeAnimatedTexture.d.ts +0 -52
- package/dist/nodes/texture/FXNodeAnimatedTexture.js +0 -151
- package/dist/nodes/texture/FXNodeStaticTexture.d.ts +0 -20
- package/dist/nodes/texture/FXNodeStaticTexture.js +0 -67
- package/dist/nodes/texture/FXNodeTexture.d.ts +0 -6
- package/dist/nodes/texture/FXNodeTexture.js +0 -9
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { assertValidNumber } from '../asserts.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 1D curve defined by anchor points at explicit normalized positions.
|
|
5
|
-
*
|
|
6
|
-
* Anchors must be strictly ascending by `value`, first must be `0`, last must be `1`.
|
|
7
|
-
* Output at each anchor is a value of type `T` - interpolation is left to the caller.
|
|
8
|
-
*/
|
|
9
|
-
class FXCurve1D {
|
|
10
|
-
/**
|
|
11
|
-
* @param config - Explicit anchor points, a uniform shorthand array, or another {@link FXCurve1D} to copy
|
|
12
|
-
*/
|
|
13
|
-
constructor(config) {
|
|
14
|
-
if (config instanceof FXCurve1D) {
|
|
15
|
-
this._private_anchorsInternal = config._private_anchorsInternal.map((anchor) => ({ ...anchor }));
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const isPointArray = config.length > 0 &&
|
|
19
|
-
typeof config[0] === "object" &&
|
|
20
|
-
!Array.isArray(config[0]) &&
|
|
21
|
-
"value" in config[0];
|
|
22
|
-
const points = isPointArray
|
|
23
|
-
? config
|
|
24
|
-
: config.map((value, index) => ({
|
|
25
|
-
value,
|
|
26
|
-
position: index / (config.length - 1),
|
|
27
|
-
}));
|
|
28
|
-
if (points.length < 2) {
|
|
29
|
-
throw new Error("FXCurve1D: at least 2 anchor points are required");
|
|
30
|
-
}
|
|
31
|
-
if (points[0].position !== 0) {
|
|
32
|
-
throw new Error(`FXCurve1D: first anchor value must be 0, got ${points[0].position}`);
|
|
33
|
-
}
|
|
34
|
-
if (points[points.length - 1].position !== 1) {
|
|
35
|
-
throw new Error(`FXCurve1D: last anchor value must be 1, got ${points[points.length - 1].position}`);
|
|
36
|
-
}
|
|
37
|
-
this._private_anchorsInternal = [];
|
|
38
|
-
for (let index = 0; index < points.length; index++) {
|
|
39
|
-
const { value, position } = points[index];
|
|
40
|
-
if (position < 0 || position > 1) {
|
|
41
|
-
throw new Error(`FXCurve1D: anchor[${index}].value must be in [0, 1], got ${position}`);
|
|
42
|
-
}
|
|
43
|
-
if (index > 0 && position <= points[index - 1].position) {
|
|
44
|
-
throw new Error(`FXCurve1D: anchor[${index}].value (${position}) must be strictly greater than anchor[${index - 1}].value (${points[index - 1].position})`);
|
|
45
|
-
}
|
|
46
|
-
this._private_anchorsInternal.push({ value, position });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/** Resolved anchor points ordered ascending by `value`. */
|
|
50
|
-
get anchors() {
|
|
51
|
-
return this._private_anchorsInternal;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Samples the curve at normalized position `t`.
|
|
55
|
-
*
|
|
56
|
-
* Returns the two bracketing anchor values and the local interpolation factor `t` in [0, 1].
|
|
57
|
-
* The caller is responsible for interpolating between `a` and `b` using `t`.
|
|
58
|
-
*
|
|
59
|
-
* @param t - Normalized position in [0, 1]
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
sample(t) {
|
|
63
|
-
assertValidNumber(t, "FXCurve1D.sample.t");
|
|
64
|
-
const anchors = this._private_anchorsInternal;
|
|
65
|
-
const anchorCount = anchors.length;
|
|
66
|
-
let segmentIndex;
|
|
67
|
-
if (anchorCount < 10) {
|
|
68
|
-
segmentIndex = 0;
|
|
69
|
-
while (segmentIndex < anchorCount - 2 && anchors[segmentIndex + 1].position <= t) {
|
|
70
|
-
segmentIndex++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
let low = 0;
|
|
75
|
-
let high = anchorCount - 2;
|
|
76
|
-
while (low < high) {
|
|
77
|
-
const mid = (low + high + 1) >> 1;
|
|
78
|
-
if (anchors[mid].position <= t) {
|
|
79
|
-
low = mid;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
high = mid - 1;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
segmentIndex = low;
|
|
86
|
-
}
|
|
87
|
-
const anchorA = anchors[segmentIndex];
|
|
88
|
-
const anchorB = anchors[segmentIndex + 1];
|
|
89
|
-
const localT = (t - anchorA.position) / (anchorB.position - anchorA.position);
|
|
90
|
-
return { a: anchorA.value, b: anchorB.value, t: localT };
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { FXCurve1D };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Vector3Tuple } from "three";
|
|
2
|
-
import { DataTexture } from "three";
|
|
3
|
-
import type { Vector3Like } from "../miscellaneous/math";
|
|
4
|
-
import type { FXTextureConfig } from "../miscellaneous/texture/FXTextureView.Internal";
|
|
5
|
-
import type { FXColor } from "./color/FXColor";
|
|
6
|
-
import type { FXCurve1D } from "./curve/FXCurve1D";
|
|
7
|
-
export interface FXRange {
|
|
8
|
-
min: number;
|
|
9
|
-
max: number;
|
|
10
|
-
}
|
|
11
|
-
export type FXRangeConfig = FXRange | [number, number, number] | number;
|
|
12
|
-
export type FXVector3Config = Vector3Like | Vector3Tuple | number;
|
|
13
|
-
export type FXAspectConfig = number | FXTextureConfig;
|
|
14
|
-
export declare function resolveFXRangeConfig(config: FXRangeConfig): FXRange;
|
|
15
|
-
export declare function resolveFXVector3Config(config: FXVector3Config): Vector3Like;
|
|
16
|
-
export declare function resolveAspect(config: number | FXTextureConfig): number;
|
|
17
|
-
export declare function buildGradientTexture(curve: FXCurve1D<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;
|
|
34
|
-
export declare const PARTICLE_DEFINES = "\n #define PARTICLE_POSITION_X p_builtin[0][0]\n #define PARTICLE_POSITION_Y p_builtin[0][1]\n #define PARTICLE_POSITION_Z p_builtin[0][2]\n\n #define PARTICLE_VELOCITY_X p_builtin[0][3]\n #define PARTICLE_VELOCITY_Y p_builtin[1][0]\n #define PARTICLE_VELOCITY_Z p_builtin[1][1]\n\n #define PARTICLE_SCALE_X p_builtin[1][2]\n #define PARTICLE_SCALE_Y p_builtin[1][3]\n #define PARTICLE_SCALE_Z p_builtin[2][0]\n\n #define PARTICLE_ROTATION p_builtin[2][1]\n #define PARTICLE_TORQUE p_builtin[2][2]\n\n #define PARTICLE_LIFETIME p_builtin[2][3]\n #define PARTICLE_AGE p_builtin[3][0]\n\n #define PARTICLE_RANDOM_A p_builtin[3][1]\n #define PARTICLE_RANDOM_B p_builtin[3][2]\n #define PARTICLE_RANDOM_C p_builtin[3][3]\n";
|
|
@@ -1,85 +0,0 @@
|
|
|
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 resolveFXVector3Config(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 buildGradientTexture(curve) {
|
|
31
|
-
const width = curve.anchors.length;
|
|
32
|
-
const height = 1;
|
|
33
|
-
const data = new Uint8Array(width * height * 4);
|
|
34
|
-
for (let i = 0; i < width; i++) {
|
|
35
|
-
const color = curve.anchors[i].value;
|
|
36
|
-
const index = i * 4;
|
|
37
|
-
data[index] = Math.round(color.r * 255);
|
|
38
|
-
data[index + 1] = Math.round(color.g * 255);
|
|
39
|
-
data[index + 2] = Math.round(color.b * 255);
|
|
40
|
-
data[index + 3] = Math.round(color.a * 255);
|
|
41
|
-
}
|
|
42
|
-
const texture = new DataTexture(data, width, height, RGBAFormat, UnsignedByteType, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter, 1, SRGBColorSpace);
|
|
43
|
-
texture.needsUpdate = true;
|
|
44
|
-
return texture;
|
|
45
|
-
}
|
|
46
|
-
const BUILTIN_OFFSET_POSITION_X = 0;
|
|
47
|
-
const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
48
|
-
const BUILTIN_OFFSET_POSITION_Z = 2;
|
|
49
|
-
const BUILTIN_OFFSET_VELOCITY_X = 3;
|
|
50
|
-
const BUILTIN_OFFSET_VELOCITY_Y = 4;
|
|
51
|
-
const BUILTIN_OFFSET_VELOCITY_Z = 5;
|
|
52
|
-
const BUILTIN_OFFSET_SCALE_X = 6;
|
|
53
|
-
const BUILTIN_OFFSET_SCALE_Y = 7;
|
|
54
|
-
const BUILTIN_OFFSET_ROTATION = 9;
|
|
55
|
-
const BUILTIN_OFFSET_TORQUE = 10;
|
|
56
|
-
const BUILTIN_OFFSET_LIFETIME = 11;
|
|
57
|
-
const BUILTIN_OFFSET_AGE = 12;
|
|
58
|
-
const BUILTIN_OFFSET_RANDOM_A = 13;
|
|
59
|
-
const BUILTIN_OFFSET_RANDOM_B = 14;
|
|
60
|
-
const BUILTIN_OFFSET_RANDOM_C = 15;
|
|
61
|
-
const PARTICLE_DEFINES = `
|
|
62
|
-
#define PARTICLE_POSITION_X p_builtin[0][0]
|
|
63
|
-
#define PARTICLE_POSITION_Y p_builtin[0][1]
|
|
64
|
-
#define PARTICLE_POSITION_Z p_builtin[0][2]
|
|
65
|
-
|
|
66
|
-
#define PARTICLE_VELOCITY_X p_builtin[0][3]
|
|
67
|
-
#define PARTICLE_VELOCITY_Y p_builtin[1][0]
|
|
68
|
-
#define PARTICLE_VELOCITY_Z p_builtin[1][1]
|
|
69
|
-
|
|
70
|
-
#define PARTICLE_SCALE_X p_builtin[1][2]
|
|
71
|
-
#define PARTICLE_SCALE_Y p_builtin[1][3]
|
|
72
|
-
#define PARTICLE_SCALE_Z p_builtin[2][0]
|
|
73
|
-
|
|
74
|
-
#define PARTICLE_ROTATION p_builtin[2][1]
|
|
75
|
-
#define PARTICLE_TORQUE p_builtin[2][2]
|
|
76
|
-
|
|
77
|
-
#define PARTICLE_LIFETIME p_builtin[2][3]
|
|
78
|
-
#define PARTICLE_AGE p_builtin[3][0]
|
|
79
|
-
|
|
80
|
-
#define PARTICLE_RANDOM_A p_builtin[3][1]
|
|
81
|
-
#define PARTICLE_RANDOM_B p_builtin[3][2]
|
|
82
|
-
#define PARTICLE_RANDOM_C p_builtin[3][3]
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
|
-
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, PARTICLE_DEFINES, buildGradientTexture, resolveAspect, resolveFXRangeConfig, resolveFXVector3Config };
|
|
@@ -1,49 +0,0 @@
|
|
|
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;
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { Ferrsign3 } from 'ferrsign';
|
|
2
|
-
import { Matrix3, Vector2, Texture } from 'three';
|
|
3
|
-
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../asserts.js';
|
|
4
|
-
import { TEXTURE_DEFAULT_TEXTURE, TEXTURE_DEFAULT_SIZE } from './FXTextureView.Internal.js';
|
|
5
|
-
|
|
6
|
-
/** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
|
|
7
|
-
class FXTextureView {
|
|
8
|
-
/** @param config Texture or atlas configuration */
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this._private_textureInternal = TEXTURE_DEFAULT_TEXTURE;
|
|
11
|
-
this._private_sourceWidth = TEXTURE_DEFAULT_SIZE;
|
|
12
|
-
this._private_sourceHeight = TEXTURE_DEFAULT_SIZE;
|
|
13
|
-
this._private_frameX = 0;
|
|
14
|
-
this._private_frameY = 0;
|
|
15
|
-
this._private_frameWidth = TEXTURE_DEFAULT_SIZE;
|
|
16
|
-
this._private_frameHeight = TEXTURE_DEFAULT_SIZE;
|
|
17
|
-
this._private_rotatedInternal = false;
|
|
18
|
-
this._private_scaleInternal = 1;
|
|
19
|
-
this._private_trimLeft = 0;
|
|
20
|
-
this._private_trimRight = 0;
|
|
21
|
-
this._private_trimTop = 0;
|
|
22
|
-
this._private_trimBottom = 0;
|
|
23
|
-
this._private_textureDirtyInternal = false;
|
|
24
|
-
this._private_uvTransformDirtyInternal = false;
|
|
25
|
-
this._private_trimDirtyInternal = false;
|
|
26
|
-
this._private_signalDiminsionsChangedInternal = new Ferrsign3();
|
|
27
|
-
if (config !== undefined) {
|
|
28
|
-
this.set(config);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** Original width before trimming in world units */
|
|
32
|
-
get width() {
|
|
33
|
-
return this._private_sourceWidth / this._private_scaleInternal;
|
|
34
|
-
}
|
|
35
|
-
/** Original height before trimming in world units */
|
|
36
|
-
get height() {
|
|
37
|
-
return this._private_sourceHeight / this._private_scaleInternal;
|
|
38
|
-
}
|
|
39
|
-
/** Visible width after trimming in world units */
|
|
40
|
-
get trimmedWidth() {
|
|
41
|
-
const frameSize = this._private_rotatedInternal ? this._private_frameHeight : this._private_frameWidth;
|
|
42
|
-
return frameSize / this._private_scaleInternal;
|
|
43
|
-
}
|
|
44
|
-
/** Visible height after trimming in world units */
|
|
45
|
-
get trimmedHeight() {
|
|
46
|
-
const frameSize = this._private_rotatedInternal ? this._private_frameWidth : this._private_frameHeight;
|
|
47
|
-
return frameSize / this._private_scaleInternal;
|
|
48
|
-
}
|
|
49
|
-
/** Underlying Three.js texture */
|
|
50
|
-
get texture() {
|
|
51
|
-
return this._private_textureInternal;
|
|
52
|
-
}
|
|
53
|
-
/** Whether sprite is rotated in atlas */
|
|
54
|
-
get rotated() {
|
|
55
|
-
return this._private_rotatedInternal;
|
|
56
|
-
}
|
|
57
|
-
/** Scale factor for resolution independence */
|
|
58
|
-
get scale() {
|
|
59
|
-
return this._private_scaleInternal;
|
|
60
|
-
}
|
|
61
|
-
/** Transparent padding around visible content */
|
|
62
|
-
get trim() {
|
|
63
|
-
const scale = this._private_scaleInternal;
|
|
64
|
-
return {
|
|
65
|
-
left: this._private_trimLeft / scale,
|
|
66
|
-
right: this._private_trimRight / scale,
|
|
67
|
-
top: this._private_trimTop / scale,
|
|
68
|
-
bottom: this._private_trimBottom / scale,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
get textureDirty() {
|
|
72
|
-
return this._private_textureDirtyInternal;
|
|
73
|
-
}
|
|
74
|
-
/** Whether UV transform inputs changed since last check */
|
|
75
|
-
get uvTransformDirty() {
|
|
76
|
-
return this._private_uvTransformDirtyInternal;
|
|
77
|
-
}
|
|
78
|
-
/** Whether trim values changed since last check */
|
|
79
|
-
get trimDirty() {
|
|
80
|
-
return this._private_trimDirtyInternal;
|
|
81
|
-
}
|
|
82
|
-
get signalDiminsionsChanged() {
|
|
83
|
-
return this._private_signalDiminsionsChangedInternal;
|
|
84
|
-
}
|
|
85
|
-
setTextureDirtyFalse() {
|
|
86
|
-
this._private_textureDirtyInternal = false;
|
|
87
|
-
}
|
|
88
|
-
/** Marks UV transform as clean. @internal */
|
|
89
|
-
setUVTransformDirtyFalse() {
|
|
90
|
-
this._private_uvTransformDirtyInternal = false;
|
|
91
|
-
}
|
|
92
|
-
/** Marks trim as clean. @internal */
|
|
93
|
-
setTrimDirtyFalse() {
|
|
94
|
-
this._private_trimDirtyInternal = false;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Calculates UV transform matrix for shader sampling.
|
|
98
|
-
* @param result Matrix to store result in
|
|
99
|
-
* @returns UV transform matrix
|
|
100
|
-
*/
|
|
101
|
-
calculateUVTransform(result = new Matrix3()) {
|
|
102
|
-
const atlasWidth = this._private_textureInternal.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;
|
|
103
|
-
const atlasHeight = this._private_textureInternal.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;
|
|
104
|
-
if (this._private_rotatedInternal) {
|
|
105
|
-
const physicalWidth = this._private_frameHeight;
|
|
106
|
-
const physicalHeight = this._private_frameWidth;
|
|
107
|
-
const u0 = this._private_frameX / atlasWidth;
|
|
108
|
-
const v0 = (atlasHeight - this._private_frameY - physicalHeight) / atlasHeight;
|
|
109
|
-
const uSize = physicalWidth / atlasWidth;
|
|
110
|
-
const vSize = physicalHeight / atlasHeight;
|
|
111
|
-
result.set(0, uSize, u0, -vSize, 0, v0 + vSize, 0, 0, 1);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const u0 = this._private_frameX / atlasWidth;
|
|
115
|
-
const v0 = (atlasHeight - this._private_frameY - this._private_frameHeight) / atlasHeight;
|
|
116
|
-
const uSize = this._private_frameWidth / atlasWidth;
|
|
117
|
-
const vSize = this._private_frameHeight / atlasHeight;
|
|
118
|
-
result.set(uSize, 0, u0, 0, vSize, v0, 0, 0, 1);
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Gets original dimensions before trimming.
|
|
124
|
-
* @param result Vector to store result in
|
|
125
|
-
* @returns Width and height in world units
|
|
126
|
-
*/
|
|
127
|
-
getResolution(result = new Vector2()) {
|
|
128
|
-
return result.set(this.width, this.height);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Replaces texture with new configuration.
|
|
132
|
-
* @param config Texture or atlas configuration
|
|
133
|
-
*/
|
|
134
|
-
set(config) {
|
|
135
|
-
const lastWidth = this.width;
|
|
136
|
-
const lastHeight = this.height;
|
|
137
|
-
if (config instanceof Texture) {
|
|
138
|
-
this._private_setFromTexture(config);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this._private_setFromAtlasConfig(config);
|
|
142
|
-
}
|
|
143
|
-
if (this.width !== lastWidth || this.height !== lastHeight) {
|
|
144
|
-
this._private_signalDiminsionsChangedInternal.emit(this.width, this.height, this);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
_private_setFromTexture(texture) {
|
|
148
|
-
const width = texture.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;
|
|
149
|
-
const height = texture.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;
|
|
150
|
-
this._private_sourceWidth = width;
|
|
151
|
-
this._private_sourceHeight = height;
|
|
152
|
-
if (this.texture !== texture) {
|
|
153
|
-
this._private_textureInternal = texture;
|
|
154
|
-
this._private_textureDirtyInternal = true;
|
|
155
|
-
}
|
|
156
|
-
if (this._private_frameX !== 0 ||
|
|
157
|
-
this._private_frameY !== 0 ||
|
|
158
|
-
this._private_frameWidth !== width ||
|
|
159
|
-
this._private_frameHeight !== height ||
|
|
160
|
-
this._private_scaleInternal !== 1 || this._private_rotatedInternal) {
|
|
161
|
-
this._private_frameX = 0;
|
|
162
|
-
this._private_frameY = 0;
|
|
163
|
-
this._private_frameWidth = width;
|
|
164
|
-
this._private_frameHeight = height;
|
|
165
|
-
this._private_rotatedInternal = false;
|
|
166
|
-
this._private_scaleInternal = 1;
|
|
167
|
-
this._private_uvTransformDirtyInternal = true;
|
|
168
|
-
}
|
|
169
|
-
if (this._private_trimLeft !== 0 ||
|
|
170
|
-
this._private_trimRight !== 0 ||
|
|
171
|
-
this._private_trimTop !== 0 ||
|
|
172
|
-
this._private_trimBottom !== 0) {
|
|
173
|
-
this._private_trimLeft = 0;
|
|
174
|
-
this._private_trimRight = 0;
|
|
175
|
-
this._private_trimTop = 0;
|
|
176
|
-
this._private_trimBottom = 0;
|
|
177
|
-
this._private_trimDirtyInternal = true;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
_private_setFromAtlasConfig(config) {
|
|
181
|
-
assertValidPositiveNumber(config.sourceSize.w, "FXTextureView.setFromAtlasConfig.config.sourceSize.w");
|
|
182
|
-
assertValidPositiveNumber(config.sourceSize.h, "FXTextureView.setFromAtlasConfig.config.sourceSize.h");
|
|
183
|
-
assertValidNonNegativeNumber(config.frame.x, "FXTextureView.setFromAtlasConfig.config.frame.x");
|
|
184
|
-
assertValidNonNegativeNumber(config.frame.y, "FXTextureView.setFromAtlasConfig.config.frame.y");
|
|
185
|
-
assertValidPositiveNumber(config.frame.w, "FXTextureView.setFromAtlasConfig.config.frame.w");
|
|
186
|
-
assertValidPositiveNumber(config.frame.h, "FXTextureView.setFromAtlasConfig.config.frame.h");
|
|
187
|
-
assertValidNonNegativeNumber(config.spriteSourceSize.x, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.x");
|
|
188
|
-
assertValidNonNegativeNumber(config.spriteSourceSize.y, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.y");
|
|
189
|
-
assertValidPositiveNumber(config.spriteSourceSize.w, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.w");
|
|
190
|
-
assertValidPositiveNumber(config.spriteSourceSize.h, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.h");
|
|
191
|
-
if (config.scale !== undefined) {
|
|
192
|
-
assertValidPositiveNumber(config.scale, "FXTextureView.setFromAtlasConfig.config.scale");
|
|
193
|
-
}
|
|
194
|
-
this._private_sourceWidth = config.sourceSize.w;
|
|
195
|
-
this._private_sourceHeight = config.sourceSize.h;
|
|
196
|
-
if (this.texture !== config.texture) {
|
|
197
|
-
this._private_textureInternal = config.texture;
|
|
198
|
-
this._private_textureDirtyInternal = true;
|
|
199
|
-
}
|
|
200
|
-
const scale = config.scale ?? 1;
|
|
201
|
-
const rotated = config.rotated ?? false;
|
|
202
|
-
if (this._private_frameX !== 0 ||
|
|
203
|
-
this._private_frameY !== 0 ||
|
|
204
|
-
this._private_frameWidth !== config.frame.w ||
|
|
205
|
-
this._private_frameHeight !== config.frame.h ||
|
|
206
|
-
this._private_scaleInternal !== scale ||
|
|
207
|
-
this._private_rotatedInternal !== rotated) {
|
|
208
|
-
this._private_frameX = config.frame.x;
|
|
209
|
-
this._private_frameY = config.frame.y;
|
|
210
|
-
this._private_frameWidth = config.frame.w;
|
|
211
|
-
this._private_frameHeight = config.frame.h;
|
|
212
|
-
this._private_scaleInternal = scale;
|
|
213
|
-
this._private_rotatedInternal = rotated;
|
|
214
|
-
this._private_uvTransformDirtyInternal = true;
|
|
215
|
-
}
|
|
216
|
-
const spriteSource = config.spriteSourceSize;
|
|
217
|
-
const trimLeft = spriteSource.x;
|
|
218
|
-
const trimTop = spriteSource.y;
|
|
219
|
-
const trimRight = this._private_sourceWidth - spriteSource.x - spriteSource.w;
|
|
220
|
-
const trimBottom = this._private_sourceHeight - spriteSource.y - spriteSource.h;
|
|
221
|
-
if (this._private_trimLeft !== trimLeft ||
|
|
222
|
-
this._private_trimRight !== trimRight ||
|
|
223
|
-
this._private_trimTop !== trimTop ||
|
|
224
|
-
this._private_trimBottom !== trimBottom) {
|
|
225
|
-
this._private_trimLeft = trimLeft;
|
|
226
|
-
this._private_trimRight = trimRight;
|
|
227
|
-
this._private_trimTop = trimTop;
|
|
228
|
-
this._private_trimBottom = trimBottom;
|
|
229
|
-
this._private_trimDirtyInternal = true;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export { FXTextureView };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const checkSRGBSupport: () => boolean;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks sRGB support
|
|
3
|
-
*/
|
|
4
|
-
function checkSRGBSupportInternal() {
|
|
5
|
-
const canvasElement = document.createElement("canvas");
|
|
6
|
-
const gl = canvasElement.getContext("webgl2") ?? canvasElement.getContext("webgl");
|
|
7
|
-
if (!gl) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (gl instanceof WebGL2RenderingContext) {
|
|
11
|
-
try {
|
|
12
|
-
const texture = gl.createTexture();
|
|
13
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
14
|
-
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.SRGB8_ALPHA8, 2, 2);
|
|
15
|
-
const errorCode = gl.getError();
|
|
16
|
-
gl.deleteTexture(texture);
|
|
17
|
-
return errorCode === gl.NO_ERROR;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const extension = gl.getExtension("EXT_sRGB");
|
|
24
|
-
if (!extension) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const texture = gl.createTexture();
|
|
29
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
30
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, extension.SRGB_ALPHA_EXT, 2, 2, 0, extension.SRGB_ALPHA_EXT, gl.UNSIGNED_BYTE, null);
|
|
31
|
-
const errorCode = gl.getError();
|
|
32
|
-
gl.deleteTexture(texture);
|
|
33
|
-
return errorCode === gl.NO_ERROR;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
let SRGB_SUPPORTED_INTERNAL;
|
|
40
|
-
const checkSRGBSupport = () => {
|
|
41
|
-
SRGB_SUPPORTED_INTERNAL ?? (SRGB_SUPPORTED_INTERNAL = checkSRGBSupportInternal());
|
|
42
|
-
return SRGB_SUPPORTED_INTERNAL;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { checkSRGBSupport };
|