-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: visually highlight element selected
- Loading branch information
1 parent
69d5edc
commit 86476c5
Showing
5 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as THREE from 'three' | ||
|
||
export class HightlightMesh extends THREE.Mesh { | ||
type = 'HightlightMesh' | ||
createTime: number | ||
constructor(...args: THREE.Mesh['args']) { | ||
super(...args) | ||
this.createTime = Date.now() | ||
} | ||
|
||
onBeforeRender() { | ||
const currentTime = Date.now() | ||
const time = (currentTime - this.createTime) / 1000 | ||
// Pulsing effect parameters | ||
const scaleAmplitude = 0.07 // Amplitude of the scale pulsation | ||
const pulseSpeed = 2.5 // Speed of the pulsation | ||
|
||
// Calculate the scale factor with a sine function for pulsing effect | ||
const scaleFactor = 1 + scaleAmplitude * Math.sin(pulseSpeed * time) | ||
|
||
// Apply the scale factor | ||
this.scale.set(scaleFactor, scaleFactor, scaleFactor) | ||
} | ||
} |