@inweb/viewer-three 26.11.0 → 26.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -7
- package/dist/plugins/components/AxesHelperComponent.js.map +1 -0
- package/dist/plugins/components/AxesHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/ExtentsHelperComponent.js.map +1 -0
- package/dist/plugins/components/ExtentsHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/GridHelperComponent.js.map +1 -0
- package/dist/plugins/components/GridHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/LightHelperComponent.js.map +1 -0
- package/dist/plugins/components/LightHelperComponent.module.js.map +1 -0
- package/dist/plugins/components/RoomEnvironmentComponent.js.map +1 -0
- package/dist/plugins/components/RoomEnvironmentComponent.module.js.map +1 -0
- package/dist/plugins/components/StatsPanelComponent.js.map +1 -0
- package/dist/plugins/components/StatsPanelComponent.module.js.map +1 -0
- package/dist/plugins/loaders/GLTFCloudLoader.js.map +1 -0
- package/dist/plugins/loaders/GLTFCloudLoader.module.js.map +1 -0
- package/dist/{extensions → plugins}/loaders/GLTFFileLoader.js +1 -1
- package/dist/plugins/loaders/GLTFFileLoader.js.map +1 -0
- package/dist/plugins/loaders/GLTFFileLoader.min.js +24 -0
- package/dist/plugins/loaders/GLTFFileLoader.module.js.map +1 -0
- package/dist/plugins/loaders/IFCXLoader.js.map +1 -0
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -0
- package/dist/plugins/loaders/PotreeLoader.js.map +1 -0
- package/dist/plugins/loaders/PotreeLoader.module.js.map +1 -0
- package/dist/viewer-three.js +153 -249
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +155 -243
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +1 -1
- package/lib/Viewer/components/SelectionComponent.d.ts +3 -1
- package/lib/Viewer/draggers/MeasureLineDragger.d.ts +1 -7
- package/lib/Viewer/models/IModelImpl.d.ts +0 -4
- package/lib/Viewer/models/ModelImpl.d.ts +0 -4
- package/package.json +11 -11
- package/src/Viewer/Viewer.ts +1 -1
- package/src/Viewer/components/SelectionComponent.ts +30 -5
- package/src/Viewer/draggers/MeasureLineDragger.ts +226 -84
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +16 -14
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +0 -1
- package/src/Viewer/models/IModelImpl.ts +0 -8
- package/src/Viewer/models/ModelImpl.ts +0 -18
- package/src/index-umd.ts +1 -1
- package/dist/extensions/components/AxesHelperComponent.js.map +0 -1
- package/dist/extensions/components/AxesHelperComponent.module.js.map +0 -1
- package/dist/extensions/components/ExtentsHelperComponent.js.map +0 -1
- package/dist/extensions/components/ExtentsHelperComponent.module.js.map +0 -1
- package/dist/extensions/components/GridHelperComponent.js.map +0 -1
- package/dist/extensions/components/GridHelperComponent.module.js.map +0 -1
- package/dist/extensions/components/LightHelperComponent.js.map +0 -1
- package/dist/extensions/components/LightHelperComponent.module.js.map +0 -1
- package/dist/extensions/components/RoomEnvironmentComponent.js.map +0 -1
- package/dist/extensions/components/RoomEnvironmentComponent.module.js.map +0 -1
- package/dist/extensions/components/StatsPanelComponent.js.map +0 -1
- package/dist/extensions/components/StatsPanelComponent.module.js.map +0 -1
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +0 -1
- package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +0 -1
- package/dist/extensions/loaders/GLTFFileLoader.js.map +0 -1
- package/dist/extensions/loaders/GLTFFileLoader.min.js +0 -24
- package/dist/extensions/loaders/GLTFFileLoader.module.js.map +0 -1
- package/dist/extensions/loaders/IFCXLoader.js.map +0 -1
- package/dist/extensions/loaders/IFCXLoader.module.js.map +0 -1
- package/dist/extensions/loaders/PotreeLoader.js.map +0 -1
- package/dist/extensions/loaders/PotreeLoader.module.js.map +0 -1
- package/lib/Viewer/measurement/Snapper.d.ts +0 -15
- package/lib/Viewer/measurement/UnitConverter.d.ts +0 -63
- package/lib/Viewer/measurement/UnitFormatter.d.ts +0 -4
- package/src/Viewer/measurement/Snapper.ts +0 -208
- package/src/Viewer/measurement/UnitConverter.ts +0 -47
- package/src/Viewer/measurement/UnitFormatter.ts +0 -95
- /package/dist/{extensions → plugins}/components/AxesHelperComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/AxesHelperComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/AxesHelperComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/components/ExtentsHelperComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/ExtentsHelperComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/ExtentsHelperComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/components/GridHelperComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/GridHelperComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/GridHelperComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/components/LightHelperComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/LightHelperComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/LightHelperComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/components/RoomEnvironmentComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/RoomEnvironmentComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/RoomEnvironmentComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/components/StatsPanelComponent.js +0 -0
- /package/dist/{extensions → plugins}/components/StatsPanelComponent.min.js +0 -0
- /package/dist/{extensions → plugins}/components/StatsPanelComponent.module.js +0 -0
- /package/dist/{extensions → plugins}/loaders/GLTFCloudLoader.js +0 -0
- /package/dist/{extensions → plugins}/loaders/GLTFCloudLoader.min.js +0 -0
- /package/dist/{extensions → plugins}/loaders/GLTFCloudLoader.module.js +0 -0
- /package/dist/{extensions → plugins}/loaders/GLTFFileLoader.module.js +0 -0
- /package/dist/{extensions → plugins}/loaders/IFCXLoader.js +0 -0
- /package/dist/{extensions → plugins}/loaders/IFCXLoader.min.js +0 -0
- /package/dist/{extensions → plugins}/loaders/IFCXLoader.module.js +0 -0
- /package/dist/{extensions → plugins}/loaders/PotreeLoader.js +0 -0
- /package/dist/{extensions → plugins}/loaders/PotreeLoader.min.js +0 -0
- /package/dist/{extensions → plugins}/loaders/PotreeLoader.module.js +0 -0
- /package/{extensions → plugins}/components/AxesHelperComponent.ts +0 -0
- /package/{extensions → plugins}/components/ExtentsHelperComponent.ts +0 -0
- /package/{extensions → plugins}/components/GridHelperComponent.ts +0 -0
- /package/{extensions → plugins}/components/LightHelperComponent.ts +0 -0
- /package/{extensions → plugins}/components/RoomEnvironmentComponent.ts +0 -0
- /package/{extensions → plugins}/components/StatsPanelComponent.ts +0 -0
- /package/{extensions → plugins}/loaders/GLTFCloudLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/GLTFFileLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/IFCX/IFCXCloudLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/IFCX/IFCXFileLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/IFCX/IFCXLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/IFCX/index.ts +0 -0
- /package/{extensions → plugins}/loaders/IFCX/render.js +0 -0
- /package/{extensions → plugins}/loaders/Potree/PotreeFileLoader.ts +0 -0
- /package/{extensions → plugins}/loaders/Potree/PotreeModelImpl.ts +0 -0
- /package/{extensions → plugins}/loaders/Potree/index.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PotreeLoader.module.js","sources":["../../../extensions/loaders/Potree/PotreeModelImpl.ts","../../../extensions/loaders/Potree/PotreeFileLoader.ts","../../../extensions/loaders/Potree/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { Box3 } from \"three\";\nimport { PointCloudOctree } from \"potree-core\";\nimport { ModelImpl } from \"@inweb/viewer-three\";\n\n// Potree model implementation.\n\nexport class PotreeModelImpl extends ModelImpl {\n public pco: PointCloudOctree;\n\n override getExtents(target: Box3): Box3 {\n return target.union(this.pco.pcoGeometry.boundingBox);\n }\n}\n","///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { Euler, Vector3 } from \"three\";\nimport { PointColorType, PointCloudOctree, PointSizeType, PointShape, Potree } from \"potree-core\";\nimport { Loader, LoadParams, Viewer } from \"@inweb/viewer-three\";\n\nimport { PotreeModelImpl } from \"./PotreeModelImpl\";\n\nexport type PotreeLoadParams = LoadParams & {\n path?: string;\n position?: Vector3;\n rotation?: Euler;\n scale?: Vector3;\n};\n\nexport class PotreeFileLoader extends Loader {\n public viewer: Viewer;\n public potree: Potree;\n public pointClouds: PointCloudOctree[];\n\n constructor(viewer: Viewer) {\n super();\n this.viewer = viewer;\n\n this.potree = new Potree();\n this.pointClouds = [];\n\n this.viewer.addEventListener(\"render\", this.updatePointClouds);\n this.viewer.addEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override dispose() {\n this.pointClouds.forEach((pco) => pco.dispose());\n\n this.viewer.removeEventListener(\"render\", this.updatePointClouds);\n this.viewer.removeEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override isSupport(file: any, format?: string): boolean {\n return typeof file === \"string\" && /(cloud.js|metadata.json)$/i.test(file);\n }\n\n override async load(file: any, format?: string, params: PotreeLoadParams = {}): Promise<this> {\n const path = (params.path || \"\") + file;\n const index = path.lastIndexOf(\"/\");\n const baseUrl = path.slice(0, index + 1);\n const url = path.slice(index + 1);\n\n const pco = await this.potree.loadPointCloud(url, baseUrl);\n pco.material.size = 1.0;\n pco.material.shape = 2;\n pco.material.inputColorEncoding = 1;\n pco.material.outputColorEncoding = 1;\n pco.material.pointColorType = PointColorType.RGB; // RGB | DEPTH | HEIGHT | POINT_INDEX | LOD | CLASSIFICATION\n pco.material.pointSizeType = PointSizeType.ADAPTIVE; // ADAPTIVE | FIXED\n pco.material.shape = PointShape.CIRCLE; // CIRCLE | SQUARE\n\n if (params.position) pco.position.copy(params.position);\n if (params.rotation) pco.rotation.copy(params.rotation);\n if (params.scale) pco.scale.copy(params.scale);\n\n this.pointClouds.push(pco);\n\n const modelImpl = new PotreeModelImpl(pco);\n modelImpl.id = params.modelId || this.extractFileName(file);\n modelImpl.pco = pco;\n\n this.viewer.scene.add(pco);\n this.viewer.models.push(modelImpl);\n\n this.viewer.syncOptions();\n this.viewer.syncOverlay();\n this.viewer.update();\n\n this.viewer.emitEvent({ type: \"databasechunk\", data: pco, file });\n\n return this;\n }\n\n updatePointClouds = () => {\n const result = this.potree.updatePointClouds(this.pointClouds, this.viewer.camera, this.viewer.renderer);\n if (result.exceededMaxLoadsToGPU || result.nodeLoadPromises.length > 0) this.viewer.update();\n };\n}\n","///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { loaders } from \"@inweb/viewer-three\";\n\nimport { PotreeFileLoader } from \"./PotreeFileLoader\";\n\nloaders.registerLoader(\"potree-file\", (viewer: any) => new PotreeFileLoader(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BM,MAAO,eAAgB,SAAQ,SAAS,CAAA;AAGnC,IAAA,UAAU,CAAC,MAAY,EAAA;AAC9B,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC;IACvD;AACD;;ACCK,MAAO,gBAAiB,SAAQ,MAAM,CAAA;AAK1C,IAAA,WAAA,CAAY,MAAc,EAAA;AACxB,QAAA,KAAK,EAAE;QA0DT,IAAA,CAAA,iBAAiB,GAAG,MAAK;YACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAA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AAC,IAAI,CAAC,SAAS,CAAC;AAElC,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;AACzB,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;AACzB,QAAA,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;AAEpB,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AAEjE,QAAA,OAAO,IAAI;IACb;AAMD;;AC7ED,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,MAAW,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Camera, Intersection, Object3D, Vector2, Vector3, WebGLRenderer } from "three";
|
|
2
|
-
export declare class Snapper {
|
|
3
|
-
camera: Camera;
|
|
4
|
-
renderer: WebGLRenderer;
|
|
5
|
-
canvas: HTMLCanvasElement;
|
|
6
|
-
private raycaster;
|
|
7
|
-
private detectRadiusInPixels;
|
|
8
|
-
private edgesCache;
|
|
9
|
-
constructor(camera: Camera, renderer: WebGLRenderer, canvas: HTMLCanvasElement);
|
|
10
|
-
isMobile(): boolean;
|
|
11
|
-
getMousePosition(event: MouseEvent, target: Vector2): Vector2;
|
|
12
|
-
getPointerIntersects(mouse: Vector2, objects: Object3D[]): Array<Intersection<Object3D>>;
|
|
13
|
-
getDetectRadius(point: Vector3): number;
|
|
14
|
-
getSnapPoint(mouse: Vector2, objects: Object3D[]): Vector3;
|
|
15
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export declare const ModelUnits: {
|
|
2
|
-
Meters: {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
scale: number;
|
|
6
|
-
};
|
|
7
|
-
Centimeters: {
|
|
8
|
-
name: string;
|
|
9
|
-
type: string;
|
|
10
|
-
scale: number;
|
|
11
|
-
};
|
|
12
|
-
Millimeters: {
|
|
13
|
-
name: string;
|
|
14
|
-
type: string;
|
|
15
|
-
scale: number;
|
|
16
|
-
};
|
|
17
|
-
Feet: {
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
scale: number;
|
|
21
|
-
};
|
|
22
|
-
Inches: {
|
|
23
|
-
name: string;
|
|
24
|
-
type: string;
|
|
25
|
-
scale: number;
|
|
26
|
-
};
|
|
27
|
-
Yards: {
|
|
28
|
-
name: string;
|
|
29
|
-
type: string;
|
|
30
|
-
scale: number;
|
|
31
|
-
};
|
|
32
|
-
Kilometers: {
|
|
33
|
-
name: string;
|
|
34
|
-
type: string;
|
|
35
|
-
scale: number;
|
|
36
|
-
};
|
|
37
|
-
Miles: {
|
|
38
|
-
name: string;
|
|
39
|
-
type: string;
|
|
40
|
-
scale: number;
|
|
41
|
-
};
|
|
42
|
-
Micrometers: {
|
|
43
|
-
name: string;
|
|
44
|
-
type: string;
|
|
45
|
-
scale: number;
|
|
46
|
-
};
|
|
47
|
-
Mils: {
|
|
48
|
-
name: string;
|
|
49
|
-
type: string;
|
|
50
|
-
scale: number;
|
|
51
|
-
};
|
|
52
|
-
MicroInches: {
|
|
53
|
-
name: string;
|
|
54
|
-
type: string;
|
|
55
|
-
scale: number;
|
|
56
|
-
};
|
|
57
|
-
Default: {
|
|
58
|
-
name: string;
|
|
59
|
-
type: string;
|
|
60
|
-
scale: number;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export declare function convertUnits(fromUnits: string, toUnits: string, distance: number): number;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function getDisplayUnit(units: string): any;
|
|
2
|
-
export declare function calculatePrecision(value: number): number;
|
|
3
|
-
export declare function calculateDistance(precision: any): number;
|
|
4
|
-
export declare function formatDistance(distance: number, units: string, precision?: any): string;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
-
// All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This software and its documentation and related materials are owned by
|
|
6
|
-
// the Alliance. The software may only be incorporated into application
|
|
7
|
-
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
-
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
-
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
-
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
-
// protected by copyright law and international treaty provisions. Application
|
|
12
|
-
// programs incorporating this software must include the following statement
|
|
13
|
-
// with their copyright notices:
|
|
14
|
-
//
|
|
15
|
-
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
-
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
-
// All rights reserved.
|
|
19
|
-
//
|
|
20
|
-
// By use of this software, its documentation or related materials, you
|
|
21
|
-
// acknowledge and accept the above terms.
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
Camera,
|
|
26
|
-
EdgesGeometry,
|
|
27
|
-
Intersection,
|
|
28
|
-
Line3,
|
|
29
|
-
MathUtils,
|
|
30
|
-
Object3D,
|
|
31
|
-
Plane,
|
|
32
|
-
Raycaster,
|
|
33
|
-
Vector2,
|
|
34
|
-
Vector3,
|
|
35
|
-
WebGLRenderer,
|
|
36
|
-
} from "three";
|
|
37
|
-
|
|
38
|
-
const DESKTOP_SNAP_DISTANCE = 10;
|
|
39
|
-
const MOBILE_SNAP_DISTANCE = 50;
|
|
40
|
-
|
|
41
|
-
const _vertex = new Vector3();
|
|
42
|
-
const _start = new Vector3();
|
|
43
|
-
const _end = new Vector3();
|
|
44
|
-
const _line = new Line3();
|
|
45
|
-
const _center = new Vector3();
|
|
46
|
-
const _projection = new Vector3();
|
|
47
|
-
|
|
48
|
-
export class Snapper {
|
|
49
|
-
public camera: Camera;
|
|
50
|
-
public renderer: WebGLRenderer;
|
|
51
|
-
public canvas: HTMLCanvasElement;
|
|
52
|
-
private raycaster: Raycaster;
|
|
53
|
-
private detectRadiusInPixels: number;
|
|
54
|
-
private edgesCache: WeakMap<any, EdgesGeometry>;
|
|
55
|
-
|
|
56
|
-
constructor(camera: Camera, renderer: WebGLRenderer, canvas: HTMLCanvasElement) {
|
|
57
|
-
this.camera = camera;
|
|
58
|
-
this.renderer = renderer;
|
|
59
|
-
this.canvas = canvas;
|
|
60
|
-
|
|
61
|
-
this.raycaster = new Raycaster();
|
|
62
|
-
this.detectRadiusInPixels = this.isMobile() ? MOBILE_SNAP_DISTANCE : DESKTOP_SNAP_DISTANCE;
|
|
63
|
-
this.edgesCache = new WeakMap();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
isMobile(): boolean {
|
|
67
|
-
if (typeof navigator === "undefined") return false;
|
|
68
|
-
|
|
69
|
-
// ===================== AI-CODE-START ======================
|
|
70
|
-
// Source: Claude Sonnet 4
|
|
71
|
-
// Date: 2025-09-09
|
|
72
|
-
// Reviewer: roman.mochalov@opendesign.com
|
|
73
|
-
// Issue: CLOUD-5799
|
|
74
|
-
|
|
75
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
|
|
76
|
-
|
|
77
|
-
// ===================== AI-CODE-END ======================
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
getMousePosition(event: MouseEvent, target: Vector2): Vector2 {
|
|
81
|
-
return target.set(event.clientX, event.clientY);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getPointerIntersects(mouse: Vector2, objects: Object3D[]): Array<Intersection<Object3D>> {
|
|
85
|
-
const rect = this.canvas.getBoundingClientRect();
|
|
86
|
-
const x = ((mouse.x - rect.left) / rect.width) * 2 - 1;
|
|
87
|
-
const y = (-(mouse.y - rect.top) / rect.height) * 2 + 1;
|
|
88
|
-
|
|
89
|
-
const coords = new Vector2(x, y);
|
|
90
|
-
this.raycaster.setFromCamera(coords, this.camera);
|
|
91
|
-
|
|
92
|
-
this.raycaster.params = {
|
|
93
|
-
Mesh: {},
|
|
94
|
-
Line: { threshold: 0.05 },
|
|
95
|
-
Line2: { threshold: 0.05 },
|
|
96
|
-
LOD: {},
|
|
97
|
-
Points: { threshold: 0.01 },
|
|
98
|
-
Sprite: {},
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
let intersects = this.raycaster.intersectObjects(objects, false);
|
|
102
|
-
|
|
103
|
-
(this.renderer.clippingPlanes || []).forEach((plane: Plane) => {
|
|
104
|
-
intersects = intersects.filter((intersect) => plane.distanceToPoint(intersect.point) >= 0);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return intersects;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
getDetectRadius(point: Vector3): number {
|
|
111
|
-
const camera: any = this.camera;
|
|
112
|
-
|
|
113
|
-
// ===================== AI-CODE-START ======================
|
|
114
|
-
// Source: Gemini 2.5 Pro
|
|
115
|
-
// Date: 2025-08-27
|
|
116
|
-
// Reviewer: roman.mochalov@opendesign.com
|
|
117
|
-
// Issue: CLOUD-5799
|
|
118
|
-
// Notes: Originally AI-generated, modified manually
|
|
119
|
-
|
|
120
|
-
if (camera.isOrthographicCamera) {
|
|
121
|
-
const fieldHeight = (camera.top - camera.bottom) / camera.zoom;
|
|
122
|
-
|
|
123
|
-
const canvasHeight = this.canvas.height;
|
|
124
|
-
const worldUnitsPerPixel = fieldHeight / canvasHeight;
|
|
125
|
-
|
|
126
|
-
return this.detectRadiusInPixels * worldUnitsPerPixel;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (camera.isPerspectiveCamera) {
|
|
130
|
-
const distance = camera.position.distanceTo(point);
|
|
131
|
-
const fieldHeight = 2 * Math.tan(MathUtils.degToRad(camera.fov * 0.5)) * distance;
|
|
132
|
-
|
|
133
|
-
const canvasHeight = this.canvas.height;
|
|
134
|
-
const worldUnitsPerPixel = fieldHeight / canvasHeight;
|
|
135
|
-
|
|
136
|
-
return this.detectRadiusInPixels * worldUnitsPerPixel;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// ===================== AI-CODE-END ======================
|
|
140
|
-
|
|
141
|
-
return 0.1;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
getSnapPoint(mouse: Vector2, objects: Object3D[]): Vector3 {
|
|
145
|
-
const intersections = this.getPointerIntersects(mouse, objects);
|
|
146
|
-
if (intersections.length === 0) return undefined;
|
|
147
|
-
|
|
148
|
-
// ===================== AI-CODE-START ======================
|
|
149
|
-
// Source: Gemini 2.5 Pro
|
|
150
|
-
// Date: 2025-08-20
|
|
151
|
-
// Reviewer: roman.mochalov@opendesign.com
|
|
152
|
-
// Issue: CLOUD-5799
|
|
153
|
-
// Notes: Originally AI-generated, modified manually
|
|
154
|
-
|
|
155
|
-
const object: any = intersections[0].object;
|
|
156
|
-
const intersectionPoint = intersections[0].point;
|
|
157
|
-
const localPoint = object.worldToLocal(intersectionPoint.clone());
|
|
158
|
-
|
|
159
|
-
let snapPoint: Vector3;
|
|
160
|
-
let snapDistance = this.getDetectRadius(intersectionPoint);
|
|
161
|
-
|
|
162
|
-
const geometry = object.geometry;
|
|
163
|
-
|
|
164
|
-
const positions = geometry.attributes.position.array;
|
|
165
|
-
for (let i = 0; i < positions.length; i += 3) {
|
|
166
|
-
_vertex.set(positions[i], positions[i + 1], positions[i + 2]);
|
|
167
|
-
const distance = _vertex.distanceTo(localPoint);
|
|
168
|
-
if (distance < snapDistance) {
|
|
169
|
-
snapDistance = distance;
|
|
170
|
-
snapPoint = _vertex.clone();
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (snapPoint) return object.localToWorld(snapPoint);
|
|
174
|
-
|
|
175
|
-
let edges = this.edgesCache.get(geometry);
|
|
176
|
-
if (!edges) {
|
|
177
|
-
edges = new EdgesGeometry(geometry);
|
|
178
|
-
this.edgesCache.set(geometry, edges);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const edgePositions = edges.attributes.position.array;
|
|
182
|
-
for (let i = 0; i < edgePositions.length; i += 6) {
|
|
183
|
-
_start.set(edgePositions[i], edgePositions[i + 1], edgePositions[i + 2]);
|
|
184
|
-
_end.set(edgePositions[i + 3], edgePositions[i + 4], edgePositions[i + 5]);
|
|
185
|
-
_line.set(_start, _end);
|
|
186
|
-
|
|
187
|
-
_line.getCenter(_center);
|
|
188
|
-
const centerDistance = _center.distanceTo(localPoint);
|
|
189
|
-
if (centerDistance < snapDistance) {
|
|
190
|
-
snapDistance = centerDistance;
|
|
191
|
-
snapPoint = _center.clone();
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
_line.closestPointToPoint(localPoint, true, _projection);
|
|
196
|
-
const lineDistance = _projection.distanceTo(localPoint);
|
|
197
|
-
if (lineDistance < snapDistance) {
|
|
198
|
-
snapDistance = lineDistance;
|
|
199
|
-
snapPoint = _projection.clone();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (snapPoint) return object.localToWorld(snapPoint);
|
|
203
|
-
|
|
204
|
-
// ===================== AI-CODE-END ======================
|
|
205
|
-
|
|
206
|
-
return intersectionPoint.clone();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
-
// All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This software and its documentation and related materials are owned by
|
|
6
|
-
// the Alliance. The software may only be incorporated into application
|
|
7
|
-
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
-
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
-
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
-
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
-
// protected by copyright law and international treaty provisions. Application
|
|
12
|
-
// programs incorporating this software must include the following statement
|
|
13
|
-
// with their copyright notices:
|
|
14
|
-
//
|
|
15
|
-
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
-
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
-
// All rights reserved.
|
|
19
|
-
//
|
|
20
|
-
// By use of this software, its documentation or related materials, you
|
|
21
|
-
// acknowledge and accept the above terms.
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
// Model units for the user to choose from.
|
|
25
|
-
|
|
26
|
-
export const ModelUnits = {
|
|
27
|
-
Meters: { name: "Meters", type: "m", scale: 1.0 },
|
|
28
|
-
Centimeters: { name: "Centimeters", type: "cm", scale: 0.01 },
|
|
29
|
-
Millimeters: { name: "Millimeters", type: "mm", scale: 0.001 },
|
|
30
|
-
Feet: { name: "Feet", type: "ft", scale: 0.3048 },
|
|
31
|
-
Inches: { name: "Inches", type: "in", scale: 0.0254 },
|
|
32
|
-
Yards: { name: "Yards", type: "yd", scale: 0.9144 },
|
|
33
|
-
Kilometers: { name: "Kilometers", type: "km", scale: 1000.0 },
|
|
34
|
-
Miles: { name: "Miles", type: "mi", scale: 1609.344 },
|
|
35
|
-
Micrometers: { name: "Micrometers", type: "µm", scale: 0.000001 },
|
|
36
|
-
Mils: { name: "Mils", type: "mil", scale: 0.0000254 },
|
|
37
|
-
MicroInches: { name: "Micro-inches", type: "µin", scale: 0.0000000254 },
|
|
38
|
-
Default: { name: "File units", type: "unit", scale: 1.0 },
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Convert distance from unit to unit.
|
|
42
|
-
|
|
43
|
-
export function convertUnits(fromUnits: string, toUnits: string, distance: number) {
|
|
44
|
-
const fromFactor = 1 / (ModelUnits[fromUnits] || ModelUnits.Default).scale;
|
|
45
|
-
const toFactor = (ModelUnits[toUnits] || ModelUnits.Default).scale || 1;
|
|
46
|
-
return distance * fromFactor * toFactor;
|
|
47
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
-
// All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This software and its documentation and related materials are owned by
|
|
6
|
-
// the Alliance. The software may only be incorporated into application
|
|
7
|
-
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
-
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
-
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
-
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
-
// protected by copyright law and international treaty provisions. Application
|
|
12
|
-
// programs incorporating this software must include the following statement
|
|
13
|
-
// with their copyright notices:
|
|
14
|
-
//
|
|
15
|
-
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
-
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
-
// All rights reserved.
|
|
19
|
-
//
|
|
20
|
-
// By use of this software, its documentation or related materials, you
|
|
21
|
-
// acknowledge and accept the above terms.
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
import { ModelUnits } from "./UnitConverter";
|
|
25
|
-
|
|
26
|
-
// Returns a standard string representation of the display unit.
|
|
27
|
-
|
|
28
|
-
export function getDisplayUnit(units: string) {
|
|
29
|
-
return (ModelUnits[units] || ModelUnits.Default).type;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ===================== AI-CODE-START ======================
|
|
33
|
-
// Source: Claude Sonnet 4.5
|
|
34
|
-
// Date: 2025-10-08
|
|
35
|
-
// Reviewer: roman.mochalov@opendesign.com
|
|
36
|
-
// Issue: CLOUD-5963
|
|
37
|
-
|
|
38
|
-
// Calculates recommended precision for small values (|value| < 1) to avoid showing "0.00".
|
|
39
|
-
|
|
40
|
-
export function calculatePrecision(value: number) {
|
|
41
|
-
const distance = Math.abs(value);
|
|
42
|
-
|
|
43
|
-
if (distance >= 1000) return 0;
|
|
44
|
-
if (distance >= 10) return 1;
|
|
45
|
-
if (distance >= 0.1) return 2;
|
|
46
|
-
if (distance >= 0.001) return 3;
|
|
47
|
-
|
|
48
|
-
return distance > 0 ? Math.floor(-Math.log10(distance)) + 1 : 2;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Calculates the minimal distance for the sepecified precision.
|
|
52
|
-
|
|
53
|
-
export function calculateDistance(precision: any): number {
|
|
54
|
-
let digits: number;
|
|
55
|
-
|
|
56
|
-
if (precision === "Auto") digits = 2;
|
|
57
|
-
else if (Number.isFinite(precision)) digits = precision;
|
|
58
|
-
else digits = parseFloat(precision);
|
|
59
|
-
|
|
60
|
-
if (!Number.isFinite(digits) || digits < 0) digits = 2;
|
|
61
|
-
else if (digits > 10) digits = 10;
|
|
62
|
-
|
|
63
|
-
return Math.pow(10, -digits);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ===================== AI-CODE-END ======================
|
|
67
|
-
|
|
68
|
-
// Formats a distance with units.
|
|
69
|
-
|
|
70
|
-
function formatNumber(distance: number, digits: number, precision: any) {
|
|
71
|
-
let result = distance.toFixed(digits);
|
|
72
|
-
if (precision === "Auto") result = result.replace(/\.0+$/, "").replace(/\.$/, "");
|
|
73
|
-
if (+result !== distance) result = "~ " + result;
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function formatDistance(distance: number, units: string, precision: any = 2) {
|
|
78
|
-
let digits: number;
|
|
79
|
-
|
|
80
|
-
if (precision === "Auto") digits = calculatePrecision(distance);
|
|
81
|
-
else if (Number.isFinite(precision)) digits = precision;
|
|
82
|
-
else digits = parseFloat(precision);
|
|
83
|
-
|
|
84
|
-
if (!Number.isFinite(digits)) digits = 2;
|
|
85
|
-
else if (digits < 0) digits = 0;
|
|
86
|
-
else if (digits > 10) digits = 10;
|
|
87
|
-
|
|
88
|
-
if (ModelUnits[units]) {
|
|
89
|
-
return formatNumber(distance, digits, precision) + " " + ModelUnits[units].type;
|
|
90
|
-
} else if (units) {
|
|
91
|
-
return formatNumber(distance, digits, precision) + " " + units;
|
|
92
|
-
} else {
|
|
93
|
-
return formatNumber(distance, digits, precision);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|