4

I'm trying to add an OutlinePass described in outline a 3d object in three.js. I'm using TransformControls to move objects in my scene. However, whenever I try to outline an object, it looks like the TransformControls are being outlined as well. This is especially prominent when the hiddenEdgeColor is lighter.

You can see an example where I added a TransformControl to the OutlinePass demo provided by THREE.js:

https://jsfiddle.net/ye0e47dv/3/

I added this snippet:

let gizmo = new THREE.TransformControls(camera, renderer.domElement);
scene.add(gizmo);
gizmo.attach(floorMesh);

If you select any object other than the ground, you'll see the TransformControls light up.

3 Answers 3

4

I just ran into the same issue using up-to-date TransformControls, OutlinePass (containing the patch mentioned in the answer of @eskubeltz) and THREEjs (v100).

It seems that some recent modifications on the visiblity tags are responsible of this.

To solve this, I tag the TransformControls objects:

control = new THREE.TransformControls(camera, domElement);
control.traverse((obj) => { // To be detected correctly by OutlinePass.
  obj.isTransformControls = true;
});

.. and fix again the Outline.VisibilityChangeCallBack() function like following:

if ( object.isMesh || object.isLine || object.isSprite || object.isTransformControls )
Sign up to request clarification or add additional context in comments.

Comments

1

I have had the same problem with Lineas and Sprites. To fix this problem, I edited the file outlinePass.js in the line 181 (function VisibilityChangeCallBack)

Original

if (( object instanceof THREE.Mesh ) {

Edited

if (( object instanceof THREE.Mesh ) || (object instanceof THREE.Sprite) || (object instanceof THREE.Line)) {

I think your problem will be fixed with this change, as I could see in your jsfiddle only the lines of the transformControl are selected, not the cones.

Regards

1 Comment

Thank you, was facing the same issue with simple sprites added to the scene.
0

In three version 0.132.2 just add || object.isTransformControls to VisibilityChangeCallBack(). Updated OutlinePass code is here (with three module imports changed). You can use this OutlinePass - https://paste-bin.xyz/6023

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.