@haiyue/extensions 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/animation/Animation2DComponent.d.ts +46 -0
- package/dist/animation/Animation2DExtensionRegistry.d.ts +27 -0
- package/dist/animation/Animation2DRenderSystem.d.ts +89 -0
- package/dist/animation/Animation2DRuntime.d.ts +99 -0
- package/dist/animation/Animation2DStateMachine.d.ts +13 -0
- package/dist/animation/Animation2DStateMachineComponent.d.ts +54 -0
- package/dist/animation/Animation2DStateMachineRuntime.d.ts +30 -0
- package/dist/animation/Animation2DStateMachineSystem.d.ts +14 -0
- package/dist/animation/Animation2DStateMachineVisualRuntime.d.ts +27 -0
- package/dist/animation/Animation2DSystem.d.ts +14 -0
- package/dist/animation/AnimationAssetLoader.d.ts +9 -0
- package/dist/animation/AnimationAudioClip.d.ts +26 -0
- package/dist/animation/AnimationPathTessellator.d.ts +52 -0
- package/dist/animation/AnimationTextRasterizer.d.ts +21 -0
- package/dist/animation/AnimationVisual2D.d.ts +68 -0
- package/dist/animation/HyaAnimation2DClipAdapter.d.ts +16 -0
- package/dist/animation/Particle2DDescriptorAdapter.d.ts +5 -0
- package/dist/animation/runtime/mixer/Action.d.ts +150 -0
- package/dist/animation/runtime/mixer/Mixer.d.ts +54 -0
- package/dist/animation/runtime/mixer/PoseBuffer.d.ts +23 -0
- package/dist/animation/runtime/mixer/Sampler.d.ts +17 -0
- package/dist/animation/runtime/mixer/Types.d.ts +101 -0
- package/dist/animation/runtime/mixer/index.d.ts +6 -0
- package/dist/animation-state-machine/AnimationStateMachine.d.ts +111 -0
- package/dist/animation-state-machine/AnimationStateMachineChannels.d.ts +23 -0
- package/dist/animation-state-machine/runtime/Animation2DStateMachineMixerAdapter.d.ts +51 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineBlendTreeWeights.d.ts +14 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineCompiler.d.ts +109 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineController.d.ts +103 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineMixerPort.d.ts +35 -0
- package/dist/animation-state-machine/runtime/index.d.ts +7 -0
- package/dist/animation.d.ts +15 -0
- package/dist/animation.js +1171 -0
- package/dist/animation3d/Animation3DAction.d.ts +46 -0
- package/dist/animation3d/Animation3DBinding.d.ts +85 -0
- package/dist/animation3d/Animation3DClip.d.ts +20 -0
- package/dist/animation3d/Animation3DError.d.ts +13 -0
- package/dist/animation3d/Animation3DMixer.d.ts +27 -0
- package/dist/animation3d/Animation3DPose.d.ts +40 -0
- package/dist/animation3d/Animation3DPoseBuffer.d.ts +24 -0
- package/dist/animation3d/Animation3DResource.d.ts +28 -0
- package/dist/animation3d/Animation3DStateMachine.d.ts +95 -0
- package/dist/animation3d/Animation3DStateMachineRuntime.d.ts +70 -0
- package/dist/animation3d/Animation3DTrack.d.ts +19 -0
- package/dist/animation3d/hya/HyaAnimation3DRuntime.d.ts +73 -0
- package/dist/animation3d/hya/HyaAnimation3DStateMachineRuntime.d.ts +65 -0
- package/dist/animation3d/hya/HyaAnimation3DTypes.d.ts +170 -0
- package/dist/animation3d/hya/index.d.ts +4 -0
- package/dist/animation3d/index.d.ts +14 -0
- package/dist/animation3d/runtime/integration/Animation3DStateMachineMixerAdapter.d.ts +81 -0
- package/dist/animation3d/runtime/integration/Animation3DStateMachineMixerIntegration.d.ts +39 -0
- package/dist/animation3d/runtime/integration/index.d.ts +2 -0
- package/dist/animation3d/runtime/mixer/Action.d.ts +150 -0
- package/dist/animation3d/runtime/mixer/Animation3DMixerRuntimeStore.d.ts +6 -0
- package/dist/animation3d/runtime/mixer/Mixer.d.ts +59 -0
- package/dist/animation3d/runtime/mixer/PoseBuffer.d.ts +1 -0
- package/dist/animation3d/runtime/mixer/TrackSampler.d.ts +24 -0
- package/dist/animation3d/runtime/mixer/index.d.ts +4 -0
- package/dist/animation3d/runtime/state-machine/Animation3DBlendTreeWeights.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineCompiler.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineController.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineMixerPort.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/index.d.ts +6 -0
- package/dist/animation3d.d.ts +5 -0
- package/dist/animation3d.js +1708 -0
- package/dist/benchmark.d.ts +30 -0
- package/dist/benchmark.js +119 -0
- package/dist/canvas-text/CanvasText2DRenderSystem.d.ts +24 -0
- package/dist/canvas-text/CanvasTextComponent.d.ts +18 -0
- package/dist/canvas-text.d.ts +4 -0
- package/dist/canvas-text.js +276 -0
- package/dist/chunks/2d-ui-animation-2d.generated-D4aHzFU2.js +4 -0
- package/dist/chunks/2d-ui-canvas-text-2d.generated-C0Eaej2m.js +4 -0
- package/dist/chunks/2d-ui-spine2d.generated-CUUi8xjl.js +4 -0
- package/dist/chunks/2d-ui-tilemap2d.generated-gebw4mX7.js +4 -0
- package/dist/chunks/Animation2DStateMachine-9IonguNa.js +3245 -0
- package/dist/chunks/AnimationStateMachineController-BIcAh-sT.js +1438 -0
- package/dist/chunks/GltfAnimation3DAdapter-Cu3rQQsW.js +2240 -0
- package/dist/chunks/GltfAnimationRuntime-CRHsLycN.js +631 -0
- package/dist/chunks/RenderSystem2DBase-DDT61dAu.js +227 -0
- package/dist/chunks/Spine2DRuntime-D9M9LAQR.js +3056 -0
- package/dist/chunks/SpineAssetParser-BSDmPge1.js +378 -0
- package/dist/chunks/gltfLoader-Dm22jLYB.js +2085 -0
- package/dist/chunks/pluginUtils-CvwroRMd.js +33 -0
- package/dist/experimental-gltf-worker.d.ts +4 -0
- package/dist/experimental-gltf-worker.js +138 -0
- package/dist/experimental-spine-worker.d.ts +4 -0
- package/dist/experimental-spine-worker.js +110 -0
- package/dist/gltf/GltfAccessorReader.d.ts +7 -0
- package/dist/gltf/GltfAnimation3DAdapter.d.ts +47 -0
- package/dist/gltf/GltfAnimationRuntime.d.ts +10 -0
- package/dist/gltf/GltfAssetWorkerClient.d.ts +20 -0
- package/dist/gltf/GltfCompatibilityReport.d.ts +70 -0
- package/dist/gltf/GltfConservativeBounds.d.ts +18 -0
- package/dist/gltf/GltfDracoDecoder.d.ts +4 -0
- package/dist/gltf/GltfExtensionAdapter.d.ts +54 -0
- package/dist/gltf/GltfLoaderContract.d.ts +249 -0
- package/dist/gltf/GltfLoaderErrors.d.ts +4 -0
- package/dist/gltf/GltfMaterialDescriptor.d.ts +23 -0
- package/dist/gltf/GltfMaterialEncoder.d.ts +20 -0
- package/dist/gltf/GltfMaterialLoader.d.ts +6 -0
- package/dist/gltf/GltfModelComponent.d.ts +72 -0
- package/dist/gltf/GltfModelSystem.d.ts +37 -0
- package/dist/gltf/GltfPlugin.d.ts +6 -0
- package/dist/gltf/GltfSchema.d.ts +225 -0
- package/dist/gltf/GltfUvSemanticPlanner.d.ts +33 -0
- package/dist/gltf/gltfLoader.d.ts +9 -0
- package/dist/gltf-animation3d.d.ts +3 -0
- package/dist/gltf-animation3d.js +8 -0
- package/dist/gltf-worker-runtime.d.ts +7 -0
- package/dist/gltf-worker-runtime.js +6981 -0
- package/dist/gltf.d.ts +12 -0
- package/dist/gltf.js +517 -0
- package/dist/grid/Grid2DComponent.d.ts +25 -0
- package/dist/grid.d.ts +2 -0
- package/dist/grid.js +56 -0
- package/dist/hya-state-machine.d.ts +7 -0
- package/dist/hya-state-machine.js +2934 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/internal/2d-ui-shader-artifact.js +870 -0
- package/dist/plugins/pluginUtils.d.ts +20 -0
- package/dist/plugins.d.ts +6 -0
- package/dist/shaders/generated/2d-ui-artifact.generated.d.ts +658 -0
- package/dist/spine/Spine2DComponent.d.ts +116 -0
- package/dist/spine/Spine2DGpuRenderer.d.ts +65 -0
- package/dist/spine/Spine2DRenderSystem.d.ts +27 -0
- package/dist/spine/Spine2DRuntime.d.ts +103 -0
- package/dist/spine/SpineAnimationBoneTimelines.d.ts +8 -0
- package/dist/spine/SpineAssetParser.d.ts +18 -0
- package/dist/spine/SpineAssetWorkerClient.d.ts +19 -0
- package/dist/spine/SpineAssetWorkerContract.d.ts +6 -0
- package/dist/spine/SpineAtlasParser.d.ts +21 -0
- package/dist/spine/SpineFloatBuilder.d.ts +15 -0
- package/dist/spine/SpinePathConstraintSolver.d.ts +32 -0
- package/dist/spine/SpinePlugin.d.ts +8 -0
- package/dist/spine/SpineSkeletonRuntime.d.ts +185 -0
- package/dist/spine/SpineSlotAnimation.d.ts +17 -0
- package/dist/spine/SpineTimelineRuntime.d.ts +25 -0
- package/dist/spine/SpineVertexBuilder.d.ts +61 -0
- package/dist/spine.d.ts +7 -0
- package/dist/spine.js +578 -0
- package/dist/tilemap/Tilemap2DComponent.d.ts +110 -0
- package/dist/tilemap/Tilemap2DRenderSystem.d.ts +11 -0
- package/dist/tilemap/Tilemap2DRenderer.d.ts +24 -0
- package/dist/tilemap/TilemapPlugin.d.ts +8 -0
- package/dist/tilemap.d.ts +6 -0
- package/dist/tilemap.js +535 -0
- package/dist/tween/Tween2DComponent.d.ts +70 -0
- package/dist/tween/Tween2DSystem.d.ts +12 -0
- package/dist/tween.d.ts +4 -0
- package/dist/tween.js +138 -0
- package/dist/utils/RenderSystem2DBase.d.ts +42 -0
- package/dist/utils/arrayAccess.d.ts +4 -0
- package/dist/utils/camera2d.d.ts +12 -0
- package/dist/utils/render2dGpu.d.ts +32 -0
- package/package.json +124 -0
- package/src/animation/Animation2DComponent.ts +135 -0
- package/src/animation/Animation2DExtensionRegistry.ts +52 -0
- package/src/animation/Animation2DRenderSystem.ts +1026 -0
- package/src/animation/Animation2DRuntime.ts +1326 -0
- package/src/animation/Animation2DStateMachine.ts +39 -0
- package/src/animation/Animation2DStateMachineComponent.ts +228 -0
- package/src/animation/Animation2DStateMachineRuntime.ts +141 -0
- package/src/animation/Animation2DStateMachineSystem.ts +60 -0
- package/src/animation/Animation2DStateMachineVisualRuntime.ts +282 -0
- package/src/animation/Animation2DSystem.ts +72 -0
- package/src/animation/AnimationAssetLoader.ts +84 -0
- package/src/animation/AnimationAudioClip.ts +140 -0
- package/src/animation/AnimationPathTessellator.ts +691 -0
- package/src/animation/AnimationTextRasterizer.ts +340 -0
- package/src/animation/AnimationVisual2D.ts +153 -0
- package/src/animation/HyaAnimation2DClipAdapter.ts +845 -0
- package/src/animation/Particle2DDescriptorAdapter.ts +35 -0
- package/src/animation/runtime/mixer/Action.ts +876 -0
- package/src/animation/runtime/mixer/Mixer.ts +505 -0
- package/src/animation/runtime/mixer/PoseBuffer.ts +105 -0
- package/src/animation/runtime/mixer/Sampler.ts +252 -0
- package/src/animation/runtime/mixer/Types.ts +138 -0
- package/src/animation/runtime/mixer/index.ts +31 -0
- package/src/animation-state-machine/AnimationStateMachine.ts +146 -0
- package/src/animation-state-machine/AnimationStateMachineChannels.ts +116 -0
- package/src/animation-state-machine/runtime/Animation2DStateMachineMixerAdapter.ts +197 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineBlendTreeWeights.ts +503 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineCompiler.ts +763 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineController.ts +987 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineMixerPort.ts +54 -0
- package/src/animation-state-machine/runtime/index.ts +47 -0
- package/src/animation.ts +33 -0
- package/src/animation3d/Animation3DAction.ts +73 -0
- package/src/animation3d/Animation3DBinding.ts +116 -0
- package/src/animation3d/Animation3DClip.ts +22 -0
- package/src/animation3d/Animation3DError.ts +34 -0
- package/src/animation3d/Animation3DMixer.ts +82 -0
- package/src/animation3d/Animation3DPose.ts +100 -0
- package/src/animation3d/Animation3DPoseBuffer.ts +85 -0
- package/src/animation3d/Animation3DResource.ts +49 -0
- package/src/animation3d/Animation3DStateMachine.ts +126 -0
- package/src/animation3d/Animation3DStateMachineRuntime.ts +191 -0
- package/src/animation3d/Animation3DTrack.ts +29 -0
- package/src/animation3d/hya/HyaAnimation3DRuntime.ts +756 -0
- package/src/animation3d/hya/HyaAnimation3DStateMachineRuntime.ts +618 -0
- package/src/animation3d/hya/HyaAnimation3DTypes.ts +168 -0
- package/src/animation3d/hya/index.ts +10 -0
- package/src/animation3d/index.ts +76 -0
- package/src/animation3d/runtime/integration/Animation3DStateMachineMixerAdapter.ts +325 -0
- package/src/animation3d/runtime/integration/Animation3DStateMachineMixerIntegration.ts +158 -0
- package/src/animation3d/runtime/integration/index.ts +9 -0
- package/src/animation3d/runtime/mixer/Action.ts +833 -0
- package/src/animation3d/runtime/mixer/Animation3DMixerRuntimeStore.ts +26 -0
- package/src/animation3d/runtime/mixer/Mixer.ts +562 -0
- package/src/animation3d/runtime/mixer/PoseBuffer.ts +1 -0
- package/src/animation3d/runtime/mixer/TrackSampler.ts +399 -0
- package/src/animation3d/runtime/mixer/index.ts +8 -0
- package/src/animation3d/runtime/state-machine/Animation3DBlendTreeWeights.ts +4 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineCompiler.ts +1 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineController.ts +1 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineMixerPort.ts +1 -0
- package/src/animation3d/runtime/state-machine/index.ts +45 -0
- package/src/animation3d.ts +5 -0
- package/src/benchmark.ts +168 -0
- package/src/canvas-text/CanvasText2DRenderSystem.ts +292 -0
- package/src/canvas-text/CanvasTextComponent.ts +47 -0
- package/src/canvas-text.ts +4 -0
- package/src/experimental-gltf-worker.ts +18 -0
- package/src/experimental-spine-worker.ts +9 -0
- package/src/gltf/GltfAccessorReader.ts +271 -0
- package/src/gltf/GltfAnimation3DAdapter.ts +680 -0
- package/src/gltf/GltfAnimationRuntime.ts +392 -0
- package/src/gltf/GltfAssetWorkerClient.ts +136 -0
- package/src/gltf/GltfCompatibilityReport.ts +214 -0
- package/src/gltf/GltfConservativeBounds.ts +219 -0
- package/src/gltf/GltfDracoDecoder.ts +251 -0
- package/src/gltf/GltfExtensionAdapter.ts +340 -0
- package/src/gltf/GltfLoaderContract.ts +333 -0
- package/src/gltf/GltfLoaderErrors.ts +59 -0
- package/src/gltf/GltfMaterialDescriptor.ts +134 -0
- package/src/gltf/GltfMaterialEncoder.ts +173 -0
- package/src/gltf/GltfMaterialLoader.ts +293 -0
- package/src/gltf/GltfModelComponent.ts +115 -0
- package/src/gltf/GltfModelSystem.ts +208 -0
- package/src/gltf/GltfPlugin.ts +84 -0
- package/src/gltf/GltfSchema.ts +229 -0
- package/src/gltf/GltfUvSemanticPlanner.ts +166 -0
- package/src/gltf/gltfLoader.ts +910 -0
- package/src/gltf-animation3d.ts +10 -0
- package/src/gltf-worker-runtime.ts +10 -0
- package/src/gltf.ts +56 -0
- package/src/grid/Grid2DComponent.ts +69 -0
- package/src/grid.ts +2 -0
- package/src/hya-state-machine.ts +19 -0
- package/src/index.ts +2 -0
- package/src/plugins/pluginUtils.ts +50 -0
- package/src/plugins.ts +6 -0
- package/src/shaders/generated/2d-ui-animation-2d.generated.wgsl +242 -0
- package/src/shaders/generated/2d-ui-artifact.generated.ts +867 -0
- package/src/shaders/generated/2d-ui-canvas-text-2d.generated.wgsl +38 -0
- package/src/shaders/generated/2d-ui-spine2d.generated.wgsl +41 -0
- package/src/shaders/generated/2d-ui-tilemap2d.generated.wgsl +36 -0
- package/src/spine/Spine2DComponent.ts +168 -0
- package/src/spine/Spine2DGpuRenderer.ts +449 -0
- package/src/spine/Spine2DRenderSystem.ts +199 -0
- package/src/spine/Spine2DRuntime.ts +1529 -0
- package/src/spine/SpineAnimationBoneTimelines.ts +30 -0
- package/src/spine/SpineAssetParser.ts +20 -0
- package/src/spine/SpineAssetWorkerClient.ts +112 -0
- package/src/spine/SpineAssetWorkerContract.ts +4 -0
- package/src/spine/SpineAtlasParser.ts +127 -0
- package/src/spine/SpineFloatBuilder.ts +66 -0
- package/src/spine/SpinePathConstraintSolver.ts +582 -0
- package/src/spine/SpinePlugin.ts +76 -0
- package/src/spine/SpineSkeletonRuntime.ts +521 -0
- package/src/spine/SpineSlotAnimation.ts +195 -0
- package/src/spine/SpineTimelineRuntime.ts +453 -0
- package/src/spine/SpineVertexBuilder.ts +686 -0
- package/src/spine.ts +7 -0
- package/src/tilemap/Tilemap2DComponent.ts +232 -0
- package/src/tilemap/Tilemap2DRenderSystem.ts +58 -0
- package/src/tilemap/Tilemap2DRenderer.ts +289 -0
- package/src/tilemap/TilemapPlugin.ts +75 -0
- package/src/tilemap.ts +6 -0
- package/src/tween/Tween2DComponent.ts +83 -0
- package/src/tween/Tween2DSystem.ts +78 -0
- package/src/tween.ts +4 -0
- package/src/types/earcut.d.ts +7 -0
- package/src/types/wgsl.d.ts +4 -0
- package/src/utils/RenderSystem2DBase.ts +164 -0
- package/src/utils/arrayAccess.ts +17 -0
- package/src/utils/camera2d.ts +68 -0
- package/src/utils/render2dGpu.ts +132 -0
- package/test/fixtures/gltf/animation-characterization.gltf +344 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// haiyue:builtin-render canvas-text-2d
|
|
2
|
+
// source: shader-language/builtin-components-2d-ui-family.json
|
|
3
|
+
|
|
4
|
+
struct CameraUniforms {
|
|
5
|
+
viewProj : mat4x4<f32>,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
struct ObjectUniforms {
|
|
9
|
+
model : mat4x4<f32>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@group(0) @binding(0) var<uniform> camera : CameraUniforms;
|
|
13
|
+
@group(1) @binding(0) var<uniform> object : ObjectUniforms;
|
|
14
|
+
@group(2) @binding(0) var textTexture : texture_2d<f32>;
|
|
15
|
+
@group(2) @binding(1) var textSampler : sampler;
|
|
16
|
+
|
|
17
|
+
struct VertexInput {
|
|
18
|
+
@location(0) position : vec2<f32>,
|
|
19
|
+
@location(1) uv : vec2<f32>,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
struct VertexOutput {
|
|
23
|
+
@builtin(position) clipPos : vec4<f32>,
|
|
24
|
+
@location(0) uv : vec2<f32>,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@vertex
|
|
28
|
+
fn vs_main(input : VertexInput) -> VertexOutput {
|
|
29
|
+
var out : VertexOutput;
|
|
30
|
+
out.clipPos = camera.viewProj * object.model * vec4<f32>(input.position, 0.0, 1.0);
|
|
31
|
+
out.uv = input.uv;
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@fragment
|
|
36
|
+
fn fs_main(input : VertexOutput) -> @location(0) vec4<f32> {
|
|
37
|
+
return textureSample(textTexture, textSampler, input.uv);
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// haiyue:builtin-render spine2d
|
|
2
|
+
// source: shader-language/builtin-components-2d-ui-family.json
|
|
3
|
+
|
|
4
|
+
struct CameraUniforms {
|
|
5
|
+
viewProj : mat4x4<f32>,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
struct ObjectUniforms {
|
|
9
|
+
model : mat4x4<f32>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@group(0) @binding(0) var<uniform> camera : CameraUniforms;
|
|
13
|
+
@group(1) @binding(0) var<uniform> object : ObjectUniforms;
|
|
14
|
+
@group(2) @binding(0) var atlasTexture : texture_2d<f32>;
|
|
15
|
+
@group(2) @binding(1) var atlasSampler : sampler;
|
|
16
|
+
|
|
17
|
+
struct VertexInput {
|
|
18
|
+
@location(0) position : vec2<f32>,
|
|
19
|
+
@location(1) uv : vec2<f32>,
|
|
20
|
+
@location(2) color : vec4<f32>,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
struct VertexOutput {
|
|
24
|
+
@builtin(position) clipPos : vec4<f32>,
|
|
25
|
+
@location(0) uv : vec2<f32>,
|
|
26
|
+
@location(1) color : vec4<f32>,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@vertex
|
|
30
|
+
fn vs_main(input : VertexInput) -> VertexOutput {
|
|
31
|
+
var out : VertexOutput;
|
|
32
|
+
out.clipPos = camera.viewProj * object.model * vec4<f32>(input.position, 0.0, 1.0);
|
|
33
|
+
out.uv = input.uv;
|
|
34
|
+
out.color = input.color;
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@fragment
|
|
39
|
+
fn fs_main(input : VertexOutput) -> @location(0) vec4<f32> {
|
|
40
|
+
return textureSample(atlasTexture, atlasSampler, input.uv) * input.color;
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// haiyue:builtin-render tilemap2d
|
|
2
|
+
// source: shader-language/builtin-components-2d-ui-family.json
|
|
3
|
+
|
|
4
|
+
struct CameraUniforms {
|
|
5
|
+
viewProj : mat4x4<f32>,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
struct ObjectUniforms {
|
|
9
|
+
model : mat4x4<f32>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@group(0) @binding(0) var<uniform> camera : CameraUniforms;
|
|
13
|
+
@group(1) @binding(0) var<uniform> object : ObjectUniforms;
|
|
14
|
+
|
|
15
|
+
struct VertexInput {
|
|
16
|
+
@location(0) position : vec2<f32>,
|
|
17
|
+
@location(1) color : vec4<f32>,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
struct VertexOutput {
|
|
21
|
+
@builtin(position) clipPos : vec4<f32>,
|
|
22
|
+
@location(0) color : vec4<f32>,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@vertex
|
|
26
|
+
fn vs_main(input : VertexInput) -> VertexOutput {
|
|
27
|
+
var out : VertexOutput;
|
|
28
|
+
out.clipPos = camera.viewProj * object.model * vec4<f32>(input.position, 0.0, 1.0);
|
|
29
|
+
out.color = input.color;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@fragment
|
|
34
|
+
fn fs_main(input : VertexOutput) -> @location(0) vec4<f32> {
|
|
35
|
+
return input.color;
|
|
36
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Component } from '@haiyue/engine';
|
|
2
|
+
import { UniqueCheckType } from '@haiyue/engine/ecs';
|
|
3
|
+
|
|
4
|
+
export interface Spine2DComponentOptions {
|
|
5
|
+
jsonUrl?: string;
|
|
6
|
+
atlasUrl?: string;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
imageUrls?: Record<string, string>;
|
|
9
|
+
skin?: string;
|
|
10
|
+
animation?: string;
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
timeScale?: number;
|
|
13
|
+
scale?: number;
|
|
14
|
+
premultipliedAlpha?: boolean;
|
|
15
|
+
debugMesh?: boolean;
|
|
16
|
+
debugBones?: boolean;
|
|
17
|
+
mixDuration?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Spine2DStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
21
|
+
|
|
22
|
+
export class Spine2DComponent extends Component {
|
|
23
|
+
static override UniqueCheckType = UniqueCheckType.SYMBOL | UniqueCheckType.REPLACE;
|
|
24
|
+
static override UniqueSymbol = Symbol.for('Spine2DComponent');
|
|
25
|
+
static editor = {
|
|
26
|
+
fields: {
|
|
27
|
+
jsonUrl: { type: 'text', label: 'Skeleton JSON URL' },
|
|
28
|
+
atlasUrl: { type: 'text', label: 'Atlas URL' },
|
|
29
|
+
imageUrl: { type: 'text', label: 'Image URL Override' },
|
|
30
|
+
skin: { type: 'text', label: 'Skin' },
|
|
31
|
+
animation: { type: 'text', label: 'Animation' },
|
|
32
|
+
loop: { type: 'boolean', label: 'Loop' },
|
|
33
|
+
timeScale: { type: 'number', label: 'Time Scale', step: 0.1 },
|
|
34
|
+
scale: { type: 'number', label: 'Scale', min: 0.001, step: 0.1 },
|
|
35
|
+
premultipliedAlpha: { type: 'boolean', label: 'Premultiplied Alpha' },
|
|
36
|
+
debugMesh: { type: 'boolean', label: 'Debug Mesh' },
|
|
37
|
+
debugBones: { type: 'boolean', label: 'Debug Bones' },
|
|
38
|
+
mixDuration: { type: 'number', label: 'Mix Duration', min: 0, step: 0.05 },
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
private _jsonUrl = '';
|
|
43
|
+
private _atlasUrl = '';
|
|
44
|
+
private _imageUrl = '';
|
|
45
|
+
private _imageUrls: Record<string, string> = {};
|
|
46
|
+
private _imageUrlsKey = '{}';
|
|
47
|
+
private _skin = 'default';
|
|
48
|
+
private _sourceKey = '';
|
|
49
|
+
private _sourceKeyDirty = true;
|
|
50
|
+
|
|
51
|
+
animation: string;
|
|
52
|
+
loop: boolean;
|
|
53
|
+
timeScale: number;
|
|
54
|
+
scale: number;
|
|
55
|
+
premultipliedAlpha: boolean;
|
|
56
|
+
debugMesh: boolean;
|
|
57
|
+
debugBones: boolean;
|
|
58
|
+
mixDuration: number;
|
|
59
|
+
|
|
60
|
+
status: Spine2DStatus = 'idle';
|
|
61
|
+
error: string | null = null;
|
|
62
|
+
elapsed = 0;
|
|
63
|
+
previousAnimation = '';
|
|
64
|
+
previousElapsed = 0;
|
|
65
|
+
mixElapsed = 0;
|
|
66
|
+
runtimeKey = '';
|
|
67
|
+
loadingKey = '';
|
|
68
|
+
|
|
69
|
+
constructor(options: Spine2DComponentOptions = {}) {
|
|
70
|
+
super('Spine2DComponent');
|
|
71
|
+
this.jsonUrl = options.jsonUrl ?? '';
|
|
72
|
+
this.atlasUrl = options.atlasUrl ?? '';
|
|
73
|
+
this.imageUrl = options.imageUrl ?? '';
|
|
74
|
+
this.imageUrls = options.imageUrls ?? {};
|
|
75
|
+
this.skin = options.skin ?? 'default';
|
|
76
|
+
this.animation = options.animation ?? '';
|
|
77
|
+
this.loop = options.loop ?? true;
|
|
78
|
+
this.timeScale = options.timeScale ?? 1;
|
|
79
|
+
this.scale = options.scale ?? 1;
|
|
80
|
+
this.premultipliedAlpha = options.premultipliedAlpha ?? false;
|
|
81
|
+
this.debugMesh = options.debugMesh ?? false;
|
|
82
|
+
this.debugBones = options.debugBones ?? false;
|
|
83
|
+
this.mixDuration = options.mixDuration ?? 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get jsonUrl(): string {
|
|
87
|
+
return this._jsonUrl;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
set jsonUrl(value: string) {
|
|
91
|
+
if (this._jsonUrl === value) return;
|
|
92
|
+
this._jsonUrl = value;
|
|
93
|
+
this.invalidateSourceKey(false);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get atlasUrl(): string {
|
|
97
|
+
return this._atlasUrl;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
set atlasUrl(value: string) {
|
|
101
|
+
if (this._atlasUrl === value) return;
|
|
102
|
+
this._atlasUrl = value;
|
|
103
|
+
this.invalidateSourceKey(false);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get imageUrl(): string {
|
|
107
|
+
return this._imageUrl;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set imageUrl(value: string) {
|
|
111
|
+
if (this._imageUrl === value) return;
|
|
112
|
+
this._imageUrl = value;
|
|
113
|
+
this.invalidateSourceKey(false);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get imageUrls(): Record<string, string> {
|
|
117
|
+
return this._imageUrls;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
set imageUrls(value: Record<string, string>) {
|
|
121
|
+
if (this._imageUrls === value) return;
|
|
122
|
+
this._imageUrls = value;
|
|
123
|
+
this._imageUrlsKey = JSON.stringify(value);
|
|
124
|
+
this.invalidateSourceKey(false);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get skin(): string {
|
|
128
|
+
return this._skin;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
set skin(value: string) {
|
|
132
|
+
if (this._skin === value) return;
|
|
133
|
+
this._skin = value;
|
|
134
|
+
this.invalidateSourceKey(false);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get sourceKey(): string {
|
|
138
|
+
if (this._sourceKeyDirty) {
|
|
139
|
+
this._sourceKey = `${this._jsonUrl}|${this._atlasUrl}|${this._imageUrl}|${this._imageUrlsKey}|${this._skin}`;
|
|
140
|
+
this._sourceKeyDirty = false;
|
|
141
|
+
}
|
|
142
|
+
return this._sourceKey;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
invalidateSourceKey(refreshImageUrlsKey = true): this {
|
|
146
|
+
if (refreshImageUrlsKey) this._imageUrlsKey = JSON.stringify(this._imageUrls);
|
|
147
|
+
this._sourceKeyDirty = true;
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
override clone(): Spine2DComponent {
|
|
152
|
+
return new Spine2DComponent({
|
|
153
|
+
jsonUrl: this.jsonUrl,
|
|
154
|
+
atlasUrl: this.atlasUrl,
|
|
155
|
+
imageUrl: this.imageUrl,
|
|
156
|
+
imageUrls: { ...this.imageUrls },
|
|
157
|
+
skin: this.skin,
|
|
158
|
+
animation: this.animation,
|
|
159
|
+
loop: this.loop,
|
|
160
|
+
timeScale: this.timeScale,
|
|
161
|
+
scale: this.scale,
|
|
162
|
+
premultipliedAlpha: this.premultipliedAlpha,
|
|
163
|
+
debugMesh: this.debugMesh,
|
|
164
|
+
debugBones: this.debugBones,
|
|
165
|
+
mixDuration: this.mixDuration,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|