question-mark
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.

Error on changing plane position of slice

See original GitHub issue

I am working on a feature that allows users to rotate the localizer helpers of quadview like this video. It is working fine, but after rotation of any 2D renderers, the translation of other renderers is not working fine. The slice of these other renderers is moving, but it should remain the same slice. Watch the video to understand what I am trying to explain. In the video, first I am rotating localizer helper on r2 renderer, and it worked fine. After I am translating the localizer helpers on r2, and observe the slice is not moving, it remains still, like I expected, but when I translate the localizer helper on r1, renderer r1’s slice is moving, but it should not be.

How I am rotating (angle is in radian)

axis = renderer.stackHelper.slice.planeDirection
planeDirection = renderer.stackHelper.slice.planeDirection.clone()
planeDirection.applyAxisAngle(axis,angle)
renderer.stackHelper.slice.planeDirection = planeDirection
renderer.stackHelper.border.helpersSlice = renderer.stackHelper.slice

How I am translating

renderer.stackHelper.slice.planePosition = point
renderer.stackHelper.border.helpersSlice = renderer.stackHelper.slice

I guess there is some error on rounding (Math.ceil or Math.floor) the point that I am setting the planePosition, because it is not coplanar with planePosition and I don’t have a clue how to solve this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasRannoucommented, Nov 27, 2019

Oh I see now thanks -

How do you get the new plane position? By raycasting the cursor position? renderer.stackHelper.slice.planePosition = point

0reactions
zicolimongicommented, Nov 28, 2019

It does not work when I do the raycasting against renderer.stackHelper.slice, it just works when I do it against renderer.stackHelper.slice.children. But the error remains 😦

I checked the localizer helper and I am updating like this Rotating

//Rotate plane method
let axis = renderer.stackHelper.slice.planeDirection
//updateLocalizer method - Update the renderer I am rotating
renderer.localizerHelper.plane1 = [r1,r2,r3].filter(function(e) { if(e!=renderer) return e })[0].stackHelper.slice.cartesianEquation()
renderer.localizerHelper.plane2 = [r1,r2,r3].filter(function(e) { if(e!=renderer) return e })[1].stackHelper.slice.cartesianEquation()
renderer.localizerHelper.referencePlane = renderer.stackHelper.slice.cartesianEquation()
renderer.localizerHelper.geometry = renderer.stackHelper.slice.geometry

for(let otherRenderer of [r1,r2,r3].filter(function(e) { if(e!=renderer) return e })){
 //Rotate PLane direction method
 let planeDirection = otherRenderer.stackHelper.slice.planeDirection.clone()
 planeDirection.applyAxisAngle(axis,angle)
 otherRenderer.stackHelper.slice.planeDirection = planeDirection
 otherRenderer.stackHelper.border.helpersSlice = otherRenderer.stackHelper.slice
 //updateLocalizer method - Update the other rendererers
 otherRenderer.localizerHelper.plane1 = [r1,r2,r3].filter(function(e) { if(e!=otherRenderer) return e })[0].stackHelper.slice.cartesianEquation()
 otherRenderer.localizerHelper.plane2 = [r1,r2,r3].filter(function(e) { if(e!=otherRenderer) return e })[1].stackHelper.slice.cartesianEquation()
 otherRenderer.localizerHelper.referencePlane = otherRenderer.stackHelper.slice.cartesianEquation()
 otherRenderer.localizerHelper.geometry = otherRenderer.stackHelper.slice.geometry
 //Rotate camera method
 for(let direction of otherRenderer.camera._directions){
   direction.applyAxisAngle(axis,angle)
 }
 otherRenderer.camera.update()
}

Translating

// translateLocalizerToMousePosition method
let raycaster = new THREE.Raycaster();
let camera = renderer.camera
let stackHelper = renderer.stackHelper
let scene = renderer.scene
if(renderer.domId == 'r0'){
 stackHelper = r1.stackHelper
}
raycaster.setFromCamera(point, camera);
let intersects = raycaster.intersectObjects(renderer.stackHelper.slice.children, false);
if (intersects.length > 0) {
 //translatePlanesToPoint method
 let point = CoreUtils.worldToData(renderer.stackHelper.stack.lps2IJK, intersects[0].point);
 for(let renderer of [r1,r2,r3]){
   renderer.stackHelper.slice.planePosition = point
   renderer.stackHelper.border.helpersSlice = renderer.stackHelper.slice
 }
 for(let renderer of [r1,r2,r3]){
   //updateLocalizer method
   renderer.localizerHelper.plane1 = [r1,r2,r3].filter(function(e) { if(e!=renderer) return e })[0].stackHelper.slice.cartesianEquation()
   renderer.localizerHelper.plane2 = [r1,r2,r3].filter(function(e) { if(e!=renderer) return e })[1].stackHelper.slice.cartesianEquation()
   renderer.localizerHelper.referencePlane = renderer.stackHelper.slice.cartesianEquation()
   renderer.localizerHelper.geometry = renderer.stackHelper.slice.geometry
 } 
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

slice plane not correct - 3ds Max Community - Autodesk Forums
Hi all, I am new in 3ds max. I import two .obj files into 3ds max. After imported the files, one got the...
Read more >
Am I using slice incorrectly? - MATLAB Answers - MathWorks
My problem is when I use slice it switches the x and y planes. The array is still stored correctly when points are...
Read more >
How To Fix A Slice: 7 Simple Steps To A Beautiful Ball Flight
Learn how to fix a slice and start hitting longer, straighter, and more consistent golf shots. Follow these 7 simple steps and start...
Read more >
Slices – How to Stop Slicing Golf Balls Right - Golf Distillery
FIX: Keep the knee bend angle in your knees constant mostly during the entire swing. This should help you avoid moving your hips...
Read more >
Python list error: [::-1] step on [:-1] slice - Stack Overflow
The first -1 in a[:-1:-1] doesn't mean what you think it does. In slicing, negative start/end indices are not interpreted literally.
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found