Hello ThreeJS’ers,
I have an issue with the main renderer being obscured by the viewHelper.
I have followed Interactive view helper. - JSFiddle - Code Playground example and the code that I have used is almost the same.
The scenario is:
- if I put the
viewHelper.render(renderer)
below therenderer.render (scene, camera)
I can see theviewHelper
. - If I put it above I can see the holes I import after the scene is setup.
The difference in my code is that I add my custom objects through a file upload. They are added to the scene
in their respective creation code.
- fileInput buutton pressed
- fileUpload called
- drawHoles Called
- case checked and hole style (drawCrossHole) called
- hole group added to Scene
//snippet from inside fileUpload.js
else if (data.split("\n")[0].split(",").length === 7) {
for (const point of points) {
if (params.debugComments) {
console.log("fileUpload/handleFileUploadNoEvent/drawHoles: " + point.pointID + " X: " + point.startXLocation + " Y: " + point.startYLocation + " Z: " + point.startZLocation);
}
const tempPoint = {
pointID: point.pointID,
startXLocation: point.startXLocation - x,
startYLocation: point.startYLocation - y,
startZLocation: point.startZLocation - z,
endXLocation: point.endXLocation - x,
endYLocation: point.endYLocation - y,
endZLocation: point.endZLocation - z
};
drawHoles(canvas.scene, colour, tempPoint, 165, 1);
}
}
//snippet from inside drawHoles.js
case "lineCross": {
const lineWidth = 5;
const dashArray = false;
const dashOffset = 0;
const dashRatio = 0;
const opacity = 1;
const sizeAttenuation = false;
const diameter = 500;
drawCrossHole(scene, colour, pointID, collarVector, intervalVector, toeVector, diameter, lineWidth, dashArray, dashOffset, dashRatio, opacity, sizeAttenuation);
if (params.debugComments) {
console.log("crossHoleID: " + pointID + " X: " + collarVector.x + " Y: " + collarVector.y + " Z: " + collarVector.z);
}
break;
}
//snippet from inside drawCrossHole.js
const hole = new Group();
//draw Cross
hole.add(createLine(vectors.topLeft, vectors.bottomRight, color, lineWidth, dashArray, dashOffset, dashRatio, opacity, sizeAttenuation));
hole.add(createLine(vectors.bottomLeft, vectors.topRight, color, lineWidth, dashArray, dashOffset, dashRatio, opacity, sizeAttenuation));
//draw BenchLength of hole
hole.add(createLine(collarXYZ, intervalXYZ, color, lineWidth, dashArray, dashOffset, dashRatio, opacity, sizeAttenuation));
//color = getRandomColor();
color = "red";
//draw subdrill of hole
hole.add(createLine(intervalXYZ, toeXYZ, color, lineWidth, dashArray, dashOffset, dashRatio, opacity, sizeAttenuation));
hole.name = pointID;
scene.add(hole);
}
The scenario is:
- if I put the viewHelper.render(renderer) below the renderer.render (scene, camera) I can see the viewHelper.
- If I put it above I can see the holes I import after the scene is setup.
I don’t get both my holes and the viewHelper
ViewHelper visible but unable to see holes loaded after scene setup
//snippet from inside createScene.js
function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
if (viewHelper.animating) viewHelper.update(delta);
renderer.render(scene, camera);
viewHelper.render(renderer);
//controls.update();
}
ViewHelper NOT visible however holes loaded after scene setup are visible.
//snippet from inside createScene.js
function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
if (viewHelper.animating) viewHelper.update(delta);
viewHelper.render(renderer);
renderer.render(scene, camera);
//controls.update();
}
Below is a GIF of the issue. In this, you can see that after the viewHelper
is //commented
out, the file is consumed and produces output as desired. However, the ViewHelper
is not visible (obviously) but the same occurs if I swap the render order.
What could be wrong with this?*.
Is the renderer opaque and I just can’t see behind it or is there some other issue?
Thanks in advance.