Commit Graph

97 Commits

Author SHA1 Message Date
Iain Sproat 0d739416cf chore(deps): bump various dependencies with documented vulnerabilities (#5680) 2025-10-06 17:02:34 +01:00
Iain Sproat b828daf5d2 chore(deps): revert bumps to dependencies (#5676) 2025-10-06 15:04:46 +01:00
Iain Sproat 872d28cc12 chore(deps): bump rollup to ^2.79.2 (#5652) 2025-10-06 11:16:26 +01:00
Alexandru Popovici f3974dd9d0 Alex/text updates (#5012)
* feat(viewer-lib): Text updates:
- Update to latest troika-three-text version
- Started working on the new TextBatch whoich will actually batch texts
- Augmented BatchedText type from troika
- Renamed old SpeckleText to TextLabel

* feat)viewer-lib): Copied over the batched version for the speckle text into our text material since troika won't export it

* feat(viewer-lib): First draft on text batching

* feat(viewer-lib): WIP on TextBatch and SpeckleText

* feat(viewer-lib): SpeckleText batch now has working TAS and BAS. Overloaded getBatches to also take an array of geometry types and added GeometryType.TEXT in places where required alongisde MESH

* feat(viewer-lib): Text batch has correctly transformed texts

* feat(viewer-lib): Patched troika BatchedText to allow per text opacity. Draw ranges for text batches are now functional

* feat(viewer-lib): Fixed an issue with the BAS not correctly reporting bounds. Had to override two methods completely in our SpeckleText extension of the BatchedText just so that we don't do stupid things and still get good performance when dealing with a huge number of texts

* feat(viewer-lib): Added text batch object count limit. Default is 5k. Implemented proper material caching and cloning inside SpeckleText. Overriden the default updateBounds function so that we don't waste tens of millisecons per frame!!! pointlessly

* feat(viewer-lib): Implemented TextBatchObject along with individual text batch object transform manipulation at batch level.

* chore(viewer-lib): Updated the pipelines to not render text geometries twice

* feat(viewer-lib): Implemented RTE for batched text rendering. As with the rest of the geometry types, RTE is automaic and will only be used when needed

* feat(viewer-lib): Integrated remaining text v3 features: alignments and maxWidth

* feat(viwer-lib): Implemented billboarding and RTE billboarding for text.

* feat(viewer-lib): Text batches now report correct object materials and can be filtered properly

* fix(viewer-lib): Some Fixes:
- The need for text RTE is now correctly being computed on the right text dimensions
- Sequential update ranges now correctly apply materials to all of them

* fix(viewer-lib): RTE text box is now correctly transformed. The text batch object only uses the TAS for intersecting since it's BAS is redundant.

* feat(viewer-lib): Text batches now correctly use gradient/ramp textures along with sample indices for colored filtering.

* feat(viewer-lib): Implemented raycasting for billboarded text batches in the most simple and robust way I was capable of. Lacks TAS speedup but it's a compromise we have to make and one which we probably will never regret

* feat(viewer-lib): Good progress on reworking TextLabel, which replaces the old multi purpose SpeckleText, which we use internally for measurements. More precise rendering, no more rogue margins between text and background. Regular billboarding now also works, along with non-billboarded rendering

* feat(viewer-lib): Finally a unified billboarding solution in SpeckleBasicMaterial. Supporting both world and screen billboarding; SpeckleTextMaterial now extends SpeckleBasicMaterial; TextLabel now has proper control over size and margins. No more weird offsets. Added background margins to the text params which work in both world and screen space.

* feat(viewer-lib): Implemented raycasting for all billboarding types. Spent quite some time on the screen billboarding one because of a stupid mistake

* chore(viewer-lib): Added (vibed) type declaration file for troika's Text class and fixed compiler errors for TextLabel

* chore(viewer-lib): Renamed SpeckleText to SpeckleBatchedText and fixed all compiler errors. Updated type definition file

* feat(viewer-lib): Integrated TextLabel with measurements. Simplified a lot of code

* fix(viewer-lib): Some updates and fixes to text and measurements integration
- Screen space billboarding now also takes an NDC offset alongside the size.
- Added auto margin calculation for TextLabel background so it's always centered regardless of anchor-ing
- DPR is automatically factored in for TextLabel
- Some changes to sizes and margins for measurements

* fix(viewer-lib): Bunch of fixes and tweaks

* fix(viewer-lib): Area measurement's area plane no longer overdraws on top of the area value text label via simple stenciling

* fix(viewer-lib): Fixed CI build

* fix(viewer-lib): Fixed CI build

* feat(viewer-lib): Slightly reduces the size and h margin of text gizmos for measurements

* fix(viewer-lib): Fixed incorrect text transformation when neither RTE nor billboarded

* chore(viewer-lib): Added review suggestions
2025-07-15 14:48:13 +03:00
Alexandru Popovici 0ef0a13979 Pro Measurement Tools (#4452)
* feat(viewer-lib): WIP on area measurement

* feat(viewer-lib): WIP on area measurement. Basics are working. Needs more bling

* feat(viewer-lib): Implemented polygon triangulation for measured area

* chore(shared): Updated MeasurementType

* Add Area control to measure panel

* feat(viewer-lib): Real time updates of the fill polygon and area value

* feat(viewer-lib): Added pole of innacessibility as area label anchor using the polylabel libraryh

* feat(viewer-lib): Fixed fill polygon material

* feat(viewer-lib): Changed the surface normal indicator from the faulty disc to a outlined rectangle. Looks and works much better now

* fix(viewer-lib): Measurements get clipped by sections planes

* faet(viewer-lib): Measurements can now optionally define their own snapping method. Area measurement snaps to first point in screen space. Generic vertex snap still applies if enabled

* fix(viewer-lib): Forgot to project the measured point

* feat(viewer-lib): Double click auto-finishes the area measurmenet by instantly joining with the first point. Right clikc removes current area measurement point so you can 'undo'

* fix(viewer-lib: Fixed a stupid bug relatedto text because somebody thought that making it 'async' would be sooooo cool...

* fix(frontend): Prevent zoom on double click when using area measurement

* chore(viewer-lib): Refined and fomralized a bit now that the general idea of a measurement has got more complex

* chore(viewer-lib): Moved state switching a bit

* chore(viewer-lib): Replaced the old disc normal indicator with the new one and made it standard. Added an option to the gizmo's style that determines the pixels size of the normal indicator

* chore(viewer-lib): Documented the area measurement tool

* chore(viewer-lib): Some updates:
- Implemented proper bounds getter for area measurement
- Got rid of the static vector buffers in Measurement and replaced them with consts where needed
- Reduced the min click timing from 250ms to 150ms
- Other small adjustments

* feat(viewer-lib): Added the option to chain measurements

* chore(frontend-2): Added toggle for measurement chaining

* chore(viewer-lib): Perpendicular measurement chaining now align on the same line as requested

* feat(viewer-lib): Implemented point (coordinate) measurement:
- Added support for billboard offseting in NDC in the shader via vec2 offset uniform. Not a dream come true, but required mostly because of how troika works
- SpeckleText background now follows text anchoring
- Implemented new POINT measurement type

* chore(viewer-lib): Separated label position calculation. We now update only the label transform each frame, instead of updating the entire label redunantly

* chore(viewer-lib): Offsets are now constants. Removed redundant vector and matrix creation

* chore(frontend-2): Placeholder radio button for point measurement type. Fixed compile errors

* fix(viewer-lib): Fixes WEB-3105. Export all measurement types

* updated icons

* Update description

---------

Co-authored-by: andrewwallacespeckle <andrew@speckle.systems>
Co-authored-by: Mike Tasset <mike.tasset@gmail.com>
2025-05-26 12:10:19 +03:00
Alexandru Popovici a385823b2d feat(viewer): objectloader2 integration (#4267)
* feat(viewer-sandbox): Made a sandbox function that will only invoke the object-loader loading objects

* first pass of creating an objectloader2

* updated build + added vitest

* try to get viewer sandbox to use new code

* sandbox type fix

* refactor a bit

* can download root

* intermediate commit for downloader/caching queue

* can download stuff!

* refactor files

* intro isBase and fix isString

* move single download to downloader

* fix download

* PR feedback

* some intermediate commit

* do clean up and download better

* clean up promises and linting

* can generate values while downloading and caching

* add a finish method

* remove unused functions

* remove asBase

* add temporary docs

* add more docs with mermaid

* add more test models

* add response validation

* add tests and redo options

* add test for download batch

* fix downloader tests and change Item to have clearer Base items

* add tests and refactor a little

* use fetch in downloader as an option

* use optional in-memory indexdb instead of monkey patching the global one

* more refactors for options for objectloader2

* add tests for objectloader2

* adjust single download

* benchmark loading and adjust ol2 batches

* download more!

* adjust to use hash privates

* refactored again with renaming

* cleanup

* make setupCacheDb throw instead

* use BatchedPool for downloads!

* fix tests

* adjust timings and add adaptive waiting

* Only wait if queue wasn't empty and queue size was full

* fix tests

* fix file names and some private usage

* fix interval and private usage

* rename vars

* use params for methods

* fix params for constructors and tests

* fix params for constructors and tests again

* using dexie

* faster settings but doesn't end well

* fixed end, optimized and removed logs

* fix tests

* fix types?

* update lock with WSL

* add e2e small model test

* fix/update yarn.lock

* Remove unused eslint ignore to fix pre-commit

* prettier fixes

* fix real DB usage

* rename methods to better match OL1

* rename methods to better match OL1 again

* add extra header collection

* add headers correctly

* test getTotalObjectCount

* feat(viewer-lib): Replaced old object loader with Adam's  objectloder2

* fix(viewer-lib): Removed the old object loader. Removed unneeded pause time in speckle loader

* Testing

* only deferred if not downloaded....don't save everything

* Lockfile

* pool isn't adjustable, adjust download buckets, dexie read is faster

* chore

* fix(viewer-lib): Fixed compiler errors

* fix getObject access with real indexeddb...adjust buffer for deferred access

* Fix disposal and pausing

* don't index item!

* fix dockerfiles to use OL2

* fix Dockerfile

* Fix dockerfile

* defer correctly and use record to add/lookup/remove to

* delete stuff correctly

* chore(sandbox): Enabled viewer loading

* use objects instead of arrays to avoid findIndex

* remove extra count

* add a found cache to avoid some db hits

* order matters for deferment

* move found map to deferment

* change option numbers

* 2 level cache with expiry

* defer everything, use loader to track what is requested....expire only found items

* add deferment disposal

* oops mismerge

* chore(sandbox): Default stream

* Beta version of CachePump and CacheReader

* Clean up initialization

* More clean up

* chore(objectloader2): Fixed CI compiler error

* chore(objectloader2): Fixed prettier

* add cachePump tests

* add cacheReader tests

* fixed more tests

* fixed final tests

* moving stuff around and lock return value

* try to move stuff out of objectloader2

* use a factory

* rename factory

* formatting

* eslist fixes

* try allocating no strings

* add comments

* small refactor and add another test

* fix deferment expiration and have test

* use byte size for max memory cache size

* fix deferment manager tests

* saved comment

* fix(viewer-sandbox): Fixed compiler error

* ignore tshy

* chore(frontend): Attempt to make viewer loading sequential

---------

Co-authored-by: Adam Hathcock <adam@hathcock.uk>
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2025-05-21 10:05:50 +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 f844b6d22e Viewer Navigation (#2416)
* Added model-viewer's orbit camera control implementation. All the features from the old orbit controls are now functional with the new one

* Figured out the relation between radius and fov. Added zoom decelariting when getting closer to origin. This feature was present in the old controller but lacking in this one

* WIP

* Added infinite zooming

* First version of infinite zoom and zoom to cursor

* A few improvements on zoom to cursor. Inifite zoom and zoom to cursor now work together. Simplified the implementation

* Added orthographic camera functionality in the controller without hte special features

* Zoom to cursor now works with orthographic projections. Switching between perspective and orthographic while keeping all functionality correct now works

* Minor cleanup a ton more to come

* Added controls dampening in the sandbox

* Adapted frontend to the new controller plus some additional changes to the controller options in general

* Implemented setting inline and polar viewers. However mosts of the time spent was dedicated into understanding why the frontend checks for changes in the camera each frame, and if it finds one forces the camera viewer to the inline one. I haven't figured out why it's doing this and it seems very wasteful. There probably is a better way of achieving the same thing

* Orbit Controller now computes it;s cartesian value based on spherical in a function so it can be used in multiple places. Replaced getting the current camera position with the target camera position in frontend frame update callback as the old camera controller did

* Follow mode now works properly

* Sandbox fix

* Disabled debug spheres

* WIP on fly controls

* Correct basis transformations for fly controls

* Added QE up/down movement to fly controls

* Minimum radius is now dynamic and accounts for scene size

* Fixed an issue with zooming to cursor when infinetely zooming

* Fixed inconsistencies between zooming normally and infinetely for both zooming to cursors and otherwise

* Further fixing zooming to cursor when infinetely zooming

* Zoom radius modulation

* Fine tuning zooming radius and wheel modulation. I think I got to some defaults that seem good enough for all scene scales.

* Defaulted to 30ms decau time for dampers

* Added a 'tasOnly' argument in all 'intersect' variants. This will only intersect the TAS(es) and provide an intersection result. When requesting an intersection with 'firstOnly' set, onyl the first intersected TAS will be queried further and it's first intersected BAS will provide the intersection result. Conditioned zooming to cursors by needing to have any geometry under the cursor; Fixed some small issues with  functions in the acceleration structures.

* Restricted intersecting onyl when zooming

* Geometry intersection when zooming does not affect infinetely zoom anymore, only zoom to cursor

* Temporary disabled firstHitOnly

* raycastFirst now works correctly in the context of tasOnly param true or false

* Added dampers to the fly controls so we have consistency across various camera controller types.

* Added statinary function

* WIP on controls

* Debuging orbit controller issues on ipad

* More consolidation work on the interface for SpeckleControl and our current implementations for it

* Added controller toggle-ing

* Making the controllers work from immediate data

* There are no more spaces left I can transform from/to. Done them all. Works fine now essentially. Just need to clean stuff up

* SpeckleControls now provide an 'up' vector, and basis transformation is computed that way rather than requirig a mat4 directly. Fixed two issues with event locking on orbit and fly

* More cleanup, more fixes, more grind

* Controllers now have consistency in the basis they provide the position and target into. As well as the fromPositionAndTarget function. It will always be in a basis where (0,1,0) is up. This is required because certain parts of three.js assume that basis

* FlyController is now properly relative-itiez

* Sorted out options for both controls. Dampening is now done via options

* Small fixes for frontend integration

* Fixed the issue with quaternions misaligning around PI

* Added consistent orthographic resizing

* Fixed camera focusing when in orthographic mode

* Implemented disabling/enabling rotations with the new controls. Removed PolarView since it was never used. Canonical views WIP

* Made the HybridCameraController with the simplest implementation possible that seamslessly combines both camera controls. This is for testing to get an idea about how it feels. Removed zoomToCursors when not on geometry. Increased regular zoom speed

* Using constants since move speed is a modifier

* lock fix

* Removed HybridCameraController. Increased maximum zoom. Removed toggling camera controls with Space. New way to apply canonic views, this time a correct one
2024-06-25 15:21:47 +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
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 af8c3e1a14 New URL formats in URLHelper (#2229)
* URLHelper now supports both old and new speckle URLs. Moved URLHelper to the viewer library so users can use it to transform speckle urls in loadable object urls. Disabled object-loader from reading the local storage for auth tokens.

* Added URI decoding

* Error checking. URLHelper is not a class anymore

* Queries are not run in parallel
2024-04-26 11:02:14 +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 9c481a20f5 WEB-695 Batching Maintenance (#2182)
* Starting to tackle WBX-397 by taking a different approach on computing draw ranges

* WIP

* Range computation is more or less done. Material indices still need a more robust approach

* Range material indices figured out mostly by trating them as edges in a graph. Also some profiling to max out pergf

* Added forward and backwards material index edges in order to be able to directly look them up rather than searching for them in an array

* Extended the new draw range integration approach to instanced batches

* Added vitest and wrote a first test for the DrawRange integration approach. Fixed some cicular dependencie which were messing up vitest runtime.

* A bunch of more tests

* Removed unused dep

* ci(viewer): test the viewer in CircleCI

* Include test-viewer as a dependency of later jobs

* Small updates

* Removed old range integration from all three batches

* Working on making the range update integration work on an array at a time

* Update range integration now works on entire arrays at a time. Almost twice as fast this way. Updates tests

* DrawRanges now also flattens the computed draw ranges, so we got rid of the old ugly way of flattening the ranges. Update MeshBatch, PointBatch and InstancedMeshBatch

* More adjustment to point batch

* Implemented a common PrimitiveBatch which can be used for any typical primitive based rendering (triangles, lines, points) as abstract. Our Mesh and Point batch will use most of the common implementation. Updated MeshBatch to extend PrimitiveBatch

* Updated PointBatch to extend PrimitiveBatch

* Tried making the instaned mesh batch extend the primitive batch but there was no point, they too different to make sense. Got rid of the pointless circular dependency between the instaned batch and mesh

* fixed viewer build

* Removed unused code and execution time measurements

---------

Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2024-04-02 15:48:01 +03:00
Alexandru Popovici edcd1b64f8 Viewer Embedded Textures (#1770)
* With Fabian's help we changed the way the default textures are loaded. They are now embeded using another rollup plugin as base64 directly into the js module

* Embedded textures

* Yarn lock stuff
2023-09-19 08:37:40 +01:00
Iain Sproat fac01c518e fix(objectloader, viewer, & shared): relax required node version to >=18.0.0 (#1779)
* fix(objectloader): relax required node version to >=18.0.0

* Viewer is now more tolerant of node versions
2023-09-01 23:53:46 +01:00
Iain Sproat 080e8197f9 chore(deps): bump node from 18.17.0 to 18.17.1 (#1771) 2023-08-24 10:55:43 +01:00
Iain Sproat ea941b3b81 chore(deps): bump node to 18.17.0 (#1722) 2023-07-26 12:38:50 +01:00
Alexandru Popovici 56058c04a3 Alex/#1678 faster diff (#1688)
* Sped up diffing by several orders of magnitude. Also started on a different more fancy approach to diffing involving boolean operations on object maps

* Finished with boolean version of diffing. Improved the speed of both by 50% on top of the previous speed improvements

* #1690 Completely transparent objects are ignored during picking via a toggle-able flag in renderer
2023-07-26 10:40:47 +03:00
Iain Sproat ffc3c5186f chore(node): bump to 18.16.1 (#1675) 2023-07-07 16:54:18 +01: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 b3d8c5d28c Text support and limited Dimensions support (#1604)
* Font loading (hidden under a .png for now). Simple experiments with rendering text

* Added some text rendering tests. WIP on billboarding

* Added tests using troika-text-three library which uses sdf font textures instead of generating text geometry

* WIP on supporting speckle text objects

* Some more work on speckle text object integration. Worked on text materials, text batch and text object. We're now rendering basic text

* We're now rendering the text for various dimension types. Changed text to use display style first, since that's the one that contains it's color.

* Implemented text selection. Text can now be selected and works the same way every other speckle objects works when selecting

* Implemented the rest of the filtering features for text.

* Batch building can now be async. Building text batches needs to be async because that's how the troika libary works. Fixed an issue with the section box not clippin text properly

* Removed dummy text geometry data from it's RenderData. Enabled render views with metadata to count as valid. getRenderableRenderViews now returns nodes with metadata as well. Text now supports proper unit conversion. Text now is being displayed correctly(-ish) when inside blocks. Autocad text is now being displayed
2023-06-06 15:49:47 +03:00
Kristaps Fabians Geikins b02a07e2b6 feat: Frontend 2.0 MVP 2023-05-08 10:47:01 +03:00
Iain Sproat 4eab7d9dcd chore(deps): bump node to 18.16.0 (#1564) 2023-05-05 12:43:39 +01:00
Iain Sproat 87e8d08e64 chore(deps): bump node to 18.15.0 (#1446) 2023-03-10 11:01:30 +00:00
Iain Sproat d8b7123ed0 chore(deps): bump node from 18.14.0 to 18.14.2 (#1426) 2023-03-01 12:16:55 +00:00
Iain Sproat a6fba9ebd3 chore(node): bump node version to 18.14.0 (#1365) 2023-02-10 11:44:44 +00: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
Iain Sproat ee50b32b59 chore(node): upgrades to node 18 (#1189)
* chore(node): upgrades to node 18

Node 16 was out of support (but not security upgrades), so bumping to next stable version.

https://github.com/specklesystems/speckle-server/issues/1187

* Update server liveness and readiness probes for node 18
* Bump web-ifc to 0.0.36
* Apply `--no-experimental-fetch` flag to fileimport-service to prevent issues in web-ifc (via emscripten) with node 18
2022-12-06 12:57:48 +00:00
AlexandruPopovici 10771db1aa Integrated three-mesh-bvh's bvh with the viewer's raycast picking. Using a simple workaround for the library's need of re-sorting the index buffer. Implemented a new way of retrieving the objects from the batch based on the raycast hit result index which does not depend on the order inside the index buffer 2022-11-03 22:10:19 +02:00
Kristaps Fabians Geikins 0a58381174 feat: @speckle/shared & some comments fixes (#997) 2022-10-10 16:32:23 +03:00
Dimitrie Stefanescu 3fcb820627 Merge branch 'main' into viewer-redux-integration 2022-09-06 09:14:41 +01:00
Dimitrie Stefanescu 95ede102eb chore(viewer/frontend): determinstic (not that great) colors for string prop filtering 2022-09-01 13:09:36 +03:00
Kristaps Fabians Geikins a170b1d163 fix: relaxed engine constraint for libs (#960) 2022-08-24 12:26:30 +03:00
Dimitrie Stefanescu a4d568477a feat(filtering): colors by category string props and other improvements on the get object filters/props 2022-08-09 12:49:49 +03:00
Dimitrie Stefanescu 627eb50ec9 feat(filtering): wip colors 2022-08-06 21:30:46 +03:00
AlexandruPopovici 582d9c0af8 Merged with main 2022-08-02 18:59:52 +03:00
Kristaps Fabians Geikins 827500c32b fix(frontend): embed viewer bugfixes & speed improvements (#804)
Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
2022-06-16 12:37:04 +03:00
Kristaps Fabians Geikins 437e1558ec fix: fixing all builds that broke with the new viewer (#788)
builds fix + viewer logic fixes
2022-06-02 18:13:32 +03:00
AlexandruPopovici 59ad804227 working on tree parsing 2022-06-02 17:18:07 +03:00
Fabians be87f88ff6 viewer asset support 2022-05-26 16:55:09 +03:00
Fabians 758d4fb125 attempted viewer build fix 2022-05-24 15:59:56 +03:00
AlexandruPopovici 439201ce0e Merged with main 2022-05-24 12:12:30 +03:00
Gergő Jedlicska 638969cd01 gergo/yarn (#753)
* yarn first go

* fix frontend build cache loader

* yarn workspaces built server Docker

* build(yarn): add workspaces plugin config

* chore(package defs): clean package*.json -s

* chore(gitignore): ignore yarn error log

* build(yarn): update yarn lock

* build(preview-service webpack): add extra resolved path to preview service webpack config

because of yarn package hoisting, there are no package level node_modules folder anymore.

* build(docker): update dockerignore with yarn specific configs

* build(docker): update Dockerfiles for yarn workspaces utilization

* ci(circleci): update server test job to yarn

* ci(circle): disable cache restore

* ci(circleci): trying the node orb yarn-run

* ci(circleci): yarn-run again

* ci(circleci): disable node orb

* ci(circleci): change base node image for tests

* ci(circleci): add yarn cache

* ci(circleci): remove node install step

* ci(circleci): add server specific cache archives

* ci(circleci): test build and publish

* ci(circleci): change npm auth method to suit yarn

* ci(circleci): trying new builder image

* ci(circleci): another base image, maybe this works

* ci(circleci): force a specific docker engine version

* ci(circleci): add yarn version plugin and its changes

* ci(circleci): cleanup and remove temp branch config

* chore(package defs): moving from npm run to yarn

* explicitly specifying webpack4 as a frontend dep

* chore(package defs): replace npm with yarn everywhere

* docs(root readme): update with some yarn specific docs

* chore(root workspace): update dev scripts and package lock

* ci(circleci): enable package publish step with yarn

Co-authored-by: Fabians <fabis94@live.com>
2022-05-19 19:53:07 +02:00
AlexandruPopovici 1eb44d00d9 Updated three.js version to 140. Thick lin raycasting now properly works in world space and also the threshold in world space is now accurate. 2022-05-18 11:53:50 +03:00
Fabians a47e226a0c Fixing TS config for viewer 2022-05-10 11:51:12 +03:00
AlexandruPopovici 0f1fafa8bc Started working on moving towards typescript inside the viewer. Made rollup compile a mix of ts and js files (will need to be reviewd soon). Added a public interface for the Viewer and also the Viewer is now typescript and implements the public API 2022-05-09 14:00:41 +03:00
AlexandruPopovici 48e085ceaf Revert "chore(release): publish to npm. Done by mistake with lerna"
This reverts commit 8b974d0db5.
2022-04-30 17:48:02 +03:00
AlexandruPopovici 8b974d0db5 chore(release): publish to npm
[skip ci]

 - @speckle/fileimport-service@2.3.17
 - @speckle/frontend@2.3.17
 - @speckle/objectloader@2.4.3
 - @speckle/preview-service@2.4.3
 - @speckle/server@2.3.17
 - @speckle/viewer-sandbox@1.0.1
 - @speckle/viewer@2.4.3
 - @speckle/webhook-service@2.3.17
2022-04-29 12:54:26 +03:00
Alexandru Popovici 02eb9a8c41 Alex/lines #443 (#721)
* Fixed some issues with npm scripts on Windows systems

* Made the example script run the dev build with wtch in parralel with running a http server. Handled #443

* #443. Added lineweigth to the rendered lines. However this will not work on most systems. More information about this in the issue

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Reverted the changes to the npm scripts

* Restored package.lock files from packages outside of viewer to their original state

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-04-27 17:24:37 +03:00
Gergő Jedlicska b574817200 chore: re lernafy package version specks 2022-04-09 16:06:55 +02:00