-
Notifications
You must be signed in to change notification settings - Fork 15
Sroberge/2 0 6 #244
Sroberge/2 0 6 #244
Changes from 3 commits
fb49110
49cf3e4
112b261
2694758
1c35bed
0676026
ad6235d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import { IElement } from 'vim-format' | ||
import { ElementParameter } from 'vim-format/dist/vimHelpers' | ||
import { Vim } from '../../../vim-loader/vim' | ||
import { Viewer } from '../../viewer' | ||
import * as THREE from 'three' | ||
import { IObject, ObjectType } from '../../../vim-loader/objectInterface' | ||
import { SimpleInstanceSubmesh } from '../../../vim-loader/mesh' | ||
import { ObjectAttribute } from '../../../vim-loader/objectAttributes' | ||
import { ColorAttribute } from '../../../vim-loader/colorAttributes' | ||
|
@@ -12,8 +9,8 @@ import { ColorAttribute } from '../../../vim-loader/colorAttributes' | |
* Marker gizmo that display an interactive sphere at a 3D positions | ||
* Marker gizmos are still under development. | ||
*/ | ||
export class GizmoMarker implements IObject { | ||
public readonly type: ObjectType = 'Marker' | ||
export class GizmoMarker { | ||
public readonly type = 'Marker' | ||
private _viewer: Viewer | ||
private _submesh: SimpleInstanceSubmesh | ||
|
||
|
@@ -160,16 +157,21 @@ export class GizmoMarker implements IObject { | |
this._viewer.renderer.needsUpdate = true | ||
} | ||
|
||
getBimElement (): Promise<IElement> { | ||
throw new Error('Method not implemented.') | ||
get size () { | ||
const matrix = new THREE.Matrix4() | ||
this._submesh.mesh.getMatrixAt(this._submesh.index, matrix) | ||
return matrix.elements[0] | ||
Comment on lines
+160
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing the The current implementation of the Also, the method only checks the first element of the matrix (index 0), assuming uniform scaling. If non-uniform scaling is possible or important for your use case, you might need to adjust this implementation. Here's a potential optimization: private _cachedSize: number | null = null;
get size(): number {
if (this._cachedSize === null) {
const matrix = new THREE.Matrix4();
this._submesh.mesh.getMatrixAt(this._submesh.index, matrix);
this._cachedSize = matrix.elements[0];
}
return this._cachedSize;
} Don't forget to invalidate the |
||
} | ||
|
||
getBimParameters (): Promise<ElementParameter[]> { | ||
throw new Error('Method not implemented.') | ||
} | ||
|
||
get elementId (): any { | ||
throw new Error('Method not implemented.') | ||
set size (value: number) { | ||
const matrix = new THREE.Matrix4() | ||
this._submesh.mesh.getMatrixAt(this._submesh.index, matrix) | ||
matrix.elements[0] = value | ||
matrix.elements[5] = value | ||
matrix.elements[10] = value | ||
this._submesh.mesh.setMatrixAt(this._submesh.index, matrix) | ||
this._submesh.mesh.instanceMatrix.needsUpdate = true | ||
this._viewer.renderer.needsUpdate = true | ||
Comment on lines
+166
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using THREE.js methods for matrix manipulation The current implementation directly modifies matrix elements to set the size. While this is efficient, it might be more maintainable and less error-prone to use THREE.js built-in methods for matrix manipulation. Also, the method enforces uniform scaling. If non-uniform scaling is a requirement for your use case, you might need to adjust this implementation. Here's a suggestion using THREE.js methods: set size(value: number) {
const matrix = new THREE.Matrix4();
this._submesh.mesh.getMatrixAt(this._submesh.index, matrix);
const position = new THREE.Vector3();
const quaternion = new THREE.Quaternion();
const scale = new THREE.Vector3();
matrix.decompose(position, quaternion, scale);
scale.setScalar(value);
matrix.compose(position, quaternion, scale);
this._submesh.mesh.setMatrixAt(this._submesh.index, matrix);
this._submesh.mesh.instanceMatrix.needsUpdate = true;
this._viewer.renderer.needsUpdate = true;
this._cachedSize = null; // Invalidate cache if you implement the optimization suggested for the getter
} This approach uses |
||
} | ||
|
||
/** | ||
|
@@ -180,14 +182,4 @@ export class GizmoMarker implements IObject { | |
getBoundingBox (): THREE.Box3 { | ||
return new THREE.Box3().setFromCenterAndSize(this.position.clone(), new THREE.Vector3(1, 1, 1)) | ||
} | ||
|
||
/** | ||
* Retrieves the center position of this object. | ||
* @param {THREE.Vector3} [target=new THREE.Vector3()] Optional parameter specifying where to copy the center position data. | ||
* A new instance is created if none is provided. | ||
* @returns {THREE.Vector3 | undefined} The center position of the object. | ||
*/ | ||
public getCenter (target?: THREE.Vector3): THREE.Vector3 { | ||
return (target ?? new THREE.Vector3()).copy(this.position) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Issues Found: Missing or incorrect
Object3D
imports across multiple files.Several files are using
Object3D
without proper import statements, which may lead to runtime errors or inconsistencies following the import path change incameraMovementSnap.ts
. Please update the import statements in the following files:src/vim-webgl-viewer/selection.ts
src/vim-loader/object3D.ts
src/vim-loader/vim.ts
src/vim-loader/vim.ts
src/vim-loader/vim.ts
src/vim-loader/scene.ts
src/vim-webgl-viewer/gizmos/sectionBox/sectionBoxInputs.ts
docs/api/types/viw_webgl_viewer.ThreeIntersectionList.html
docs/api/classes/viw_webgl_viewer_rendering.RenderScene.html
docs/api/classes/viw_webgl_viewer_rendering.Renderer.html
docs/api/classes/viw_webgl_viewer_gizmos_sectionBox.BoxMesh.html
docs/api/classes/viw_webgl_viewer_gizmos_sectionBox.BoxInputs.html
docs/api/interfaces/vim_loader.IRenderer.html
src/vim-webgl-viewer/raycaster.ts
src/vim-webgl-viewer/environment.ts
src/vim-webgl-viewer/rendering/renderer.ts
src/vim-webgl-viewer/camera/cameraMovementLerp.ts
src/vim-webgl-viewer/rendering/renderScene.ts
src/vim-webgl-viewer/camera/cameraMovement.ts
Please ensure that each file properly imports
Object3D
from the correct path to maintain consistency across the project.🔗 Analysis chain
LGTM! Verify consistent usage across the project.
The import statement for
Object3D
has been correctly updated. This change aligns with the method signature update in thetarget
method.To ensure consistency across the project, please run the following script to check for any other files that might need similar updates:
Adjusted Script for Verifying
Object3D
UsagePlease run the following script to ensure
Object3D
is consistently imported and used across the project:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 442
Script:
Length of output: 114320