Compare commits

...

54 Commits

Author SHA1 Message Date
Dogukan Karatas e0f4a4c02c Merge pull request #192 from specklesystems/dogukan/send-versionId-to-server
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
feat (data): send `versionId` to the server
2025-07-29 10:14:11 +02:00
Dogukan Karatas 29773f9492 versionId added 2025-07-28 16:28:53 +02:00
Oğuzhan Koral 634df47a25 Revert "Merge pull request #186 from specklesystems/dogukan/cnx-2136-tag-as-markreceived-after-download-in-dataconnector" (#189)
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
This reverts commit ffc0d8ef5e, reversing
changes made to c8d858d575.

Co-authored-by: bimgeek <mucahitbgoker@gmail.com>
2025-07-22 08:02:27 +01:00
Mucahit Bilal GOKER 9ad59bf1d3 Bilal/cnx 2115 configure oauth2 for data gateway usage (#183)
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
* oauth2 implementation

* change code challenge to plain

* Reorder error checks

* implement proper PKCE security with SHA256
2025-07-21 16:56:44 +01:00
Mucahit Bilal GOKER ffc0d8ef5e Merge pull request #186 from specklesystems/dogukan/cnx-2136-tag-as-markreceived-after-download-in-dataconnector
fix: mark stream as received
2025-07-21 15:59:26 +03:00
Mucahit Bilal GOKER 94c80857a0 Merge branch 'dev' into dogukan/cnx-2136-tag-as-markreceived-after-download-in-dataconnector 2025-07-21 14:47:07 +03:00
Mucahit Bilal GOKER c8d858d575 Merge pull request #185 from specklesystems/dogukan/cnx-1933-disable-selection-of-ghosted-objects
fix (visual): disable selection of ghosted objects
2025-07-21 14:46:54 +03:00
Mucahit Bilal GOKER 36b9787b66 Merge branch 'dev' into dogukan/cnx-1933-disable-selection-of-ghosted-objects 2025-07-21 14:44:23 +03:00
Mucahit Bilal GOKER bde7a42c44 Merge branch 'dev' into dogukan/cnx-2136-tag-as-markreceived-after-download-in-dataconnector 2025-07-21 14:36:24 +03:00
Mucahit Bilal GOKER 1040f4622d Bilal/cnx 2033 update readme (#184)
* update readme

* remove button styling

* added code

* Update README.md

* Update README.md
2025-07-21 14:23:33 +03:00
Dogukan Karatas 91e799d006 mark received function added 2025-07-16 15:45:44 +02:00
Dogukan Karatas 8694666874 remove legacy implementation 2025-07-14 15:02:46 +02:00
Dogukan Karatas fa6ad8ec40 extended filtered selection 2025-07-11 17:04:01 +02:00
Dogukan Karatas 8e60249291 update viewer for ghosted objects 2025-07-11 15:27:29 +02:00
Mucahit Bilal GOKER 68d6bf3d55 Merge pull request #180 from specklesystems/dogukan/cnx-1978-control-camera-animation-on-change
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
feat (visual): toogle for animation on action
2025-07-08 16:14:31 +03:00
Dogukan Karatas 2a8925c8ef icon updated 2025-07-08 15:08:47 +02:00
Mucahit Bilal GOKER f9b3d3db52 Merge pull request #181 from specklesystems/dogukan/cnx-2089-auto-extract-properties
feat (data): extract properties column by default
2025-07-08 15:41:06 +03:00
Mucahit Bilal GOKER bfd0c33373 Merge pull request #179 from specklesystems/bilal/cnx-2106-federate-models-helper-function
Helper Function: Federate Models
2025-07-08 15:39:36 +03:00
Dogukan Karatas d155a4b165 registered to the capabilities 2025-07-08 13:37:17 +02:00
Dogukan Karatas 2e9ece856f adds properties extractor by default 2025-07-07 15:49:38 +02:00
Dogukan Karatas 808e288848 adds option for zoom on select 2025-07-07 14:18:18 +02:00
bimgeek 701116c66c helper function: federate models 2025-07-07 10:48:05 +03:00
Dogukan Karatas e73d392013 Merge pull request #178 from specklesystems/dogukan/cnx-1932-saving-visual-with-filtered-data
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
fix (visual): persistent visual filters
2025-07-04 12:51:52 +02:00
Dogukan Karatas dd7f3fe95d cover initial states 2025-07-03 15:54:09 +02:00
Dogukan Karatas fdcc1f2cef listen load event 2025-07-03 15:42:06 +02:00
Dogukan Karatas 5e2f108e49 Merge pull request #177 from specklesystems/dogukan/cnx-2032-persistent-hide-nav-bar-toggle
fix (visual): persistent navbar toogle
2025-07-01 15:01:48 +02:00
Dogukan Karatas df334e95a2 workspace to viewmode 2025-07-01 14:53:03 +02:00
Dogukan Karatas ce733d1ced adds persistent navbar 2025-07-01 11:15:59 +02:00
Dogukan Karatas 8345258990 Merge pull request #176 from specklesystems/dogukan/fix-function-registration
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
fix: helper function registration
2025-06-24 15:22:12 +02:00
Dogukan Karatas dbd0f2f9ce fix registration 2025-06-24 15:19:11 +02:00
Dogukan Karatas c9b4155660 Merge pull request #174 from specklesystems/bilal/object-compound-structure
added objects composite structure
2025-06-24 14:56:26 +02:00
Dogukan Karatas c4d094d722 Merge branch 'dev' into bilal/object-compound-structure 2025-06-24 14:55:06 +02:00
Dogukan Karatas 5b003b182b Merge pull request #173 from specklesystems/bilal/object-materialquantities
object material quantities added
2025-06-24 14:54:36 +02:00
Dogukan Karatas 7eabd47f6d Merge pull request #175 from specklesystems/dogukan/cnx-2035-loading-got-veeeeeeery-sloooooooow
performance fix: remove `displayValue` exclusion
2025-06-24 14:54:24 +02:00
Dogukan Karatas 822b999be9 remove displayValue exclusion 2025-06-24 13:47:30 +02:00
Dogukan Karatas 2407b8758a Merge pull request #171 from specklesystems/dogukan/exclude-display-value
feat(data): exclude displayValue in data
2025-06-24 11:09:48 +02:00
Mucahit Bilal GOKER d6f5e65bd7 added objects composite structure 2025-06-19 15:28:41 +03:00
Mucahit Bilal GOKER 183cc36654 object material quantities added 2025-06-19 15:15:05 +03:00
Mucahit Bilal GOKER a740272585 Merge pull request #170 from specklesystems/bilal/expand-record-util
expand record helper function
2025-06-19 15:11:51 +03:00
Dogukan Karatas 72128a9f4e excludes displayValues in data 2025-06-19 13:55:41 +02:00
Mucahit Bilal GOKER 677c663ef3 Merge branch 'dev' into bilal/expand-record-util 2025-06-19 14:55:21 +03:00
Mucahit Bilal GOKER a077857c66 add new line 2025-06-19 14:40:16 +03:00
Mucahit Bilal GOKER 5897a286bc expand record helper function 2025-06-19 14:23:40 +03:00
Dogukan Karatas 5b49fb2a9a Merge pull request #169 from specklesystems/dogukan/revit-helper-functions
feat (data): get properties function
2025-06-19 13:07:57 +02:00
Dogukan Karatas 424404dd11 Merge branch 'dogukan/revit-helper-functions' of https://github.com/specklesystems/speckle-powerbi into dogukan/revit-helper-functions 2025-06-19 13:04:18 +02:00
Dogukan Karatas 31312522a7 adds objects.collections 2025-06-19 12:47:18 +02:00
Mucahit Bilal GOKER 932198dccf rename GetProperties to Objects.Properties 2025-06-19 13:47:13 +03:00
Dogukan Karatas 3770502ca4 adds function overload 2025-06-18 16:30:36 +02:00
Dogukan Karatas 93e8fcdd9d gets duplicated props 2025-06-18 16:13:42 +02:00
Dogukan Karatas 370052b2be GetProperties added 2025-06-18 14:41:14 +02:00
Oğuzhan Koral aa4a137a0d handle size in MB separately (#168)
Build and deploy Connector and Visual / build-connector (push) Has been cancelled
Build and deploy Connector and Visual / build-visual (push) Has been cancelled
Build and deploy Connector and Visual / deploy-installers (push) Has been cancelled
2025-06-16 21:17:43 +03:00
Dogukan Karatas 4acdf30734 error handling (#167)
Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com>
2025-06-16 12:05:21 +00:00
Dogukan Karatas b531446acd feat (visual): send connector version to mixpanel (#165)
* connector version added

* updated props
2025-06-16 15:03:54 +03:00
Jedd Morgan de1b2ca39c Run CI on PR (#164) 2025-06-06 10:14:00 +01:00
25 changed files with 1265 additions and 174 deletions
@@ -1,4 +1,4 @@
name: build_powerbi
name: Build and deploy Connector and Visual
on:
push:
branches: ["installer-test/**"]
+30
View File
@@ -0,0 +1,30 @@
name: Test Build Connector and Visual
on: pull_request
jobs:
build-connector:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Build Data Connector
working-directory: src/powerbi-data-connector
run: |
msbuild Speckle.proj /restore /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true
build-visual:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
working-directory: src/powerbi-visual
- run: npm run build
working-directory: src/powerbi-visual
+60 -26
View File
@@ -3,18 +3,26 @@
Speckle | Power BI
</h1>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://docs.speckle.systems/"><img src="https://img.shields.io/badge/docs-speckle.systems-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
> Speckle is the first AEC data hub that connects with your favorite AEC tools. Speckle exists to overcome the challenges of working in a fragmented industry where communication, creative workflows, and the exchange of data are often hindered by siloed software and processes. It is here to make the industry better.
<h3 align="center">
Speckle Connector and 3D Viewer Visual for Power BI
Speckle Connector and 3D Visual for Power BI
</h3>
# Features
## Features
Speckle Power BI Data Connector lets you easily get data from Speckle into Power BI reports and visualizations. You can access and analyze data from various AEC apps (like Revit, Archicad, Grasshopper, and more) and open-source files (IFC, STL, OBJ, etc.) into Power BI with ease.
<p align="center">
<div align="center">
<a href="https://app.speckle.systems/connectors/">
Download Power BI Connector
</a>
</div>
</p>
Speckles connection to Power BI consists of two parts:
- **Data Connector** fetches the data you uploaded from AEC apps to Speckle.
@@ -22,19 +30,19 @@ Speckles connection to Power BI consists of two parts:
![Desktop - 1 (1)](https://github.com/specklesystems/speckle-powerbi/assets/51519350/6d2c5224-965f-4eae-b869-be26cb48c6b2)
# Repo Structure
## Repository Structure
This repo is home to our Power BI connector. The Speckle Server provides all the web-facing functionality and can be found [here](https://github.com/specklesystems/Server).
This repository is home to our Power BI connector. The Speckle Server provides all the web-facing functionality and can be found [here](https://github.com/specklesystems/Server).
`src/powerbi-data-connector` contains all the code for the Data connector.
`src/powerbi-visual` contains all the code for 3D Visual.
# Installation
## Installation
Speckle connector can be installed directly from the [connectors portal](https://app.speckle.systems/connectors/). Full instructions for [installation](https://speckle.guide/user/powerbi/installation.html) and [configuration](https://speckle.guide/user/powerbi/configuration.html) can be found on our docs.
Power BI connector installer can be downloaded from the [connectors portal](https://app.speckle.systems/connectors/). Full instructions for [installation](https://docs.speckle.systems/connectors/power-bi#setup) and [configuration](https://docs.speckle.systems/connectors/power-bi#why-dont-i-see-speckle-as-a-data-source-in-power-bi) can be found on our docs.
# Using 3D Visual
### 3D Visual
3D Visual can be imported as any other Power BI custom visual.
@@ -43,34 +51,62 @@ Speckle connector can be installed directly from the [connectors portal](https:/
3. Go to `Documents/Power BI Desktop/Custom Visuals` and import `Speckle 3D Visual.pbiviz` file.
4. Speckle cube will appear in the Visualization pane.
For more on how to use the visual, [check our docs](https://speckle.guide/user/powerbi-visual/introduction.html).
For more on how to use the visual, [check our docs](https://docs.speckle.systems/connectors/power-bi).
# Usage
## Quick Start
To get started with Power BI connectors, please take a look at the [documentation](https://speckle.guide/user/powerbi/introduction.html) and extensive [tutorials](https://www.youtube.com/playlist?list=PLlI5Dyt2HaEsZHG2WJ75WIM0Brx6VHT2S) published.
To get started with Power BI connector, please take a look at the [documentation](https://docs.speckle.systems/connectors/power-bi) and extensive [tutorials](https://www.youtube.com/@SpeckleSystems) published.
# **Developing & Debugging**
## Development Setup
We encourage everyone interested to debug/hack/contribute/give feedback to this project.
### For local development of the 3D Visual
## **Setup**
1. **Clone the repository**:
```bash
git clone https://github.com/specklesystems/speckle-powerbi.git
cd speckle-powerbi
```
### **Install PowerQuery SDK**
2. **Navigate to the visual directory**:
```bash
cd src/powerbi-visual
```
Follow the instructions from the [official docs](https://docs.microsoft.com/en-us/power-query/installingsdk)
3. **Install dependencies**:
```bash
npm install
# or
yarn install
```
### **Build with Visual Studio**
4. **Start development server**:
```bash
npm run dev
```
Every time you build the connector, VisualStudio will copy the latest `.mez` connector file to the appropriate location. Just restart PowerBI to see the latest changes.
5. **Build the visual**:
```bash
# Development build
npm run build:dev
# Production build
npm run build
```
### **Debug**
### For local development of the Data Connector
You can start the PowerQuery connector in VisualStudio, this will open a standalone connector you can use for testing purposes.
1. **Install PowerQuery SDK**:
Follow the instructions from the [official docs](https://docs.microsoft.com/en-us/power-query/installingsdk)
We don't know of a way to debug the connector live in PowerBI, but we'd be happy to hear about it.
2. **Open the project in Visual Studio Code**:
- Open `src/powerbi-data-connector/Speckle.proj`
- Build the project to generate the `.mez` file
3. **Testing the connector**:
- Visual Studio will automatically copy the `.mez` file to the appropriate location
- Restart Power BI Desktop to see the latest changes
# About Speckle
## About Speckle
What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube/views/B9humiSpHzM?label=Speckle%20in%201%20minute%20video&style=social)
@@ -91,12 +127,10 @@ What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube
Give Speckle a try in no time by:
- [![app.speckle.systems](https://img.shields.io/badge/https://-speckle.xyz-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://app.speckle.systems) ⇒ creating an account at our public server
- [![app.speckle.systems](https://img.shields.io/badge/https://-app.speckle.systems-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://app.speckle.systems) ⇒ creating an account at our public server
### Resources
- [![Community forum users](https://img.shields.io/badge/community-forum-green?style=for-the-badge&logo=discourse&logoColor=white)](https://speckle.community) for help, feature requests or just to hang with other speckle enthusiasts, check out our community forum!
- [![website](https://img.shields.io/badge/tutorials-speckle.systems-royalblue?style=for-the-badge&logo=youtube)](https://speckle.systems) our tutorials portal is full of resources to get you started using Speckle
- [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=for-the-badge&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/) reference on almost any end-user and developer functionality
![Untitled](https://user-images.githubusercontent.com/2679513/132021739-15140299-624d-4410-98dc-b6ae6d9027ab.png)
- [![docs](https://img.shields.io/badge/docs-speckle.systems-orange?style=for-the-badge&logo=read-the-docs&logoColor=white)](https://docs.speckle.systems) reference on almost any end-user and developer functionality
+165 -21
View File
@@ -4,6 +4,79 @@ section Speckle;
AuthAppId = "spklpwerbi";
AuthAppSecret = "spklpwerbi";
// PKCE helper functions for enhanced OAuth2 security
Base64UrlEncode = (binaryData as binary) =>
let
// Convert binary to base64
base64 = Binary.ToText(binaryData, BinaryEncoding.Base64),
// Convert to base64url by replacing characters and removing padding
base64url = Text.Replace(Text.Replace(Text.Replace(base64, "+", "-"), "/", "_"), "=", "")
in
base64url;
GeneratePKCEVerifier = () =>
let
// Generate cryptographically secure random string using allowed characters
// RFC 7636: [A-Z] / [a-z] / [0-9] / "-" / "." / "_" / "~"
allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",
// Generate multiple GUIDs to create entropy
guid1 = Text.Replace(Text.Replace(Text.NewGuid(), "-", ""), "{", ""),
guid2 = Text.Replace(Text.Replace(Text.NewGuid(), "-", ""), "}", ""),
guid3 = Text.Replace(Text.Replace(Text.NewGuid(), "-", ""), "{", ""),
guid4 = Text.Replace(Text.Replace(Text.NewGuid(), "-", ""), "}", ""),
// Combine and convert to allowed characters
combined = guid1 & guid2 & guid3 & guid4,
// Map hex characters to allowed PKCE characters
mapped = Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(combined, "0", "A"),
"1", "B"),
"2", "C"),
"3", "D"),
"4", "E"),
"5", "F"),
// Continue mapping remaining hex chars to allowed chars
verifier = Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(
Text.Replace(mapped, "6", "G"),
"7", "H"),
"8", "I"),
"9", "J"),
"a", "K"),
"b", "L"),
"c", "M"),
"d", "N"),
"e", "O"),
"f", "P"),
// Ensure length is between 43-128 characters as per RFC 7636
finalVerifier = Text.Start(verifier, 43)
in
finalVerifier;
GeneratePKCEChallenge = (verifier as text) =>
let
// Create SHA256 hash of the verifier as required by RFC 7636
hash = Crypto.CreateHash(CryptoAlgorithm.SHA256, Text.ToBinary(verifier, TextEncoding.Ascii)),
// Convert to base64url encoding
challenge = Base64UrlEncode(hash)
in
challenge;
// function to load `pqm` files - this is essential and must be kept
shared Speckle.LoadFunction = (fileName as text) =>
let
@@ -75,6 +148,42 @@ shared Speckle.GetWorkspace = Value.ReplaceType(
type function (url as Uri.Type) as record
);
shared Speckle.Objects.Properties = Value.ReplaceType(
Speckle.LoadFunction("Objects.Properties.pqm"),
type function (inputRecord as record, optional filterKeys as list) as record
);
shared Speckle.Utils.ExpandRecord = Value.ReplaceType(
Speckle.LoadFunction("Utils.ExpandRecord.pqm"),
type function (
table as table,
columnName as text,
optional FieldNames as list,
optional UseCombinedNames as logical
) as table
);
shared Speckle.Objects.Collections = Value.ReplaceType(
Speckle.LoadFunction("Objects.Collections.pqm"),
type function (inputData as table) as table
);
shared Speckle.Objects.CompositeStructure = Value.ReplaceType(
Speckle.LoadFunction("Objects.CompositeStructure.pqm"),
type function (objectRecord as record, optional outputAsList as nullable logical) as any
);
shared Speckle.Objects.MaterialQuantities = Value.ReplaceType(
Speckle.LoadFunction("Objects.MaterialQuantities.pqm"),
type function (objectRecord as record, optional outputAsList as logical) as any
);
shared Speckle.Models.Federate = Value.ReplaceType(
Speckle.LoadFunction("Models.Federate.pqm"),
type function (tables as list, optional excludeData as logical) as table
);
[DataSource.Kind = "Speckle", Publish="GetByUrl.Publish"]
shared Speckle.GetByUrl = Value.ReplaceType(
Speckle.LoadFunction("GetByUrl.pqm"),
@@ -141,14 +250,21 @@ Speckle = [
let
server = Text.Combine(
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
)
),
// Generate PKCE parameters for enhanced security
codeVerifier = GeneratePKCEVerifier(),
codeChallenge = GeneratePKCEChallenge(codeVerifier),
// Build authorization URL with PKCE parameters
authUrl = Text.Combine({server, "authn", "verify", AuthAppId, state}, "/") &
"?code_challenge=" & codeChallenge &
"&code_challenge_method=S256"
in
[
LoginUri = Text.Combine({server, "authn", "verify", AuthAppId, state}, "/"),
LoginUri = authUrl,
CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 800,
WindowWidth = 600,
Context = null
Context = [code_verifier = codeVerifier]
],
FinishLogin = (clientApplication, dataSourcePath, context, callbackUri, state) =>
let
@@ -156,20 +272,22 @@ Speckle = [
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
),
Parts = Uri.Parts(callbackUri)[Query],
// Extract code verifier from context for PKCE
codeVerifier = if context <> null then context[code_verifier] else null,
// Build token request with PKCE parameters
tokenRequest = [
accessCode = Parts[access_code],
appId = AuthAppId,
appSecret = AuthAppSecret,
challenge = state
] & (if codeVerifier <> null then [code_verifier = codeVerifier] else []),
Source = Web.Contents(
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
#"Content-Type" = "application/json"
],
Content = Json.FromValue(
[
accessCode = Parts[access_code],
appId = AuthAppId,
appSecret = AuthAppSecret,
challenge = state
]
)
Content = Json.FromValue(tokenRequest)
]
),
json = Json.Document(Source)
@@ -185,7 +303,8 @@ Speckle = [
server = Text.Combine(
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
),
Source = Web.Contents(
// Enhanced refresh with error handling for gateway compatibility
Source = try Web.Contents(
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
@@ -197,17 +316,42 @@ Speckle = [
appId = AuthAppId,
appSecret = AuthAppSecret
]
)
),
ManualStatusHandling = {400, 401, 403, 500, 502, 503, 504}
]
) otherwise null,
// Check if request was successful
IsSuccess = Source <> null,
// If successful, parse the response
json = if IsSuccess then
try Json.Document(Source) otherwise null
else
null,
// Validate the response contains expected fields
IsValidResponse = json <> null and Record.HasFields(json, {"token"}),
// Return result with enhanced error handling
result = if IsValidResponse then
[
access_token = json[token],
scope = null,
token_type = "bearer",
refresh_token = json[refreshToken]
]
else
error [
Reason = "TokenRefreshFailed",
Message = "Failed to refresh OAuth token - please re-authenticate",
Detail = [
Server = server,
RefreshToken = if refreshToken = null then "null" else "present"
]
]
),
json = Json.Document(Source)
in
[
access_token = json[token],
scope = null,
token_type = "bearer",
refresh_token = json[refreshToken]
]
result
],
Key = [
KeyLabel = "Personal Access Token",
@@ -1,6 +1,8 @@
(server as text, optional query as text, optional variables as record) as record =>
let
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
// Enhanced credential retrieval with OAuth2 support
apiKey = try Extension.CurrentCredential()[Key] otherwise try Extension.CurrentCredential()[access_token] otherwise null,
defaultQuery = "query {
activeUser {
email
@@ -12,7 +14,9 @@
version
}
}",
Source = Web.Contents(
// Enhanced API call with comprehensive error handling
Source = try Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers = [
@@ -20,14 +24,56 @@
#"Content-Type" = "application/json",
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey})
],
ManualStatusHandling = {400},
ManualStatusHandling = {400, 401, 403, 404, 500, 502, 503, 504},
Content = Json.FromValue([query = Text.From(query ?? defaultQuery), variables = variables])
]
),
#"JSON" = Json.Document(Source)
in
// Check if response contains errors, if so, return first error.
if Record.HasFields(#"JSON", {"errors"}) then
error #"JSON"[errors]{0}[message]
) otherwise null,
// Check if the HTTP request was successful
IsHttpSuccess = Source <> null,
// Get HTTP status code for detailed error handling
StatusCode = if IsHttpSuccess then Value.Metadata(Source)[Response.Status] else null,
// Parse JSON response if HTTP request was successful
#"JSON" = if IsHttpSuccess then
try Json.Document(Source) otherwise null
else
#"JSON"[data]
null,
// Comprehensive error handling
// Comprehensive error handling
result = if not IsHttpSuccess then
error [
Reason = "HttpRequestFailed",
Message = "Failed to connect to Speckle server",
Detail = [Server = server, StatusCode = StatusCode]
]
else if StatusCode = 401 then
error [
Reason = "AuthenticationFailed",
Message = "Invalid or expired authentication token",
Detail = [Server = server, HasToken = apiKey <> null]
]
else if StatusCode = 403 then
error [
Reason = "AuthorizationFailed",
Message = "Insufficient permissions for this operation",
Detail = [Server = server]
]
else if #"JSON" = null then
error [
Reason = "InvalidJsonResponse",
Message = "Server returned invalid JSON response",
Detail = [Server = server, StatusCode = StatusCode]
]
else if Record.HasFields(#"JSON", {"errors"}) then
error [
Reason = "GraphQLError",
Message = #"JSON"[errors]{0}[message],
Detail = [Server = server, Errors = #"JSON"[errors]]
]
else
#"JSON"[data]
in
result
@@ -39,8 +39,9 @@
),
// fields to remove from data record
FieldsToRemove = {"__closure", "totalChildrenCount", "renderMaterialProxies"},
// create the final table with cleaned data records
FinalTable = Table.FromRecords(
// create basic table with cleaned data records (no properties column yet)
BasicTable = Table.FromRecords(
List.Transform(
TableFromList[Column1],
each let
@@ -48,18 +49,19 @@
fieldsToRemoveForThisRecord = List.Select(
FieldsToRemove,
each Record.HasFields(record, {_})
)
),
cleanedRecord = Record.RemoveFields(record, fieldsToRemoveForThisRecord)
in
[
#"Object IDs" = record[id], // Object IDs
#"Speckle Type" = record[speckle_type], // Speckle Type
#"Version Object ID" = rootId,
data = Record.RemoveFields(record, fieldsToRemoveForThisRecord) // Data
data = cleanedRecord // Data
]
)
),
// Function to check if a row should be excluded based on speckle type
// function to check if a row should be excluded based on speckle type
ShouldExcludeRow = (row as record) as logical =>
let
speckleType = Record.FieldOrDefault(row[data], "speckle_type", "")
@@ -70,14 +72,38 @@
// Filtering logic here
// If model data contains any DataObject -> fetch only data objects (excluding unwanted types)
// If there are no data objects in the data -> fetch everything but exclude DataChunks and RawEncoding
// Check if model contains any DataObject
HasDataObjects = Table.RowCount(
Table.SelectRows(
FinalTable,
BasicTable,
each Text.Contains(Record.FieldOrDefault([data], "speckle_type", ""), "DataObject")
and not ShouldExcludeRow(_)
)
) > 0,
// load the Objects.Properties function only if we have DataObjects
ObjectsProperties = if HasDataObjects then Extension.LoadFunction("Objects.Properties.pqm") else null,
// Add properties column only if model has DataObjects
FinalTable = if HasDataObjects then
Table.AddColumn(
BasicTable,
"properties",
each let
dataRecord = [data],
isDataObject = Text.Contains(Record.FieldOrDefault(dataRecord, "speckle_type", ""), "DataObject"),
hasProperties = Record.HasFields(dataRecord, {"properties"}),
extractedProperties = if hasProperties and isDataObject then
try ObjectsProperties(dataRecord) otherwise []
else
[]
in
if Record.FieldCount(extractedProperties) > 0 then extractedProperties else null
)
else
BasicTable,
// Apply the same filtering logic as before
FilteredTable = if HasDataObjects then
Table.SelectRows(
FinalTable,
@@ -0,0 +1,30 @@
// function for federating multiple tables by combining them and creating a concatenated Version Object ID
(tables as list, optional excludeData as logical) as table =>
let
ViewerOnly = if excludeData = null then false else excludeData,
// filter columns from each table if excludeData is true
ProcessedTables = List.Transform(
tables,
each
if ViewerOnly then
Table.SelectColumns(_, {"Version Object ID", "Object IDs"}, MissingField.Ignore)
else
_
),
CombinedTable = Table.Combine(ProcessedTables),
DistinctVersionObjectIDs = List.Distinct(CombinedTable[Version Object ID]),
ConcatenatedVersionObjectIDs = Text.Combine(DistinctVersionObjectIDs, ","),
// Replace all Version Object ID values with the concatenated string
FederatedTable = Table.ReplaceValue(
CombinedTable,
each [Version Object ID],
ConcatenatedVersionObjectIDs,
Replacer.ReplaceText,
{"Version Object ID"}
)
in
FederatedTable
@@ -0,0 +1,163 @@
// function for mapping collection names to referenced elements in Speckle data
(inputData as table) as table =>
let
// Helper function to safely get field value
SafeFieldValue = (record as record, fieldName as text) as any =>
if Record.HasFields(record, {fieldName}) then
Record.Field(record, fieldName)
else
null,
// Helper function to safely get nested field value
SafeNestedValue = (record as record, path as list) as any =>
List.Accumulate(
path,
record,
(current, fieldName) =>
if current <> null and Value.Is(current, type record) and Record.HasFields(current, {fieldName}) then
Record.Field(current, fieldName)
else
null
),
// Step 1: Identify Collection Objects
CollectionObjects = Table.SelectRows(
inputData,
each
let
speckleType = SafeFieldValue(_, "Speckle Type")
in
speckleType <> null and Text.Contains(speckleType, "Collection")
),
// Step 2: Extract Collection Metadata
CollectionMetadata = Table.AddColumn(
CollectionObjects,
"CollectionInfo",
each
let
objectId = SafeFieldValue(_, "Object IDs"),
collectionName = SafeNestedValue(_, {"data", "name"}),
elements = SafeNestedValue(_, {"data", "elements"})
in
[
ObjectId = objectId,
CollectionName = if collectionName <> null then collectionName else "Unnamed Collection",
Elements = if elements <> null and Value.Is(elements, type list) then elements else {}
]
),
// Step 3: Build Collection Hierarchy Mapping
CollectionHierarchy = Table.AddColumn(
CollectionMetadata,
"CollectionReferences",
each
let
info = [CollectionInfo],
collectionName = info[CollectionName],
elements = info[Elements]
in
List.Transform(
elements,
(element) =>
let
referencedId = if Value.Is(element, type record) and Record.HasFields(element, {"referencedId"}) then
element[referencedId]
else
null
in
if referencedId <> null then
[
ReferencedId = referencedId,
CollectionName = collectionName,
ParentCollectionId = info[ObjectId]
]
else
null
)
),
// Step 4: Flatten Reference Mapping
FlattenedReferences = Table.SelectRows(
Table.ExpandListColumn(
Table.SelectColumns(CollectionHierarchy, {"CollectionReferences"}),
"CollectionReferences"
),
each [CollectionReferences] <> null
),
ReferenceTable = Table.ExpandRecordColumn(
FlattenedReferences,
"CollectionReferences",
{"ReferencedId", "CollectionName", "ParentCollectionId"},
{"ReferencedId", "CollectionName", "ParentCollectionId"}
),
// Step 5: Build Hierarchical Collection Paths
BuildCollectionPath = (objectId as text, visited as list) as text =>
let
// Prevent infinite loops
_ = if List.Contains(visited, objectId) then
error "Circular reference detected in collection hierarchy"
else
null,
newVisited = List.InsertRange(visited, 0, {objectId}),
// Find if this object is referenced by any collection
parentReferences = Table.SelectRows(ReferenceTable, each [ReferencedId] = objectId),
result = if Table.RowCount(parentReferences) = 0 then
// No parent collection found
""
else
let
parentRef = parentReferences{0},
parentCollectionId = parentRef[ParentCollectionId],
currentCollectionName = parentRef[CollectionName],
// Recursively get parent path
parentPath = @BuildCollectionPath(parentCollectionId, newVisited),
// Build full path
fullPath = if parentPath = "" then
currentCollectionName
else
parentPath & "::" & currentCollectionName
in
fullPath
in
result,
// Step 6: Add Collection Paths to data field
FinalData = Table.TransformColumns(
inputData,
{
"data", each
let
currentData = _,
currentRow = Table.SelectRows(inputData, each [data] = currentData){0},
objectId = SafeFieldValue(currentRow, "Object IDs"),
collectionPath = if objectId <> null then
try
BuildCollectionPath(objectId, {})
otherwise
""
else
"",
// Add CollectionPath field to the data record, set to null if empty
enhancedData = if Value.Is(currentData, type record) then
Record.AddField(
currentData,
"collectionPath",
if collectionPath = "" then null else collectionPath
)
else
currentData
in
enhancedData
}
)
in
FinalData
@@ -0,0 +1,18 @@
(objectRecord as record, optional outputAsList as nullable logical) as any =>
let
compositeStructure =
if Record.HasFields(objectRecord[properties], "Composite Structure") then
objectRecord[properties][Composite Structure]
else if Record.HasFields(objectRecord[properties], "Parameters") and
Record.HasFields(objectRecord[properties][Parameters], "Type Parameters") and
Record.HasFields(objectRecord[properties][Parameters][Type Parameters], "Structure") then
objectRecord[properties][Parameters][Type Parameters][Structure]
else
null,
result =
if outputAsList = true then
if compositeStructure <> null then Record.ToList(compositeStructure) else null
else
compositeStructure
in
result
@@ -0,0 +1,15 @@
// Helper function to extract [properties][Material Quantities] and optionally output as list
(objectRecord as record, optional outputAsList as logical) as any =>
let
// Ensure outputAsList is logical and defaults to false if not provided
OutputAsList = if outputAsList = null then false else outputAsList,
// Check if 'properties' and 'Material Quantities' exist
HasMaterialQuantities = Record.HasFields(objectRecord, {"properties"}) and Record.HasFields(Record.Field(objectRecord, "properties"), {"Material Quantities"}),
MaterialQuantities = if HasMaterialQuantities then Record.Field(Record.Field(objectRecord, "properties"), "Material Quantities") else null,
Result = if MaterialQuantities = null then null else
if OutputAsList then
Record.ToList(MaterialQuantities)
else
MaterialQuantities
in
Result
@@ -0,0 +1,196 @@
// function for extracting and flattening properties from Speckle objects
(inputRecord as record, optional filterKeys as list) as record =>
let
// auto-extract properties if the input has a "properties" field
ActualInput = if Record.HasFields(inputRecord, {"properties"}) then
inputRecord[properties]
else
inputRecord,
// helper function to check if a key should be included
ShouldIncludeKey = (keyName as text) as logical =>
if filterKeys = null then
true
else
List.Contains(filterKeys, keyName),
// define excluded paths
ExcludedPaths = {
"Composite Structure",
"Material Quantities",
"Parameters.Type Parameters.Structure"
},
IsExcludedPath = (path as text) as logical =>
List.AnyTrue(
List.Transform(
ExcludedPaths,
(excludedPath) => Text.StartsWith(path, excludedPath)
)
),
// helper function to handle duplicate keys by adding suffixes
AddUniqueKey = (existingRecord as record, newKey as text, newValue as any) as record =>
let
originalKey = newKey,
counter = 1,
// find a unique key by adding suffix if needed
FindUniqueKey = (testKey as text, testCounter as number) as text =>
if Record.HasFields(existingRecord, {testKey}) then
@FindUniqueKey(originalKey & "_" & Text.From(testCounter), testCounter + 1)
else
testKey,
uniqueKey = FindUniqueKey(newKey, counter),
result = Record.AddField(existingRecord, uniqueKey, newValue)
in
result,
// enhanced combine function that handles duplicates and filtering
SafeRecordCombine = (records as list) as record =>
List.Accumulate(
records,
[],
(state, current) =>
List.Accumulate(
Record.FieldNames(current),
state,
(innerState, fieldName) =>
if ShouldIncludeKey(fieldName) then
AddUniqueKey(innerState, fieldName, Record.Field(current, fieldName))
else
innerState
)
),
// helper function to process name-value objects
ProcessNameValueObject = (obj as record) as record =>
let
// Assert that the object has required fields
_ = if not (Record.HasFields(obj, {"name"}) and Record.HasFields(obj, {"value"})) then
error [
Reason = "Invalid Name-Value Object",
Message = "Object must have both 'name' and 'value' fields"
]
else
null,
BaseName = obj[name],
BaseValue = obj[value],
// only extract name and value if it should be included
Result = if ShouldIncludeKey(BaseName) then
Record.FromList({BaseValue}, {BaseName})
else
[]
in
Result,
// helper function to process direct key-value objects
ProcessDirectKeyValueObject = (obj as record) as record =>
let
// assert that input is a record
_ = if not Value.Is(obj, type record) then
error [
Reason = "Invalid Input Type",
Message = "Expected record for direct key-value processing"
]
else
null,
// extract all primitive key-value pairs
PrimitiveFields = List.Transform(
Record.FieldNames(obj),
(fieldName) =>
let
fieldValue = Record.Field(obj, fieldName)
in
if not Type.Is(Value.Type(fieldValue), type record) and ShouldIncludeKey(fieldName) then
Record.FromList({fieldValue}, {fieldName})
else
[]
),
// filter out empty records and combine using safe combine
FilteredFields = List.Select(PrimitiveFields, (rec) => Record.FieldCount(rec) > 0),
Result = SafeRecordCombine(FilteredFields)
in
Result,
// helper functions for type checking
HasDirectKeyValuePattern = (obj as record) as logical =>
List.AllTrue(
List.Transform(
Record.FieldValues(obj),
(value) => not Type.Is(Value.Type(value), type record)
)
),
IsNestedContainer = (obj as record) as logical =>
List.AnyTrue(
List.Transform(
Record.FieldValues(obj),
(value) => Type.Is(Value.Type(value), type record)
)
),
// main processing function with path tracking
ProcessField = (fieldName as text, fieldValue as any, currentPath as text) as record =>
let
fieldPath = if currentPath = "" then fieldName else currentPath & "." & fieldName
in
if IsExcludedPath(fieldPath) then
[]
else if Type.Is(Value.Type(fieldValue), type record) then
if Record.HasFields(fieldValue, {"name", "value"}) then
ProcessNameValueObject(fieldValue)
else if HasDirectKeyValuePattern(fieldValue) then
ProcessDirectKeyValueObject(fieldValue)
else if IsNestedContainer(fieldValue) then
// recursive call for nested containers
@ProcessRecord(fieldValue, fieldPath)
else
// unknown record type, skip
[]
else
// primitive value - check if should be included
if ShouldIncludeKey(fieldName) then
Record.FromList({fieldValue}, {fieldName})
else
[],
// process entire record recursively
ProcessRecord = (record as record, currentPath as text) as record =>
let
// assert that input is a record
_ = if not Value.Is(record, type record) then
error [
Reason = "Invalid Record Type",
Message = "Expected record for processing, but received: " & Text.From(Value.Type(record))
]
else
null,
ProcessedFields = List.Transform(
Record.FieldNames(record),
(fieldName) => ProcessField(fieldName, Record.Field(record, fieldName), currentPath)
),
FilteredFields = List.Select(ProcessedFields, (rec) => Record.FieldCount(rec) > 0),
CombinedRecord = SafeRecordCombine(FilteredFields)
in
CombinedRecord,
// assert that input is a record before processing
_ = if not Value.Is(ActualInput, type record) then
error [
Reason = "Invalid Input Type",
Message = "Input must be a record, but received: " & Text.From(Value.Type(ActualInput))
]
else
null,
// start processing from root
Result = ProcessRecord(ActualInput, "")
in
Result
@@ -1,5 +1,5 @@
(url as text) as list =>
let
try let
// Import required functions
GetModel = Extension.LoadFunction("GetModel.pqm"),
Parser = Extension.LoadFunction("Parser.pqm"),
@@ -47,6 +47,7 @@
SourceApplication = modelInfo[sourceApplication],
Token = apiKey,
Version = connectorVersion,
VersionId = parsedUrl[versionId],
WorkspaceId = workspaceInfo[workspaceId],
WorkspaceName = workspaceInfo[workspaceName],
WorkspaceLogo = workspaceInfo[workspaceLogo],
@@ -70,4 +71,10 @@
JsonResponse = Json.Document(Response)
in
JsonResponse
JsonResponse
otherwise
error [
Reason = "Desktop Service Not Available",
Message = "Cannot connect to Speckle Desktop Service. Please ensure the Desktop Service is running and try again.",
Detail = "The Speckle Desktop Service must be running to load data from Speckle. Please start the Desktop Service application and refresh your data connection."
]
@@ -0,0 +1,31 @@
// Expands a record column in a table, adding new columns for each field in the record.
// If UseCombinedNames is true, columns are named as ColumnName.FieldName, otherwise just FieldName.
// If FieldNames is provided (list), only those fields are expanded.
(table as table, columnName as text, optional FieldNames as list, optional UseCombinedNames as logical) as table =>
let
useCombined = if UseCombinedNames = null then false else UseCombinedNames,
// Determine which field names to expand
allFieldNames = if FieldNames <> null then FieldNames else List.Distinct(
List.Combine(
List.Transform(
Table.Column(table, columnName),
each if _ is record then Record.FieldNames(_) else {}
)
)
),
// Add each field as a new column
addColumns = List.Accumulate(
allFieldNames,
table,
(state, field) =>
Table.AddColumn(
state,
if useCombined then columnName & "." & field else field,
(row) =>
if Record.HasFields(row, columnName) and Record.Field(row, columnName) is record and Record.HasFields(Record.Field(row, columnName), field)
then Record.Field(Record.Field(row, columnName), field)
else null
)
)
in
addColumns
+6
View File
@@ -89,6 +89,9 @@
"properties": {
"defaultViewMode": {
"type": { "text": true }
},
"navbarHidden": {
"type": { "bool": true }
}
}
},
@@ -102,6 +105,9 @@
},
"isGhost": {
"type": { "bool": true }
},
"zoomOnFilter": {
"type": { "bool": true }
}
}
},
+5 -4
View File
@@ -5367,9 +5367,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001689",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001689.tgz",
"integrity": "sha512-CmeR2VBycfa+5/jOfnp/NpWPGd06nf1XYiefUvhXFfZE4GkRc9jv+eGPS4nT558WS/8lYCzV8SlANCIPvbWP1g==",
"version": "1.0.30001726",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001726.tgz",
"integrity": "sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw==",
"funding": [
{
"type": "opencollective",
@@ -5383,7 +5383,8 @@
"type": "github",
"url": "https://github.com/sponsors/ai"
}
]
],
"license": "CC-BY-4.0"
},
"node_modules/chai": {
"version": "5.1.2",
@@ -5,6 +5,19 @@
<ViewerControlsButtonToggle flat tooltip="Zoom extends" @click="onZoomExtentsClicked">
<ArrowsPointingOutIcon class="h-4 w-4 md:h-5 md:w-5" />
</ViewerControlsButtonToggle>
<!-- Zoom on Filter -->
<ViewerControlsButtonToggle
:tooltip="
visualStore.isZoomOnFilterActive
? 'Move camera on filter'
: 'Keep camera position on filter'
"
flat
@click="toggleZoomOnFilter"
>
<ZoomToFit v-if="visualStore.isZoomOnFilterActive" class="h-5 w-5" />
<ZoomToFit v-else class="h-5 w-5 opacity-30" />
</ViewerControlsButtonToggle>
<!-- Ghost / Hidden -->
<ViewerControlsButtonToggle
:tooltip="
@@ -65,6 +78,7 @@ import Perspective from '../components/global/icon/Perspective.vue'
import PerspectiveMore from '../components/global/icon/PerspectiveMore.vue'
import Ghost from '../components/global/icon/Ghost.vue'
import ZoomToFit from '../components/global/icon/ZoomToFit.vue'
const visualStore = useVisualStore()
@@ -111,6 +125,11 @@ const toggleGhostHidden = () => {
visualStore.writeIsGhostToFile()
}
const toggleZoomOnFilter = () => {
visualStore.setIsZoomOnFilterActive(!visualStore.isZoomOnFilterActive)
visualStore.writeZoomOnFilterToFile()
}
const viewModesOpen = computed({
get: () => activeControl.value === 'viewModes',
set: (value) => {
@@ -2,7 +2,7 @@
<div class="border">
<transition name="slide-fade">
<nav
v-show="!isNavbarCollapsed"
v-show="!visualStore.isNavbarHidden"
class="fixed top-0 h-9 flex items-center bg-foundation border border-outline-2 w-full transition z-20 cursor-default"
>
<div class="flex items-center transition-all justify-between w-full">
@@ -46,7 +46,7 @@
<button
class="text-gray-400 hover:text-gray-700 transition"
title="Hide navbar"
@click="isNavbarCollapsed = true"
@click="visualStore.toggleNavbar()"
>
<ChevronUpIcon class="w-4 h-4" />
</button>
@@ -58,17 +58,17 @@
<div
v-if="!isInteractive"
class="absolute left-1/2 -translate-x-1/2 z-20 bg-white bg-opacity-70 text-black text-center text-xs px-4 py-1 rounded shadow font-medium cursor-default transition-all duration-300"
:class="isNavbarCollapsed ? 'top-1' : 'top-11'"
:class="visualStore.isNavbarHidden ? 'top-1' : 'top-11'"
>
<strong>Object IDs</strong>
field is needed for interactivity with other visuals.
</div>
<div v-if="isNavbarCollapsed" class="fixed top-0 right-0 z-20">
<div v-if="visualStore.isNavbarHidden" class="fixed top-0 right-0 z-20">
<button
class="transition opacity-50 hover:opacity-100"
title="Show navbar"
@click="isNavbarCollapsed = false"
@click="visualStore.toggleNavbar()"
>
<ChevronDownIcon class="w-4 h-4 text-gray-400" />
</button>
@@ -76,7 +76,7 @@
<transition name="slide-left">
<ViewerControls
v-show="!isNavbarCollapsed"
v-show="!visualStore.isNavbarHidden"
v-model:section-box="bboxActive"
:views="views"
class="fixed top-11 left-2 z-30"
@@ -152,8 +152,6 @@ const container = ref<HTMLElement>()
let bboxActive = ref(false)
let views: Ref<SpeckleView[]> = ref([])
const isNavbarCollapsed = ref(false)
const isInteractive = computed(
() => visualStore.fieldInputState.rootObjectId && visualStore.fieldInputState.objectIds
)
@@ -164,6 +162,10 @@ onMounted(async () => {
console.log('Viewer Wrapper mounted')
viewerHandler = new ViewerHandler()
await viewerHandler.init(container.value)
// Set up event listener for object clicks from the FilteredSelectionExtension
viewerHandler.emitter.on('objectClicked', handleObjectClicked)
visualStore.setViewerEmitter(viewerHandler.emit)
})
@@ -171,43 +173,59 @@ onBeforeUnmount(async () => {
await viewerHandler.dispose()
})
function isMultiSelect(e: MouseEvent) {
if (!e) return false
if (currentOS === OS.MacOS) return e.metaKey || e.shiftKey
else return e.ctrlKey || e.shiftKey
}
async function onCanvasClick(ev: MouseEvent) {
async function handleObjectClicked(hit: any, isMultiSelect: boolean, mouseEvent?: PointerEvent) {
// Skip if dragging occurred
if (dragged.value) return
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
const multi = isMultiSelect(ev)
const hit = intersectResult?.hit
console.log('🎯 Object clicked in ViewerWrapper:', hit, isMultiSelect)
if (hit) {
visualStore.setPostClickSkipNeeded(true)
const id = hit.object.id as string
if (multi || !selectionHandler.isSelected(id)) {
await selectionHandler.select(id, multi)
if (isMultiSelect || !selectionHandler.isSelected(id)) {
await selectionHandler.select(id, isMultiSelect)
}
tooltipHandler.show(hit, { x: ev.clientX, y: ev.clientY })
// Show tooltip if we have mouse coordinates
if (mouseEvent) {
tooltipHandler.show(hit, { x: mouseEvent.clientX, y: mouseEvent.clientY })
}
const selection = selectionHandler.getCurrentSelection()
const ids = selection.map((s) => s.id)
await viewerHandler.selectObjects(ids)
} else {
visualStore.setPostClickSkipNeeded(false)
tooltipHandler.hide()
if (!multi) {
if (!isMultiSelect) {
selectionHandler.clear()
await viewerHandler.selectObjects(null)
}
}
}
function onCanvasClick(ev: MouseEvent) {
// This click handler allows the viewer's built-in input system to handle clicks
// The viewer will emit ViewerEvent.ObjectClicked events which the SelectionExtension handles
console.log('🖱️ Canvas click detected:', ev.clientX, ev.clientY)
// Let the event propagate to the viewer's input system
// The viewer should handle the click and emit ViewerEvent.ObjectClicked
}
async function onCanvasAuxClick(ev: MouseEvent) {
if (ev.button != 2 || dragged.value) return
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
await selectionHandler.showContextMenu(ev, intersectResult?.hit)
if (ev.button !== 2 || dragged.value) return
// For right-clicks, we need to get the object at the click position
// Since FilteredSelectionExtension doesn't handle right-clicks, we'll ask it for current selection
const selectedObjects = viewerHandler.selection.getSelectedObjects()
const hit = selectedObjects.length > 0 ? {
guid: selectedObjects[0].id,
object: selectedObjects[0],
point: { x: 0, y: 0, z: 0 } // We don't have exact point for context menu
} : null
await selectionHandler.showContextMenu(ev, hit)
}
</script>
@@ -0,0 +1,24 @@
<template>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3.75 3.75V8.25M3.75 3.75H8.25M3.75 3.75L9 9M20.25 3.75H15.75M20.25 3.75V8.25M20.25 3.75L15 9"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M15.75 15.4028L18.8093 12.3435C18.8772 12.2756 18.9638 12.2294 19.0581 12.2107C19.1523 12.1919 19.25 12.2016 19.3387 12.2383C19.4275 12.2751 19.5034 12.3373 19.5568 12.4172C19.6102 12.4971 19.6388 12.591 19.6389 12.687V20.063C19.6388 20.159 19.6102 20.2529 19.5568 20.3328C19.5034 20.4127 19.4275 20.4749 19.3387 20.5117C19.25 20.5484 19.1523 20.5581 19.0581 20.5393C18.9638 20.5206 18.8772 20.4744 18.8093 20.4065L15.75 17.3472M8.45833 20.75H14.2917C14.6784 20.75 15.0494 20.5964 15.3229 20.3229C15.5964 20.0494 15.75 19.6784 15.75 19.2917V13.4583C15.75 13.0716 15.5964 12.7006 15.3229 12.4271C15.0494 12.1536 14.6784 12 14.2917 12H8.45833C8.07156 12 7.70063 12.1536 7.42714 12.4271C7.15365 12.7006 7 13.0716 7 13.4583V19.2917C7 19.6784 7.15365 20.0494 7.42714 20.3229C7.70063 20.5964 8.07156 20.75 8.45833 20.75Z"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
@@ -0,0 +1,155 @@
import {
CameraController,
FilteringExtension,
NodeRenderView,
SelectionEvent,
SelectionExtension,
TreeNode,
ObjectLayers,
IViewer,
ExtendedIntersection
} from '@speckle/viewer'
import { Vector2, Vector3 } from 'three'
export enum FilteredSelectionEvent {
FilteredObjectClicked = 'filtered-object-clicked'
}
export interface FilteredSelectionEventPayload {
[FilteredSelectionEvent.FilteredObjectClicked]: SelectionEvent | null
}
export class FilteredSelectionExtension extends SelectionExtension {
// We're adding the Filtering Extension
public get inject(): Array<new (viewer: IViewer, ...args: any[]) => any> {
return [...super.inject, FilteringExtension]
}
public constructor(
viewer: IViewer,
protected cameraProvider: CameraController,
protected filtering: FilteringExtension
) {
super(viewer, cameraProvider)
}
public on<T extends FilteredSelectionEvent>(
eventType: T,
listener: (arg: FilteredSelectionEventPayload[T]) => void
): void {
super.on(eventType, listener)
}
protected isVisibleForSelection(id: string): boolean
protected isVisibleForSelection(rv: NodeRenderView): boolean
protected isVisibleForSelection(input: string | NodeRenderView): boolean {
if (input instanceof NodeRenderView) return this.isVisibleForSelectionRv(input)
else if (typeof input === 'string') return this.isVisibleForSelectionId(input)
return false
}
protected isVisibleForSelectionId(id: string): boolean {
// The current filtering state
const filteringState = this.filtering.filteringState
// If there are no isolated objects, all objects are visible for selection
if (!filteringState.isolatedObjects || filteringState.isolatedObjects.length === 0) {
return true
}
// If there are isolated objects, only those objects are visible for selection
return filteringState.isolatedObjects.includes(id)
}
protected isVisibleForSelectionRv(rv: NodeRenderView): boolean {
// The current filtering state
const filteringState = this.filtering.filteringState
// If there are no isolated objects, all objects are visible for selection
if (!filteringState.isolatedObjects || filteringState.isolatedObjects.length === 0) {
return true
}
// Check if this render view belongs to any of the isolated objects
for (let k = 0; k < filteringState.isolatedObjects.length; k++) {
const rvs = this.viewer
.getWorldTree()
.getRenderTree()
.getRenderViewsForNodeId(filteringState.isolatedObjects[k])
if (rvs.includes(rv)) return true
}
return false
}
protected onObjectClicked(selection: SelectionEvent | null) {
console.log('🎯 FilteredSelectionExtension.onObjectClicked called with:', selection)
if (!selection) {
console.log('🎯 No selection, calling super with null')
super.onObjectClicked(selection)
return
}
const filteredHits = []
const filteredSelection = selection
? {
event: selection.event,
hits: filteredHits,
multiple: selection.multiple
}
: null
if (filteredSelection) {
for (const hit of selection.hits) {
console.log('🎯 Checking hit:', hit.node.model.id, 'isVisible:', this.isVisibleForSelection(hit.node.model.id))
if (this.isVisibleForSelection(hit.node.model.id)) {
filteredHits.push(hit)
}
}
}
console.log('🎯 Filtered hits:', filteredHits.length)
// Call base class with the filtered selection
if (filteredSelection && filteredSelection.hits.length) {
super.onObjectClicked(filteredSelection)
this.emit(FilteredSelectionEvent.FilteredObjectClicked, filteredSelection)
} else {
// If no valid hits, treat as empty selection
super.onObjectClicked(null)
}
}
protected onPointerMove(e: Vector2 & { event: Event }) {
if (!this._enabled) return
const camera = this.viewer.getRenderer().renderingCamera
if (!camera) return
if (!this.options.hoverMaterialData) return
const result =
(this.viewer
.getRenderer()
.intersections.intersect(
this.viewer.getRenderer().scene,
camera,
e,
[
ObjectLayers.STREAM_CONTENT_MESH,
ObjectLayers.STREAM_CONTENT_POINT,
ObjectLayers.STREAM_CONTENT_LINE,
ObjectLayers.STREAM_CONTENT_TEXT
],
true,
this.viewer.getRenderer().clippingVolume
) as ExtendedIntersection[]) || []
let rv = null
for (let k = 0; k < result.length; k++) {
rv = this.viewer.getRenderer().renderViewFromIntersection(result[k])
if (this.isVisibleForSelection(rv)) break
else rv = null
}
this.applyHover(rv)
}
}
+70 -57
View File
@@ -1,7 +1,6 @@
import {
DefaultViewerParams,
FilteringState,
IntersectionQuery,
CameraController,
CanonicalView,
ViewModes,
@@ -13,8 +12,10 @@ import {
SelectionExtension,
FilteringExtension,
UpdateFlags,
ViewerEvent
ViewerEvent,
SelectionEvent
} from '@speckle/viewer'
import { FilteredSelectionExtension, FilteredSelectionEvent } from '@src/extensions/FilteredSelectionExtension'
import { SpeckleObjectsOfflineLoader } from '@src/laoder/SpeckleObjectsOfflineLoader'
import { useVisualStore } from '@src/store/visualStore'
import { Tracker } from '@src/utils/mixpanel'
@@ -37,8 +38,8 @@ export interface Hit {
export interface IViewerEvents {
ping: (message: string) => void
setSelection: (objectIds: string[]) => void
resetFilter: (objectIds: string[], ghost: boolean) => void
filterSelection: (objectIds: string[], ghost: boolean) => void
resetFilter: (objectIds: string[], ghost: boolean, zoom: boolean) => void
filterSelection: (objectIds: string[], ghost: boolean, zoom: boolean) => void
setViewMode: (viewMode: ViewMode) => void
colorObjectsByGroup: (
colorById: {
@@ -52,6 +53,8 @@ export interface IViewerEvents {
toggleProjection: () => void
toggleGhostHidden: (ghost: boolean) => void
loadObjects: (objects: object[]) => void
objectsLoaded: () => void
objectClicked: (hit: Hit | null, isMultiSelect: boolean, mouseEvent?: PointerEvent) => void
}
export type ColorBy = {
@@ -64,7 +67,7 @@ export class ViewerHandler {
public viewer: Viewer
public cameraControls: CameraController
public filtering: FilteringExtension
public selection: SelectionExtension
public selection: FilteredSelectionExtension
private filteringState: FilteringState
constructor() {
@@ -81,6 +84,7 @@ export class ViewerHandler {
this.emitter.on('zoomExtends', this.zoomExtends)
this.emitter.on('zoomObjects', this.zoomObjects)
this.emitter.on('loadObjects', this.loadObjects)
this.emitter.on('objectsLoaded', this.handleObjectsLoaded)
this.emitter.on('toggleProjection', this.toggleProjection)
this.emitter.on('toggleGhostHidden', this.toggleGhostHidden)
}
@@ -89,7 +93,7 @@ export class ViewerHandler {
this.viewer = await createViewer(parent)
this.cameraControls = this.viewer.getExtension(CameraController)
this.filtering = this.viewer.getExtension(FilteringExtension)
this.selection = this.viewer.getExtension(SelectionExtension)
this.selection = this.viewer.getExtension(FilteredSelectionExtension)
const store = useVisualStore()
if (store.isOrthoProjection) {
@@ -99,6 +103,14 @@ export class ViewerHandler {
this.viewer.on(ViewerEvent.LoadComplete, (arg: string) => {
store.clearLoadingProgress()
})
// Set up event listener for viewer's built-in object clicked events
this.viewer.on(ViewerEvent.ObjectClicked, (selection: SelectionEvent | null) => {
console.log('🎯 Viewer ObjectClicked event received:', selection)
})
// Set up event listener for filtered selection events
this.selection.on(FilteredSelectionEvent.FilteredObjectClicked, this.handleFilteredSelection)
}
emit<E extends keyof IViewerEvents>(event: E, ...payload: Parameters<IViewerEvents[E]>): void {
@@ -147,20 +159,24 @@ export class ViewerHandler {
}
}
public filterSelection = (objectIds: string[], ghost: boolean) => {
public filterSelection = (objectIds: string[], ghost: boolean, zoom: boolean = true) => {
console.log('🔗 Handling filterSelection inside ViewerHandler')
if (objectIds) {
this.unIsolateObjects()
this.filteringState = this.filtering.isolateObjects(objectIds, 'powerbi', true, ghost)
this.zoomObjects(objectIds, true)
if (zoom) {
this.zoomObjects(objectIds, true)
}
}
}
public resetFilter = (objectIds: string[], ghost: boolean) => {
public resetFilter = (objectIds: string[], ghost: boolean, zoom: boolean = true) => {
console.log('🔗 Handling filterSelection inside ViewerHandler')
if (objectIds) {
this.isolateObjects(objectIds, ghost)
this.zoomObjects(objectIds, true)
if (zoom) {
this.zoomObjects(objectIds, true)
}
}
}
@@ -192,25 +208,7 @@ export class ViewerHandler {
}
}
public intersect = (coords: { x: number; y: number }) => {
const point = this.viewer.Utils.screenToNDC(coords.x, coords.y)
const intQuery: IntersectionQuery = {
operation: 'Pick',
point
}
const res = this.viewer.query(intQuery)
if (!res) {
this.selection.clearSelection()
return
}
return {
hit: this.pickViewableHit(res.objects),
objects: res.objects
}
}
public loadObjects = async (modelObjects: object[][]) => {
await this.viewer.unloadAll()
@@ -219,7 +217,8 @@ export class ViewerHandler {
const store = useVisualStore()
const speckleViews = []
modelObjects.forEach(async (objects) => {
// Use for...of loop to properly handle async operations
for (const objects of modelObjects) {
//@ts-ignore
const loader = new SpeckleObjectsOfflineLoader(this.viewer.getWorldTree(), objects)
@@ -232,7 +231,7 @@ export class ViewerHandler {
// Since you are setting another camera position, maybe you want the second argument to false
await this.viewer.loadObject(loader, true)
this.viewer.getRenderer().shadowcatcher.shadowcatcherMesh.visible = false // works fine only right after loadObjects
})
}
store.setSpeckleViews(speckleViews)
if (store.defaultViewModeInFile) {
@@ -241,7 +240,8 @@ export class ViewerHandler {
Tracker.dataLoaded({
sourceHostApp: store.receiveInfo.sourceApplication,
workspace_id: store.receiveInfo.workspaceId
workspace_id: store.receiveInfo.workspaceId,
core_version: store.receiveInfo.version
})
if (store.cameraPosition) {
const position = new Vector3(
@@ -256,38 +256,51 @@ export class ViewerHandler {
)
this.cameraControls.setCameraView({ position, target }, true)
}
// Emit objects loaded event to trigger update
this.emit('objectsLoaded')
}
private handlePing = (message: string) => {
console.log(message)
}
private pickViewableHit(hits: Hit[]): Hit | null {
// The current filtering state
const filteringState = this.filtering.filteringState
// Are there any objects isolated?
const hasIsolatedObjects =
!!filteringState.isolatedObjects && filteringState.isolatedObjects.length !== 0
// Are there any objects hidden?
const hasHiddenObjects =
!!filteringState.hiddenObjects && filteringState.hiddenObjects.length !== 0
// No isolated or hidden objects? Return the first hit
if (hasIsolatedObjects && !hasHiddenObjects) {
return hits.find((h) => filteringState.isolatedObjects.includes(h.guid))
}
for (let k = 0; k < hits.length; k++) {
/** Return the first one that's not hidden or isolated. */
if (
hasIsolatedObjects &&
filteringState.isolatedObjects?.includes(hits[k].guid) &&
hasHiddenObjects &&
filteringState.hiddenObjects?.includes(hits[k].guid)
)
return hits[k]
}
private handleObjectsLoaded = () => {
console.log('🎯 Objects loaded - triggering update')
const store = useVisualStore()
// Handle state restoration after objects are loaded
store.handleObjectsLoadedComplete()
}
private handleFilteredSelection = (selection: SelectionEvent | null) => {
console.log('🎯 Filtered selection event received:', selection)
let hit: Hit | null = null
let isMultiSelect = false
let mouseEvent: PointerEvent | undefined = undefined
if (selection && selection.hits.length > 0) {
// Convert the first hit to the Hit format expected by ViewerWrapper
const firstHit = selection.hits[0]
hit = {
guid: firstHit.node.model.id,
object: firstHit.node.model.raw,
point: {
x: firstHit.point.x,
y: firstHit.point.y,
z: firstHit.point.z
}
}
isMultiSelect = selection.multiple
mouseEvent = selection.event
}
// Emit the objectClicked event for ViewerWrapper to handle
this.emit('objectClicked', hit, isMultiSelect, mouseEvent)
}
public dispose() {
this.viewer.getExtension(CameraController).dispose()
this.viewer.dispose()
@@ -303,11 +316,11 @@ const createViewer = async (parent: HTMLElement): Promise<Viewer> => {
await viewer.init()
viewer.createExtension(HybridCameraController) // camera controller
viewer.createExtension(SelectionExtension) // selection helper
viewer.createExtension(FilteringExtension) // filtering - must be created before FilteredSelectionExtension
viewer.createExtension(FilteredSelectionExtension) // filtered selection helper - depends on FilteringExtension
// viewer.createExtension(SectionTool) // section tool, possibly not needed for now?
// viewer.createExtension(SectionOutlines) // section tool, possibly not needed for now?
// viewer.createExtension(MeasurementsExtension) // measurements, possibly not needed for now?
viewer.createExtension(FilteringExtension) // filtering
viewer.createExtension(ViewModes) // view modes
console.log('🎥 Viewer is created!')
+102 -4
View File
@@ -35,6 +35,8 @@ export const useVisualStore = defineStore('visualStore', () => {
const isBrandingHidden = ref<boolean>(false)
const isOrthoProjection = ref<boolean>(false)
const isGhostActive = ref<boolean>(true)
const isNavbarHidden = ref<boolean>(false)
const isZoomOnFilterActive = ref<boolean>(true)
const commonError = ref<string>(undefined)
@@ -164,11 +166,17 @@ export const useVisualStore = defineStore('visualStore', () => {
if (dataInput.value.selectedIds.length > 0) {
isFilterActive.value = true
viewerEmit.value('filterSelection', dataInput.value.selectedIds, isGhostActive.value)
viewerEmit.value('filterSelection', dataInput.value.selectedIds, isGhostActive.value, isZoomOnFilterActive.value)
} else {
isFilterActive.value = false
latestColorBy.value = dataInput.value.colorByIds
viewerEmit.value('resetFilter', dataInput.value.objectIds, isGhostActive.value)
// Only apply filtering if object IDs are available, otherwise show all objects normally
if (fieldInputState.value.objectIds && dataInput.value.objectIds && dataInput.value.objectIds.length > 0) {
viewerEmit.value('resetFilter', dataInput.value.objectIds, isGhostActive.value, isZoomOnFilterActive.value)
} else {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
}
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
@@ -240,6 +248,22 @@ export const useVisualStore = defineStore('visualStore', () => {
})
}
const writeZoomOnFilterToFile = () => {
// NOTE: need skipping the update function, it resets the viewer state unneccessarily.
postFileSaveSkipNeeded.value = true
host.value.persistProperties({
merge: [
{
objectName: 'camera',
properties: {
zoomOnFilter: isZoomOnFilterActive.value
},
selector: null
}
]
})
}
const writeViewModeToFile = (viewMode: ViewMode) => {
// NOTE: need skipping the update function, it resets the viewer state unneccessarily.
postFileSaveSkipNeeded.value = true
@@ -272,6 +296,22 @@ export const useVisualStore = defineStore('visualStore', () => {
})
}
const writeNavbarVisibilityToFile = (navbarHidden: boolean) => {
// NOTE: need skipping the update function, it resets the viewer state unneccessarily.
postFileSaveSkipNeeded.value = true
host.value.persistProperties({
merge: [
{
objectName: 'viewMode',
properties: {
navbarHidden: navbarHidden
},
selector: null
}
]
})
}
const writeCameraPositionToFile = (position: Vector3, target: Vector3) => {
// NOTE: need skipping the update function, it resets the viewer state unneccessarily.
postFileSaveSkipNeeded.value = true
@@ -313,6 +353,15 @@ export const useVisualStore = defineStore('visualStore', () => {
isBrandingHidden.value = val
}
const setNavbarHidden = (val: boolean) => {
isNavbarHidden.value = val
}
const toggleNavbar = () => {
isNavbarHidden.value = !isNavbarHidden.value
writeNavbarVisibilityToFile(isNavbarHidden.value)
}
const setIsOrthoProjection = (val: boolean) => {
isOrthoProjection.value = val
}
@@ -321,6 +370,10 @@ export const useVisualStore = defineStore('visualStore', () => {
isGhostActive.value = val
}
const setIsZoomOnFilterActive = (val: boolean) => {
isZoomOnFilterActive.value = val
}
const setPostFileSaveSkipNeeded = (newValue: boolean) => (postFileSaveSkipNeeded.value = newValue)
const setPostClickSkipNeeded = (newValue: boolean) => (postClickSkipNeeded.value = newValue)
@@ -332,7 +385,13 @@ export const useVisualStore = defineStore('visualStore', () => {
(formattingSettings.value = newFormattingSettings)
const resetFilters = () => {
viewerEmit.value('resetFilter', dataInput.value.objectIds, isGhostActive.value)
// Only apply filtering if object IDs are available, otherwise show all objects normally
if (fieldInputState.value.objectIds && dataInput.value && dataInput.value.objectIds && dataInput.value.objectIds.length > 0) {
viewerEmit.value('resetFilter', dataInput.value.objectIds, isGhostActive.value, isZoomOnFilterActive.value)
} else {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
if (latestColorBy.value !== null) {
viewerEmit.value('colorObjectsByGroup', latestColorBy.value)
}
@@ -347,6 +406,37 @@ export const useVisualStore = defineStore('visualStore', () => {
commonError.value = error
}
const handleObjectsLoadedComplete = () => {
console.log('🔄 Objects loaded - handling state restoration')
// If we have current data input with selections, restore them
if (dataInput.value) {
console.log('🔄 Restoring selection state after object load')
// Restore selection filters if they exist
if (dataInput.value.selectedIds.length > 0) {
isFilterActive.value = true
viewerEmit.value('filterSelection', dataInput.value.selectedIds, isGhostActive.value, isZoomOnFilterActive.value)
} else {
isFilterActive.value = false
latestColorBy.value = dataInput.value.colorByIds
// Only apply filtering if object IDs are available, otherwise show all objects normally
if (fieldInputState.value.objectIds && dataInput.value.objectIds && dataInput.value.objectIds.length > 0) {
viewerEmit.value('resetFilter', dataInput.value.objectIds, isGhostActive.value, isZoomOnFilterActive.value)
} else {
// No object IDs provided - show all objects without any filtering
viewerEmit.value('unIsolateObjects')
}
}
// Restore color grouping
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
// Trigger host data refresh to synchronize with Power BI
host.value.refreshHostData()
}
return {
host,
receiveInfo,
@@ -373,6 +463,8 @@ export const useVisualStore = defineStore('visualStore', () => {
isBrandingHidden,
isOrthoProjection,
isGhostActive,
isNavbarHidden,
isZoomOnFilterActive,
latestAvailableVersion,
isConnectorUpToDate,
commonError,
@@ -380,8 +472,10 @@ export const useVisualStore = defineStore('visualStore', () => {
setLatestAvailableVersion,
setIsOrthoProjection,
setIsGhost,
setIsZoomOnFilterActive,
setFormattingSettings,
setBrandingHidden,
setNavbarHidden,
setPostClickSkipNeeded,
setPostFileSaveSkipNeeded,
setCameraPositionInFile,
@@ -395,11 +489,14 @@ export const useVisualStore = defineStore('visualStore', () => {
writeObjectsToFile,
writeCameraViewToFile,
writeIsGhostToFile,
writeZoomOnFilterToFile,
writeIsOrthoToFile,
writeViewModeToFile,
writeCameraPositionToFile,
writeHideBrandingToFile,
writeNavbarVisibilityToFile,
toggleBranding,
toggleNavbar,
setViewerEmitter,
setDataInput,
setFieldInputState,
@@ -409,6 +506,7 @@ export const useVisualStore = defineStore('visualStore', () => {
clearLoadingProgress,
setIsLoadingFromFile,
resetFilters,
downloadLatestVersion
downloadLatestVersion,
handleObjectsLoadedComplete
}
})
@@ -296,9 +296,14 @@ async function fetchStreamedDataForModel(
const endObjectCleanup = performance.now()
console.log(`Objects cleaned up in: ${(endObjectCleanup - startObjectCleanup) / 1000} s`)
const sizeInBytes = new TextEncoder().encode(JSON.stringify(objects)).length
const sizeInMB = sizeInBytes / (1024 * 1024)
console.log(`Size of objects: ${sizeInMB} MB`)
try {
const sizeInBytes = new TextEncoder().encode(JSON.stringify(objects)).length
const sizeInMB = sizeInBytes / (1024 * 1024)
console.log(`Size of objects: ${sizeInMB} MB`)
} catch (error) {
console.log("Can't calculate the size of the model")
console.log(error)
}
return objects
} catch (error) {
+2 -1
View File
@@ -31,7 +31,8 @@ export class Tracker {
// eslint-disable-next-line camelcase
server_id: hashedServer,
email: receiveInfo.userEmail,
isAnonymous: receiveInfo.userEmail === ''
isAnonymous: receiveInfo.userEmail === '',
core_version: receiveInfo.version
}
}
+1 -12
View File
@@ -1,4 +1,3 @@
import { FilteringState } from '@speckle/viewer'
import { OrthographicCamera, PerspectiveCamera } from 'three'
export function projectToScreen(cam: OrthographicCamera | PerspectiveCamera, loc) {
@@ -16,17 +15,7 @@ export interface Hit {
object?: Record<string, unknown>
point: { x: number; y: number; z: number }
}
export function pickViewableHit(hits: Hit[], state: FilteringState): Hit | null {
let hit = null
if (state.isolatedObjects) {
// Find the first hit contained in the isolated objects
hit = hits.find((hit) => {
const hitId = hit.object.id as string
return state.isolatedObjects.includes(hitId)
})
}
return hit
}
export const createViewerContainerDiv = (parent: HTMLElement) => {
const container = parent.appendChild(document.createElement('div'))
+22
View File
@@ -148,6 +148,18 @@ export class Visual implements IVisual {
)
}
if (options.dataViews[0].metadata.objects.viewMode?.navbarHidden as boolean) {
console.log(
`Navbar Hidden: ${
options.dataViews[0].metadata.objects.viewMode?.navbarHidden as boolean
}`
)
visualStore.setNavbarHidden(
options.dataViews[0].metadata.objects.viewMode?.navbarHidden as boolean
)
}
if (options.dataViews[0].metadata.objects.cameraPosition?.positionX as string) {
console.log(`Stored camera position is found`)
visualStore.setCameraPositionInFile([
@@ -184,6 +196,16 @@ export class Visual implements IVisual {
)
}
if (camera && 'zoomOnFilter' in camera) {
console.log(
`Zoom on filter?: ${options.dataViews[0].metadata.objects.camera?.zoomOnFilter as boolean}`
)
visualStore.setIsZoomOnFilterActive(
options.dataViews[0].metadata.objects.camera?.zoomOnFilter as boolean
)
}
// get receive info from file for mixpanel
try {
const receiveInfoFromFile = JSON.parse(