@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,33 @@
|
|
|
1
|
+
const EXTENSIONS_PLUGIN_VERSION = '0.1.0';
|
|
2
|
+
function removeSystem(context, system) {
|
|
3
|
+
if (system)
|
|
4
|
+
context.world.removeSystem(system);
|
|
5
|
+
}
|
|
6
|
+
function installEditorRenderSystem(context, constructor, create) {
|
|
7
|
+
let system = context.world.getSystem(constructor);
|
|
8
|
+
const created = system === null;
|
|
9
|
+
if (!system) {
|
|
10
|
+
system = create();
|
|
11
|
+
context.world.addSystem(system);
|
|
12
|
+
}
|
|
13
|
+
system.setCameraEntity?.(context.camera2DEntity);
|
|
14
|
+
if (context.registerRenderSystem) {
|
|
15
|
+
system.autoUpdate = false;
|
|
16
|
+
context.registerRenderSystem(system);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
system.autoUpdate = true;
|
|
20
|
+
}
|
|
21
|
+
return ownedEditorViewportSystem(context.world, system, created);
|
|
22
|
+
}
|
|
23
|
+
function ownedEditorViewportSystem(world, system, owned) {
|
|
24
|
+
return {
|
|
25
|
+
dispose() {
|
|
26
|
+
if (owned && world.hasSystem(system))
|
|
27
|
+
world.removeSystem(system);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { EXTENSIONS_PLUGIN_VERSION as E, installEditorRenderSystem as i, ownedEditorViewportSystem as o, removeSystem as r };
|
|
33
|
+
//# sourceMappingURL=pluginUtils-CvwroRMd.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Experimental worker transport and low-level parsing contracts for glTF. */
|
|
2
|
+
export { GltfAssetWorkerClient, createGltfAssetWorkerClientFromUrl, createGltfAssetWorkerSource, createInlineGltfAssetWorkerClient, } from './gltf/GltfAssetWorkerClient';
|
|
3
|
+
export { loadParsedGltfAsset, prepareGltfGeometryPayloads, } from './gltf/gltfLoader';
|
|
4
|
+
export type { GltfAnimationChannelRuntime, GltfAnimationTarget, GltfGeometryPayloadMatrix, GltfParsedAsset, GltfPrimitiveGeometryPayload, } from './gltf/gltfLoader';
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { WorkerChannel } from '@haiyue/engine/experimental/async';
|
|
2
|
+
import { i as isGltfParsedAsset } from './chunks/gltfLoader-Dm22jLYB.js';
|
|
3
|
+
export { l as loadParsedGltfAsset, p as prepareGltfGeometryPayloads } from './chunks/gltfLoader-Dm22jLYB.js';
|
|
4
|
+
import '@haiyue/engine';
|
|
5
|
+
import '@haiyue/engine/components';
|
|
6
|
+
import 'wgpu-matrix';
|
|
7
|
+
import '@haiyue/engine/material';
|
|
8
|
+
import './chunks/GltfAnimationRuntime-CRHsLycN.js';
|
|
9
|
+
import '@haiyue/engine/core';
|
|
10
|
+
|
|
11
|
+
class GltfAssetWorkerClient {
|
|
12
|
+
objectUrl;
|
|
13
|
+
channel;
|
|
14
|
+
constructor(worker, objectUrl = null) {
|
|
15
|
+
this.objectUrl = objectUrl;
|
|
16
|
+
this.channel = new WorkerChannel(worker, {
|
|
17
|
+
label: 'glTF asset worker',
|
|
18
|
+
path: 'gltf.worker',
|
|
19
|
+
context: { resourceType: 'model/gltf' },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
loadParsedAsset(src, options = {}) {
|
|
23
|
+
return this.channel.request('loadParsedGltfAsset', {
|
|
24
|
+
src,
|
|
25
|
+
dracoDecoderConfig: toWorkerDracoDecoderConfig(options.dracoDecoderConfig),
|
|
26
|
+
}, {
|
|
27
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
28
|
+
context: { url: src },
|
|
29
|
+
abortMessage: 'glTF load aborted.',
|
|
30
|
+
validate: isGltfParsedAsset,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
dispose(options = {}) {
|
|
34
|
+
const alreadyDisposed = this.channel.isDisposed;
|
|
35
|
+
this.channel.dispose(options);
|
|
36
|
+
if (!alreadyDisposed && this.objectUrl)
|
|
37
|
+
URL.revokeObjectURL(this.objectUrl);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function toWorkerDracoDecoderConfig(config) {
|
|
41
|
+
if (!config)
|
|
42
|
+
return undefined;
|
|
43
|
+
return {
|
|
44
|
+
...(config.scriptUrl === undefined ? {} : { scriptUrl: config.scriptUrl }),
|
|
45
|
+
...(config.wasmBinary === undefined ? {} : { wasmBinary: config.wasmBinary }),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The worker imports the same production parser used by the main-thread fallback. */
|
|
49
|
+
function createGltfAssetWorkerSource(extensionGltfModuleUrl) {
|
|
50
|
+
return `
|
|
51
|
+
const parserModulePromise = import(${JSON.stringify(extensionGltfModuleUrl)});
|
|
52
|
+
const requests = new Map();
|
|
53
|
+
self.addEventListener('message', async event => {
|
|
54
|
+
const request = event.data;
|
|
55
|
+
if (!request || request.version !== 1 || typeof request.id !== 'number') return;
|
|
56
|
+
if (request.type === 'cancel') {
|
|
57
|
+
requests.get(request.id)?.abort('cancelled');
|
|
58
|
+
requests.delete(request.id);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (request.type !== 'loadParsedGltfAsset') return;
|
|
62
|
+
const controller = new AbortController();
|
|
63
|
+
requests.set(request.id, controller);
|
|
64
|
+
try {
|
|
65
|
+
const parser = await parserModulePromise;
|
|
66
|
+
const value = await parser.loadParsedGltfAsset(request.src, controller.signal);
|
|
67
|
+
const geometryStartedAt = performance.now();
|
|
68
|
+
let dracoDecodeMs = 0;
|
|
69
|
+
value.geometryPayloads = await parser.prepareGltfGeometryPayloads(value.gltf, value.buffers, {
|
|
70
|
+
signal: controller.signal,
|
|
71
|
+
dracoDecoderConfig: request.dracoDecoderConfig,
|
|
72
|
+
diagnostics: {
|
|
73
|
+
onDracoDecode(durationMs) { dracoDecodeMs += durationMs; },
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const geometryPreparationMs = performance.now() - geometryStartedAt;
|
|
77
|
+
if (!requiresRuntimeSourceBuffers(value.gltf)) {
|
|
78
|
+
value.binaryChunk = null;
|
|
79
|
+
value.buffers = [];
|
|
80
|
+
}
|
|
81
|
+
const transfer = [];
|
|
82
|
+
const seen = new Set();
|
|
83
|
+
const add = buffer => { if (buffer && !seen.has(buffer)) { seen.add(buffer); transfer.push(buffer); } };
|
|
84
|
+
add(value.binaryChunk);
|
|
85
|
+
for (const buffer of value.buffers || []) add(buffer);
|
|
86
|
+
for (const mesh of value.geometryPayloads || []) for (const payload of mesh || []) if (payload) {
|
|
87
|
+
for (const array of [payload.positions, payload.indices, payload.normals, payload.joints, payload.weights]) add(array && array.buffer);
|
|
88
|
+
for (const entry of payload.textureCoordinates || []) add(entry.data && entry.data.buffer);
|
|
89
|
+
for (const array of payload.positionTargets || []) add(array.buffer);
|
|
90
|
+
for (const array of payload.normalTargets || []) add(array.buffer);
|
|
91
|
+
}
|
|
92
|
+
const workerTransferBytes = transfer.reduce((total, buffer) => total + buffer.byteLength, 0);
|
|
93
|
+
const baseMetrics = value.metrics || {};
|
|
94
|
+
value.metrics = {
|
|
95
|
+
fetchMs: baseMetrics.fetchMs || 0,
|
|
96
|
+
parseMs: baseMetrics.parseMs || 0,
|
|
97
|
+
workerParseMs: (baseMetrics.parseMs || 0) + Math.max(0, geometryPreparationMs - dracoDecodeMs),
|
|
98
|
+
dracoDecodeMs,
|
|
99
|
+
geometryPreparationMs,
|
|
100
|
+
sourceBytes: baseMetrics.sourceBytes || 0,
|
|
101
|
+
workerTransferBytes,
|
|
102
|
+
workerTransferBufferCount: transfer.length,
|
|
103
|
+
};
|
|
104
|
+
self.postMessage({ version: 1, id: request.id, ok: true, value }, transfer);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (controller.signal.aborted) return;
|
|
107
|
+
const serialized = error && typeof error.toJSON === 'function' ? error.toJSON() : {
|
|
108
|
+
name: 'EngineError', domain: 'asset', code: 'E_ASSET_INVALID_DATA',
|
|
109
|
+
message: error instanceof Error ? error.message : String(error), recoverable: false,
|
|
110
|
+
recovery: 'release-resource', context: { url: request.src, resourceType: 'model/gltf' },
|
|
111
|
+
path: error && error.path || 'gltf.parse',
|
|
112
|
+
cause: error instanceof Error ? { name: error.name, message: error.message, stack: error.stack } : undefined,
|
|
113
|
+
};
|
|
114
|
+
self.postMessage({ version: 1, id: request.id, ok: false, error: serialized });
|
|
115
|
+
} finally {
|
|
116
|
+
requests.delete(request.id);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function requiresRuntimeSourceBuffers(gltf) {
|
|
121
|
+
if ((gltf.animations || []).length > 0) return true;
|
|
122
|
+
if ((gltf.images || []).some(image => image.bufferView !== undefined)) return true;
|
|
123
|
+
return (gltf.skins || []).some(skin => skin.inverseBindMatrices !== undefined);
|
|
124
|
+
}
|
|
125
|
+
`.trim();
|
|
126
|
+
}
|
|
127
|
+
function createGltfAssetWorkerClientFromUrl(url, options) {
|
|
128
|
+
return new GltfAssetWorkerClient(new Worker(url, options));
|
|
129
|
+
}
|
|
130
|
+
function createInlineGltfAssetWorkerClient(extensionGltfModuleUrl, options) {
|
|
131
|
+
const blob = new Blob([createGltfAssetWorkerSource(extensionGltfModuleUrl)], { type: 'text/javascript' });
|
|
132
|
+
const url = URL.createObjectURL(blob);
|
|
133
|
+
const worker = new Worker(url, { type: 'module', ...options });
|
|
134
|
+
return new GltfAssetWorkerClient(worker, url);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { GltfAssetWorkerClient, createGltfAssetWorkerClientFromUrl, createGltfAssetWorkerSource, createInlineGltfAssetWorkerClient };
|
|
138
|
+
//# sourceMappingURL=experimental-gltf-worker.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SPINE_ASSET_PARSER, parseSpineAssetPayload } from './spine/SpineAssetParser';
|
|
2
|
+
export type { SpineAssetParserInput, SpineParsedAsset } from './spine/SpineAssetParser';
|
|
3
|
+
export { SpineAssetWorkerClient, createInlineSpineAssetWorkerClient, createSpineAssetWorkerClientFromUrl, createSpineAssetWorkerSource, } from './spine/SpineAssetWorkerClient';
|
|
4
|
+
export type { SpineAssetWorker } from './spine/SpineAssetWorkerContract';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export { S as SPINE_ASSET_PARSER, a as parseSpineAssetPayload } from './chunks/SpineAssetParser-BSDmPge1.js';
|
|
2
|
+
import { WorkerChannel } from '@haiyue/engine/experimental/async';
|
|
3
|
+
import '@haiyue/engine';
|
|
4
|
+
import '@haiyue/engine/core';
|
|
5
|
+
|
|
6
|
+
class SpineAssetWorkerClient {
|
|
7
|
+
objectUrl;
|
|
8
|
+
channel;
|
|
9
|
+
constructor(worker, objectUrl = null) {
|
|
10
|
+
this.objectUrl = objectUrl;
|
|
11
|
+
this.channel = new WorkerChannel(worker, {
|
|
12
|
+
label: 'Spine asset worker',
|
|
13
|
+
path: 'spine.worker',
|
|
14
|
+
context: { resourceType: 'skeleton/spine' },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
loadParsedAsset(jsonUrl, atlasUrl, options = {}) {
|
|
18
|
+
return this.channel.request('loadParsedSpineAsset', { jsonUrl, atlasUrl }, {
|
|
19
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
20
|
+
context: { url: jsonUrl },
|
|
21
|
+
abortMessage: 'Spine load aborted.',
|
|
22
|
+
validate: isSpineParsedAsset,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
dispose(options = {}) {
|
|
26
|
+
const alreadyDisposed = this.channel.isDisposed;
|
|
27
|
+
this.channel.dispose(options);
|
|
28
|
+
if (!alreadyDisposed && this.objectUrl)
|
|
29
|
+
URL.revokeObjectURL(this.objectUrl);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function isSpineParsedAsset(value) {
|
|
33
|
+
if (!value || typeof value !== 'object')
|
|
34
|
+
return false;
|
|
35
|
+
const candidate = value;
|
|
36
|
+
const data = candidate.data;
|
|
37
|
+
return !!data && typeof data === 'object'
|
|
38
|
+
&& Array.isArray(data.bones)
|
|
39
|
+
&& Array.isArray(candidate.regions);
|
|
40
|
+
}
|
|
41
|
+
function createSpineAssetWorkerSource(extensionSpineModuleUrl) {
|
|
42
|
+
return `
|
|
43
|
+
const parserModulePromise = import(${JSON.stringify(extensionSpineModuleUrl)});
|
|
44
|
+
const requests = new Map();
|
|
45
|
+
const assetError = (message, code, path, recovery, context, cause) => Object.assign(new Error(message), {
|
|
46
|
+
domain: 'component', code, path, recovery, recoverable: recovery === 'retry', context, cause,
|
|
47
|
+
});
|
|
48
|
+
self.addEventListener('message', async event => {
|
|
49
|
+
const request = event.data;
|
|
50
|
+
if (!request || request.version !== 1 || typeof request.id !== 'number') return;
|
|
51
|
+
if (request.type === 'cancel') { requests.get(request.id)?.abort('cancelled'); requests.delete(request.id); return; }
|
|
52
|
+
if (request.type !== 'loadParsedSpineAsset') return;
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
requests.set(request.id, controller);
|
|
55
|
+
try {
|
|
56
|
+
const [parser, jsonResponse, atlasResponse] = await Promise.all([
|
|
57
|
+
parserModulePromise,
|
|
58
|
+
fetch(request.jsonUrl, { signal: controller.signal }),
|
|
59
|
+
request.atlasUrl ? fetch(request.atlasUrl, { signal: controller.signal }) : Promise.resolve(null),
|
|
60
|
+
]);
|
|
61
|
+
if (!jsonResponse.ok) throw assetError(
|
|
62
|
+
'Failed to load Spine JSON: ' + jsonResponse.status + ' ' + jsonResponse.statusText,
|
|
63
|
+
'E_ASSET_LOAD_FAILED', 'spine.json', 'retry',
|
|
64
|
+
{ url: request.jsonUrl, resourceType: 'skeleton/spine-json', status: jsonResponse.status },
|
|
65
|
+
);
|
|
66
|
+
if (atlasResponse && !atlasResponse.ok) throw assetError(
|
|
67
|
+
'Failed to load Spine atlas: ' + atlasResponse.status + ' ' + atlasResponse.statusText,
|
|
68
|
+
'E_ASSET_LOAD_FAILED', 'spine.atlas', 'retry',
|
|
69
|
+
{ url: request.atlasUrl, resourceType: 'skeleton/spine-atlas', status: atlasResponse.status },
|
|
70
|
+
);
|
|
71
|
+
let json;
|
|
72
|
+
try { json = await jsonResponse.json(); }
|
|
73
|
+
catch (cause) {
|
|
74
|
+
throw assetError(
|
|
75
|
+
'Spine JSON is not valid JSON.', 'E_ASSET_INVALID_DATA', 'spine.json', 'release-resource',
|
|
76
|
+
{ url: request.jsonUrl, resourceType: 'skeleton/spine-json' }, cause,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const value = parser.parseSpineAssetPayload({
|
|
80
|
+
json,
|
|
81
|
+
atlasText: atlasResponse ? await atlasResponse.text() : '',
|
|
82
|
+
});
|
|
83
|
+
self.postMessage({ version: 1, id: request.id, ok: true, value });
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (controller.signal.aborted) return;
|
|
86
|
+
const serialized = error && typeof error.toJSON === 'function' ? error.toJSON() : {
|
|
87
|
+
name: 'EngineError', domain: error && error.domain || 'asset', code: error && error.code || 'E_ASSET_INVALID_DATA',
|
|
88
|
+
message: error instanceof Error ? error.message : String(error),
|
|
89
|
+
recovery: error && error.recovery || 'release-resource',
|
|
90
|
+
recoverable: error && typeof error.recoverable === 'boolean' ? error.recoverable : false,
|
|
91
|
+
context: Object.assign({ url: request.jsonUrl, resourceType: 'skeleton/spine' }, error && error.context || {}),
|
|
92
|
+
path: error && error.path || 'spine.parse',
|
|
93
|
+
cause: error instanceof Error ? { name: error.name, message: error.message, stack: error.stack } : undefined,
|
|
94
|
+
};
|
|
95
|
+
self.postMessage({ version: 1, id: request.id, ok: false, error: serialized });
|
|
96
|
+
} finally { requests.delete(request.id); }
|
|
97
|
+
});
|
|
98
|
+
`.trim();
|
|
99
|
+
}
|
|
100
|
+
function createInlineSpineAssetWorkerClient(extensionSpineModuleUrl, options) {
|
|
101
|
+
const blob = new Blob([createSpineAssetWorkerSource(extensionSpineModuleUrl)], { type: 'text/javascript' });
|
|
102
|
+
const url = URL.createObjectURL(blob);
|
|
103
|
+
return new SpineAssetWorkerClient(new Worker(url, { type: 'module', ...options }), url);
|
|
104
|
+
}
|
|
105
|
+
function createSpineAssetWorkerClientFromUrl(url, options) {
|
|
106
|
+
return new SpineAssetWorkerClient(new Worker(url, options));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { SpineAssetWorkerClient, createInlineSpineAssetWorkerClient, createSpineAssetWorkerClientFromUrl, createSpineAssetWorkerSource };
|
|
110
|
+
//# sourceMappingURL=experimental-spine-worker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GltfAsset } from './GltfSchema';
|
|
2
|
+
export declare function readAccessorFloat(gltf: GltfAsset, buffers: ArrayBuffer[], accessorIndex: number, expectedSize: number): Float32Array;
|
|
3
|
+
export declare function readAccessorMat4(gltf: GltfAsset, buffers: ArrayBuffer[], accessorIndex: number): Float32Array[];
|
|
4
|
+
export declare function readAccessorUnsigned(gltf: GltfAsset, buffers: ArrayBuffer[], accessorIndex: number, expectedSize: number): Uint16Array | Uint32Array;
|
|
5
|
+
export declare function readAccessorIndices(gltf: GltfAsset, buffers: ArrayBuffer[], accessorIndex: number): Uint16Array | Uint32Array;
|
|
6
|
+
export declare function generateFlatNormals(positions: Float32Array, indices: Uint16Array | Uint32Array | null): Float32Array;
|
|
7
|
+
export declare function requiredFiniteArrayValue(values: ArrayLike<number>, index: number, label: string): number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Entity } from '@haiyue/engine';
|
|
2
|
+
import type { Animation3DClip } from '../animation3d/Animation3DClip';
|
|
3
|
+
import { Animation3DMixer } from '../animation3d/Animation3DMixer';
|
|
4
|
+
import type { Animation3DPose } from '../animation3d/Animation3DPose';
|
|
5
|
+
import { Animation3DPoseBuffer } from '../animation3d/Animation3DPoseBuffer';
|
|
6
|
+
import type { LoadedGltfModel } from './GltfLoaderContract';
|
|
7
|
+
export interface GltfAnimation3DRuntimeOptions {
|
|
8
|
+
/** Cancels and destroys the adapter without taking ownership of the glTF model. */
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
/** Stable prefix used when several glTF models share a higher-level clip registry. */
|
|
11
|
+
readonly clipIdPrefix?: string;
|
|
12
|
+
}
|
|
13
|
+
export type GltfAnimation3DRuntimeState = 'active' | 'destroyed';
|
|
14
|
+
/**
|
|
15
|
+
* Model-scoped owner combining the existing Animation3D mixer with glTF
|
|
16
|
+
* binding and pose adapters. It does not own or dispose the LoadedGltfModel.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GltfAnimation3DRuntime {
|
|
19
|
+
readonly mixer: Animation3DMixer;
|
|
20
|
+
readonly pose: Animation3DPoseBuffer;
|
|
21
|
+
private readonly _clips;
|
|
22
|
+
private readonly _owner;
|
|
23
|
+
private readonly _resolver;
|
|
24
|
+
private readonly _poseApplier;
|
|
25
|
+
private _root;
|
|
26
|
+
private _state;
|
|
27
|
+
private readonly _signal;
|
|
28
|
+
private readonly _abortListener;
|
|
29
|
+
constructor(model: LoadedGltfModel, options?: GltfAnimation3DRuntimeOptions);
|
|
30
|
+
get state(): GltfAnimation3DRuntimeState;
|
|
31
|
+
get root(): Entity | null;
|
|
32
|
+
get clips(): readonly Animation3DClip[];
|
|
33
|
+
/** Diagnostic count without exposing the model-specific resolver handle. */
|
|
34
|
+
get bindingCount(): number;
|
|
35
|
+
/** Diagnostic count without exposing the model-specific pose-applier handle. */
|
|
36
|
+
get targetCount(): number;
|
|
37
|
+
update(deltaSeconds: number): Animation3DPose;
|
|
38
|
+
evaluate(): Animation3DPose;
|
|
39
|
+
/** @internal Applies a pose produced by a shared multi-mixer state-machine transaction. */
|
|
40
|
+
applySynchronizedPose(pose: Animation3DPose): void;
|
|
41
|
+
setTime(timeSeconds: number): Animation3DPose;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
private assertActive;
|
|
44
|
+
}
|
|
45
|
+
export declare function createGltfAnimation3DRuntime(model: LoadedGltfModel, options?: GltfAnimation3DRuntimeOptions): GltfAnimation3DRuntime;
|
|
46
|
+
/** Converts loaded legacy glTF clips without exposing glTF sampler structures. */
|
|
47
|
+
export declare function createGltfAnimation3DClips(model: LoadedGltfModel, clipIdPrefix?: string): readonly Animation3DClip[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Geometry3D } from '@haiyue/engine';
|
|
2
|
+
import { GltfConservativeBounds } from './GltfConservativeBounds';
|
|
3
|
+
import type { GltfAsset } from './GltfSchema';
|
|
4
|
+
import type { GltfAnimationClip, GltfAnimationTarget, GltfSkinnedPrimitiveRuntime } from './GltfLoaderContract';
|
|
5
|
+
export declare function registerGltfConservativeBounds(geometry: Geometry3D, bounds: GltfConservativeBounds): void;
|
|
6
|
+
export declare function createAnimationClips(gltf: GltfAsset, buffers: ArrayBuffer[], targets: Map<number, GltfAnimationTarget>, skinnedPrimitives: GltfSkinnedPrimitiveRuntime[]): GltfAnimationClip[];
|
|
7
|
+
export declare function applyGltfAnimationClip(clip: GltfAnimationClip, time: number): void;
|
|
8
|
+
export declare function composeTrsMatrix(translation: ArrayLike<number>, rotation: ArrayLike<number>, scale: ArrayLike<number>, out?: Float32Array<ArrayBuffer>): Float32Array;
|
|
9
|
+
export declare function applyMorphWeights(target: GltfAnimationTarget, weights: ArrayLike<number>): void;
|
|
10
|
+
export declare function updateSkinnedPrimitive(runtime: GltfSkinnedPrimitiveRuntime): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type WorkerChannelLike } from '@haiyue/engine/experimental/async';
|
|
2
|
+
import { type DracoDecoderConfig, type GltfAssetWorker } from './GltfLoaderContract';
|
|
3
|
+
type GltfAssetWorkerLike = WorkerChannelLike;
|
|
4
|
+
export declare class GltfAssetWorkerClient implements GltfAssetWorker {
|
|
5
|
+
private readonly objectUrl;
|
|
6
|
+
private readonly channel;
|
|
7
|
+
constructor(worker: GltfAssetWorkerLike, objectUrl?: string | null);
|
|
8
|
+
loadParsedAsset(src: string, options?: {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
dracoDecoderConfig?: DracoDecoderConfig;
|
|
11
|
+
}): Promise<Awaited<ReturnType<GltfAssetWorker['loadParsedAsset']>>>;
|
|
12
|
+
dispose(options?: {
|
|
13
|
+
terminate?: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
}
|
|
16
|
+
/** The worker imports the same production parser used by the main-thread fallback. */
|
|
17
|
+
export declare function createGltfAssetWorkerSource(extensionGltfModuleUrl: string): string;
|
|
18
|
+
export declare function createGltfAssetWorkerClientFromUrl(url: string | URL, options?: WorkerOptions): GltfAssetWorkerClient;
|
|
19
|
+
export declare function createInlineGltfAssetWorkerClient(extensionGltfModuleUrl: string, options?: WorkerOptions): GltfAssetWorkerClient;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Geometry3D } from '@haiyue/engine';
|
|
2
|
+
import type { GltfAsset, GltfPrimitive } from './GltfSchema';
|
|
3
|
+
import type { GltfUvSemanticPlan } from './GltfUvSemanticPlanner';
|
|
4
|
+
export type GltfCompatibilityStatus = 'compatible' | 'degraded';
|
|
5
|
+
export type GltfTextureMipmapSource = 'generated-full-chain' | 'source-provided' | 'unavailable';
|
|
6
|
+
export type GltfPrimitiveBoundsSupport = 'static' | 'accessor-conservative' | 'fail-open';
|
|
7
|
+
export interface GltfCompatibilityExtensionEntry {
|
|
8
|
+
readonly extension: string;
|
|
9
|
+
readonly required: boolean;
|
|
10
|
+
readonly support: 'supported' | 'partial' | 'unsupported';
|
|
11
|
+
readonly disposition: 'supported' | 'partial' | 'ignored';
|
|
12
|
+
readonly note: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GltfTextureCompatibilityEntry {
|
|
15
|
+
readonly textureIndex: number;
|
|
16
|
+
readonly imageIndex: number | null;
|
|
17
|
+
readonly mipmapSource: GltfTextureMipmapSource;
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly note: string;
|
|
20
|
+
}
|
|
21
|
+
export interface GltfPrimitiveBoundsCompatibilityEntry {
|
|
22
|
+
readonly meshIndex: number;
|
|
23
|
+
readonly primitiveIndex: number;
|
|
24
|
+
readonly support: GltfPrimitiveBoundsSupport;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly reason: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface GltfPrimitiveUvSemanticCompatibilityEntry {
|
|
29
|
+
readonly meshIndex: number;
|
|
30
|
+
readonly primitiveIndex: number;
|
|
31
|
+
readonly capacity: number;
|
|
32
|
+
readonly availableSemantics: readonly string[];
|
|
33
|
+
readonly referencedSemantics: readonly string[];
|
|
34
|
+
readonly mappings: readonly Readonly<{
|
|
35
|
+
semantic: string;
|
|
36
|
+
set: number;
|
|
37
|
+
channel: 0 | 1;
|
|
38
|
+
}>[];
|
|
39
|
+
readonly path: string;
|
|
40
|
+
}
|
|
41
|
+
export interface GltfCompatibilityPerformanceSummary {
|
|
42
|
+
/** Fetch, parse, decode, and entity/material instantiation on the loading thread. */
|
|
43
|
+
readonly loadMs: number;
|
|
44
|
+
/** Unique decoded geometry ArrayBuffer storage retained by the loaded model. */
|
|
45
|
+
readonly decodedGeometryBytes: number;
|
|
46
|
+
}
|
|
47
|
+
export interface GltfCompatibilityIssue {
|
|
48
|
+
readonly category: 'extension' | 'texture-mipmap' | 'bounds' | 'uv-semantic';
|
|
49
|
+
readonly path: string;
|
|
50
|
+
readonly code: string;
|
|
51
|
+
readonly message: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GltfCompatibilityReport {
|
|
54
|
+
readonly status: GltfCompatibilityStatus;
|
|
55
|
+
readonly extensions: readonly GltfCompatibilityExtensionEntry[];
|
|
56
|
+
readonly textures: readonly GltfTextureCompatibilityEntry[];
|
|
57
|
+
readonly bounds: readonly GltfPrimitiveBoundsCompatibilityEntry[];
|
|
58
|
+
readonly uvSemantics: readonly GltfPrimitiveUvSemanticCompatibilityEntry[];
|
|
59
|
+
readonly performance: GltfCompatibilityPerformanceSummary;
|
|
60
|
+
readonly issues: readonly GltfCompatibilityIssue[];
|
|
61
|
+
}
|
|
62
|
+
export interface GltfPrimitiveCompatibilityInput {
|
|
63
|
+
readonly meshIndex: number;
|
|
64
|
+
readonly primitiveIndex: number;
|
|
65
|
+
readonly primitive: GltfPrimitive;
|
|
66
|
+
readonly geometry: Geometry3D;
|
|
67
|
+
readonly skinRequested: boolean;
|
|
68
|
+
readonly uvSemanticPlan: GltfUvSemanticPlan;
|
|
69
|
+
}
|
|
70
|
+
export declare function createGltfCompatibilityReport(gltf: GltfAsset, extensions: readonly GltfCompatibilityExtensionEntry[], primitives: readonly GltfPrimitiveCompatibilityInput[], performance: GltfCompatibilityPerformanceSummary): GltfCompatibilityReport;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Geometry3DLocalBounds } from '@haiyue/engine/geometry';
|
|
2
|
+
import type { GltfAsset, GltfPrimitive } from './GltfSchema';
|
|
3
|
+
/**
|
|
4
|
+
* Keeps the accessor evidence needed to derive conservative bounds for the
|
|
5
|
+
* current morph weights and skin matrices. Missing evidence returns null so
|
|
6
|
+
* Render3D keeps its fail-open culling behavior.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GltfConservativeBounds {
|
|
9
|
+
private readonly _base;
|
|
10
|
+
private readonly _positionTargets;
|
|
11
|
+
private _current;
|
|
12
|
+
private _skinUsageCache;
|
|
13
|
+
private constructor();
|
|
14
|
+
static fromPrimitive(gltf: GltfAsset, primitive: GltfPrimitive): GltfConservativeBounds | null;
|
|
15
|
+
updateMorphWeights(weights: ArrayLike<number>): Geometry3DLocalBounds | null;
|
|
16
|
+
getSourceBounds(): Geometry3DLocalBounds | null;
|
|
17
|
+
getSkinnedBounds(jointMatrices: Float32Array, joints?: Float32Array, weights?: Float32Array): Geometry3DLocalBounds | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GltfAsset, GltfDracoMeshCompression } from './GltfSchema';
|
|
2
|
+
import type { DracoPrimitiveGeometry, LoadGltfOptions } from './GltfLoaderContract';
|
|
3
|
+
/** Resolves and decodes one KHR_draco_mesh_compression primitive. */
|
|
4
|
+
export declare function decodeDracoPrimitive(gltf: GltfAsset, buffers: ArrayBuffer[], extension: GltfDracoMeshCompression, options: LoadGltfOptions): Promise<DracoPrimitiveGeometry>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { PbrMaterialState, PbrTextureSlot } from '@haiyue/engine/material';
|
|
2
|
+
import type { GltfAsset, GltfMaterial, GltfPrimitive, GltfTextureInfo } from './GltfSchema';
|
|
3
|
+
export type GltfExtensionSupport = 'supported' | 'partial' | 'unsupported';
|
|
4
|
+
export interface GltfExtensionCapability {
|
|
5
|
+
readonly support: GltfExtensionSupport;
|
|
6
|
+
readonly note: string;
|
|
7
|
+
}
|
|
8
|
+
export interface GltfMaterialTextureBinding {
|
|
9
|
+
readonly slot: PbrTextureSlot;
|
|
10
|
+
readonly textureInfo: GltfTextureInfo;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
}
|
|
13
|
+
export interface GltfMaterialExtensionContext {
|
|
14
|
+
readonly gltf: GltfAsset;
|
|
15
|
+
readonly material: GltfMaterial;
|
|
16
|
+
readonly primitive: GltfPrimitive;
|
|
17
|
+
readonly materialPath: string;
|
|
18
|
+
readonly extensionData: unknown;
|
|
19
|
+
}
|
|
20
|
+
export type GltfMaterialStatePatch = Readonly<Partial<Omit<PbrMaterialState, 'baseColorTexture' | 'metallicRoughnessTexture' | 'normalTexture' | 'occlusionTexture' | 'emissiveTexture' | 'clearcoatTexture' | 'clearcoatRoughnessTexture' | 'clearcoatNormalTexture' | 'specularTexture' | 'specularColorTexture' | 'sheenColorTexture' | 'sheenRoughnessTexture' | 'transmissionTexture' | 'thicknessTexture' | 'textureMappings' | 'samplers' | 'sampler'>>>;
|
|
21
|
+
export interface GltfMaterialExtensionPatch {
|
|
22
|
+
/** Pure material parameters. Texture ownership must use `textures`. */
|
|
23
|
+
readonly state?: GltfMaterialStatePatch;
|
|
24
|
+
readonly textures?: readonly GltfMaterialTextureBinding[];
|
|
25
|
+
}
|
|
26
|
+
export interface GltfMaterialVariantReference {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly materialIndex: number;
|
|
29
|
+
}
|
|
30
|
+
export interface GltfPrimitiveExtensionContext {
|
|
31
|
+
readonly gltf: GltfAsset;
|
|
32
|
+
readonly primitive: GltfPrimitive;
|
|
33
|
+
readonly rootExtensionData: unknown;
|
|
34
|
+
readonly primitiveExtensionData: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A stateless glTF extension adapter. Hooks return declarative patches and
|
|
38
|
+
* references; resource ownership and concrete material creation stay in the
|
|
39
|
+
* loader and engine respectively.
|
|
40
|
+
*/
|
|
41
|
+
export interface GltfExtensionAdapter {
|
|
42
|
+
readonly extension: string;
|
|
43
|
+
readonly capability: GltfExtensionCapability;
|
|
44
|
+
readonly extendMaterial?: (context: GltfMaterialExtensionContext) => GltfMaterialExtensionPatch | null;
|
|
45
|
+
readonly collectMaterialVariantNames?: (gltf: GltfAsset, rootExtensionData: unknown) => readonly string[];
|
|
46
|
+
readonly collectMaterialVariants?: (context: GltfPrimitiveExtensionContext) => readonly GltfMaterialVariantReference[];
|
|
47
|
+
}
|
|
48
|
+
export declare const DEFAULT_GLTF_EXTENSION_ADAPTERS: readonly GltfExtensionAdapter[];
|
|
49
|
+
/** Resolves an immutable per-load adapter set; user adapters replace defaults by extension id. */
|
|
50
|
+
export declare function resolveGltfExtensionAdapters(customAdapters?: readonly GltfExtensionAdapter[]): readonly GltfExtensionAdapter[];
|
|
51
|
+
export declare function createGltfExtensionCapabilities(adapters: readonly GltfExtensionAdapter[]): Readonly<Record<string, GltfExtensionCapability>>;
|
|
52
|
+
export declare function collectGltfMaterialExtensionPatches(gltf: GltfAsset, material: GltfMaterial | null, primitive: GltfPrimitive, materialPath: string, adapters: readonly GltfExtensionAdapter[]): readonly GltfMaterialExtensionPatch[];
|
|
53
|
+
export declare function collectGltfMaterialVariantReferences(gltf: GltfAsset, primitive: GltfPrimitive, adapters: readonly GltfExtensionAdapter[]): readonly GltfMaterialVariantReference[];
|
|
54
|
+
export declare function collectGltfMaterialVariantNames(gltf: GltfAsset, adapters: readonly GltfExtensionAdapter[]): readonly string[];
|