cepekas
cepekas

Reputation: 1

issues with bcf coords while creating BCF

I’m using THREE JS perspective camera and I have bad time to get proper viewpoints, directions or upVectors, because my created bcf file with perspective camera coords do not work in other bcf readers. I guess BCF readers using different coords system then Three js? Here is my snippet how I extract data from perspective camera:

const perspectiveCamera = camera.activeCamera;

              // Ensure we're working with the world matrix
              perspectiveCamera.updateMatrixWorld();
              const worldMatrix = perspectiveCamera.matrixWorld.elements;

              // Extract view point (camera position in world space)
              const viewPoint = new THREE.Vector3().setFromMatrixPosition(
                perspectiveCamera.matrixWorld
              );

              // Extract and calculate direction (positive Z axis of camera in world space for BCF)
              const direction = new THREE.Vector3(
                worldMatrix[8],
                worldMatrix[9],
                worldMatrix[10]
              ).normalize();

              // Extract up vector (Y axis of camera in world space)
              const upVector = new THREE.Vector3(
                worldMatrix[4],
                worldMatrix[5],
                worldMatrix[6]
              ).normalize();

here is my bcfv which is created with extracted camera data:

<PerspectiveCamera>
      <CameraViewPoint>
        <X>13.097523748662885</X>
        <Y>19.561082935279494</Y>
        <Z>7.822913290014812</Z>
      </CameraViewPoint>
      <CameraDirection>
        <X>0.6397360265711332</X>
        <Y>0.30665559581291757</Y>
        <Z>0.7047695806883291</Z>
      </CameraDirection>
      <CameraUpVector>
        <X>-0.2061088446664055</X>
        <Y>0.9518205427267393</Y>
        <Z>-0.2270612221266656</Z>
      </CameraUpVector>
      <FieldOfView>60</FieldOfView>
    </PerspectiveCamera>

and here is how from other bcf reader created bcfv file looking at almost the same position looks like:

<PerspectiveCamera>
      <CameraViewPoint>
            <X>25.506270197147572</X>
            <Y>-7.8545907994160586</Y>
            <Z>19.219019694186667</Z>
        </CameraViewPoint>
        <CameraDirection>
            <X>-0.52133992233293036</X>
            <Y>0.79782835854564405</Y>
            <Z>-0.30277812946488963</Z>
        </CameraDirection>
        <CameraUpVector>
            <X>-0.16562456632256012</X>
            <Y>0.25346222344310271</Y>
            <Z>0.95306107061286616</Z>
        </CameraUpVector>
        <FieldOfView>44.999990638015838</FieldOfView>
    </PerspectiveCamera>
```

Upvotes: 0

Views: 36

Answers (0)

Related Questions