Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Voxel Probe domElement position

See original GitHub issue

The positioning of the element containing voxel data only works when the renderer’s parent element is positioned at the top-left corner of the document. If the the renderer parent is contained in another element and its positioning with respect to the document is not at the top-left corner you should take in account its offset.

I made a little patch to the “updateRaycaster” function but I’m not sure if it’s the correct way to address the problem, neither if it conforms to your code conventions…

Anyway, here’s my patch:

updateRaycaster(raycaster, event, container) {
  // calculate mouse position in normalized device coordinates
  // (-1 to +1) for both components
  var offsets = this.getContainerOffsets();

  this._mouse = {
    x: (event.clientX - offsets.left) / container.offsetWidth * 2 - 1,
    y: -((event.clientY - / container.offsetHeight) * 2 + 1,
    screenX: event.clientX - offsets.left,
    screenY: event.clientY -

  // update the raycaster
  raycaster.setFromCamera(this._mouse, this._camera);

getContainerOffsets() { // crossbrowser version
  //Taken from
  var box = container.getBoundingClientRect();

  var body = document.body;
  var docEl = document.documentElement;

  var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
  var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;

  var clientTop = docEl.clientTop || body.clientTop || 0;
  var clientLeft = docEl.clientLeft || body.clientLeft || 0;

  var top  = +  scrollTop - clientTop;
  var left = box.left + scrollLeft - clientLeft;

  return { top: Math.round(top), left: Math.round(left) };

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

okradcommented, Mar 26, 2017

Ok, I’m working on it… Expect a pull request on a couple of days…

NicolasRannoucommented, Mar 27, 2017

Thanks @okrad that would be very useful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three.js Voxel Painter / groundbear - Observable
renderer = hg {domElement: HTMLCanvasElement, debug: Object, autoClear: true, ... voxel.position.copy(intersect.point).add(intersect.face.normal);.
Read more >
Voxel Probe - Documentation - Unigine Developer
Voxel Probe is a light source which provides static voxel lighting and shading on an object inside Voxel Probe by using a prebaked...
Read more >
API Docs - Cornerstone Tools
Returns an array of voxel values masked by the segment for each frame, as well as the real world volume of a voxel...
Read more >
Manipulating DOM Elements with html() and position() - p5.js ...
This video shows how to change the content of an HTML element using html() or set its position using position (). These functions...
Read more >
How To Bake Global Illumination to Voxel Probes - unigine
Voxel Probe is one of the light baking technologies available in UNIGINE 2 that provides static voxel lighting and object shading using a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found