added event handler
This commit is contained in:
@@ -1,13 +1,34 @@
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import * as THREE from 'three'
|
||||
import { usePlayButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||
import { useProductContext } from '../../../products/productContext';
|
||||
|
||||
import PillarJibAnimator from '../animator/pillarJibAnimator'
|
||||
import PillarJibHelper from '../helper/pillarJibHelper'
|
||||
|
||||
function PillarJibInstance({ crane }: { crane: CraneStatus }) {
|
||||
const { isPlaying } = usePlayButtonStore();
|
||||
const { craneStore, productStore } = useSceneContext();
|
||||
const { getActionByUuid, getEventByModelUuid, getTriggerByUuid } = productStore();
|
||||
const { getCraneById } = craneStore();
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const [currentPhase, setCurrentPhase] = useState<string>('idle');
|
||||
const [animationPhase, setAnimationPhase] = useState<string>('idle');
|
||||
const [points, setPoints] = useState<[THREE.Vector3, THREE.Vector3] | null>(null);
|
||||
|
||||
const position1: [number, number, number] = [5, 1, -4];
|
||||
const position2: [number, number, number] = [-2, 2, -2];
|
||||
useEffect(() => {
|
||||
if (isPlaying) {
|
||||
const action = getActionByUuid(selectedProduct.productUuid, crane?.currentAction?.actionUuid || '');
|
||||
if (!action || action.actionType !== 'pickAndDrop') return;
|
||||
|
||||
if (!crane.isActive && currentPhase === 'idle' && crane.currentMaterials.length > 0 && action.maxPickUpCount <= crane.currentMaterials.length) {
|
||||
console.log('crane: ', crane);
|
||||
|
||||
}
|
||||
}
|
||||
}, [crane, currentPhase])
|
||||
|
||||
const handleAnimationComplete = (action: string) => {
|
||||
if (action === 'picking') {
|
||||
@@ -27,10 +48,7 @@ function PillarJibInstance({ crane }: { crane: CraneStatus }) {
|
||||
<PillarJibAnimator
|
||||
key={crane.modelUuid}
|
||||
crane={crane}
|
||||
points={[
|
||||
new THREE.Vector3(...position1),
|
||||
new THREE.Vector3(...position2)
|
||||
]}
|
||||
points={points}
|
||||
animationPhase={animationPhase}
|
||||
setAnimationPhase={setAnimationPhase}
|
||||
onAnimationComplete={handleAnimationComplete}
|
||||
|
||||
Reference in New Issue
Block a user