laymur 0.17.0 → 0.17.2
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 +5 -0
- package/{src/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.ts → dist/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts} +2 -3
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +22 -0
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
- package/dist/core/constraints/UIConstraint.d.ts +12 -0
- package/dist/core/constraints/UIConstraint.js +11 -0
- package/dist/core/constraints/UICustomConstraint.d.ts +28 -0
- package/dist/core/constraints/UICustomConstraint.js +37 -0
- package/{src/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.ts → dist/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts} +2 -3
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +20 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +36 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +14 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +44 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
- package/{src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.ts → dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts} +2 -3
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +22 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
- package/{src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.ts → dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts} +8 -9
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +43 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +32 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +14 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +44 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
- package/{src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.ts → dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts} +2 -3
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +22 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
- package/{src/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.ts → dist/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts} +2 -3
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +20 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +64 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +46 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +13 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.d.ts +29 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +13 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.d.ts +29 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.d.ts +12 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
- package/dist/core/elements/UIAnchor/UIAnchor.d.ts +32 -0
- package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +27 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +77 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +30 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +82 -0
- package/dist/core/elements/UIDummy/UIDummy.js +173 -0
- package/{src/core/elements/UIElement/UIElement.Internal.ts → dist/core/elements/UIElement/UIElement.Internal.d.ts} +5 -7
- package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
- package/dist/core/elements/UIElement/UIElement.d.ts +38 -0
- package/dist/core/elements/UIElement/UIElement.js +74 -0
- package/{src/core/elements/UIGraphics/UIGraphics.Internal.ts → dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts} +5 -7
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
- package/dist/core/elements/UIGraphics/UIGraphics.d.ts +51 -0
- package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
- package/{src/core/elements/UIImage/UIImage.Internal.ts → dist/core/elements/UIImage/UIImage.Internal.d.ts} +2 -3
- package/dist/core/elements/UIImage/UIImage.d.ts +32 -0
- package/dist/core/elements/UIImage/UIImage.js +85 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.d.ts +23 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
- package/dist/core/elements/UINineSlice/UINineSlice.d.ts +60 -0
- package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.d.ts +14 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
- package/dist/core/elements/UIProgress/UIProgress.d.ts +45 -0
- package/dist/core/elements/UIProgress/UIProgress.js +165 -0
- package/dist/core/elements/UIScene/UIScene.Internal.d.ts +43 -0
- package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
- package/dist/core/elements/UIScene/UIScene.d.ts +59 -0
- package/dist/core/elements/UIScene/UIScene.js +157 -0
- package/{src/core/elements/UIText/UIText.Interfaces.ts → dist/core/elements/UIText/UIText.Interfaces.d.ts} +16 -21
- package/dist/core/elements/UIText/UIText.Internal.d.ts +26 -0
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.d.ts +50 -0
- package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
- package/dist/core/elements/UIText/UIText.Rendering.d.ts +20 -0
- package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
- package/dist/core/elements/UIText/UIText.d.ts +71 -0
- package/dist/core/elements/UIText/UIText.js +265 -0
- package/{src/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts → dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts} +11 -14
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +63 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
- package/{src/core/layers/UILayer/UILayer.Internal.ts → dist/core/layers/UILayer/UILayer.Internal.d.ts} +11 -15
- package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
- package/dist/core/layers/UILayer/UILayer.d.ts +49 -0
- package/dist/core/layers/UILayer/UILayer.js +113 -0
- package/dist/core/miscellaneous/UIExpression.d.ts +69 -0
- package/dist/core/miscellaneous/UIExpression.js +128 -0
- package/dist/core/miscellaneous/UIMode.d.ts +23 -0
- package/dist/core/miscellaneous/UIMode.js +30 -0
- package/dist/core/miscellaneous/UIOrientation.d.ts +15 -0
- package/dist/core/miscellaneous/UIOrientation.js +20 -0
- package/dist/core/miscellaneous/UIPriority.d.ts +32 -0
- package/dist/core/miscellaneous/UIPriority.js +63 -0
- package/dist/core/miscellaneous/UIRelation.d.ts +23 -0
- package/dist/core/miscellaneous/UIRelation.js +40 -0
- package/dist/core/miscellaneous/UITransparencyMode.d.ts +9 -0
- package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
- package/dist/core/miscellaneous/area/UIArea.d.ts +3 -0
- package/dist/core/miscellaneous/area/UIArea.js +5 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +15 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +12 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +17 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +21 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
- package/dist/core/miscellaneous/asserts.d.ts +43 -0
- package/dist/core/miscellaneous/asserts.js +163 -0
- package/dist/core/miscellaneous/canvas.d.ts +31 -0
- package/dist/core/miscellaneous/canvas.js +37 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.d.ts +7 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
- package/dist/core/miscellaneous/color/UIColor.d.ts +234 -0
- package/dist/core/miscellaneous/color/UIColor.js +636 -0
- package/dist/core/miscellaneous/computeTransform.d.ts +18 -0
- package/dist/core/miscellaneous/computeTransform.js +82 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +19 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +1 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
- package/{src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts → dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts} +8 -10
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +1 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +38 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.d.ts +11 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.d.ts +48 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +9 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +21 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +16 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
- package/dist/core/miscellaneous/math.d.ts +7 -0
- package/dist/core/miscellaneous/math.js +11 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.d.ts +31 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
- package/dist/core/miscellaneous/micro/UIMicro.d.ts +59 -0
- package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +3 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +22 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +5 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
- package/dist/core/miscellaneous/shared.d.ts +46 -0
- package/dist/core/miscellaneous/shared.js +37 -0
- package/{src/core/miscellaneous/text-span/UITextSpan.Internal.ts → dist/core/miscellaneous/text-span/UITextSpan.Internal.d.ts} +4 -5
- package/dist/core/miscellaneous/text-span/UITextSpan.d.ts +14 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +48 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +85 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.d.ts +49 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
- package/dist/core/miscellaneous/texture/UITextureView.d.ts +67 -0
- package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
- package/dist/core/miscellaneous/webglCapabilities.d.ts +2 -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/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +17 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +13 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +13 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +20 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +49 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +215 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
- package/dist/index.js +51 -0
- 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.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 +8 -1
- package/.claude/settings.local.json +0 -9
- package/.editorconfig +0 -14
- package/CLAUDE.md +0 -181
- package/assets/logotype.png +0 -0
- package/eslint.config.js +0 -111
- package/rollup.config.js +0 -52
- package/src/core/constraints/UIAspectConstraint/UIAspectConstraint.ts +0 -60
- package/src/core/constraints/UIConstraint.ts +0 -20
- package/src/core/constraints/UICustomConstraint.ts +0 -62
- package/src/core/constraints/UIHeightConstraint/UIHeightConstraint.ts +0 -52
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts +0 -13
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts +0 -139
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts +0 -16
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts +0 -189
- package/src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts +0 -68
- package/src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts +0 -94
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts +0 -13
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts +0 -135
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts +0 -16
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts +0 -189
- package/src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts +0 -68
- package/src/core/constraints/UIWidthConstraint/UIWidthConstraint.ts +0 -52
- package/src/core/constraints/builders/UIConstraint2DBuilder.Internal.ts +0 -84
- package/src/core/constraints/builders/UIConstraint2DBuilder.ts +0 -168
- package/src/core/constraints/builders/UICoverConstraintBuilder.Internal.ts +0 -15
- package/src/core/constraints/builders/UICoverConstraintBuilder.ts +0 -84
- package/src/core/constraints/builders/UIFitConstraintBuilder.Internal.ts +0 -15
- package/src/core/constraints/builders/UIFitConstraintBuilder.ts +0 -84
- package/src/core/elements/UIAnchor/UIAnchor.Internal.ts +0 -13
- package/src/core/elements/UIAnchor/UIAnchor.ts +0 -70
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts +0 -30
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.ts +0 -355
- package/src/core/elements/UIDummy/UIDummy.Internal.ts +0 -33
- package/src/core/elements/UIDummy/UIDummy.ts +0 -244
- package/src/core/elements/UIElement/UIElement.ts +0 -127
- package/src/core/elements/UIGraphics/UIGraphics.ts +0 -168
- package/src/core/elements/UIImage/UIImage.ts +0 -138
- package/src/core/elements/UINineSlice/UINineSlice.Internal.ts +0 -26
- package/src/core/elements/UINineSlice/UINineSlice.ts +0 -296
- package/src/core/elements/UIProgress/UIProgress.Internal.ts +0 -24
- package/src/core/elements/UIProgress/UIProgress.ts +0 -259
- package/src/core/elements/UIScene/UIScene.Internal.ts +0 -46
- package/src/core/elements/UIScene/UIScene.ts +0 -259
- package/src/core/elements/UIText/UIText.Internal.ts +0 -29
- package/src/core/elements/UIText/UIText.Measuring.ts +0 -183
- package/src/core/elements/UIText/UIText.Rendering.ts +0 -83
- package/src/core/elements/UIText/UIText.ts +0 -376
- package/src/core/layers/UIFullscreenLayer/UIFullscreenLayer.ts +0 -233
- package/src/core/layers/UILayer/UILayer.ts +0 -156
- package/src/core/miscellaneous/UIExpression.ts +0 -142
- package/src/core/miscellaneous/UIMode.ts +0 -29
- package/src/core/miscellaneous/UIOrientation.ts +0 -18
- package/src/core/miscellaneous/UIPriority.ts +0 -63
- package/src/core/miscellaneous/UIRelation.ts +0 -39
- package/src/core/miscellaneous/UITransparencyMode.ts +0 -9
- package/src/core/miscellaneous/area/UIArea.ts +0 -5
- package/src/core/miscellaneous/area/UIAreaCircle.ts +0 -32
- package/src/core/miscellaneous/area/UIAreaPolygon.ts +0 -50
- package/src/core/miscellaneous/area/UIAreaRectangle.ts +0 -38
- package/src/core/miscellaneous/area/UIAreaRoundedRectangle.ts +0 -78
- package/src/core/miscellaneous/asserts.ts +0 -187
- package/src/core/miscellaneous/canvas.ts +0 -73
- package/src/core/miscellaneous/color/UIColor.Internal.ts +0 -89
- package/src/core/miscellaneous/color/UIColor.ts +0 -844
- package/src/core/miscellaneous/computeTransform.ts +0 -127
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts +0 -235
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts +0 -524
- package/src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts +0 -448
- package/src/core/miscellaneous/generic-plane/shared.ts +0 -323
- package/src/core/miscellaneous/insets/UIInsets.Internal.ts +0 -9
- package/src/core/miscellaneous/insets/UIInsets.ts +0 -248
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunction.ts +0 -24
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts +0 -58
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts +0 -52
- package/src/core/miscellaneous/math.ts +0 -16
- package/src/core/miscellaneous/micro/UIMicro.Internal.ts +0 -33
- package/src/core/miscellaneous/micro/UIMicro.ts +0 -222
- package/src/core/miscellaneous/resize-policy/UIResizePolicy.ts +0 -8
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCover.ts +0 -57
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCross.ts +0 -65
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts +0 -65
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFit.ts +0 -57
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts +0 -65
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts +0 -65
- package/src/core/miscellaneous/resize-policy/UIResizePolicyNone.ts +0 -11
- package/src/core/miscellaneous/shared.ts +0 -73
- package/src/core/miscellaneous/text-span/UITextSpan.ts +0 -43
- package/src/core/miscellaneous/text-style/UITextStyle.Internal.ts +0 -52
- package/src/core/miscellaneous/text-style/UITextStyle.ts +0 -479
- package/src/core/miscellaneous/texture/UITextureView.Internal.ts +0 -55
- package/src/core/miscellaneous/texture/UITextureView.ts +0 -308
- package/src/core/miscellaneous/webglCapabilities.ts +0 -129
- package/src/core/shaders/UIImage.glsl +0 -10
- package/src/core/shaders/UINineSlice.glsl +0 -53
- package/src/core/shaders/UIProgress.glsl +0 -15
- package/src/core/shaders/UIProgressMaskFunctionCircular.glsl +0 -13
- package/src/core/shaders/UIProgressMaskFunctionDirectional.glsl +0 -12
- package/src/core/shaders/glsl.d.ts +0 -27
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.ts +0 -23
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.ts +0 -124
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.ts +0 -22
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.ts +0 -101
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.ts +0 -58
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.ts +0 -605
- package/src/particles/behaviorModules/UIBehaviorDirectionalGravity.ts +0 -70
- package/src/particles/behaviorModules/UIBehaviorModule.ts +0 -20
- package/src/particles/behaviorModules/UIBehaviorPointGravity.ts +0 -173
- package/src/particles/behaviorModules/UIBehaviorScaleOverLife.ts +0 -104
- package/src/particles/behaviorModules/UIBehaviorTorqueDamping.ts +0 -75
- package/src/particles/behaviorModules/UIBehaviorTorqueNoise.ts +0 -115
- package/src/particles/behaviorModules/UIBehaviorVelocityDamping.ts +0 -77
- package/src/particles/behaviorModules/UIBehaviorVelocityNoise.ts +0 -118
- package/src/particles/elements/UIEmitter.Internal.ts +0 -22
- package/src/particles/elements/UIEmitter.ts +0 -313
- package/src/particles/instancedParticle/UIInstancedParticle.Internal.ts +0 -263
- package/src/particles/instancedParticle/UIInstancedParticle.ts +0 -138
- package/src/particles/miscellaneous/miscellaneous.ts +0 -115
- package/src/particles/renderingModules/UIRenderingColorOverLife.ts +0 -39
- package/src/particles/renderingModules/UIRenderingColorOverVelocity.ts +0 -49
- package/src/particles/renderingModules/UIRenderingModule.ts +0 -17
- package/src/particles/renderingModules/UIRenderingTexture.ts +0 -30
- package/src/particles/shaders/UIRenderingColorOverLife.glsl +0 -4
- package/src/particles/shaders/UIRenderingColorOverVelocity.glsl +0 -6
- package/src/particles/shaders/UIRenderingTexture.glsl +0 -4
- package/src/particles/spawnModules/UISpawnModule.ts +0 -22
- package/src/particles/spawnModules/UISpawnOffset.ts +0 -62
- package/src/particles/spawnModules/UISpawnRandomLifetime.ts +0 -68
- package/src/particles/spawnModules/UISpawnRandomRotation.ts +0 -60
- package/src/particles/spawnModules/UISpawnRandomScale.ts +0 -81
- package/src/particles/spawnModules/UISpawnRandomTorque.ts +0 -62
- package/src/particles/spawnModules/UISpawnRandomVelocity.ts +0 -92
- package/src/particles/spawnModules/UISpawnRectangle.ts +0 -81
- package/tsconfig.json +0 -29
- /package/{src/core/index.ts → dist/core/index.d.ts} +0 -0
- /package/{src/particles/index.ts → dist/particles/index.d.ts} +0 -0
|
@@ -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.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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Mesh, InstancedBufferAttribute, StreamDrawUsage } from 'three';
|
|
2
|
+
import { resolvePropertyUniform } from '../../core/miscellaneous/generic-plane/shared.js';
|
|
3
|
+
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME } from '../miscellaneous/miscellaneous.js';
|
|
4
|
+
import { INSTANCED_PARTICLE_GEOMETRY, buildParticleMaterial } from './UIInstancedParticle.Internal.js';
|
|
5
|
+
|
|
6
|
+
class UIInstancedParticle extends Mesh {
|
|
7
|
+
constructor(sources, uniforms, varyings, expectedCapacity, _private_capacityStep) {
|
|
8
|
+
const instancedGeometry = INSTANCED_PARTICLE_GEOMETRY.clone();
|
|
9
|
+
const shaderMaterial = buildParticleMaterial(sources, uniforms, varyings);
|
|
10
|
+
super(instancedGeometry, shaderMaterial);
|
|
11
|
+
this._private_capacityStep = _private_capacityStep;
|
|
12
|
+
this.propertyBuffers = {};
|
|
13
|
+
this.frustumCulled = false;
|
|
14
|
+
this.matrixAutoUpdate = false;
|
|
15
|
+
this.matrixWorldAutoUpdate = false;
|
|
16
|
+
this._private_instancedGeometry = instancedGeometry;
|
|
17
|
+
this._private_instancedGeometry.instanceCount = 0;
|
|
18
|
+
this._private_shaderMaterial = shaderMaterial;
|
|
19
|
+
this._private_capacity = Math.max(Math.ceil(expectedCapacity / this._private_capacityStep) * this._private_capacityStep, this._private_capacityStep);
|
|
20
|
+
for (const name in varyings) {
|
|
21
|
+
const { bufferSize } = varyings[name];
|
|
22
|
+
const attribute = new InstancedBufferAttribute(new Float32Array(this._private_capacity * bufferSize), bufferSize);
|
|
23
|
+
attribute.setUsage(StreamDrawUsage);
|
|
24
|
+
this._private_instancedGeometry.setAttribute(`a_${name}`, attribute);
|
|
25
|
+
this.propertyBuffers[name] = attribute;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
get instanceCount() {
|
|
29
|
+
return this._private_instancedGeometry.instanceCount;
|
|
30
|
+
}
|
|
31
|
+
createInstances(count) {
|
|
32
|
+
const currentInstanceCount = this._private_instancedGeometry.instanceCount;
|
|
33
|
+
this._private_ensureCapacity(currentInstanceCount + count);
|
|
34
|
+
this._private_instancedGeometry.instanceCount += count;
|
|
35
|
+
}
|
|
36
|
+
setOrigin(x, y) {
|
|
37
|
+
const uniform = resolvePropertyUniform("origin", this._private_shaderMaterial);
|
|
38
|
+
uniform.value.set(x, y);
|
|
39
|
+
}
|
|
40
|
+
removeDeadParticles() {
|
|
41
|
+
const builtinBuffer = this.propertyBuffers.builtin;
|
|
42
|
+
if (builtinBuffer === undefined) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { array: builtinArray, itemSize: builtinItemSize } = builtinBuffer;
|
|
46
|
+
const { instanceCount } = this._private_instancedGeometry;
|
|
47
|
+
let writeIndex = 0;
|
|
48
|
+
for (let readIndex = 0; readIndex < instanceCount; readIndex++) {
|
|
49
|
+
const offset = readIndex * builtinItemSize;
|
|
50
|
+
if (builtinArray[offset + BUILTIN_OFFSET_AGE] < builtinArray[offset + BUILTIN_OFFSET_LIFETIME]) {
|
|
51
|
+
if (writeIndex !== readIndex) {
|
|
52
|
+
for (const name in this.propertyBuffers) {
|
|
53
|
+
const attribute = this.propertyBuffers[name];
|
|
54
|
+
const { itemSize: dataItemSize, array: dataArray } = attribute;
|
|
55
|
+
const srcOffset = readIndex * dataItemSize;
|
|
56
|
+
const dstOffset = writeIndex * dataItemSize;
|
|
57
|
+
dataArray.copyWithin(dstOffset, srcOffset, srcOffset + dataItemSize);
|
|
58
|
+
attribute.needsUpdate = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
writeIndex++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this._private_instancedGeometry.instanceCount = writeIndex;
|
|
65
|
+
}
|
|
66
|
+
drop() {
|
|
67
|
+
this._private_instancedGeometry.instanceCount = 0;
|
|
68
|
+
}
|
|
69
|
+
destroy() {
|
|
70
|
+
this._private_instancedGeometry.dispose();
|
|
71
|
+
this._private_shaderMaterial.dispose();
|
|
72
|
+
}
|
|
73
|
+
_private_ensureCapacity(requiredCapacity) {
|
|
74
|
+
if (requiredCapacity <= this._private_capacity) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const newCapacity = Math.ceil(requiredCapacity / this._private_capacityStep) * this._private_capacityStep;
|
|
78
|
+
for (const name in this.propertyBuffers) {
|
|
79
|
+
const { itemSize, array, usage } = this.propertyBuffers[name];
|
|
80
|
+
const newArray = new Float32Array(newCapacity * itemSize);
|
|
81
|
+
newArray.set(array);
|
|
82
|
+
const newAttribute = new InstancedBufferAttribute(newArray, itemSize);
|
|
83
|
+
newAttribute.setUsage(usage);
|
|
84
|
+
this._private_instancedGeometry.setAttribute(`a_${name}`, newAttribute);
|
|
85
|
+
this.propertyBuffers[name] = newAttribute;
|
|
86
|
+
}
|
|
87
|
+
this._private_capacity = newCapacity;
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- old three.js compatibility fix
|
|
89
|
+
this._private_instancedGeometry._maxInstanceCount = newCapacity;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { UIInstancedParticle };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DataTexture, type Vector2Tuple } from "three";
|
|
2
|
+
import type { UIColor } from "../../core";
|
|
3
|
+
import type { Vector2Like } from "../../core/miscellaneous/math";
|
|
4
|
+
import type { UITextureConfig } from "../../core/miscellaneous/texture/UITextureView.Internal";
|
|
5
|
+
export interface UIRange {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
}
|
|
9
|
+
export type UIRangeConfig = UIRange | [number, number] | number;
|
|
10
|
+
export type UIVector2Config = Vector2Like | Vector2Tuple | number;
|
|
11
|
+
export type UIAspectConfig = number | UITextureConfig;
|
|
12
|
+
export declare function resolveUIRangeConfig(config: UIRangeConfig): UIRange;
|
|
13
|
+
export declare function resolveUIVector2Config(config: UIVector2Config): Vector2Like;
|
|
14
|
+
export declare function resolveAspect(config: number | UITextureConfig): number;
|
|
15
|
+
export declare function generateNoise2D(x: number, y: number): number;
|
|
16
|
+
export declare function buildGradientTexture(colors: UIColor[]): DataTexture;
|
|
17
|
+
export declare const BUILTIN_OFFSET_POSITION_X = 0;
|
|
18
|
+
export declare const BUILTIN_OFFSET_POSITION_Y = 1;
|
|
19
|
+
export declare const BUILTIN_OFFSET_VELOCITY_X = 2;
|
|
20
|
+
export declare const BUILTIN_OFFSET_VELOCITY_Y = 3;
|
|
21
|
+
export declare const BUILTIN_OFFSET_SCALE_X = 4;
|
|
22
|
+
export declare const BUILTIN_OFFSET_SCALE_Y = 5;
|
|
23
|
+
export declare const BUILTIN_OFFSET_ROTATION = 6;
|
|
24
|
+
export declare const BUILTIN_OFFSET_TORQUE = 7;
|
|
25
|
+
export declare const BUILTIN_OFFSET_LIFETIME = 8;
|
|
26
|
+
export declare const BUILTIN_OFFSET_AGE = 9;
|
|
27
|
+
export declare const BUILTIN_OFFSET_RANDOM_A = 10;
|
|
28
|
+
export declare const BUILTIN_OFFSET_RANDOM_B = 11;
|
|
29
|
+
export declare const BUILTIN_OFFSET_RANDOM_C = 12;
|
|
30
|
+
export declare const BUILTIN_OFFSET_RANDOM_D = 13;
|
|
31
|
+
export declare const BUILTIN_OFFSET_RANDOM_E = 14;
|
|
32
|
+
export declare const BUILTIN_OFFSET_RANDOM_F = 15;
|