laymur 0.16.0 → 0.17.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 +84 -208
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
- package/dist/{constraints → core/constraints}/UIConstraint.d.ts +2 -2
- package/dist/core/constraints/UIConstraint.js +11 -0
- package/dist/core/constraints/UICustomConstraint.js +37 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.Internal.d.ts +3 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.d.ts +3 -3
- package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
- package/dist/{elements → core/elements}/UIDummy/UIDummy.d.ts +2 -2
- package/dist/core/elements/UIDummy/UIDummy.js +173 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIElement/UIElement.d.ts +2 -2
- package/dist/core/elements/UIElement/UIElement.js +74 -0
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
- package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
- package/dist/core/elements/UIImage/UIImage.js +85 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
- package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
- package/dist/core/elements/UIProgress/UIProgress.js +165 -0
- package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
- package/dist/core/elements/UIScene/UIScene.js +157 -0
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
- package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
- package/dist/core/elements/UIText/UIText.js +265 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
- package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
- package/dist/core/layers/UILayer/UILayer.js +113 -0
- package/dist/core/miscellaneous/UIExpression.js +128 -0
- package/dist/core/miscellaneous/UIMode.js +30 -0
- package/dist/core/miscellaneous/UIOrientation.js +20 -0
- package/dist/core/miscellaneous/UIPriority.js +63 -0
- package/dist/core/miscellaneous/UIRelation.js +40 -0
- package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
- package/dist/core/miscellaneous/area/UIArea.js +5 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
- package/dist/core/miscellaneous/asserts.js +163 -0
- package/dist/core/miscellaneous/canvas.js +37 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
- package/dist/core/miscellaneous/color/UIColor.js +636 -0
- package/dist/core/miscellaneous/computeTransform.js +82 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
- package/dist/{miscellaneous → core/miscellaneous}/math.d.ts +2 -0
- package/dist/core/miscellaneous/math.js +11 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
- package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
- package/dist/core/miscellaneous/shared.js +37 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
- package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
- package/dist/core/miscellaneous/webglCapabilities.js +103 -0
- package/dist/core/shaders/UIImage.glsl.js +3 -0
- package/dist/core/shaders/UINineSlice.glsl.js +3 -0
- package/dist/core/shaders/UIProgress.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +3 -0
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.d.ts +2 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
- package/dist/index.js +51 -9246
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +47 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +14 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.js +9 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +110 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +22 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +48 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +49 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +70 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -0
- package/dist/particles/elements/UIEmitter.Internal.js +11 -0
- package/dist/particles/elements/UIEmitter.d.ts +68 -0
- package/dist/particles/elements/UIEmitter.js +203 -0
- package/dist/particles/index.d.ts +18 -0
- package/dist/particles/index.js +18 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +13 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +211 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +17 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +93 -0
- package/dist/particles/miscellaneous/miscellaneous.d.ts +32 -0
- package/dist/particles/miscellaneous/miscellaneous.js +67 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +32 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +15 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +37 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +8 -0
- package/dist/particles/renderingModules/UIRenderingModule.js +9 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingTexture.js +26 -0
- package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingTexture.glsl.js +3 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +9 -0
- package/dist/particles/spawnModules/UISpawnModule.js +9 -0
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +21 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +46 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +47 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +60 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +64 -0
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +27 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +62 -0
- package/package.json +27 -36
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UICustomConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIDummy/UIDummy.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIElement/UIElement.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Interfaces.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Measuring.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Rendering.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.d.ts +0 -0
- /package/dist/{index.d.ts → core/index.d.ts} +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIExpression.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIOrientation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIPriority.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIRelation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UITransparencyMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIArea.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaCircle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaPolygon.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRoundedRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/asserts.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/canvas.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/computeTransform.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunction.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicy.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCover.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCross.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFit.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyNone.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/webglCapabilities.d.ts +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { MathUtils } from 'three';
|
|
2
|
+
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../core/miscellaneous/asserts.js';
|
|
3
|
+
import { resolveUIRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, generateNoise2D } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { UIBehaviorModule } from './UIBehaviorModule.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Applies noise-based acceleration to particles.
|
|
8
|
+
*
|
|
9
|
+
* Uses 2D noise based on particle position. Higher scale means finer noise detail.
|
|
10
|
+
*/
|
|
11
|
+
class UIBehaviorVelocityNoise extends UIBehaviorModule {
|
|
12
|
+
/**
|
|
13
|
+
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
14
|
+
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
15
|
+
*/
|
|
16
|
+
constructor(scale = 100, strength = 500) {
|
|
17
|
+
super();
|
|
18
|
+
/** @internal */
|
|
19
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
+
this._private_scaleInternal = resolveUIRangeConfig(scale);
|
|
21
|
+
assertValidPositiveNumber(this._private_scaleInternal.min, `UIBehaviorVelocityNoise.constructor.scale.min`);
|
|
22
|
+
assertValidPositiveNumber(this._private_scaleInternal.max, `UIBehaviorVelocityNoise.constructor.scale.max`);
|
|
23
|
+
this._private_strengthInternal = resolveUIRangeConfig(strength);
|
|
24
|
+
assertValidNonNegativeNumber(this._private_strengthInternal.min, `UIBehaviorVelocityNoise.constructor.strength.min`);
|
|
25
|
+
assertValidNonNegativeNumber(this._private_strengthInternal.max, `UIBehaviorVelocityNoise.constructor.strength.max`);
|
|
26
|
+
}
|
|
27
|
+
/** Noise frequency range */
|
|
28
|
+
get scale() {
|
|
29
|
+
return this._private_scaleInternal;
|
|
30
|
+
}
|
|
31
|
+
/** Force multiplier range */
|
|
32
|
+
get strength() {
|
|
33
|
+
return this._private_strengthInternal;
|
|
34
|
+
}
|
|
35
|
+
/** Noise frequency range */
|
|
36
|
+
set scale(value) {
|
|
37
|
+
this._private_scaleInternal = resolveUIRangeConfig(value);
|
|
38
|
+
assertValidPositiveNumber(this._private_scaleInternal.min, `UIBehaviorVelocityNoise.scale.min`);
|
|
39
|
+
assertValidPositiveNumber(this._private_scaleInternal.max, `UIBehaviorVelocityNoise.scale.max`);
|
|
40
|
+
}
|
|
41
|
+
/** Force multiplier range */
|
|
42
|
+
set strength(value) {
|
|
43
|
+
this._private_strengthInternal = resolveUIRangeConfig(value);
|
|
44
|
+
assertValidNonNegativeNumber(this._private_strengthInternal.min, `UIBehaviorVelocityNoise.strength.min`);
|
|
45
|
+
assertValidNonNegativeNumber(this._private_strengthInternal.max, `UIBehaviorVelocityNoise.strength.max`);
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
update(properties, instanceCount, deltaTime) {
|
|
49
|
+
const { builtin } = properties;
|
|
50
|
+
const { array, itemSize } = builtin;
|
|
51
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
52
|
+
const itemOffset = i * itemSize;
|
|
53
|
+
const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
54
|
+
const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
55
|
+
// Constant over the life of a particle but different for each particle
|
|
56
|
+
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
57
|
+
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
58
|
+
const noiseX = generateNoise2D(x * scale, y * scale);
|
|
59
|
+
const noiseY = generateNoise2D((x + 100) * scale, (y + 100) * scale);
|
|
60
|
+
// Constant over the life of a particle but different for each particle
|
|
61
|
+
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_D];
|
|
62
|
+
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
63
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
|
|
64
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += noiseY * strength * deltaTime;
|
|
65
|
+
}
|
|
66
|
+
builtin.needsUpdate = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { UIBehaviorVelocityNoise };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UIMode } from "../../core";
|
|
2
|
+
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal";
|
|
3
|
+
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
4
|
+
expectedCapacity: number;
|
|
5
|
+
capacityStep: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UIEmitterPlayOptions {
|
|
8
|
+
duration: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function ignoreInput(): boolean;
|
|
11
|
+
export type UIEmitterMode = UIMode.HIDDEN | UIMode.VISIBLE;
|
|
12
|
+
export declare const EMITTER_DEFAULT_MODE: UIEmitterMode;
|
|
13
|
+
export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
14
|
+
export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
15
|
+
export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UIMode } from '../../core/miscellaneous/UIMode.js';
|
|
2
|
+
|
|
3
|
+
function ignoreInput() {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const EMITTER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
7
|
+
const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
8
|
+
const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
9
|
+
const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
10
|
+
|
|
11
|
+
export { EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_MODE, ignoreInput };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { UILayer } from "../../core";
|
|
2
|
+
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor";
|
|
3
|
+
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal";
|
|
4
|
+
import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule";
|
|
5
|
+
import type { UIRenderingModule } from "../renderingModules/UIRenderingModule";
|
|
6
|
+
import type { UISpawnModule } from "../spawnModules/UISpawnModule";
|
|
7
|
+
import { type UIEmitterMode, type UIEmitterPlayOptions } from "./UIEmitter.Internal";
|
|
8
|
+
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
9
|
+
mode: UIEmitterMode;
|
|
10
|
+
expectedCapacity: number;
|
|
11
|
+
capacityStep: number;
|
|
12
|
+
automaticallyDestroyModules: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Particle emitter element.
|
|
16
|
+
*
|
|
17
|
+
* Spawns, updates, and renders particles using modular spawn/behavior/rendering pipeline.
|
|
18
|
+
*/
|
|
19
|
+
export declare class UIEmitter extends UIAnchor {
|
|
20
|
+
private readonly spawnSequence;
|
|
21
|
+
private readonly behaviorSequence;
|
|
22
|
+
private readonly renderingSequence;
|
|
23
|
+
/** Whether to call destroy() on all modules when emitter is destroyed */
|
|
24
|
+
automaticallyDestroyModules: boolean;
|
|
25
|
+
private readonly mesh;
|
|
26
|
+
private readonly catcherHandler;
|
|
27
|
+
private emissionRate;
|
|
28
|
+
private emissionAccumulator;
|
|
29
|
+
private emissionDuration;
|
|
30
|
+
private emissionElapsed;
|
|
31
|
+
private modeInternal;
|
|
32
|
+
/**
|
|
33
|
+
* @param layer - Layer containing this emitter
|
|
34
|
+
* @param spawnSequence - Modules that initialize new particles
|
|
35
|
+
* @param behaviorSequence - Modules that update particles each frame
|
|
36
|
+
* @param renderingSequence - Modules that control particle appearance
|
|
37
|
+
* @param options - Configuration options
|
|
38
|
+
*/
|
|
39
|
+
constructor(layer: UILayer, spawnSequence: UISpawnModule[], behaviorSequence: readonly UIBehaviorModule[], renderingSequence: readonly UIRenderingModule[], options?: Partial<UIEmitterOptions>);
|
|
40
|
+
/** Visibility mode */
|
|
41
|
+
get mode(): UIEmitterMode;
|
|
42
|
+
/** Rendering order. Higher values draw on top */
|
|
43
|
+
get zIndex(): number;
|
|
44
|
+
/** Visibility mode */
|
|
45
|
+
set mode(value: UIEmitterMode);
|
|
46
|
+
/** Rendering order. Higher values draw on top */
|
|
47
|
+
set zIndex(value: number);
|
|
48
|
+
/** Removes emitter and optionally destroys modules */
|
|
49
|
+
destroy(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Spawns a specific number of particles immediately.
|
|
52
|
+
*
|
|
53
|
+
* @param count - Number of particles to create
|
|
54
|
+
*/
|
|
55
|
+
burst(count: number): void;
|
|
56
|
+
/** Removes all active particles */
|
|
57
|
+
clear(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Starts continuous particle emission.
|
|
60
|
+
*
|
|
61
|
+
* @param rate - Particles per second
|
|
62
|
+
* @param options - Emission duration and other settings
|
|
63
|
+
*/
|
|
64
|
+
play(rate: number, options?: Partial<UIEmitterPlayOptions>): void;
|
|
65
|
+
/** Stops continuous particle emission */
|
|
66
|
+
stop(): void;
|
|
67
|
+
private readonly onRendering;
|
|
68
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Vector2 } from 'three';
|
|
2
|
+
import { UIAnchor } from '../../core/elements/UIAnchor/UIAnchor.js';
|
|
3
|
+
import { resolveGLSLTypeInfo } from '../../core/miscellaneous/generic-plane/shared.js';
|
|
4
|
+
import { isUIModeVisible } from '../../core/miscellaneous/UIMode.js';
|
|
5
|
+
import { UIInstancedParticle } from '../instancedParticle/UIInstancedParticle.js';
|
|
6
|
+
import { collectProperties, collectUniforms } from '../instancedParticle/UIInstancedParticle.Internal.js';
|
|
7
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_RANDOM_E, BUILTIN_OFFSET_RANDOM_F } from '../miscellaneous/miscellaneous.js';
|
|
8
|
+
import { ignoreInput, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_MODE } from './UIEmitter.Internal.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Particle emitter element.
|
|
12
|
+
*
|
|
13
|
+
* Spawns, updates, and renders particles using modular spawn/behavior/rendering pipeline.
|
|
14
|
+
*/
|
|
15
|
+
class UIEmitter extends UIAnchor {
|
|
16
|
+
/**
|
|
17
|
+
* @param layer - Layer containing this emitter
|
|
18
|
+
* @param spawnSequence - Modules that initialize new particles
|
|
19
|
+
* @param behaviorSequence - Modules that update particles each frame
|
|
20
|
+
* @param renderingSequence - Modules that control particle appearance
|
|
21
|
+
* @param options - Configuration options
|
|
22
|
+
*/
|
|
23
|
+
constructor(layer, _private_spawnSequence, _private_behaviorSequence, _private_renderingSequence, options = {}) {
|
|
24
|
+
super(layer, options);
|
|
25
|
+
this._private_spawnSequence = _private_spawnSequence;
|
|
26
|
+
this._private_behaviorSequence = _private_behaviorSequence;
|
|
27
|
+
this._private_renderingSequence = _private_renderingSequence;
|
|
28
|
+
this._private_emissionRate = 0;
|
|
29
|
+
this._private_emissionAccumulator = 0;
|
|
30
|
+
this._private_emissionDuration = Infinity;
|
|
31
|
+
this._private_emissionElapsed = 0;
|
|
32
|
+
this._private_onRendering = (renderer, deltaTime) => {
|
|
33
|
+
{
|
|
34
|
+
const { builtin } = this._private_mesh.propertyBuffers;
|
|
35
|
+
const { array, itemSize } = builtin;
|
|
36
|
+
for (let i = 0; i < this._private_mesh.instanceCount; i++) {
|
|
37
|
+
array[i * itemSize + BUILTIN_OFFSET_AGE] += deltaTime;
|
|
38
|
+
}
|
|
39
|
+
builtin.needsUpdate = true;
|
|
40
|
+
this._private_mesh.removeDeadParticles();
|
|
41
|
+
}
|
|
42
|
+
if (this._private_emissionRate > 0) {
|
|
43
|
+
this._private_emissionElapsed += deltaTime;
|
|
44
|
+
if (this._private_emissionElapsed >= this._private_emissionDuration) {
|
|
45
|
+
this.stop();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this._private_emissionAccumulator += this._private_emissionRate * deltaTime;
|
|
49
|
+
const particlesToSpawn = Math.floor(this._private_emissionAccumulator);
|
|
50
|
+
if (particlesToSpawn > 0) {
|
|
51
|
+
this.burst(particlesToSpawn);
|
|
52
|
+
this._private_emissionAccumulator -= particlesToSpawn;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (this._private_mesh.instanceCount === 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._private_mesh.renderOrder = this.zIndex;
|
|
60
|
+
this._private_mesh.setOrigin(this.x, this.y);
|
|
61
|
+
{
|
|
62
|
+
const { propertyBuffers, instanceCount } = this._private_mesh;
|
|
63
|
+
for (const module of this._private_behaviorSequence) {
|
|
64
|
+
module.update(propertyBuffers, instanceCount, deltaTime);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const { builtin } = this._private_mesh.propertyBuffers;
|
|
68
|
+
const { array, itemSize } = builtin;
|
|
69
|
+
{
|
|
70
|
+
for (let i = 0; i < this._private_mesh.instanceCount; i++) {
|
|
71
|
+
const itemOffset = i * itemSize;
|
|
72
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] +=
|
|
73
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] * deltaTime;
|
|
74
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] +=
|
|
75
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] * deltaTime;
|
|
76
|
+
}
|
|
77
|
+
builtin.needsUpdate = true;
|
|
78
|
+
}
|
|
79
|
+
{
|
|
80
|
+
for (let i = 0; i < this._private_mesh.instanceCount; i++) {
|
|
81
|
+
const itemOffset = i * itemSize;
|
|
82
|
+
array[itemOffset + BUILTIN_OFFSET_ROTATION] +=
|
|
83
|
+
array[itemOffset + BUILTIN_OFFSET_TORQUE] * deltaTime;
|
|
84
|
+
}
|
|
85
|
+
builtin.needsUpdate = true;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const collectedProperties = {
|
|
89
|
+
builtin: resolveGLSLTypeInfo("Matrix4"),
|
|
90
|
+
// 0, 1 positionX, positionY
|
|
91
|
+
// 2, 3 velocityX, velocityY
|
|
92
|
+
// 4, 5 scaleX, scaleY
|
|
93
|
+
// 6, 7 rotation, torque
|
|
94
|
+
// 8, 9 lifetime, age
|
|
95
|
+
// 10, 11, 12 randomX, randomY, randomZ
|
|
96
|
+
// 13, 14, 16 reservedX, reservedY, reservedZ
|
|
97
|
+
};
|
|
98
|
+
collectProperties(collectedProperties, _private_spawnSequence, "UIEmitter.constructor.spawnSequence:");
|
|
99
|
+
collectProperties(collectedProperties, _private_behaviorSequence, "UIEmitter.constructor.behaviorSequence");
|
|
100
|
+
collectProperties(collectedProperties, _private_renderingSequence, "UIEmitter.constructor.renderingSequence");
|
|
101
|
+
const collectedUniforms = {
|
|
102
|
+
origin: { value: new Vector2(), glslTypeInfo: resolveGLSLTypeInfo("Vector2") },
|
|
103
|
+
};
|
|
104
|
+
collectUniforms(collectedUniforms, _private_renderingSequence, "UIEmitter.constructor.renderingSequence");
|
|
105
|
+
const zIndex = 0;
|
|
106
|
+
this._private_catcherHandler = this.layer.inputWrapper.createInputCatcher(ignoreInput, ignoreInput, ignoreInput, zIndex);
|
|
107
|
+
this._private_mesh = new UIInstancedParticle(this._private_renderingSequence.map((module) => module.source), collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP);
|
|
108
|
+
this._private_mesh.renderOrder = zIndex;
|
|
109
|
+
this.layer.signalRendering.on(this._private_onRendering);
|
|
110
|
+
this.layer.sceneWrapper.insertCustomObject(this._private_mesh);
|
|
111
|
+
this.automaticallyDestroyModules =
|
|
112
|
+
options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
|
|
113
|
+
this._private_modeInternal = options.mode ?? EMITTER_DEFAULT_MODE;
|
|
114
|
+
}
|
|
115
|
+
/** Visibility mode */
|
|
116
|
+
get mode() {
|
|
117
|
+
return this._private_modeInternal;
|
|
118
|
+
}
|
|
119
|
+
/** Rendering order. Higher values draw on top */
|
|
120
|
+
get zIndex() {
|
|
121
|
+
return this.layer.inputWrapper.getZIndex(this._private_catcherHandler);
|
|
122
|
+
}
|
|
123
|
+
/** Visibility mode */
|
|
124
|
+
set mode(value) {
|
|
125
|
+
if (this._private_modeInternal !== value) {
|
|
126
|
+
this._private_modeInternal = value;
|
|
127
|
+
this._private_mesh.visible = isUIModeVisible(value);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Rendering order. Higher values draw on top */
|
|
131
|
+
set zIndex(value) {
|
|
132
|
+
this.layer.inputWrapper.setZIndex(this._private_catcherHandler, value);
|
|
133
|
+
}
|
|
134
|
+
/** Removes emitter and optionally destroys modules */
|
|
135
|
+
destroy() {
|
|
136
|
+
this.layer.signalRendering.off(this._private_onRendering);
|
|
137
|
+
this.layer.sceneWrapper.removeCustomObject(this._private_mesh);
|
|
138
|
+
if (this.automaticallyDestroyModules) {
|
|
139
|
+
for (const module of this._private_spawnSequence) {
|
|
140
|
+
module.destroy?.();
|
|
141
|
+
}
|
|
142
|
+
for (const module of this._private_behaviorSequence) {
|
|
143
|
+
module.destroy?.();
|
|
144
|
+
}
|
|
145
|
+
for (const module of this._private_renderingSequence) {
|
|
146
|
+
module.destroy?.();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
super.destroy();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Spawns a specific number of particles immediately.
|
|
153
|
+
*
|
|
154
|
+
* @param count - Number of particles to create
|
|
155
|
+
*/
|
|
156
|
+
burst(count) {
|
|
157
|
+
const instanceBegin = this._private_mesh.instanceCount;
|
|
158
|
+
this._private_mesh.createInstances(count);
|
|
159
|
+
const instanceEnd = this._private_mesh.instanceCount;
|
|
160
|
+
{
|
|
161
|
+
const { builtin } = this._private_mesh.propertyBuffers;
|
|
162
|
+
const { array, itemSize } = builtin;
|
|
163
|
+
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
164
|
+
const itemOffset = i * itemSize;
|
|
165
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_A] = Math.random();
|
|
166
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_B] = Math.random();
|
|
167
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_C] = Math.random();
|
|
168
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_D] = Math.random();
|
|
169
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_E] = Math.random();
|
|
170
|
+
array[itemOffset + BUILTIN_OFFSET_RANDOM_F] = Math.random();
|
|
171
|
+
}
|
|
172
|
+
builtin.needsUpdate = true;
|
|
173
|
+
}
|
|
174
|
+
for (const spawnModule of this._private_spawnSequence) {
|
|
175
|
+
spawnModule.spawn(this._private_mesh.propertyBuffers, instanceBegin, instanceEnd);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Removes all active particles */
|
|
179
|
+
clear() {
|
|
180
|
+
this._private_mesh.drop();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Starts continuous particle emission.
|
|
184
|
+
*
|
|
185
|
+
* @param rate - Particles per second
|
|
186
|
+
* @param options - Emission duration and other settings
|
|
187
|
+
*/
|
|
188
|
+
play(rate, options = {}) {
|
|
189
|
+
this._private_emissionRate = rate;
|
|
190
|
+
this._private_emissionAccumulator = 0;
|
|
191
|
+
this._private_emissionDuration = options.duration ?? Infinity;
|
|
192
|
+
this._private_emissionElapsed = 0;
|
|
193
|
+
}
|
|
194
|
+
/** Stops continuous particle emission */
|
|
195
|
+
stop() {
|
|
196
|
+
this._private_emissionRate = 0;
|
|
197
|
+
this._private_emissionAccumulator = 0;
|
|
198
|
+
this._private_emissionDuration = Infinity;
|
|
199
|
+
this._private_emissionElapsed = 0;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { UIEmitter };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity";
|
|
2
|
+
export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity";
|
|
3
|
+
export { UIBehaviorScaleOverLife } from "./behaviorModules/UIBehaviorScaleOverLife";
|
|
4
|
+
export { UIBehaviorTorqueDamping } from "./behaviorModules/UIBehaviorTorqueDamping";
|
|
5
|
+
export { UIBehaviorTorqueNoise } from "./behaviorModules/UIBehaviorTorqueNoise";
|
|
6
|
+
export { UIBehaviorVelocityDamping } from "./behaviorModules/UIBehaviorVelocityDamping";
|
|
7
|
+
export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoise";
|
|
8
|
+
export { UIEmitter } from "./elements/UIEmitter";
|
|
9
|
+
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife";
|
|
10
|
+
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity";
|
|
11
|
+
export { UITextureRenderingModule } from "./renderingModules/UIRenderingTexture";
|
|
12
|
+
export { UISpawnOffset } from "./spawnModules/UISpawnOffset";
|
|
13
|
+
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime";
|
|
14
|
+
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation";
|
|
15
|
+
export { UISpawnRandomScale } from "./spawnModules/UISpawnRandomScale";
|
|
16
|
+
export { UISpawnRandomTorque } from "./spawnModules/UISpawnRandomTorque";
|
|
17
|
+
export { UISpawnRandomVelocity } from "./spawnModules/UISpawnRandomVelocity";
|
|
18
|
+
export { UISpawnRectangle } from "./spawnModules/UISpawnRectangle";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { UIBehaviorDirectionalGravity } from './behaviorModules/UIBehaviorDirectionalGravity.js';
|
|
2
|
+
export { UIBehaviorPointGravity } from './behaviorModules/UIBehaviorPointGravity.js';
|
|
3
|
+
export { UIBehaviorScaleOverLife } from './behaviorModules/UIBehaviorScaleOverLife.js';
|
|
4
|
+
export { UIBehaviorTorqueDamping } from './behaviorModules/UIBehaviorTorqueDamping.js';
|
|
5
|
+
export { UIBehaviorTorqueNoise } from './behaviorModules/UIBehaviorTorqueNoise.js';
|
|
6
|
+
export { UIBehaviorVelocityDamping } from './behaviorModules/UIBehaviorVelocityDamping.js';
|
|
7
|
+
export { UIBehaviorVelocityNoise } from './behaviorModules/UIBehaviorVelocityNoise.js';
|
|
8
|
+
export { UIEmitter } from './elements/UIEmitter.js';
|
|
9
|
+
export { UIRenderingColorOverLife } from './renderingModules/UIRenderingColorOverLife.js';
|
|
10
|
+
export { UIRenderingColorOverVelocity } from './renderingModules/UIRenderingColorOverVelocity.js';
|
|
11
|
+
export { UITextureRenderingModule } from './renderingModules/UIRenderingTexture.js';
|
|
12
|
+
export { UISpawnOffset } from './spawnModules/UISpawnOffset.js';
|
|
13
|
+
export { UISpawnRandomLifetime } from './spawnModules/UISpawnRandomLifetime.js';
|
|
14
|
+
export { UISpawnRandomRotation } from './spawnModules/UISpawnRandomRotation.js';
|
|
15
|
+
export { UISpawnRandomScale } from './spawnModules/UISpawnRandomScale.js';
|
|
16
|
+
export { UISpawnRandomTorque } from './spawnModules/UISpawnRandomTorque.js';
|
|
17
|
+
export { UISpawnRandomVelocity } from './spawnModules/UISpawnRandomVelocity.js';
|
|
18
|
+
export { UISpawnRectangle } from './spawnModules/UISpawnRectangle.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InstancedBufferGeometry, ShaderMaterial } from "three";
|
|
2
|
+
import type { GLProperty, GLTypeInfo } from "../../core/miscellaneous/generic-plane/shared";
|
|
3
|
+
import { type UIProperty, type UIPropertyName } from "../../core/miscellaneous/generic-plane/shared";
|
|
4
|
+
export declare const INSTANCED_PARTICLE_GEOMETRY: InstancedBufferGeometry;
|
|
5
|
+
export declare function collectProperties(keeper: Record<string, GLTypeInfo>, modules: readonly {
|
|
6
|
+
requiredProperties?: Record<string, UIPropertyName>;
|
|
7
|
+
}[], debugContext: string): void;
|
|
8
|
+
export declare function collectUniforms(keeper: Record<string, GLProperty>, modules: readonly {
|
|
9
|
+
requiredUniforms: Record<string, UIProperty>;
|
|
10
|
+
}[], debugContext: string): void;
|
|
11
|
+
export declare function buildParticleVertexShader(uniformDeclarations: string[], attributeDeclarations: string[], varyingDeclarations: string[], vertexAssignments: string[]): string;
|
|
12
|
+
export declare function buildParticleFragmentShader(uniformDeclarations: string[], varyingDeclarations: string[], sources: string[]): string;
|
|
13
|
+
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>): ShaderMaterial;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { InstancedBufferGeometry, BufferAttribute, Float32BufferAttribute, ShaderMaterial } from 'three';
|
|
2
|
+
import { resolveGLSLTypeInfo } from '../../core/miscellaneous/generic-plane/shared.js';
|
|
3
|
+
import { checkSRGBSupport } from '../../core/miscellaneous/webglCapabilities.js';
|
|
4
|
+
import { UIColor } from '../../core/miscellaneous/color/UIColor.js';
|
|
5
|
+
|
|
6
|
+
const INSTANCED_PARTICLE_GEOMETRY = (() => {
|
|
7
|
+
const geometry = new InstancedBufferGeometry();
|
|
8
|
+
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
|
|
9
|
+
geometry.setIndex(new BufferAttribute(indices, 1));
|
|
10
|
+
const positions = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
|
|
11
|
+
geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
|
|
12
|
+
const uvs = new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]);
|
|
13
|
+
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
14
|
+
return geometry;
|
|
15
|
+
})();
|
|
16
|
+
function collectProperties(keeper, modules, debugContext) {
|
|
17
|
+
for (const module of modules) {
|
|
18
|
+
if (module.requiredProperties === undefined) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
for (const key in module.requiredProperties) {
|
|
22
|
+
const existingTypeInfo = keeper[key];
|
|
23
|
+
const newTypeInfo = resolveGLSLTypeInfo(module.requiredProperties[key]);
|
|
24
|
+
if (existingTypeInfo === undefined) {
|
|
25
|
+
keeper[key] = newTypeInfo;
|
|
26
|
+
}
|
|
27
|
+
else if (existingTypeInfo.glslTypeName !== newTypeInfo.glslTypeName) {
|
|
28
|
+
throw new Error(`${debugContext}: property conflict for "${key}"`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function collectUniforms(keeper, modules, debugContext) {
|
|
34
|
+
for (const module of modules) {
|
|
35
|
+
for (const key in module.requiredUniforms) {
|
|
36
|
+
const value = module.requiredUniforms[key];
|
|
37
|
+
const existingGLProperty = keeper[key];
|
|
38
|
+
const newPropertyTypeInfo = resolveGLSLTypeInfo(value);
|
|
39
|
+
if (existingGLProperty === undefined) {
|
|
40
|
+
keeper[key] = { value, glslTypeInfo: newPropertyTypeInfo };
|
|
41
|
+
}
|
|
42
|
+
else if (existingGLProperty.glslTypeInfo.glslTypeName !== newPropertyTypeInfo.glslTypeName) {
|
|
43
|
+
throw new Error(`${debugContext}: property conflict for "${key}"`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function buildParticleVertexShader(uniformDeclarations, attributeDeclarations, varyingDeclarations, vertexAssignments) {
|
|
49
|
+
return `
|
|
50
|
+
|
|
51
|
+
#define PARTICLE_POSITION_X a_builtin[0][0]
|
|
52
|
+
#define PARTICLE_POSITION_Y a_builtin[0][1]
|
|
53
|
+
|
|
54
|
+
#define PARTICLE_VELOCITY_X a_builtin[0][2]
|
|
55
|
+
#define PARTICLE_VELOCITY_Y a_builtin[0][3]
|
|
56
|
+
|
|
57
|
+
#define PARTICLE_SCALE_X a_builtin[1][0]
|
|
58
|
+
#define PARTICLE_SCALE_Y a_builtin[1][1]
|
|
59
|
+
|
|
60
|
+
#define PARTICLE_ROTATION a_builtin[1][2]
|
|
61
|
+
#define PARTICLE_TORQUE a_builtin[1][3]
|
|
62
|
+
|
|
63
|
+
#define PARTICLE_LIFETIME a_builtin[2][0]
|
|
64
|
+
#define PARTICLE_AGE a_builtin[2][1]
|
|
65
|
+
|
|
66
|
+
#define PARTICLE_RANDOM_A a_builtin[2][2]
|
|
67
|
+
#define PARTICLE_RANDOM_B a_builtin[2][3]
|
|
68
|
+
#define PARTICLE_RANDOM_C a_builtin[3][0]
|
|
69
|
+
#define PARTICLE_RANDOM_D a_builtin[3][1]
|
|
70
|
+
#define PARTICLE_RANDOM_E a_builtin[3][2]
|
|
71
|
+
#define PARTICLE_RANDOM_F a_builtin[3][3]
|
|
72
|
+
|
|
73
|
+
// User attributes
|
|
74
|
+
${attributeDeclarations.join("\n")}
|
|
75
|
+
|
|
76
|
+
// Uniforms
|
|
77
|
+
${uniformDeclarations.join("\n")}
|
|
78
|
+
|
|
79
|
+
// Builtin varyings
|
|
80
|
+
varying vec2 p_uv;
|
|
81
|
+
|
|
82
|
+
// User varyings
|
|
83
|
+
${varyingDeclarations.join("\n")}
|
|
84
|
+
|
|
85
|
+
void main() {
|
|
86
|
+
${vertexAssignments.join("\n")}
|
|
87
|
+
|
|
88
|
+
p_uv = uv;
|
|
89
|
+
|
|
90
|
+
vec2 transformedPosition = position.xy;
|
|
91
|
+
transformedPosition.x *= PARTICLE_SCALE_X;
|
|
92
|
+
transformedPosition.y *= PARTICLE_SCALE_Y;
|
|
93
|
+
|
|
94
|
+
float cosR = cos(PARTICLE_ROTATION);
|
|
95
|
+
float sinR = sin(PARTICLE_ROTATION);
|
|
96
|
+
|
|
97
|
+
transformedPosition = vec2(
|
|
98
|
+
transformedPosition.x * cosR - transformedPosition.y * sinR,
|
|
99
|
+
transformedPosition.x * sinR + transformedPosition.y * cosR
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
transformedPosition.x += PARTICLE_POSITION_X;
|
|
103
|
+
transformedPosition.y += PARTICLE_POSITION_Y;
|
|
104
|
+
|
|
105
|
+
transformedPosition += p_origin;
|
|
106
|
+
gl_Position = projectionMatrix * vec4(transformedPosition, position.z, 1.0);
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
function buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, sources) {
|
|
111
|
+
const renamedSources = sources.map((source, index) => {
|
|
112
|
+
return source.replace(/vec4\s+draw\s*\(\s*\)/g, `vec4 draw${index}()`);
|
|
113
|
+
});
|
|
114
|
+
let drawCalls = "";
|
|
115
|
+
for (let i = 0; i < sources.length; i++) {
|
|
116
|
+
drawCalls += i !== 0 ? " * " : "";
|
|
117
|
+
drawCalls += `draw${i}()`;
|
|
118
|
+
}
|
|
119
|
+
return `
|
|
120
|
+
// Defines
|
|
121
|
+
#define PI 3.14159265359
|
|
122
|
+
#define SRGB_SUPPORTED ${checkSRGBSupport() ? "1" : "0"}
|
|
123
|
+
|
|
124
|
+
#define PARTICLE_POSITION_X p_builtin[0][0]
|
|
125
|
+
#define PARTICLE_POSITION_Y p_builtin[0][1]
|
|
126
|
+
|
|
127
|
+
#define PARTICLE_VELOCITY_X p_builtin[0][2]
|
|
128
|
+
#define PARTICLE_VELOCITY_Y p_builtin[0][3]
|
|
129
|
+
|
|
130
|
+
#define PARTICLE_SCALE_X p_builtin[1][0]
|
|
131
|
+
#define PARTICLE_SCALE_Y p_builtin[1][1]
|
|
132
|
+
|
|
133
|
+
#define PARTICLE_ROTATION p_builtin[1][2]
|
|
134
|
+
#define PARTICLE_TORQUE p_builtin[1][3]
|
|
135
|
+
|
|
136
|
+
#define PARTICLE_LIFETIME p_builtin[2][0]
|
|
137
|
+
#define PARTICLE_AGE p_builtin[2][1]
|
|
138
|
+
|
|
139
|
+
#define PARTICLE_RANDOM_A p_builtin[2][2]
|
|
140
|
+
#define PARTICLE_RANDOM_B p_builtin[2][3]
|
|
141
|
+
#define PARTICLE_RANDOM_C p_builtin[3][0]
|
|
142
|
+
#define PARTICLE_RANDOM_D p_builtin[3][1]
|
|
143
|
+
#define PARTICLE_RANDOM_E p_builtin[3][2]
|
|
144
|
+
#define PARTICLE_RANDOM_F p_builtin[3][3]
|
|
145
|
+
|
|
146
|
+
// Uniforms
|
|
147
|
+
${uniformDeclarations.join("\n")}
|
|
148
|
+
|
|
149
|
+
// Builtin varyings
|
|
150
|
+
varying vec2 p_uv;
|
|
151
|
+
|
|
152
|
+
// User varyings
|
|
153
|
+
${varyingDeclarations.join("\n")}
|
|
154
|
+
|
|
155
|
+
#include <alphahash_pars_fragment>
|
|
156
|
+
|
|
157
|
+
// sRGB decode helper
|
|
158
|
+
vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {
|
|
159
|
+
#if SRGB_SUPPORTED
|
|
160
|
+
return texture2D(textureSampler, uv);
|
|
161
|
+
#else
|
|
162
|
+
vec4 textureValue = texture2D(textureSampler, uv);
|
|
163
|
+
return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);
|
|
164
|
+
#endif
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Source must define vec4 draw() function
|
|
168
|
+
${renamedSources.join("\n")}
|
|
169
|
+
|
|
170
|
+
void main() {
|
|
171
|
+
vec4 diffuseColor = ${drawCalls};
|
|
172
|
+
if (diffuseColor.a < 0.0035) {
|
|
173
|
+
discard;
|
|
174
|
+
}
|
|
175
|
+
#ifdef USE_ALPHAHASH
|
|
176
|
+
if (diffuseColor.a < getAlphaHashThreshold(p_position)) {
|
|
177
|
+
discard;
|
|
178
|
+
}
|
|
179
|
+
#endif
|
|
180
|
+
gl_FragColor = linearToOutputTexel(diffuseColor);
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
function buildParticleMaterial(sources, uniformProperties, varyingProperties) {
|
|
185
|
+
const uniforms = {};
|
|
186
|
+
const uniformDeclarations = [];
|
|
187
|
+
const attributeDeclarations = [];
|
|
188
|
+
const varyingDeclarations = [];
|
|
189
|
+
const vertexAssignments = [];
|
|
190
|
+
for (const name in uniformProperties) {
|
|
191
|
+
const { value, glslTypeInfo } = uniformProperties[name];
|
|
192
|
+
uniforms[`p_${name}`] = { value: value instanceof UIColor ? value.toGLSLColor() : value };
|
|
193
|
+
uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
|
|
194
|
+
}
|
|
195
|
+
for (const name in varyingProperties) {
|
|
196
|
+
const { glslTypeName } = varyingProperties[name];
|
|
197
|
+
attributeDeclarations.push(`attribute ${glslTypeName} a_${name};`);
|
|
198
|
+
varyingDeclarations.push(`varying ${glslTypeName} p_${name};`);
|
|
199
|
+
vertexAssignments.push(`p_${name} = a_${name};`);
|
|
200
|
+
}
|
|
201
|
+
return new ShaderMaterial({
|
|
202
|
+
uniforms,
|
|
203
|
+
vertexShader: buildParticleVertexShader(uniformDeclarations, attributeDeclarations, varyingDeclarations, vertexAssignments),
|
|
204
|
+
fragmentShader: buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, sources),
|
|
205
|
+
transparent: true,
|
|
206
|
+
depthWrite: false,
|
|
207
|
+
depthTest: true,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { INSTANCED_PARTICLE_GEOMETRY, buildParticleFragmentShader, buildParticleMaterial, buildParticleVertexShader, collectProperties, collectUniforms };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InstancedBufferAttribute, Mesh } from "three";
|
|
2
|
+
import { type GLProperty, type GLTypeInfo } from "../../core/miscellaneous/generic-plane/shared";
|
|
3
|
+
export declare class UIInstancedParticle extends Mesh {
|
|
4
|
+
private readonly capacityStep;
|
|
5
|
+
readonly propertyBuffers: Record<string, InstancedBufferAttribute>;
|
|
6
|
+
private readonly instancedGeometry;
|
|
7
|
+
private readonly shaderMaterial;
|
|
8
|
+
private capacity;
|
|
9
|
+
constructor(sources: string[], uniforms: Record<string, GLProperty>, varyings: Record<string, GLTypeInfo>, expectedCapacity: number, capacityStep: number);
|
|
10
|
+
get instanceCount(): number;
|
|
11
|
+
createInstances(count: number): void;
|
|
12
|
+
setOrigin(x: number, y: number): void;
|
|
13
|
+
removeDeadParticles(): void;
|
|
14
|
+
drop(): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
private ensureCapacity;
|
|
17
|
+
}
|