From 2c9d55a1aa5fb7d65a1c7dd7c00db6a27802dc3a Mon Sep 17 00:00:00 2001 From: kgv Date: Sun, 16 Feb 2020 21:53:08 +0300 Subject: [PATCH] 0031373: Samples - provide sample combining OCCT and 3 viewer --- samples/webgl/WasmOcctView.cpp | 14 ++++++++++ samples/webgl/occt-webgl-sample.html | 40 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/samples/webgl/WasmOcctView.cpp b/samples/webgl/WasmOcctView.cpp index 68a8b86bba..7f78ee6b9d 100644 --- a/samples/webgl/WasmOcctView.cpp +++ b/samples/webgl/WasmOcctView.cpp @@ -52,6 +52,14 @@ namespace return aDevicePixelRatio; }); + /*EM_JS(void, jsSetOcctCamera, (float theFOV, float theAspect, float theNear, float theFar), { + setOcctCamera(); + });*/ + + EM_JS(void, jsPostFrameRender, (), { + postFrameRender(); + }); + //! Return cavas size in pixels. static Graphic3d_Vec2i jsCanvasSize() { @@ -336,7 +344,13 @@ void WasmOcctView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCt const Handle(V3d_View)& theView) { myUpdateRequests = 0; + + theView->Invalidate(); /// Three.js cannot be rendered properly without full redraw + glEnable (GL_POLYGON_OFFSET_FILL); /// reset defaults Graphic3d_PolygonOffset after Three.js + glPolygonOffset (1.0f, 1.0f); + AIS_ViewController::handleViewRedraw (theCtx, theView); + jsPostFrameRender(); if (myToAskNextFrame) { // ask more frames diff --git a/samples/webgl/occt-webgl-sample.html b/samples/webgl/occt-webgl-sample.html index 80f7e6f4d8..fc417b2e8f 100644 --- a/samples/webgl/occt-webgl-sample.html +++ b/samples/webgl/occt-webgl-sample.html @@ -16,6 +16,7 @@

Console output:

+