Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions packages/frontend-2/lib/viewer/composables/anchorPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ export function useViewerAnchoredPointCalculator(params: {
point: target,
operation: 'Project'
})
inFrustum ||= targetProjectionResult.inFrustum
/** If not in camera's frustum, don't bother projecting */
if (inFrustum)
targetLoc = viewer.Utils.NDCToScreen(
targetProjectionResult.x,
targetProjectionResult.y,
parentEl.value.clientWidth,
parentEl.value.clientHeight
)
if (targetProjectionResult) {
inFrustum ||= targetProjectionResult.inFrustum
/** If not in camera's frustum, don't bother projecting */
if (inFrustum)
targetLoc = viewer.Utils.NDCToScreen(
targetProjectionResult.x,
targetProjectionResult.y,
parentEl.value.clientWidth,
parentEl.value.clientHeight
)
}

// round it out
if (targetLoc) {
Expand All @@ -63,7 +65,9 @@ export function useViewerAnchoredPointCalculator(params: {
tolerance: 0.001,
operation: 'Occlusion'
})
isOccluded = !!targetOcclusionRes.objects?.length
if (targetOcclusionRes) {
isOccluded = !!targetOcclusionRes.objects?.length
}
}

return {
Expand Down
34 changes: 29 additions & 5 deletions packages/frontend-2/lib/viewer/composables/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ import {
DefaultViewerParams,
ViewerEvent,
DefaultLightConfiguration,
LegacyViewer,
FilteringExtension
FilteringExtension,
Viewer,
SelectionExtension,
MeasurementsExtension,
SectionTool,
SectionOutlines,
HybridCameraController,
ExplodeExtension,
DiffExtension,
ViewModes
} from '@speckle/viewer'
import type {
ViewMode,
FilteringState,
SunLightConfiguration,
SpeckleView,
DiffResult,
Viewer,
WorldTree,
VisualDiffMode
} from '@speckle/viewer'
Expand Down Expand Up @@ -140,7 +147,7 @@ export type InjectableViewerState = Readonly<{
/**
* The actual viewer instance
*/
instance: LegacyViewer
instance: Viewer
/**
* Container onto which the Viewer instance is attached
*/
Expand Down Expand Up @@ -453,12 +460,29 @@ function createViewerDataBuilder(params: { viewerDebug: boolean }) {
container.style.width = '100%'
container.style.height = '100%'

const viewer = new LegacyViewer(container, {
const viewer = new Viewer(container, {
...DefaultViewerParams,
verbose: !!(import.meta.client && params.viewerDebug)
})
viewer.createExtension(HybridCameraController)
viewer.createExtension(SelectionExtension)
viewer.createExtension(SectionTool)
viewer.createExtension(SectionOutlines)
viewer.createExtension(MeasurementsExtension)
viewer.createExtension(FilteringExtension)
viewer.createExtension(ExplodeExtension)
viewer.createExtension(DiffExtension)
viewer.createExtension(HighlightExtension)
viewer.createExtension(ViewModes)
viewer.createExtension(PassReader)

/** Workaround so that the frontend comments get section outlines when comment that has sections needs to show at startup */
viewer.on(ViewerEvent.LoadComplete, () => {
const sections = viewer.getExtension(SectionTool)
const sectionOutlines = viewer.getExtension(SectionOutlines)
if (sections?.enabled && sectionOutlines) sectionOutlines.requestUpdate(true)
})

const initPromise = viewer.init()

return {
Expand Down
Loading