Add unit information where it is known.
This commit is contained in:
parent
1c1a74dfe2
commit
599f05ceb7
@ -11,6 +11,7 @@ import { Matrix } from '../geometry/matrix.js';
|
||||
import { Transformation } from '../geometry/transformation.js';
|
||||
import { ColorToMaterialConverter } from './importerutils.js';
|
||||
import { Property, PropertyGroup, PropertyType } from '../model/property.js';
|
||||
import { Unit } from '../model/unit.js';
|
||||
|
||||
export class ImporterBim extends ImporterBase
|
||||
{
|
||||
@ -43,6 +44,8 @@ export class ImporterBim extends ImporterBase
|
||||
|
||||
ImportContent (fileContent, onFinish)
|
||||
{
|
||||
this.model.SetUnit (Unit.Meter);
|
||||
|
||||
let textContent = ArrayBufferToUtf8String (fileContent);
|
||||
let bimJson = null;
|
||||
try {
|
||||
|
||||
@ -5,6 +5,7 @@ import { RGBColorFromFloatComponents } from '../model/color.js';
|
||||
import { ConvertThreeGeometryToMesh } from '../threejs/threeutils.js';
|
||||
import { ImporterBase } from './importerbase.js';
|
||||
import { ColorToMaterialConverter } from './importerutils.js';
|
||||
import { Unit } from '../model/unit.js';
|
||||
|
||||
export class ImporterOcct extends ImporterBase
|
||||
{
|
||||
@ -61,6 +62,10 @@ export class ImporterOcct extends ImporterBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (format === 'step' || format === 'iges') {
|
||||
this.model.SetUnit (Unit.Millimeter);
|
||||
}
|
||||
|
||||
let fileBuffer = new Uint8Array (fileContent);
|
||||
this.worker.postMessage ({
|
||||
format : format,
|
||||
|
||||
@ -60,6 +60,7 @@ import { Property, PropertyGroup, PropertyToString, PropertyType } from './model
|
||||
import { GetTriangleArea, GetTetrahedronSignedVolume, CalculateVolume, CalculateSurfaceArea } from './model/quantities.js';
|
||||
import { TopologyVertex, TopologyEdge, TopologyTriangleEdge, TopologyTriangle, Topology } from './model/topology.js';
|
||||
import { Triangle } from './model/triangle.js';
|
||||
import { Unit } from './model/unit.js';
|
||||
import { ParameterListBuilder, ParameterListParser, CreateUrlBuilder, CreateUrlParser, CreateModelUrlParameters, ParameterConverter } from './parameters/parameterlist.js';
|
||||
import { ModelToThreeConversionParams, ModelToThreeConversionOutput, ThreeConversionStateHandler, ThreeNodeTree, ConvertModelToThreeObject } from './threejs/threeconverter.js';
|
||||
import { ThreeModelLoader } from './threejs/threemodelloader.js';
|
||||
@ -270,6 +271,7 @@ export {
|
||||
TopologyTriangle,
|
||||
Topology,
|
||||
Triangle,
|
||||
Unit,
|
||||
ParameterListBuilder,
|
||||
ParameterListParser,
|
||||
CreateUrlBuilder,
|
||||
|
||||
@ -1,17 +1,29 @@
|
||||
import { MeshInstance, MeshInstanceId } from './meshinstance.js';
|
||||
import { Node } from './node.js';
|
||||
import { ModelObject3D } from './object.js';
|
||||
import { Unit } from './unit.js';
|
||||
|
||||
export class Model extends ModelObject3D
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
super ();
|
||||
this.unit = Unit.Unknown;
|
||||
this.root = new Node ();
|
||||
this.materials = [];
|
||||
this.meshes = [];
|
||||
}
|
||||
|
||||
GetUnit ()
|
||||
{
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
SetUnit (unit)
|
||||
{
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
GetRootNode ()
|
||||
{
|
||||
return this.root;
|
||||
|
||||
9
source/engine/model/unit.js
Normal file
9
source/engine/model/unit.js
Normal file
@ -0,0 +1,9 @@
|
||||
export const Unit =
|
||||
{
|
||||
Unknown : 0,
|
||||
Millimeter : 1,
|
||||
Centimeter : 2,
|
||||
Meter : 3,
|
||||
Inch : 4,
|
||||
Foot : 5
|
||||
};
|
||||
@ -97,9 +97,9 @@ export class Sidebar
|
||||
this.panelSet.Clear ();
|
||||
}
|
||||
|
||||
AddObject3DProperties (object3D)
|
||||
AddObject3DProperties (model, object3D)
|
||||
{
|
||||
this.detailsPanel.AddObject3DProperties (object3D);
|
||||
this.detailsPanel.AddObject3DProperties (model, object3D);
|
||||
}
|
||||
|
||||
AddMaterialProperties (material)
|
||||
|
||||
@ -9,6 +9,24 @@ import { CreateInlineColorCircle } from './utils.js';
|
||||
import { GetFileName, IsUrl } from '../engine/io/fileutils.js';
|
||||
import { MaterialType } from '../engine/model/material.js';
|
||||
import { RGBColorToHexString } from '../engine/model/color.js';
|
||||
import { Unit } from '../engine/model/unit.js';
|
||||
|
||||
function UnitToString (unit)
|
||||
{
|
||||
switch (unit) {
|
||||
case Unit.Millimeter:
|
||||
return 'Millimeter';
|
||||
case Unit.Centimeter:
|
||||
return 'Centimeter';
|
||||
case Unit.Meter:
|
||||
return 'Meter';
|
||||
case Unit.Inch:
|
||||
return 'Inch';
|
||||
case Unit.Foot:
|
||||
return 'Foot';
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
export class SidebarDetailsPanel extends SidebarPanel
|
||||
{
|
||||
@ -27,14 +45,18 @@ export class SidebarDetailsPanel extends SidebarPanel
|
||||
return 'details';
|
||||
}
|
||||
|
||||
AddObject3DProperties (object3D)
|
||||
AddObject3DProperties (model, object3D)
|
||||
{
|
||||
this.Clear ();
|
||||
let table = AddDiv (this.contentDiv, 'ov_property_table');
|
||||
let boundingBox = GetBoundingBox (object3D);
|
||||
let size = SubCoord3D (boundingBox.max, boundingBox.min);
|
||||
let unit = model.GetUnit ();
|
||||
this.AddProperty (table, new Property (PropertyType.Integer, 'Vertices', object3D.VertexCount ()));
|
||||
this.AddProperty (table, new Property (PropertyType.Integer, 'Triangles', object3D.TriangleCount ()));
|
||||
if (unit !== Unit.Unknown) {
|
||||
this.AddProperty (table, new Property (PropertyType.Text, 'Unit', UnitToString (unit)));
|
||||
}
|
||||
this.AddProperty (table, new Property (PropertyType.Number, 'Size X', size.x));
|
||||
this.AddProperty (table, new Property (PropertyType.Number, 'Size Y', size.y));
|
||||
this.AddProperty (table, new Property (PropertyType.Number, 'Size Z', size.z));
|
||||
|
||||
@ -900,11 +900,11 @@ export class Website
|
||||
this.UpdateMeshesSelection ();
|
||||
},
|
||||
onSelectionCleared : () => {
|
||||
this.sidebar.AddObject3DProperties (this.model);
|
||||
this.sidebar.AddObject3DProperties (this.model, this.model);
|
||||
},
|
||||
onMeshSelected : (meshInstanceId) => {
|
||||
let meshInstance = this.model.GetMeshInstance (meshInstanceId);
|
||||
this.sidebar.AddObject3DProperties (meshInstance);
|
||||
this.sidebar.AddObject3DProperties (this.model, meshInstance);
|
||||
},
|
||||
onMaterialSelected : (materialIndex) => {
|
||||
this.sidebar.AddMaterialProperties (this.model.GetMaterial (materialIndex));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user