3D draw operations seem to destroy webgl in palettes

3D draw operations seem to destroy webgl in palettes

nraynaud
Enthusiast Enthusiast
441 Views
1 Reply
Message 1 of 2

3D draw operations seem to destroy webgl in palettes

nraynaud
Enthusiast
Enthusiast

I am trying to develop a slicer for fusion 360, and I am struggling to find a solution for display.

When exploring webgl, it seems that any display operation in Fusion 360 destroys the webgl context in the palette.

Does anyone have some experience with webgl in a palette on mac?

Here is a movie, clicking on the "redraw button" should slightly rotate the sphere and redraw it:

 

hIfDFsa8CR

 

here is the HTML code in the palette:

<html>
<head>
    <style>
        body {
            margin: 0;
        }

        canvas {
            width: 100%;
            height: 100%
        }
    </style>
    <script src="three.js"></script>
</head>
<body>
<button onclick="test(null);console.log('click');">redraw</button>
<script>
    var scene = new THREE.Scene();
    var renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);
    var lineMaterial = new THREE.LineBasicMaterial({color: 0xffffff, transparent: true, opacity: 0.5});
    var meshMaterial = new THREE.MeshPhongMaterial({
        color: 0x156289,
        emissive: 0x072534,
        side: THREE.DoubleSide,
        flatShading: true
    });
    var lights = [];
    lights[0] = new THREE.PointLight(0xffffff, 1, 0);
    lights[1] = new THREE.PointLight(0xffffff, 1, 0);
    lights[2] = new THREE.PointLight(0xffffff, 1, 0);

    lights[0].position.set(0, 200, 0);
    lights[1].position.set(100, 200, 100);
    lights[2].position.set(-100, -200, -100);

    scene.add(lights[0]);
    scene.add(lights[1]);
    scene.add(lights[2]);
    var geometry = new THREE.SphereBufferGeometry(100, 32, 32);
    var group = new THREE.Group();
    group.add(new THREE.LineSegments(geometry, lineMaterial));
    group.add(new THREE.Mesh(geometry, meshMaterial));
    scene.add(group);
    var camera2 = new THREE.OrthographicCamera(-150, 150, -150, 150, 0, 10000000);
    camera2.position.set(0, 0, 1500);
    camera2.lookAt(new THREE.Vector3(0, 0, 0));
    test = function () {
        //requestAnimationFrame(animate);
        group.rotation.x += 0.1;
        renderer.render(scene, camera2);
    };
    //animate();

</script>
</body>
</html>

Thanks for any help,

 

Nicolas.

0 Likes
442 Views
1 Reply
Reply (1)
Message 2 of 2

nraynaud
Enthusiast
Enthusiast

upon further investigation, it seems that fusion 360 moves something about the camera in webgl (and it goes black because my background is black), 

 

I tested by putting a scene containing an environmental map ( https://threejs.org/examples/webgl_materials_envmaps.html ) in the palette, and having fusion 360 do any drawing operation moves the point of view, or somehow destroys some matrix on the webgl stack but still "draws":

0J7MFhDuR8

0 Likes