Commit Graph

124 Commits

Author SHA1 Message Date
Alexandru Popovici a3d1e6adec Orbit WASDEQ Controls (#3875)
* Updated the fly controller to use the z up basis

* Fixed very important compiler error

* Removed the annoying delay when first holding down WASD keys before movement started

* Updated LegacyViewer to use the hybrid camera controls

* Added big baker

* Trying to figure out the essence of this

* Partly works

* Pivotal coordinates now work

* Smoothened out the math abit

* Fixed sandbox error

* Enabled the pivot sphere

* feat(viewer-lib): Fixed some issues with orbiting around cursor

* feat(viewer-lib): Updates to WEB-2313, orbiting around mouse cursor
Orbiting around mouse cursor now works correctly with an orthographic projection as well as when toggling between orthographic and perspective.
Disabled WASD navigation for now.
SmoothOrbitControls now has protected members instead of private allowing extension
Documented the important parts of the pivotal navigation code

* feat(viewer-lib): Mouse orbiting now takes clipping planes into consideration

* chore(viewer-lib): Fixed sandbox build error

* fix(viewer-lib): Handled WEB-2449 and WEB-2450
Additionally fixed an issue where changing the orbit pivot would trigger a hard render, adding the unneeded noise of AO re-convergence

* fix(viewer-lib): Fixed the issue with focusing and other camera animations caused by the introduction on the pivotal CS. Pivot sphere now shows only on orbit

* feat(viewer-lib): Updates on mouse orbiting:
- When clicking outside of the model, oribitig will switch to polar and use the last computed origin (which is still going to be based on the last pivot point)
Made the pivot sphere speckle blue
The pivot sphere now only shows when clicking on objects, when clicking outside of the model it will not show

* feat(viewer-lib): Update for WASD aka fly mode:
- Smoother combined navigation by using the immediate controler position and orientation as opposed the the goal ones
- Pivot sphere properly hides when in fly mode
- The bug where the camera would incorrectly jump when toggling between fly and oribit is now gone (or I cannot reproduce it anymore)

* fix(viewer-lib): Fixed sandbox compile error

* feat(viewer-lib): Added the hybrid fly orbit controller to the legacy viewer

* feat(viewer-lib): Added a slower movement speed to WASD navigation when camera is close to geometry

* fix(viewer-lib): Fixed the issue where opening the context menu while holding down a WASD key would make the camera move indefinetely

* Feat(viewer-lib): Update to WASD controls:
- Disabled cursor orbiting
- Added an option to allow for world space up/down with e/q keys. By default it's enabled
- Fixed the pan speed to work similar to WASD speed in two steps depending how close the camera is to geometry

* chore(viewer-lib): Tidied up a bit

* fix(viewer-lib): Fixed an ugly bug where the camera distance calculataion plane would flip, especially when WASD-ing, and mess up the min distance calculation which led the camera near plane to be way off

* chore(viewer-lib): Swapped E to up and Q to down

* Re-nabled cursor orbiting
2025-01-30 16:05:51 +02:00
Alexandru Popovici e1c83d08cf WEB-2417: Shadowcatcher updates when switching versions (#3777)
* chore(viewer-lib): Snow mode is no longer default in the sandbox

* fix(viewer-lib): Handles WEB-2417

Shadowcather now properly updates when adding/removing render trees even if the scene bounds does not change
2025-01-09 13:05:58 +02:00
Alexandru Popovici 68bbedcd92 WEB-1389 (#3555)
* Added FilterMaterial and related types to export list

* Handled WEB-1389
2024-11-26 20:55:53 +02:00
Alexandru Popovici 613614d5d0 View Modes (#3259)
* Edge drawing render pass using both depth and normal data

* Edges are now mixed with the rest of the passes in the final pass

* Set MSAA for SS edges framebuffers to maximum number of samples

* New depth gradient extraction approach. Several improvements over the old one

* Some changes to the normal gradient extraction. Using Robert's Cross works roughly the same as the older approach with 1 less texture fetch. Also implemented Canny

* Combined static AO with edges

* Implemented SMAA and static TAA. Both toggeable in realtime for better comparisons

* Added the normal pass and fixed some issues

* The pipeline is now capable of jitter individual passes if requested

* Added TAA pass. Technically it can be used to antialias anything. Right now we've disabled MSAA and using TAA for stationary as an example

* Added a TAA pipeline on the final image. Added DPR into pipeline resize calls. Struggled a *lot* with different blending results between drawing to the backbuffer and to a framebuffer then copying to the backbuffer. There are still some differences visible

* Edges pipeline

* Edges + TAA + AO + COLOR pipeline

* ShadedView mode

* Visibility is now properly reset when coming from a visibility conditioned pass to an unconditioned one

* Added another version for 'shaded' view, inspired by blender's viewport shading

* Added pen view together with a sample paper like texture for vissual background

* A form of techincal view

* Arctic view. Separate viewport pass from matcap pass

* Cleaned up the ao shader a bit. Formalized progressive ao pass options

* WIP on BasitMode

* Added pipeline switching to the sandbox. Edge pass now has an optional texture background

* Implemented BasicMode using material overrides

* Merged with latest main

* Fix merge issues

* More merge misses

* Stating stream

* Fixed an issue that took hours to debug and it turned out to be a literal typo

* Formalized the progressive pipeline concept which removed a lot of duplicated code

* Added pipeline reseting. Added pipeline passthrough to allow features like measurements to run correctly. Added jitter to depth buffer for progressive AO for much better results!

* Implemented the required stencil passes used for stencil selection as new pass formats. Added them as well as the overlay pass to all pipelines. Will need to automate their addition though

* Fixed stencil selection in pen view. Decided to only show outlines because it makes more sense

* Implemented proper pass clearing values and flags. Also made sure the minimum amount of clears are made inside the frame. Fixed an issue with progressive pass frame counts and indices.

* Formalized options for all passes that had any. Tidied up some shaders and simplified where possible

* Centralized render target creation and removed a lot of render target creation in the passes that had no need for it. Fixed an issue where the matcap material would not not update it's matcap texture properly when rendering in override mode

* Matcap and Viewport passes where merged into a single Viewport pass that can take a matcap texture in it's options. Also, changed the way the viewport shader displays colors, based on three's textureless matcap shader block.

* Updated PassReader extension to work with the latest pipeline. NNowthe pass reader accepts the pass name when reading, so it can used to read any passes

* WIP on MRT

* Implemented DepthNormal MRT pass and used in a pipeline. Working fine on WebGL2.0

* Full Support for WebGL1.0

* Fix for viewport material not updating it's texture properly

* Added an extension that enables hotkeys for view modes

* Fixed jittering for orthographic projections

* Fixed the section tool integration issues with the new pipelines

* Added MRT versions of the pipelines that need it]

* Added a wrapper ViewModes extensions that defines the existing view modes and handles the required check for MRT capabilities and selects the nonMRT/MRT pipelines accordingly

* Error fixes

* Another error

* Added shadowcatcher to arctic and shaded view since it was missing by mistake. Increased the KERNEL_SIZE for arctic mode so that the AO is more smooth

* Disabled pen view background texture

* When reseting the pipeline the jitter index is also reset in order to avoid visible jittering when switching fast between dynamic and progressive mode repeteadly (like when moving the clipping box)

* Quick solution for integrating view modes with per-object operatins like selection and filtering

* View modes now have the ability of overriding the batch's default material instead of all it;s materials. This means that per object material changes like selection and filtering will work together with view modes. Handles WEB-2080, WEB-2083, WEB-2084, WEB-2081 and WEB-2082

* Fiter applies now trigger a hard reset, which is required and fixes a preexisting bug in production. Fixed an issue where the shadowcatcher would incorrectly blend in shaded view mode

* Viewport pass can now render transparency. Arctic mode now renders transparent objects as well (was originally required)

* Forcing the multipel render targets we use for MRT to use a 32 bit depth buffer for proper precision on MacOs Chromium

* Fixed an issue where incorrect visible ranges were being perpetuated when selecting hidden objects (outlines only mode)

* PROPS are not rendered twice anymore and they've been moved to the overlay pass in all pipelines

* Reorganized passes and pipelines. Deleted old passes

* Renamed all new passes. Only the interface and base pass types have a G prepended to make it 100% clear it's different than three's Pass type

* Fixed some compiling errors

* Dont change viewmodes when inputs are being used

* Pipeline gets resized whenever it's set in the renderer. Some other smaller changes

---------

Co-authored-by: Mike Tasset <mike.tasset@gmail.com>
2024-10-29 13:30:26 +02:00
Alexandru Popovici 2f8efeabc5 WEB-1799: Camera Staying in the same location across models (#2862)
* Fixed the issue with camera controller incorrect zoomToBox when switching between loaded objects. If zoomToBox is requested as non animated, now it actually is non animated. Added a default function to the camera controller extensions which moves the camera to the predefined location/orientation

* No radius is specified as default
2024-09-23 15:03:00 +03:00
Kristaps Fabians Geikins 3313787f16 fix(viewer): viewer node16 support + fixing up package.jsons (#2442)
* fix: viewer node16 support + fixing up package.jsons

* lockfile fix

* Removed unnecessary type augmentations. Deleted unused SpeckleCameraControls

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-07-15 15:16:13 +03:00
Alexandru Popovici 3c2b0165e5 Soft Pipeline Reset (#2452)
* Simplified a lot from the Pipeline's render loop. UpdateFlags.Render now does not reset the pipeline. Added UpdateFlags.RESET_RENDER which resets the pipeline. Measurements now do not reset the pipeline needlessly

* Fixed sandbox lint error

* Accumulation now starts automatically based on the current accumulation frames count. SectionTool no longer resets the pipeline without a reason. Changing light paramters no longer reset s the pipeline without a reason. Clipping plane updating no longer resets the pipeline, except when the planes are actually set. Highlight and selection now no longer reset the pipeline. Explosion does reset the pipeline

* Fixed sandbox linting error
2024-07-02 16:12:49 +03:00
Kristaps Fabians Geikins 83d8035dc2 chore: upgrade to eslint 9 (#2348)
* root + server

* frontend

* frontend-2

* dui3

* dui3

* tailwind theme

* ui-components

* preview service

* viewer

* viewer-sandbox

* fileimport-service

* webhook service

* objectloader

* shared

* ui-components-nuxt

* WIP full config

* WIP full linter

* eslint projectwide util

* minor fix

* removing redundant ci

* clean up test errors

* fixed prettier formatting

* CI improvements

* TSC lint fix

* 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader

* removed unnecessary void

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-06-12 14:38:02 +03:00
andrewwallacespeckle d8d1173c38 fix(fe2): View menu not outputting correct names (#2298)
* fix: use view.view.name rather than view.name

* Remove headlessui from Views Menu to prevent close on click

* Fix mobile view

* Remove unused active ref

* Update SpeckleView type to include view.view.name

* Changed the SpeckleView type to no longer use the legacy structure. It's now just another SpeckleObject with some extra props which may or may not exist

* Adapted the viewer library and sandbox to the current SpeckleView model

* Use new SpeckleView. Remove old truncation method.

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
2024-06-03 12:04:11 +02:00
Alexandru Popovici ec78d316bb Viewer API Improvements (#2072)
* Fix some monstrous bugs with index buffer shuffling now that we've changed our approach a bit.~

* Finished with the new material management approach for mesh batches. SelectionExtension now uses this approach and also considers existing material opacities when setting select and hover materials

* Updated LineBatch to work with the new material management approach

* Implemented the required draw range related changes to the point batch

* Text batche now work with the new material management

* SpeckleLineMaterial and SpecklePointsMaterial are now SpeckleMaterial as well. Had to rename two properties of SpeckleMaterial due to some typescript named property clash thing, but nothing really changed

* Removed eslint-disable clauses in materials where they were no longer needed. Removed unused imports and overrides

* Added the RTE define for some materials by default. It can still be overriden if users want to

* Stencil outlines is now an toggle-able option for any SpeckleMaterial. Restricted to meshes

* Implemented setting desired material for all geometry types via RenderMaterial and DisplayStyle data. SpeckleRenderer now has three overloaded setMaterial function. One for a material instance, one for a filer material and one for RenderData&DisplayStyle. Moved material hash related functionality from NodeRendeView into Materials

* Added MaterialOptions which can be used when setting materials based on RenderMaterial/DisplayStyle to toggle various material features like stencilOutlines, pointSize. SelectionExtension now uses data material to set materials, and things are so much more simpler and nicer

* Added public method for setting seletion extension options

* After some profiling, realized three.js was doing a lot of pointless work each frame so now we're caching materials created from RenderMaterial/DisplayStyle to avoid this. Perf is nice and sharp now

* addRenderTreeAsync is now a generator. Handled automatic zooming on viewer loading. Disabled section tool by default

* Centralized RTE and shadow RTE buffer in an extended webglrenderer. This avoids re-computing rte data for each material over and over. Also, rte data is now centralized and available to materials

* SpeckleMeshes now use a cached material clone as their batch material like any other material they use

* Cleaned up Materils. Updated the debug show batches function use the new material manipulation system. So much easier now

* Real time measurement exist now as a separate extension. Existing functionality preserved, besides one or two small additions. Renamed the MEASUREMENTS object layer to OVERLAY for a more generic usage. SelectionExtension can now be enabled/disabled. Added an additional overload to the setCameraView method in ICameraController which takes a box3 as target to focus the camera on

* Removed viewer related events from input and replaced them everywhere with the proper input event types where required

* Fixed two issues with the shadowcatcher. One was a regression introduced after we centralized the RTE data. The other was a super old one one and was essentially causing the shadowcatcher to generate the contact shadows incorrectly because the correct transform textures were not bound (this is three.js being a pain)

* WIP on the filtering extension

* FilteringExtension is done. Kept the same implementation

* Added filter reset function

* Removed uniform texture and batch count binding from each material's OnBeforeRender function. Additionallit our material override function from SpeckleMesh now uses our fast copy instead of three's copy function for materials. This decreased CPU overhead each frame by 20+% and also eliminated the ugly call to SpeckleMesh's function for updating the material with the transform texture and batch object count from each material's render callback which was not supposed to be there

* Update RenderingStats to measure CPU render time per frame.

* Added early and late update functions for extensions. First gets called before the core's update, and the latter afterwards

* All speckle materials now use the centralized RTE data. Updated the fasts copy method to copy userdata defined uniforms where needed

* Added explosion extension. Additional cleanup

* Dirty transforms are marked on a per batch object basis, whenever their transforms gets changed. This automates the transform texture update execution, so we no longer need to manually mark entire batches as dirty

* Added getObjects which returns all batch objects in the scene and getObjects which takes an rv an returns only the batch object associated with that rv. Both of these methods are availale on the renderer

* Added setters for position, rotiation and scale in batch object

* Diff extension is complete. We stuck with creating material instances and using those for coloring since it ensures maximum draw call efficiency. Fixed an issue in MeshBatch where transparent draw groups were not always sorted at the end of the group list leading to incorect opauque object selection during the depth pass

* RV batch materials are obtained via the viewer-core API based on the RV itslef. This removed the need to get all batch materials for the differ

* Small cleanup

* Removed all circular dependencies besides one, like I predicted. The final one will dissapaear on it's own in the near future when we'll gracefull make DataTree obsolete. As a note, the circular dependencies were very shallow, reffering to enums/interfaces/statics declared in specific files. There was no real circular dependency on a class level

* Removed last circular dependency just for the sake of completion

* SpeckleRendere now has a clipping volume which is used internally to reject picks outside of it, and it's also exposed to the outside world to be used however

* Implemented the SpeckleLoader along with it's abstract supertype. Data loading is now done through this loader which handles tree population with raw data as well as render view data.

* Working minimal obj loader

* Added total node counting and displaying

* Viewer's load object now takes a loader of any speckle loader base class and uses that to load, instead of taking urls and tokens. This allows for any kind of loader to work with the vieweer's load function. Moved indexing of obj geometry to the obj geometry convertor. Loaders now take the target world tree instance instead of a viewer instance

* Loaders can now load from string and array buffer data where implemented. ObjLoader can now load from a string payload. Sandbox can now load obj files from the UI using a file picker

* alex/API2.0-core

* Started on #1673. Fixed an issue with walkAsync where the recursive generator would waste too much time idle.

* Solution for #1673. Replaced the old async pausing approach with a better version that has true variable wait time, and does not add additional dead wait time. Render tree building is now several times faster

* Cut down some more on load time by using a lookup table for determined speckle types. For a very large number of objects, getting the actual speckle type was quite slow. For our reference stream with 1kk objects we cut down around 2 seconds of load time

* BoxFromObjects now returns the correctly transformed aabb

* Implemented optimisations for batch building step from the loading process. Reduced the step's time by around 50%

* Implemented a NodeMap which allows us to search for nodes very very fast.

* Added a dynamic pause in the loader which stops the converter from blocking. Paramater object types are not added as nodes anymore. Callback from converter is not without arguments

* Replaced some internal walks with the newer and much faster id finding approach

* Disable object shallow cloning acrss the speckle converter

* Fixed the issues with block instances and revit instances caused by not duplicating speckle objects in the converter

* getObjectPropertis is now async and slightly improved the execution time of the flatten function which it uses

* Set caching to true by default

* Fix for display style hashing

* Implemented legacy viewer as a wrapper around the old viewer API

* Started testing FE1 with API 2.0. Fixed some legacy issues. Also the camera controller extension now exposes it's underlying controls object for the sake of not messing around with unwatend changes in FE1

* Updated FE1 with API2.0 selection changes

* Fixing selection bugs

* The viewer now ignores duplicate id nodes

* Fixes to object properties population, camera zooming and adding subtrees in core

* Fixed some filtering issues. Added UpdateFlags to the viewer's requestRender function

* Fixed an issue where section boxes were incorrectly added to the URL

* Objects with no id are not given nodes into the tree

* Updates to FE2 for API2.0. Also fixed a really really obscure bug in viewer-core where a material an incorrect material was set when reseting the batch to the default material

* We now store separate node maps for each model loaded. Each node now holds it's subtree id (as a small number for memory considerations)

* Render request after updating the visual diff

* Fixed some missing update calls on shadows

* Reverted FE1 changes and pinned the viewer library to a specific (latest) version pre-API2.0

* We're adding a viewer node for loaded models as subtree parent. This is because we're no longer spoofing ids and the model parent id needs to be preserved

* Fixed an issue where clicking on a comment bubble made the pipeline use accumulation improperly, leading to dark blight

* Null check for setMaterial. Fixed another case of dark blight. Hack required by frontend

* Fixed the issue with filtering state not propagating in the FE

* Updated selection event changes

* Fixed an issue where an undefined subtree id would yield an incorrect render tree upon requesting it

* Fixed an issue where undefined nodes were returned as valid when searching of ids

* NodeRenderView now holds it's subtree id along the speckle id. This allows for precise node matching when looking for specific nodes

* Fixed an issue with BlockInstances not instancing underlying meshes from breps

* Some fixes to diffing. Some older than API2.0, some new. Render views now have guid composed of their id and subtreeid.

* Update node render view id with guid where needed

* Unload function now checks for requested resource to unload before trying to unload it

* Check for the existence of a batch before applying draw ranges. Inthe FE, extension can temporarily keep dead rvs in their state when switching between streams leading to errors

* Fixed an issue for filtering where subtree roots would cause incorrect rv additions to the ghosted rv lists

* Unified block instance and revit instance conversion implementation

* Separted instanced from non-instanced rvs. Working on InstancedMeshBatch

* WIP on instanced types

* Implemented visual for box draging

* BoxSelection extension beautified and documented along with some small but welcomed changes to the viewer-core

* Viewer's getExtension now looks in the prototype chain before returning an undefined extension

* Added the extended Selection extension here for possible later use

* First iteration on instancing. General idea works. Still WIP on several fronts

* Fixed issues related to incorrect transform being calculated for instanced geometry. Fixed an issue with incorrect bounds being calculated

* Fixed a few issues with instanced vs non instanced render view gathering

* Disabled box selection extension

* Fixed some linter errors

* Disabled a lint 'error'

* Fixed issues with depth rendering and instanced objects and fixed draw range visibility for instanced batches in a minimalistic way

* Updated the measurements extension with the visiblity option

* Restructed a bit our implementation for the acceleration structure because now the BLAS needs to aggregate an instance of three-mesh-bvh not extend it. So that instanced batch objects can share a single bvh instance -> no redundancy

* WIP

* Revert "WIP"

This reverts commit 20d4bbf6210b0d37b956cc5b41fdb06f29845b4f.

* More WIP on trying to make instanced geometry TAS and BAS work properly

* Both Tas and Bas intersection testing seem to working fine. Now we need to implemented draw grouping for instanced mesh batches

* Added draw group management to InstancedMeshBatch. It works in the same manner as for non instanced batches, but the offset value refers to instances not triangles. I believe it could be simplified, but I'd like to get it up and working first

* Draw groups need to hold the index and count from the instanced buffer attribute

* Added array shuffling to the instanced mesh batch using the same approach we used for the non instanced one.

* Instanced batches now dynamically add InstancedMesh objects based on draw groups and a computed transform buffer

* Applying draw range updates for instanced batches now works. Still some issues to handle. It aint much, but it's honest work

* Disabled some more RTE until setting visibility for draw ranges is finished

* Moved getting opaque, transparent and stencil draw ranges out from Batcher and on to a per-batch basis. Now instanced batches correctly apply draw ranges and get their opaque, transparent and stecil ranges

* Fixed an issue with setting the visibility ranges for instanced mesh batches

* Instanced attributes for instanced meshes now no longer allocate

* Shadow depth material for instances is now set in the speckle renderer

* R-enabled RTE globally. Made instancing work with RTE. Made instancing work with both RTE and shadowmapping.

* Fixed an issue with materials building up in the mesh batch's cache incorrectly

* Implemented gradient indexs attributes for instanced batches. Thismeans, any color ramp based material like the ones we use for filtering now works

* Changed the way compound ids are created for instances, so that less memory is required. i.e chrome is not crashing anymore on particular streams

* Implemented reseting the draw ranges for instanced mesh batches. We no longer double buffer the gradient index buffer. We just create a new one when shuffling, populate it, then copy it over at the end. We're still double buffering the transforms buffer since that one is larger and we might not want to allocate it each time we shuffle

* Removed references of draw groups with ids since we're not doing that anymore. Fixed an issue with mesh batches where the material cache would keep piling materials incorrectly

* Several issues with selective transformations on instanced batches fixed.

* Added default null materials for instanced meshes both with and without vertex colors

* Got rid of the patched InstancedMesh because it was ridiculously slow. Instead we're now computing the scene box using our acceleration structures where available and three.s boundingbox where not available

* Minor, yet big regression fix

* Fixed regression

* Exported some extra types

* WIP on instanced balancing

* Instanced objects under a certain threshold now get batched together as regular mesh batches

* Forgot to update the rvs aabb

* Unified instanced and non instanced batch creation. Instances which do not qualify for instanced batching anre now mixed together with the rest of the non instanced batched objects

* Added some timing information to instanced batches

* Fixed an issue with zooming in on objects not working in the selection extension. Fixed an issue with object picking failing due to fp precision for objects right at the edge of the clipping volume.

* Removed logs

* Update stream moving via UI

* Removed the priority argument from loadObject since it's not needed anymore

* Updated LegacyViewer

* Fixed an issue with API 2.0 where the legacy form of transforms with only an array of values as the matrix would not work

* Updated FE1 viewer package to latest before API 2.0

* Disabled selection when measurement mode is on

* Updated ibl params updating

* Fixed an issue with measurement text not showing up

* Logs

* lockfile

* Made DataTree obsolete. Removed unused 'input' property from viewer

* Fixed circular dependencies

* Removed DebugViewer, other small changes

* Small changes

* Small fixes

* Added id to NodeData

* Removed unused bounds property in rendertree

* Notes to future self + ExtendedExtension is now exported

* Removed an unused function from renderer. Removed the parent argumetn from getRenderViewerForNode... since it was legacy and has no meaning anymore.

* Removed the instance type check in getRenderViewesForNode method. Should not be needed anymore and it was bad to begin with anyway

* Removed some test code

* Small changes

* Removed pointless bounds calculation. Added note

* Added return types

* Ingestigating large group operations

* Nested nodes from TreeNode are now optional. Small update to node render view.

* #1818 Remove the concept of speckle data existing behind a 'data' field

* Removed unneeded property

* made arguments options in transformTRS

* getBoundingBox from acceleration structures have an optional argument now

* Several Batch methods no longer take variable numbe of arguments, but arrays now

* Added note

* Note

* Removed unused things

* Note and made the raycaster protected in intersections

* Added some typings

* Replaceds some functions with accessors. Added typings. Renamed stuff

* Removed some unused properties.

* Typings for measurements

* Small typing changes

* Fixed some more compile errors

* Sources from 'batching' folder are now strict compile compliant

* Sources from 'materials' folder are now strict compile compliant

* Sources from 'extensions' folder are now strict compile compliant

* Sources from 'tree' folder are now strict compile compliant

* Viewer interface, implementation, legacy implementation and the exports now comply with the strict compilation flag. Also added the new tsconfig

* Sources from 'objects' folder now comply to the strict compilation rules

* Sources from 'pipeline' now satisfy the requirements for strict compilation

* Sources from 'loaders' folder are now compiling with strict. That was so much fun

* Sources from 'query' folder are now compiling with strict

* Another round of correction triggered by previous changes

* Update the declaration file in the object loader to contain a member that needs to be public

* SpeckleRenderer along with the rest of the surces from the root 'modules' folder are not compiled with strict

* Completely deprecated DataTree. Updated the dependencies with @types/underscore. Fixed remaining compilation issues

* Fixed a failing build on the CI regarding a timeout id

* Fixed compile errors from sandbox

* Another fix

* All EventEmiter child classes now have mapped event handler argument types, so that when attaching to a specific event, the provided handler has the correct types for it's arguments. Implicitly, got rid of the the unknown types in all event handlers.

* Disabled verbatimModuleSyntax because it was messing things up. Fixed an issue with an improper import

* Fixed frontend-2 linting errors. Also added all the event payload maps to the viewer export

* Some good additions but mostly typescript catering

* Some more typescript catering, but also something useful. The intersect function is now overloaded so that when you specify only the ObjectLayers.STREAM_CONTENT_MESH object layer in it's layers argument it will always return a ExtendedMeshIntersection which guarantees to have a batchObject, face and it's object is of type SpeckleMesh | SpeckleInstancedMesh. Generally you mostly raycast against meshes and getting a three.js intersection object which has all it's fileds optional led to some very useless defined checks. With this we can avoid all of them

* Continued from yesterday, finished with the changes in intersections. Added MeshIntersection which is returned by all bvh intersections. This eliminates the need to check for face, faceIndex or index on intersection results from intersection meshes. Groups from MeshBatch and InstancedMeshBatch are now always DrawRanges(they always were)

* Mostly catering to typescript

* Removed underscore and all unused dependancies. Fixed remaining lint and build errors

* Minor changes

* Added the no-non-null assertion rule to the sandbox

* getExtension never returns null, but rather throws an exception if requested extension does not exist. Added hasExtension for (theoretical) situations where you want to check for extension existence but don't want to go by try/catch with getExtension. Fixed remaining lint/build errors

* getBatches now returns explicit batch types based on the geometry type that you provide

* Adding the lockfile

* undoing unnecessary FE2 changes

* Merged viewer/fe SpeckleObject types

* Fixed two small issues

* Minor linting issues

---------

Co-authored-by: Kristaps Fabians Geikins <fabians@speckle.systems>
2024-05-07 15:18:38 +03:00
Alexandru Popovici 1010c9d23a AEC Aesthetics (#2225)
* Addede a bunch of abstract hdris as well as the option to cycle cle though them at runtime

* Added an extended PMREMGenerator that allows for the rotation of the hdri image.Now our IBL sources are finally straight not tilded 90 deg anymore. Added artificial shininess to all objects configurable in real time from the sandbox.

* Added color grading operations to our standard shader and material. Updated the sandbox to reflect the required AEC Aesthetics properties
2024-04-23 09:56:05 +03:00
Alexandru Popovici d7f0325192 Extension Access Changes (#2193)
* Removed the concept of Providers entirely. Now extentions specify explicity extention types or archypes in their inject lists. Removed the concept of core-extensions entirely. All extensions are now equal. The concept of CameraProvider was replaced by SpeckleCamera which the SpeckleRenderer now uses and relie on the default camera controller extension to seed it.

* Fixed some compile errors

* Fixed compile errors. Had to make Extension concrete, but meh, it's fine I guess

* fix viewer types

* Removed generic arguments since they're no longer needed

---------

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2024-04-05 18:07:02 +03:00
Alexandru Popovici 0454b39cfc WBX-8 Viewer-lib bugfixes (#2041)
* Handled WBX-55

* Fix for WBX-53

* Fixed WBX-160

* Fixed an issue with section box comments where an unwated margin was applied. Fixed an issue where objects were not sliced when opening a URL that had a comment + section box. Fixed an issue where the object with a comment attached would not select when opening it directly from a comment URL in FE2

* Fixed WBX-132
2024-02-14 20:33:15 +02:00
Alexandru Popovici 26b37c7fb3 Viewer API 2.0 (#1879)
* Implemented selection by using the new extentions paradigm. Seems to be working fine, and it's more straightforward

* Implemented the camera controller core extension. Still WIP but it's working

* Fixed some issues in the progressive pipeline triggering caused by removing all camera controls from the renderer

* Renamed ICameraController to ICameraProvider. Simplified a bit the camera controller extension

* Implemented the concept of Providers and simple dependancy injection for extensions which need functionality defined inside other extensions.

* Added events to the ICameraProvider which replace the old camera events delegate. SectionTool is now an extension which replaces the old section box. Still WIP

* Input now emits input related events which can be used by extensions, core or clients directly. SectionTool extension is mostly working,including all it's gizmos and default behaviours. What's left is the interaction with core regarding clipping planes updates

* Removed legacy sources and code

* Finished with the section tool extension. Finished with the section tool outlines built as another extension which requires the section tool extension as a provider

* Added optional forge style mouse hover effect on objects. Included it in the selection extension

* Ignore null draw range id when removing

* WIP on allowing more flexibility for material configuration in the core

* Added rendering stats collection for better profiling of the current draw group managements

* Shuffling IBOs for maximum draw call efficency now works correctly for our new draw group management approach. Also this process is now automatic and it happens when the draw group getsfragmented above a configurable point

* Fix some monstrous bugs with index buffer shuffling now that we've changed our approach a bit.~

* Finished with the new material management approach for mesh batches. SelectionExtension now uses this approach and also considers existing material opacities when setting select and hover materials

* Updated LineBatch to work with the new material management approach

* Implemented the required draw range related changes to the point batch

* Text batche now work with the new material management

* SpeckleLineMaterial and SpecklePointsMaterial are now SpeckleMaterial as well. Had to rename two properties of SpeckleMaterial due to some typescript named property clash thing, but nothing really changed

* Removed eslint-disable clauses in materials where they were no longer needed. Removed unused imports and overrides

* Added the RTE define for some materials by default. It can still be overriden if users want to

* Stencil outlines is now an toggle-able option for any SpeckleMaterial. Restricted to meshes

* Implemented setting desired material for all geometry types via RenderMaterial and DisplayStyle data. SpeckleRenderer now has three overloaded setMaterial function. One for a material instance, one for a filer material and one for RenderData&DisplayStyle. Moved material hash related functionality from NodeRendeView into Materials

* Added MaterialOptions which can be used when setting materials based on RenderMaterial/DisplayStyle to toggle various material features like stencilOutlines, pointSize. SelectionExtension now uses data material to set materials, and things are so much more simpler and nicer

* Added public method for setting seletion extension options

* After some profiling, realized three.js was doing a lot of pointless work each frame so now we're caching materials created from RenderMaterial/DisplayStyle to avoid this. Perf is nice and sharp now

* addRenderTreeAsync is now a generator. Handled automatic zooming on viewer loading. Disabled section tool by default

* Centralized RTE and shadow RTE buffer in an extended webglrenderer. This avoids re-computing rte data for each material over and over. Also, rte data is now centralized and available to materials

* SpeckleMeshes now use a cached material clone as their batch material like any other material they use

* Cleaned up Materils. Updated the debug show batches function use the new material manipulation system. So much easier now

* Real time measurement exist now as a separate extension. Existing functionality preserved, besides one or two small additions. Renamed the MEASUREMENTS object layer to OVERLAY for a more generic usage. SelectionExtension can now be enabled/disabled. Added an additional overload to the setCameraView method in ICameraController which takes a box3 as target to focus the camera on

* Removed viewer related events from input and replaced them everywhere with the proper input event types where required

* Fixed two issues with the shadowcatcher. One was a regression introduced after we centralized the RTE data. The other was a super old one one and was essentially causing the shadowcatcher to generate the contact shadows incorrectly because the correct transform textures were not bound (this is three.js being a pain)

* WIP on the filtering extension

* FilteringExtension is done. Kept the same implementation

* Added filter reset function

* Removed uniform texture and batch count binding from each material's OnBeforeRender function. Additionallit our material override function from SpeckleMesh now uses our fast copy instead of three's copy function for materials. This decreased CPU overhead each frame by 20+% and also eliminated the ugly call to SpeckleMesh's function for updating the material with the transform texture and batch object count from each material's render callback which was not supposed to be there

* Update RenderingStats to measure CPU render time per frame.

* Added early and late update functions for extensions. First gets called before the core's update, and the latter afterwards

* All speckle materials now use the centralized RTE data. Updated the fasts copy method to copy userdata defined uniforms where needed

* Added explosion extension. Additional cleanup

* Dirty transforms are marked on a per batch object basis, whenever their transforms gets changed. This automates the transform texture update execution, so we no longer need to manually mark entire batches as dirty

* Added getObjects which returns all batch objects in the scene and getObjects which takes an rv an returns only the batch object associated with that rv. Both of these methods are availale on the renderer

* Added setters for position, rotiation and scale in batch object

* Diff extension is complete. We stuck with creating material instances and using those for coloring since it ensures maximum draw call efficiency. Fixed an issue in MeshBatch where transparent draw groups were not always sorted at the end of the group list leading to incorect opauque object selection during the depth pass

* RV batch materials are obtained via the viewer-core API based on the RV itslef. This removed the need to get all batch materials for the differ

* Small cleanup

* Removed all circular dependencies besides one, like I predicted. The final one will dissapaear on it's own in the near future when we'll gracefull make DataTree obsolete. As a note, the circular dependencies were very shallow, reffering to enums/interfaces/statics declared in specific files. There was no real circular dependency on a class level

* Removed last circular dependency just for the sake of completion

* SpeckleRendere now has a clipping volume which is used internally to reject picks outside of it, and it's also exposed to the outside world to be used however

* Implemented the SpeckleLoader along with it's abstract supertype. Data loading is now done through this loader which handles tree population with raw data as well as render view data.

* Working minimal obj loader

* Added total node counting and displaying

* Viewer's load object now takes a loader of any speckle loader base class and uses that to load, instead of taking urls and tokens. This allows for any kind of loader to work with the vieweer's load function. Moved indexing of obj geometry to the obj geometry convertor. Loaders now take the target world tree instance instead of a viewer instance

* Loaders can now load from string and array buffer data where implemented. ObjLoader can now load from a string payload. Sandbox can now load obj files from the UI using a file picker

* alex/API2.0-core

* Started on #1673. Fixed an issue with walkAsync where the recursive generator would waste too much time idle.

* Solution for #1673. Replaced the old async pausing approach with a better version that has true variable wait time, and does not add additional dead wait time. Render tree building is now several times faster

* Cut down some more on load time by using a lookup table for determined speckle types. For a very large number of objects, getting the actual speckle type was quite slow. For our reference stream with 1kk objects we cut down around 2 seconds of load time

* BoxFromObjects now returns the correctly transformed aabb

* Implemented optimisations for batch building step from the loading process. Reduced the step's time by around 50%

* Implemented a NodeMap which allows us to search for nodes very very fast.

* Added a dynamic pause in the loader which stops the converter from blocking. Paramater object types are not added as nodes anymore. Callback from converter is not without arguments

* Replaced some internal walks with the newer and much faster id finding approach

* Disable object shallow cloning acrss the speckle converter

* Fixed the issues with block instances and revit instances caused by not duplicating speckle objects in the converter

* getObjectPropertis is now async and slightly improved the execution time of the flatten function which it uses

* Set caching to true by default

* Fix for display style hashing

* Implemented legacy viewer as a wrapper around the old viewer API

* Started testing FE1 with API 2.0. Fixed some legacy issues. Also the camera controller extension now exposes it's underlying controls object for the sake of not messing around with unwatend changes in FE1

* Updated FE1 with API2.0 selection changes

* Fixing selection bugs

* The viewer now ignores duplicate id nodes

* Fixes to object properties population, camera zooming and adding subtrees in core

* Fixed some filtering issues. Added UpdateFlags to the viewer's requestRender function

* Fixed an issue where section boxes were incorrectly added to the URL

* Objects with no id are not given nodes into the tree

* Updates to FE2 for API2.0. Also fixed a really really obscure bug in viewer-core where a material an incorrect material was set when reseting the batch to the default material

* We now store separate node maps for each model loaded. Each node now holds it's subtree id (as a small number for memory considerations)

* Render request after updating the visual diff

* Fixed some missing update calls on shadows

* Reverted FE1 changes and pinned the viewer library to a specific (latest) version pre-API2.0

* We're adding a viewer node for loaded models as subtree parent. This is because we're no longer spoofing ids and the model parent id needs to be preserved

* Fixed an issue where clicking on a comment bubble made the pipeline use accumulation improperly, leading to dark blight

* Null check for setMaterial. Fixed another case of dark blight. Hack required by frontend

* Fixed the issue with filtering state not propagating in the FE

* Updated selection event changes

* Fixed an issue where an undefined subtree id would yield an incorrect render tree upon requesting it

* Fixed an issue where undefined nodes were returned as valid when searching of ids

* NodeRenderView now holds it's subtree id along the speckle id. This allows for precise node matching when looking for specific nodes

* Fixed an issue with BlockInstances not instancing underlying meshes from breps

* Some fixes to diffing. Some older than API2.0, some new. Render views now have guid composed of their id and subtreeid.

* Update node render view id with guid where needed

* Unload function now checks for requested resource to unload before trying to unload it

* Check for the existence of a batch before applying draw ranges. Inthe FE, extension can temporarily keep dead rvs in their state when switching between streams leading to errors

* Fixed an issue for filtering where subtree roots would cause incorrect rv additions to the ghosted rv lists

* Unified block instance and revit instance conversion implementation

* Separted instanced from non-instanced rvs. Working on InstancedMeshBatch

* WIP on instanced types

* Implemented visual for box draging

* BoxSelection extension beautified and documented along with some small but welcomed changes to the viewer-core

* Viewer's getExtension now looks in the prototype chain before returning an undefined extension

* Added the extended Selection extension here for possible later use

* First iteration on instancing. General idea works. Still WIP on several fronts

* Fixed issues related to incorrect transform being calculated for instanced geometry. Fixed an issue with incorrect bounds being calculated

* Fixed a few issues with instanced vs non instanced render view gathering

* Disabled box selection extension

* Fixed some linter errors

* Disabled a lint 'error'

* Fixed issues with depth rendering and instanced objects and fixed draw range visibility for instanced batches in a minimalistic way

* Updated the measurements extension with the visiblity option

* Restructed a bit our implementation for the acceleration structure because now the BLAS needs to aggregate an instance of three-mesh-bvh not extend it. So that instanced batch objects can share a single bvh instance -> no redundancy

* WIP

* Revert "WIP"

This reverts commit 20d4bbf6210b0d37b956cc5b41fdb06f29845b4f.

* More WIP on trying to make instanced geometry TAS and BAS work properly

* Both Tas and Bas intersection testing seem to working fine. Now we need to implemented draw grouping for instanced mesh batches

* Added draw group management to InstancedMeshBatch. It works in the same manner as for non instanced batches, but the offset value refers to instances not triangles. I believe it could be simplified, but I'd like to get it up and working first

* Draw groups need to hold the index and count from the instanced buffer attribute

* Added array shuffling to the instanced mesh batch using the same approach we used for the non instanced one.

* Instanced batches now dynamically add InstancedMesh objects based on draw groups and a computed transform buffer

* Applying draw range updates for instanced batches now works. Still some issues to handle. It aint much, but it's honest work

* Disabled some more RTE until setting visibility for draw ranges is finished

* Moved getting opaque, transparent and stencil draw ranges out from Batcher and on to a per-batch basis. Now instanced batches correctly apply draw ranges and get their opaque, transparent and stecil ranges

* Fixed an issue with setting the visibility ranges for instanced mesh batches

* Instanced attributes for instanced meshes now no longer allocate

* Shadow depth material for instances is now set in the speckle renderer

* R-enabled RTE globally. Made instancing work with RTE. Made instancing work with both RTE and shadowmapping.

* Fixed an issue with materials building up in the mesh batch's cache incorrectly

* Implemented gradient indexs attributes for instanced batches. Thismeans, any color ramp based material like the ones we use for filtering now works

* Changed the way compound ids are created for instances, so that less memory is required. i.e chrome is not crashing anymore on particular streams

* Implemented reseting the draw ranges for instanced mesh batches. We no longer double buffer the gradient index buffer. We just create a new one when shuffling, populate it, then copy it over at the end. We're still double buffering the transforms buffer since that one is larger and we might not want to allocate it each time we shuffle

* Removed references of draw groups with ids since we're not doing that anymore. Fixed an issue with mesh batches where the material cache would keep piling materials incorrectly

* Several issues with selective transformations on instanced batches fixed.

* Added default null materials for instanced meshes both with and without vertex colors

* Got rid of the patched InstancedMesh because it was ridiculously slow. Instead we're now computing the scene box using our acceleration structures where available and three.s boundingbox where not available

* Minor, yet big regression fix

* Fixed regression

* Exported some extra types

* WIP on instanced balancing

* Instanced objects under a certain threshold now get batched together as regular mesh batches

* Forgot to update the rvs aabb

* Unified instanced and non instanced batch creation. Instances which do not qualify for instanced batching anre now mixed together with the rest of the non instanced batched objects

* Added some timing information to instanced batches

* Fixed an issue with zooming in on objects not working in the selection extension. Fixed an issue with object picking failing due to fp precision for objects right at the edge of the clipping volume.

* Removed logs

* Update stream moving via UI

* Removed the priority argument from loadObject since it's not needed anymore

* Updated LegacyViewer

* Fixed an issue with API 2.0 where the legacy form of transforms with only an array of values as the matrix would not work

* Updated FE1 viewer package to latest before API 2.0

* Disabled selection when measurement mode is on

* Updated ibl params updating

* Fixed an issue with measurement text not showing up

* Logs

* lockfile
2024-01-10 12:50:15 +02:00
Kristaps Fabians Geikins 8f0af9efbd fix(viewer): fixed three.js imports to hopefully fix fe2 (#1660)
* fix(viewer): fixed three.js imports to hopefully fix fe2

* undoing viewer changes that break preview service
2023-06-28 16:04:29 +03:00
Alexandru Popovici 5844280e35 Alex/measurements (#1639)
* WIP on measurements. Got some basic functionalities going

* New update for measurements. We're no showing multiple lines towards the measurement endpoint for better reference. Added dotted lines. Added text. Added measurement end and start points. Added the possibility to add multiple measurements.

* When double clicking, Input will not ignore the second click and will not send a click event. It will send the first click event, then a double click event. Implemented auto perpendicular measurement by using double click

* Added the option to have fixed sized measurement gizmos. As in, the are the same size regardless of the camera zoom. Implemented gizmo styles which lets us control and change at runtime the way the gizmos look. Currently they're only programatic, but I'll add controls for them in the sandbox next

* Implemented measurement management. Added picking, cancelling, removing and highlighting of measurements. Measurements are all now on their special ObjectLayer

* Added frame lock, so mouse events do not trigger intersection tests more than once per frame for the measurements. Added opacity options in the measurement gizmos. Made the end gizmo line transparent by default. Added preprocessor macro in the line shader which enables opacity as a uniform as opposed to attribute only like we had it before

* Point is now fixed size when style imposes it

* WIP on text aligning with the line. Still needs some things to be clarified since it can get complicated. Fixed some color issues. Added a maximum constraint to the screen space gizmo sizes. It's empirical, but seems to be workign decently for the all the various stream sizes I've trid

* Measurement gizmo now flashes red a few times if requrested to auto-lazer and no intersection was found

* Added unit conversion to measurment text, unit display and precision

* Implemented proper billboarding (fixed size and non fixed size) in the text and basic vertex programs as well as support for them in the text and basic speckle materials. Overhauled how the measurements look based on the forge reference

* Split measurements by type and added an abstract superclass. Point to point measurement has it's own implementation now

* Implemented screen space snapping for point to point measurements. Text background now gets dyanamically resized when needed

* End point gizmo is now only shown when required

* Added clamp guard to acos since dot can return outside of [-1,1] due to fp precision issues. Fixed an issue where existing measurements could be selected in the process of creating another measurement

* Added function for adding measurements programatically. Currently only start and end point make sense as measuremetn data

* Added an 100nm offset from the original point along the surface normal for auto-lazer function because sometimes it would intersect itself and report incorrect length

* Separated all measurement related rendering into a separate 'Overlay' pass. We now have better control over the rendering order of the individal elements of the measurement gizmos. This fixed the issue of having the measurement line overlap the end points

* Billboarded shaders now also work correctly with section planes

* Measurement tool no longer considers surfaces clipped by the section box

* Implemented correct raycasting for billboarded and fixed sized bibboarded objects, like the measurement's text

* Implemented zooming in to measurements when double clicking

* Big update to measurements which addresses most if not all requirements regarding UX/UI, API, and generaly functionalities. Additionally, a fix or an ancient issue in Units where kilometers were incorrectly calculated, and added automatically resolution updates to the SpeckleLineMaterial

* Added dpr factor into billboard size calculations. Fixed an issue with the round rect geometry generation function which would fail on macos. Added the billboard text background size into the text's style so it's configurable

* Text can now be updated for perpendicular measurements also when in it's complete state

* Fixed an exception which was thorwn when double clicking on another measurement while measuring

* When changing the measurement type while the measurement is still in it's dangling start state, the measurement gets cancelled and a new one with the new type gets started. If the measurement is in it's dangling end state, then it does not. This is now forge viewer does it

* Implemented screen space surface normal indicator line

* Measurements now work on visible and non-ghosted objects. Removed the surface normal indicator from the point to point measurement

* Fixed an issue with orthogrtaphic camera and NDC normal computation. Implemented fixed sized gizmo disc for orthographic camera

* Fixed an issue where the pipeline would not get properly reset after zooming in orthographic mode

* Fixed some regressions with the pre-existing application measurements functionalit and text. Fixed an issue where auto-lazer measurements were not vertically centered.
2023-06-27 15:13:39 +03:00
Alexandru Popovici a52bb75414 Fixed the issues in #1611. There is still an issue left, where zooming in in orthographic mode, then switching to perspective does not yield the correct camera distance, especially when the controls target is off model (#1616) 2023-06-16 15:55:27 +03:00
Dimitrie Stefanescu 7b037352df Dim/fe2/view changes (#1608)
* Fixed an issue with curves doubling up on geometry and also not being selectable after the last filtering changes. Added the options to make lines transparent. Added lines to diffing

* Points now are diff-able and support proper visual diff-ing. Visual diff filters are now chosen internally by the Differ. Fixed an issue with LineBatch and transparency

* Implemented PLAIN visual diff mode, where all objects keep their original materil, but opacity is manipulated via the diff time. Added API member function to switch between the PLAIN and COLORED visual diff modes

* feat(fe2): diffs wip

* Diffing fixes for instances and blocks. Things seem to be working fine, but there are some caveats. Additionally, some older issues were fixed and diffing now works better on all the rest of the streams

* feat(fe2): de-dupes diff results

* feat(fe2): wip diffs

* feat(fe2): diff transparency goes from 0 to 1

* feat(fe2): diff results display work

* feat(fe2): diff results display work

* feat(fe2): diff panel work

* feat(fe2): diff work: various display changes, coloring toggle, selection logic, selection object display wip

* feat(fe2): diff work: cleaned up old/new version, fixed minor bug in viewer diff time when swapping color mode

* feat(fe2): diff work: implements custom selection logic and selection display for modified objects (they come in pairs now)

* feat(fe2): diff minor fix in selected object display

* feat(fe2): wip; trying to fix diff order to be consistent (ordered by date)

* feat(fe2): wip, broken state right now

* feat(fe2): fixes scrollbars in viewer

* feat(fe2): fixes slider sync with diff time

* feat(fe2): WIP syncs of diffs (threads, refreshes, etc.)

* feat(fe2): diffing polish

* speckle shared fix

* speckle shared fix

* more bugfixes

* linter fixess

* more CI fixes

* fix viewerState serialization

* more linting fixess

* template fixes

* moving tailwind classes to theme package

* migrated away from diffString + simplified postSetup

* moved diff new/old version resolution to use state.resources

* cleanup

* updating url threadId & diff command correctly

* minor improvements to diff state

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2023-06-08 11:26:19 +03:00
AlexandruPopovici fe1a9f2eb3 Updated the older synchronous object loading function 2023-06-06 20:29:26 +03:00
AlexandruPopovici 0b7887767a Updated how the viewer emits the Busy signal so it reflects it's activity better 2023-05-22 18:03:47 +03:00
Alexandru Popovici 1668cf6a65 Alex/diffing part 2 (#1579)
* Fixed an issue with curves doubling up on geometry and also not being selectable after the last filtering changes. Added the options to make lines transparent. Added lines to diffing

* Points now are diff-able and support proper visual diff-ing. Visual diff filters are now chosen internally by the Differ. Fixed an issue with LineBatch and transparency

* Implemented PLAIN visual diff mode, where all objects keep their original materil, but opacity is manipulated via the diff time. Added API member function to switch between the PLAIN and COLORED visual diff modes

* Diffing fixes for instances and blocks. Things seem to be working fine, but there are some caveats. Additionally, some older issues were fixed and diffing now works better on all the rest of the streams

* Fixed the diffing issues with revit instances and hosted elements and nesting, etc. SetUserMaterial now accepts an optional list of rvs to apply the filter to, instead of figuring out the rvs itself.
2023-05-19 16:41:26 +03:00
Alexandru Popovici 294f2a101d Instance/Block Selection Fixes (#1572)
* Fixed conflicts

* Fixed the issues with instances not isolating. Fixed the issue with not being able to zoom in on instances
2023-05-11 11:34:37 +03:00
Kristaps Fabians Geikins b02a07e2b6 feat: Frontend 2.0 MVP 2023-05-08 10:47:01 +03:00
AlexandruPopovici 14d7e46c55 Added automatic explode range calculation. Fixed an issue where meshes with no faces were making the viewer throw errors. They are now properly ignored. Fixed an issue where the TAS was not computing the total bounds correctly after creation, leading to incorrect world sizes 2023-05-02 15:11:24 +03:00
Alexandru Popovici 7ea5e35761 Diffing (#1543)
* WIP on naive diffing

* WIP on animating modified objects after diff

* Some more work on this

* Default building

* Removed and added now get opacity transitions as well

* Updated starting model

* Implemented two 'subpasses' in side the color pass, where opaque and transparent draw groups are rendered individually. Disabled double side depth rendering when visual diffing, to avoid AO generated by backfaces, visible through transparent diffed objects. Removed previous hacks

* Finished with cleaning up diff-ing related viewer functionality.

* Implemented UserMaterialState into filtering manager, as a 'sticky' filter which always gets applied before any other filters, until removed. Visual diff-ing and undiff-ing now go through the filtering manager so other filters can be stacked on top of it

* diff API function now checks to see if the diffing streams exist, if not, it loads them, computes the diff and applies the visual diff all in one call. Added undiff in the API which removes all the diff related sticky filters. Added setDiffTime in the API. DiffResult now holds modifiedOld and modifiedNew speckle objects in the same member as 2 item sequential arrays

* There was an unreported git conflict in one of the shaders. Fixed that
2023-04-21 15:41:26 +03:00
Alexandru Popovici 4aef572a44 Multi Viewer (#1518)
* Fixed an issue with HDRIs not generating proper PMREMs over multiple viewer instances

* WIP on makign the world tree multiple instanced

* The WorldTree is no longer static. Each viewer has it's own instance and it hands it over to whoever needs it.

* Fixed an issue with filtering and the new non-static tree. Also removed the 'root' key from the NodeData structure since it's not needed

* Added an guard when building batches for situations where all render views have invalid geometries. This generally means there is somethign wrong with the stream itself

* multi-viewer css fixes

---------

Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
2023-04-21 13:12:15 +03:00
Alexandru Popovici 90439d7d41 Alex/#1447 advanced batching (#1488)
* #1051 Implemented batch splitting based on a configurable mximum batch vertex count and configurable maximum batch object count. We're not splitting single objects though since that's not required right now and will do it when the need arrives

* Implemented dynamic batch object transformation using all available vertex uniforms.

* Fixed batch object index buffer size

* Added debug per object movement for debugging

* WIP on texture based object transform

* Finally fixed a bug which was making three.js use the same shader for multiple batches, and thus messing up individual obects transforms

* Integrated shadows, AO, depth, and selection material with the recent batching changes.

* Implemented per object BVH building and correct intersection testing when each object has its own transformation

* Implemented BatchObject which holds the single source of truth for individual transformations, it's BVH and some other WIP things

* Restructed how object level and batch level BVHs are constructed and used. Also added a bounds check for intersecting the batch level BVH (which is not really a bvh, just a flat list of small bvhs)

* Shapecasting now provides the intersected BatchObject inside the callbacks, so required data could be fetched from it. SectionOutlines now work correctly

* Fixed some issues regarding the shadowcatcher and the colored and ghost material uniform updates

* Fixed an issue with colored material and shadows. Restructed how speckle materials are defined and extended. This removes duplicate code as well as duplicate functionality. Implemented fro the standard material, still need to do it for the basic material

* Removed unused material and shaders

* Custom material defintion and extension MK2

* Improved the RTE and TRANSFORM_STORAGE shader blocks for minimal redundancy. Updated all shaders. Updated all materials to MK2. Still need to find a way to avoid some boilerplate code in the base materials

* Fixed an issue where three was incorrectly frustum culling objects

* Fixed the issue where depth material programs were getting ignored for batches with same object count, leading to incorrect depth

* Removed the need to have a preprocessor define for 0BJ_COUNT inside the batched shaders. This eliminates the extra startup time taken by all the program compiles. In order to do it, I had to drop using the scene override material in the depth pass. Instead we're applying the override material before the pass render on each objecti individually

* Added a generic method for overriding the batch's material, which can be used by any pass. Added a material cache for each batch so that we don't need to clone materials more than we need to. Fixed an issue in the depth mateial clone function which made three not update our uniforms (this happens so often I'm getting sick of it). Filters now use cached material so they work correctly

* Fixed a dreaded three.js bug where it would sporadically not update our custom uniforms for reasons unknown

* Finally managed to get mixins working for out material system. With this, we avoid needing to write duplicate boilerplate code for all speckle base material types. Only applied it to SpeckleStandardMaterial because I want to test more before I adopt it globally. Implemented our custom material overriding approach to the stencil and stencil mask passes.

* A lot of dead brain cells. Transforms and RTE and BVH and all them things work correctly, with the exception of transforming around a point very far from origin. That will cause jitter because we end up multiplying large floats

* Managed to get RTE working properly with individual object transforms, transforms around random pivot. Fixed an issue caused by the fact that three-mesh-bvh messes up the bounding box of objects very far away from origin. Worked around it. WIP on cleaning things up

* Solution for object transforms in a real RTE context (far from origin). First pass on cleanup. Solution will be applied to the rest of the shaders in the next commit

* Updated WebGL 1.0 transform texture sampling and matrix array transform fallback

* Updated all shaders with object transforms RTE solution

* Updated remaining materials to the new mixin'ed approach implemented a little while ago. This removes a ton of boilerplate repeated code

* Update the normals pass. Simplified and removed reduandant batch update ranges from the before/after pass callbacks

* Reorganized BatchObject so we're not wastefull with matrix and vector instantiations

* Added explode function in the viewer API

* Enabled cleaning of redundant geometry

* Some html crap

* Fixed an issue with filtering out invalid render views. Removed the red sphere of doom (forgot it in). Fixed an older issue (not related to this branch) where instance points were deleted while still being shared by other lines, yielding invalid lines

* Fixed ShowBatches

* Fixed some sandbox related issues and improved qol
2023-04-20 15:44:31 +03:00
Alexandru Popovici 6b7dbc5d70 Reduced Viewer Memory Footprint (#1406)
* The ObjectLoader and ViewerObjectsLoaders are disposed upon loading complete.

* Added viewer parameter for keeping or discarding original geometry data. Defaults to discarding it. WIP on mesh and point cloud implementation for actual discarding it

* Geometry data from raw nodes is now disposed after building their reder views

* Removed raw geometry data from points and lines

* Removed the float64 array which was persisted pointlessly by the section plane outlines feature. Also fixed a bug for this feature regarding resizing the point buffer and RTE

* Implemented BVHs in local space, relative to world origin. This cuts down on it's redundant memory footprint by half

* Implemented SpeckleMeshBVH which completely hides the RTE-related transformations that we're making to reduce memory footprint.

* Added some clarifications to the SpeckleMeshBVH class
2023-02-28 13:07:33 +02:00
Alexandru Popovici 1c78607942 Alex/#1347 Async Loading and Load cancelling (#1367)
* Implemented async walk for the world tree. Implemented asyn render tree building and async batch building. Implemented progressive loading

* WIP tree walk async that actually works using a generator

* Async walking now properly works and can be interrupted

* Properly working async walk

* Added loadObjectAsync function in the API which should be used if stream loading needs to be cancelled and for 'progressive' loading. Added a priority argument to the loadObjectAsync and to walkAsync functions which makes the async-iness so to speak configurable.

* Refactored the sync and async subtree batch building to remove duplicate code. Changed some logs for better clarity

* Fixed an issue with point clouds and material creation
2023-02-17 13:45:22 +02:00
Alexandru Popovici c6694c2511 query now returns the proper query result type. Added return type to the Utils functions (#1342) 2023-01-26 14:15:24 +02:00
Alexandru Popovici 071e6382ca Queries update (#1341)
* Separated Point queries from Intersection queries. Defined query result types for both

* Updated exports

* Update Utils

* Updated frontend after the queries updates

* Allowed the objects field in the IntersectionQueryResult to be null
2023-01-26 12:12:09 +02:00
Alexandru Popovici 96b3a4923b Viewer queries (#1331)
* Added the concept of queries with a minimalistic implementation. Implemented PointQuerySolver which handles occlusion, projection and unprojection of points

* Added and tested the 'Pick' PointQuery operations which works just like an onclick viewer event

* Small fixes and changes to query and point query.

* Better approach on the occlusion query solving by using our universal scene intersection routine

* Tested and fixed occlusion testing for points

* Added optional custom width and height to NDC<->Screen helper functions

* Integrated queries in the frontend. Projection queries replace projecting by hand, and also added occlusion queries as a demonstration

* Added refactor comment
2023-01-20 18:59:01 +02:00
Alexandru Popovici de2bce89a5 Alex/verbosity and mouse event (#1275)
* Added a verbose flag in the viewer params. Default is false and it's equivalent to the ERROR level

* Piggybacked the original pointer event into the SelectionEvent
2023-01-02 16:23:52 +02:00
AlexandruPopovici d345b2a2d6 Fixed an issue where the accumulation cycle would not start after toggling orthographic mode due to a dangling flag. Fixed an issue where accumulation would sometimes not start after viewer load 2022-12-02 00:02:25 +02:00
AlexandruPopovici ef7f4b550a Fixed the commnet bubbles issues with orthographic projection, so we can bring it back in the frontend. Also fixed some issues with camera zooming in orthographic mode and the rendering pipeline, and the zoom in animation 2022-11-30 17:03:29 +02:00
AlexandruPopovici 6a0b78357e Implemented multi section plane outline generation 2022-11-25 12:42:02 +02:00
AlexandruPopovici fa828cf427 Integrating section box variable thikness outlines in the viewer 2022-11-22 16:46:32 +02:00
Dimitrie Stefanescu 5b98fdc574 feat(viewer): drives iteration so we only traverse the world tree once, rather than n times 2022-11-15 11:30:52 +00:00
Alexandru Popovici 9abeb2645b New progressive rending pipeline. Progressive ambient occlusion (#1156)
* Started working on progressive sao

* Started working on the ao generation stage shader and pass

* Continued with progressive SAO. Added the accumulation pass

* Implemented progressive AO using the same estimator as for the dynamic one.

* First draft of progressive AO with multiple selectable estimators. WIP on final implementation

* Restructuring how the pipeline and it's passes work so we can extend/configure them more easily. Added the concept of SpecklePass

* A lot of changes. Pipeline rework is more or less complete. Added individual output for some pipeline passes that we might want to inspect inside the sandbox.

* Finished with displaying individual pipeline stages

* Intruduced accumulation frames properly at pipeline level. Cleaned up progressive AO shader and pass. Exposed the number of accumulation frames as well as the kernel size in the sandbox.

* Accumulation frame count is now reset after a resize

* In the end I just implemented my own stationary/dynamic detection routine since the events sent from the 'camera controller' are dogshit

* Implemented interpolating during frame accumulation between the dynamic SAO and the static AO. This makes the transition much more smooth and seamless than simply jumping straight to the static AO which begins accumulating from 0

* Added configurable intensity to static AO. Fixed an issue with static scenario detection where the accumulation frames were ran twice in succession, because the 'camera controller' is probably clamping the angles to X decimal points at the end of a camera motion cycle, which in turn triggers a camera move larger than our defined epsilon

* Dynamic AO at half res

* Some improvements to how we update the rendering pipeline and it's dynamic and progressive states

* Trying to fix the issue with artifacts on progressive AO on mac. seems to be depth encoding related. Changed the depth pass to render to 32 float texture to check if the artifacts are gone

* Trying out a new float->RGBA encoding and decoding

* Added ner and far camera planes controls to see how they're values change depth encoding precision

* Finally managed to get AO properly working with encoded linear depth

* Trying 24 bit encoding

* Fix for the macOS artifacts using linear depth buffer and a bias value

* Extended the camera controller class and added/changed a few things so that the controller doesn't mess up our camera movement and also we now rely on the events sent by it to determine stationary vs dynamic camera scenarios. This way we spare the rendered from having to determine camera movement deltas by itslef(only to have it ruined by the camera controller anyway)

* Added switching between perspective and linear depth when going from dynamic AO to progressive AO, so we don't have to integrate linear depth buffer sampling in the already existing features

* Disabled normal texture rendering for dynamic AO

* Some fixes and added dynamic AO back in at half res

* Fixed an issue with converging progressive pipeline when using a trackpad

* Implemented relative dynamic progressive AO kernel size

* Fixed compile error

* Fixed an issue with macOS and depth texture filtering

* Added half res depth buffer switching for dynamic AO

* Changed some params now that dynamic AO is at half res

* Made section boxes work properly with our new progressive pipeline

* Added correct kernel size computation for orthographic projection

* Patched the camera controls to send events when zooming in orthographic mode

* Some more integrations with camera views and fixed a bug with bad pipeline resets

* Small fix for zoom and startup reset

* Various fixes of issues I could find

* Removed longs

* preview-service now waits for the pipeline to convgerge before taking the screenshot

* Handled #1110. Added the concept of 'ObjectLayers' which uses three's existing implementation for selective layer rendering/lighting/picking. Also added the BaseSpecklePass abstract class which provides a default implementation for any subclassing pass that needs to use specific layers when rendering.

* Added more time between frames for the preview service. It seems to be generating the previews properly now

Co-authored-by: Alex <alex@192-168-0-159.rdsnet.ro>
Co-authored-by: Alex <alexandru.popovici@busymachines.com>
2022-11-01 16:30:36 +02:00
AlexandruPopovici 5d02fb2423 Fix for frontend which starts off the viewer with 0 width and heiht. This makes the framebuffers incomplete and errors are thrown. We now render to framebuffers only after we have a valid rendering size 2022-09-27 10:36:59 +03:00
AlexandruPopovici 0bd362e1ef #1014 SAO WIP 2022-09-22 16:43:24 +03:00
AlexandruPopovici c7c98a2e24 #1014 Started working on SAO 2022-09-21 18:50:20 +03:00
Dimitrie Stefanescu 227b847dee feat(filtering): allows for "highlighting" objects using a ghosted material (useful for highlighting hidden objects) 2022-09-02 09:54:42 +03:00
Dimitrie Stefanescu 9a6bedc528 feat(viewer): adds default ghosting params for filtering ops 2022-09-01 20:51:03 +03:00
Dimitrie Stefanescu 82b4a56fac feat(viewer/frontend): viewer real time user bubbles section box & filtering alignment 2022-08-31 12:58:58 +03:00
Dimitrie Stefanescu 3317f4b922 feat(viewer/frontend): section box controls fe 2022-08-31 10:37:17 +03:00
Dimitrie Stefanescu 27c9834d02 Merge branch 'dim/viewer-redux' into viewer-redux-integration 2022-08-30 19:38:56 +03:00
Dimitrie Stefanescu c3381ae44d feat(viewer/frontend): fixes various edge cases on numeric filters and filter props caching 2022-08-30 19:33:39 +03:00
AlexandruPopovici 1d38cd6db2 Small changes and fixes 2022-08-29 18:33:22 +03:00
AlexandruPopovici 2e0cb521f8 Removed internal handling of zoom-on-double click. Double clicking now just emits the double click event along with the selection info. Added simple implementation for sandbox and frontend 2022-08-29 11:52:08 +03:00