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

[#53069] bump xeokit bim viewer version to 2.5.1-beta-18 #14907

Merged
merged 5 commits into from
Apr 18, 2024
Merged
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
842 changes: 824 additions & 18 deletions frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@uirouter/rx": "^1.0.0",
"@vusion/webfonts-generator": "^0.8.0",
"@w11k/ngx-componentdestroyed": "^5.0.2",
"@xeokit/xeokit-bim-viewer": "2.3.10",
"@xeokit/xeokit-bim-viewer": "2.5.1-beta-28",
"autoprefixer": "^10.4.16",
"byte-base64": "^1.1.0",
"chart.js": "4.3.0",
Expand Down
71 changes: 40 additions & 31 deletions frontend/src/app/features/bim/bcf/api/bcf-api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,6 @@
// See COPYRIGHT and LICENSE files for more details.
//++

export type BcfViewpointData = BcfViewpoint&{
components:BcfViewpointVisibility&BcfViewpointSelection
};

export type CreateBcfViewpointData = BcfViewpointData&{
snapshot:{ snapshot_type:string, snapshot_data:string }
};

export interface BcfViewpoint {
index:number|null
guid:string
orthogonal_camera:BcfOrthogonalCamera|null
perspective_camera:BcfPerspectiveCamera|null
lines:BcfLine[]|null
clipping_planes:BcfClippingPlane[]|null
bitmaps:BcfBitmap[]|null
snapshot:{ snapshot_type:string }
}

export interface BcfViewpointVisibility {
visibility:{
default_visibility:boolean
exceptions:BcfComponent[]
view_setup_hints:BcfViewSetupHints|null
}
}

export interface BcfViewpointSelection {
selection:BcfComponent[]
}

export interface BcfComponent {
ifc_guid:string|null
originating_system:string|null
Expand All @@ -69,6 +38,27 @@ export interface BcfViewSetupHints {
openings_visible:boolean
}

export interface BcfColoring {
color:string,
components:BcfComponent[],
}

export interface BcfViewpointColoring {
coloring:BcfColoring[]
}

export interface BcfViewpointSelection {
selection:BcfComponent[]
}

export interface BcfViewpointVisibility {
visibility:{
default_visibility:boolean
exceptions:BcfComponent[]
view_setup_hints:BcfViewSetupHints|null
}
}

export interface BcfOrthogonalCamera {
camera_view_point:{ x:number, y:number, z:number }
camera_direction:{ x:number, y:number, z:number }
Expand Down Expand Up @@ -101,3 +91,22 @@ export interface BcfLine {
start_point:{ x:number, y:number, z:number }
end_point:{ x:number, y:number, z:number }
}

export interface BcfViewpoint {
index:number|null
guid:string
orthogonal_camera:BcfOrthogonalCamera|null
perspective_camera:BcfPerspectiveCamera|null
lines:BcfLine[]|null
clipping_planes:BcfClippingPlane[]|null
bitmaps:BcfBitmap[]|null
snapshot:{ snapshot_type:string }
}

export type BcfViewpointData = BcfViewpoint&{
components:BcfViewpointVisibility&BcfViewpointSelection&BcfViewpointColoring
};

export type CreateBcfViewpointData = BcfViewpointData&{
snapshot:{ snapshot_type:string, snapshot_data:string }
};
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class ViewpointsService {
map(({ viewpoint, selection, visibility }) => {
const data = viewpoint as BcfViewpointData;
data.components = {
coloring: [],
selection: selection.selection,
visibility: visibility.visibility,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
busyModelBackdropElement: this.viewerContainer.nativeElement as HTMLElement,
keyboardEventsElement: this.modelCanvas.nativeElement as HTMLElement,
enableEditModels: manageIfcModelsAllowed,
enableMeasurements: false,
},
this.ifcData.projects,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface XeokitElements {
busyModelBackdropElement:HTMLElement;
enableEditModels?:boolean;
keyboardEventsElement?:HTMLElement;
enableMeasurements?:boolean;
}

/**
Expand Down Expand Up @@ -90,7 +91,7 @@ type Controller = {
*/
type XeokitBimViewer = Controller&{
loadProject:(projectId:string) => void,
saveBCFViewpoint:(options:BCFCreationOptions) => CreateBcfViewpointData,
saveBCFViewpoint:(options:BCFCreationOptions) => unknown,
loadBCFViewpoint:(bcfViewpoint:BcfViewpointData, options:BCFLoadOptions) => void,
setKeyboardEnabled:(enabled:boolean) => true,
destroy:() => void
Expand Down Expand Up @@ -154,9 +155,7 @@ export class IFCViewerService extends ViewerBridgeService {
);

this.httpClient.post(
this.pathHelper.ifcModelsDeletePath(
this.currentProjectService.identifier as string, event.modelId,
),
this.pathHelper.ifcModelsDeletePath(this.currentProjectService.identifier as string, event.modelId),
formData,
)
.subscribe()
Expand Down Expand Up @@ -200,12 +199,35 @@ export class IFCViewerService extends ViewerBridgeService {
}

const opts:BCFCreationOptions = { spacesVisible: true, reverseClippingPlanes: true };
const viewpoint = this.viewer.saveBCFViewpoint(opts);

// The backend rejects viewpoints with bitmaps
viewpoint.bitmaps = null;

return of(viewpoint);
const viewpoint = this.viewer.saveBCFViewpoint(opts) as CreateBcfViewpointData;

// project output of viewer to ensured BCF viewpoint format
const bcfViewpoint:CreateBcfViewpointData = {
// The backend currently rejects viewpoints with bitmaps
bitmaps: null,
clipping_planes: viewpoint.clipping_planes,
index: viewpoint.index,
guid: viewpoint.guid,
components: {
selection: viewpoint.components.selection,
coloring: viewpoint.components.coloring,
visibility: {
default_visibility: viewpoint.components.visibility.default_visibility,
exceptions: viewpoint.components.visibility.exceptions,
view_setup_hints: {
openings_visible: viewpoint.components.visibility.view_setup_hints?.openings_visible || false,
space_boundaries_visible: viewpoint.components.visibility.view_setup_hints?.space_boundaries_visible || false,
spaces_visible: viewpoint.components.visibility.view_setup_hints?.spaces_visible || false,
},
},
},
lines: viewpoint.lines,
orthogonal_camera: viewpoint.orthogonal_camera,
perspective_camera: viewpoint.perspective_camera,
snapshot: viewpoint.snapshot,
};

return of(bcfViewpoint);
}

public showViewpoint(workPackage:WorkPackageResource, index:number):void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ export interface IFCPermissionMap {
manage_bcf:boolean;
}

export interface IFCGonDefinition {
models:IfcModelDefinition[];
shown_models:number[];
projects:IfcProjectDefinition[];
xkt_attachment_ids:{ [id:number]:number };
permissions:IFCPermissionMap;
}

export interface IfcProjectDefinition {
name:string;
id:string;
Expand All @@ -27,12 +19,21 @@ export interface IfcModelDefinition {
default:boolean;
}

export interface IFCGonDefinition {
models:IfcModelDefinition[];
shown_models:number[];
projects:IfcProjectDefinition[];
xkt_attachment_ids:{ [id:number]:number };
permissions:IFCPermissionMap;
}

@Injectable()
export class IfcModelsDataService {
constructor(readonly paths:PathHelperService,
constructor(
readonly paths:PathHelperService,
readonly currentProjectService:CurrentProjectService,
readonly gon:GonService) {
}
readonly gon:GonService,
) { }

public get models():IfcModelDefinition[] {
return this.gonIFC.models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
color: var(--main-menu-font-color)
font-weight: var(--base-text-weight-bold)
padding: 0 5px !important
max-width: unset !important

&:hover
border-bottom: 2px solid white
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
@include icon-mixin-cursor
.fa-th::before
@include icon-mixin-menu
.fa-codepen::before
@include icon-mixin-view-model
.fa-object-group::before
@include icon-mixin-image2
.fa-ruler::before
@include icon-mixin-to-fullscreen
.fa-chevron-left::before
@include icon-mixin-arrow-left2

// -------------------------- XEOKIT Section tool ----------------------
.xeokit-section-counter
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/app/features/bim/ifc_models/xeokit/xeokit-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ export class XeokitServer {
* Gets a manifest for a project.
* @param projectId
* @param done
* @param error
* @param _error
*/
getProject(projectData:any, done:Function, _error:Function) {
getProject(projectId:string, done:(json:unknown) => void, _error:() => void) {
const projectDefinition = this.ifcModels.projects.find((p) => p.id === projectId);
if (projectDefinition === undefined) {
throw new Error(`unknown project id '${projectId}'`);
}

const manifestData = {
id: projectData[0].id,
name: projectData[0].name,
id: projectDefinition.id,
name: projectDefinition.name,
models: this.ifcModels.models,
viewerContent: {
modelsLoaded: this.ifcModels.shown_models,
Expand Down
48 changes: 24 additions & 24 deletions modules/bim/app/contracts/bim/bcf/viewpoints/create_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CreateContract < ::ModelContract
space_boundaries_visible
openings_visible).freeze

COLOR_REGEXP = /#([0-9a-f]{2})?[0-9a-f]{6}/
COLOR_REGEXP = /([0-9a-f]{2})?[0-9a-f]{6}/

WHITELISTED_DIMENSIONS = %w(x y z).freeze

Expand Down Expand Up @@ -114,40 +114,40 @@ def validate_properties
end

def validate_snapshot
return unless (sjson = viewpoint['snapshot'])
return unless (sjson = viewpoint["snapshot"])

errors.add(:json_viewpoint, :snapshot_type_unsupported) unless %w(jpg png).include? sjson['snapshot_type']
errors.add(:json_viewpoint, :snapshot_data_blank) if sjson['snapshot_data'].blank?
errors.add(:json_viewpoint, :snapshot_type_unsupported) unless %w(jpg png).include? sjson["snapshot_type"]
errors.add(:json_viewpoint, :snapshot_data_blank) if sjson["snapshot_data"].blank?
end

def validate_index
return unless (ijson = viewpoint['index'])
return unless (ijson = viewpoint["index"])

errors.add(:json_viewpoint, :index_not_integer) unless ijson.is_a? Integer
end

def validate_orthogonal_camera
return unless (ocjson = viewpoint['orthogonal_camera'])
return unless (ocjson = viewpoint["orthogonal_camera"])

if ocjson.keys != ORTHOGONAL_CAMERA_PROPERTIES ||
ocjson.except('view_to_world_scale').any? { |_, direction| invalid_direction?(direction) } ||
!ocjson['view_to_world_scale'].is_a?(Numeric)
ocjson.except("view_to_world_scale").any? { |_, direction| invalid_direction?(direction) } ||
!ocjson["view_to_world_scale"].is_a?(Numeric)
errors.add(:json_viewpoint, :invalid_orthogonal_camera)
end
end

def validate_perspective_camera
return unless (pcjson = viewpoint['perspective_camera'])
return unless (pcjson = viewpoint["perspective_camera"])

if pcjson.keys != PERSPECTIVE_CAMERA_PROPERTIES ||
pcjson.except('field_of_view').any? { |_, direction| invalid_direction?(direction) } ||
!pcjson['field_of_view'].is_a?(Numeric)
pcjson.except("field_of_view").any? { |_, direction| invalid_direction?(direction) } ||
!pcjson["field_of_view"].is_a?(Numeric)
errors.add(:json_viewpoint, :invalid_perspective_camera)
end
end

def validate_lines
return unless (ljson = viewpoint['lines'])
return unless (ljson = viewpoint["lines"])

if !ljson.is_a?(Array) ||
ljson.any? { |line| invalid_line?(line) }
Expand All @@ -156,7 +156,7 @@ def validate_lines
end

def validate_clipping_planes
return unless (cpjson = viewpoint['clipping_planes'])
return unless (cpjson = viewpoint["clipping_planes"])

if !cpjson.is_a?(Array) ||
cpjson.any? { |cp| invalid_clipping_plane?(cp) }
Expand All @@ -165,11 +165,11 @@ def validate_clipping_planes
end

def validate_bitmaps
errors.add(:json_viewpoint, :bitmaps_not_writable) if viewpoint['bitmaps']
errors.add(:json_viewpoint, :bitmaps_not_writable) if viewpoint["bitmaps"]
end

def validate_components
return unless (cjson = viewpoint['components'])
return unless (cjson = viewpoint["components"])

if !cjson.is_a?(Hash) ||
invalid_components_properties?(cjson)
Expand All @@ -178,16 +178,16 @@ def validate_components
end

def validate_guid
return unless (json_guid = viewpoint['guid'])
return unless (json_guid = viewpoint["guid"])

errors.add(:json_viewpoint, :mismatching_guid) if json_guid != model.uuid
end

def invalid_components_properties?(json)
(json.keys - COMPONENTS_PROPERTIES).any? ||
invalid_visibility?(json['visibility']) ||
invalid_components?(json['selection']) ||
invalid_colorings?(json['coloring'])
invalid_visibility?(json["visibility"]) ||
invalid_components?(json["selection"]) ||
invalid_colorings?(json["coloring"])
end

def invalid_line?(line)
Expand All @@ -208,9 +208,9 @@ def invalid_visibility?(visibility)
visibility.nil? ||
!visibility.is_a?(Hash) ||
(visibility.keys - VISIBILITY_PROPERTIES).any? ||
invalid_default_visibility?(visibility['default_visibility']) ||
invalid_components?(visibility['exceptions']) ||
invalid_view_setup_hints?(visibility['view_setup_hints'])
invalid_default_visibility?(visibility["default_visibility"]) ||
invalid_components?(visibility["exceptions"]) ||
invalid_view_setup_hints?(visibility["view_setup_hints"])
end

def invalid_components?(components)
Expand All @@ -235,8 +235,8 @@ def invalid_component?(component)
def invalid_coloring?(coloring)
!coloring.is_a?(Hash) ||
coloring.keys != COLORING_PROPERTIES ||
invalid_color?(coloring['color']) ||
invalid_components?(coloring['components'])
invalid_color?(coloring["color"]) ||
invalid_components?(coloring["components"])
end

def invalid_color?(color)
Expand Down
Loading
Loading