laymur 0.23.0 → 0.25.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 +1 -1
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.js +1 -0
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +3 -3
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +14 -16
- package/dist/core/constraints/UIConstraint.d.ts +22 -2
- package/dist/core/constraints/UIConstraint.js +26 -3
- package/dist/core/constraints/UICustomConstraint.d.ts +4 -4
- package/dist/core/constraints/UICustomConstraint.js +15 -15
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.js +1 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +3 -3
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +11 -13
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +1 -3
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +3 -3
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +30 -30
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +2 -4
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +3 -3
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +40 -39
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.js +1 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +3 -3
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +13 -15
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +3 -3
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.js +1 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +13 -7
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +37 -30
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +1 -3
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +3 -3
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +30 -30
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +2 -4
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +3 -3
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +40 -39
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.js +1 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +3 -3
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +13 -15
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +1 -1
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.js +1 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +3 -3
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +11 -13
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +3 -3
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +1 -3
- package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +11 -11
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +10 -13
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +1 -1
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +1 -3
- package/dist/core/constraints/builders/UICoverConstraintBuilder.d.ts +7 -7
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +10 -13
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +1 -1
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +1 -3
- package/dist/core/constraints/builders/UIFitConstraintBuilder.d.ts +7 -7
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +10 -13
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +3 -5
- package/dist/core/elements/UIAnchor/UIAnchor.d.ts +23 -5
- package/dist/core/elements/UIAnchor/UIAnchor.js +42 -8
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +2 -2
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +4 -6
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +10 -10
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +108 -111
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +4 -4
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +5 -8
- package/dist/core/elements/UIDummy/UIDummy.d.ts +19 -11
- package/dist/core/elements/UIDummy/UIDummy.js +59 -42
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +5 -5
- package/dist/core/elements/UIElement/UIElement.Internal.js +9 -12
- package/dist/core/elements/UIElement/UIElement.d.ts +11 -11
- package/dist/core/elements/UIElement/UIElement.js +57 -60
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +3 -3
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +4 -7
- package/dist/core/elements/UIGraphics/UIGraphics.d.ts +7 -7
- package/dist/core/elements/UIGraphics/UIGraphics.js +44 -47
- package/dist/core/elements/UIImage/UIImage.Internal.d.ts +2 -2
- package/dist/core/elements/UIImage/UIImage.Internal.js +1 -0
- package/dist/core/elements/UIImage/UIImage.d.ts +9 -9
- package/dist/core/elements/UIImage/UIImage.js +21 -24
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.d.ts +3 -3
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +3 -5
- package/dist/core/elements/UINineSlice/UINineSlice.d.ts +12 -12
- package/dist/core/elements/UINineSlice/UINineSlice.js +71 -73
- package/dist/core/elements/UIProgress/UIProgress.Internal.d.ts +3 -4
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +1 -3
- package/dist/core/elements/UIProgress/UIProgress.d.ts +10 -10
- package/dist/core/elements/UIProgress/UIProgress.js +59 -62
- package/dist/core/elements/UIScene/UIScene.Internal.d.ts +3 -3
- package/dist/core/elements/UIScene/UIScene.Internal.js +11 -14
- package/dist/core/elements/UIScene/UIScene.d.ts +8 -8
- package/dist/core/elements/UIScene/UIScene.js +68 -69
- package/dist/core/elements/UIText/UIText.Bidi.d.ts +2 -2
- package/dist/core/elements/UIText/UIText.Bidi.js +3 -5
- package/dist/core/elements/UIText/UIText.Interfaces.d.ts +6 -2
- package/dist/core/elements/UIText/UIText.Interfaces.js +1 -0
- package/dist/core/elements/UIText/UIText.Internal.d.ts +4 -4
- package/dist/core/elements/UIText/UIText.Internal.js +5 -7
- package/dist/core/elements/UIText/UIText.Measuring.d.ts +14 -7
- package/dist/core/elements/UIText/UIText.Measuring.js +115 -55
- package/dist/core/elements/UIText/UIText.Rendering.d.ts +3 -3
- package/dist/core/elements/UIText/UIText.Rendering.js +6 -9
- package/dist/core/elements/UIText/UIText.d.ts +28 -14
- package/dist/core/elements/UIText/UIText.js +181 -141
- package/dist/core/index.d.ts +55 -54
- package/dist/core/index.js +53 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +4 -4
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +2 -5
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +4 -4
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +43 -42
- package/dist/core/layers/UILayer/UILayer.Internal.d.ts +2 -2
- package/dist/core/layers/UILayer/UILayer.Internal.js +4 -7
- package/dist/core/layers/UILayer/UILayer.d.ts +19 -4
- package/dist/core/layers/UILayer/UILayer.js +125 -62
- package/dist/core/miscellaneous/UIBlendMode.js +1 -3
- package/dist/core/miscellaneous/UIExpression.js +16 -19
- package/dist/core/miscellaneous/UIMode.js +3 -5
- package/dist/core/miscellaneous/UIOrientation.js +2 -4
- package/dist/core/miscellaneous/UIPriority.js +5 -8
- package/dist/core/miscellaneous/UIRelation.js +5 -8
- package/dist/core/miscellaneous/UITransparencyMode.js +1 -3
- package/dist/core/miscellaneous/area/UIArea.js +1 -3
- package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +1 -1
- package/dist/core/miscellaneous/area/UIAreaCircle.js +3 -6
- package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +2 -2
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +3 -6
- package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +1 -1
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +3 -6
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +1 -1
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +3 -6
- package/dist/core/miscellaneous/asserts.d.ts +30 -1
- package/dist/core/miscellaneous/asserts.js +87 -19
- package/dist/core/miscellaneous/canvas.js +13 -7
- package/dist/core/miscellaneous/color/UIColor.Internal.d.ts +1 -1
- package/dist/core/miscellaneous/color/UIColor.Internal.js +1 -3
- package/dist/core/miscellaneous/color/UIColor.d.ts +1 -1
- package/dist/core/miscellaneous/color/UIColor.js +202 -205
- package/dist/core/miscellaneous/computeTransform.d.ts +1 -1
- package/dist/core/miscellaneous/computeTransform.js +4 -7
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +10 -5
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +63 -58
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.d.ts +52 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.js +110 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +181 -261
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +3 -3
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.js +1 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +209 -115
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +12 -12
- package/dist/core/miscellaneous/generic-plane/shared.js +28 -23
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +1 -3
- package/dist/core/miscellaneous/insets/UIInsets.d.ts +1 -1
- package/dist/core/miscellaneous/insets/UIInsets.js +96 -99
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +1 -3
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +1 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +14 -17
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +2 -2
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +13 -16
- package/dist/core/miscellaneous/math.js +3 -5
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +6 -8
- package/dist/core/miscellaneous/micro/UIMicro.d.ts +1 -1
- package/dist/core/miscellaneous/micro/UIMicro.js +91 -94
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +1 -3
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +12 -15
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +13 -16
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +13 -16
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +12 -15
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +13 -16
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +13 -16
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +3 -6
- package/dist/core/miscellaneous/shared.d.ts +1 -1
- package/dist/core/miscellaneous/shared.js +4 -7
- package/dist/core/miscellaneous/text-span/UITextSpan.Internal.d.ts +1 -1
- package/dist/core/miscellaneous/text-span/UITextSpan.Internal.js +1 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.d.ts +2 -2
- package/dist/core/miscellaneous/text-span/UITextSpan.js +10 -13
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +15 -17
- package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +13 -2
- package/dist/core/miscellaneous/text-style/UITextStyle.js +222 -207
- package/dist/core/miscellaneous/texture/UITextureView.Internal.d.ts +7 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +16 -6
- package/dist/core/miscellaneous/texture/UITextureView.d.ts +1 -1
- package/dist/core/miscellaneous/texture/UITextureView.js +113 -117
- package/dist/core/miscellaneous/webglCapabilities.js +3 -4
- package/dist/core/shaders/UIImage.d.ts +9 -0
- package/dist/core/shaders/UIImage.js +14 -0
- package/dist/core/shaders/UINineSlice.d.ts +11 -0
- package/dist/core/shaders/UINineSlice.js +57 -0
- package/dist/core/shaders/UIProgress.d.ts +14 -0
- package/dist/core/shaders/UIProgress.js +21 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.d.ts +2 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.js +16 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.d.ts +2 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.js +15 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +4 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.js +1 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +7 -1
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +50 -47
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +5 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.js +1 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +11 -3
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +42 -26
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +5 -3
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.js +1 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +20 -4
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +138 -117
- package/dist/debug/UIAspectDebug.d.ts +3 -3
- package/dist/debug/UIAspectDebug.js +64 -68
- package/dist/debug/UIConstraintDebug.d.ts +1 -1
- package/dist/debug/UIConstraintDebug.js +1 -0
- package/dist/debug/UIHeightDebug.d.ts +3 -3
- package/dist/debug/UIHeightDebug.js +63 -67
- package/dist/debug/UIHorizontalDistanceDebug.d.ts +3 -3
- package/dist/debug/UIHorizontalDistanceDebug.js +76 -81
- package/dist/debug/UIHorizontalInterpolationDebug.d.ts +3 -3
- package/dist/debug/UIHorizontalInterpolationDebug.js +74 -78
- package/dist/debug/UILayerDebug.d.ts +1 -1
- package/dist/debug/UILayerDebug.js +55 -64
- package/dist/debug/UIVerticalDistanceDebug.d.ts +3 -3
- package/dist/debug/UIVerticalDistanceDebug.js +76 -81
- package/dist/debug/UIVerticalInterpolationDebug.d.ts +3 -3
- package/dist/debug/UIVerticalInterpolationDebug.js +74 -78
- package/dist/debug/UIWidthDebug.d.ts +3 -3
- package/dist/debug/UIWidthDebug.js +63 -67
- package/dist/debug/index.d.ts +8 -8
- package/dist/debug/index.js +8 -8
- package/dist/debug/miscellaneous.js +8 -11
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +3 -3
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +13 -16
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +1 -1
- package/dist/particles/behaviorModules/UIBehaviorModule.js +1 -3
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +3 -3
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +37 -40
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +41 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +87 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +17 -20
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +13 -16
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +21 -24
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +13 -16
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +2 -2
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +21 -24
- package/dist/particles/elements/UIEmitter.Internal.d.ts +2 -2
- package/dist/particles/elements/UIEmitter.Internal.js +6 -9
- package/dist/particles/elements/UIEmitter.d.ts +17 -11
- package/dist/particles/elements/UIEmitter.js +100 -88
- package/dist/particles/index.d.ts +20 -18
- package/dist/particles/index.js +19 -18
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +1 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +14 -15
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +4 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.js +40 -32
- package/dist/particles/miscellaneous/miscellaneous.d.ts +3 -3
- package/dist/particles/miscellaneous/miscellaneous.js +26 -27
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +2 -2
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +5 -8
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +2 -2
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +6 -9
- package/dist/particles/renderingModules/UIRenderingModule.js +1 -3
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +2 -2
- package/dist/particles/renderingModules/UIRenderingTexture.js +4 -7
- package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +2 -0
- package/dist/particles/shaders/UIRenderingColorOverLife.js +7 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +9 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.js +16 -0
- package/dist/particles/shaders/UIRenderingTexture.d.ts +2 -0
- package/dist/particles/shaders/UIRenderingTexture.js +7 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +1 -1
- package/dist/particles/spawnModules/UISpawnModule.js +1 -3
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +3 -3
- package/dist/particles/spawnModules/UISpawnOffset.js +12 -15
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +13 -16
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +13 -16
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomScale.js +19 -22
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +13 -16
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +2 -2
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +21 -24
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +3 -3
- package/dist/particles/spawnModules/UISpawnRectangle.js +21 -24
- package/package.json +13 -17
- package/dist/_virtual/2d.js +0 -3
- package/dist/_virtual/3d.js +0 -3
- package/dist/_virtual/4d.js +0 -3
- package/dist/_virtual/mod.js +0 -5
- package/dist/_virtual/mod2.js +0 -3
- package/dist/core/shaders/UIImage.glsl.js +0 -3
- package/dist/core/shaders/UINineSlice.glsl.js +0 -3
- package/dist/core/shaders/UIProgress.glsl.js +0 -3
- package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +0 -3
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +0 -3
- package/dist/index.js +0 -52
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +0 -93
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +0 -142
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +0 -196
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +0 -24
- package/dist/node_modules/three/examples/jsm/lines/Line2.js +0 -56
- package/dist/node_modules/three/examples/jsm/lines/LineGeometry.js +0 -157
- package/dist/node_modules/three/examples/jsm/lines/LineMaterial.js +0 -691
- package/dist/node_modules/three/examples/jsm/lines/LineSegments2.js +0 -415
- package/dist/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +0 -289
- package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +0 -3
- package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +0 -3
- package/dist/particles/shaders/UIRenderingTexture.glsl.js +0 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UIMicroAnchorMode } from
|
|
3
|
-
|
|
1
|
+
import { Matrix4, Quaternion, Vector3 } from "three";
|
|
2
|
+
import { UIMicroAnchorMode } from "../miscellaneous/micro/UIMicro.Internal.js";
|
|
4
3
|
const TEMP_POSITION = new Vector3();
|
|
5
4
|
const TEMP_QUATERNION = new Quaternion();
|
|
6
5
|
const TEMP_SCALE = new Vector3();
|
|
@@ -10,7 +9,7 @@ const Z_AXIS = new Vector3(0, 0, 1);
|
|
|
10
9
|
* Computes element transform matrix.
|
|
11
10
|
* @returns Transform matrix (reused, do not store reference)
|
|
12
11
|
*/
|
|
13
|
-
function computeTransformMatrix(x, y, width, height, zIndex, microX, microY, microAnchorX, microAnchorY, microScaleX, microScaleY, microRotation, microAnchorMode) {
|
|
12
|
+
export function computeTransformMatrix(x, y, width, height, zIndex, microX, microY, microAnchorX, microAnchorY, microScaleX, microScaleY, microRotation, microAnchorMode) {
|
|
14
13
|
const scaledWidth = width * microScaleX;
|
|
15
14
|
const scaledHeight = height * microScaleY;
|
|
16
15
|
const anchorOffsetX = microAnchorX * scaledWidth;
|
|
@@ -46,7 +45,7 @@ function computeTransformMatrix(x, y, width, height, zIndex, microX, microY, mic
|
|
|
46
45
|
* @param trimBottom Pixels trimmed from bottom
|
|
47
46
|
* @returns Transform matrix (reused, do not store reference)
|
|
48
47
|
*/
|
|
49
|
-
function computeTrimmedTransformMatrix(x, y, width, height, zIndex, microX, microY, microAnchorX, microAnchorY, microScaleX, microScaleY, microRotation, microAnchorMode, trimLeft, trimRight, trimTop, trimBottom) {
|
|
48
|
+
export function computeTrimmedTransformMatrix(x, y, width, height, zIndex, microX, microY, microAnchorX, microAnchorY, microScaleX, microScaleY, microRotation, microAnchorMode, trimLeft, trimRight, trimTop, trimBottom) {
|
|
50
49
|
const trimmedWidth = width - trimLeft - trimRight;
|
|
51
50
|
const trimmedHeight = height - trimTop - trimBottom;
|
|
52
51
|
const scaledWidth = width * microScaleX;
|
|
@@ -78,5 +77,3 @@ function computeTrimmedTransformMatrix(x, y, width, height, zIndex, microX, micr
|
|
|
78
77
|
TEMP_MATRIX.compose(TEMP_POSITION, TEMP_QUATERNION, TEMP_SCALE);
|
|
79
78
|
return TEMP_MATRIX;
|
|
80
79
|
}
|
|
81
|
-
|
|
82
|
-
export { computeTransformMatrix, computeTrimmedTransformMatrix };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { InstancedBufferAttribute, InstancedBufferGeometry, ShaderMaterial } from "three";
|
|
2
|
-
import { UITransparencyMode } from "../../UITransparencyMode";
|
|
3
|
-
import type { GLProperty, UIProperty } from "../shared";
|
|
2
|
+
import { UITransparencyMode } from "../../UITransparencyMode.js";
|
|
3
|
+
import type { GLProperty, UIProperty } from "../shared.js";
|
|
4
|
+
import type { PackedLayout } from "./UIGenericInstancedPlane.Layout.js";
|
|
4
5
|
export declare const INSTANCED_PLANE_GEOMETRY: InstancedBufferGeometry;
|
|
5
6
|
export declare const CAPACITY_STEP = 4;
|
|
6
7
|
export declare const INITIAL_CAPACITY = 1;
|
|
7
8
|
export declare function writePropertyToArray(value: UIProperty, array: Float32Array, offset: number): void;
|
|
8
|
-
export declare
|
|
9
|
-
export declare
|
|
10
|
-
export declare
|
|
9
|
+
export declare const BUILTIN_TRANSFORM = "instanceTransform";
|
|
10
|
+
export declare const BUILTIN_VISIBILITY = "instanceVisibility";
|
|
11
|
+
export declare const BUILTIN_BLEND = "instanceBlend";
|
|
12
|
+
export declare const BUILTIN_HSL = "instanceHSL";
|
|
13
|
+
export declare function buildPlaneLayout(varyingProperties: Record<string, GLProperty>): PackedLayout;
|
|
14
|
+
export declare function buildPackedAttribute(itemSize: number, capacity: number): InstancedBufferAttribute;
|
|
15
|
+
export declare function buildMaterial(source: string, uniformProperties: Record<string, GLProperty>, layout: PackedLayout, transparency: UITransparencyMode): ShaderMaterial;
|
|
11
16
|
/**
|
|
12
17
|
* Shift buffer region within the same array.
|
|
13
18
|
* Uses copyWithin for efficient memory moves with correct overlap handling.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UIColor } from
|
|
3
|
-
import { UITransparencyMode } from
|
|
4
|
-
import { buildGenericPlaneFragmentShader, resolveGLSLTypeInfo } from
|
|
5
|
-
|
|
6
|
-
const INSTANCED_PLANE_GEOMETRY = (() => {
|
|
1
|
+
import { DoubleSide, Float32BufferAttribute, InstancedBufferAttribute, InstancedBufferGeometry, Matrix3, Matrix4, ShaderMaterial, Uint16BufferAttribute, Vector2, Vector3, Vector4, } from "three";
|
|
2
|
+
import { UIColor } from "../../color/UIColor.js";
|
|
3
|
+
import { UITransparencyMode } from "../../UITransparencyMode.js";
|
|
4
|
+
import { buildGenericPlaneFragmentShader, resolveGLSLTypeInfo } from "../shared.js";
|
|
5
|
+
import { buildPackedAttributeDeclarations, buildPackedFieldSpec, buildPackedLayout, resolvePackedField, } from "./UIGenericInstancedPlane.Layout.js";
|
|
6
|
+
export const INSTANCED_PLANE_GEOMETRY = (() => {
|
|
7
7
|
const geometry = new InstancedBufferGeometry();
|
|
8
8
|
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
|
|
9
9
|
geometry.setIndex(new Uint16BufferAttribute(indices, 1));
|
|
@@ -13,10 +13,10 @@ const INSTANCED_PLANE_GEOMETRY = (() => {
|
|
|
13
13
|
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
|
|
14
14
|
return geometry;
|
|
15
15
|
})();
|
|
16
|
-
const CAPACITY_STEP = 4;
|
|
17
|
-
const INITIAL_CAPACITY = 1;
|
|
16
|
+
export const CAPACITY_STEP = 4;
|
|
17
|
+
export const INITIAL_CAPACITY = 1;
|
|
18
18
|
const TEMP_COLOR_VECTOR = new Vector4();
|
|
19
|
-
function writePropertyToArray(value, array, offset) {
|
|
19
|
+
export function writePropertyToArray(value, array, offset) {
|
|
20
20
|
if (value instanceof UIColor) {
|
|
21
21
|
value.toGLSLColor(TEMP_COLOR_VECTOR);
|
|
22
22
|
array[offset] = TEMP_COLOR_VECTOR.x;
|
|
@@ -49,17 +49,50 @@ function writePropertyToArray(value, array, offset) {
|
|
|
49
49
|
array[offset] = value;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
export const BUILTIN_TRANSFORM = "instanceTransform";
|
|
53
|
+
export const BUILTIN_VISIBILITY = "instanceVisibility";
|
|
54
|
+
export const BUILTIN_BLEND = "instanceBlend";
|
|
55
|
+
export const BUILTIN_HSL = "instanceHSL";
|
|
56
|
+
/**
|
|
57
|
+
* Builtin fields only the vertex shader reads. Every other field, builtin blend and HSL included,
|
|
58
|
+
* is passed on to the fragment shader as a p_* varying.
|
|
59
|
+
*/
|
|
60
|
+
const BUILTIN_VERTEX_ONLY = [BUILTIN_TRANSFORM, BUILTIN_VISIBILITY];
|
|
61
|
+
/**
|
|
62
|
+
* The transform is a Matrix4, but the plane is a unit quad at z = 0 and every element transform
|
|
63
|
+
* is affine: the z basis column only ever multiplies 0 and the bottom row is always (0, 0, 0, 1).
|
|
64
|
+
* Only the x basis, y basis and translation columns are stored, without their w components, and
|
|
65
|
+
* the shader applies them as mat3(xBasis, yBasis, translation) * vec3(position.xy, 1.0).
|
|
66
|
+
* Translation z is the zIndex, see TRANSFORM_ZINDEX_OFFSET.
|
|
67
|
+
*/
|
|
68
|
+
const BUILTIN_TRANSFORM_SPEC = {
|
|
69
|
+
name: BUILTIN_TRANSFORM,
|
|
70
|
+
glslTypeName: "mat3",
|
|
71
|
+
flatSize: 16,
|
|
72
|
+
columns: [
|
|
73
|
+
{ sourceOffset: 0, size: 3 },
|
|
74
|
+
{ sourceOffset: 4, size: 3 },
|
|
75
|
+
{ sourceOffset: 12, size: 3 },
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
export function buildPlaneLayout(varyingProperties) {
|
|
79
|
+
const specs = [
|
|
80
|
+
BUILTIN_TRANSFORM_SPEC,
|
|
81
|
+
buildPackedFieldSpec(BUILTIN_VISIBILITY, resolveGLSLTypeInfo("number")),
|
|
82
|
+
buildPackedFieldSpec(BUILTIN_BLEND, resolveGLSLTypeInfo("number")),
|
|
83
|
+
buildPackedFieldSpec(BUILTIN_HSL, resolveGLSLTypeInfo("Vector3")),
|
|
84
|
+
];
|
|
85
|
+
for (const name in varyingProperties) {
|
|
86
|
+
specs.push(buildPackedFieldSpec(name, varyingProperties[name].glslTypeInfo));
|
|
56
87
|
}
|
|
57
|
-
return
|
|
88
|
+
return buildPackedLayout(specs);
|
|
89
|
+
}
|
|
90
|
+
export function buildPackedAttribute(itemSize, capacity) {
|
|
91
|
+
return new InstancedBufferAttribute(new Float32Array(capacity * itemSize), itemSize);
|
|
58
92
|
}
|
|
59
|
-
function buildMaterial(source, uniformProperties,
|
|
93
|
+
export function buildMaterial(source, uniformProperties, layout, transparency) {
|
|
60
94
|
const uniforms = {};
|
|
61
95
|
const uniformDeclarations = [];
|
|
62
|
-
const attributeDeclarations = [];
|
|
63
96
|
const varyingDeclarations = [];
|
|
64
97
|
const vertexAssignments = [];
|
|
65
98
|
for (const name in uniformProperties) {
|
|
@@ -69,15 +102,17 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
69
102
|
};
|
|
70
103
|
uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
|
|
71
104
|
}
|
|
72
|
-
for (const name
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
105
|
+
for (const [name, field] of layout.fields) {
|
|
106
|
+
if (BUILTIN_VERTEX_ONLY.includes(name)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
varyingDeclarations.push(`varying ${field.glslTypeName} p_${name};`);
|
|
110
|
+
vertexAssignments.push(`p_${name} = ${field.expression};`);
|
|
77
111
|
}
|
|
112
|
+
const visibility = resolvePackedField(layout, BUILTIN_VISIBILITY).expression;
|
|
113
|
+
const transform = resolvePackedField(layout, BUILTIN_TRANSFORM).expression;
|
|
78
114
|
const vertexShader = `
|
|
79
|
-
|
|
80
|
-
${attributeDeclarations.join("\n")}
|
|
115
|
+
${buildPackedAttributeDeclarations(layout).join("\n")}
|
|
81
116
|
|
|
82
117
|
// Uniforms
|
|
83
118
|
${uniformDeclarations.join("\n")}
|
|
@@ -86,11 +121,10 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
86
121
|
varying vec3 p_position;
|
|
87
122
|
varying vec2 p_uv;
|
|
88
123
|
|
|
89
|
-
// User varyings
|
|
90
124
|
${varyingDeclarations.join("\n")}
|
|
91
125
|
|
|
92
126
|
void main() {
|
|
93
|
-
if (
|
|
127
|
+
if (${visibility} < 0.5) {
|
|
94
128
|
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
95
129
|
return;
|
|
96
130
|
}
|
|
@@ -100,7 +134,8 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
100
134
|
p_position = position;
|
|
101
135
|
p_uv = uv;
|
|
102
136
|
|
|
103
|
-
|
|
137
|
+
vec3 worldPosition = ${transform} * vec3(position.xy, 1.0);
|
|
138
|
+
gl_Position = projectionMatrix * vec4(worldPosition, 1.0);
|
|
104
139
|
}
|
|
105
140
|
`;
|
|
106
141
|
const alphaTestValue = 0.0075;
|
|
@@ -120,39 +155,11 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
|
|
|
120
155
|
premultipliedAlpha,
|
|
121
156
|
});
|
|
122
157
|
}
|
|
123
|
-
function reconstructValue(referenceValue, array, offset) {
|
|
124
|
-
if (typeof referenceValue === "number") {
|
|
125
|
-
return array[offset];
|
|
126
|
-
}
|
|
127
|
-
if (referenceValue instanceof Vector2) {
|
|
128
|
-
return new Vector2(array[offset], array[offset + 1]);
|
|
129
|
-
}
|
|
130
|
-
if (referenceValue instanceof Vector3) {
|
|
131
|
-
return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
|
|
132
|
-
}
|
|
133
|
-
if (referenceValue instanceof Vector4) {
|
|
134
|
-
return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
|
|
135
|
-
}
|
|
136
|
-
if (referenceValue instanceof UIColor) {
|
|
137
|
-
return new UIColor().setGLSLColor(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
|
|
138
|
-
}
|
|
139
|
-
if (referenceValue instanceof Matrix3) {
|
|
140
|
-
const matrix = new Matrix3();
|
|
141
|
-
matrix.fromArray(array, offset);
|
|
142
|
-
return matrix;
|
|
143
|
-
}
|
|
144
|
-
if (referenceValue instanceof Matrix4) {
|
|
145
|
-
const matrix = new Matrix4();
|
|
146
|
-
matrix.fromArray(array, offset);
|
|
147
|
-
return matrix;
|
|
148
|
-
}
|
|
149
|
-
throw new Error(`reconstructValue.referenceValue: cannot reconstruct value for type`);
|
|
150
|
-
}
|
|
151
158
|
/**
|
|
152
159
|
* Shift buffer region within the same array.
|
|
153
160
|
* Uses copyWithin for efficient memory moves with correct overlap handling.
|
|
154
161
|
*/
|
|
155
|
-
function shiftBufferRegion(array, itemSize, fromIndex, count, delta) {
|
|
162
|
+
export function shiftBufferRegion(array, itemSize, fromIndex, count, delta) {
|
|
156
163
|
if (count <= 0 || delta === 0) {
|
|
157
164
|
return;
|
|
158
165
|
}
|
|
@@ -164,10 +171,8 @@ function shiftBufferRegion(array, itemSize, fromIndex, count, delta) {
|
|
|
164
171
|
/**
|
|
165
172
|
* Copy data between two different buffers.
|
|
166
173
|
*/
|
|
167
|
-
function copyBetweenBuffers(src, srcOffset, dst, dstOffset, length) {
|
|
174
|
+
export function copyBetweenBuffers(src, srcOffset, dst, dstOffset, length) {
|
|
168
175
|
for (let i = 0; i < length; i++) {
|
|
169
176
|
dst[dstOffset + i] = src[srcOffset + i];
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
|
-
|
|
173
|
-
export { CAPACITY_STEP, INITIAL_CAPACITY, INSTANCED_PLANE_GEOMETRY, buildEmptyInstancedBufferAttribute, buildMaterial, copyBetweenBuffers, reconstructValue, shiftBufferRegion, writePropertyToArray };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { GLTypeInfo } from "../shared.js";
|
|
2
|
+
export interface PackedColumnSpec {
|
|
3
|
+
sourceOffset: number;
|
|
4
|
+
size: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A field to be packed. Its value is flattened into flatSize floats, and each column takes size
|
|
8
|
+
* (1..4) of them starting at sourceOffset. Columns are listed in the order the GLSL constructor of
|
|
9
|
+
* glslTypeName takes them, which is how the vertex shader reassembles the field.
|
|
10
|
+
*/
|
|
11
|
+
export interface PackedFieldSpec {
|
|
12
|
+
name: string;
|
|
13
|
+
glslTypeName: string;
|
|
14
|
+
flatSize: number;
|
|
15
|
+
columns: readonly PackedColumnSpec[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A column placed into the packed attribute attributeIndex, starting at its component
|
|
19
|
+
* componentOffset.
|
|
20
|
+
*/
|
|
21
|
+
export interface PackedColumn extends PackedColumnSpec {
|
|
22
|
+
attributeIndex: number;
|
|
23
|
+
componentOffset: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A field placed into packed attributes. Expression is the GLSL that reads it back from them in
|
|
27
|
+
* the vertex shader.
|
|
28
|
+
*/
|
|
29
|
+
export interface PackedField {
|
|
30
|
+
glslTypeName: string;
|
|
31
|
+
columns: readonly PackedColumn[];
|
|
32
|
+
expression: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* attributeSizes holds the item size (1..4) of each packed attribute. Two layouts with an equal
|
|
36
|
+
* signature place every field identically, so buffers can be copied between their planes as is.
|
|
37
|
+
*/
|
|
38
|
+
export interface PackedLayout {
|
|
39
|
+
attributeSizes: readonly number[];
|
|
40
|
+
fields: ReadonlyMap<string, PackedField>;
|
|
41
|
+
signature: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function packedAttributeName(attributeIndex: number): string;
|
|
44
|
+
export declare function buildPackedFieldSpec(name: string, glslTypeInfo: GLTypeInfo): PackedFieldSpec;
|
|
45
|
+
/**
|
|
46
|
+
* Places the columns of the given fields into packed attributes, first fit by decreasing size;
|
|
47
|
+
* with sizes of 1..4 and bins of 4 that takes the minimal number of attributes. Ties are broken by
|
|
48
|
+
* field name and column index, so the result does not depend on the order the fields come in.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildPackedLayout(specs: readonly PackedFieldSpec[]): PackedLayout;
|
|
51
|
+
export declare function resolvePackedField(layout: PackedLayout, name: string): PackedField;
|
|
52
|
+
export declare function buildPackedAttributeDeclarations(layout: PackedLayout): string[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Packing of per-instance fields into vertex attributes.
|
|
3
|
+
*
|
|
4
|
+
* A vertex attribute location holds at most a vec4, and an attribute of any smaller type still
|
|
5
|
+
* takes a whole location, while devices commonly offer only 16 locations. Declaring one attribute
|
|
6
|
+
* per field therefore spends most of that budget on padding. Instead every field is cut into
|
|
7
|
+
* columns of 1..4 floats (a matrix into its columns, anything else into a single column), and the
|
|
8
|
+
* columns are bin-packed into as few attributes as possible. The vertex shader reassembles each
|
|
9
|
+
* field from swizzles of the packed attributes.
|
|
10
|
+
*
|
|
11
|
+
* The layout is a pure function of the set of fields, independent of their declaration order, so
|
|
12
|
+
* planes built from the same fields always share a layout and their buffers can be merged or split
|
|
13
|
+
* by plain copies.
|
|
14
|
+
*/
|
|
15
|
+
const PACKED_ATTRIBUTE_CAPACITY = 4;
|
|
16
|
+
const PACKED_ATTRIBUTE_TYPES = ["float", "vec2", "vec3", "vec4"];
|
|
17
|
+
const SWIZZLE_COMPONENTS = "xyzw";
|
|
18
|
+
export function packedAttributeName(attributeIndex) {
|
|
19
|
+
return `a_packed${attributeIndex}`;
|
|
20
|
+
}
|
|
21
|
+
export function buildPackedFieldSpec(name, glslTypeInfo) {
|
|
22
|
+
const { glslTypeName, bufferSize, columnCount, instantiable } = glslTypeInfo;
|
|
23
|
+
if (!instantiable) {
|
|
24
|
+
throw new Error(`buildPackedFieldSpec.glslTypeInfo: "${name}" (${glslTypeName}) is not instantiable`);
|
|
25
|
+
}
|
|
26
|
+
const columnSize = bufferSize / columnCount;
|
|
27
|
+
const columns = [];
|
|
28
|
+
for (let i = 0; i < columnCount; i++) {
|
|
29
|
+
columns.push({ sourceOffset: i * columnSize, size: columnSize });
|
|
30
|
+
}
|
|
31
|
+
return { name, glslTypeName, flatSize: bufferSize, columns };
|
|
32
|
+
}
|
|
33
|
+
function compareNames(a, b) {
|
|
34
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Places the columns of the given fields into packed attributes, first fit by decreasing size;
|
|
38
|
+
* with sizes of 1..4 and bins of 4 that takes the minimal number of attributes. Ties are broken by
|
|
39
|
+
* field name and column index, so the result does not depend on the order the fields come in.
|
|
40
|
+
*/
|
|
41
|
+
export function buildPackedLayout(specs) {
|
|
42
|
+
const entries = [];
|
|
43
|
+
const names = new Set();
|
|
44
|
+
for (const spec of specs) {
|
|
45
|
+
if (names.has(spec.name)) {
|
|
46
|
+
throw new Error(`buildPackedLayout.specs: duplicate field "${spec.name}"`);
|
|
47
|
+
}
|
|
48
|
+
names.add(spec.name);
|
|
49
|
+
for (let i = 0; i < spec.columns.length; i++) {
|
|
50
|
+
const { sourceOffset, size } = spec.columns[i];
|
|
51
|
+
if (size < 1 || size > PACKED_ATTRIBUTE_CAPACITY || sourceOffset + size > spec.flatSize) {
|
|
52
|
+
throw new Error(`buildPackedLayout.specs: invalid column ${i} of field "${spec.name}"`);
|
|
53
|
+
}
|
|
54
|
+
entries.push({ spec, columnIndex: i });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
entries.sort((a, b) => b.spec.columns[b.columnIndex].size - a.spec.columns[a.columnIndex].size ||
|
|
58
|
+
compareNames(a.spec.name, b.spec.name) ||
|
|
59
|
+
a.columnIndex - b.columnIndex);
|
|
60
|
+
const attributeSizes = [];
|
|
61
|
+
const placements = new Map();
|
|
62
|
+
for (const { spec, columnIndex } of entries) {
|
|
63
|
+
const column = spec.columns[columnIndex];
|
|
64
|
+
let attributeIndex = attributeSizes.findIndex((used) => used + column.size <= PACKED_ATTRIBUTE_CAPACITY);
|
|
65
|
+
if (attributeIndex === -1) {
|
|
66
|
+
attributeIndex = attributeSizes.length;
|
|
67
|
+
attributeSizes.push(0);
|
|
68
|
+
}
|
|
69
|
+
let placed = placements.get(spec);
|
|
70
|
+
if (placed === undefined) {
|
|
71
|
+
placed = new Array(spec.columns.length);
|
|
72
|
+
placements.set(spec, placed);
|
|
73
|
+
}
|
|
74
|
+
placed[columnIndex] = {
|
|
75
|
+
sourceOffset: column.sourceOffset,
|
|
76
|
+
size: column.size,
|
|
77
|
+
attributeIndex,
|
|
78
|
+
componentOffset: attributeSizes[attributeIndex],
|
|
79
|
+
};
|
|
80
|
+
attributeSizes[attributeIndex] += column.size;
|
|
81
|
+
}
|
|
82
|
+
const fields = new Map();
|
|
83
|
+
const signatureParts = [];
|
|
84
|
+
for (const spec of [...specs].sort((a, b) => compareNames(a.name, b.name))) {
|
|
85
|
+
const columns = placements.get(spec) ?? [];
|
|
86
|
+
const columnExpressions = columns.map(({ attributeIndex, componentOffset, size }) => {
|
|
87
|
+
const attributeName = packedAttributeName(attributeIndex);
|
|
88
|
+
return size === attributeSizes[attributeIndex]
|
|
89
|
+
? attributeName
|
|
90
|
+
: `${attributeName}.${SWIZZLE_COMPONENTS.slice(componentOffset, componentOffset + size)}`;
|
|
91
|
+
});
|
|
92
|
+
const expression = columnExpressions.length === 1
|
|
93
|
+
? columnExpressions[0]
|
|
94
|
+
: `${spec.glslTypeName}(${columnExpressions.join(", ")})`;
|
|
95
|
+
fields.set(spec.name, { glslTypeName: spec.glslTypeName, columns, expression });
|
|
96
|
+
const sourceOffsets = columns.map(({ sourceOffset }) => sourceOffset).join(",");
|
|
97
|
+
signatureParts.push(`${spec.name}:${spec.glslTypeName}[${sourceOffsets}]=${expression}`);
|
|
98
|
+
}
|
|
99
|
+
return { attributeSizes, fields, signature: signatureParts.join(";") };
|
|
100
|
+
}
|
|
101
|
+
export function resolvePackedField(layout, name) {
|
|
102
|
+
const field = layout.fields.get(name);
|
|
103
|
+
if (field === undefined) {
|
|
104
|
+
throw new Error(`resolvePackedField.name: unknown field "${name}"`);
|
|
105
|
+
}
|
|
106
|
+
return field;
|
|
107
|
+
}
|
|
108
|
+
export function buildPackedAttributeDeclarations(layout) {
|
|
109
|
+
return layout.attributeSizes.map((size, index) => `attribute ${PACKED_ATTRIBUTE_TYPES[size - 1]} ${packedAttributeName(index)};`);
|
|
110
|
+
}
|