Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add NavCubePlugin option to align with project/true North #1042

Closed
xeolabs opened this issue May 11, 2023 · 0 comments
Closed

Feature: Add NavCubePlugin option to align with project/true North #1042

xeolabs opened this issue May 11, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@xeolabs
Copy link
Member

xeolabs commented May 11, 2023

Add an optional offset angle property "projectNorthOffsetAngle" to NavCubePlugin to align it with project North / true North.

As we rotate the NavCube, it calculates the eye, look, and 'up' at set on the Scene's camera. Conversely, when we interact with the Scene's camera, the NavCube calculates it's own camera's eye, look, and 'up' from the camera's matrix.

This solution works by rotating the eye->look direction vector according to projectNorthOffsetAngle, just before we transfer it from the Scene camera to the NavCube camera, or vice-versa.

By rotating the vector, we're able to avoid the disorientation problem we were having earlier from instead applying a yaw rotation to the camera. The problem with the yaw rotation was that it is rotating about the camera's local "upwards" axis, so that was causing the weird tumbling side effect.

Screencast.from.11.05.2023.21.05.05.webm

Usage

 import {Viewer, NavCubePlugin, XKTLoaderPlugin} from  "../dist/xeokit-sdk.es.js";

    const viewer = new Viewer({
        canvasId: "myCanvas"
    });

    viewer.camera.eye = [-3.933, 2.855, 27.018];
    viewer.camera.look = [4.400, 3.724, 8.899];
    viewer.camera.up = [-0.018, 0.999, 0.039];

    const xktLoader = new XKTLoaderPlugin(viewer);

    new NavCubePlugin(viewer, {
        canvasId: "myNavCubeCanvas",

        isProjectNorth: true,
        projectNorthOffsetAngle: -30.0 // Example value

    });

    const sceneModel = xktLoader.load({
        id: "myModel",
        src: "../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt", // Sets visual states of object in model
        edges: true
    });

Work remaining

When we click on the top or bottom of the cube, the scene camera loses the north-alignment. Will fix by rotating the 'up' vector that's used when setting the scene camera for upwards/downwards looking orientations. Will push what we've got so far now though, in @xeokit/xeokit-sdk 2.4.0-alpha-19.

@xeolabs xeolabs self-assigned this May 11, 2023
@xeolabs xeolabs added this to the 2.4.0 milestone May 11, 2023
@xeolabs xeolabs added the enhancement New feature or request label May 11, 2023
@xeolabs xeolabs closed this as completed May 11, 2023
Kurtil added a commit to Amoki/xeokit-sdk that referenced this issue May 16, 2023
* Install the CodeSee workflow. Learn more at https://docs.codesee.io

* Support federated metamodels xeokit#991

* Fix Angle and Distance measurement failure to set second point xeokit#998

* Skip inactive section planes in BCF getViewpoint

* Support federated metamodels xeokit#991

* Support federated metamodels xeokit#991

* Support federated metamodels xeokit#991

* npm bump

* Support federated metamodels xeokit#991

* fi typo in LineBatchingLayer

* fix imports to make them ES valid

* Fix loaders.gl import

* Fix imports

* more fixes

* fix las loader import

* z-index

* Optimization: avoid unneeded DOM layout calculations due to the obtention of Client Bounding Rect.

* Optimization: avoid to create 1 anonymous function instance every time a scene render happens.

* Optimization: avoid to bind same texture to same texture unit if was already bound.

* Improved WebGL2 compatibility.

(this does not make all xeokit code compatible with WebGL2)

* Introducing `DataTexturePeformanceModel`

This is a variation of `PeformanceModel` where all the GPU data is stored in data textures.

GPU memory savings are bigger than 80% (both with instanced and non-instanced geometries) when using the `DataTexturePerformanceModel`.

It requires WebGL2 to run properly.

* GPU-Optimised support for per-Entity Offsets.

* Fix management of deferred-flags in data-textures model

* Add GPU-optimized support for per-object coloring.

Plus minor refactors to make to code more readable.

* Bugfix: take into account `transparent` flag for entities in `TrianglesDataTextureLayer`.

* Introduce a toggle-able LOD mechanism.

This will keep hiding the most complex objects in the scene to be able to keep up with a `target frame rate`.

This is an extension to the `DataTexturesPerformanceModel`.

* Introduce a toggle-able View Frustum Culling mechanism.

This will cull the objects outside of the camera frustum, by making use of an `r*tree` data structure to speed up containement queries.

This is an extension to the `DataTexturesPerformanceModel`.

* Fix shader normal calculation in `data-textures Renderers.

* Fix normal picking in `TrianglesDataTexturePickNormalsRenderer`

* Fix in `ViewFrustumCullingManager.js` when there is no geometry in the AABB tree

* Increase the precision of per-object matrices from HALF_FLOAT to FLOAT.

* Avoid to draw triangles if the object `alpha` is zero.

* Replace wrong usage of `Float16` textures with `Float32` textures

* When finalizing data-texture Models, make sure to update flags for portion in batched mode,

This saves 1/3rd of model load time.

* Update data-textures initializtion with latest changes in `master`

Fix after rebase

data-textures: fix initialization of AABB's

* data-textures: avoid the need to store entity-normal matrices

* data-textures: register number of created data-textures in DataTextureRamStats

* data-textures: Increase max geometry texture size to 4096x4096 indices and vertices

* data-textures: Increase max colors texture size to 512 objects per row

* data-textures: remove temporary log

* data-textures: Increase positions+entity matrices texture size to 512 objects per row

* data-textures: Increase offsets texture size to 512 objects per row

* data-textures: raise the limit from 4096 objects/layer to 65536

* data-texture: add support for double-sided gometry

This introduces a novel way of doing it when geometries are non-solid.

In the Vertex Shader, non-geometries' triangles will have its winding flipped in case they would be culled.

* data-textures: more efficient double-side management

This is done by transforming the camera=>polygon vector to quantized space instead of transforming the normal to de-quantized space.

* data-textures: fix shading

This is done by taking into account the portion positioning matrix (entity * positions-decode) when obtaining the view-normal

* data-textures: add support for arbitrary ray-picking

(both for `ortho` and `perspective` camera modes)

* data-textures: use WebGLv2 syntax for section plane clipping code

* data-texture: add support for `TrianglesDataTextureSilhouetteRenderer`

* data-textures: add support for `TrianglesDataTextureEdgesRenderer`

* data-textures: clean-up temporary debug code

* data-textures: use `instanceof` instead of string comparison for `drawable.constructor.name`

* data-textures: temporarily disable shaders related to SAO

* data-textures: protect access to the update of pick-view-matrix

* data-textures: split initialization of camera-matrix and pick-camera-matrix in data-tex-perf-model

* Refactorings xeokit#824

* Refactorings xeokit#824

* Improvements in the LOD mechanism

* Fix missing DistanceMeasurement "measurementEnd" event for touch xeokit#1019

* npm bump

* xeokit#1022

* npm bump

* Make Frustum class public

* Added examples

* Fix unwanted SAO depth render for DataTextureSceneModel xeokit#824

* Add examples

* npm bump

* Make `VFC` mechanism support `model.worldMatrix` != ' identity'

This fixes a problem where View Frustum Culling would not work well for models loaded with e.g. the `cfg.position` parameter different from the zero vector.

This fix is based on the fact that it is the same (during `VFC`):

- to pre-process the AABB's so they include the `model.worldMatrix` and this the culling considers final world-AABB's. Then the clipping happens in world-space.
- to instead transform the camera `eye`/`look` with the inverse transform, so the AABB's are kept the same. Then the clipping happens in model-space.

* Add `useDataTextures.disableVertexWelding` option to the `XKTLoaderPlugin`

This allows to disable welding geometry vertices when loading the data into the GPU.

* Add `useDataTextures.disableIndexRebucketing` option to the `XKTLoaderPlugin`

This allows to disable adaptive demotion of triangles indices' bitness.

* Implement Depth Renderer for data-textures

* Allow SAO in `DataTextureSceneModel`

* Mitigation for what looks like a bug in Chrome for Mac

When using data-textures, unless those `Unit8Array`'s are converted to `Unit16Array`'s, the geometry is corrupted in Chrome for Mac after using the SAO renderers for the 1st time.

* When SAO-rendering triangles in data-textures, use a GL texture unit different from 0

This prevents additional texture re-binds as texture unit 0 is used frequently to update camera matrices, and portion flags.

* SAO-rendering for data-textures triangles: make sure the renderer is WebGLv2-compatible

* Chrome-for-Mac mitigation for data-textures when SAO enabled

Improvement over a previous mitigation where models containing objects with > 2^16 triangles, when using data-textures, got corrupted in Chrome for Mac when enabling SAO.

* Fix sticky DistanceMeasurementsControl xeokit#1030

* Enable masking in datatex depth vert shader & tweaks xeokit#811

* Removed redundant ScratchMemory from DataTextureSceneModel xeokit#811

* Rename some internal classes xeokit#811

* npm bump

* npm bump

* Fix broken TreeViewPlugin checkbox synchronization xeokit#1031

* npm bump

* add properties for nav cube to be able to turn on/off the usage of project north / true north,
and set the offset angle to align the nav cube to the used north. the default is using true north, and when setting the project north offset angle - it will rotate the nav cube to align it.

* remove duplicated line in Component.js

The removed line is identical to the line `170` which is always executed.

* [data-textures]: implement a smart deferred flags update mechanism

If the number of updated per-object properties in a frame is less than a threshold, they will be updated directly.

If the number of updates is instead bigger than a threshold (by default 10), the ones above the threshold will be batched, and the batch flushed just before rendering the frame.

This completely solves xeokit#1033

* Enable SAO rendering in Safari.

* npm bump

* Fix broken TreeViewPlugin checkbox synchronization xeokit#1031

* npm bump

* Unmerge PR with syntax errors
xeokit#1017

* npm bump

* Added examples

* Fix broken TreeViewPlugin checkbox synchronization xeokit#1031

* Fix Viewer.getSnapshot custom width and height params xeokit#1040

* npm bump

* Make annotation dots and labels ignore mouse wheel events xeokit#1041

* npm bump

* Add NavCubePlugin option to align with project/true North xeokit#1042

* npm bump

* Add NavCubePlugin option to align with project/true North - fix top & bottom clicks xeokit#1042

* npm bump

* Add NavCubePlugin option to align with project/true North - customize example xeokit#1042

* Enable mouse wheel zooming while hovering over measurements xeokit#1043

* npm bump

* Fix stuck pan/rotate/dolly keypresses over annotations and measurements xeokit#965

* npm bump

* [fix]: make sure to restore `gl.pixelStatei` changes in `Texture2D` class

---------

Co-authored-by: codesee-maps[bot] <86324825+codesee-maps[bot]@users.noreply.github.com>
Co-authored-by: lindsay <lindsay.kay@xeolabs.com>
Co-authored-by: Hugo Duroux <hugo@bimdata.io>
Co-authored-by: Hugo Duroux <hugo.duroux@gmail.com>
Co-authored-by: Christophe B <christophe.bellec@kwarto.immo>
Co-authored-by: Toni Martí <toni.marti.coll@tribia.com>
Co-authored-by: Elyran Kogan <elyran.kogan@versatile.ai>
@xeolabs xeolabs changed the title Add NavCubePlugin option to align with project/true North Feature: Add NavCubePlugin option to align with project/true North Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant