Skip to content

Commit

Permalink
feat: add custom events for rotation and position updates in VantageR…
Browse files Browse the repository at this point in the history
…enderer
  • Loading branch information
fidelthomet committed Feb 13, 2025
1 parent de8615f commit d18cc45
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ class VantageRenderer extends HTMLElement {
const target = Object.values(this.projections).find(({ focus }) => focus)
if (target == null) return
target.element.setAttribute('rotation', value.join(' '))

target.element.dispatchEvent(
new CustomEvent('vantage:set-rotation', {
bubbles: true,
detail: {
rotation: value
}
})
)
})

const screens = new Group()
Expand Down Expand Up @@ -211,6 +220,14 @@ class VantageRenderer extends HTMLElement {
raycaster.ray.intersectPlane(plane, intersection)

focusProjection.element.setAttribute('position', [...intersection].join(' '))
focusProjection.element.dispatchEvent(
new CustomEvent('vantage:set-position', {
bubbles: true,
detail: {
position: [...intersection]
}
})
)
})
}

Expand Down Expand Up @@ -259,6 +276,14 @@ class VantageRenderer extends HTMLElement {
const pos = this.cameraOperator.camera.getWorldPosition(new Vector3())

target.element.setAttribute('position', [...pos].join(' '))
target.element.dispatchEvent(
new CustomEvent('vantage:set-position', {
bubbles: true,
detail: {
position: [...pos]
}
})
)
}

async addProjection({ id, attributes, element }) {
Expand Down

0 comments on commit d18cc45

Please sign in to comment.