... func update(context: SceneUpdateContext) { var transforms: [HandTrackingComponent.Location: simd_float4x4] = [:] // HandTrackingComponentを持つentities (AnchorEntity)からtransformを取得して保持する for entity in context.entities(matching: EntityQuery(where: .has(HandTrackingComponent.self)), updatingSystemWhen: .rendering) { guard let anchorEntity = entity as? AnchorEntity, anchorEntity.isAnchored else { continue } guard let handTrackingComponent = entity.components[HandTrackingComponent.self] else { continue } transforms[handTrackingComponent.location] = entity.transformMatrix(relativeTo: nil) } // ShipControlComponentを持つentitiesに対して、上で取得したtransformをもとにパラメータを更新 for entity in context.entities(matching: EntityQuery(where: .has(ShipControlComponent.self)), updatingSystemWhen: .rendering) { updateShipControlParameters(for: entity, context: context, transforms: transforms) } } ... @MainActor func updateShipControlParameters(for entity: Entity, context: SceneUpdateContext, transforms: [HandTrackingComponent.Location: simd_float4x4]) { let shipControlParameters = entity.components[ShipControlComponent.self]!.parameters guard let indexTipTransform = transforms[.leftIndexFingerTip], let thumbTipTransform = transforms[.leftThumbTip], let rightPalmTransform = transforms[.rightPalm] else { return } // 左手 親指,人差し指 transformからthrottleを計算して更新する let throttle = computeTargetThrottle(indexTipTransform: indexTipTransform, thumbTipTransform: thumbTipTransform) shipControlParameters.throttle = interpolateThrottle(current: currentThrottle, target: targetThrottle, deltaTime: context.deltaTime) // 左右 手 ひら transformからpitch,rollを計算して更新する let (pitch, roll) = computePitchAndRoll(leftPalmTransform: leftPalmTransform, rightPalmTransform: rightPalmTransform) shipControlParameters.pitch = pitch shipControlParameters.roll = roll } }