agentscape3d 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +11 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
export const PHYSICS_BACKEND_CAPABILITIES = Object.freeze([
|
|
2
|
-
'rigid-body','articulated-body','character-controller','collision','joints','scene-query'
|
|
3
|
-
]);
|
|
4
|
-
|
|
5
|
-
const missing=(identity,method)=>{ throw new Error(`Physics backend ${identity} ${method}() must be implemented`); };
|
|
6
|
-
|
|
7
|
-
export class PhysicsBackend {
|
|
8
|
-
constructor(identity, capabilities = [], { executionModes=['realtime'], qualities={} } = {}) {
|
|
9
|
-
if (!identity) throw new TypeError('PhysicsBackend identity is required');
|
|
10
|
-
this.identity = identity;
|
|
11
|
-
this.capabilities = Object.freeze([...new Set(capabilities)]);
|
|
12
|
-
this.executionModes = Object.freeze([...new Set(executionModes)]);
|
|
13
|
-
this.qualities = Object.freeze({ realtime:qualities.realtime===true, deterministic:qualities.deterministic===true });
|
|
14
|
-
}
|
|
15
|
-
hasCapability(capability) { return this.capabilities.includes(capability); }
|
|
16
|
-
supportsExecutionMode(mode) { return this.executionModes.includes(mode); }
|
|
17
|
-
async init() { missing(this.identity,'init'); }
|
|
18
|
-
createWorld() { missing(this.identity,'createWorld'); }
|
|
19
|
-
step() { missing(this.identity,'step'); }
|
|
20
|
-
dispose() { missing(this.identity,'dispose'); }
|
|
21
|
-
|
|
22
|
-
// Deep runtime contract. Handles returned here are opaque to PhysicsSystem.
|
|
23
|
-
createBody() { missing(this.identity,'createBody'); }
|
|
24
|
-
removeBody() { missing(this.identity,'removeBody'); }
|
|
25
|
-
createColliders() { missing(this.identity,'createColliders'); }
|
|
26
|
-
colliders() { missing(this.identity,'colliders'); }
|
|
27
|
-
bodyKey() { missing(this.identity,'bodyKey'); }
|
|
28
|
-
colliderKey() { missing(this.identity,'colliderKey'); }
|
|
29
|
-
colliderParent() { missing(this.identity,'colliderParent'); }
|
|
30
|
-
colliderSnapshot() { missing(this.identity,'colliderSnapshot'); }
|
|
31
|
-
bodyType() { missing(this.identity,'bodyType'); }
|
|
32
|
-
setBodyType() { missing(this.identity,'setBodyType'); }
|
|
33
|
-
bodyPose() { missing(this.identity,'bodyPose'); }
|
|
34
|
-
setBodyPose() { missing(this.identity,'setBodyPose'); }
|
|
35
|
-
translateBody() { missing(this.identity,'translateBody'); }
|
|
36
|
-
clearBodyMotion() { missing(this.identity,'clearBodyMotion'); }
|
|
37
|
-
bodyMotion() { missing(this.identity,'bodyMotion'); }
|
|
38
|
-
setBodyMotion() { missing(this.identity,'setBodyMotion'); }
|
|
39
|
-
applyImpulse() { missing(this.identity,'applyImpulse'); }
|
|
40
|
-
applyForce() { missing(this.identity,'applyForce'); }
|
|
41
|
-
applyTorque() { missing(this.identity,'applyTorque'); }
|
|
42
|
-
setBodyMaterial() { missing(this.identity,'setBodyMaterial'); }
|
|
43
|
-
setBodyDynamics() { missing(this.identity,'setBodyDynamics'); }
|
|
44
|
-
setBodyCcd() { missing(this.identity,'setBodyCcd'); }
|
|
45
|
-
setBodySensor() { missing(this.identity,'setBodySensor'); }
|
|
46
|
-
setBodyCollisionFilter() { missing(this.identity,'setBodyCollisionFilter'); }
|
|
47
|
-
sleepBody() { missing(this.identity,'sleepBody'); }
|
|
48
|
-
wakeBody() { missing(this.identity,'wakeBody'); }
|
|
49
|
-
createJoint() { missing(this.identity,'createJoint'); }
|
|
50
|
-
setJointTarget() { missing(this.identity,'setJointTarget'); }
|
|
51
|
-
|
|
52
|
-
createCharacterController() { missing(this.identity,'createCharacterController'); }
|
|
53
|
-
removeCharacterController() { missing(this.identity,'removeCharacterController'); }
|
|
54
|
-
cancelCharacterMovement() { missing(this.identity,'cancelCharacterMovement'); }
|
|
55
|
-
moveCharacter() { missing(this.identity,'moveCharacter'); }
|
|
56
|
-
|
|
57
|
-
syncSceneQueries() { missing(this.identity,'syncSceneQueries'); }
|
|
58
|
-
createQueryShape() { missing(this.identity,'createQueryShape'); }
|
|
59
|
-
disposeQueryShape() { missing(this.identity,'disposeQueryShape'); }
|
|
60
|
-
intersectionsWithShape() { missing(this.identity,'intersectionsWithShape'); }
|
|
61
|
-
castCollider() { missing(this.identity,'castCollider'); }
|
|
62
|
-
raycast() { missing(this.identity,'raycast'); }
|
|
63
|
-
contactPairs() { missing(this.identity,'contactPairs'); }
|
|
64
|
-
penetrations() { missing(this.identity,'penetrations'); }
|
|
65
|
-
shapesIntersect() { missing(this.identity,'shapesIntersect'); }
|
|
66
|
-
evidenceGeometry(kind) { return `${this.identity}-${kind}`; }
|
|
67
|
-
|
|
68
|
-
// Optional observation contract. Backends may expose native debug geometry/metrics
|
|
69
|
-
// without leaking solver-private world handles to callers such as Observatory.
|
|
70
|
-
debugSnapshot(_world, _options = {}) {
|
|
71
|
-
return { backend:this.identity, nativeGeometry:null, metrics:{} };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export class TransformPhysicsBackend extends PhysicsBackend {
|
|
78
|
-
constructor({ identity='transform' } = {}) {
|
|
79
|
-
super(identity, [], {
|
|
80
|
-
executionModes:['render-only'],
|
|
81
|
-
qualities:{realtime:true,deterministic:true}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
async init() { return this; }
|
|
85
|
-
createWorld() { return null; }
|
|
86
|
-
step() { return false; }
|
|
87
|
-
dispose() {}
|
|
88
|
-
}
|
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
-
import { PHYSICS_BACKEND_CAPABILITIES, PhysicsBackend } from './PhysicsBackend.js';
|
|
3
|
-
|
|
4
|
-
const v3=(value=[0,0,0])=>Array.isArray(value)
|
|
5
|
-
? {x:value[0],y:value[1],z:value[2]}
|
|
6
|
-
: {x:value.x,y:value.y,z:value.z};
|
|
7
|
-
const q4=(value=[0,0,0,1])=>Array.isArray(value)
|
|
8
|
-
? {x:value[0],y:value[1],z:value[2],w:value[3]}
|
|
9
|
-
: {x:value.x,y:value.y,z:value.z,w:value.w};
|
|
10
|
-
const array3=(value)=>[value.x,value.y,value.z];
|
|
11
|
-
const array4=(value)=>[value.x,value.y,value.z,value.w];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const createBodyDesc=(type,position,{canSleep=true,lockTranslation=null,lockRotation=null}={})=>{
|
|
15
|
-
const desc=type==='dynamic' ? RAPIER.RigidBodyDesc.dynamic()
|
|
16
|
-
: type==='kinematic' ? RAPIER.RigidBodyDesc.kinematicPositionBased()
|
|
17
|
-
: RAPIER.RigidBodyDesc.fixed();
|
|
18
|
-
if(type==='dynamic') {
|
|
19
|
-
desc.setCanSleep(Boolean(canSleep));
|
|
20
|
-
if(lockTranslation) desc.restrictTranslations(!lockTranslation[0],!lockTranslation[1],!lockTranslation[2]);
|
|
21
|
-
if(lockRotation) desc.restrictRotations(!lockRotation[0],!lockRotation[1],!lockRotation[2]);
|
|
22
|
-
}
|
|
23
|
-
if(position) {
|
|
24
|
-
const p=v3(position);
|
|
25
|
-
desc.setTranslation(p.x,p.y,p.z);
|
|
26
|
-
}
|
|
27
|
-
return desc;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const createColliderDesc=(spec)=>{
|
|
31
|
-
let desc;
|
|
32
|
-
if(spec.shape==='box') desc=RAPIER.ColliderDesc.cuboid(...spec.halfExtents);
|
|
33
|
-
else if(spec.shape==='cylinder') desc=RAPIER.ColliderDesc.cylinder(spec.halfHeight,spec.radius);
|
|
34
|
-
else if(spec.shape==='capsule') desc=RAPIER.ColliderDesc.capsule(spec.halfHeight,spec.radius);
|
|
35
|
-
else if(spec.shape==='convexHull') desc=RAPIER.ColliderDesc.convexHull(new Float32Array(spec.vertices));
|
|
36
|
-
else if(spec.shape==='trimesh') desc=RAPIER.ColliderDesc.trimesh(new Float32Array(spec.vertices),new Uint32Array(spec.indices));
|
|
37
|
-
else return null;
|
|
38
|
-
if(!desc) throw new Error(`Rapier rejected collider shape: ${spec.shape}`);
|
|
39
|
-
return desc;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const createJoint=(world,part,parentBody,childBody)=>{
|
|
43
|
-
const vec=(a=[0,0,0])=>({x:a[0],y:a[1],z:a[2]});
|
|
44
|
-
let data;
|
|
45
|
-
if(part.joint.type==='revolute') data=RAPIER.JointData.revolute(vec(part.joint.parentAnchor),vec(part.joint.childAnchor),vec(part.joint.axis));
|
|
46
|
-
else if(part.joint.type==='prismatic') data=RAPIER.JointData.prismatic(vec(part.joint.parentAnchor),vec(part.joint.childAnchor),vec(part.joint.axis));
|
|
47
|
-
else if(part.joint.type==='fixed') {
|
|
48
|
-
const parent=parentBody.rotation(),child=childBody.rotation();
|
|
49
|
-
const inverseParent={x:-parent.x,y:-parent.y,z:-parent.z,w:parent.w};
|
|
50
|
-
const multiply=(a,b)=>({x:a.w*b.x+a.x*b.w+a.y*b.z-a.z*b.y,y:a.w*b.y-a.x*b.z+a.y*b.w+a.z*b.x,z:a.w*b.z+a.x*b.y-a.y*b.x+a.z*b.w,w:a.w*b.w-a.x*b.x-a.y*b.y-a.z*b.z});
|
|
51
|
-
data=RAPIER.JointData.fixed(vec(part.joint.parentAnchor),multiply(inverseParent,child),vec(part.joint.childAnchor),{x:0,y:0,z:0,w:1});
|
|
52
|
-
} else throw new TypeError(`RapierPhysicsBackend unsupported joint type: ${part.joint.type}`);
|
|
53
|
-
const joint=world.createImpulseJoint(data,parentBody,childBody,true);
|
|
54
|
-
joint.setContactsEnabled(false);
|
|
55
|
-
if(part.joint.type!=='fixed' && part.joint.limits) joint.setLimits(part.joint.limits[0],part.joint.limits[1]);
|
|
56
|
-
return joint;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const createQueryShape=(spec)=>{
|
|
60
|
-
if(spec.shape==='box') return new RAPIER.Cuboid(...spec.halfExtents);
|
|
61
|
-
if(spec.shape==='cylinder') return new RAPIER.Cylinder(spec.halfHeight,spec.radius);
|
|
62
|
-
if(spec.shape==='capsule') return new RAPIER.Capsule(spec.halfHeight,spec.radius);
|
|
63
|
-
if(spec.shape==='convexHull') return new RAPIER.ConvexPolyhedron(new Float32Array(spec.vertices));
|
|
64
|
-
return null;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const describeShape=(shape)=>{
|
|
68
|
-
if(!shape) return {kind:'unknown'};
|
|
69
|
-
if(shape.type===RAPIER.ShapeType.Cuboid) return {
|
|
70
|
-
kind:'box', halfExtents:v3(shape.halfExtents), borderRadius:Number(shape.borderRadius)||0
|
|
71
|
-
};
|
|
72
|
-
if(shape.type===RAPIER.ShapeType.Cylinder) return {
|
|
73
|
-
kind:'cylinder', halfHeight:shape.halfHeight, radius:shape.radius, borderRadius:Number(shape.borderRadius)||0
|
|
74
|
-
};
|
|
75
|
-
if(shape.type===RAPIER.ShapeType.Capsule) return {
|
|
76
|
-
kind:'capsule', halfHeight:shape.halfHeight, radius:shape.radius, borderRadius:Number(shape.borderRadius)||0
|
|
77
|
-
};
|
|
78
|
-
if(shape.type===RAPIER.ShapeType.ConvexPolyhedron) return {
|
|
79
|
-
kind:'convexHull', vertices:Array.from(shape.vertices || []), borderRadius:Number(shape.borderRadius)||0
|
|
80
|
-
};
|
|
81
|
-
if(shape.type===RAPIER.ShapeType.TriMesh) return {
|
|
82
|
-
kind:'trimesh', vertices:Array.from(shape.vertices || []), indices:Array.from(shape.indices || [])
|
|
83
|
-
};
|
|
84
|
-
return {kind:'unknown',type:shape.type};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export class RapierPhysicsBackend extends PhysicsBackend {
|
|
88
|
-
constructor({ gravity={x:0,y:-9.81,z:0} } = {}) {
|
|
89
|
-
super('rapier', PHYSICS_BACKEND_CAPABILITIES, {
|
|
90
|
-
executionModes:['realtime','validation-only'],
|
|
91
|
-
qualities:{realtime:true,deterministic:true}
|
|
92
|
-
});
|
|
93
|
-
this.gravity=gravity;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async init() { await RAPIER.init(); return this; }
|
|
97
|
-
createWorld() { return new RAPIER.World(this.gravity); }
|
|
98
|
-
step(world, dt) {
|
|
99
|
-
world.timestep=dt;
|
|
100
|
-
world.step();
|
|
101
|
-
world.bodies.forEach((body)=>{ if(body.isDynamic()) { body.resetForces(false); body.resetTorques(false); } });
|
|
102
|
-
}
|
|
103
|
-
dispose(world) { world?.free?.(); }
|
|
104
|
-
debugSnapshot(world,{nativeGeometry=true}={}) {
|
|
105
|
-
return {
|
|
106
|
-
backend:this.identity,
|
|
107
|
-
nativeGeometry:nativeGeometry && world?.debugRender ? world.debugRender() : null,
|
|
108
|
-
metrics:{}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
createBody(world,{type='fixed',position=null,rotation=null,canSleep=true,lockTranslation=null,lockRotation=null}={}) {
|
|
113
|
-
const body=world.createRigidBody(createBodyDesc(type,position,{canSleep,lockTranslation,lockRotation}));
|
|
114
|
-
if(rotation) body.setRotation(q4(rotation),true);
|
|
115
|
-
return body;
|
|
116
|
-
}
|
|
117
|
-
removeBody(world,body) { if(body) world.removeRigidBody(body); }
|
|
118
|
-
createColliders(world,body,specs=[],{mass,friction,restitution}={}) {
|
|
119
|
-
const colliderMass=mass!=null && specs.length ? mass/specs.length : null;
|
|
120
|
-
const created=[];
|
|
121
|
-
for(const spec of specs) {
|
|
122
|
-
const desc=createColliderDesc(spec);
|
|
123
|
-
if(!desc) continue;
|
|
124
|
-
if(spec.translation) desc.setTranslation(...spec.translation);
|
|
125
|
-
if(spec.rotation) desc.setRotation(q4(spec.rotation));
|
|
126
|
-
if(colliderMass!=null) desc.setMass(colliderMass);
|
|
127
|
-
if(friction!=null) desc.setFriction(friction);
|
|
128
|
-
if(restitution!=null) desc.setRestitution(restitution);
|
|
129
|
-
created.push(world.createCollider(desc,body));
|
|
130
|
-
}
|
|
131
|
-
return created;
|
|
132
|
-
}
|
|
133
|
-
colliders(body) {
|
|
134
|
-
if(!body) return [];
|
|
135
|
-
return Array.from({length:body.numColliders()},(_,index)=>body.collider(index));
|
|
136
|
-
}
|
|
137
|
-
bodyKey(body) { return body?.handle ?? null; }
|
|
138
|
-
colliderKey(collider) { return collider?.handle ?? null; }
|
|
139
|
-
colliderParent(collider) { return collider?.parent?.() || null; }
|
|
140
|
-
colliderSnapshot(collider) {
|
|
141
|
-
if(!collider) return null;
|
|
142
|
-
const position=collider.translation();
|
|
143
|
-
const rotation=collider.rotation();
|
|
144
|
-
return {
|
|
145
|
-
ref:collider,
|
|
146
|
-
key:this.colliderKey(collider),
|
|
147
|
-
parent:this.colliderParent(collider),
|
|
148
|
-
position:v3(position),
|
|
149
|
-
rotation:q4(rotation),
|
|
150
|
-
shape:describeShape(collider.shape),
|
|
151
|
-
shapeRef:collider.shape
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
bodyType(body) { return body?.isKinematic?.() ? 'kinematic' : body?.isDynamic?.() ? 'dynamic' : 'fixed'; }
|
|
155
|
-
setBodyType(body,type) {
|
|
156
|
-
if(type==='kinematic') body.setBodyType(RAPIER.RigidBodyType.KinematicPositionBased,true);
|
|
157
|
-
else if(type==='dynamic') body.setBodyType(RAPIER.RigidBodyType.Dynamic,true);
|
|
158
|
-
else body.setBodyType(RAPIER.RigidBodyType.Fixed,true);
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
bodyPose(body,{next=false}={}) {
|
|
162
|
-
if(!body) return null;
|
|
163
|
-
const position=next && body.nextTranslation ? body.nextTranslation() : body.translation();
|
|
164
|
-
const rotation=next && body.nextRotation ? body.nextRotation() : body.rotation();
|
|
165
|
-
return {position:array3(position),rotation:array4(rotation)};
|
|
166
|
-
}
|
|
167
|
-
setBodyPose(body,{position=null,rotation=null,next=false,wake=true}={}) {
|
|
168
|
-
if(!body) return false;
|
|
169
|
-
if(next) {
|
|
170
|
-
if(position) body.setNextKinematicTranslation(v3(position));
|
|
171
|
-
if(rotation) body.setNextKinematicRotation(q4(rotation));
|
|
172
|
-
} else {
|
|
173
|
-
if(position) body.setTranslation(v3(position),wake);
|
|
174
|
-
if(rotation) body.setRotation(q4(rotation),wake);
|
|
175
|
-
}
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
translateBody(body,delta,{clearLinearVelocity=true,wake=true}={}) {
|
|
179
|
-
const pose=this.bodyPose(body);
|
|
180
|
-
if(!pose) return false;
|
|
181
|
-
this.setBodyPose(body,{position:[pose.position[0]+delta[0],pose.position[1]+delta[1],pose.position[2]+delta[2]],wake});
|
|
182
|
-
if(clearLinearVelocity) body.setLinvel?.({x:0,y:0,z:0},wake);
|
|
183
|
-
if(wake) body.wakeUp?.();
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
clearBodyMotion(body,{wake=false}={}) {
|
|
187
|
-
if(!body) return false;
|
|
188
|
-
body.setLinvel?.({x:0,y:0,z:0},wake);
|
|
189
|
-
body.setAngvel?.({x:0,y:0,z:0},wake);
|
|
190
|
-
if(wake) body.wakeUp?.();
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
bodyMotion(body) {
|
|
194
|
-
if(!body) return null;
|
|
195
|
-
const linear=body.linvel(),angular=body.angvel();
|
|
196
|
-
return {
|
|
197
|
-
sleeping:body.isSleeping(),
|
|
198
|
-
linearVelocity:array3(linear),
|
|
199
|
-
angularVelocity:array3(angular),
|
|
200
|
-
linearSpeed:Math.hypot(linear.x,linear.y,linear.z),
|
|
201
|
-
angularSpeed:Math.hypot(angular.x,angular.y,angular.z)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
setBodyMotion(body,{linearVelocity=null,angularVelocity=null,wake=true}={}) {
|
|
205
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
206
|
-
if(linearVelocity) body.setLinvel(v3(linearVelocity),wake);
|
|
207
|
-
if(angularVelocity) body.setAngvel(v3(angularVelocity),wake);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
applyImpulse(body,impulse,{point=null,wake=true}={}) {
|
|
211
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
212
|
-
if(point) body.applyImpulseAtPoint(v3(impulse),v3(point),wake);
|
|
213
|
-
else body.applyImpulse(v3(impulse),wake);
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
applyForce(body,force,{point=null,wake=true}={}) {
|
|
217
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
218
|
-
if(point) body.addForceAtPoint(v3(force),v3(point),wake);
|
|
219
|
-
else body.addForce(v3(force),wake);
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
applyTorque(body,torque,{wake=true}={}) {
|
|
223
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
224
|
-
body.addTorque(v3(torque),wake);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
setBodyMaterial(body,{friction=null,restitution=null}={}) {
|
|
228
|
-
if(!body) return false;
|
|
229
|
-
for(const collider of this.colliders(body)) {
|
|
230
|
-
if(friction!=null) collider.setFriction(friction);
|
|
231
|
-
if(restitution!=null) collider.setRestitution(restitution);
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
setBodyDynamics(body,{linearDamping=null,angularDamping=null,gravityScale=null,wake=true}={}) {
|
|
236
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
237
|
-
if(linearDamping!=null) body.setLinearDamping(linearDamping);
|
|
238
|
-
if(angularDamping!=null) body.setAngularDamping(angularDamping);
|
|
239
|
-
if(gravityScale!=null) body.setGravityScale(gravityScale,wake);
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
setBodyCcd(body,enabled) {
|
|
243
|
-
if(!body || this.bodyType(body)!=='dynamic') return false;
|
|
244
|
-
body.enableCcd(Boolean(enabled));
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
setBodySensor(body,enabled) {
|
|
248
|
-
if(!body) return false;
|
|
249
|
-
for(const collider of this.colliders(body)) collider.setSensor(Boolean(enabled));
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
setBodyCollisionFilter(body,filter=null) {
|
|
253
|
-
if(!body) return false;
|
|
254
|
-
const groups=filter ? ((((filter.membership & 0xffff) << 16) | (filter.filter & 0xffff)) >>> 0) : 0xffffffff;
|
|
255
|
-
for(const collider of this.colliders(body)) collider.setCollisionGroups(groups);
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
sleepBody(body) { if(!body || this.bodyType(body)!=='dynamic') return false; body.sleep(); return true; }
|
|
259
|
-
wakeBody(body) { body?.wakeUp?.(); return Boolean(body); }
|
|
260
|
-
|
|
261
|
-
createJoint(world,part,parentBody,childBody) { return createJoint(world,part,parentBody,childBody); }
|
|
262
|
-
setJointTarget(joint,target,{stiffness=40,damping=8}={}) {
|
|
263
|
-
if(!joint || joint.type?.()===RAPIER.JointType.Fixed) return false;
|
|
264
|
-
// A null target restores the unmotorized joint used before the first action.
|
|
265
|
-
joint.configureMotorPosition(target ?? 0,target == null ? 0 : stiffness,target == null ? 0 : damping);
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
createCharacterController(world,{
|
|
270
|
-
offset=.02,autostepHeight=.3,autostepMinWidth=.2,snapToGround=.3,
|
|
271
|
-
maxSlopeClimbAngle=Math.PI/4,minSlopeSlideAngle=Math.PI/6
|
|
272
|
-
}={}) {
|
|
273
|
-
const controller=world.createCharacterController(offset);
|
|
274
|
-
controller.enableAutostep(autostepHeight,autostepMinWidth,false);
|
|
275
|
-
controller.enableSnapToGround(snapToGround);
|
|
276
|
-
controller.setMaxSlopeClimbAngle(maxSlopeClimbAngle);
|
|
277
|
-
controller.setMinSlopeSlideAngle(minSlopeSlideAngle);
|
|
278
|
-
controller.setApplyImpulsesToDynamicBodies(false);
|
|
279
|
-
return controller;
|
|
280
|
-
}
|
|
281
|
-
removeCharacterController(world,controller) { if(world&&controller) world.removeCharacterController(controller); }
|
|
282
|
-
cancelCharacterMovement(body) {
|
|
283
|
-
const pose=this.bodyPose(body);
|
|
284
|
-
if(!pose) return false;
|
|
285
|
-
return this.setBodyPose(body,{...pose,next:true});
|
|
286
|
-
}
|
|
287
|
-
moveCharacter(controller,body,desiredTranslation,{predicate=null}={}) {
|
|
288
|
-
if(!controller || this.bodyType(body)!=='kinematic') {
|
|
289
|
-
return {success:false,code:'CHARACTER_BODY_UNAVAILABLE',movement:[0,0,0],grounded:false,collisions:[]};
|
|
290
|
-
}
|
|
291
|
-
const colliders=this.colliders(body);
|
|
292
|
-
if(colliders.length!==1) {
|
|
293
|
-
return {success:false,code:'CHARACTER_BODY_UNAVAILABLE',movement:[0,0,0],grounded:false,collisions:[]};
|
|
294
|
-
}
|
|
295
|
-
controller.computeColliderMovement(colliders[0],v3(desiredTranslation),undefined,undefined,predicate || undefined);
|
|
296
|
-
const movement=controller.computedMovement();
|
|
297
|
-
const pose=this.bodyPose(body);
|
|
298
|
-
this.setBodyPose(body,{
|
|
299
|
-
position:[pose.position[0]+movement.x,pose.position[1]+movement.y,pose.position[2]+movement.z],
|
|
300
|
-
next:true
|
|
301
|
-
});
|
|
302
|
-
const collisions=[];
|
|
303
|
-
for(let index=0;index<controller.numComputedCollisions();index++) {
|
|
304
|
-
const hit=controller.computedCollision(index);
|
|
305
|
-
if(!hit?.collider) continue;
|
|
306
|
-
collisions.push({colliderKey:this.colliderKey(hit.collider),toi:hit.toi,normal:[hit.normal1.x,hit.normal1.y,hit.normal1.z]});
|
|
307
|
-
}
|
|
308
|
-
return {success:true,movement:array3(movement),grounded:controller.computedGrounded(),collisions};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
syncSceneQueries(world) {
|
|
312
|
-
if(!world) return;
|
|
313
|
-
if(typeof world.updateSceneQueries==='function') world.updateSceneQueries();
|
|
314
|
-
else world.propagateModifiedBodyPositionsToColliders?.();
|
|
315
|
-
}
|
|
316
|
-
createQueryShape(spec) { return createQueryShape(spec); }
|
|
317
|
-
disposeQueryShape(shape) { shape?.free?.(); }
|
|
318
|
-
intersectionsWithShape(world,position,rotation,shape,callback,{
|
|
319
|
-
excludeCollider=null,excludeBody=null,predicate=null
|
|
320
|
-
}={}) {
|
|
321
|
-
this.syncSceneQueries(world);
|
|
322
|
-
let active=true;
|
|
323
|
-
world?.forEachCollider((other)=>{
|
|
324
|
-
if(!active || other.isEnabled?.()===false) return;
|
|
325
|
-
if(excludeCollider && this.colliderKey(other)===this.colliderKey(excludeCollider)) return;
|
|
326
|
-
const parent=this.colliderParent(other);
|
|
327
|
-
if(excludeBody && this.bodyKey(parent)===this.bodyKey(excludeBody)) return;
|
|
328
|
-
if(predicate && !predicate(other)) return;
|
|
329
|
-
if(!other.intersectsShape(shape,v3(position),q4(rotation))) return;
|
|
330
|
-
active=callback(other)!==false;
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
castCollider(world,source,velocity,{
|
|
334
|
-
excludeCollider=null,excludeBody=null,predicate=null,targetDistance=0,maxToi=1,stopAtPenetration=false
|
|
335
|
-
}={}) {
|
|
336
|
-
this.syncSceneQueries(world);
|
|
337
|
-
let best=null;
|
|
338
|
-
const zero={x:0,y:0,z:0};
|
|
339
|
-
world?.forEachCollider((other)=>{
|
|
340
|
-
if(other.isEnabled?.()===false) return;
|
|
341
|
-
if(this.colliderKey(other)===this.colliderKey(source)) return;
|
|
342
|
-
if(excludeCollider && this.colliderKey(other)===this.colliderKey(excludeCollider)) return;
|
|
343
|
-
const parent=this.colliderParent(other);
|
|
344
|
-
if(excludeBody && this.bodyKey(parent)===this.bodyKey(excludeBody)) return;
|
|
345
|
-
if(predicate && !predicate(other)) return;
|
|
346
|
-
const hit=source.castCollider(v3(velocity),other,zero,targetDistance,maxToi,stopAtPenetration);
|
|
347
|
-
if(!hit) return;
|
|
348
|
-
const colliderKey=this.colliderKey(other);
|
|
349
|
-
if(!best || hit.time_of_impact<best.timeOfImpact) best={colliderKey,timeOfImpact:hit.time_of_impact};
|
|
350
|
-
});
|
|
351
|
-
return best ? {...best,collider:world.getCollider(best.colliderKey)} : null;
|
|
352
|
-
}
|
|
353
|
-
raycast(world,origin,direction,maxDistance,{solid=true,predicate=null}={}) {
|
|
354
|
-
this.syncSceneQueries(world);
|
|
355
|
-
const ray=new RAPIER.Ray(v3(origin),v3(direction));
|
|
356
|
-
let best=null;
|
|
357
|
-
world?.forEachCollider((collider)=>{
|
|
358
|
-
if(collider.isEnabled?.()===false) return;
|
|
359
|
-
if(predicate && !predicate(collider)) return;
|
|
360
|
-
const toi=collider.castRay(ray,maxDistance,solid);
|
|
361
|
-
if(!Number.isFinite(toi) || toi<0) return;
|
|
362
|
-
const colliderKey=this.colliderKey(collider);
|
|
363
|
-
if(!best || toi<best.timeOfImpact) best={colliderKey,timeOfImpact:toi};
|
|
364
|
-
});
|
|
365
|
-
return best ? {...best,collider:world.getCollider(best.colliderKey)} : null;
|
|
366
|
-
}
|
|
367
|
-
contactPairs(world,source) {
|
|
368
|
-
const pairs=[];
|
|
369
|
-
world.contactPairsWith(source,(other)=>{
|
|
370
|
-
let manifoldCount=0,contactCount=0,activeContactCount=0,minDistance=Infinity,totalImpulse=0,normal=null;
|
|
371
|
-
world.contactPair(source,other,(manifold,flipped)=>{
|
|
372
|
-
manifoldCount+=1;
|
|
373
|
-
const rawNormal=manifold.normal();
|
|
374
|
-
normal=flipped ? [-rawNormal.x,-rawNormal.y,-rawNormal.z] : [rawNormal.x,rawNormal.y,rawNormal.z];
|
|
375
|
-
for(let index=0;index<manifold.numContacts();index++) {
|
|
376
|
-
const distance=manifold.contactDist(index);
|
|
377
|
-
const impulse=Math.abs(manifold.contactImpulse(index)||0);
|
|
378
|
-
contactCount+=1;
|
|
379
|
-
if(distance<=1e-6 || impulse>1e-8) activeContactCount+=1;
|
|
380
|
-
minDistance=Math.min(minDistance,distance);
|
|
381
|
-
totalImpulse+=impulse;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
if(manifoldCount && activeContactCount) pairs.push({
|
|
385
|
-
otherKey:this.colliderKey(other),manifoldCount,contactCount,activeContactCount,
|
|
386
|
-
minDistance:Number.isFinite(minDistance)?minDistance:null,totalImpulse,normal,
|
|
387
|
-
evidenceKind:'solver-contact',impulseAvailable:true
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
return pairs.map((pair)=>({...pair,other:world.getCollider(pair.otherKey)}));
|
|
391
|
-
}
|
|
392
|
-
penetrations(world,source) {
|
|
393
|
-
const sourceSnapshot=this.colliderSnapshot(source);
|
|
394
|
-
const sourceBody=sourceSnapshot?.parent;
|
|
395
|
-
if(!sourceSnapshot) return [];
|
|
396
|
-
const hits=[];
|
|
397
|
-
this.intersectionsWithShape(world,sourceSnapshot.position,sourceSnapshot.rotation,sourceSnapshot.shapeRef,(other)=>{
|
|
398
|
-
const otherBody=this.colliderParent(other);
|
|
399
|
-
if(!otherBody || this.bodyKey(otherBody)===this.bodyKey(sourceBody)) return true;
|
|
400
|
-
const contact=source.contactCollider(other,0);
|
|
401
|
-
if(contact && contact.distance<0) hits.push({otherKey:this.colliderKey(other),distance:contact.distance});
|
|
402
|
-
return true;
|
|
403
|
-
},{excludeCollider:source});
|
|
404
|
-
return hits.map((hit)=>({...hit,other:world.getCollider(hit.otherKey)}));
|
|
405
|
-
}
|
|
406
|
-
shapesIntersect(leftShape,leftPosition,leftRotation,rightShape,rightPosition,rightRotation) {
|
|
407
|
-
return leftShape.intersectsShape(v3(leftPosition),q4(leftRotation),rightShape,v3(rightPosition),q4(rightRotation));
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Rendering
|
|
2
|
-
|
|
3
|
-
正式渲染能力:createRenderer、后处理、Gaussian Splat 加载、资源释放与 RendererProbe。
|
|
4
|
-
保持平铺文件。RendererProbe 服务正式运行诊断;实验 WebGPU probes 已归 apps/observatory/probes/rendering。
|
|
5
|
-
World 的 RenderingSystem 负责 World 展示适配,并由 application/createSession.js 装配到 WorldRuntime。modules/rendering 不依赖 World;Generated World 坐标转换由 World 的 RenderingSystem 应用。
|
|
6
|
-
|
|
7
|
-
任务见 tasks.jsonl。验证:npm run test -- tests/rendering tests/observatory。
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { rendererDiagnostics } from './createRenderer.js';
|
|
2
|
-
|
|
3
|
-
const WEBGPU_LIMIT_KEYS = Object.freeze([
|
|
4
|
-
'maxTextureDimension2D',
|
|
5
|
-
'maxBindGroups',
|
|
6
|
-
'maxBufferSize',
|
|
7
|
-
'maxUniformBufferBindingSize',
|
|
8
|
-
'maxStorageBufferBindingSize',
|
|
9
|
-
'maxComputeWorkgroupStorageSize',
|
|
10
|
-
'maxComputeInvocationsPerWorkgroup',
|
|
11
|
-
'maxStorageBuffersPerShaderStage',
|
|
12
|
-
'maxComputeWorkgroupSizeX',
|
|
13
|
-
'maxComputeWorkgroupSizeY',
|
|
14
|
-
'maxComputeWorkgroupSizeZ',
|
|
15
|
-
'maxComputeWorkgroupsPerDimension'
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
const scalar = (value) => typeof value === 'bigint'
|
|
19
|
-
? (value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString())
|
|
20
|
-
: value;
|
|
21
|
-
|
|
22
|
-
function deviceDiagnostics(renderer) {
|
|
23
|
-
const backend = renderer?.backend;
|
|
24
|
-
if (backend?.isWebGPUBackend !== true) {
|
|
25
|
-
return {
|
|
26
|
-
compatibilityMode: null,
|
|
27
|
-
timestampSupported: Boolean(backend?.disjoint),
|
|
28
|
-
features: [],
|
|
29
|
-
limits: {}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const device = backend.device;
|
|
34
|
-
const limits = {};
|
|
35
|
-
for (const key of WEBGPU_LIMIT_KEYS) {
|
|
36
|
-
const value = device?.limits?.[key];
|
|
37
|
-
if (value != null) limits[key] = scalar(value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
compatibilityMode: backend.compatibilityMode === true,
|
|
42
|
-
timestampSupported: Boolean(device?.features?.has?.('timestamp-query')),
|
|
43
|
-
features: device?.features ? [...device.features].map(String).sort() : [],
|
|
44
|
-
limits
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class RendererProbe {
|
|
49
|
-
constructor(renderer, {
|
|
50
|
-
requestedMode = 'auto',
|
|
51
|
-
timingIntervalMs = 1000,
|
|
52
|
-
onDeviceLost = null,
|
|
53
|
-
onError = null
|
|
54
|
-
} = {}) {
|
|
55
|
-
if (!renderer) throw new TypeError('RendererProbe requires a renderer');
|
|
56
|
-
this.renderer = renderer;
|
|
57
|
-
this.info = rendererDiagnostics(renderer, requestedMode);
|
|
58
|
-
this.device = deviceDiagnostics(renderer);
|
|
59
|
-
this.health = 'ready';
|
|
60
|
-
this.lastError = null;
|
|
61
|
-
this.gpuTimeMs = null;
|
|
62
|
-
this.frameIntervals=[];
|
|
63
|
-
this.lastFrameAt=null;
|
|
64
|
-
this.renderCpuMs=[];
|
|
65
|
-
this.timingIntervalMs = Math.max(250, Number(timingIntervalMs) || 1000);
|
|
66
|
-
this.nextTimingAt = 0;
|
|
67
|
-
this.timingPromise = null;
|
|
68
|
-
this.onDeviceLost = typeof onDeviceLost === 'function' ? onDeviceLost : null;
|
|
69
|
-
this.onError = typeof onError === 'function' ? onError : null;
|
|
70
|
-
this.previousDeviceLost = renderer.onDeviceLost;
|
|
71
|
-
this.previousError = renderer.onError;
|
|
72
|
-
|
|
73
|
-
renderer.onDeviceLost = (detail) => {
|
|
74
|
-
this.previousDeviceLost?.call(renderer, detail);
|
|
75
|
-
this.health = 'lost';
|
|
76
|
-
this.lastError = normalizeRendererError(detail, 'device-lost');
|
|
77
|
-
this.onDeviceLost?.(this.lastError);
|
|
78
|
-
};
|
|
79
|
-
renderer.onError = (detail) => {
|
|
80
|
-
this.previousError?.call(renderer, detail);
|
|
81
|
-
if (this.health !== 'lost') this.health = 'degraded';
|
|
82
|
-
this.lastError = normalizeRendererError(detail, 'backend-error');
|
|
83
|
-
this.onError?.(this.lastError);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
afterRender(timestamp = 0, renderCpuMs = null) {
|
|
88
|
-
if(Number.isFinite(timestamp)) {
|
|
89
|
-
const interval=this.lastFrameAt==null?null:timestamp-this.lastFrameAt;
|
|
90
|
-
// Background-tab suspension starts a fresh window instead of inflating frame percentiles.
|
|
91
|
-
if(interval>1000){this.frameIntervals.length=0;this.renderCpuMs.length=0;}
|
|
92
|
-
else if(interval>0)pushSample(this.frameIntervals,interval);
|
|
93
|
-
this.lastFrameAt=timestamp;
|
|
94
|
-
}
|
|
95
|
-
if(Number.isFinite(renderCpuMs) && renderCpuMs>=0)pushSample(this.renderCpuMs,renderCpuMs);
|
|
96
|
-
if (!this.renderer?.backend?.trackTimestamp || this.health === 'lost') return;
|
|
97
|
-
if (this.timingPromise || timestamp < this.nextTimingAt) return;
|
|
98
|
-
this.nextTimingAt = timestamp + this.timingIntervalMs;
|
|
99
|
-
this.timingPromise = Promise.resolve(this.renderer.resolveTimestampsAsync?.('render'))
|
|
100
|
-
.then((value) => {
|
|
101
|
-
if (Number.isFinite(value)) this.gpuTimeMs = value;
|
|
102
|
-
})
|
|
103
|
-
.catch((error) => {
|
|
104
|
-
this.lastError = normalizeRendererError(error, 'timestamp-error');
|
|
105
|
-
})
|
|
106
|
-
.finally(() => { this.timingPromise = null; });
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
snapshot() {
|
|
110
|
-
return Object.freeze({
|
|
111
|
-
...this.info,
|
|
112
|
-
health: this.health,
|
|
113
|
-
gpuTiming: Boolean(this.renderer?.backend?.trackTimestamp),
|
|
114
|
-
gpuTimeMs: this.gpuTimeMs,
|
|
115
|
-
frameIntervalMs:percentiles(this.frameIntervals),
|
|
116
|
-
renderCpuMs:percentiles(this.renderCpuMs),
|
|
117
|
-
workload:{
|
|
118
|
-
drawCalls:this.renderer?.info?.render?.drawCalls ?? this.renderer?.info?.render?.calls ?? null,
|
|
119
|
-
triangles:this.renderer?.info?.render?.triangles ?? null,
|
|
120
|
-
geometries:this.renderer?.info?.memory?.geometries ?? null,
|
|
121
|
-
textures:this.renderer?.info?.memory?.textures ?? null
|
|
122
|
-
},
|
|
123
|
-
compatibilityMode: this.device.compatibilityMode,
|
|
124
|
-
timestampSupported: this.device.timestampSupported,
|
|
125
|
-
features: [...this.device.features],
|
|
126
|
-
limits: { ...this.device.limits },
|
|
127
|
-
lastError: this.lastError ? { ...this.lastError } : null
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
dispose() {
|
|
132
|
-
if (!this.renderer) return;
|
|
133
|
-
this.renderer.onDeviceLost = this.previousDeviceLost;
|
|
134
|
-
this.renderer.onError = this.previousError;
|
|
135
|
-
this.renderer = null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function pushSample(samples,value) {if(samples.length===240)samples.shift();samples.push(value);}
|
|
140
|
-
function percentiles(samples) {
|
|
141
|
-
if(!samples.length)return {samples:0,p50:null,p95:null};
|
|
142
|
-
const sorted=[...samples].sort((a,b)=>a-b);
|
|
143
|
-
return {samples:sorted.length,p50:sorted[Math.ceil(sorted.length*.5)-1],p95:sorted[Math.ceil(sorted.length*.95)-1]};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function normalizeRendererError(detail, fallbackType) {
|
|
147
|
-
return Object.freeze({
|
|
148
|
-
type: String(detail?.type || fallbackType),
|
|
149
|
-
api: detail?.api ? String(detail.api) : null,
|
|
150
|
-
reason: detail?.reason ? String(detail.reason) : null,
|
|
151
|
-
message: String(detail?.message || detail?.error?.message || detail || 'Unknown renderer error')
|
|
152
|
-
});
|
|
153
|
-
}
|