@@ -40,10 +40,12 @@ export function rgba(color: string, opacity: number) {
|
|||||||
return rgbaStr
|
return rgbaStr
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rgbToHex(color:string) {
|
export function rgbToHex(color: string) {
|
||||||
// 去掉字符串中的空格
|
// 去掉字符串中的空格
|
||||||
color = color.replace(/\s+/g, '');
|
color = color.replace(/\s+/g, '');
|
||||||
|
if (isHex(color)) {
|
||||||
|
return color
|
||||||
|
}
|
||||||
// 匹配rgba或rgb格式的字符串
|
// 匹配rgba或rgb格式的字符串
|
||||||
const rgbaMatch = color.match(/^rgba?\((\d+),(\d+),(\d+),?(\d*\.?\d+)?\)$/i);
|
const rgbaMatch = color.match(/^rgba?\((\d+),(\d+),(\d+),?(\d*\.?\d+)?\)$/i);
|
||||||
if (!rgbaMatch) {
|
if (!rgbaMatch) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export function useViewModel() {
|
|||||||
const personPool = ref<IPersonConfig[]>([])
|
const personPool = ref<IPersonConfig[]>([])
|
||||||
const intervalTimer = ref<any>(null)
|
const intervalTimer = ref<any>(null)
|
||||||
const isInitialDone = ref<boolean>(false)
|
const isInitialDone = ref<boolean>(false)
|
||||||
|
const animationFrameId = ref<any>(null)
|
||||||
|
|
||||||
function initThreeJs() {
|
function initThreeJs() {
|
||||||
const felidView = 40
|
const felidView = 40
|
||||||
@@ -214,7 +215,7 @@ export function useViewModel() {
|
|||||||
}
|
}
|
||||||
// 设置自动旋转
|
// 设置自动旋转
|
||||||
// 设置相机位置
|
// 设置相机位置
|
||||||
requestAnimationFrame(animation)
|
animationFrameId.value = requestAnimationFrame(animation)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 旋转的动画
|
* @description: 旋转的动画
|
||||||
@@ -531,6 +532,13 @@ export function useViewModel() {
|
|||||||
* @description: 清理资源,避免内存溢出
|
* @description: 清理资源,避免内存溢出
|
||||||
*/
|
*/
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
// 停止所有Tween动画
|
||||||
|
TWEEN.removeAll()
|
||||||
|
|
||||||
|
// 清理动画循环
|
||||||
|
if ((window as any).cancelAnimationFrame) {
|
||||||
|
(window as any).cancelAnimationFrame(animationFrameId.value)
|
||||||
|
}
|
||||||
clearInterval(intervalTimer.value)
|
clearInterval(intervalTimer.value)
|
||||||
intervalTimer.value = null
|
intervalTimer.value = null
|
||||||
if (scene.value) {
|
if (scene.value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user